]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
hurd: Remove some remnants of cthreads
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sat, 14 Nov 2020 23:35:35 +0000 (23:35 +0000)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 15 Nov 2020 12:16:03 +0000 (13:16 +0100)
Libc has actually been using mach's lock-internal.h mutex for a long
time already.

27 files changed:
conform/Makefile
htl/libpthread_syms.a
htl/lockfile.c
hurd/dtable.c
hurd/hurd.h
hurd/hurd/fd.h
hurd/hurd/id.h
hurd/hurd/signal.h
hurd/hurdmalloc.c
hurd/hurdpid.c
hurd/hurdrlimit.c
hurd/hurdsig.c
hurd/hurdsock.c
hurd/hurdstartup.c
hurd/msgportdemux.c
mach/lock-intern.h
mach/mutex-solid.c
scripts/check-local-headers.sh
sysdeps/htl/Makeconfig
sysdeps/htl/bits/pthread-np.h
sysdeps/hurd/include/hurd/signal.h
sysdeps/mach/hurd/brk.c
sysdeps/mach/hurd/cthreads.c
sysdeps/mach/hurd/fork.c
sysdeps/mach/hurd/htl/bits/pthread-np.h
sysdeps/mach/hurd/i386/Makefile
sysdeps/mach/hurd/profil.c

index 0b5c4cb8cef2819db293bec64691bd73213dbd30..015037f26781ff3ccb5cae470b189e83c040e907 100644 (file)
@@ -189,14 +189,15 @@ $(linknamespace-symlists-tests): $(objpfx)symlist-%: list-header-symbols.py
 
 linknamespace-libs-isoc = $(common-objpfx)libc.a $(common-objpfx)math/libm.a
 linknamespace-libs-thr = $(linknamespace-libs-isoc) \
-                        $(common-objpfx)rt/librt.a $(static-thread-library)
+                        $(common-objpfx)rt/librt.a \
+                        $(filter-out %_syms.a,$(static-thread-library))
 linknamespace-libs-posix = $(linknamespace-libs-thr) \
                           $(common-objpfx)dlfcn/libdl.a
 linknamespace-libs-xsi = $(linknamespace-libs-posix)
 linknamespace-libs-ISO = $(linknamespace-libs-isoc)
 linknamespace-libs-ISO99 = $(linknamespace-libs-isoc)
 linknamespace-libs-ISO11 = $(linknamespace-libs-isoc) \
-                          $(static-thread-library)
+                          $(filter-out %_syms.a,$(static-thread-library))
 linknamespace-libs-XPG4 = $(linknamespace-libs-isoc)
 linknamespace-libs-XPG42 = $(linknamespace-libs-XPG4)
 linknamespace-libs-POSIX = $(linknamespace-libs-thr)
index 48dadfbd5f3ee22d1a37d39ffa6713e30af9cc3a..b299edd4de14bf1df9319d3bd0de02fb1873932b 100644 (file)
@@ -15,7 +15,9 @@ EXTERN(__mutex_unlock_solid)
 EXTERN(_cthreads_flockfile)
 EXTERN(_cthreads_funlockfile)
 EXTERN(_cthreads_ftrylockfile)
-/* To get the sigthread stack layout on fork */
+/* To create the sigthread and get its stack layout on fork */
+EXTERN(pthread_create)
+EXTERN(pthread_detach)
 EXTERN(pthread_getattr_np)
 EXTERN(pthread_attr_getstack)
 EXTERN(__pthread_enable_asynccancel)
index 51ed5ef8cce12e9e03cb8fa87beab971cee35aa8..12f077e6452fa847806683181939a0f13b021f50 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library;  if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <cthreads.h>
 #include <pthread.h>           /* Must come before <stdio.h>! */
 #include <stdio.h>
 
index 9f6ae2f606f9697e24a5e3eb974e41a59e00adb4..80d02474fa41f1c7687db56b621752ec65e69bef 100644 (file)
@@ -22,7 +22,7 @@
 #include <stdio.h>
 #include <fcntl.h>
 #include <limits.h>
-#include <cthreads.h>          /* For `struct mutex'.  */
+#include <lock-intern.h>       /* For `struct mutex'.  */
 #include "set-hooks.h"
 #include "hurdmalloc.h"                /* XXX */
 
