├── tests ├── .cvsignore ├── README ├── test-12.c ├── test-2.c ├── test-8.c ├── test-1.c ├── test-10.c ├── test-14.c ├── Makefile ├── test-3.c ├── test-16.c ├── test-5.c ├── test-17.c └── test-7.c ├── shlib-versions ├── sysdeps ├── mach │ ├── hurd │ │ ├── Implies │ │ ├── pt-sigstate-destroy.c │ │ ├── pt-attr-setstacksize.c │ │ ├── pt-attr-setstackaddr.c │ │ ├── pt-sigstate-init.c │ │ └── pt-hurd-cond-wait.c │ ├── pt-wakeup.c │ ├── pt-block.c │ ├── pt-spin.c │ ├── bits │ │ └── spin-lock.h │ └── pt-thread-halt.c ├── pthread │ └── Makefile ├── generic │ ├── killpg.c │ ├── pt-key.h │ ├── sigemptyset.c │ ├── pt-startup.c │ ├── sigfillset.c │ ├── pt-getspecific.c │ ├── pt-key-delete.c │ ├── bits │ │ ├── thread-specific.h │ │ ├── pthread-np.h │ │ ├── pthreadtypes.h │ │ ├── once.h │ │ ├── condition-attr.h │ │ ├── rwlock-attr.h │ │ ├── barrier-attr.h │ │ ├── pthread.h │ │ ├── condition.h │ │ ├── barrier.h │ │ ├── semaphore.h │ │ └── mutex-attr.h │ ├── pt-barrier-destroy.c │ ├── pt-init-specific.c │ ├── pt-setspecific.c │ ├── pt-mutexattr-destroy.c │ ├── pt-rwlockattr-destroy.c │ ├── pt-barrierattr-destroy.c │ ├── pt-key-create.c │ ├── pt-getconcurrency.c │ ├── pt-setschedprio.c │ ├── pt-barrier.c │ ├── pt-kill.c │ ├── pt-rwlock-attr.c │ ├── pt-mutexattr-init.c │ ├── sigwait.c │ ├── pt-rwlockattr-init.c │ ├── pt-attr-destroy.c │ ├── pt-barrierattr-init.c │ ├── sigaddset.c │ ├── sigdelset.c │ ├── pt-cond-destroy.c │ ├── pt-destroy-specific.c │ ├── pt-mutex-getprioceiling.c │ ├── pt-mutex-setprioceiling.c │ ├── pt-mutexattr-gettype.c │ ├── pt-mutexattr-setprioceiling.c │ ├── pt-attr-setstackaddr.c │ ├── pt-attr-setguardsize.c │ ├── pt-mutexattr-getprioceiling.c │ ├── pt-attr-getguardsize.c │ ├── pt-attr-getstackaddr.c │ ├── pt-attr-getstacksize.c │ ├── pt-rwlock-destroy.c │ ├── sem-close.c │ ├── pt-atfork.c │ ├── pt-attr-init.c │ ├── pt-cond.c │ ├── pt-condattr-getpshared.c │ ├── pt-barrierattr-getpshared.c │ ├── pt-condattr-destroy.c │ ├── pt-mutexattr-getpshared.c │ ├── pt-mutexattr-getprotocol.c │ ├── pt-rwlockattr-getpshared.c │ ├── sem-unlink.c │ ├── pt-condattr-getclock.c │ ├── sigismember.c │ ├── pt-condattr-init.c │ ├── sem-open.c │ ├── siginterrupt.c │ ├── pt-getschedparam.c │ ├── pt-setconcurrency.c │ ├── pt-equal.c │ ├── pt-setschedparam.c │ ├── pt-attr-getscope.c │ ├── pt-attr-getschedpolicy.c │ ├── pt-attr-getstack.c │ ├── pt-getcpuclockid.c │ ├── pt-attr-getdetachstate.c │ ├── sem-wait.c │ ├── pt-attr-getinheritsched.c │ ├── sem-getvalue.c │ ├── sem-destroy.c │ ├── pt-attr-getschedparam.c │ ├── raise.c │ ├── pt-mutexattr-settype.c │ ├── pt-condattr-setpshared.c │ ├── pt-mutexattr-setpshared.c │ ├── pt-barrierattr-setpshared.c │ ├── pt-rwlockattr-setpshared.c │ ├── pt-rwlock-rdlock.c │ ├── pt-rwlock-wrlock.c │ ├── pt-mutex-destroy.c │ ├── signal.c │ ├── pt-once.c │ ├── pt-attr-setdetachstate.c │ ├── pt-attr-setinheritsched.c │ ├── sem-trywait.c │ ├── pt-attr-setschedpolicy.c │ ├── sem-init.c │ ├── pt-attr-setschedparam.c │ ├── pt-mutexattr-setprotocol.c │ ├── pt-cond-brdcast.c │ ├── pt-mutex-lock.c │ ├── pt-cond-signal.c │ ├── pt-attr-setscope.c │ ├── pt-attr-setstacksize.c │ ├── pt-attr.c │ ├── pt-cond-wait.c │ ├── pt-cond-init.c │ ├── pt-rwlock-init.c │ └── pt-rwlock-trywrlock.c ├── i386 │ ├── pt-machdep.h │ ├── machine-sp.h │ └── bits │ │ ├── spin-lock.h │ │ └── memory.h └── hurd │ ├── pt-init-specific.c │ ├── pt-getspecific.c │ ├── pt-setspecific.c │ └── pt-kill.c ├── configure.in ├── include └── pthread.h ├── ChangeLog ├── Makeconfig ├── not-in-libc.h ├── pthread ├── Versions ├── pt-yield.c ├── pt-cleanup.c ├── pt-self.c ├── pt-sigmask.c ├── pt-testcancel.c ├── pt-spin-inlines.c ├── pt-setcanceltype.c └── pt-setcancelstate.c ├── libpthread.a ├── libpthread_pic.a ├── signal ├── README ├── sig-internal.c ├── sigsuspend.c ├── sigtimedwait.c ├── sigpending.c └── TODO └── libc_pthread_init.c /tests/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile.in 2 | -------------------------------------------------------------------------------- /shlib-versions: -------------------------------------------------------------------------------- 1 | .*-.*-.* libpthread=0.3 2 | -------------------------------------------------------------------------------- /sysdeps/mach/hurd/Implies: -------------------------------------------------------------------------------- 1 | hurd 2 | pthread 3 | -------------------------------------------------------------------------------- /configure.in: -------------------------------------------------------------------------------- 1 | GLIBC_PROVIDES 2 | 3 | libc_add_on_canonical=libpthread 4 | libc_add_on_subdirs=. 5 | -------------------------------------------------------------------------------- /sysdeps/pthread/Makefile: -------------------------------------------------------------------------------- 1 | ifeq ($(subdir),posix) 2 | CFLAGS-confstr.c += -DLIBPTHREAD_VERSION='"libpthread $(pthread-version)"' 3 | endif 4 | -------------------------------------------------------------------------------- /include/pthread.h: -------------------------------------------------------------------------------- 1 | #ifndef _PTHREAD_H 2 | #include 3 | 4 | extern int __pthread_mutex_lock (pthread_mutex_t *__mutex); 5 | extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /tests/README: -------------------------------------------------------------------------------- 1 | Testing of installed package: 2 | 3 | $ [libpthread]/configure --prefix=[install_root] 4 | $ make 5 | $ make install 6 | $ make -C [libpthread]/tests/ INSTALL_ROOT=[install_root] clean check 7 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 51839d398b0f9885a17ab5c0768b8dec4dd9eb79 is the last commit imported from CVS. 2 | All commits after that one have valid author and committer information. 3 | 4 | Use this to examine the change log for earlier changes: 5 | 6 | $ git show 51839d398b0f9885a17ab5c0768b8dec4dd9eb79:ChangeLog 7 | -------------------------------------------------------------------------------- /Makeconfig: -------------------------------------------------------------------------------- 1 | # Makeconfig fragment for Hurd libpthread add-on. 2 | # This gets included at the end of the main glibc Makeconfig. 3 | 4 | have-thread-library = yes 5 | 6 | shared-thread-library = $(common-objpfx)libpthread/libpthread.so 7 | static-thread-library = $(common-objpfx)libpthread/libpthread.a 8 | bounded-thread-library = $(static-thread-library) 9 | 10 | rpath-dirs += libpthread 11 | 12 | +includes += -I$(..)libpthread/include 13 | -------------------------------------------------------------------------------- /not-in-libc.h: -------------------------------------------------------------------------------- 1 | #define __mach_port_insert_right mach_port_insert_right 2 | #define __mach_port_allocate mach_port_allocate 3 | #define __mig_init mig_init 4 | #define __thread_create thread_create 5 | #define __thread_get_state thread_get_state 6 | #define __thread_resume thread_resume 7 | #define __thread_set_state thread_set_state 8 | #define __thread_terminate thread_terminate 9 | #define __vm_allocate vm_allocate 10 | #define __vm_deallocate vm_deallocate 11 | #define __sched_yield sched_yield 12 | -------------------------------------------------------------------------------- /pthread/Versions: -------------------------------------------------------------------------------- 1 | libc { 2 | GLIBC_2.2 { 3 | # XXX 4 | __vm_deallocate; __mach_port_insert_right; __mach_reply_port; 5 | __mig_init; __vm_allocate; 6 | 7 | # functions used in inline functions or macros 8 | __pthread_spin_destroy; __pthread_spin_init; __pthread_spin_lock; 9 | _pthread_spin_lock; __pthread_spin_trylock; __pthread_spin_unlock; 10 | 11 | # p* 12 | pthread_spin_destroy; pthread_spin_init; pthread_spin_lock; 13 | pthread_spin_trylock; pthread_spin_unlock; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/test-12.c: -------------------------------------------------------------------------------- 1 | /* Test concurrency level. */ 2 | 3 | #define _GNU_SOURCE 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | int 11 | main (int argc, char **argv) 12 | { 13 | int i; 14 | int err; 15 | 16 | i = pthread_getconcurrency (); 17 | assert (i == 0); 18 | 19 | err = pthread_setconcurrency (-1); 20 | assert (err == EINVAL); 21 | 22 | err = pthread_setconcurrency (4); 23 | assert (err == 0); 24 | 25 | i = pthread_getconcurrency (); 26 | assert (i == 4); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /libpthread.a: -------------------------------------------------------------------------------- 1 | /* pthread initializer is weak in glibc. It must be included if glibc 2 | is to start threading. */ 3 | EXTERN(_cthread_init_routine) 4 | 5 | /* Weak references in glibc that must be filled if glibc is to be 6 | thread safe. */ 7 | EXTERN(cthread_detach) 8 | EXTERN(cthread_fork) 9 | EXTERN(cthread_keycreate) 10 | EXTERN(cthread_getspecific) 11 | EXTERN(__libc_getspecific) 12 | EXTERN(cthread_setspecific) 13 | EXTERN(__mutex_lock_solid) 14 | EXTERN(__mutex_unlock_solid) 15 | /* For libio stream locking. */ 16 | EXTERN(_cthreads_flockfile) 17 | EXTERN(_cthreads_funlockfile) 18 | EXTERN(_cthreads_ftrylockfile) 19 | 20 | GROUP(-lpthread2 -lihash -lrt) 21 | -------------------------------------------------------------------------------- /libpthread_pic.a: -------------------------------------------------------------------------------- 1 | /* pthread initializer is weak in glibc. It must be included if glibc 2 | is to start threading. */ 3 | EXTERN(_cthread_init_routine) 4 | 5 | /* Weak references in glibc that must be filled if glibc is to be 6 | thread safe. */ 7 | EXTERN(cthread_detach) 8 | EXTERN(cthread_fork) 9 | EXTERN(cthread_keycreate) 10 | EXTERN(cthread_getspecific) 11 | EXTERN(__libc_getspecific) 12 | EXTERN(cthread_setspecific) 13 | EXTERN(__mutex_lock_solid) 14 | EXTERN(__mutex_unlock_solid) 15 | /* For libio stream locking. */ 16 | EXTERN(_cthreads_flockfile) 17 | EXTERN(_cthreads_funlockfile) 18 | EXTERN(_cthreads_ftrylockfile) 19 | 20 | GROUP(-lpthread2_pic -lihash_pic) 21 | -------------------------------------------------------------------------------- /signal/README: -------------------------------------------------------------------------------- 1 | This directory provides a signal implementation, which is appropriate 2 | for operating systems where signals are managed at user-level. It is 3 | up to the run-time to catch the signals and forward them to the 4 | implementation via, e.g., the pthread_kill_info_np call. 5 | 6 | The files in this directory are accompanied by the generic implementations 7 | found in sysdeps/generic/: killpg.c, raise.c, sigaddset.c, sigdelset.c, 8 | sigemptyset.c, sigfillset.c, siginterrupt.c, sigismember.c, signal.c, 9 | sigwait.c. 10 | 11 | This implementation was once used for a native port running on L4, but is not 12 | currently used in any libpthread port bundled in this release. 13 | -------------------------------------------------------------------------------- /tests/test-2.c: -------------------------------------------------------------------------------- 1 | /* Test detachability. */ 2 | #define _GNU_SOURCE 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | void * 11 | thread (void *arg) 12 | { 13 | while (1) 14 | sched_yield (); 15 | } 16 | 17 | int 18 | main (int argc, char **argv) 19 | { 20 | int err; 21 | pthread_t tid; 22 | void *ret; 23 | 24 | err = pthread_create (&tid, 0, thread, 0); 25 | if (err) 26 | error (1, err, "pthread_create"); 27 | 28 | err = pthread_detach (tid); 29 | if (err) 30 | error (1, err, "pthread_detach"); 31 | 32 | err = pthread_detach (tid); 33 | assert (err == EINVAL); 34 | 35 | err = pthread_join (tid, &ret); 36 | assert (err == EINVAL); 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /sysdeps/generic/killpg.c: -------------------------------------------------------------------------------- 1 | /* killpg.c - Generic killpg implementation. 2 | Copyright (C) 2008 Free Software Foundation, Inc. 3 | Written by Neal H. Walfield . 4 | 5 | This file is part of the GNU Hurd. 6 | 7 | The GNU Hurd is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 3 of 10 | the License, or (at your option) any later version. 11 | 12 | The GNU Hurd is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this program. If not, see 19 | . */ 20 | 21 | #include "sig-internal.h" 22 | 23 | int 24 | killpg (pid_t pid, int sig) 25 | { 26 | return kill (-pid, sig); 27 | } 28 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-key.h: -------------------------------------------------------------------------------- 1 | /* pthread_key internal declatations. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | 22 | #define PTHREAD_KEY_MEMBERS 23 | -------------------------------------------------------------------------------- /sysdeps/generic/sigemptyset.c: -------------------------------------------------------------------------------- 1 | /* sigemptyset.c - Generic sigemptyset implementation. 2 | Copyright (C) 2008 Free Software Foundation, Inc. 3 | Written by Neal H. Walfield . 4 | 5 | This file is part of the GNU Hurd. 6 | 7 | The GNU Hurd is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 3 of 10 | the License, or (at your option) any later version. 11 | 12 | The GNU Hurd is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this program. If not, see 19 | . */ 20 | 21 | #include 22 | 23 | int 24 | sigemptyset (sigset_t *sigset) 25 | { 26 | *sigset = 0; 27 | return 0; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /tests/test-8.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #define THREADS 10 9 | 10 | pthread_once_t inc_var_once = PTHREAD_ONCE_INIT; 11 | int var; 12 | 13 | void 14 | inc_var (void) 15 | { 16 | var ++; 17 | } 18 | 19 | void * 20 | thr (void *arg) 21 | { 22 | int i; 23 | 24 | for (i = 0; i < 500; i ++) 25 | pthread_once (&inc_var_once, inc_var); 26 | 27 | return 0; 28 | } 29 | 30 | int 31 | main (int argc, char **argv) 32 | { 33 | error_t err; 34 | int i; 35 | pthread_t tid[THREADS]; 36 | 37 | for (i = 0; i < THREADS; i ++) 38 | { 39 | err = pthread_create (&tid[i], 0, thr, 0); 40 | if (err) 41 | error (1, err, "pthread_create (%d)", i); 42 | } 43 | 44 | assert (thr (0) == 0); 45 | 46 | for (i = 0; i < THREADS; i ++) 47 | { 48 | void *ret; 49 | 50 | err = pthread_join (tid[i], &ret); 51 | if (err) 52 | error (1, err, "pthread_join"); 53 | 54 | assert (ret == 0); 55 | } 56 | 57 | assert (var == 1); 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-startup.c: -------------------------------------------------------------------------------- 1 | /* Thread initialization. Generic version. 2 | Copyright (C) 2008 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | 22 | void 23 | __pthread_startup (void) 24 | { 25 | } 26 | -------------------------------------------------------------------------------- /sysdeps/generic/sigfillset.c: -------------------------------------------------------------------------------- 1 | /* sigfillset.c - Generic sigfillset implementation. 2 | Copyright (C) 2008 Free Software Foundation, Inc. 3 | Written by Neal H. Walfield . 4 | 5 | This file is part of the GNU Hurd. 6 | 7 | The GNU Hurd is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 3 of 10 | the License, or (at your option) any later version. 11 | 12 | The GNU Hurd is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this program. If not, see 19 | . */ 20 | 21 | #include 22 | 23 | int 24 | sigfillset (sigset_t *sigset) 25 | { 26 | *sigset = (1ULL << (NSIG - 1)) - 1; 27 | return 0; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /signal/sig-internal.c: -------------------------------------------------------------------------------- 1 | /* sig-internal.c - Signal state functions. 2 | Copyright (C) 2008 Free Software Foundation, Inc. 3 | Written by Neal H. Walfield . 4 | 5 | This file is part of the GNU Hurd. 6 | 7 | The GNU Hurd is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 3 of 10 | the License, or (at your option) any later version. 11 | 12 | The GNU Hurd is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this program. If not, see 19 | . */ 20 | 21 | #include "sig-internal.h" 22 | 23 | pthread_mutex_t sig_lock = PTHREAD_MUTEX_INITIALIZER; 24 | 25 | sigset_t process_pending; 26 | siginfo_t process_pending_info[NSIG]; 27 | -------------------------------------------------------------------------------- /signal/sigsuspend.c: -------------------------------------------------------------------------------- 1 | /* sigsuspend.c - Generic sigsuspend implementation. 2 | Copyright (C) 2008 Free Software Foundation, Inc. 3 | Written by Neal H. Walfield . 4 | 5 | This file is part of the GNU Hurd. 6 | 7 | The GNU Hurd is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 3 of 10 | the License, or (at your option) any later version. 11 | 12 | The GNU Hurd is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this program. If not, see 19 | . */ 20 | 21 | #include "sig-internal.h" 22 | 23 | int 24 | sigsuspend (const sigset_t *set) 25 | { 26 | /* XXX: Implement me. */ 27 | errno = EOPNOTSUPP; 28 | return -1; 29 | } 30 | -------------------------------------------------------------------------------- /pthread/pt-yield.c: -------------------------------------------------------------------------------- 1 | /* Yield the processor to another thread or process. 2 | Copyright (C) 2010 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int pthread_yield(void) 24 | { 25 | return sched_yield (); 26 | } 27 | -------------------------------------------------------------------------------- /tests/test-1.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #define THREADS 500 11 | 12 | void * 13 | foo (void *arg) 14 | { 15 | pthread_mutex_t *mutex = arg; 16 | pthread_mutex_lock (mutex); 17 | pthread_mutex_unlock (mutex); 18 | return mutex; 19 | } 20 | 21 | int 22 | main (int argc, char **argv) 23 | { 24 | int i; 25 | error_t err; 26 | pthread_t tid[THREADS]; 27 | pthread_mutex_t mutex[THREADS]; 28 | 29 | for (i = 0; i < THREADS; i ++) 30 | { 31 | pthread_mutex_init (&mutex[i], 0); 32 | pthread_mutex_lock (&mutex[i]); 33 | err = pthread_create (&tid[i], 0, foo, &mutex[i]); 34 | if (err) 35 | error (1, err, "pthread_create"); 36 | sched_yield (); 37 | } 38 | 39 | for (i = THREADS - 1; i >= 0; i --) 40 | { 41 | void *ret; 42 | pthread_mutex_unlock (&mutex[i]); 43 | err = pthread_join (tid[i], &ret); 44 | if (err) 45 | error (1, err, "pthread_join"); 46 | assert (ret == &mutex[i]); 47 | } 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /tests/test-10.c: -------------------------------------------------------------------------------- 1 | /* Test error checking mutexes. */ 2 | 3 | #define _GNU_SOURCE 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | int 11 | main (int argc, char **argv) 12 | { 13 | error_t err; 14 | pthread_mutexattr_t mattr; 15 | pthread_mutex_t mutex; 16 | 17 | err = pthread_mutexattr_init (&mattr); 18 | if (err) 19 | error (1, err, "pthread_mutexattr_init"); 20 | 21 | err = pthread_mutexattr_settype (&mattr, PTHREAD_MUTEX_ERRORCHECK); 22 | if (err) 23 | error (1, err, "pthread_mutexattr_settype"); 24 | 25 | err = pthread_mutex_init (&mutex, &mattr); 26 | if (err) 27 | error (1, err, "pthread_mutex_init"); 28 | 29 | err = pthread_mutexattr_destroy (&mattr); 30 | if (err) 31 | error (1, err, "pthread_mutexattr_destroy"); 32 | 33 | err = pthread_mutex_lock (&mutex); 34 | assert (err == 0); 35 | 36 | err = pthread_mutex_lock (&mutex); 37 | assert (err == EDEADLK); 38 | 39 | err = pthread_mutex_unlock (&mutex); 40 | assert (err == 0); 41 | 42 | err = pthread_mutex_unlock (&mutex); 43 | assert (err == EPERM); 44 | 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-getspecific.c: -------------------------------------------------------------------------------- 1 | /* pthread_getspecific. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_getspecific (pthread_key_t key) 25 | { 26 | return EINVAL; 27 | } 28 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-key-delete.c: -------------------------------------------------------------------------------- 1 | /* pthread_key_delete. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_key_delete (pthread_key_t key) 25 | { 26 | return ENOSYS; 27 | } 28 | -------------------------------------------------------------------------------- /sysdeps/generic/bits/thread-specific.h: -------------------------------------------------------------------------------- 1 | /* Thread specific data. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #ifndef _BITS_THREAD_SPECIFIC_H 21 | #define _BITS_THREAD_SPECIFIC_H 1 22 | 23 | typedef int __pthread_key; 24 | 25 | #endif /* bits/thread-specific.h */ 26 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-barrier-destroy.c: -------------------------------------------------------------------------------- 1 | /* pthread_barrier_destroy. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_barrier_destroy (pthread_barrier_t *barrier) 25 | { 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-init-specific.c: -------------------------------------------------------------------------------- 1 | /* __pthread_init_specific. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | error_t 24 | __pthread_init_specific (struct __pthread *thread) 25 | { 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-setspecific.c: -------------------------------------------------------------------------------- 1 | /* pthread_setspecific. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_setspecific (pthread_key_t key, const void *value) 25 | { 26 | return EINVAL; 27 | } 28 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-mutexattr-destroy.c: -------------------------------------------------------------------------------- 1 | /* pthread_mutexattr_destroy. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_mutexattr_destroy (pthread_mutexattr_t *attr) 25 | { 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-rwlockattr-destroy.c: -------------------------------------------------------------------------------- 1 | /* pthread_rwlockattr_destroy. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_rwlockattr_destroy (pthread_rwlockattr_t *attr) 25 | { 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /signal/sigtimedwait.c: -------------------------------------------------------------------------------- 1 | /* sigtimedwait.c - Generic sigtimedwait implementation. 2 | Copyright (C) 2008 Free Software Foundation, Inc. 3 | Written by Neal H. Walfield . 4 | 5 | This file is part of the GNU Hurd. 6 | 7 | The GNU Hurd is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 3 of 10 | the License, or (at your option) any later version. 11 | 12 | The GNU Hurd is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this program. If not, see 19 | . */ 20 | 21 | #include "sig-internal.h" 22 | 23 | int 24 | sigtimedwait (const sigset_t *restrict set, siginfo_t *restrict info, 25 | const struct timespec *restrict timeout) 26 | { 27 | errno = EOPNOTSUPP; 28 | return -1; 29 | } 30 | 31 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-barrierattr-destroy.c: -------------------------------------------------------------------------------- 1 | /* pthread_barrierattr_destroy. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_barrierattr_destroy (pthread_barrierattr_t *attr) 25 | { 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-key-create.c: -------------------------------------------------------------------------------- 1 | /* pthread_key_create. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_key_create (pthread_key_t *key, void (*destructor) (void *)) 25 | { 26 | return ENOSYS; 27 | } 28 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-getconcurrency.c: -------------------------------------------------------------------------------- 1 | /* Get the current level of desired concurrency. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_getconcurrency (void) 25 | { 26 | return __pthread_concurrency; 27 | } 28 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-setschedprio.c: -------------------------------------------------------------------------------- 1 | /* Set the scheduling priority of a thread. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_setschedprio (pthread_t thread, int prio) 25 | { 26 | return ENOSYS; 27 | } 28 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-barrier.c: -------------------------------------------------------------------------------- 1 | /* Default barrier attributes. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | const struct __pthread_barrierattr __pthread_default_barrierattr = 24 | { 25 | pshared: PTHREAD_PROCESS_PRIVATE 26 | }; 27 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-kill.c: -------------------------------------------------------------------------------- 1 | /* pthread-kill.c - Generic pthread-kill implementation. 2 | Copyright (C) 2008 Free Software Foundation, Inc. 3 | Written by Neal H. Walfield . 4 | 5 | This file is part of the GNU Hurd. 6 | 7 | The GNU Hurd is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 3 of 10 | the License, or (at your option) any later version. 11 | 12 | The GNU Hurd is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this program. If not, see 19 | . */ 20 | 21 | #include "sig-internal.h" 22 | 23 | int 24 | pthread_kill (pthread_t tid, int signo) 25 | { 26 | siginfo_t si; 27 | memset (&si, 0, sizeof (si)); 28 | si.si_signo = signo; 29 | 30 | return pthread_kill_siginfo_np (tid, si); 31 | } 32 | 33 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-rwlock-attr.c: -------------------------------------------------------------------------------- 1 | /* Default rwlock attributes. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | const struct __pthread_rwlockattr __pthread_default_rwlockattr = 24 | { 25 | pshared: PTHREAD_PROCESS_PRIVATE 26 | }; 27 | -------------------------------------------------------------------------------- /sysdeps/i386/pt-machdep.h: -------------------------------------------------------------------------------- 1 | /* Machine dependent pthreads internal defenitions. i386 version. 2 | Copyright (C) 2000 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #ifndef _PT_MACHDEP_H 21 | #define _PT_MACHDEP_H 1 22 | 23 | struct pthread_mcontext 24 | { 25 | void *pc; 26 | void *sp; 27 | }; 28 | 29 | #endif /* pt-machdep.h */ 30 | -------------------------------------------------------------------------------- /sysdeps/mach/hurd/pt-sigstate-destroy.c: -------------------------------------------------------------------------------- 1 | /* Destroy the signal state. Hurd on Mach version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | 22 | #include 23 | 24 | void 25 | __pthread_sigstate_destroy (struct __pthread *thread) 26 | { 27 | /* Nothing to do. */ 28 | } 29 | -------------------------------------------------------------------------------- /tests/test-14.c: -------------------------------------------------------------------------------- 1 | /* Test pthread_mutex_timedlock. */ 2 | 3 | #define _GNU_SOURCE 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int 13 | main (int argc, char **argv) 14 | { 15 | error_t err; 16 | struct timespec ts; 17 | pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; 18 | struct timeval before, after; 19 | int diff; 20 | 21 | gettimeofday (&before, 0); 22 | ts.tv_sec = before.tv_sec + 1; 23 | ts.tv_nsec = before.tv_usec * 1000; 24 | 25 | printf ("Starting wait @ %d\n", (int) before.tv_sec); 26 | 27 | pthread_mutex_lock (&m); 28 | /* A default mutex shall dead lock if locked twice. As such we do 29 | not need spawn a second thread. */ 30 | err = pthread_mutex_timedlock (&m, &ts); 31 | assert (err == ETIMEDOUT); 32 | 33 | gettimeofday (&after, 0); 34 | 35 | printf ("End wait @ %d\n", (int) after.tv_sec); 36 | 37 | diff = after.tv_sec * 1000000 + after.tv_usec 38 | - before.tv_sec * 1000000 - before.tv_usec; 39 | 40 | if (diff < 900000 || diff > 1100000) 41 | error (1, EGRATUITOUS, "pthread_mutex_timedlock waited %d us", diff); 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /pthread/pt-cleanup.c: -------------------------------------------------------------------------------- 1 | /* Add a cancelation handler to the stack. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | 22 | #include 23 | 24 | struct __pthread_cancelation_handler ** 25 | __pthread_get_cleanup_stack (void) 26 | { 27 | return &_pthread_self ()->cancelation_handlers; 28 | } 29 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-mutexattr-init.c: -------------------------------------------------------------------------------- 1 | /* pthread_mutexattr_init. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_mutexattr_init (pthread_mutexattr_t *attr) 25 | { 26 | *attr = __pthread_default_mutexattr; 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /sysdeps/generic/sigwait.c: -------------------------------------------------------------------------------- 1 | /* sigwait.c - Generic sigwait implementation. 2 | Copyright (C) 2008 Free Software Foundation, Inc. 3 | Written by Neal H. Walfield . 4 | 5 | This file is part of the GNU Hurd. 6 | 7 | The GNU Hurd is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 3 of 10 | the License, or (at your option) any later version. 11 | 12 | The GNU Hurd is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this program. If not, see 19 | . */ 20 | 21 | #include "sig-internal.h" 22 | 23 | int 24 | sigwait (const sigset_t *restrict set, int *restrict signo) 25 | { 26 | siginfo_t info; 27 | 28 | if (sigwaitinfo (set, &info) < 0) 29 | return -1; 30 | 31 | *signo = info.si_signo; 32 | return 0; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /sysdeps/generic/bits/pthread-np.h: -------------------------------------------------------------------------------- 1 | /* Non-portable functions. Generic version. 2 | Copyright (C) 2008 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | /* 21 | * Never include this file directly; use or instead. 22 | */ 23 | 24 | #ifndef _BITS_PTHREAD_NP_H 25 | #define _BITS_PTHREAD_NP_H 1 26 | 27 | #endif /* bits/pthread-np.h */ 28 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-rwlockattr-init.c: -------------------------------------------------------------------------------- 1 | /* pthread_rwlockattr_init. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_rwlockattr_init (pthread_rwlockattr_t *attr) 25 | { 26 | *attr = __pthread_default_rwlockattr; 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-attr-destroy.c: -------------------------------------------------------------------------------- 1 | /* pthread_attr_destroy. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | __pthread_attr_destroy (pthread_attr_t *attr) 25 | { 26 | return 0; 27 | } 28 | strong_alias (__pthread_attr_destroy, pthread_attr_destroy); 29 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-barrierattr-init.c: -------------------------------------------------------------------------------- 1 | /* pthread_barrierattr_init. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_barrierattr_init (pthread_barrierattr_t *attr) 25 | { 26 | *attr = __pthread_default_barrierattr; 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /sysdeps/generic/sigaddset.c: -------------------------------------------------------------------------------- 1 | /* sigaddset.c - Generic sigaddset implementation. 2 | Copyright (C) 2008 Free Software Foundation, Inc. 3 | Written by Neal H. Walfield . 4 | 5 | This file is part of the GNU Hurd. 6 | 7 | The GNU Hurd is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 3 of 10 | the License, or (at your option) any later version. 11 | 12 | The GNU Hurd is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this program. If not, see 19 | . */ 20 | 21 | #include "sig-internal.h" 22 | 23 | int 24 | sigaddset (sigset_t *sigset, int signo) 25 | { 26 | if (signo <= 0 || signo >= NSIG) 27 | { 28 | errno = EINVAL; 29 | return -1; 30 | } 31 | 32 | *sigset |= sigmask (signo); 33 | return 0; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /sysdeps/generic/sigdelset.c: -------------------------------------------------------------------------------- 1 | /* sigdelset.c - Generic sigdelset implementation. 2 | Copyright (C) 2008 Free Software Foundation, Inc. 3 | Written by Neal H. Walfield . 4 | 5 | This file is part of the GNU Hurd. 6 | 7 | The GNU Hurd is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 3 of 10 | the License, or (at your option) any later version. 11 | 12 | The GNU Hurd is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this program. If not, see 19 | . */ 20 | 21 | #include "sig-internal.h" 22 | 23 | int 24 | sigdelset (sigset_t *sigset, int signo) 25 | { 26 | if (signo <= 0 || signo >= NSIG) 27 | { 28 | errno = EINVAL; 29 | return -1; 30 | } 31 | 32 | *sigset &= ~sigmask (signo); 33 | return 0; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-cond-destroy.c: -------------------------------------------------------------------------------- 1 | /* pthread_cond_destroy. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | __pthread_cond_destroy (pthread_cond_t *cond) 25 | { 26 | return 0; 27 | } 28 | 29 | strong_alias (__pthread_cond_destroy, pthread_cond_destroy); 30 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-destroy-specific.c: -------------------------------------------------------------------------------- 1 | /* __pthread_destory_specific. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | void 24 | __pthread_destory_specifc (struct __pthread *thread) 25 | { 26 | /* Not support, thus there cannot be any. */ 27 | return; 28 | } 29 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-mutex-getprioceiling.c: -------------------------------------------------------------------------------- 1 | /* Get a mutex' priority ceiling. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_mutex_getprioceiling (const pthread_mutex_t *mutex, 25 | int *prioceiling) 26 | { 27 | return ENOSYS; 28 | } 29 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-mutex-setprioceiling.c: -------------------------------------------------------------------------------- 1 | /* Set a mutex' priority ceiling. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_mutex_setprioceiling (pthread_mutex_t *mutex, int prio, 25 | int *oldprio) 26 | { 27 | return ENOSYS; 28 | } 29 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-mutexattr-gettype.c: -------------------------------------------------------------------------------- 1 | /* pthread_mutexattr_gettype. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_mutexattr_gettype (const pthread_mutexattr_t *attr, int *type) 25 | { 26 | *type = attr->mutex_type; 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-mutexattr-setprioceiling.c: -------------------------------------------------------------------------------- 1 | /* pthread_mutexattr_setprioceiling. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_mutexattr_setprioceiling (pthread_mutexattr_t *attr, 25 | int prioceiling) 26 | { 27 | return ENOSYS; 28 | } 29 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-attr-setstackaddr.c: -------------------------------------------------------------------------------- 1 | /* pthread_attr_setstackaddr. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_attr_setstackaddr (pthread_attr_t *attr, 25 | void *stackaddr) 26 | { 27 | attr->stackaddr = stackaddr; 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /sysdeps/hurd/pt-init-specific.c: -------------------------------------------------------------------------------- 1 | /* __pthread_init_specific. Hurd version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | error_t 26 | __pthread_init_specific (struct __pthread *thread) 27 | { 28 | thread->thread_specifics = 0; 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-attr-setguardsize.c: -------------------------------------------------------------------------------- 1 | /* pthread_attr_setguardsize. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_attr_setguardsize (pthread_attr_t *attr, 25 | size_t guardsize) 26 | { 27 | attr->guardsize = guardsize; 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-mutexattr-getprioceiling.c: -------------------------------------------------------------------------------- 1 | /* pthread_mutexattr_getprioceiling. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_mutexattr_getprioceiling (const pthread_mutexattr_t *attr, 25 | int *prioceiling) 26 | { 27 | return ENOSYS; 28 | } 29 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-attr-getguardsize.c: -------------------------------------------------------------------------------- 1 | /* pthread_attr_getguardsize. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_attr_getguardsize (const pthread_attr_t *attr, 25 | size_t *guardsize) 26 | { 27 | *guardsize = attr->guardsize; 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-attr-getstackaddr.c: -------------------------------------------------------------------------------- 1 | /* pthread_attr_getstackaddr. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_attr_getstackaddr (const pthread_attr_t *attr, 25 | void **stackaddr) 26 | { 27 | *stackaddr = attr->stackaddr; 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-attr-getstacksize.c: -------------------------------------------------------------------------------- 1 | /* pthread_attr_getstacksize. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_attr_getstacksize (const pthread_attr_t *attr, 25 | size_t *stacksize) 26 | { 27 | *stacksize = attr->stacksize; 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-rwlock-destroy.c: -------------------------------------------------------------------------------- 1 | /* Destroy a rwlock. Generic version. 2 | Copyright (C) 2002, 2006 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | _pthread_rwlock_destroy (pthread_rwlock_t *rwlock) 25 | { 26 | return 0; 27 | } 28 | 29 | strong_alias (_pthread_rwlock_destroy, pthread_rwlock_destroy); 30 | -------------------------------------------------------------------------------- /sysdeps/generic/sem-close.c: -------------------------------------------------------------------------------- 1 | /* Close a named semaphore. Generic version. 2 | Copyright (C) 2005 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | int 26 | __sem_close (sem_t *sem) 27 | { 28 | errno = EOPNOTSUPP; 29 | return -1; 30 | } 31 | 32 | strong_alias (__sem_close, sem_close); 33 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-atfork.c: -------------------------------------------------------------------------------- 1 | /* Register fork handlers. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_atfork (void (*prepare) (void), 25 | void (*parent) (void), 26 | void (*child) (void)) 27 | { 28 | return __register_atfork (prepare, parent, child); 29 | } 30 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-attr-init.c: -------------------------------------------------------------------------------- 1 | /* pthread_attr_init. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | __pthread_attr_init (pthread_attr_t *attr) 25 | { 26 | *attr = __pthread_default_attr; 27 | return 0; 28 | } 29 | strong_alias (__pthread_attr_init, pthread_attr_init); 30 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-cond.c: -------------------------------------------------------------------------------- 1 | /* Default condition attributes. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | const struct __pthread_condattr __pthread_default_condattr = 26 | { 27 | pshared: PTHREAD_PROCESS_PRIVATE, 28 | clock: CLOCK_REALTIME 29 | }; 30 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-condattr-getpshared.c: -------------------------------------------------------------------------------- 1 | /* pthread_condattr_getpshared. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_condattr_getpshared (const pthread_condattr_t *attr, 25 | int *pshared) 26 | { 27 | *pshared = attr->pshared; 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-barrierattr-getpshared.c: -------------------------------------------------------------------------------- 1 | /* pthread_barrierattr_getpshared. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_barrierattr_getpshared (const pthread_barrierattr_t *attr, 25 | int *pshared) 26 | { 27 | *pshared = attr->pshared; 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-condattr-destroy.c: -------------------------------------------------------------------------------- 1 | /* pthread_condattr_destroy. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | __pthread_condattr_destroy (pthread_condattr_t *cond) 25 | { 26 | return 0; 27 | } 28 | 29 | strong_alias (__pthread_condattr_destroy, pthread_condattr_destroy); 30 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-mutexattr-getpshared.c: -------------------------------------------------------------------------------- 1 | /* pthread_mutexattr_getpshared. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_mutexattr_getpshared (const pthread_mutexattr_t *attr, 25 | int *pshared) 26 | { 27 | *pshared = attr->pshared; 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-mutexattr-getprotocol.c: -------------------------------------------------------------------------------- 1 | /* pthread_mutexattr_getprotocol. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_mutexattr_getprotocol (const pthread_mutexattr_t *attr, 25 | int *protocol) 26 | { 27 | *protocol = attr->protocol; 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-rwlockattr-getpshared.c: -------------------------------------------------------------------------------- 1 | /* pthread_rwlockattr_getpshared. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *attr, 25 | int *pshared) 26 | { 27 | *pshared = attr->pshared; 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /sysdeps/generic/sem-unlink.c: -------------------------------------------------------------------------------- 1 | /* Unlink a named semaphore. Generic version. 2 | Copyright (C) 2005, 2006 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | int 26 | __sem_unlink (const char *name) 27 | { 28 | errno = EOPNOTSUPP; 29 | return -1; 30 | } 31 | 32 | strong_alias (__sem_unlink, sem_unlink); 33 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-condattr-getclock.c: -------------------------------------------------------------------------------- 1 | /* pthread_condattr_getclock. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | int 26 | pthread_condattr_getclock (const pthread_condattr_t *attr, 27 | clockid_t *clock) 28 | { 29 | *clock = attr->clock; 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /sysdeps/generic/sigismember.c: -------------------------------------------------------------------------------- 1 | /* sigismember.c - Generic sigismember implementation. 2 | Copyright (C) 2008 Free Software Foundation, Inc. 3 | Written by Neal H. Walfield . 4 | 5 | This file is part of the GNU Hurd. 6 | 7 | The GNU Hurd is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 3 of 10 | the License, or (at your option) any later version. 11 | 12 | The GNU Hurd is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this program. If not, see 19 | . */ 20 | 21 | #include "sig-internal.h" 22 | 23 | int 24 | sigismember (const sigset_t *sigset, int signo) 25 | { 26 | if (signo <= 0 || signo >= NSIG) 27 | { 28 | errno = EINVAL; 29 | return -1; 30 | } 31 | 32 | if (*sigset & sigmask (signo)) 33 | return 1; 34 | else 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-condattr-init.c: -------------------------------------------------------------------------------- 1 | /* pthread_condattr_init. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | __pthread_condattr_init (pthread_condattr_t *attr) 25 | { 26 | *attr = __pthread_default_condattr; 27 | return 0; 28 | } 29 | 30 | strong_alias (__pthread_condattr_init, pthread_condattr_init); 31 | -------------------------------------------------------------------------------- /sysdeps/generic/sem-open.c: -------------------------------------------------------------------------------- 1 | /* Open a named semaphore. Generic version. 2 | Copyright (C) 2005, 2006 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | sem_t * 26 | __sem_open (const char *name, int open_flags, ...) 27 | { 28 | errno = EOPNOTSUPP; 29 | return SEM_FAILED; 30 | } 31 | 32 | strong_alias (__sem_open, sem_open); 33 | -------------------------------------------------------------------------------- /tests/Makefile: -------------------------------------------------------------------------------- 1 | ifdef INSTALL_ROOT 2 | INSTALL_ROOT_CPPFLAGS = -isystem $(INSTALL_ROOT)/include 3 | INSTALL_ROOT_LDFLAGS = -L$(INSTALL_ROOT)/lib -Wl,-rpath,$(INSTALL_ROOT)/lib 4 | endif 5 | 6 | CFLAGS=-Wall -g 7 | 8 | LDLIBS = -lpthread 9 | 10 | CHECK_SRC := test-1.c test-2.c test-3.c test-6.c test-7.c test-8.c \ 11 | test-9.c test-10.c test-11.c test-12.c test-13.c test-14.c \ 12 | test-15.c test-16.c test-17.c test-__pthread_destroy_specific-skip.c 13 | 14 | CHECK_OBJS := $(addsuffix .o,$(basename $(notdir $(CHECK_SRC)))) 15 | CHECK_PROGS := $(basename $(notdir $(CHECK_SRC))) \ 16 | $(addsuffix -static, $(basename $(CHECK_SRC))) 17 | 18 | %.o: %.c 19 | $(CC) $(INSTALL_ROOT_CPPFLAGS) $(CPPFLAGS) $(CFLAGS) $< -c -o $@ 20 | 21 | %: %.o 22 | $(CC) $(INSTALL_ROOT_LDFLAGS) $(LDFLAGS) $< -o $@ $(LDLIBS) 23 | 24 | %-static: %.o 25 | $(CC) -static $(INSTALL_ROOT_LDFLAGS) $(LDFLAGS) $< -o $@ $(LDLIBS) 26 | 27 | check: $(CHECK_OBJS) $(CHECK_PROGS) 28 | for i in $(CHECK_PROGS); do \ 29 | echo -n Running $$i...\ ; \ 30 | if ./$$i 2>&1 > $$i.out; \ 31 | then \ 32 | echo Success.; \ 33 | else \ 34 | echo Failure.; \ 35 | fi \ 36 | done 37 | 38 | clean: 39 | rm -f $(CHECK_OBJS) $(CHECK_PROGS) \ 40 | $(addsuffix .out,$(basename $(notdir $(CHECK_PROGS)))) -------------------------------------------------------------------------------- /sysdeps/generic/bits/pthreadtypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2000 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #if !defined _BITS_TYPES_H && !defined _PTHREAD_H 21 | # error "Never include directly; use instead." 22 | #endif 23 | 24 | #ifndef _BITS_PTHREADTYPES_H 25 | #define _BITS_PTHREADTYPES_H 1 26 | 27 | #include 28 | 29 | #endif /* bits/pthreadtypes.h */ 30 | -------------------------------------------------------------------------------- /sysdeps/generic/siginterrupt.c: -------------------------------------------------------------------------------- 1 | /* siginterrupt.c - Generic siginterrupt implementation. 2 | Copyright (C) 2008 Free Software Foundation, Inc. 3 | Written by Neal H. Walfield . 4 | 5 | This file is part of the GNU Hurd. 6 | 7 | The GNU Hurd is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 3 of 10 | the License, or (at your option) any later version. 11 | 12 | The GNU Hurd is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this program. If not, see 19 | . */ 20 | 21 | #include "sig-internal.h" 22 | 23 | int 24 | siginterrupt (int sig, int flag) 25 | { 26 | int ret; 27 | struct sigaction act; 28 | 29 | sigaction (sig, NULL, &act); 30 | if (flag) 31 | act.sa_flags &= ~SA_RESTART; 32 | else 33 | act.sa_flags |= SA_RESTART; 34 | ret = sigaction(sig, &act, NULL); 35 | return ret; 36 | } 37 | -------------------------------------------------------------------------------- /tests/test-3.c: -------------------------------------------------------------------------------- 1 | /* Test the thread attribute get and set methods. */ 2 | 3 | #define _GNU_SOURCE 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | int 11 | main (int argc, char *argv[]) 12 | { 13 | error_t err; 14 | pthread_attr_t attr; 15 | 16 | int i; 17 | struct sched_param sp; 18 | void *p; 19 | size_t sz; 20 | 21 | err = pthread_attr_init (&attr); 22 | assert_perror (err); 23 | 24 | err = pthread_attr_destroy (&attr); 25 | assert_perror (err); 26 | 27 | err = pthread_attr_init (&attr); 28 | assert_perror (err); 29 | 30 | #define TEST1(foo, rv, v) \ 31 | err = pthread_attr_get##foo (&attr, rv); \ 32 | assert_perror (err); \ 33 | \ 34 | err = pthread_attr_set##foo (&attr, v); \ 35 | assert_perror (err); 36 | 37 | #define TEST(foo, rv, v) TEST1(foo, rv, v) 38 | 39 | TEST(inheritsched, &i, i); 40 | TEST(schedparam, &sp, &sp); 41 | TEST(schedpolicy, &i, i); 42 | TEST(scope, &i, i); 43 | TEST(stackaddr, &p, p); 44 | TEST(detachstate, &i, i); 45 | TEST(guardsize, &sz, sz); 46 | TEST(stacksize, &sz, sz); 47 | 48 | err = pthread_attr_getstack (&attr, &p, &sz); 49 | assert_perror (err); 50 | 51 | err = pthread_attr_setstack (&attr, p, sz); 52 | assert_perror (err); 53 | 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /sysdeps/i386/machine-sp.h: -------------------------------------------------------------------------------- 1 | /* Machine-specific function to return the stack pointer. i386 version. 2 | Copyright (C) 1994, 1997, 2001, 2006 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _MACHINE_SP_H 21 | #define _MACHINE_SP_H 22 | 23 | /* Return the current stack pointer. */ 24 | 25 | #define __thread_stack_pointer() ({ \ 26 | register void *__sp__ asm("esp"); \ 27 | __sp__; \ 28 | }) 29 | 30 | #endif /* machine-sp.h */ 31 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-getschedparam.c: -------------------------------------------------------------------------------- 1 | /* Get the scheduling parameters for a thread. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | __pthread_getschedparam (pthread_t thread, int *policy, 25 | struct sched_param *param) 26 | { 27 | return ENOSYS; 28 | } 29 | 30 | strong_alias (__pthread_getschedparam, pthread_getschedparam); 31 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-setconcurrency.c: -------------------------------------------------------------------------------- 1 | /* Set the desired level of concurrency. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int __pthread_concurrency; 24 | 25 | int 26 | pthread_setconcurrency (int new_level) 27 | { 28 | if (new_level < 0) 29 | return EINVAL; 30 | 31 | __pthread_concurrency = new_level; 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-equal.c: -------------------------------------------------------------------------------- 1 | /* Default attributes. Generic version. 2 | Copyright (C) 2000,02 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | /* Return true if __T1 and __T2 both name the same thread. Otherwise, 24 | false. */ 25 | int 26 | __pthread_equal (pthread_t __t1, pthread_t __t2) 27 | { 28 | return __t1 == __t2; 29 | } 30 | 31 | strong_alias (__pthread_equal, pthread_equal); 32 | -------------------------------------------------------------------------------- /pthread/pt-self.c: -------------------------------------------------------------------------------- 1 | /* Get calling thread's ID. 2 | Copyright (C) 2000, 2008 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | 22 | #include 23 | 24 | /* Return the thread ID of the calling thread. */ 25 | pthread_t 26 | __pthread_self (void) 27 | { 28 | struct __pthread *self = _pthread_self (); 29 | assert (self); 30 | 31 | return self->thread; 32 | } 33 | 34 | strong_alias (__pthread_self, pthread_self); 35 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-setschedparam.c: -------------------------------------------------------------------------------- 1 | /* Set the scheduling parameters for a thread. Generic version. 2 | Copyright (C) 2002, 2005 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | __pthread_setschedparam (pthread_t thread, int policy, 25 | const struct sched_param *param) 26 | { 27 | return ENOSYS; 28 | } 29 | 30 | strong_alias (__pthread_setschedparam, pthread_setschedparam); 31 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-attr-getscope.c: -------------------------------------------------------------------------------- 1 | /* pthread_attr_getscope. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | __pthread_attr_getscope (const pthread_attr_t *attr, 25 | int *contentionscope) 26 | { 27 | *contentionscope = attr->contentionscope; 28 | return 0; 29 | } 30 | 31 | strong_alias (__pthread_attr_getscope, pthread_attr_getscope); 32 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-attr-getschedpolicy.c: -------------------------------------------------------------------------------- 1 | /* pthread_attr_getschedpolicy. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | __pthread_attr_getschedpolicy (const pthread_attr_t *attr, 25 | int *policy) 26 | { 27 | *policy = attr->schedpolicy; 28 | return 0; 29 | } 30 | 31 | strong_alias (__pthread_attr_getschedpolicy, pthread_attr_getschedpolicy); 32 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-attr-getstack.c: -------------------------------------------------------------------------------- 1 | /* pthread_attr_getstack. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_attr_getstack (const pthread_attr_t *attr, 25 | void **stackaddr, 26 | size_t *stacksize) 27 | { 28 | pthread_attr_getstackaddr (attr, stackaddr); 29 | pthread_attr_getstacksize (attr, stacksize); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-getcpuclockid.c: -------------------------------------------------------------------------------- 1 | /* Return a thread's cpu clockid. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | int 26 | pthread_getcpuclockid (pthread_t thread, clockid_t *clock) 27 | { 28 | #ifdef CLOCK_THREAD_CPUTIME_ID 29 | *clock = CLOCK_THREAD_CPUTIME_ID; 30 | return 0; 31 | #else 32 | return ENOSYS; 33 | #endif 34 | } 35 | -------------------------------------------------------------------------------- /sysdeps/generic/bits/once.h: -------------------------------------------------------------------------------- 1 | /* Dynamic package initialization data structures. Generic version. 2 | Copyright (C) 2002, 2009 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #ifndef _BITS_ONCE_H 21 | #define _BITS_ONCE_H 1 22 | 23 | #include 24 | 25 | struct __pthread_once 26 | { 27 | int run; 28 | __pthread_spinlock_t lock; 29 | }; 30 | 31 | #define __PTHREAD_ONCE_INIT \ 32 | { 0, __PTHREAD_SPIN_LOCK_INITIALIZER } 33 | 34 | #endif /* bits/once.h */ 35 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-attr-getdetachstate.c: -------------------------------------------------------------------------------- 1 | /* pthread_attr_getdetachstate. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | __pthread_attr_getdetachstate (const pthread_attr_t *attr, 25 | int *detachstate) 26 | { 27 | *detachstate = attr->detachstate; 28 | return 0; 29 | } 30 | 31 | strong_alias (__pthread_attr_getdetachstate, pthread_attr_getdetachstate); 32 | -------------------------------------------------------------------------------- /sysdeps/generic/sem-wait.c: -------------------------------------------------------------------------------- 1 | /* Wait on a semaphore. Generic version. 2 | Copyright (C) 2005, 2006 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | extern int __sem_timedwait_internal (sem_t *restrict sem, 24 | const struct timespec *restrict timeout); 25 | 26 | int 27 | __sem_wait (sem_t *sem) 28 | { 29 | return __sem_timedwait_internal (sem, 0); 30 | } 31 | 32 | strong_alias (__sem_wait, sem_wait); 33 | -------------------------------------------------------------------------------- /pthread/pt-sigmask.c: -------------------------------------------------------------------------------- 1 | /* Get or set a thread's signal mask. 2 | Copyright (C) 2000 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | int 26 | pthread_sigmask (int how, const sigset_t *set, 27 | sigset_t *oset) 28 | { 29 | struct __pthread *self = _pthread_self (); 30 | 31 | /* Do not clear SELF's pending signals. */ 32 | return __pthread_sigstate (self, how, set, oset, 0); 33 | } 34 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-attr-getinheritsched.c: -------------------------------------------------------------------------------- 1 | /* pthread_attr_getinheritsched. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | __pthread_attr_getinheritsched (const pthread_attr_t *attr, 25 | int *inheritsched) 26 | { 27 | *inheritsched = attr->inheritsched; 28 | return 0; 29 | } 30 | 31 | strong_alias (__pthread_attr_getinheritsched, pthread_attr_getinheritsched); 32 | -------------------------------------------------------------------------------- /sysdeps/generic/sem-getvalue.c: -------------------------------------------------------------------------------- 1 | /* Get the value of a semaphore. Generic version. 2 | Copyright (C) 2005, 2006 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | __sem_getvalue (sem_t *restrict sem, int *restrict value) 25 | { 26 | __pthread_spin_lock (&sem->__lock); 27 | *value = sem->__value; 28 | __pthread_spin_unlock (&sem->__lock); 29 | 30 | return 0; 31 | } 32 | 33 | strong_alias (__sem_getvalue, sem_getvalue); 34 | -------------------------------------------------------------------------------- /sysdeps/generic/sem-destroy.c: -------------------------------------------------------------------------------- 1 | /* Destroy a semaphore. Generic version. 2 | Copyright (C) 2005, 2006 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | int 26 | __sem_destroy (sem_t *sem) 27 | { 28 | if (sem->__queue) 29 | /* There are threads waiting on *SEM. */ 30 | { 31 | errno = EBUSY; 32 | return -1; 33 | } 34 | 35 | return 0; 36 | } 37 | 38 | strong_alias (__sem_destroy, sem_destroy); 39 | -------------------------------------------------------------------------------- /sysdeps/generic/bits/condition-attr.h: -------------------------------------------------------------------------------- 1 | /* Condition attribute type. Generic version. 2 | Copyright (C) 2002, 2008 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #ifndef _BITS_CONDITION_ATTR_H 21 | #define _BITS_CONDITION_ATTR_H 1 22 | 23 | #include 24 | 25 | enum __pthread_process_shared; 26 | 27 | /* User visible part of a condition attribute variable. */ 28 | struct __pthread_condattr 29 | { 30 | enum __pthread_process_shared pshared; 31 | __clockid_t clock; 32 | }; 33 | 34 | #endif /* bits/condition.h */ 35 | -------------------------------------------------------------------------------- /signal/sigpending.c: -------------------------------------------------------------------------------- 1 | /* sigpending.c - Generic sigpending implementation. 2 | Copyright (C) 2008 Free Software Foundation, Inc. 3 | Written by Neal H. Walfield . 4 | 5 | This file is part of the GNU Hurd. 6 | 7 | The GNU Hurd is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 3 of 10 | the License, or (at your option) any later version. 11 | 12 | The GNU Hurd is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this program. If not, see 19 | . */ 20 | 21 | #include 22 | #include 23 | 24 | int 25 | sigpending (sigset_t *set) 26 | { 27 | struct signal_state *ss = &_pthread_self ()->ss; 28 | 29 | pthread_mutex_lock (&ss->lock); 30 | 31 | /* There is no need to lock SIG_LOCK for process_pending since we 32 | just read it, which is atomic. */ 33 | *set = (ss->pending | process_pending) & ss->blocked; 34 | 35 | pthread_mutex_unlock (&ss->lock); 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /sysdeps/generic/bits/rwlock-attr.h: -------------------------------------------------------------------------------- 1 | /* Thread rwlock attribute type. Generic version. 2 | Copyright (C) 2002, 2008 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #ifndef _BITS_RWLOCK_ATTR_H 21 | #define _BITS_RWLOCK_ATTR_H 1 22 | 23 | enum __pthread_process_shared; 24 | 25 | /* This structure describes the attributes of a POSIX thread rwlock. 26 | Note that not all of them are supported on all systems. */ 27 | struct __pthread_rwlockattr 28 | { 29 | enum __pthread_process_shared pshared; 30 | }; 31 | 32 | #endif /* bits/rwlock-attr.h */ 33 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-attr-getschedparam.c: -------------------------------------------------------------------------------- 1 | /* pthread_attr_getschedparam. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | int 27 | __pthread_attr_getschedparam (const pthread_attr_t *attr, 28 | struct sched_param *param) 29 | { 30 | memcpy (param, &attr->schedparam, sizeof *param); 31 | return 0; 32 | } 33 | 34 | strong_alias (__pthread_attr_getschedparam, pthread_attr_getschedparam); 35 | -------------------------------------------------------------------------------- /sysdeps/generic/bits/barrier-attr.h: -------------------------------------------------------------------------------- 1 | /* Thread barrier attribute type. Generic version. 2 | Copyright (C) 2002, 2008 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #ifndef _BITS_BARRIER_ATTR_H 21 | #define _BITS_BARRIER_ATTR_H 1 22 | 23 | enum __pthread_process_shared; 24 | 25 | /* This structure describes the attributes of a POSIX thread barrier. 26 | Note that not all of them are supported on all systems. */ 27 | struct __pthread_barrierattr 28 | { 29 | enum __pthread_process_shared pshared; 30 | }; 31 | 32 | #endif /* bits/barrier-attr.h */ 33 | -------------------------------------------------------------------------------- /sysdeps/generic/raise.c: -------------------------------------------------------------------------------- 1 | /* raise.c - Generic raise implementation. 2 | Copyright (C) 2008 Free Software Foundation, Inc. 3 | Written by Neal H. Walfield . 4 | 5 | This file is part of the GNU Hurd. 6 | 7 | The GNU Hurd is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 3 of 10 | the License, or (at your option) any later version. 11 | 12 | The GNU Hurd is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this program. If not, see 19 | . */ 20 | 21 | #include "sig-internal.h" 22 | 23 | int 24 | raise (int signo) 25 | { 26 | /* According to POSIX, if we implement threads (and we do), then 27 | "the effect of the raise() function shall be equivalent to 28 | calling: pthread_kill(pthread_self(), sig);" */ 29 | 30 | debug (0, ""); 31 | int err = pthread_kill (pthread_self (), signo); 32 | debug (0, ""); 33 | if (err) 34 | { 35 | errno = err; 36 | return -1; 37 | } 38 | 39 | return 0; 40 | } 41 | 42 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-mutexattr-settype.c: -------------------------------------------------------------------------------- 1 | /* pthread_mutexattr_settype. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_mutexattr_settype (pthread_mutexattr_t *attr, int type) 25 | { 26 | switch (type) 27 | { 28 | case PTHREAD_MUTEX_NORMAL: 29 | case PTHREAD_MUTEX_ERRORCHECK: 30 | case PTHREAD_MUTEX_RECURSIVE: 31 | attr->mutex_type = type; 32 | return 0; 33 | 34 | default: 35 | return EINVAL; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /pthread/pt-testcancel.c: -------------------------------------------------------------------------------- 1 | /* Add an explicit cancelation point. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | 22 | #include 23 | 24 | void 25 | pthread_testcancel (void) 26 | { 27 | struct __pthread *p = _pthread_self (); 28 | int cancelled; 29 | 30 | __pthread_mutex_lock (&p->cancel_lock); 31 | cancelled = (p->cancel_state == PTHREAD_CANCEL_ENABLE) && p->cancel_pending; 32 | __pthread_mutex_unlock (&p->cancel_lock); 33 | 34 | if (cancelled) 35 | pthread_exit (PTHREAD_CANCELED); 36 | } 37 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-condattr-setpshared.c: -------------------------------------------------------------------------------- 1 | /* pthread_condattr_setpshared. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_condattr_setpshared (pthread_condattr_t *attr, 25 | int pshared) 26 | { 27 | switch (pshared) 28 | { 29 | case PTHREAD_PROCESS_PRIVATE: 30 | attr->pshared = pshared; 31 | return 0; 32 | 33 | case PTHREAD_PROCESS_SHARED: 34 | return ENOTSUP; 35 | 36 | default: 37 | return EINVAL; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-mutexattr-setpshared.c: -------------------------------------------------------------------------------- 1 | /* pthread_mutexattr_setpshared. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_mutexattr_setpshared (pthread_mutexattr_t *attr, 25 | int pshared) 26 | { 27 | switch (pshared) 28 | { 29 | case PTHREAD_PROCESS_PRIVATE: 30 | attr->pshared = pshared; 31 | return 0; 32 | 33 | case PTHREAD_PROCESS_SHARED: 34 | return ENOTSUP; 35 | 36 | default: 37 | return EINVAL; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /sysdeps/mach/hurd/pt-attr-setstacksize.c: -------------------------------------------------------------------------------- 1 | /* pthread_attr_setstacksize. Hurd on Mach version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | /* We use fixed sized stacks which require proper alignment. */ 24 | #define __pthread_stacksize __pthread_default_attr.stacksize 25 | 26 | int 27 | pthread_attr_setstacksize (pthread_attr_t *attr, 28 | size_t stacksize) 29 | { 30 | if (stacksize != __pthread_stacksize) 31 | return EINVAL; 32 | 33 | attr->stacksize = stacksize; 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-barrierattr-setpshared.c: -------------------------------------------------------------------------------- 1 | /* pthread_barrierattr_setpshared. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_barrierattr_setpshared (pthread_barrierattr_t *attr, 25 | int pshared) 26 | { 27 | switch (pshared) 28 | { 29 | case PTHREAD_PROCESS_PRIVATE: 30 | attr->pshared = pshared; 31 | return 0; 32 | 33 | case PTHREAD_PROCESS_SHARED: 34 | return ENOTSUP; 35 | 36 | default: 37 | return EINVAL; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-rwlockattr-setpshared.c: -------------------------------------------------------------------------------- 1 | /* pthread_rwlockattr_setpshared. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_rwlockattr_setpshared (pthread_rwlockattr_t *attr, 25 | int pshared) 26 | { 27 | switch (pshared) 28 | { 29 | case PTHREAD_PROCESS_PRIVATE: 30 | attr->pshared = pshared; 31 | return 0; 32 | 33 | case PTHREAD_PROCESS_SHARED: 34 | return ENOTSUP; 35 | 36 | default: 37 | return EINVAL; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /signal/TODO: -------------------------------------------------------------------------------- 1 | Unimplemented Functionality 2 | --------------------------- 3 | 4 | We don't support interruptible functions. That is, if a signal is 5 | delivered when a thread is in e.g. the write system call, then the 6 | write function should be interrupted and return EINTR when the signal 7 | handler is finished. To realize this behavior, we could have a thread 8 | local interruptible flag and a setjmp buffer. A function that is 9 | interruptible would fill the jump buffer and set the interruptible 10 | flag. If a signal comes in and the interruptible flag is set, rather 11 | than resuming the thread, we longjmp to the buffer. 12 | 13 | If a signal action has set the SA_SIGINFO, the third argument must be 14 | a pointer to a ucontext describing the thread's interrupted state; 15 | this implementation passes NULL. This isn't as bad as it sounds as 16 | the the ucontext family of functions are marked obsolete in SUSv3 with 17 | the advisory that any use of them should be replaced by the use of 18 | pthread functionality (cf. makecontext rationale). 19 | 20 | stop and continue signals are not implemented (as we need to stop all 21 | threads, this requires being in bed with libpthread). 22 | 23 | Implementation is not yet cancellation-safe. 24 | 25 | There are not even stubs for sighold, sigingore, sigpause, sigrelse, 26 | however, according to posix: "Use of any of these functions is 27 | unspecified in a multi-threaded process." 28 | 29 | Implement sigtimedwait, sigqueue. -------------------------------------------------------------------------------- /sysdeps/mach/hurd/pt-attr-setstackaddr.c: -------------------------------------------------------------------------------- 1 | /* pthread_attr_setstackaddr. Hurd on Mach version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | /* We use fixed sized stacks which require proper alignment. */ 24 | #define __pthread_stacksize __pthread_default_attr.stacksize 25 | 26 | int 27 | pthread_attr_setstackaddr (pthread_attr_t *attr, 28 | void *stackaddr) 29 | { 30 | if ((long) stackaddr & (__pthread_stacksize - 1)) 31 | return EINVAL; 32 | 33 | attr->stackaddr = stackaddr; 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /sysdeps/mach/pt-wakeup.c: -------------------------------------------------------------------------------- 1 | /* Wakeup a thread. Mach version. 2 | Copyright (C) 2000, 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | /* Wakeup THREAD. */ 29 | void 30 | __pthread_wakeup (struct __pthread *thread) 31 | { 32 | error_t err; 33 | 34 | err = __mach_msg (&thread->wakeupmsg, MACH_SEND_MSG | MACH_SEND_TIMEOUT, 35 | sizeof (thread->wakeupmsg), 0, MACH_PORT_NULL, 36 | 0 , MACH_PORT_NULL); 37 | assert_perror (err); 38 | } 39 | -------------------------------------------------------------------------------- /sysdeps/mach/pt-block.c: -------------------------------------------------------------------------------- 1 | /* Block a thread. Mach version. 2 | Copyright (C) 2000 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | /* Block THREAD. */ 29 | void 30 | __pthread_block (struct __pthread *thread) 31 | { 32 | mach_msg_header_t msg; 33 | error_t err; 34 | 35 | err = __mach_msg (&msg, MACH_RCV_MSG, 0, sizeof msg, 36 | thread->wakeupmsg.msgh_remote_port, 37 | MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); 38 | assert_perror (err); 39 | } 40 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-rwlock-rdlock.c: -------------------------------------------------------------------------------- 1 | /* Acquire a rwlock for reading. Generic version. 2 | Copyright (C) 2002, 2005 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | /* Implemented in pt-rwlock-timedrdlock.c. */ 24 | extern int __pthread_rwlock_timedrdlock_internal (struct __pthread_rwlock *rwlock, 25 | const struct timespec *abstime); 26 | 27 | /* Acquire RWLOCK for reading, block if we can't get it. */ 28 | int 29 | pthread_rwlock_rdlock (struct __pthread_rwlock *rwlock) 30 | { 31 | return __pthread_rwlock_timedrdlock_internal (rwlock, 0); 32 | } 33 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-rwlock-wrlock.c: -------------------------------------------------------------------------------- 1 | /* Acquire a rwlock for writing. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | /* Implemented in pt-rwlock-timedwrlock.c. */ 26 | extern int __pthread_rwlock_timedwrlock_internal (struct __pthread_rwlock *rwlock, 27 | const struct timespec *abstime); 28 | 29 | /* Acquire RWLOCK for writing. */ 30 | int 31 | pthread_rwlock_wrlock (struct __pthread_rwlock *rwlock) 32 | { 33 | return __pthread_rwlock_timedwrlock_internal (rwlock, 0); 34 | } 35 | -------------------------------------------------------------------------------- /tests/test-16.c: -------------------------------------------------------------------------------- 1 | /* Test pthread_kill.c. */ 2 | 3 | #define _GNU_SOURCE 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | pthread_t testthread; 14 | 15 | int i; 16 | 17 | void * 18 | test (void *arg) 19 | { 20 | error_t err; 21 | 22 | printf ("test: %d\n", pthread_self ()); 23 | 24 | err = pthread_kill (pthread_self (), SIGINFO); 25 | if (err) 26 | error (1, err, "pthread_kill"); 27 | 28 | /* To avoid using condition variables in a signal handler. */ 29 | while (i == 0) 30 | sched_yield (); 31 | 32 | return 0; 33 | } 34 | 35 | static void 36 | handler (int sig) 37 | { 38 | assert (pthread_equal (pthread_self (), testthread)); 39 | printf ("handler: %d\n", pthread_self ()); 40 | i = 1; 41 | } 42 | 43 | int 44 | main (int argc, char **argv) 45 | { 46 | error_t err; 47 | struct sigaction sa; 48 | void *ret; 49 | 50 | printf ("main: %d\n", pthread_self ()); 51 | 52 | sa.sa_handler = handler; 53 | sa.sa_mask = 0; 54 | sa.sa_flags = 0; 55 | 56 | err = sigaction (SIGINFO, &sa, 0); 57 | if (err) 58 | error (1, err, "sigaction"); 59 | 60 | err = pthread_create (&testthread, 0, test, 0); 61 | if (err) 62 | error (1, err, "pthread_create"); 63 | 64 | err = pthread_join (testthread, &ret); 65 | if (err) 66 | error (1, err, "pthread_join"); 67 | 68 | assert (ret == 0); 69 | 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /libc_pthread_init.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | Contributed by Jakub Jelinek , 2002. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #include 21 | #include 22 | 23 | void 24 | __libc_pthread_init (functions) 25 | const struct pthread_functions *functions; 26 | { 27 | #ifdef SHARED 28 | /* We copy the content of the variable pointed to by the FUNCTIONS 29 | parameter to one in libc.so since this means access to the array 30 | can be done with one memory access instead of two. */ 31 | memcpy (&__libc_pthread_functions, functions, 32 | sizeof (__libc_pthread_functions)); 33 | #endif 34 | } 35 | -------------------------------------------------------------------------------- /sysdeps/generic/bits/pthread.h: -------------------------------------------------------------------------------- 1 | /* Pthread data structures. Generic version. 2 | Copyright (C) 2002, 2008 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #ifndef _BITS_PTHREAD_H 21 | #define _BITS_PTHREAD_H 1 22 | 23 | typedef int __pthread_t; 24 | 25 | /* Return true if __T1 and __T2 both name the same thread. Otherwise, 26 | false. */ 27 | extern int 28 | __pthread_equal (__pthread_t __t1, __pthread_t __t2); 29 | 30 | #ifdef __USE_EXTERN_INLINES 31 | __extern_inline int 32 | __pthread_equal (__pthread_t __t1, __pthread_t __t2) 33 | { 34 | return __t1 == __t2; 35 | } 36 | #endif 37 | 38 | #endif /* bits/pthread.h */ 39 | -------------------------------------------------------------------------------- /tests/test-5.c: -------------------------------------------------------------------------------- 1 | /* Test signals. */ 2 | 3 | #define _GNU_SOURCE 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | void * 15 | thr (void *arg) 16 | { 17 | * (int *)0 = 0; 18 | return 0; 19 | } 20 | 21 | int foobar; 22 | 23 | int 24 | main (int argc, char *argv[]) 25 | { 26 | error_t err; 27 | pid_t child; 28 | 29 | struct rlimit limit; 30 | 31 | limit.rlim_cur = 0; 32 | limit.rlim_max = 0; 33 | 34 | err = setrlimit (RLIMIT_CORE, &limit); 35 | if (err) 36 | error (1, err, "setrlimit"); 37 | 38 | child = fork (); 39 | switch (child) 40 | { 41 | case -1: 42 | error (1, errno, "fork"); 43 | break; 44 | 45 | case 0: 46 | { 47 | pthread_t tid; 48 | void *ret; 49 | 50 | err = pthread_create (&tid, 0, thr, 0); 51 | if (err) 52 | error (1, err, "pthread_create"); 53 | 54 | err = pthread_join (tid, &ret); 55 | assert_perror (err); 56 | 57 | /* Should have never returned. Our parent expects us to fail 58 | thus we succeed and indicate the error. */ 59 | return 0; 60 | } 61 | 62 | default: 63 | { 64 | pid_t pid; 65 | int status; 66 | 67 | pid = waitpid (child, &status, 0); 68 | printf ("pid = %d; child = %d; status = %d\n", pid, child, status); 69 | assert (pid == child); 70 | assert (status != 0); 71 | } 72 | } 73 | 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-mutex-destroy.c: -------------------------------------------------------------------------------- 1 | /* Destroy a mutex. Generic version. 2 | Copyright (C) 2000, 2002, 2006 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | int 27 | _pthread_mutex_destroy (pthread_mutex_t *mutex) 28 | { 29 | if (mutex->attr == __PTHREAD_ERRORCHECK_MUTEXATTR 30 | || mutex->attr == __PTHREAD_RECURSIVE_MUTEXATTR) 31 | /* Static attributes. */ 32 | ; 33 | else 34 | free (mutex->attr); 35 | 36 | return 0; 37 | } 38 | 39 | strong_alias (_pthread_mutex_destroy, pthread_mutex_destroy); 40 | -------------------------------------------------------------------------------- /sysdeps/hurd/pt-getspecific.c: -------------------------------------------------------------------------------- 1 | /* pthread_getspecific. Hurd version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | void * 26 | pthread_getspecific (pthread_key_t key) 27 | { 28 | struct __pthread *self; 29 | 30 | if (key < 0 || key >= __pthread_key_count 31 | || __pthread_key_destructors[key] == PTHREAD_KEY_INVALID) 32 | return NULL; 33 | 34 | self = _pthread_self (); 35 | if (! self->thread_specifics) 36 | return 0; 37 | 38 | return hurd_ihash_find (self->thread_specifics, key); 39 | } 40 | -------------------------------------------------------------------------------- /sysdeps/generic/signal.c: -------------------------------------------------------------------------------- 1 | /* signal.c - Generic signal implementation. 2 | Copyright (C) 2008 Free Software Foundation, Inc. 3 | Written by Neal H. Walfield . 4 | 5 | This file is part of the GNU Hurd. 6 | 7 | The GNU Hurd is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 3 of 10 | the License, or (at your option) any later version. 11 | 12 | The GNU Hurd is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this program. If not, see 19 | . */ 20 | 21 | #include "sig-internal.h" 22 | 23 | void (*signal (int sig, void (*handler)(int)))(int) 24 | { 25 | struct sigaction sa; 26 | 27 | sa.sa_handler = handler; 28 | sa.sa_flags = SA_RESTART; 29 | 30 | if (sigemptyset (&sa.sa_mask) < 0 31 | || sigaddset (&sa.sa_mask, sig) < 0) 32 | return SIG_ERR; 33 | 34 | struct sigaction osa; 35 | if (sigaction (sig, &sa, &osa) < 0) 36 | return SIG_ERR; 37 | 38 | return osa.sa_handler; 39 | } 40 | 41 | void (*bsd_signal (int sig, void (*func)(int)))(int) 42 | { 43 | return signal (sig, func); 44 | } 45 | -------------------------------------------------------------------------------- /sysdeps/mach/pt-spin.c: -------------------------------------------------------------------------------- 1 | /* Spin locks. Mach version. 2 | Copyright (C) 2002, 2004 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | /* In glibc. */ 24 | extern void __spin_lock_solid (__pthread_spinlock_t *lock); 25 | 26 | /* Lock the spin lock object LOCK. If the lock is held by another 27 | thread spin until it becomes available. */ 28 | int 29 | _pthread_spin_lock (__pthread_spinlock_t *lock) 30 | { 31 | __spin_lock_solid (lock); 32 | return 0; 33 | } 34 | 35 | weak_alias (_pthread_spin_lock, pthread_spin_lock); 36 | weak_alias (_pthread_spin_lock, __pthread_spin_lock); 37 | -------------------------------------------------------------------------------- /sysdeps/mach/hurd/pt-sigstate-init.c: -------------------------------------------------------------------------------- 1 | /* Initialize the signal state. Hurd on Mach version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | error_t 26 | __pthread_sigstate_init (struct __pthread *thread) 27 | { 28 | void **location = 29 | (void *) __hurd_threadvar_location_from_sp (_HURD_THREADVAR_SIGSTATE, 30 | thread->stackaddr); 31 | 32 | /* The real initialization happens internally in glibc the first 33 | time that _hurd_thead_sigstate is called. */ 34 | *location = 0; 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-once.c: -------------------------------------------------------------------------------- 1 | /* pthread_once. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | int 26 | pthread_once (pthread_once_t *once_control, void (*init_routine) (void)) 27 | { 28 | if (once_control->run == 0) 29 | { 30 | __pthread_spin_lock (&once_control->lock); 31 | 32 | if (once_control->run == 0) 33 | { 34 | init_routine (); 35 | __memory_barrier (); 36 | once_control->run = 1; 37 | } 38 | 39 | __pthread_spin_unlock (&once_control->lock); 40 | } 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-attr-setdetachstate.c: -------------------------------------------------------------------------------- 1 | /* pthread_attr_setdetachstate. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | __pthread_attr_setdetachstate (pthread_attr_t *attr, 25 | int detachstate) 26 | { 27 | switch (detachstate) 28 | { 29 | case PTHREAD_CREATE_DETACHED: 30 | case PTHREAD_CREATE_JOINABLE: 31 | attr->detachstate = detachstate; 32 | break; 33 | default: 34 | return EINVAL; 35 | } 36 | 37 | return 0; 38 | } 39 | 40 | strong_alias (__pthread_attr_setdetachstate, pthread_attr_setdetachstate); 41 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-attr-setinheritsched.c: -------------------------------------------------------------------------------- 1 | /* pthread_attr_setinheritsched. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | __pthread_attr_setinheritsched (pthread_attr_t *attr, 25 | int inheritsched) 26 | { 27 | switch (inheritsched) 28 | { 29 | case PTHREAD_INHERIT_SCHED: 30 | case PTHREAD_EXPLICIT_SCHED: 31 | attr->inheritsched = inheritsched; 32 | break; 33 | default: 34 | return EINVAL; 35 | } 36 | 37 | return 0; 38 | } 39 | 40 | strong_alias (__pthread_attr_setinheritsched, pthread_attr_setinheritsched); 41 | -------------------------------------------------------------------------------- /sysdeps/generic/sem-trywait.c: -------------------------------------------------------------------------------- 1 | /* Lock a semaphore if it does not require blocking. Generic version. 2 | Copyright (C) 2005, 2006 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | int 26 | __sem_trywait (sem_t *sem) 27 | { 28 | __pthread_spin_lock (&sem->__lock); 29 | if (sem->__value > 0) 30 | /* Successful down. */ 31 | { 32 | sem->__value --; 33 | __pthread_spin_unlock (&sem->__lock); 34 | return 0; 35 | } 36 | __pthread_spin_unlock (&sem->__lock); 37 | 38 | errno = EAGAIN; 39 | return -1; 40 | } 41 | 42 | strong_alias (__sem_trywait, sem_trywait); 43 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-attr-setschedpolicy.c: -------------------------------------------------------------------------------- 1 | /* pthread_attr_getschedpolicy. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | __pthread_attr_setschedpolicy (pthread_attr_t *attr, 25 | int policy) 26 | { 27 | switch (policy) 28 | { 29 | case SCHED_OTHER: 30 | attr->schedpolicy = policy; 31 | break; 32 | 33 | case SCHED_FIFO: 34 | case SCHED_RR: 35 | return ENOTSUP; 36 | 37 | default: 38 | return EINVAL; 39 | } 40 | 41 | return 0; 42 | } 43 | 44 | strong_alias (__pthread_attr_setschedpolicy, pthread_attr_setschedpolicy); 45 | -------------------------------------------------------------------------------- /sysdeps/i386/bits/spin-lock.h: -------------------------------------------------------------------------------- 1 | /* Machine-specific definitions for spin locks. i386 version. 2 | Copyright (C) 2000, 2005, 2008, 2009 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | /* 21 | * Never include this file directly; use or instead. 22 | */ 23 | 24 | #ifndef _BITS_SPIN_LOCK_H 25 | #define _BITS_SPIN_LOCK_H 1 26 | 27 | #include 28 | 29 | __BEGIN_DECLS 30 | 31 | /* The type of a spin lock object. */ 32 | typedef __volatile int __pthread_spinlock_t; 33 | 34 | /* Initializer for a spin lock object. */ 35 | # define __PTHREAD_SPIN_LOCK_INITIALIZER ((__pthread_spinlock_t) 0) 36 | 37 | __END_DECLS 38 | 39 | #endif /* bits/spin-lock.h */ 40 | -------------------------------------------------------------------------------- /sysdeps/mach/bits/spin-lock.h: -------------------------------------------------------------------------------- 1 | /* Definitions of user-visible names for spin locks. 2 | Copyright (C) 1994, 1997, 2002, 2008, 2009 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _BITS_SPIN_LOCK_H 21 | #define _BITS_SPIN_LOCK_H 1 22 | 23 | #include 24 | #include /* This does all the work. */ 25 | 26 | __BEGIN_DECLS 27 | 28 | /* The type of a spin lock object. */ 29 | typedef __spin_lock_t __pthread_spinlock_t; 30 | 31 | /* Initializer for a spin lock object. */ 32 | #ifndef __PTHREAD_SPIN_LOCK_INITIALIZER 33 | #error __PTHREAD_SPIN_LOCK_INITIALIZER undefined: should be defined by . 34 | #endif 35 | 36 | __END_DECLS 37 | 38 | #endif /* bits/spin-lock.h */ 39 | -------------------------------------------------------------------------------- /sysdeps/generic/sem-init.c: -------------------------------------------------------------------------------- 1 | /* Initialize a semaphore. Generic version. 2 | Copyright (C) 2005, 2006 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | int 26 | __sem_init (sem_t *sem, int pshared, unsigned value) 27 | { 28 | if (pshared != 0) 29 | { 30 | errno = EOPNOTSUPP; 31 | return -1; 32 | } 33 | 34 | #ifdef SEM_VALUE_MAX 35 | if (value > SEM_VALUE_MAX) 36 | { 37 | errno = EINVAL; 38 | return -1; 39 | } 40 | #endif 41 | 42 | *sem = (sem_t) __SEMAPHORE_INITIALIZER (pshared, value); 43 | return 0; 44 | } 45 | 46 | strong_alias (__sem_init, sem_init); 47 | -------------------------------------------------------------------------------- /tests/test-17.c: -------------------------------------------------------------------------------- 1 | /* Test that the key reuse inside libpthread does not cause thread 2 | specific values to persist. */ 3 | 4 | #define _GNU_SOURCE 1 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | void 12 | work (int iter) 13 | { 14 | error_t err; 15 | pthread_key_t key1; 16 | pthread_key_t key2; 17 | void *value1; 18 | void *value2; 19 | 20 | printf ("work/%d: start\n", iter); 21 | err = pthread_key_create (&key1, NULL); 22 | assert (err == 0); 23 | err = pthread_key_create (&key2, NULL); 24 | assert (err == 0); 25 | 26 | value1 = pthread_getspecific (key1); 27 | value2 = pthread_getspecific (key2); 28 | printf ("work/%d: pre-setspecific: %p,%p\n", iter, value1, value2); 29 | assert (value1 == NULL); 30 | assert (value2 == NULL); 31 | err = pthread_setspecific (key1, (void *)(0x100 + iter)); 32 | assert (err == 0); 33 | err = pthread_setspecific (key2, (void *)(0x200 + iter)); 34 | assert (err == 0); 35 | 36 | value1 = pthread_getspecific (key1); 37 | value2 = pthread_getspecific (key2); 38 | printf ("work/%d: post-setspecific: %p,%p\n", iter, value1, value2); 39 | assert (value1 == (void *)(0x100 + iter)); 40 | assert (value2 == (void *)(0x200 + iter)); 41 | 42 | err = pthread_key_delete (key1); 43 | assert (err == 0); 44 | err = pthread_key_delete (key2); 45 | assert (err == 0); 46 | } 47 | 48 | int 49 | main (int argc, char *argv[]) 50 | { 51 | int i; 52 | 53 | for (i = 0; i < 8; ++i) 54 | work (i + 1); 55 | 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-attr-setschedparam.c: -------------------------------------------------------------------------------- 1 | /* pthread_attr_getschedparam. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | int 27 | __pthread_attr_setschedparam (pthread_attr_t *attr, 28 | const struct sched_param *param) 29 | { 30 | if (memcmp (param, &__pthread_default_attr.schedparam, 31 | sizeof *param) == 0) 32 | { 33 | memcpy (&attr->schedparam, param, sizeof *param); 34 | return 0; 35 | } 36 | 37 | return ENOTSUP; 38 | } 39 | 40 | strong_alias (__pthread_attr_setschedparam, pthread_attr_setschedparam); 41 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-mutexattr-setprotocol.c: -------------------------------------------------------------------------------- 1 | /* pthread_mutexattr_setprotocol. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_mutexattr_setprotocol (pthread_mutexattr_t *attr, 25 | int protocol) 26 | { 27 | if (protocol == __pthread_default_mutexattr.protocol) 28 | { 29 | attr->protocol = protocol; 30 | return 0; 31 | } 32 | 33 | switch (protocol) 34 | { 35 | case PTHREAD_PRIO_NONE: 36 | case PTHREAD_PRIO_INHERIT: 37 | case PTHREAD_PRIO_PROTECT: 38 | return ENOTSUP; 39 | default: 40 | return EINVAL; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-cond-brdcast.c: -------------------------------------------------------------------------------- 1 | /* Broadcast a condition. Generic version. 2 | Copyright (C) 2000, 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | 22 | #include 23 | 24 | /* Unblock all threads that are blocked on condition variable COND. */ 25 | int 26 | __pthread_cond_broadcast (pthread_cond_t *cond) 27 | { 28 | struct __pthread *wakeup; 29 | 30 | __pthread_spin_lock (&cond->__lock); 31 | __pthread_dequeuing_iterate (cond->__queue, wakeup) 32 | __pthread_wakeup (wakeup); 33 | 34 | cond->__queue = NULL; 35 | __pthread_spin_unlock (&cond->__lock); 36 | 37 | return 0; 38 | } 39 | 40 | strong_alias (__pthread_cond_broadcast, pthread_cond_broadcast); 41 | -------------------------------------------------------------------------------- /sysdeps/generic/bits/condition.h: -------------------------------------------------------------------------------- 1 | /* Condition type. Generic version. 2 | Copyright (C) 2000, 2005, 2009 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #ifndef _BITS_CONDITION_H 21 | #define _BITS_CONDITION_H 1 22 | 23 | #include 24 | 25 | /* User visible part of a condition variable. */ 26 | struct __pthread_cond 27 | { 28 | __pthread_spinlock_t __lock; 29 | struct __pthread *__queue; 30 | struct __pthread_condattr *__attr; 31 | struct __pthread_condimpl *__impl; 32 | void *__data; 33 | }; 34 | 35 | /* Initializer for a condition variable. */ 36 | #define __PTHREAD_COND_INITIALIZER \ 37 | { __PTHREAD_SPIN_LOCK_INITIALIZER, NULL, NULL, NULL, NULL } 38 | 39 | #endif /* bits/condition.h */ 40 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-mutex-lock.c: -------------------------------------------------------------------------------- 1 | /* Lock a mutex. Generic version. 2 | Copyright (C) 2000, 2002, 2006 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | /* Implemented in pt-mutex-timedlock.c. */ 26 | extern int __pthread_mutex_timedlock_internal (struct __pthread_mutex *mutex, 27 | const struct timespec *abstime); 28 | 29 | /* Lock MUTEX, block if we can't get it. */ 30 | int 31 | __pthread_mutex_lock (struct __pthread_mutex *mutex) 32 | { 33 | return __pthread_mutex_timedlock_internal (mutex, 0); 34 | } 35 | 36 | strong_alias (__pthread_mutex_lock, _pthread_mutex_lock); 37 | strong_alias (__pthread_mutex_lock, pthread_mutex_lock); 38 | -------------------------------------------------------------------------------- /sysdeps/generic/bits/barrier.h: -------------------------------------------------------------------------------- 1 | /* Thread barrier attribute type. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #ifndef _BITS_BARRIER_H 21 | #define _BITS_BARRIER_H 1 22 | 23 | #include 24 | 25 | /* This structure describes the attributes of a POSIX barrier. */ 26 | struct __pthread_barrier 27 | { 28 | __pthread_spinlock_t lock; 29 | struct __pthread *queue; /* List of waiters. */ 30 | unsigned pending; /* Number of that still need to wait on 31 | barrier. */ 32 | unsigned count; /* Number of threads that must wait before 33 | barrier is passed. */ 34 | struct __pthread_barrierattr *attr; 35 | void *data; 36 | }; 37 | 38 | 39 | #endif /* bits/barrier.h */ 40 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-cond-signal.c: -------------------------------------------------------------------------------- 1 | /* Signal a condition. Generic version. 2 | Copyright (C) 2000 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | 22 | #include 23 | 24 | /* Unblock at least one of the threads that are blocked on condition 25 | variable COND. */ 26 | int 27 | __pthread_cond_signal (pthread_cond_t *cond) 28 | { 29 | struct __pthread *wakeup; 30 | 31 | __pthread_spin_lock (&cond->__lock); 32 | wakeup = cond->__queue; 33 | if (wakeup) 34 | __pthread_dequeue (wakeup); 35 | __pthread_spin_unlock (&cond->__lock); 36 | 37 | if (wakeup) 38 | __pthread_wakeup (wakeup); 39 | 40 | return 0; 41 | } 42 | 43 | strong_alias (__pthread_cond_signal, pthread_cond_signal); 44 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-attr-setscope.c: -------------------------------------------------------------------------------- 1 | /* pthread_attr_setscope. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | __pthread_attr_setscope (pthread_attr_t *attr, 25 | int contentionscope) 26 | { 27 | if (contentionscope == __pthread_default_attr.contentionscope) 28 | { 29 | attr->contentionscope = contentionscope; 30 | return 0; 31 | } 32 | 33 | switch (contentionscope) 34 | { 35 | case PTHREAD_SCOPE_PROCESS: 36 | case PTHREAD_SCOPE_SYSTEM: 37 | return ENOTSUP; 38 | default: 39 | return EINVAL; 40 | } 41 | } 42 | 43 | strong_alias (__pthread_attr_setscope, pthread_attr_setscope); 44 | -------------------------------------------------------------------------------- /sysdeps/mach/pt-thread-halt.c: -------------------------------------------------------------------------------- 1 | /* Deallocate the kernel thread resources. Mach version. 2 | Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | /* Stop the kernel thread associated with THREAD. If NEED_DEALLOC is 27 | true, the function must call __pthread_dealloc on THREAD. 28 | 29 | NB: The thread executing this function may be the thread which is 30 | being halted, thus the last action should be halting the thread 31 | itself. */ 32 | void 33 | __pthread_thread_halt (struct __pthread *thread) 34 | { 35 | error_t err = __thread_terminate (thread->kernel_thread); 36 | assert_perror (err); 37 | } 38 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-attr-setstacksize.c: -------------------------------------------------------------------------------- 1 | /* pthread_attr_setstacksize. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | int 24 | pthread_attr_setstacksize (pthread_attr_t *attr, 25 | size_t stacksize) 26 | { 27 | if (stacksize == __pthread_default_attr.stacksize) 28 | { 29 | attr->stacksize = stacksize; 30 | 31 | /* The guard size cannot be larger than the stack itself, as 32 | such, if the new stack size is smaller than the guard size, 33 | we squash the guard size. */ 34 | if (attr->guardsize > attr->stacksize) 35 | attr->guardsize = attr->stacksize; 36 | 37 | return 0; 38 | } 39 | 40 | return ENOTSUP; 41 | } 42 | -------------------------------------------------------------------------------- /sysdeps/i386/bits/memory.h: -------------------------------------------------------------------------------- 1 | /* Memory barrier operations. i386 version. 2 | Copyright (C) 2002, 2008 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #ifndef _BITS_MEMORY_H 21 | #define _BITS_MEMORY_H 1 22 | 23 | /* Prevent read and write reordering across this function. */ 24 | static inline void 25 | __memory_barrier (void) 26 | { 27 | int i; 28 | 29 | /* Any lock'ed instruction will do. We just do a simple 30 | increment. */ 31 | __asm__ __volatile ("lock; incl %0" : "=m" (i) : "m" (i) : "memory"); 32 | } 33 | 34 | /* Prevent read reordering across this function. */ 35 | #define __memory_read_barrier __memory_barrier 36 | 37 | /* Prevent write reordering across this function. */ 38 | #define __memory_write_barrier __memory_barrier 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /sysdeps/generic/bits/semaphore.h: -------------------------------------------------------------------------------- 1 | /* Semaphore type. Generic version. 2 | Copyright (C) 2005, 2009 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #ifndef _BITS_SEMAPHORE_H 21 | #define _BITS_SEMAPHORE_H 1 22 | 23 | #ifndef _SEMAPHORE_H 24 | #error Never include directly. 25 | #endif 26 | 27 | #include 28 | 29 | /* User visible part of a semaphore. */ 30 | struct __semaphore 31 | { 32 | __pthread_spinlock_t __lock; 33 | struct __pthread *__queue; 34 | int __pshared; 35 | int __value; 36 | void *__data; 37 | }; 38 | 39 | /* Initializer for a semaphore. */ 40 | #define __SEMAPHORE_INITIALIZER(pshared, value) \ 41 | { __PTHREAD_SPIN_LOCK_INITIALIZER, NULL, (pshared), (value), NULL } 42 | 43 | #endif /* bits/mutex.h */ 44 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-attr.c: -------------------------------------------------------------------------------- 1 | /* Default attributes. Generic version. 2 | Copyright (C) 2000,02 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | /* FIXME Normally const, see sysdeps/mach/hurd/pt-sysdep.c. */ 28 | struct __pthread_attr __pthread_default_attr = 29 | { 30 | schedparam: { sched_priority: 0 }, 31 | stacksize: PTHREAD_STACK_DEFAULT, 32 | stackaddr: NULL, 33 | #ifdef PAGESIZE 34 | guardsize: PAGESIZE, 35 | #else 36 | guardsize: 1, 37 | #endif /* PAGESIZE */ 38 | detachstate: PTHREAD_CREATE_JOINABLE, 39 | inheritsched: PTHREAD_EXPLICIT_SCHED, 40 | contentionscope: PTHREAD_SCOPE_SYSTEM, 41 | schedpolicy: SCHED_OTHER 42 | }; 43 | -------------------------------------------------------------------------------- /pthread/pt-spin-inlines.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2000 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Library General Public License as 6 | published by the Free Software Foundation; either version 2 of the 7 | License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Library General Public License for more details. 13 | 14 | You should have received a copy of the GNU Library General Public 15 | License along with the GNU C Library; see the file COPYING.LIB. If not, 16 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | Boston, MA 02111-1307, USA. */ 18 | 19 | /* declares some extern inline functions. These 20 | functions are declared additionally here for use when inlining is 21 | not possible. */ 22 | 23 | #define _FORCE_INLINES 24 | #define __PT_SPIN_INLINE /* empty */ 25 | 26 | #include 27 | 28 | /* Weak aliases for the spin lock functions. Note that 29 | pthread_spin_lock is left out deliberately. We already provide an 30 | implementation for it in pt-spin.c. */ 31 | weak_alias (__pthread_spin_destroy, pthread_spin_destroy); 32 | weak_alias (__pthread_spin_init, pthread_spin_init); 33 | weak_alias (__pthread_spin_trylock, pthread_spin_trylock); 34 | weak_alias (__pthread_spin_unlock, pthread_spin_unlock); 35 | -------------------------------------------------------------------------------- /pthread/pt-setcanceltype.c: -------------------------------------------------------------------------------- 1 | /* Set the cancel type for the calling thread. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | 22 | #include 23 | 24 | int 25 | __pthread_setcanceltype (int type, int *oldtype) 26 | { 27 | struct __pthread *p = _pthread_self (); 28 | 29 | switch (type) 30 | { 31 | default: 32 | return EINVAL; 33 | case PTHREAD_CANCEL_DEFERRED: 34 | case PTHREAD_CANCEL_ASYNCHRONOUS: 35 | break; 36 | } 37 | 38 | __pthread_mutex_lock (&p->cancel_lock); 39 | if (oldtype) 40 | *oldtype = p->cancel_type; 41 | p->cancel_type = type; 42 | __pthread_mutex_unlock (&p->cancel_lock); 43 | 44 | return 0; 45 | } 46 | 47 | strong_alias (__pthread_setcanceltype, pthread_setcanceltype); 48 | -------------------------------------------------------------------------------- /pthread/pt-setcancelstate.c: -------------------------------------------------------------------------------- 1 | /* Set the cancel state for the calling thread. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | 22 | #include 23 | 24 | int 25 | __pthread_setcancelstate (int state, int *oldstate) 26 | { 27 | struct __pthread *p = _pthread_self (); 28 | 29 | switch (state) 30 | { 31 | default: 32 | return EINVAL; 33 | case PTHREAD_CANCEL_ENABLE: 34 | case PTHREAD_CANCEL_DISABLE: 35 | break; 36 | } 37 | 38 | __pthread_mutex_lock (&p->cancel_lock); 39 | if (oldstate) 40 | *oldstate = p->cancel_state; 41 | p->cancel_state = state; 42 | __pthread_mutex_unlock (&p->cancel_lock); 43 | 44 | return 0; 45 | } 46 | 47 | strong_alias (__pthread_setcancelstate, pthread_setcancelstate); 48 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-cond-wait.c: -------------------------------------------------------------------------------- 1 | /* Wait on a condition. Generic version. 2 | Copyright (C) 2000,02 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | 22 | #include 23 | 24 | /* Implemented in pt-cond-timedwait.c. */ 25 | extern int __pthread_cond_timedwait_internal (pthread_cond_t *cond, 26 | pthread_mutex_t *mutex, 27 | const struct timespec *abstime); 28 | 29 | 30 | /* Block on condition variable COND. MUTEX should be held by the 31 | calling thread. On return, MUTEX will be held by the calling 32 | thread. */ 33 | int 34 | __pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex) 35 | { 36 | return __pthread_cond_timedwait_internal (cond, mutex, 0); 37 | } 38 | 39 | strong_alias (__pthread_cond_wait, pthread_cond_wait); 40 | -------------------------------------------------------------------------------- /sysdeps/mach/hurd/pt-hurd-cond-wait.c: -------------------------------------------------------------------------------- 1 | /* pthread_hurd_cond_wait. Hurd-specific wait on a condition. 2 | Copyright (C) 2012 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | /* Implemented in pt-hurd-cond-timedwait.c. */ 27 | extern int __pthread_hurd_cond_timedwait_internal (pthread_cond_t *cond, 28 | pthread_mutex_t *mutex, 29 | const struct timespec *abstime); 30 | 31 | int 32 | __pthread_hurd_cond_wait_np (pthread_cond_t *cond, 33 | pthread_mutex_t *mutex) 34 | { 35 | error_t err; 36 | 37 | err = __pthread_hurd_cond_timedwait_internal (cond, mutex, NULL); 38 | return (err == EINTR); 39 | } 40 | 41 | strong_alias (__pthread_hurd_cond_wait_np, pthread_hurd_cond_wait_np); 42 | -------------------------------------------------------------------------------- /tests/test-7.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #define THREADS 10 10 | #define KEYS 400 11 | 12 | pthread_key_t key[KEYS]; 13 | 14 | void * 15 | thr (void *arg) 16 | { 17 | error_t err; 18 | int i; 19 | 20 | for (i = 0; i < KEYS; i ++) 21 | { 22 | printf ("pthread_getspecific(%d).\n", key[i]); 23 | assert (pthread_getspecific (key[i]) == NULL); 24 | printf ("pthread_setspecific(%d, %d).\n", key[i], pthread_self ()); 25 | err = pthread_setspecific (key[i], (void *) pthread_self ()); 26 | printf ("pthread_setspecific(%d, %d) => %d.\n", key[i], pthread_self (), err); 27 | assert_perror (err); 28 | } 29 | 30 | return 0; 31 | } 32 | 33 | int 34 | main (int argc, char **argv) 35 | { 36 | error_t err; 37 | int i; 38 | pthread_t tid[THREADS]; 39 | 40 | void des (void *val) 41 | { 42 | assert ((pthread_t) val == pthread_self ()); 43 | } 44 | 45 | assert (pthread_getspecific ((pthread_key_t) 0) == NULL); 46 | assert (pthread_setspecific ((pthread_key_t) 0, (void *) 0x1) == EINVAL); 47 | 48 | for (i = 0; i < KEYS; i ++) 49 | err = pthread_key_create (&key[i], des); 50 | 51 | for (i = 0; i < THREADS; i ++) 52 | { 53 | err = pthread_create (&tid[i], 0, thr, 0); 54 | if (err) 55 | error (1, err, "pthread_create (%d)", i); 56 | } 57 | 58 | for (i = 0; i < THREADS; i ++) 59 | { 60 | void *ret; 61 | 62 | err = pthread_join (tid[i], &ret); 63 | if (err) 64 | error (1, err, "pthread_join"); 65 | 66 | assert (ret == 0); 67 | } 68 | 69 | return 0; 70 | } 71 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-cond-init.c: -------------------------------------------------------------------------------- 1 | /* pthread_cond_init. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | int 27 | __pthread_cond_init (pthread_cond_t *cond, 28 | const pthread_condattr_t *attr) 29 | { 30 | *cond = (pthread_cond_t) __PTHREAD_COND_INITIALIZER; 31 | 32 | if (! attr 33 | || memcmp (attr, &__pthread_default_condattr, sizeof (*attr) == 0)) 34 | /* Use the default attributes. */ 35 | return 0; 36 | 37 | /* Non-default attributes. */ 38 | 39 | cond->__attr = malloc (sizeof *attr); 40 | if (! cond->__attr) 41 | return ENOMEM; 42 | 43 | *cond->__attr = *attr; 44 | return 0; 45 | } 46 | 47 | strong_alias (__pthread_cond_init, pthread_cond_init); 48 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-rwlock-init.c: -------------------------------------------------------------------------------- 1 | /* Initialize a rwlock. Generic version. 2 | Copyright (C) 2002, 2005, 2006 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | int 25 | _pthread_rwlock_init (pthread_rwlock_t *rwlock, 26 | const pthread_rwlockattr_t *attr) 27 | { 28 | *rwlock = (pthread_rwlock_t) __PTHREAD_RWLOCK_INITIALIZER; 29 | 30 | if (! attr 31 | || memcmp (attr, &__pthread_default_rwlockattr, sizeof (*attr) == 0)) 32 | /* Use the default attributes. */ 33 | return 0; 34 | 35 | /* Non-default attributes. */ 36 | 37 | rwlock->__attr = malloc (sizeof *attr); 38 | if (! rwlock->__attr) 39 | return ENOMEM; 40 | 41 | *rwlock->__attr = *attr; 42 | return 0; 43 | } 44 | 45 | strong_alias (_pthread_rwlock_init, pthread_rwlock_init); 46 | -------------------------------------------------------------------------------- /sysdeps/generic/bits/mutex-attr.h: -------------------------------------------------------------------------------- 1 | /* Mutex attribute type. Generic version. 2 | Copyright (C) 2002, 2008 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #ifndef _BITS_MUTEX_ATTR_H 21 | #define _BITS_MUTEX_ATTR_H 1 22 | 23 | enum __pthread_mutex_protocol; 24 | enum __pthread_process_shared; 25 | enum __pthread_mutex_type; 26 | 27 | /* This structure describes the attributes of a POSIX mutex 28 | attribute. */ 29 | struct __pthread_mutexattr 30 | { 31 | int prioceiling; 32 | enum __pthread_mutex_protocol protocol; 33 | enum __pthread_process_shared pshared; 34 | enum __pthread_mutex_type mutex_type; 35 | }; 36 | 37 | /* Attributes for a recursive mutex. */ 38 | extern const struct __pthread_mutexattr __pthread_errorcheck_mutexattr; 39 | extern const struct __pthread_mutexattr __pthread_recursive_mutexattr; 40 | 41 | #endif /* bits/mutex-attr.h */ 42 | -------------------------------------------------------------------------------- /sysdeps/hurd/pt-setspecific.c: -------------------------------------------------------------------------------- 1 | /* pthread_setspecific. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | int 26 | pthread_setspecific (pthread_key_t key, const void *value) 27 | { 28 | error_t err; 29 | struct __pthread *self = _pthread_self (); 30 | 31 | if (key < 0 || key >= __pthread_key_count 32 | || __pthread_key_destructors[key] == PTHREAD_KEY_INVALID) 33 | return EINVAL; 34 | 35 | if (! self->thread_specifics) 36 | { 37 | err = hurd_ihash_create (&self->thread_specifics, HURD_IHASH_NO_LOCP); 38 | if (err) 39 | return ENOMEM; 40 | } 41 | 42 | err = hurd_ihash_add (self->thread_specifics, key, (void *) value); 43 | if (err) 44 | return ENOMEM; 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /sysdeps/hurd/pt-kill.c: -------------------------------------------------------------------------------- 1 | /* pthread_kill. Hurd version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | int 28 | pthread_kill (pthread_t thread, int sig) 29 | { 30 | struct __pthread *pthread; 31 | struct hurd_signal_detail detail; 32 | struct hurd_sigstate *ss; 33 | 34 | /* Lookup the thread structure for THREAD. */ 35 | pthread = __pthread_getid (thread); 36 | if (pthread == NULL) 37 | return ESRCH; 38 | 39 | ss = _hurd_thread_sigstate (pthread->kernel_thread); 40 | assert (ss); 41 | 42 | if (!sig) 43 | return 0; 44 | 45 | detail.exc = 0; 46 | detail.code = sig; 47 | detail.error = 0; 48 | 49 | _hurd_raise_signal (ss, sig, &detail); 50 | 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /sysdeps/generic/pt-rwlock-trywrlock.c: -------------------------------------------------------------------------------- 1 | /* Try to acquire a rwlock for writing. Generic version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | /* Try to acquire RWLOCK for writing. */ 26 | int 27 | pthread_rwlock_trywrlock (struct __pthread_rwlock *rwlock) 28 | { 29 | __pthread_spin_lock (&rwlock->__lock); 30 | if (__pthread_spin_trylock (&rwlock->__held) == 0) 31 | /* Successfully acquired the lock. */ 32 | { 33 | assert (rwlock->readerqueue == 0); 34 | assert (rwlock->writerqueue == 0); 35 | assert (rwlock->readers == 0); 36 | 37 | __pthread_spin_unlock (&rwlock->__lock); 38 | return 0; 39 | } 40 | 41 | /* The lock is busy. */ 42 | 43 | __pthread_spin_unlock (&rwlock->__lock); 44 | 45 | return EBUSY; 46 | } 47 | --------------------------------------------------------------------------------