Permalink
Browse files

Reviewed by: julian and (hsu?)

Submitted by:	 John Birrel(L?)

changes for threadsafe operations
  • Loading branch information...
Julian Elischer Julian Elischer
Julian Elischer authored and Julian Elischer committed Jan 22, 1996
1 parent d6577f3 commit 4a81bbc3e8796e1f18f1a5e8ba62836ad71025c2
Showing with 1,652 additions and 113 deletions.
  1. +4 −4 include/Makefile
  2. +7 −0 include/time.h
  3. +1 −0 include/unistd.h
  4. +9 −1 lib/csu/i386/crt0.c
  5. +16 −1 lib/libc/amd64/SYS.h
  6. +10 −2 lib/libc/amd64/gen/_setjmp.S
  7. +18 −2 lib/libc/amd64/gen/setjmp.S
  8. +18 −2 lib/libc/amd64/gen/sigsetjmp.S
  9. +26 −2 lib/libc/amd64/sys/cerror.S
  10. +3 −3 lib/libc/amd64/sys/pipe.S
  11. +3 −3 lib/libc/amd64/sys/sigreturn.S
  12. +25 −3 lib/libc/amd64/sys/vfork.S
  13. +7 −7 lib/libc/db/hash/hash.c
  14. +1 −1 lib/libc/db/hash/hash.h
  15. +2 −2 lib/libc/db/hash/ndbm.c
  16. +2 −2 lib/libc/gen/Makefile.inc
  17. +16 −1 lib/libc/gen/isatty.c
  18. +20 −0 lib/libc/gen/sleep.c
  19. +111 −0 lib/libc/gen/ttyname.c
  20. +18 −1 lib/libc/gen/usleep.c
  21. +16 −1 lib/libc/i386/SYS.h
  22. +10 −2 lib/libc/i386/gen/_setjmp.S
  23. +18 −2 lib/libc/i386/gen/setjmp.S
  24. +18 −2 lib/libc/i386/gen/sigsetjmp.S
  25. +25 −3 lib/libc/i386/sys/Ovfork.S
  26. +26 −2 lib/libc/i386/sys/cerror.S
  27. +3 −3 lib/libc/i386/sys/fork.S
  28. +3 −3 lib/libc/i386/sys/pipe.S
  29. +3 −3 lib/libc/i386/sys/sigpending.S
  30. +6 −2 lib/libc/i386/sys/sigprocmask.S
  31. +3 −3 lib/libc/i386/sys/sigreturn.S
  32. +6 −2 lib/libc/i386/sys/sigsuspend.S
  33. +10 −0 lib/libc/stdio/clrerr.c
  34. +12 −0 lib/libc/stdio/fclose.c
  35. +17 −2 lib/libc/stdio/fflush.c
  36. +14 −1 lib/libc/stdio/fgetc.c
  37. +14 −1 lib/libc/stdio/fgetpos.c
  38. +19 −1 lib/libc/stdio/fgets.c
  39. +20 −8 lib/libc/stdio/fpurge.c
  40. +14 −1 lib/libc/stdio/fputc.c
  41. +14 −1 lib/libc/stdio/fputs.c
  42. +11 −0 lib/libc/stdio/fread.c
  43. +12 −0 lib/libc/stdio/fscanf.c
  44. +27 −1 lib/libc/stdio/fseek.c
  45. +15 −1 lib/libc/stdio/ftell.c
  46. +13 −3 lib/libc/stdio/fwrite.c
  47. +14 −1 lib/libc/stdio/getc.c
  48. +14 −1 lib/libc/stdio/getchar.c
  49. +14 −1 lib/libc/stdio/putc.c
  50. +14 −1 lib/libc/stdio/putchar.c
  51. +14 −1 lib/libc/stdio/puts.c
  52. +14 −1 lib/libc/stdio/putw.c
  53. +10 −0 lib/libc/stdio/rewind.c
  54. +12 −0 lib/libc/stdio/scanf.c
  55. +14 −0 lib/libc/stdio/setvbuf.c
  56. +3 −0 lib/libc/stdio/snprintf.c
  57. +3 −0 lib/libc/stdio/sprintf.c
  58. +3 −0 lib/libc/stdio/sscanf.c
  59. +33 −4 lib/libc/stdio/ungetc.c
  60. +23 −3 lib/libc/stdio/vfprintf.c
  61. +14 −1 lib/libc/stdio/vscanf.c
  62. +2 −0 lib/libc/stdio/vsnprintf.c
  63. +2 −0 lib/libc/stdio/vsprintf.c
  64. +2 −0 lib/libc/stdio/vsscanf.c
  65. +13 −0 lib/libc/stdlib/abort.c
  66. +66 −3 lib/libc/stdlib/malloc.c
  67. +129 −1 lib/libc/stdtime/localtime.c
  68. +25 −0 lib/libc/sys/accept.2
  69. +22 −0 lib/libc/sys/bind.2
  70. +22 −0 lib/libc/sys/close.2
  71. +26 −2 lib/libc/sys/connect.2
  72. +47 −0 lib/libc/sys/dup.2
  73. +17 −0 lib/libc/sys/execve.2
  74. +23 −0 lib/libc/sys/fcntl.2
  75. +22 −0 lib/libc/sys/flock.2
  76. +22 −0 lib/libc/sys/fsync.2
  77. +16 −0 lib/libc/sys/ftruncate.c
  78. +22 −0 lib/libc/sys/getdirentries.2
  79. +22 −0 lib/libc/sys/getpeername.2
  80. +22 −0 lib/libc/sys/getsockname.2
  81. +44 −1 lib/libc/sys/getsockopt.2
  82. +40 −4 lib/libc/sys/intro.2
  83. +22 −0 lib/libc/sys/ioctl.2
  84. +23 −1 lib/libc/sys/listen.2
  85. +16 −1 lib/libc/sys/lseek.c
  86. +20 −0 lib/libc/sys/open.2
  87. +47 −0 lib/libc/sys/read.2
  88. +47 −0 lib/libc/sys/write.2
  89. +6 −1 sys/sys/errno.h