index 8f1fdf4a64fadef14674bc4ea4c74cba405eea53..c6e88a63c26afbcfec4761ac08e704f59d5c50c1 100644 (file)
@@ -103,7 +103,6 @@ extern error_t _hurd_ports_use (int which, error_t (*operate) (mach_port_t));
 
 
 /* Base address and size of the initial stack set up by the exec server.
-   If using cthreads, this stack is deallocated in startup.
    Not locked.  */
 
 extern vm_address_t _hurd_stack_base;
@@ -123,9 +122,6 @@ extern int _hurd_orphaned;
 
 /* This variable is incremented every time the process IDs change.  */
 extern unsigned int _hurd_pids_changed_stamp;
-
-/* This condition is broadcast every time the process IDs change.  */
-extern struct condition _hurd_pids_changed_sync;
 \f
 /* Unix `data break', for brk and sbrk.
    If brk and sbrk are not used, this info will not be initialized or used.  */
index d27be21cfde2e1bc048b07038837a7481abf3dd2..273406fbf8f156212a3ed69b5d5a80e929ff4571 100644 (file)
@@ -21,8 +21,6 @@
 #define        _HURD_FD_H      1
 #include <features.h>
 
-#include <cthreads.h>
-
 #include <hurd/hurd_types.h>
 #include <hurd/port.h>
 #include <sys/socket.h>
@@ -47,9 +45,12 @@ struct hurd_fd
 
 /* Current file descriptor table.  */
 
+#if defined __USE_EXTERN_INLINES && defined _LIBC
+#include <lock-intern.h>
 extern int _hurd_dtablesize;
 extern struct hurd_fd **_hurd_dtable;
 extern struct mutex _hurd_dtable_lock; /* Locks those two variables.  */
+#endif
 \f
 #include <hurd/signal.h>
 
index bb796e178803a439bc5186173ac35e67395f0c53..944df218d438d94d668aef97927b975c35885c5c 100644 (file)
@@ -24,7 +24,7 @@
 #include <errno.h>
 #include <bits/types/error_t.h>
 
-#include <cthreads.h>          /* For `struct mutex'.  */
+#include <lock-intern.h>       /* For `struct mutex'.  */
 
 /* Structure describing authorization data for the process.  */
 
index ef6a8e6687b7c5ffce2ff37a4e2cbec5db94ea1c..c11f8411726348df6ae4e896a015cf1fd4503cea 100644 (file)
@@ -37,7 +37,6 @@
 #include <bits/sigaction.h>
 #include <hurd/msg.h>
 
-#include <cthreads.h>          /* For `struct mutex'.  */
 #include <setjmp.h>            /* For `jmp_buf'.  */
 #include <spin-lock.h>
 struct hurd_signal_preemptor;  /* <hurd/sigpreempt.h> */
@@ -120,8 +119,6 @@ struct hurd_sigstate
 
 extern struct hurd_sigstate *_hurd_sigstates;
 
-extern struct mutex _hurd_siglock; /* Locks _hurd_sigstates.  */
-
 /* Get the sigstate of a given thread, taking its lock.  */
 
 extern struct hurd_sigstate *_hurd_thread_sigstate (thread_t);
@@ -320,7 +317,7 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
 
 /* Function run by the signal thread to receive from the signal port.  */
 
-extern void _hurd_msgport_receive (void);
+extern void *_hurd_msgport_receive (void *arg);
 
 /* Set up STATE with a thread state that, when resumed, is
    like `longjmp (_hurd_sigthread_fault_env, 1)'.  */
index 65fb959d8491cc45c86681002d24fef86b6110b1..7046bcef338249916116e1705bbf81427d31553f 100644 (file)
@@ -4,6 +4,7 @@
 #include "hurdmalloc.h"                /* XXX see that file */
 
 #include <mach.h>
+#include <mach/spin-lock.h>
 #define vm_allocate __vm_allocate
 #define vm_page_size __vm_page_size
 
@@ -79,8 +80,6 @@
 \f
 #include <assert.h>
 
