aboutsummaryrefslogtreecommitdiff
path: root/nptl/sysdeps
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-12-13 10:59:14 +0000
committerUlrich Drepper <drepper@redhat.com>2002-12-13 10:59:14 +0000
commit9ae0909b35bc7ed04897536cbf224f7e134b5184 (patch)
treeaa669fa5f77206d19f065a05859b8c52032019ad /nptl/sysdeps
parentb9633fccd30c9cb390295ca0c43477f2bef986af (diff)
downloadglibc-9ae0909b35bc7ed04897536cbf224f7e134b5184.tar
glibc-9ae0909b35bc7ed04897536cbf224f7e134b5184.tar.gz
glibc-9ae0909b35bc7ed04897536cbf224f7e134b5184.tar.bz2
glibc-9ae0909b35bc7ed04897536cbf224f7e134b5184.zip
Update.
2002-12-13 Ulrich Drepper <drepper@redhat.com> * misc/syslog.c (log_cleanup): Don't use parameter in __libc_lock_unlock call, use syslog_lock directly. Adjust callers to pass NULL instead of a pointer to syslog_lock.
Diffstat (limited to 'nptl/sysdeps')
-rw-r--r--nptl/sysdeps/i386/tls.h8
-rw-r--r--nptl/sysdeps/pthread/bits/libc-lock.h6
-rw-r--r--nptl/sysdeps/unix/sysv/linux/accept.S4
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/createthread.c6
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S17
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h15
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/pt-socket.S80
-rw-r--r--nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c6
-rw-r--r--nptl/sysdeps/unix/sysv/linux/read.c50
-rw-r--r--nptl/sysdeps/unix/sysv/linux/write.c50
10 files changed, 209 insertions, 33 deletions
diff --git a/nptl/sysdeps/i386/tls.h b/nptl/sysdeps/i386/tls.h
index a4bbf3445a..9f4b89f7aa 100644
--- a/nptl/sysdeps/i386/tls.h
+++ b/nptl/sysdeps/i386/tls.h
@@ -24,6 +24,7 @@
# include <stddef.h>
# include <stdint.h>
# include <stdlib.h>
+# include <list.h>
/* Type for the dtv. */
@@ -40,6 +41,8 @@ typedef struct
thread descriptor used by libpthread. */
dtv_t *dtv;
void *self; /* Pointer to the thread descriptor. */
+ list_t list;
+ int multiple_threads;
} tcbhead_t;
#endif
@@ -52,10 +55,13 @@ typedef struct
/* Signal that TLS support is available. */
#define USE_TLS 1
-/* Alignment requirement for the stack. For IA-32 this is govern by
+/* Alignment requirement for the stack. For IA-32 this is governed by
the SSE memory functions. */
#define STACK_ALIGN 16
+/* Offset of the MULTIPLE_THREADS element in tcbhead_t. */
+#define MULTIPLE_THREADS_OFFSET 20
+
#ifndef __ASSEMBLER__
/* Get system call information. */
diff --git a/nptl/sysdeps/pthread/bits/libc-lock.h b/nptl/sysdeps/pthread/bits/libc-lock.h
index 555f05db85..d46f74817e 100644
--- a/nptl/sysdeps/pthread/bits/libc-lock.h
+++ b/nptl/sysdeps/pthread/bits/libc-lock.h
@@ -25,12 +25,6 @@
#include <stddef.h>
-#if defined _LIBC && !defined NOT_IN_libc
-/* Nonzero if locking is needed. */
-extern int __libc_locking_needed attribute_hidden;
-#endif
-
-
/* Fortunately Linux now has a mean to do locking which is realtime
safe without the aid of the thread library. We also need no fancy
options like error checking mutexes etc. We only need simple
diff --git a/nptl/sysdeps/unix/sysv/linux/accept.S b/nptl/sysdeps/unix/sysv/linux/accept.S
new file mode 100644
index 0000000000..6b668dfd9a
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/accept.S
@@ -0,0 +1,4 @@
+#define socket accept
+#define __socket __libc_accept
+#define NARGS 3
+#include <pt-socket.S>
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/createthread.c b/nptl/sysdeps/unix/sysv/linux/i386/createthread.c
index fc252e185d..f9abce2df2 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/createthread.c
+++ b/nptl/sysdeps/unix/sysv/linux/i386/createthread.c
@@ -82,6 +82,9 @@ create_thread (struct pthread *pd, STACK_VARIABLES_PARMS)
/* Failed. */
return errno;
+ /* We now have for sure more than one thread. */
+ pd->header.data.multiple_threads = 1;
+
/* Now fill in the information about the new thread in
the newly created thread's data structure. We cannot let
the new thread do this since we don't know whether it was
@@ -142,5 +145,8 @@ create_thread (struct pthread *pd, STACK_VARIABLES_PARMS)
/* Failed. */
return errno;
+ /* We now have for sure more than one thread. */
+ pd->header.data.multiple_threads = 1;
+
return 0;
}
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S
index 65e39e7829..27275e3158 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S
@@ -18,6 +18,7 @@
02111-1307 USA. */
#include <sysdep.h>
+#include <tls.h>
.text
@@ -48,13 +49,7 @@ __lll_lock_wait:
orl $-1, %eax /* Load -1. */
#ifndef UP
-# ifdef PIC
- call __i686.get_pc_thunk.dx
- addl $_GLOBAL_OFFSET_TABLE_, %edx
- cmpl $0, __libc_locking_needed@GOTOFF(%edx)
-# else
- cmpl $0, __libc_locking_needed
-# endif
+ cmpl $0, %gs:MULTIPLE_THREADS_OFFSET
je,pt 0f
lock
0:
@@ -83,13 +78,7 @@ lll_unlock_wake_cb:
movl 20(%esp), %ebx
#ifndef UP
-# ifdef PIC
- call __i686.get_pc_thunk.dx
- addl $_GLOBAL_OFFSET_TABLE_, %edx
- cmpl $0, __libc_locking_needed@GOTOFF(%edx)
-# else
- cmpl $0, __libc_locking_needed
-# endif
+ cmpl $0, %gs:MULTIPLE_THREADS_OFFSET
je,pt 0f
lock
0:
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h
index 94c0314c12..7c516ee36a 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h
+++ b/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h
@@ -21,6 +21,7 @@
#define _LOWLEVELLOCK_H 1
#include <time.h>
+#include <sys/param.h>
#include <bits/pthreadtypes.h>
#ifndef LOCK_INSTR
@@ -182,26 +183,27 @@ extern int lll_unlock_wake_cb (int *__futex) attribute_hidden;
the lock prefix when the thread library is not used.
XXX In future we might even want to avoid it on UP machines. */
+# include <tls.h>
/* Nonzero if locking is needed. */
extern int __libc_locking_needed attribute_hidden;
# define lll_trylock(futex) \
({ unsigned char ret; \
- __asm __volatile ("cmpl $0, %5\n\t" \
+ __asm __volatile ("cmpl $0, %%gs:%P5\n\t" \
"je,pt 0f\n\t" \
"lock\n" \
"0:\tcmpxchgl %2, %1; setne %0" \
: "=a" (ret), "=m" (futex) \
: "r" (0), "1" (futex), "0" (1), \
- "m" (__libc_locking_needed) \
+ "i" (offsetof (tcbhead_t, multiple_threads)) \
: "memory"); \
ret; })
# define lll_lock(futex) \
(void) ({ int ignore1, ignore2; \
- __asm __volatile ("cmpl $0, %5\n\t" \
+ __asm __volatile ("cmpl $0, %%gs:%P5\n\t" \
"je,pt 0f\n\t" \
"lock\n" \
"0:\txaddl %0, %2\n\t" \
@@ -214,13 +216,13 @@ extern int __libc_locking_needed attribute_hidden;
"2:" \
: "=a" (ignore1), "=&c" (ignore2), "=m" (futex) \
: "0" (-1), "2" (futex), \
- "m" (__libc_locking_needed) \
+ "i" (offsetof (tcbhead_t, multiple_threads)) \
: "memory"); })
# define lll_unlock(futex) \
(void) ({ int ignore; \
- __asm __volatile ("cmpl $0, %3\n\t" \
+ __asm __volatile ("cmpl $0, %%gs:%P3\n\t" \
"je,pt 0f\n\t" \
"lock\n" \
"0:\tincl %0\n\t" \
@@ -232,7 +234,8 @@ extern int __libc_locking_needed attribute_hidden;
".previous\n" \
"2:" \
: "=m" (futex), "=&a" (ignore) \
- : "0" (futex), "m" (__libc_locking_needed) \
+ : "0" (futex), \
+ "i" (offsetof (tcbhead_t, multiple_threads)) \
: "memory"); })
#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/pt-socket.S b/nptl/sysdeps/unix/sysv/linux/i386/pt-socket.S
new file mode 100644
index 0000000000..0b8523bd86
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/i386/pt-socket.S
@@ -0,0 +1,80 @@
+/* Copyright (C) 1995, 1996, 1997, 1998, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include <socketcall.h>
+
+#define P(a, b) P2(a, b)
+#define P2(a, b) a##b
+
+ .text
+/* The socket-oriented system calls are handled unusally in Linux.
+ They are all gated through the single `socketcall' system call number.
+ `socketcall' takes two arguments: the first is the subcode, specifying
+ which socket function is being called; and the second is a pointer to
+ the arguments to the specific function.
+
+ The .S files for the other calls just #define socket and #include this. */
+
+#ifndef __socket
+# error "__socket and socket must be defined"
+#endif
+
+.globl __socket
+ENTRY (__socket)
+ /* We need one more register. */
+ pushl %esi
+
+ /* Enable asynchronous cancellation. */
+ call __libc_enable_asynccancel /* No @plt */
+ movl %eax, %esi
+
+ /* Save registers. */
+ movl %ebx, %edx
+
+ movl $SYS_ify(socketcall), %eax /* System call number in %eax. */
+
+ /* Use ## so `socket' is a separate token that might be #define'd. */
+ movl $P(SOCKOP_,socket), %ebx /* Subcode is first arg to syscall. */
+ lea 8(%esp), %ecx /* Address of args is 2nd arg. */
+
+ /* Do the system call trap. */
+ int $0x80
+
+ /* Restore the cancellation. */
+ xchgl %esi, %eax
+ call __libc_disable_asynccancel /* No @plt */
+
+ /* Restore registers. */
+ movl %esi, %eax
+ movl %edx, %ebx
+ popl %esi
+
+ /* %eax is < 0 if there was an error. */
+ cmpl $-125, %eax
+ jae SYSCALL_ERROR_LABEL
+
+ /* Successful; return the syscall's value. */
+L(pseudo_end):
+ ret
+
+PSEUDO_END (__socket)
+
+#ifndef NO_WEAK_ALIAS
+weak_alias (__socket, socket)
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c b/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c
index d7f1c03b5e..80b6dbcb4f 100644
--- a/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c
+++ b/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c
@@ -24,9 +24,6 @@
static struct fork_handler pthread_child_handler;
-/* Global variable signalled when locking is needed. */
-int __libc_locking_needed;
-
void
__libc_pthread_init (ptr, reclaim)
@@ -41,7 +38,4 @@ __libc_pthread_init (ptr, reclaim)
/* The fork handler needed by libpthread. */
list_add_tail (&pthread_child_handler.list, &__fork_child_list);
-
- /* Signal the internal locking code that locking is needed now. */
- __libc_locking_needed = 1;
}
diff --git a/nptl/sysdeps/unix/sysv/linux/read.c b/nptl/sysdeps/unix/sysv/linux/read.c
new file mode 100644
index 0000000000..ea04002023
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/read.c
@@ -0,0 +1,50 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <sysdep.h>
+#include <unistd.h>
+#include <nptl/pthreadP.h>
+#include <tls.h>
+
+
+ssize_t
+__libc_read (int fd, void *buf, size_t count)
+{
+#ifndef NOT_IN_libc
+ if (__builtin_expect (THREAD_GETMEM (THREAD_SELF,
+ header.data.multiple_threads) == 0, 1))
+ return INLINE_SYSCALL (read, 3, fd, buf, count);
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+#endif
+
+ ssize_t result = INLINE_SYSCALL (read, 3, fd, buf, count);
+
+#ifndef NOT_IN_libc
+ LIBC_CANCEL_RESET (oldtype);
+#endif
+
+ return result;
+}
+libc_hidden_def (__libc_read)
+strong_alias (__libc_read, __read)
+libc_hidden_weak (__read)
+weak_alias (__libc_read, read)
diff --git a/nptl/sysdeps/unix/sysv/linux/write.c b/nptl/sysdeps/unix/sysv/linux/write.c
new file mode 100644
index 0000000000..ea9b60c979
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/write.c
@@ -0,0 +1,50 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <sysdep.h>
+#include <unistd.h>
+#include <nptl/pthreadP.h>
+#include <tls.h>
+
+
+ssize_t
+__libc_write (int fd, const void *buf, size_t count)
+{
+#ifndef NOT_IN_libc
+ if (__builtin_expect (THREAD_GETMEM (THREAD_SELF,
+ header.data.multiple_threads) == 0, 1))
+ return INLINE_SYSCALL (write, 3, fd, buf, count);
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+#endif
+
+ ssize_t result = INLINE_SYSCALL (write, 3, fd, buf, count);
+
+#ifndef NOT_IN_libc
+ LIBC_CANCEL_RESET (oldtype);
+#endif
+
+ return result;
+}
+libc_hidden_def (__libc_write)
+strong_alias (__libc_write, __write)
+libc_hidden_weak (__write)
+weak_alias (__libc_write, write)