View
@@ -1,5 +1,5 @@
# From: @(#)Makefile 8.2 (Berkeley) 1/4/94
# $Id: Makefile,v 1.30 1995/10/27 06:51:02 julian Exp $
# $Id: Makefile,v 1.31 1995/11/12 19:29:08 markm Exp $
#
# Doing a make install builds /usr/include
#
@@ -13,10 +13,10 @@ SUBDIR= rpcsvc
FILES= a.out.h ar.h assert.h bitstring.h ctype.h db.h dirent.h disktab.h \
err.h f2c.h fnmatch.h fstab.h fts.h glob.h grp.h strhash.h histedit.h \
kvm.h limits.h link.h locale.h malloc.h memory.h mpool.h ndbm.h \
netdb.h nl_types.h nlist.h paths.h pwd.h ranlib.h regex.h regexp.h \
resolv.h rune.h runetype.h setjmp.h sgtty.h signal.h \
netdb.h nl_types.h nlist.h paths.h pthread.h pwd.h ranlib.h regex.h \
regexp.h resolv.h rune.h runetype.h setjmp.h sgtty.h signal.h \
stab.h stddef.h stdio.h stdlib.h string.h strings.h struct.h \
sysexits.h tar.h time.h ttyent.h unistd.h utime.h \
sysexits.h tar.h time.h timers.h ttyent.h unistd.h utime.h \
utmp.h vis.h
.if defined(WANT_CSRG_LIBM)
FILES+= math.h
View
@@ -100,6 +100,13 @@ time_t mktime __P((struct tm *));
size_t strftime __P((char *, size_t, const char *, const struct tm *));
time_t time __P((time_t *));
#ifdef _THREAD_SAFE
int asctime_r __P((const struct tm *, char *, int));
int ctime_r __P((const time_t *, char *, int));
int gmtime_r __P((const time_t *, struct tm *));
int localtime_r __P((const time_t *, struct tm *));
#endif
#ifndef _ANSI_SOURCE
void tzset __P((void));
#endif /* not ANSI */
View
@@ -165,6 +165,7 @@ int swapon __P((const char *));
int symlink __P((const char *, const char *));
void sync __P((void));
int syscall __P((int, ...));
off_t __syscall __P((quad_t, ...));
int truncate __P((const char *, off_t));
int ttyslot __P((void));
unsigned int ualarm __P((unsigned int, unsigned int));
View
@@ -27,7 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: crt0.c,v 1.20 1995/10/29 09:49:21 phk Exp $
* $Id: crt0.c,v 1.21 1995/11/02 12:42:42 ache Exp $
*/
#include <sys/param.h>
@@ -98,6 +98,7 @@ extern start() asm("start");
extern mcount() asm ("mcount");
extern int main(int argc, char **argv, char **envp);
int __syscall(int syscall,...);
void _thread_init();
#ifdef MCRT0
void monstartup(void *low, void *high);
#endif /* MCRT0 */
@@ -181,6 +182,13 @@ asm("eprol:");
monstartup(&eprol, &etext);
#endif /* MCRT0 */
/*
* Initialize the initial thread.
* This function might be a stub if libc does not
* contain thread support.
*/
_thread_init();
asm ("__callmain:"); /* Defined for the benefit of debuggers */
exit(main(kfp->kargc, argv, environ));
}
View
@@ -35,7 +35,7 @@
*
* from: @(#)SYS.h 5.5 (Berkeley) 5/7/91
*
* $Id: SYS.h,v 1.3 1993/11/04 00:01:17 paul Exp $
* $Id: SYS.h,v 1.2 1994/08/05 01:17:57 wollman Exp $
*/
#include <sys/syscall.h>
@@ -63,6 +63,21 @@
#define SYSCALL(x) 2: jmp cerror; ENTRY(x); lea SYS_/**/x,%eax; LCALL(7,0); jb 2b
#define RSYSCALL(x) SYSCALL(x); ret
#ifdef _THREAD_SAFE
/*
* Support for user-space threads which require that some syscalls be
* private to the threaded library.
*/
#define PSYSCALL(x) 2: jmp cerror; ENTRY(_thread_sys_/**/x); lea SYS_/**/x,%eax; LCALL(7,0); jb 2b
#else
/*
* The non-threaded library defaults to traditional syscalls where
* the function name matches the syscall name.
*/
#define PSYSCALL(x) SYSCALL(x)
#endif
#define PRSYSCALL(x) PSYSCALL(x); ret
#define PSEUDO(x,y) ENTRY(x); lea SYS_/**/y, %eax; ; LCALL(7,0); ret
#define CALL(x,y) call _/**/y; addl $4*x,%esp
/* gas fucks up offset -- although we don't currently need it, do for BCS */
@@ -33,12 +33,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: _setjmp.S,v 1.3 1995/01/23 01:26:41 davidg Exp $
*/
#if defined(LIBC_RCS) && !defined(lint)
.text
.asciz "$Id$"
.asciz "$Id: _setjmp.S,v 1.3 1995/01/23 01:26:41 davidg Exp $"
#endif /* LIBC_RCS and not lint */
/*
@@ -53,7 +53,11 @@
#include "DEFS.h"
#ifdef _THREAD_SAFE
ENTRY(__thread_sys_setjmp)
#else
ENTRY(_setjmp)
#endif
movl 4(%esp),%eax
movl 0(%esp),%edx
movl %edx, 0(%eax) /* rta */
@@ -66,7 +70,11 @@ ENTRY(_setjmp)
xorl %eax,%eax
ret
#ifdef _THREAD_SAFE
ENTRY(__thread_sys_longjmp)
#else
ENTRY(_longjmp)
#endif
movl 4(%esp),%edx
movl 8(%esp),%eax
movl 0(%edx),%ecx
@@ -33,12 +33,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: setjmp.S,v 1.3 1995/01/23 01:27:08 davidg Exp $
*/
#if defined(LIBC_RCS) && !defined(lint)
.text
.asciz "$Id$"
.asciz "$Id: setjmp.S,v 1.3 1995/01/23 01:27:08 davidg Exp $"
#endif /* LIBC_RCS and not lint */
/*
@@ -54,9 +54,17 @@
#include "DEFS.h"
#include "SYS.h"
#ifdef _THREAD_SAFE
ENTRY(_thread_sys_setjmp)
#else
ENTRY(setjmp)
#endif
pushl $0
#ifdef _THREAD_SAFE
call PIC_PLT(__thread_sys_sigblock)
#else
call PIC_PLT(_sigblock)
#endif
popl %edx
movl 4(%esp),%ecx
movl 0(%esp),%edx
@@ -71,10 +79,18 @@ ENTRY(setjmp)
xorl %eax,%eax
ret
#ifdef _THREAD_SAFE
ENTRY(_thread_sys_longjmp)
#else
ENTRY(longjmp)
#endif
movl 4(%esp),%edx
pushl 24(%edx)
#ifdef _THREAD_SAFE
call PIC_PLT(__thread_sys_sigsetmask)
#else
call PIC_PLT(_sigsetmask) /* XXX this is not reentrant */
#endif
popl %eax
movl 4(%esp),%edx
movl 8(%esp),%eax
@@ -33,12 +33,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: sigsetjmp.S,v 1.3 1994/12/27 13:34:04 bde Exp $
* $Id: sigsetjmp.S,v 1.4 1995/01/23 01:27:10 davidg Exp $
*/
#if defined(LIBC_RCS) && !defined(lint)
.text
.asciz "$Id: sigsetjmp.S,v 1.3 1994/12/27 13:34:04 bde Exp $"
.asciz "$Id: sigsetjmp.S,v 1.4 1995/01/23 01:27:10 davidg Exp $"
#endif /* LIBC_RCS and not lint */
#include "DEFS.h"
@@ -59,14 +59,22 @@
* use sigreturn() if sigreturn() works.
*/
#ifdef _THREAD_SAFE
ENTRY(_thread_sys_sigsetjmp)
#else
ENTRY(sigsetjmp)
#endif
movl 8(%esp),%eax
movl 4(%esp),%ecx
movl %eax,32(%ecx)
testl %eax,%eax
jz 1f
pushl $0
#ifdef _THREAD_SAFE
call PIC_PLT(__thread_sys_sigblock)
#else
call PIC_PLT(_sigblock)
#endif
addl $4,%esp
movl 4(%esp),%ecx
movl %eax,24(%ecx)
@@ -81,12 +89,20 @@ ENTRY(sigsetjmp)
xorl %eax,%eax
ret
#ifdef _THREAD_SAFE
ENTRY(_thread_sys_siglongjmp)
#else
ENTRY(siglongjmp)
#endif
movl 4(%esp),%edx
cmpl $0,32(%edx)
jz 1f
pushl 24(%edx)
#ifdef _THREAD_SAFE
call PIC_PLT(_thread_sys_sigsetmask)
#else
call PIC_PLT(_sigsetmask)
#endif
addl $4,%esp
1: movl 4(%esp),%edx
movl 8(%esp),%eax
@@ -33,16 +33,39 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: cerror.S,v 1.2 1994/08/13 14:00:26 davidg Exp $
* $Id: cerror.S,v 1.3 1995/01/23 01:29:43 davidg Exp $
*/
#if defined(SYSLIBC_RCS) && !defined(lint)
.text
.asciz "$Id$"
.asciz "$Id: cerror.S,v 1.3 1995/01/23 01:29:43 davidg Exp $"
#endif /* SYSLIBC_RCS and not lint */
#include "SYS.h"
#ifdef _THREAD_SAFE
/*
* Threaded version using __error().
*/
.globl ___error
.type ___error,@function
cerror:
pushl %eax
#ifdef PIC
call PIC_PLT(___error)
#else
call ___error
#endif
popl %ecx
movl %ecx,(%eax)
movl $-1,%eax
movl $-1,%edx
ret
#else /* _THREAD_SAFE */
/*
* Non-threaded version using global errno.
*/
.globl _errno
cerror:
#ifdef PIC
@@ -56,3 +79,4 @@ cerror:
movl $-1,%eax
movl $-1,%edx
ret
#endif /* _THREAD_SAFE */
@@ -33,17 +33,17 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: pipe.S,v 1.1 1994/08/05 01:18:46 wollman Exp $
* $Id: pipe.S,v 1.2 1995/01/23 01:29:57 davidg Exp $
*/
#if defined(SYSLIBC_RCS) && !defined(lint)
.text
.asciz "$Id$"
.asciz "$Id: pipe.S,v 1.2 1995/01/23 01:29:57 davidg Exp $"
#endif /* SYSLIBC_RCS and not lint */
#include "SYS.h"
SYSCALL(pipe)
PSYSCALL(pipe)
movl 4(%esp),%ecx
movl %eax,(%ecx)
movl %edx,4(%ecx)
@@ -33,12 +33,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: sigreturn.S,v 1.1 1994/08/05 01:18:53 wollman Exp $
* $Id: sigreturn.S,v 1.2 1995/01/23 01:30:16 davidg Exp $
*/
#if defined(SYSLIBC_RCS) && !defined(lint)
.text
.asciz "$Id$"
.asciz "$Id: sigreturn.S,v 1.2 1995/01/23 01:30:16 davidg Exp $"
#endif /* SYSLIBC_RCS and not lint */
#include "SYS.h"
@@ -53,5 +53,5 @@
.data; 1:; .long 0; .text; movl $1b,%eax; call mcount; popa ; nop
#endif /* PROF */
SYSCALL(sigreturn)
PSYSCALL(sigreturn)
ret
View
@@ -33,12 +33,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: Ovfork.S,v 1.1 1994/08/05 01:18:38 wollman Exp $
* $Id: Ovfork.S,v 1.2 1995/01/23 01:29:37 davidg Exp $
*/
#if defined(SYSLIBC_RCS) && !defined(lint)
.text
.asciz "$Id$"
.asciz "$Id: Ovfork.S,v 1.2 1995/01/23 01:29:37 davidg Exp $"
#endif /* SYSLIBC_RCS and not lint */
#include "SYS.h"
@@ -63,7 +63,28 @@ vforkok:
cmpl $0,%edx /* child process? */
jne child /* yes */
jmp parent
.globl _errno
#ifdef _THREAD_SAFE
/*
* Threaded version using __error().
*/
.globl ___error
.type ___error,@function
verror:
pushl %eax
#ifdef PIC
call PIC_PLT(___error)
#else
call ___error
#endif
popl %ecx
movl %ecx,(%eax)
movl $-1,%eax
movl $-1,%edx
#else /* !_THREAD_SAFE */
/*
* Non-threaded version using global errno.
*/
.globl _errno
verror:
#ifdef PIC
PIC_PROLOGUE
@@ -74,6 +95,7 @@ verror:
movl %eax,_errno
#endif
movl $-1,%eax
#endif /* !_THREAD_SAFE */
jmp %ecx
child:
movl $0,%eax
Oops, something went wrong.

0 comments on commit 4a81bbc

Please sign in to comment.