diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2013-05-08 14:43:49 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2013-05-08 14:43:49 +0000 |
commit | 9578a3ecfc35a264ede1135033398e2a77a6cad6 (patch) | |
tree | 5e4cb064cb5c58ec85e5a9705ae92226b18bddd3 /lib/sanitizer_common/sanitizer_syscall_generic.inc | |
parent | 33280bba681b7bb683be01749aaba70dc06ffb6c (diff) |
[nolibc] Change internal syscall API to remove reliance on libc's errno.
This change moves to a model where the error value of a system call is
potentially contained in the return value itself rather than being
implicit in errno. The helper function internal_iserror can be used
to extract the error value from a return value. On platforms other
than Linux/x86_64 this still uses errno, but other platforms are free
to port their error handling to this new model.
Differential Revision: http://llvm-reviews.chandlerc.com/D756
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@181436 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_syscall_generic.inc')
-rw-r--r-- | lib/sanitizer_common/sanitizer_syscall_generic.inc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_syscall_generic.inc b/lib/sanitizer_common/sanitizer_syscall_generic.inc new file mode 100644 index 000000000..aac20a5f2 --- /dev/null +++ b/lib/sanitizer_common/sanitizer_syscall_generic.inc @@ -0,0 +1,24 @@ +//===-- sanitizer_syscall_generic.inc ---------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Generic implementations of internal_syscall and internal_iserror. +// +//===----------------------------------------------------------------------===// + +#define internal_syscall syscall + +bool internal_iserror(uptr retval, int *rverrno) { + if (retval == (uptr)-1) { + if (rverrno) + *rverrno = errno; + return true; + } else { + return false; + } +} |