diff options
author | Elliott Hughes <enh@google.com> | 2013-03-12 11:55:45 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2013-03-12 11:55:45 -0700 |
commit | cb2069bf69b14f0e76593e1ec4d1deb6fa15232c (patch) | |
tree | 2aa24aece4d7a3b1d380f2edafb14967da9d1c0b | |
parent | f21aa3b61ebc6b1a7c34265699f40bd9b5af7952 (diff) | |
download | android_bionic-cb2069bf69b14f0e76593e1ec4d1deb6fa15232c.tar.gz android_bionic-cb2069bf69b14f0e76593e1ec4d1deb6fa15232c.tar.bz2 android_bionic-cb2069bf69b14f0e76593e1ec4d1deb6fa15232c.zip |
Support large errno values on ARM.
Bug: http://code.google.com/p/android/issues/detail?id=53104
Change-Id: Ic6c40be2dc50f0644a3d8b09ceae59c38f2d5b53
-rw-r--r-- | libc/bionic/__set_errno.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/libc/bionic/__set_errno.cpp b/libc/bionic/__set_errno.cpp index 5b249c8bb..c69ca8707 100644 --- a/libc/bionic/__set_errno.cpp +++ b/libc/bionic/__set_errno.cpp @@ -27,6 +27,9 @@ */ #include <errno.h> +#include <linux/err.h> + +#define unlikely(x) __builtin_expect((x), false) // Used but not defined by <linux/err.h>. // These functions are called from our assembler syscall stubs. // C/C++ code should just assign 'errno' instead. @@ -39,14 +42,10 @@ extern "C" int __set_errno(int n) { } // TODO: this is only used on ARM, but is exported by NDK on all platforms :-( -extern "C" __LIBC_HIDDEN__ int __set_syscall_errno(int n) { - // Some syscalls, mmap() for example, have valid return - // values that are "negative". Since errno values are not - // greater than 131 on Linux, we will just consider - // anything significantly out of range as not-an-error. - if(n > -256) { - return __set_errno(-n); - } else { - return n; +extern "C" __LIBC_HIDDEN__ int __set_syscall_errno(unsigned long n) { + if (IS_ERR_VALUE(n)) { + errno = -n; + return -1; } + return n; } |