-#include <cthreads.h>
-
 #define MCHECK
 
 /*
@@ -221,7 +220,7 @@ malloc (size_t size)
                i += 1;
                n <<= 1;
        }
-       ASSERT(i < NBUCKETS);
+       assert(i < NBUCKETS);
        fl = &malloc_free_list[i];
        spin_lock(&fl->lock);
        h = fl->head;
@@ -291,11 +290,11 @@ free (void *base)
         * Sanity checks.
         */
        if (i < 0 || i >= NBUCKETS) {
-               ASSERT(0 <= i && i < NBUCKETS);
+               assert(0 <= i && i < NBUCKETS);
                return;
        }
        if (fl != &malloc_free_list[i]) {
-               ASSERT(fl == &malloc_free_list[i]);
+               assert(fl == &malloc_free_list[i]);
                return;
        }
        /*
@@ -340,11 +339,11 @@ realloc (void *old_base, size_t new_size)
         * Sanity checks.
         */
        if (i < 0 || i >= NBUCKETS) {
-               ASSERT(0 <= i && i < NBUCKETS);
+               assert(0 <= i && i < NBUCKETS);
                return 0;
        }
        if (fl != &malloc_free_list[i]) {
-               ASSERT(fl == &malloc_free_list[i]);
+               assert(fl == &malloc_free_list[i]);
                return 0;
        }
        /*
index 196177c403ff48ea671a7c57f61bb83ef5e0d235..dd8281cda7c4478c17e33e4c82ccbbe648928339 100644 (file)
@@ -37,13 +37,11 @@ text_set_element (_hurd_proc_subinit, init_pids);
 \f
 #include <hurd/msg_server.h>
 #include "set-hooks.h"
-#include <cthreads.h>
 
 DEFINE_HOOK (_hurd_pgrp_changed_hook, (pid_t));
 
 /* These let user threads synchronize with an operation which changes ids.  */
 unsigned int _hurd_pids_changed_stamp;
