35 lines · cpp
1//===-- Linux implementation of syscall -----------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "src/unistd/syscall.h"10 11#include "src/__support/OSUtil/syscall.h" // For internal syscall function.12#include "src/__support/common.h"13 14#include "src/__support/libc_errno.h"15#include "src/__support/macros/config.h"16#include <stdarg.h>17 18namespace LIBC_NAMESPACE_DECL {19 20LLVM_LIBC_FUNCTION(long, __llvm_libc_syscall,21 (long number, long arg1, long arg2, long arg3, long arg4,22 long arg5, long arg6)) {23 long ret = LIBC_NAMESPACE::syscall_impl<long>(number, arg1, arg2, arg3, arg4,24 arg5, arg6);25 // Syscalls may return large positive values that overflow, but will never26 // return values between -4096 and -127 if (static_cast<unsigned long>(ret) > -4096UL) {28 libc_errno = static_cast<int>(-ret);29 return -1;30 }31 return ret;32}33 34} // namespace LIBC_NAMESPACE_DECL35