summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2012-11-30 11:58:57 -0800
committerElliott Hughes <enh@google.com>2012-11-30 12:05:18 -0800
commit4a9e837840fda3aaea48aeba85c7c7a8782d2586 (patch)
tree3d74d674ea208fda1676d51bc9d6feecc2cc6bc9
parent97b70b2bda47af46adf58dfde61050357114aa1f (diff)
downloadbionic-4a9e837840fda3aaea48aeba85c7c7a8782d2586.zip
bionic-4a9e837840fda3aaea48aeba85c7c7a8782d2586.tar.gz
bionic-4a9e837840fda3aaea48aeba85c7c7a8782d2586.tar.bz2
Reduce the exposure of the __set_errno implementation detail.
Change-Id: I395e1b46a9491e34fc53e71853e932ea90b3d1cc
-rw-r--r--libc/Android.mk2
-rw-r--r--libc/bionic/__set_errno.cpp (renamed from libc/bionic/__set_errno.c)40
-rw-r--r--libc/bionic/pthread.c1
-rw-r--r--libc/include/errno.h4
4 files changed, 19 insertions, 28 deletions
diff --git a/libc/Android.mk b/libc/Android.mk
index 92bca4c..dc2b331 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -211,7 +211,6 @@ libc_common_src_files := \
bionic/semaphore.c \
bionic/send.c \
bionic/setegid.c \
- bionic/__set_errno.c \
bionic/seteuid.c \
bionic/setpgrp.c \
bionic/setresuid.c \
@@ -283,6 +282,7 @@ libc_bionic_src_files := \
bionic/__memcpy_chk.cpp \
bionic/__memmove_chk.cpp \
bionic/__memset_chk.cpp \
+ bionic/__set_errno.cpp \
bionic/setlocale.cpp \
bionic/__strcat_chk.cpp \
bionic/__strcpy_chk.cpp \
diff --git a/libc/bionic/__set_errno.c b/libc/bionic/__set_errno.cpp
index 163d404..5b249c8 100644
--- a/libc/bionic/__set_errno.c
+++ b/libc/bionic/__set_errno.cpp
@@ -28,29 +28,25 @@
#include <errno.h>
+// These functions are called from our assembler syscall stubs.
+// C/C++ code should just assign 'errno' instead.
-int __set_errno(int n)
-{
- errno = n;
- return -1;
+// TODO: should be __LIBC_HIDDEN__, but already exported by NDK :-(
+// TODO: this isn't used on ARM.
+extern "C" int __set_errno(int n) {
+ errno = n;
+ return -1;
}
-/*
- * this function is called from syscall stubs,
- * (tail-called in the case of 0-4 arg versions)
- */
-
-__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;
- }
+// 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;
+ }
}
diff --git a/libc/bionic/pthread.c b/libc/bionic/pthread.c
index d8d0d05..b685f2d 100644
--- a/libc/bionic/pthread.c
+++ b/libc/bionic/pthread.c
@@ -59,7 +59,6 @@ extern void pthread_debug_mutex_unlock_check(pthread_mutex_t *mutex);
extern int __pthread_clone(int (*fn)(void*), void *child_stack, int flags, void *arg);
extern void _exit_with_stack_teardown(void * stackBase, int stackSize, int retCode);
extern void _exit_thread(int retCode);
-extern int __set_errno(int);
int __futex_wake_ex(volatile void *ftx, int pshared, int val)
{
diff --git a/libc/include/errno.h b/libc/include/errno.h
index e1b15c0..2e5ce5f 100644
--- a/libc/include/errno.h
+++ b/libc/include/errno.h
@@ -40,10 +40,6 @@ __BEGIN_DECLS
#define ENOTSUP EOPNOTSUPP
#endif
-/* internal function that should *only* be called from system calls */
-/* use errno = xxxx instead in C code */
-extern int __set_errno(int error);
-
/* internal function returning the address of the thread-specific errno */
extern volatile int* __errno(void);