-struct condition _hurd_pids_changed_sync;
 
 kern_return_t
 _S_msg_proc_newids (mach_port_t me,
index 42163909247cef8219d5ae13ead5e48ca2fdee74..94f62b06b7ad5401b17c20246ae9f0f6f6733e1b 100644 (file)
@@ -17,7 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <hurd.h>
-#include <cthreads.h>
+#include <lock-intern.h>
 #include <hurd/resource.h>
 
 /* This must be given an initializer, or the a.out linking rules will
index 3150091e8476e9729d2facdbda861eeb02af66bc..2b778d6927e0421adc482dd527a9092f52679d3d 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
-#include <cthreads.h>          /* For `struct mutex'.  */
+#include <lock-intern.h>       /* For `struct mutex'.  */
 #include <pthreadP.h>
 #include <mach.h>
 #include <mach/thread_switch.h>
 #include <mach/mig_support.h>
+#include <mach/vm_param.h>
 
 #include <hurd.h>
 #include <hurd/id.h>
@@ -1477,8 +1478,8 @@ _hurdsig_init (const int *intarray, size_t intarraysize)
 
   /* Start the signal thread listening on the message port.  */
 
-#pragma weak __cthread_fork
-  if (!__cthread_fork)
+#pragma weak __pthread_create
+  if (!__pthread_create)
     {
       err = __thread_create (__mach_task_self (), &_hurd_msgport_thread);
       assert_perror (err);
@@ -1503,41 +1504,40 @@ _hurdsig_init (const int *intarray, size_t intarraysize)
     }
   else
     {
-      /* When cthreads is being used, we need to make the signal thread a
-         proper cthread.  Otherwise it cannot use mutex_lock et al, which
-         will be the cthreads versions.  Various of the message port RPC
+      pthread_t thread;
+      pthread_attr_t attr;
+      void *addr;
+      size_t size;
+
+      /* When pthread is being used, we need to make the signal thread a
+         proper pthread.  Otherwise it cannot use mutex_lock et al, which
+         will be the pthread versions.  Various of the message port RPC
          handlers need to take locks, so we need to be able to call into
-         cthreads code and meet its assumptions about how our thread and
-         its stack are arranged.  Since cthreads puts it there anyway,
+         pthread code and meet its assumptions about how our thread and
+         its stack are arranged.  Since pthread puts it there anyway,
          we'll let the signal thread's per-thread variables be found as for
-         any normal cthread, and just leave the magic __hurd_sigthread_*
+         any normal pthread, and just leave the magic __hurd_sigthread_*
          values all zero so they'll be ignored.  */
-#pragma weak __cthread_detach
+
+#pragma weak __pthread_detach
 #pragma weak __pthread_getattr_np
 #pragma weak __pthread_attr_getstack
-      __cthread_t thread = __cthread_fork (
-                            (cthread_fn_t) &_hurd_msgport_receive, 0);
-      __cthread_detach (thread);
+      __pthread_create(&thread, NULL, &_hurd_msgport_receive, NULL);
 
-      if (__pthread_getattr_np)
-       {
-         /* Record signal thread stack layout for fork() */
-         pthread_attr_t attr;
-         void *addr;
-         size_t size;
-
-         __pthread_getattr_np ((pthread_t) thread, &attr);
-         __pthread_attr_getstack (&attr, &addr, &size);
-         __hurd_sigthread_stack_base = (uintptr_t) addr;
-         __hurd_sigthread_stack_end = __hurd_sigthread_stack_base + size;
-       }
+      /* Record signal thread stack layout for fork() */
+      __pthread_getattr_np (thread, &attr);
+      __pthread_attr_getstack (&attr, &addr, &size);
+      __hurd_sigthread_stack_base = (uintptr_t) addr;
+      __hurd_sigthread_stack_end = __hurd_sigthread_stack_base + size;
+
+      __pthread_detach(thread);
 
       /* XXX We need the thread port for the signal thread further on
          in this thread (see hurdfault.c:_hurdsigfault_init).
          Therefore we block until _hurd_msgport_thread is initialized
          by the newly created thread.  This really shouldn't be
          necessary; we should be able to fetch the thread port for a
-         cthread from here.  */
+         pthread from here.  */
       while (_hurd_msgport_thread == 0)
        __swtch_pri (0);
     }
index f77c83ee9e5d8113ba47340abdb16510f441920a..e7222a8b19e9abca3d6814d610141c82cec81206 100644 (file)
@@ -23,7 +23,7 @@
 #include <hurd/paths.h>
 #include <stdio.h>
 #include <_itoa.h>
-#include <cthreads.h>          /* For `struct mutex'.  */
+#include <lock-intern.h>       /* For `struct mutex'.  */
 #include "hurdmalloc.h"                /* XXX */
 
 static struct mutex lock;
index b67de45bc98f3d388b1e66c2354e5e5bb0d01586..abe0dde8f31776029ad6d1101abd278984077223 100644 (file)
@@ -41,15 +41,7 @@ extern void __mach_init (void);
    initialization so mig-generated stubs work, and then do an exec_startup
    RPC on our bootstrap port, to which the exec server responds with the
    information passed in the exec call, as well as our original bootstrap
-   port, and the base address and size of the preallocated stack.
-
-   If using cthreads, we are given a new stack by cthreads initialization and
-   deallocate the stack set up by the exec server.  On the new stack we call
-   `start1' (above) to do the rest of the startup work.  Since the stack may
-   disappear out from under us in a machine-dependent way, we use a pile of
-   static variables to communicate the information from exec_startup to start1.
-   This is unfortunate but preferable to machine-dependent frobnication to copy
-   the state from the old stack to the new one.  */
+   port, and the base address and size of the preallocated stack.  */
 
 
 void
index 7d5f6a5a665b3ee79db3bbed8feefce164334a4d..6b35076a0449d8c84f8e36c7ddefd5cee173c8ff 100644 (file)
@@ -51,14 +51,14 @@ msgport_server (mach_msg_header_t *inp,
 }
 
 /* This is the code that the signal thread runs.  */
-void
-_hurd_msgport_receive (void)
+void *
+_hurd_msgport_receive (void *arg)
 {
   /* Get our own sigstate cached so we never again have to take a lock to
      fetch it.  There is much code in hurdsig.c that operates with some
      sigstate lock held, which will deadlock with _hurd_thread_sigstate.
 
-     Furthermore, in the cthreads case this is the convenient spot
+     Furthermore, in the pthread case this is the convenient spot
      to initialize _hurd_msgport_thread (see hurdsig.c:_hurdsig_init).  */
 
   _hurd_msgport_thread = _hurd_self_sigstate ()->thread;
index b6a075bc3a610e59c152a6d95c62d75d95af50c7..a68674cef44ca90bda818aa97631c16cd23a3b02 100644 (file)
@@ -95,6 +95,15 @@ __spin_lock_locked (__spin_lock_t *__lock)
 #endif
 \f
 /* Name space-clean internal interface to mutex locks.  */
+struct mutex {
+       __spin_lock_t __held;
+       __spin_lock_t __lock;
+       const char *__name;
+       void *__head, *__tail;
+       void *__holder;
+};
+
+#define MUTEX_INITIALIZER { __SPIN_LOCK_INITIALIZER }
 
 /* Initialize the newly allocated mutex lock LOCK for further use.  */
 extern void __mutex_init (void *__lock);
index 7ed9ce8c2878743382018dc296409e17d1de8e1f..13c01fb511f6b44fe07eb0be0b481b9098c16120 100644 (file)
    <https://www.gnu.org/licenses/>.  */
 
 #include <lock-intern.h>
-#include <cthreads.h>
 
-/* If cthreads is linked in, it will define these functions itself to do
-   real cthreads mutex locks.  This file will only be linked in when
-   cthreads is not used, and `mutexes' are in fact just spin locks (and
+/* If pthread is linked in, it will define these functions itself to do
+   real pthread mutex locks.  This file will only be linked in when
+   pthread is not used, and `mutexes' are in fact just spin locks (and
    some unused storage).  */
 
 void
index 36a75897a90cd835f32023df21a45434439a3555..837b3e9c7057548427cd42815f060fd7cf075305 100755 (executable)
@@ -33,7 +33,7 @@ exec ${AWK} -v includedir="$includedir" '
 BEGIN {
   status = 0
   exclude = "^" includedir \
-    "/(.*-.*-.*/|.*-.*/|)(asm[-/]|arch|linux/|selinux/|mach/|mach_debug/|device/|hurd/(((hurd|ioctl)_types|paths)\\.h|ioctls\\.defs|ihash\\.h)|cthreads\\.h|gd|nss3/|nspr4?/|c\\+\\+/|sys/(capability|sdt(|-config))\\.h|libaudit\\.h)"
+    "/(.*-.*-.*/|.*-.*/|)(asm[-/]|arch|linux/|selinux/|mach/|mach_debug/|device/|hurd/(((hurd|ioctl)_types|paths)\\.h|ioctls\\.defs|ihash\\.h)|gd|nss3/|nspr4?/|c\\+\\+/|sys/(capability|sdt(|-config))\\.h|libaudit\\.h)"
 }
 /^[^ ]/ && $1 ~ /.*:/ { obj = $1 }
 {
index ad56cc6bd1d57796813ea0e5d097427be151eb78..e8a8f405b09d630e29310799855392d7fb191717 100644 (file)
@@ -4,7 +4,7 @@
 have-thread-library = yes
 
 shared-thread-library = $(common-objpfx)htl/libpthread.so
-static-thread-library = $(common-objpfx)htl/libpthread.a
+static-thread-library = $(..)htl/libpthread_syms.a $(common-objpfx)htl/libpthread.a
 bounded-thread-library = $(static-thread-library)
 
 rpath-dirs += htl
index 13a04213341af755edaaaea07b4bef9eba4d74a2..8c7dc4e10436cc1f2db01828a3dbdd61150bf89b 100644 (file)
@@ -17,7 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 /*
- * Never include this file directly; use <pthread.h> or <cthreads.h> instead.
+ * Never include this file directly; use <pthread.h> instead.
  */
 
 #ifndef _BITS_PTHREAD_NP_H
index f4627a7204e194e28a5ff030fdaec75cc16cf437..1dc8a1f353c73d8002d3f36f9973b69fd6a33475 100644 (file)
@@ -1,3 +1,5 @@
+extern struct mutex _hurd_siglock; /* Locks _hurd_sigstates.  */
+
 #ifndef        _HURD_SIGNAL_H
 extern struct hurd_sigstate *_hurd_self_sigstate (void) __attribute__ ((__const__));
 #ifndef _ISOMAC
index a6d4880028433c010081fb62cdd0d81e81fdb867..02fdefd4b7d6d79a0dab484ead02ff67139a0c9d 100644 (file)
@@ -18,7 +18,7 @@
 #include <errno.h>
 #include <hurd.h>
 #include <hurd/resource.h>
-#include <cthreads.h>          /* For `struct mutex'.  */
+#include <lock-intern.h>       /* For `struct mutex'.  */
 #include <vm_param.h>
 
 
index 23dcedb72ac9f86210307766c5d28ba0857a1c3c..0e0d06b9e1e38cbf2fb0d2230954012901fcd95c 100644 (file)
@@ -18,7 +18,7 @@
 #include <libc-lock.h>
 #include <errno.h>
 #include <stdlib.h>
-#include <cthreads.h>
+#include <pthreadP.h>
 
 /* This serves as stub "self" pointer for libc locks when TLS is not initialized
    yet.  */
@@ -27,7 +27,7 @@ char __libc_lock_self0[0];
 /* Placeholder for key creation routine from Hurd cthreads library.  */
 int
 weak_function
-__cthread_keycreate (cthread_key_t *key)
+__cthread_keycreate (__cthread_key_t *key)
 {
   __set_errno (ENOSYS);
  *key = -1;
@@ -37,7 +37,7 @@ __cthread_keycreate (cthread_key_t *key)
 /* Placeholder for key retrieval routine from Hurd cthreads library.  */
 int
 weak_function
-__cthread_getspecific (cthread_key_t key, void **pval)
+__cthread_getspecific (__cthread_key_t key, void **pval)
 {
   *pval = NULL;
   __set_errno (ENOSYS);
@@ -47,7 +47,7 @@ __cthread_getspecific (cthread_key_t key, void **pval)
 /* Placeholder for key setting routine from Hurd cthreads library.  */
 int
 weak_function
-__cthread_setspecific (cthread_key_t key, void *val)
+__cthread_setspecific (__cthread_key_t key, void *val)
 {
   __set_errno (ENOSYS);
   return -1;
index 32783069ec2e578ab4d2a2e6baa24aa2302deb29..3767fd9a4c4d104a9dfb70e73a4029ccd7e74578 100644 (file)
@@ -497,7 +497,7 @@ __fork (void)
 #else
       if (__hurd_sigthread_stack_end == 0)
        {
-         /* The signal thread has a stack assigned by cthreads.
+         /* The signal thread has a stack assigned by pthread.
             The threadvar_stack variables conveniently tell us how
             to get to the highest address in the stack, just below
             the per-thread variables.  */
index c15412de2c8a681106eb71c1f0ce25d98e59e744..f1e71dc1fcd2e876608efbf34aee5f73fd06ae1e 100644 (file)
@@ -17,7 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 /*
- * Never include this file directly; use <pthread.h> or <cthreads.h> instead.
+ * Never include this file directly; use <pthread.h> instead.
  */
 
 #ifndef _BITS_PTHREAD_NP_H
index daeb85ba4f9a529e5df3c2a72f251d6805997feb..8e5f12a5330cd69145d6b5a97996b3b4386ad67c 100644 (file)
@@ -153,6 +153,8 @@ ifeq ($(subdir),elf)
 # We do use nested functions involving creation of trampolines, notably for
 # callbacks whose parameters don't permit to get the context parameters.
 check-execstack-xfail += ld.so libc.so libpthread.so
+# We always create a thread for signals
+test-xfail-tst-single_threaded-pthread-static = yes
 endif
 
 ifeq ($(subdir),stdlib)
index b475cc13b42ae4cb324316a6569418c4fca65fe2..5d8e701975234a26887be58fc44df8dd372d2877 100644 (file)
@@ -22,7 +22,7 @@
 #include <hurd.h>
 #include <mach/mach4.h>
 #include <mach/pc_sample.h>
-#include <cthreads.h>
+#include <lock-intern.h>
 #include <assert.h>
 #include <libc-internal.h>