diff --git a/lib/libsys/Makefile b/lib/libsys/Makefile --- a/lib/libsys/Makefile +++ b/lib/libsys/Makefile @@ -25,6 +25,8 @@ INCS= libsys.h _libsys.h +CFLAGS+=-DLIBSYS + CFLAGS+=-I${LIBSYS_SRCTOP}/include -I${LIBC_SRCTOP}/include CFLAGS+=-I${LIBSYS_SRCTOP}/${LIBC_ARCH} CFLAGS+=-I${LIBC_SRCTOP}/${LIBC_ARCH} diff --git a/lib/libsys/Symbol.map b/lib/libsys/Symbol.map --- a/lib/libsys/Symbol.map +++ b/lib/libsys/Symbol.map @@ -1,5 +1,6 @@ FBSDprivate_1.0 { __elf_aux_vector; + __libsys_errno; __getosreldate; __libsys_interposing_slot; __realpathat; diff --git a/lib/libsys/Symbol.sys.map b/lib/libsys/Symbol.sys.map --- a/lib/libsys/Symbol.sys.map +++ b/lib/libsys/Symbol.sys.map @@ -72,7 +72,6 @@ extattr_set_file; extattr_set_link; extattrctl; - errno; fchdir; fchflags; fchmod; diff --git a/lib/libsys/__error.c b/lib/libsys/__error.c --- a/lib/libsys/__error.c +++ b/lib/libsys/__error.c @@ -31,13 +31,15 @@ #include "libc_private.h" -int errno; +int __libsys_errno; +#ifdef LIBSYS +__sym_compat(errno, __libsys_errno, FBSD_1.0); +#endif static int * __error_unthreaded(void) { - - return (&errno); + return (&__libsys_errno); } static int *(*__error_selector)(void) = __error_unthreaded; @@ -45,13 +47,11 @@ void __set_error_selector(int *(*arg)(void)) { - __error_selector = arg; } int * __error(void) { - return (__error_selector()); } diff --git a/lib/libthr/sys/thr_error.c b/lib/libthr/sys/thr_error.c --- a/lib/libthr/sys/thr_error.c +++ b/lib/libthr/sys/thr_error.c @@ -39,8 +39,7 @@ #include "libc_private.h" #include "thr_private.h" -#undef errno -extern int errno; +extern int __libsys_errno; __weak_reference(__error_threaded, __error); int * @@ -53,5 +52,5 @@ if (curthread != NULL && curthread != _thr_initial) return (&curthread->error); } - return (&errno); + return (&__libsys_errno); } diff --git a/lib/libthr/thread/thr_rtld.c b/lib/libthr/thread/thr_rtld.c --- a/lib/libthr/thread/thr_rtld.c +++ b/lib/libthr/thread/thr_rtld.c @@ -39,8 +39,7 @@ #include "rtld_lock.h" #include "thr_private.h" -#undef errno -extern int errno; +extern int __libsys_errno; static int _thr_rtld_clr_flag(int); static void *_thr_rtld_lock_create(void); @@ -96,14 +95,14 @@ if (curthread != _thr_initial) \ errsave = curthread->error; \ else \ - errsave = errno; \ + errsave = __libsys_errno; \ } #define RESTORE_ERRNO() { \ if (curthread != _thr_initial) \ curthread->error = errsave; \ else \ - errno = errsave; \ + __libsys_errno = errsave; \ } static void