diff options
author | deischen <deischen@FreeBSD.org> | 2001-01-24 13:01:12 +0000 |
---|---|---|
committer | deischen <deischen@FreeBSD.org> | 2001-01-24 13:01:12 +0000 |
commit | 1635c221b7b2678beeeb2b5fa728edd7c8c3735b (patch) | |
tree | d7d4f61b9e319a781a335702fe846592726c22b9 /lib/libc/amd64 | |
parent | 08685e9e9fd9de1e8dc51cada55659344adaf0cc (diff) | |
download | FreeBSD-src-1635c221b7b2678beeeb2b5fa728edd7c8c3735b.zip FreeBSD-src-1635c221b7b2678beeeb2b5fa728edd7c8c3735b.tar.gz |
Remove _THREAD_SAFE and make libc thread-safe by default by
adding (weak definitions to) stubs for some of the pthread
functions. If the threads library is linked in, the real
pthread functions will pulled in.
Use the following convention for system calls wrapped by the
threads library:
__sys_foo - actual system call
_foo - weak definition to __sys_foo
foo - weak definition to __sys_foo
Change all libc uses of system calls wrapped by the threads
library from foo to _foo. In order to define the prototypes
for _foo(), we introduce namespace.h and un-namespace.h
(suggested by bde). All files that need to reference these
system calls, should include namespace.h before any standard
includes, then include un-namespace.h after the standard
includes and before any local includes. <db.h> is an exception
and shouldn't be included in between namespace.h and
un-namespace.h namespace.h will define foo to _foo, and
un-namespace.h will undefine foo.
Try to eliminate some of the recursive calls to MT-safe
functions in libc/stdio in preparation for adding a mutex
to FILE. We have recursive mutexes, but would like to avoid
using them if possible.
Remove uneeded includes of <errno.h> from a few files.
Add $FreeBSD$ to a few files in order to pass commitprep.
Approved by: -arch
Diffstat (limited to 'lib/libc/amd64')
-rw-r--r-- | lib/libc/amd64/SYS.h | 31 | ||||
-rw-r--r-- | lib/libc/amd64/gen/_setjmp.S | 7 | ||||
-rw-r--r-- | lib/libc/amd64/gen/setjmp.S | 18 | ||||
-rw-r--r-- | lib/libc/amd64/gen/sigsetjmp.S | 21 | ||||
-rw-r--r-- | lib/libc/amd64/sys/setlogin.S | 2 | ||||
-rw-r--r-- | lib/libc/amd64/sys/vfork.S | 11 |
6 files changed, 30 insertions, 60 deletions
diff --git a/lib/libc/amd64/SYS.h b/lib/libc/amd64/SYS.h index cadbecb..2d58562 100644 --- a/lib/libc/amd64/SYS.h +++ b/lib/libc/amd64/SYS.h @@ -61,31 +61,28 @@ * Design note: * * The macros PSYSCALL() and PRSYSCALL() are intended for use where a - * syscall needs to be renamed in the threaded library. When building - * a normal library, they default to the traditional SYSCALL() and - * RSYSCALL(). This avoids the need to #ifdef _THREAD_SAFE everywhere - * that the renamed function needs to be called. + * syscall needs to be renamed in the threaded library. */ -#ifdef _THREAD_SAFE /* - * For the thread_safe versions, we prepend _thread_sys_ to the function + * For the thread_safe versions, we prepend __sys_ to the function * name so that the 'C' wrapper can go around the real name. */ #define PSYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \ - ENTRY(__CONCAT(_thread_sys_,x)); \ + ENTRY(__CONCAT(__sys_,x)); \ + .weak CNAME(x); \ + .set CNAME(x),CNAME(__CONCAT(__sys_,x)); \ + .weak CNAME(__CONCAT(_,x)); \ + .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \ lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b + #define PRSYSCALL(x) PSYSCALL(x); ret -#define PPSEUDO(x,y) ENTRY(__CONCAT(_thread_sys_,x)); \ + +#define PPSEUDO(x,y) ENTRY(__CONCAT(__sys_,x)); \ + .weak CNAME(x); \ + .set CNAME(x),CNAME(__CONCAT(__sys_,x)); \ + .weak CNAME(__CONCAT(_,x)); \ + .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \ lea __CONCAT(SYS_,y), %eax; KERNCALL; ret -#else -/* - * The non-threaded library defaults to traditional syscalls where - * the function name matches the syscall name. - */ -#define PSYSCALL(x) SYSCALL(x) -#define PRSYSCALL(x) RSYSCALL(x) -#define PPSEUDO(x,y) PSEUDO(x,y) -#endif #ifdef __ELF__ #define KERNCALL int $0x80 /* Faster */ diff --git a/lib/libc/amd64/gen/_setjmp.S b/lib/libc/amd64/gen/_setjmp.S index 9c66308..5932fee 100644 --- a/lib/libc/amd64/gen/_setjmp.S +++ b/lib/libc/amd64/gen/_setjmp.S @@ -66,12 +66,9 @@ ENTRY(_setjmp) xorl %eax,%eax ret -#ifdef _THREAD_SAFE + .weak CNAME(_longjmp) + .set CNAME(_longjmp),CNAME(___longjmp) ENTRY(___longjmp) -#else -ALTENTRY(___longjmp) -ENTRY(_longjmp) -#endif movl 4(%esp),%edx movl 8(%esp),%eax movl 0(%edx),%ecx diff --git a/lib/libc/amd64/gen/setjmp.S b/lib/libc/amd64/gen/setjmp.S index 738407a..5e92c97 100644 --- a/lib/libc/amd64/gen/setjmp.S +++ b/lib/libc/amd64/gen/setjmp.S @@ -61,11 +61,7 @@ ENTRY(setjmp) pushl %eax /* (sigset_t*)oset */ pushl $0 /* (sigset_t*)set */ pushl $1 /* SIG_BLOCK */ -#ifdef _THREAD_SAFE - call PIC_PLT(CNAME(_thread_sys_sigprocmask)) -#else - call PIC_PLT(CNAME(sigprocmask)) -#endif + call PIC_PLT(CNAME(_sigprocmask)) addl $12,%esp PIC_EPILOGUE movl 4(%esp),%ecx @@ -80,10 +76,8 @@ ENTRY(setjmp) xorl %eax,%eax ret -#ifndef _THREAD_SAFE -.weak CNAME(longjmp); -.set CNAME(longjmp),CNAME(__longjmp); -#endif + .weak CNAME(longjmp) + .set CNAME(longjmp),CNAME(__longjmp) ENTRY(__longjmp) movl 4(%esp),%edx PIC_PROLOGUE @@ -91,11 +85,7 @@ ENTRY(__longjmp) leal 28(%edx), %eax pushl %eax /* (sigset_t*)set */ pushl $3 /* SIG_SETMASK */ -#ifdef _THREAD_SAFE - call PIC_PLT(CNAME(_thread_sys_sigprocmask)) -#else - call PIC_PLT(CNAME(sigprocmask)) -#endif + call PIC_PLT(CNAME(_sigprocmask)) addl $12,%esp PIC_EPILOGUE movl 4(%esp),%edx diff --git a/lib/libc/amd64/gen/sigsetjmp.S b/lib/libc/amd64/gen/sigsetjmp.S index 40aebb6..96aae68 100644 --- a/lib/libc/amd64/gen/sigsetjmp.S +++ b/lib/libc/amd64/gen/sigsetjmp.S @@ -52,9 +52,6 @@ * the renamed functions (introduced in gcc-2.5.3; previous versions * only supported *jmp with 0 or 1 leading underscores). * - * Use sigprocmask() instead of sigblock() and sigsetmask(), and - * check for and handle errors. - * * Restore _all_ the registers and the signal mask atomically. Can * use sigreturn() if sigreturn() works. */ @@ -70,11 +67,7 @@ ENTRY(sigsetjmp) pushl %eax /* (sigset_t*)oset */ pushl $0 /* (sigset_t*)set */ pushl $1 /* SIG_BLOCK */ -#ifdef _THREAD_SAFE - call PIC_PLT(CNAME(_thread_sys_sigprocmask)) -#else - call PIC_PLT(CNAME(sigprocmask)) -#endif + call PIC_PLT(CNAME(_sigprocmask)) addl $12,%esp PIC_EPILOGUE movl 4(%esp),%ecx @@ -89,10 +82,8 @@ ENTRY(sigsetjmp) xorl %eax,%eax ret -#ifndef _THREAD_SAFE -.weak CNAME(siglongjmp); -.set CNAME(siglongjmp),CNAME(__siglongjmp); -#endif + .weak CNAME(siglongjmp); + .set CNAME(siglongjmp),CNAME(__siglongjmp); ENTRY(__siglongjmp); movl 4(%esp),%edx cmpl $0,44(%edx) @@ -102,11 +93,7 @@ ENTRY(__siglongjmp); leal 28(%edx), %eax pushl %eax /* (sigset_t*)set */ pushl $3 /* SIG_SETMASK */ -#ifdef _THREAD_SAFE - call PIC_PLT(CNAME(_thread_sys_sigprocmask)) -#else - call PIC_PLT(CNAME(sigprocmask)) -#endif + call PIC_PLT(CNAME(_sigprocmask)) addl $12,%esp PIC_EPILOGUE movl 4(%esp),%edx diff --git a/lib/libc/amd64/sys/setlogin.S b/lib/libc/amd64/sys/setlogin.S index a4d74b0..3ba52c5 100644 --- a/lib/libc/amd64/sys/setlogin.S +++ b/lib/libc/amd64/sys/setlogin.S @@ -43,7 +43,7 @@ #include "SYS.h" -.globl CNAME(_logname_valid) /* in getlogin() */ +.globl CNAME(_logname_valid) /* in _getlogin() */ SYSCALL(setlogin) #ifdef PIC diff --git a/lib/libc/amd64/sys/vfork.S b/lib/libc/amd64/sys/vfork.S index 8ec99ae..8981308 100644 --- a/lib/libc/amd64/sys/vfork.S +++ b/lib/libc/amd64/sys/vfork.S @@ -51,12 +51,11 @@ * %eax == pid of child in parent, %eax == pid of parent in child. * */ - -#ifdef _THREAD_SAFE -ENTRY(_thread_sys_vfork) -#else -ENTRY(vfork) -#endif + .weak _vfork + .set _vfork,__sys_vfork + .weak vfork + .set vfork,__sys_vfork +ENTRY(__sys_vfork) popl %ecx /* my rta into ecx */ lea SYS_vfork,%eax KERNCALL |