summaryrefslogtreecommitdiff
path: root/sysdeps/generic
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/generic')
-rw-r--r--sysdeps/generic/bits/barrier-attr.h4
-rw-r--r--sysdeps/generic/bits/cancelation.h15
-rw-r--r--sysdeps/generic/bits/condition-attr.h8
-rw-r--r--sysdeps/generic/bits/condition.h4
-rw-r--r--sysdeps/generic/bits/mutex-attr.h10
-rw-r--r--sysdeps/generic/bits/mutex.h92
-rw-r--r--sysdeps/generic/bits/once.h4
-rw-r--r--sysdeps/generic/bits/pthread-np.h27
-rw-r--r--sysdeps/generic/bits/pthread.h13
-rw-r--r--sysdeps/generic/bits/pthreadtypes.h29
-rw-r--r--sysdeps/generic/bits/rwlock-attr.h4
-rw-r--r--sysdeps/generic/bits/rwlock.h31
-rw-r--r--sysdeps/generic/bits/semaphore.h4
-rw-r--r--sysdeps/generic/bits/thread-attr.h11
-rw-r--r--sysdeps/generic/killpg.c27
-rw-r--r--sysdeps/generic/pt-attr-getschedparam.c3
-rw-r--r--sysdeps/generic/pt-attr-setschedparam.c2
-rw-r--r--sysdeps/generic/pt-kill.c32
-rw-r--r--sysdeps/generic/pt-mutex-destroy.c8
-rw-r--r--sysdeps/generic/pt-mutex-init.c10
-rw-r--r--sysdeps/generic/pt-mutex-lock.c2
-rw-r--r--sysdeps/generic/pt-mutex-timedlock.c56
-rw-r--r--sysdeps/generic/pt-mutex-transfer-np.c66
-rw-r--r--sysdeps/generic/pt-mutex-trylock.c30
-rw-r--r--sysdeps/generic/pt-mutex-unlock.c42
-rw-r--r--sysdeps/generic/pt-mutexattr.c18
-rw-r--r--sysdeps/generic/pt-rwlock-destroy.c2
-rw-r--r--sysdeps/generic/pt-rwlock-init.c2
-rw-r--r--sysdeps/generic/pt-startup.c (renamed from sysdeps/generic/bits/thread-barrier.h)17
-rw-r--r--sysdeps/generic/raise.c41
-rw-r--r--sysdeps/generic/sem-destroy.c2
-rw-r--r--sysdeps/generic/sem-getvalue.c2
-rw-r--r--sysdeps/generic/sem-init.c2
-rw-r--r--sysdeps/generic/sem-open.c2
-rw-r--r--sysdeps/generic/sem-post.c2
-rw-r--r--sysdeps/generic/sem-timedwait.c3
-rw-r--r--sysdeps/generic/sem-trywait.c2
-rw-r--r--sysdeps/generic/sem-unlink.c2
-rw-r--r--sysdeps/generic/sem-wait.c2
-rw-r--r--sysdeps/generic/sigaddset.c35
-rw-r--r--sysdeps/generic/sigdelset.c35
-rw-r--r--sysdeps/generic/sigemptyset.c29
-rw-r--r--sysdeps/generic/sigfillset.c29
-rw-r--r--sysdeps/generic/siginterrupt.c36
-rw-r--r--sysdeps/generic/sigismember.c36
-rw-r--r--sysdeps/generic/signal.c44
-rw-r--r--sysdeps/generic/sigwait.c34
47 files changed, 720 insertions, 191 deletions
diff --git a/sysdeps/generic/bits/barrier-attr.h b/sysdeps/generic/bits/barrier-attr.h
index 86f3cb0..a9900b7 100644
--- a/sysdeps/generic/bits/barrier-attr.h
+++ b/sysdeps/generic/bits/barrier-attr.h
@@ -1,5 +1,5 @@
/* Thread barrier attribute type. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -20,6 +20,8 @@
#ifndef _BITS_BARRIER_ATTR_H
#define _BITS_BARRIER_ATTR_H 1
+enum __pthread_process_shared;
+
/* This structure describes the attributes of a POSIX thread barrier.
Note that not all of them are supported on all systems. */
struct __pthread_barrierattr
diff --git a/sysdeps/generic/bits/cancelation.h b/sysdeps/generic/bits/cancelation.h
index bb6b58a..46486f5 100644
--- a/sysdeps/generic/bits/cancelation.h
+++ b/sysdeps/generic/bits/cancelation.h
@@ -1,5 +1,5 @@
/* Cancelation. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -20,8 +20,6 @@
#ifndef _BITS_CANCELATION_H
#define _BITS_CANCELATION_H 1
-#include <assert.h>
-
struct __pthread_cancelation_handler
{
void (*handler)(void *);
@@ -32,22 +30,21 @@ struct __pthread_cancelation_handler
/* Returns the thread local location of the cleanup handler stack. */
struct __pthread_cancelation_handler **__pthread_get_cleanup_stack (void);
-#define pthread_cleanup_push(rt, rtarg) \
+#define __pthread_cleanup_push(rt, rtarg) \
{ \
struct __pthread_cancelation_handler **__handlers \
= __pthread_get_cleanup_stack (); \
struct __pthread_cancelation_handler __handler = \
{ \
- handler: (rt), \
- arg: (rtarg), \
- next: *__handlers \
+ (rt), \
+ (rtarg), \
+ *__handlers \
}; \
*__handlers = &__handler;
-#define pthread_cleanup_pop(execute) \
+#define __pthread_cleanup_pop(execute) \
if (execute) \
__handler.handler (__handler.arg); \
- assert (*__handlers == &__handler); \
*__handlers = __handler.next; \
}
diff --git a/sysdeps/generic/bits/condition-attr.h b/sysdeps/generic/bits/condition-attr.h
index 2d48dfb..4cd4e8c 100644
--- a/sysdeps/generic/bits/condition-attr.h
+++ b/sysdeps/generic/bits/condition-attr.h
@@ -1,5 +1,5 @@
/* Condition attribute type. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -20,13 +20,15 @@
#ifndef _BITS_CONDITION_ATTR_H
#define _BITS_CONDITION_ATTR_H 1
-#include <time.h>
+#include <bits/types.h>
+
+enum __pthread_process_shared;
/* User visible part of a condition attribute variable. */
struct __pthread_condattr
{
enum __pthread_process_shared pshared;
- clockid_t clock;
+ __clockid_t clock;
};
#endif /* bits/condition.h */
diff --git a/sysdeps/generic/bits/condition.h b/sysdeps/generic/bits/condition.h
index f3b09be..bf13ada 100644
--- a/sysdeps/generic/bits/condition.h
+++ b/sysdeps/generic/bits/condition.h
@@ -1,5 +1,5 @@
/* Condition type. Generic version.
- Copyright (C) 2000, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2005, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -34,6 +34,6 @@ struct __pthread_cond
/* Initializer for a condition variable. */
#define __PTHREAD_COND_INITIALIZER \
- { __SPIN_LOCK_INITIALIZER, NULL, NULL, NULL, NULL }
+ { __PTHREAD_SPIN_LOCK_INITIALIZER, NULL, NULL, NULL, NULL }
#endif /* bits/condition.h */
diff --git a/sysdeps/generic/bits/mutex-attr.h b/sysdeps/generic/bits/mutex-attr.h
index 883b074..8514ebe 100644
--- a/sysdeps/generic/bits/mutex-attr.h
+++ b/sysdeps/generic/bits/mutex-attr.h
@@ -1,5 +1,5 @@
/* Mutex attribute type. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -20,6 +20,10 @@
#ifndef _BITS_MUTEX_ATTR_H
#define _BITS_MUTEX_ATTR_H 1
+enum __pthread_mutex_protocol;
+enum __pthread_process_shared;
+enum __pthread_mutex_type;
+
/* This structure describes the attributes of a POSIX mutex
attribute. */
struct __pthread_mutexattr
@@ -30,4 +34,8 @@ struct __pthread_mutexattr
enum __pthread_mutex_type mutex_type;
};
+/* Attributes for a recursive mutex. */
+extern const struct __pthread_mutexattr __pthread_errorcheck_mutexattr;
+extern const struct __pthread_mutexattr __pthread_recursive_mutexattr;
+
#endif /* bits/mutex-attr.h */
diff --git a/sysdeps/generic/bits/mutex.h b/sysdeps/generic/bits/mutex.h
index feb6d07..c734c39 100644
--- a/sysdeps/generic/bits/mutex.h
+++ b/sysdeps/generic/bits/mutex.h
@@ -1,5 +1,8 @@
/* Mutex type. Generic version.
- Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
+
+ Copyright (C) 2000, 2002, 2005, 2006, 2007, 2008, 2009
+ Free Software Foundation, Inc.
+
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -52,88 +55,21 @@ struct __pthread_mutex
/* Initializer for a mutex. N.B. this also happens to be compatible
with the cthread mutex initializer. */
# define __PTHREAD_MUTEX_INITIALIZER \
- { __SPIN_LOCK_INITIALIZER, __SPIN_LOCK_INITIALIZER, 0, 0, 0, 0, 0, 0 }
+ { __PTHREAD_SPIN_LOCK_INITIALIZER, __PTHREAD_SPIN_LOCK_INITIALIZER, 0, 0, 0, 0, 0, 0 }
-# endif
-#endif /* Not __pthread_mutex_defined. */
+# define __PTHREAD_ERRORCHECK_MUTEXATTR ((struct __pthread_mutexattr *) ((unsigned long) __PTHREAD_MUTEX_ERRORCHECK + 1))
-#ifdef _BITS_MUTEX_H
+# define __PTHREAD_ERRORCHECK_MUTEX_INITIALIZER \
+ { __PTHREAD_SPIN_LOCK_INITIALIZER, __PTHREAD_SPIN_LOCK_INITIALIZER, 0, 0, \
+ __PTHREAD_ERRORCHECK_MUTEXATTR, 0, 0, 0 }
-#include <errno.h>
-#include <stddef.h>
+# define __PTHREAD_RECURSIVE_MUTEXATTR ((struct __pthread_mutexattr *) ((unsigned long) __PTHREAD_MUTEX_RECURSIVE + 1))
-#ifdef __USE_EXTERN_INLINES
+# define __PTHREAD_RECURSIVE_MUTEX_INITIALIZER \
+ { __PTHREAD_SPIN_LOCK_INITIALIZER, __PTHREAD_SPIN_LOCK_INITIALIZER, 0, 0, \
+ __PTHREAD_RECURSIVE_MUTEXATTR, 0, 0, 0 }
-# ifndef _EXTERN_INLINE
-# define _EXTERN_INLINE extern __inline
# endif
-
-_EXTERN_INLINE int
-pthread_mutex_init (struct __pthread_mutex *__restrict __mutex,
- const pthread_mutexattr_t *__restrict attr)
-{
- struct __pthread_mutex initialized_mutex = __PTHREAD_MUTEX_INITIALIZER;
-
- extern int _pthread_mutex_init (struct __pthread_mutex *,
- const pthread_mutexattr_t *);
-
- if (attr)
- return _pthread_mutex_init (__mutex, attr);
-
- *__mutex = initialized_mutex;
- return 0;
-}
-
-_EXTERN_INLINE int
-pthread_mutex_destroy (struct __pthread_mutex *__mutex)
-{
- extern int _pthread_mutex_destroy (struct __pthread_mutex *);
-
- if (__mutex->attr || __mutex->data)
- return _pthread_mutex_destroy (__mutex);
-
- return 0;
-}
-
-_EXTERN_INLINE int
-__pthread_mutex_lock (struct __pthread_mutex *__mutex)
-{
- extern int _pthread_mutex_lock (struct __pthread_mutex *);
-
- if (__mutex->attr == NULL
- && __mutex->data == NULL
- && __pthread_spin_trylock (&__mutex->__held) == 0)
- return 0;
-
- return _pthread_mutex_lock (__mutex);
-}
-
-extern __inline int
-__pthread_mutex_trylock (struct __pthread_mutex *__mutex)
-{
- extern int _pthread_mutex_trylock (struct __pthread_mutex *);
-
- if (__mutex->attr == NULL
- && __mutex->data == NULL)
- return __pthread_spin_trylock (&__mutex->__held);
-
- return _pthread_mutex_trylock (__mutex);
-}
-
-extern __inline int
-pthread_mutex_lock (struct __pthread_mutex *__mutex)
-{
- return __pthread_mutex_lock (__mutex);
-}
-
-extern __inline int
-pthread_mutex_trylock (struct __pthread_mutex *__mutex)
-{
- return __pthread_mutex_trylock (__mutex);
-}
-
-#endif /* Use extern inlines. */
-
-#endif
+#endif /* Not __pthread_mutex_defined. */
#endif /* bits/mutex.h */
diff --git a/sysdeps/generic/bits/once.h b/sysdeps/generic/bits/once.h
index 7f572fa..f4985d6 100644
--- a/sysdeps/generic/bits/once.h
+++ b/sysdeps/generic/bits/once.h
@@ -1,5 +1,5 @@
/* Dynamic package initialization data structures. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -29,6 +29,6 @@ struct __pthread_once
};
#define __PTHREAD_ONCE_INIT \
- { 0, __SPIN_LOCK_INITIALIZER }
+ { 0, __PTHREAD_SPIN_LOCK_INITIALIZER }
#endif /* bits/once.h */
diff --git a/sysdeps/generic/bits/pthread-np.h b/sysdeps/generic/bits/pthread-np.h
new file mode 100644
index 0000000..d5ddbb0
--- /dev/null
+++ b/sysdeps/generic/bits/pthread-np.h
@@ -0,0 +1,27 @@
+/* Non-portable functions. Generic version.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/*
+ * Never include this file directly; use <pthread.h> or <cthreads.h> instead.
+ */
+
+#ifndef _BITS_PTHREAD_NP_H
+#define _BITS_PTHREAD_NP_H 1
+
+#endif /* bits/pthread-np.h */
diff --git a/sysdeps/generic/bits/pthread.h b/sysdeps/generic/bits/pthread.h
index 3f9df13..80e6b09 100644
--- a/sysdeps/generic/bits/pthread.h
+++ b/sysdeps/generic/bits/pthread.h
@@ -1,5 +1,5 @@
/* Pthread data structures. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -20,14 +20,19 @@
#ifndef _BITS_PTHREAD_H
#define _BITS_PTHREAD_H 1
-typedef int pthread_t;
+typedef int __pthread_t;
/* Return true if __T1 and __T2 both name the same thread. Otherwise,
false. */
-extern __inline int
-pthread_equal (pthread_t __t1, pthread_t __t2)
+extern int
+__pthread_equal (__pthread_t __t1, __pthread_t __t2);
+
+#ifdef __USE_EXTERN_INLINES
+__extern_inline int
+__pthread_equal (__pthread_t __t1, __pthread_t __t2)
{
return __t1 == __t2;
}
+#endif
#endif /* bits/pthread.h */
diff --git a/sysdeps/generic/bits/pthreadtypes.h b/sysdeps/generic/bits/pthreadtypes.h
new file mode 100644
index 0000000..e5cbfd2
--- /dev/null
+++ b/sysdeps/generic/bits/pthreadtypes.h
@@ -0,0 +1,29 @@
+/*
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#if !defined _BITS_TYPES_H && !defined _PTHREAD_H
+# error "Never include <bits/pthreadtypes.h> directly; use <sys/types.h> instead."
+#endif
+
+#ifndef _BITS_PTHREADTYPES_H
+#define _BITS_PTHREADTYPES_H 1
+
+#include <pthread.h>
+
+#endif /* bits/pthreadtypes.h */
diff --git a/sysdeps/generic/bits/rwlock-attr.h b/sysdeps/generic/bits/rwlock-attr.h
index 44765bd..dba99f1 100644
--- a/sysdeps/generic/bits/rwlock-attr.h
+++ b/sysdeps/generic/bits/rwlock-attr.h
@@ -1,5 +1,5 @@
/* Thread rwlock attribute type. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -20,6 +20,8 @@
#ifndef _BITS_RWLOCK_ATTR_H
#define _BITS_RWLOCK_ATTR_H 1
+enum __pthread_process_shared;
+
/* This structure describes the attributes of a POSIX thread rwlock.
Note that not all of them are supported on all systems. */
struct __pthread_rwlockattr
diff --git a/sysdeps/generic/bits/rwlock.h b/sysdeps/generic/bits/rwlock.h
index fc429b4..af6b1c8 100644
--- a/sysdeps/generic/bits/rwlock.h
+++ b/sysdeps/generic/bits/rwlock.h
@@ -1,5 +1,5 @@
/* rwlock type. Generic version.
- Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -40,34 +40,7 @@ struct __pthread_rwlock
/* Initializer for a rwlock. */
#define __PTHREAD_RWLOCK_INITIALIZER \
- { __SPIN_LOCK_INITIALIZER, __SPIN_LOCK_INITIALIZER, 0, 0, 0, 0, 0 }
+ { __PTHREAD_SPIN_LOCK_INITIALIZER, __PTHREAD_SPIN_LOCK_INITIALIZER, 0, 0, 0, 0, 0 }
-_EXTERN_INLINE int
-pthread_rwlock_init (struct __pthread_rwlock *__restrict __rwlock,
- const struct __pthread_rwlockattr *__restrict __attr)
-{
- struct __pthread_rwlock initialized_rwlock = __PTHREAD_RWLOCK_INITIALIZER;
- extern int _pthread_rwlock_init (struct __pthread_rwlock *,
- const struct __pthread_rwlockattr *);
-
- if (__attr)
- return _pthread_rwlock_init (__rwlock, __attr);
-
- *__rwlock = initialized_rwlock;
- return 0;
-}
-
-_EXTERN_INLINE int
-pthread_rwlock_destroy (struct __pthread_rwlock *__rwlock)
-{
- extern int _pthread_rwlock_destroy (struct __pthread_rwlock *);
-
- if (__rwlock->__attr
- || __rwlock->__data)
- return _pthread_rwlock_destroy (__rwlock);
-
- return 0;
-}
-
#endif /* bits/rwlock.h */
diff --git a/sysdeps/generic/bits/semaphore.h b/sysdeps/generic/bits/semaphore.h
index b53f47e..5e987c1 100644
--- a/sysdeps/generic/bits/semaphore.h
+++ b/sysdeps/generic/bits/semaphore.h
@@ -1,5 +1,5 @@
/* Semaphore type. Generic version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -38,6 +38,6 @@ struct __semaphore
/* Initializer for a semaphore. */
#define __SEMAPHORE_INITIALIZER(pshared, value) \
- { __SPIN_LOCK_INITIALIZER, NULL, (pshared), (value), NULL }
+ { __PTHREAD_SPIN_LOCK_INITIALIZER, NULL, (pshared), (value), NULL }
#endif /* bits/mutex.h */
diff --git a/sysdeps/generic/bits/thread-attr.h b/sysdeps/generic/bits/thread-attr.h
index 3163022..f2e55f2 100644
--- a/sysdeps/generic/bits/thread-attr.h
+++ b/sysdeps/generic/bits/thread-attr.h
@@ -1,5 +1,5 @@
/* Thread attribute type. Generic version.
- Copyright (C) 2000,02 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -20,13 +20,18 @@
#ifndef _BITS_THREAD_ATTR_H
#define _BITS_THREAD_ATTR_H 1
-#include <sched.h>
+#define __need_schedparam
+#include <bits/sched.h>
+
+enum __pthread_detachstate;
+enum __pthread_inheritsched;
+enum __pthread_contentionscope;
/* This structure describes the attributes of a POSIX thread. Note
that not all of them are supported on all systems. */
struct __pthread_attr
{
- struct sched_param schedparam;
+ struct __sched_param schedparam;
void *stackaddr;
size_t stacksize;
size_t guardsize;
diff --git a/sysdeps/generic/killpg.c b/sysdeps/generic/killpg.c
new file mode 100644
index 0000000..7f7ed87
--- /dev/null
+++ b/sysdeps/generic/killpg.c
@@ -0,0 +1,27 @@
+/* killpg.c - Generic killpg implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+int
+killpg (pid_t pid, int sig)
+{
+ return kill (-pid, sig);
+}
diff --git a/sysdeps/generic/pt-attr-getschedparam.c b/sysdeps/generic/pt-attr-getschedparam.c
index 25afebd..190cf9d 100644
--- a/sysdeps/generic/pt-attr-getschedparam.c
+++ b/sysdeps/generic/pt-attr-getschedparam.c
@@ -19,6 +19,7 @@
#include <pthread.h>
#include <sched.h>
+#include <string.h>
#include <pt-internal.h>
@@ -26,6 +27,6 @@ int
pthread_attr_getschedparam (const pthread_attr_t *attr,
struct sched_param *param)
{
- *param = attr->schedparam;
+ memcpy (param, &attr->schedparam, sizeof *param);
return 0;
}
diff --git a/sysdeps/generic/pt-attr-setschedparam.c b/sysdeps/generic/pt-attr-setschedparam.c
index 18a575e..5459f10 100644
--- a/sysdeps/generic/pt-attr-setschedparam.c
+++ b/sysdeps/generic/pt-attr-setschedparam.c
@@ -30,7 +30,7 @@ pthread_attr_setschedparam (pthread_attr_t *attr,
if (memcmp (param, &__pthread_default_attr.schedparam,
sizeof *param) == 0)
{
- attr->schedparam = *param;
+ memcpy (&attr->schedparam, param, sizeof *param);
return 0;
}
diff --git a/sysdeps/generic/pt-kill.c b/sysdeps/generic/pt-kill.c
new file mode 100644
index 0000000..0dfac34
--- /dev/null
+++ b/sysdeps/generic/pt-kill.c
@@ -0,0 +1,32 @@
+/* pthread-kill.c - Generic pthread-kill implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+int
+pthread_kill (pthread_t tid, int signo)
+{
+ siginfo_t si;
+ memset (&si, 0, sizeof (si));
+ si.si_signo = signo;
+
+ return pthread_kill_siginfo_np (tid, si);
+}
+
diff --git a/sysdeps/generic/pt-mutex-destroy.c b/sysdeps/generic/pt-mutex-destroy.c
index 72faefe..3bbc73f 100644
--- a/sysdeps/generic/pt-mutex-destroy.c
+++ b/sysdeps/generic/pt-mutex-destroy.c
@@ -1,5 +1,5 @@
/* Destroy a mutex. Generic version.
- Copyright (C) 2000,02 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -26,7 +26,11 @@
int
_pthread_mutex_destroy (pthread_mutex_t *mutex)
{
- if (mutex->attr)
+ if (mutex->attr == __PTHREAD_ERRORCHECK_MUTEXATTR
+ || mutex->attr == __PTHREAD_RECURSIVE_MUTEXATTR)
+ /* Static attributes. */
+ ;
+ else
free (mutex->attr);
return 0;
diff --git a/sysdeps/generic/pt-mutex-init.c b/sysdeps/generic/pt-mutex-init.c
index da1781b..2f96028 100644
--- a/sysdeps/generic/pt-mutex-init.c
+++ b/sysdeps/generic/pt-mutex-init.c
@@ -1,5 +1,5 @@
/* Initialize a mutex. Generic version.
- Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2005, 2006, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -32,12 +32,14 @@ _pthread_mutex_init (pthread_mutex_t *mutex,
if (! attr
|| memcmp (attr, &__pthread_default_mutexattr, sizeof (*attr) == 0))
- /* Use the default attributes. */
+ /* The default attributes. */
return 0;
- /* Non-default attributes. */
+ if (! mutex->attr
+ || mutex->attr == __PTHREAD_ERRORCHECK_MUTEXATTR
+ || mutex->attr == __PTHREAD_RECURSIVE_MUTEXATTR)
+ mutex->attr = malloc (sizeof *attr);
- mutex->attr = malloc (sizeof *attr);
if (! mutex->attr)
return ENOMEM;
diff --git a/sysdeps/generic/pt-mutex-lock.c b/sysdeps/generic/pt-mutex-lock.c
index 60fc55a..528e593 100644
--- a/sysdeps/generic/pt-mutex-lock.c
+++ b/sysdeps/generic/pt-mutex-lock.c
@@ -1,5 +1,5 @@
/* Lock a mutex. Generic version.
- Copyright (C) 2000,02 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/generic/pt-mutex-timedlock.c b/sysdeps/generic/pt-mutex-timedlock.c
index 5e222bd..883e50a 100644
--- a/sysdeps/generic/pt-mutex-timedlock.c
+++ b/sysdeps/generic/pt-mutex-timedlock.c
@@ -1,5 +1,5 @@
/* Lock a mutex with a timeout. Generic version.
- Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2005, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -31,13 +31,33 @@ __pthread_mutex_timedlock_internal (struct __pthread_mutex *mutex,
const struct timespec *abstime)
{
struct __pthread *self;
+ const struct __pthread_mutexattr *attr = mutex->attr;
+
+ if (attr == __PTHREAD_ERRORCHECK_MUTEXATTR)
+ attr = &__pthread_errorcheck_mutexattr;
+ if (attr == __PTHREAD_RECURSIVE_MUTEXATTR)
+ attr = &__pthread_recursive_mutexattr;
__pthread_spin_lock (&mutex->__lock);
if (__pthread_spin_trylock (&mutex->__held) == 0)
/* Successfully acquired the lock. */
{
- if (mutex->attr)
- switch (mutex->attr->mutex_type)
+#ifdef ALWAYS_TRACK_MUTEX_OWNER
+#ifndef NDEBUG
+ self = _pthread_self ();
+ if (self)
+ /* The main thread may take a lock before the library is fully
+ initialized, in particular, before the main thread has a
+ TCB. */
+ {
+ assert (! mutex->owner);
+ mutex->owner = _pthread_self ();
+ }
+#endif
+#endif
+
+ if (attr)
+ switch (attr->mutex_type)
{
case PTHREAD_MUTEX_NORMAL:
break;
@@ -59,14 +79,18 @@ __pthread_mutex_timedlock_internal (struct __pthread_mutex *mutex,
/* The lock is busy. */
self = _pthread_self ();
+ assert (self);
- if (mutex->attr)
+ if (! attr || attr->mutex_type == PTHREAD_MUTEX_NORMAL)
+ {
+#if defined(ALWAYS_TRACK_MUTEX_OWNER)
+ assert (mutex->owner != self);
+#endif
+ }
+ else
{
- switch (mutex->attr->mutex_type)
+ switch (attr->mutex_type)
{
- case PTHREAD_MUTEX_NORMAL:
- break;
-
case PTHREAD_MUTEX_ERRORCHECK:
if (mutex->owner == self)
{
@@ -89,6 +113,11 @@ __pthread_mutex_timedlock_internal (struct __pthread_mutex *mutex,
}
}
+#if !defined(ALWAYS_TRACK_MUTEX_OWNER)
+ if (attr && attr->mutex_type != PTHREAD_MUTEX_NORMAL)
+#endif
+ assert (mutex->owner);
+
if (abstime && (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000))
return EINVAL;
@@ -123,8 +152,15 @@ __pthread_mutex_timedlock_internal (struct __pthread_mutex *mutex,
else
__pthread_block (self);
- if (mutex->attr)
- switch (mutex->attr->mutex_type)
+#if !defined(ALWAYS_TRACK_MUTEX_OWNER)
+ if (attr && attr->mutex_type != PTHREAD_MUTEX_NORMAL)
+#endif
+ {
+ assert (mutex->owner == self);
+ }
+
+ if (attr)
+ switch (attr->mutex_type)
{
case PTHREAD_MUTEX_NORMAL:
break;
diff --git a/sysdeps/generic/pt-mutex-transfer-np.c b/sysdeps/generic/pt-mutex-transfer-np.c
new file mode 100644
index 0000000..967f1c7
--- /dev/null
+++ b/sysdeps/generic/pt-mutex-transfer-np.c
@@ -0,0 +1,66 @@
+/* Transfer ownership of a mutex. Generic version.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <pthread.h>
+#include <assert.h>
+
+#include <pt-internal.h>
+
+int
+__pthread_mutex_transfer_np (struct __pthread_mutex *mutex, pthread_t tid)
+{
+ assert (mutex->owner == _pthread_self ());
+
+ struct __pthread *thread = __pthread_getid (tid);
+ const struct __pthread_mutexattr *attr = mutex->attr;
+
+ if (! thread)
+ return ESRCH;
+
+ if (thread == _pthread_self ())
+ return 0;
+
+ if (attr == __PTHREAD_ERRORCHECK_MUTEXATTR)
+ attr = &__pthread_errorcheck_mutexattr;
+ if (attr == __PTHREAD_RECURSIVE_MUTEXATTR)
+ attr = &__pthread_recursive_mutexattr;
+
+ if (attr && attr->mutex_type == PTHREAD_MUTEX_ERRORCHECK)
+ {
+
+ if (mutex->owner != _pthread_self ())
+ return EPERM;
+
+ mutex->owner = thread;
+ }
+
+#ifndef NDEBUG
+# if !defined(ALWAYS_TRACK_MUTEX_OWNER)
+ if (attr && attr->mutex_type != PTHREAD_MUTEX_NORMAL)
+# endif
+ {
+ mutex->owner = thread;
+ }
+#endif
+
+ return 0;
+}
+
+strong_alias (__pthread_mutex_transfer_np, pthread_mutex_transfer_np)
diff --git a/sysdeps/generic/pt-mutex-trylock.c b/sysdeps/generic/pt-mutex-trylock.c
index d56f6e1..7a54cc9 100644
--- a/sysdeps/generic/pt-mutex-trylock.c
+++ b/sysdeps/generic/pt-mutex-trylock.c
@@ -1,5 +1,5 @@
/* Try to Lock a mutex. Generic version.
- Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -29,13 +29,33 @@ __pthread_mutex_trylock (struct __pthread_mutex *mutex)
{
int err;
struct __pthread *self;
+ const struct __pthread_mutexattr *attr = mutex->attr;
+
+ if (attr == __PTHREAD_ERRORCHECK_MUTEXATTR)
+ attr = &__pthread_errorcheck_mutexattr;
+ if (attr == __PTHREAD_RECURSIVE_MUTEXATTR)
+ attr = &__pthread_recursive_mutexattr;
__pthread_spin_lock (&mutex->__lock);
if (__pthread_spin_trylock (&mutex->__held) == 0)
/* Acquired the lock. */
{
- if (mutex->attr)
- switch (mutex->attr->mutex_type)
+#if defined(ALWAYS_TRACK_MUTEX_OWNER)
+#ifndef NDEBUG
+ self = _pthread_self ();
+ if (self)
+ /* The main thread may take a lock before the library is fully
+ initialized, in particular, before the main thread has a
+ TCB. */
+ {
+ assert (! mutex->owner);
+ mutex->owner = _pthread_self ();
+ }
+#endif
+#endif
+
+ if (attr)
+ switch (attr->mutex_type)
{
case PTHREAD_MUTEX_NORMAL:
break;
@@ -56,10 +76,10 @@ __pthread_mutex_trylock (struct __pthread_mutex *mutex)
err = EBUSY;
- if (mutex->attr)
+ if (attr)
{
self = _pthread_self ();
- switch (mutex->attr->mutex_type)
+ switch (attr->mutex_type)
{
case PTHREAD_MUTEX_NORMAL:
break;
diff --git a/sysdeps/generic/pt-mutex-unlock.c b/sysdeps/generic/pt-mutex-unlock.c
index 2f719d3..09d70f8 100644
--- a/sysdeps/generic/pt-mutex-unlock.c
+++ b/sysdeps/generic/pt-mutex-unlock.c
@@ -1,5 +1,5 @@
/* Unlock a mutex. Generic version.
- Copyright (C) 2000,02 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -28,15 +28,31 @@ int
__pthread_mutex_unlock (pthread_mutex_t *mutex)
{
struct __pthread *wakeup;
-
+ const struct __pthread_mutexattr *attr = mutex->attr;
+
+ if (attr == __PTHREAD_ERRORCHECK_MUTEXATTR)
+ attr = &__pthread_errorcheck_mutexattr;
+ if (attr == __PTHREAD_RECURSIVE_MUTEXATTR)
+ attr = &__pthread_recursive_mutexattr;
+
__pthread_spin_lock (&mutex->__lock);
- if (mutex->attr)
- switch (mutex->attr->mutex_type)
+ if (! attr || attr->mutex_type == PTHREAD_MUTEX_NORMAL)
+ {
+#if defined(ALWAYS_TRACK_MUTEX_OWNER)
+# ifndef NDEBUG
+ if (_pthread_self ())
+ {
+ assert (mutex->owner);
+ assert (mutex->owner == _pthread_self ());
+ mutex->owner = NULL;
+ }
+# endif
+#endif
+ }
+ else
+ switch (attr->mutex_type)
{
- case PTHREAD_MUTEX_NORMAL:
- break;
-
case PTHREAD_MUTEX_ERRORCHECK:
case PTHREAD_MUTEX_RECURSIVE:
if (mutex->owner != _pthread_self ())
@@ -45,7 +61,7 @@ __pthread_mutex_unlock (pthread_mutex_t *mutex)
return EPERM;
}
- if (mutex->attr->mutex_type == PTHREAD_MUTEX_RECURSIVE)
+ if (attr->mutex_type == PTHREAD_MUTEX_RECURSIVE)
if (--mutex->locks > 0)
{
__pthread_spin_unlock (&mutex->__lock);
@@ -59,6 +75,7 @@ __pthread_mutex_unlock (pthread_mutex_t *mutex)
LOSE;
}
+
if (mutex->__queue == NULL)
{
__pthread_spin_unlock (&mutex->__held);
@@ -69,6 +86,15 @@ __pthread_mutex_unlock (pthread_mutex_t *mutex)
wakeup = mutex->__queue;
__pthread_dequeue (wakeup);
+#ifndef NDEBUG
+# if !defined (ALWAYS_TRACK_MUTEX_OWNER)
+ if (attr && attr->mutex_type != PTHREAD_MUTEX_NORMAL)
+# endif
+ {
+ mutex->owner = wakeup;
+ }
+#endif
+
/* We do not unlock MUTEX->held: we are transferring the ownership
to the thread that we are waking up. */
diff --git a/sysdeps/generic/pt-mutexattr.c b/sysdeps/generic/pt-mutexattr.c
index 647db24..5ebde6e 100644
--- a/sysdeps/generic/pt-mutexattr.c
+++ b/sysdeps/generic/pt-mutexattr.c
@@ -1,5 +1,5 @@
/* Default mutex attributes. Generic version.
- Copyright (C) 2000,02 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -27,3 +27,19 @@ const struct __pthread_mutexattr __pthread_default_mutexattr =
pshared: PTHREAD_PROCESS_PRIVATE,
mutex_type: PTHREAD_MUTEX_DEFAULT
};
+
+const struct __pthread_mutexattr __pthread_errorcheck_mutexattr =
+{
+ prioceiling: 0,
+ protocol: PTHREAD_PRIO_NONE,
+ pshared: PTHREAD_PROCESS_PRIVATE,
+ mutex_type: PTHREAD_MUTEX_ERRORCHECK
+};
+
+const struct __pthread_mutexattr __pthread_recursive_mutexattr =
+{
+ prioceiling: 0,
+ protocol: PTHREAD_PRIO_NONE,
+ pshared: PTHREAD_PROCESS_PRIVATE,
+ mutex_type: PTHREAD_MUTEX_RECURSIVE
+};
diff --git a/sysdeps/generic/pt-rwlock-destroy.c b/sysdeps/generic/pt-rwlock-destroy.c
index 034d930..045eebd 100644
--- a/sysdeps/generic/pt-rwlock-destroy.c
+++ b/sysdeps/generic/pt-rwlock-destroy.c
@@ -1,5 +1,5 @@
/* Destroy a rwlock. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/generic/pt-rwlock-init.c b/sysdeps/generic/pt-rwlock-init.c
index 8aa495e..c9ff9b2 100644
--- a/sysdeps/generic/pt-rwlock-init.c
+++ b/sysdeps/generic/pt-rwlock-init.c
@@ -1,5 +1,5 @@
/* Initialize a rwlock. Generic version.
- Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/generic/bits/thread-barrier.h b/sysdeps/generic/pt-startup.c
index 23d51ae..c21a181 100644
--- a/sysdeps/generic/bits/thread-barrier.h
+++ b/sysdeps/generic/pt-startup.c
@@ -1,5 +1,5 @@
-/* Thread barrier attribute type. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+/* Thread initialization. Generic version.
+ Copyright (C) 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -17,14 +17,9 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#ifndef _BITS_THREAD_BARRIER_H
-#define _BITS_THREAD_BARRIER_H 1
+#include <pt-internal.h>
-/* This structure describes the attributes of a POSIX thread barrier.
- Note that not all of them are supported on all systems. */
-struct __pthread_attr
+void
+__pthread_startup (void)
{
- enum __
-};
-
-#endif /* bits/thread-barrier.h */
+}
diff --git a/sysdeps/generic/raise.c b/sysdeps/generic/raise.c
new file mode 100644
index 0000000..410f557
--- /dev/null
+++ b/sysdeps/generic/raise.c
@@ -0,0 +1,41 @@
+/* raise.c - Generic raise implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+int
+raise (int signo)
+{
+ /* According to POSIX, if we implement threads (and we do), then
+ "the effect of the raise() function shall be equivalent to
+ calling: pthread_kill(pthread_self(), sig);" */
+
+debug (0, "");
+ int err = pthread_kill (pthread_self (), signo);
+debug (0, "");
+ if (err)
+ {
+ errno = err;
+ return -1;
+ }
+
+ return 0;
+}
+
diff --git a/sysdeps/generic/sem-destroy.c b/sysdeps/generic/sem-destroy.c
index 985f4ad..6486599 100644
--- a/sysdeps/generic/sem-destroy.c
+++ b/sysdeps/generic/sem-destroy.c
@@ -1,5 +1,5 @@
/* Destroy a semaphore. Generic version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/generic/sem-getvalue.c b/sysdeps/generic/sem-getvalue.c
index 8e418e3..7762089 100644
--- a/sysdeps/generic/sem-getvalue.c
+++ b/sysdeps/generic/sem-getvalue.c
@@ -1,5 +1,5 @@
/* Get the value of a semaphore. Generic version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/generic/sem-init.c b/sysdeps/generic/sem-init.c
index 6c6d79e..d2414f5 100644
--- a/sysdeps/generic/sem-init.c
+++ b/sysdeps/generic/sem-init.c
@@ -1,5 +1,5 @@
/* Initialize a semaphore. Generic version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/generic/sem-open.c b/sysdeps/generic/sem-open.c
index 9eb13aa..bae87ed 100644
--- a/sysdeps/generic/sem-open.c
+++ b/sysdeps/generic/sem-open.c
@@ -1,5 +1,5 @@
/* Open a named semaphore. Generic version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/generic/sem-post.c b/sysdeps/generic/sem-post.c
index 0e20ea7..6d438bf 100644
--- a/sysdeps/generic/sem-post.c
+++ b/sysdeps/generic/sem-post.c
@@ -1,5 +1,5 @@
/* Post a semaphore. Generic version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/generic/sem-timedwait.c b/sysdeps/generic/sem-timedwait.c
index d01bfdb..e34539a 100644
--- a/sysdeps/generic/sem-timedwait.c
+++ b/sysdeps/generic/sem-timedwait.c
@@ -1,5 +1,5 @@
/* Wait on a semaphore with a timeout. Generic version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -18,7 +18,6 @@
Boston, MA 02111-1307, USA. */
#include <semaphore.h>
-#include <error.h>
#include <errno.h>
#include <assert.h>
diff --git a/sysdeps/generic/sem-trywait.c b/sysdeps/generic/sem-trywait.c
index 199f317..437e282 100644
--- a/sysdeps/generic/sem-trywait.c
+++ b/sysdeps/generic/sem-trywait.c
@@ -1,5 +1,5 @@
/* Lock a semaphore if it does not require blocking. Generic version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/generic/sem-unlink.c b/sysdeps/generic/sem-unlink.c
index 519f4f7..570ed61 100644
--- a/sysdeps/generic/sem-unlink.c
+++ b/sysdeps/generic/sem-unlink.c
@@ -1,5 +1,5 @@
/* Unlink a named semaphore. Generic version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/generic/sem-wait.c b/sysdeps/generic/sem-wait.c
index 50752f3..8347480 100644
--- a/sysdeps/generic/sem-wait.c
+++ b/sysdeps/generic/sem-wait.c
@@ -1,5 +1,5 @@
/* Wait on a semaphore. Generic version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/generic/sigaddset.c b/sysdeps/generic/sigaddset.c
new file mode 100644
index 0000000..14edb71
--- /dev/null
+++ b/sysdeps/generic/sigaddset.c
@@ -0,0 +1,35 @@
+/* sigaddset.c - Generic sigaddset implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+int
+sigaddset (sigset_t *sigset, int signo)
+{
+ if (signo <= 0 || signo >= NSIG)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ *sigset |= sigmask (signo);
+ return 0;
+}
+
diff --git a/sysdeps/generic/sigdelset.c b/sysdeps/generic/sigdelset.c
new file mode 100644
index 0000000..5456467
--- /dev/null
+++ b/sysdeps/generic/sigdelset.c
@@ -0,0 +1,35 @@
+/* sigdelset.c - Generic sigdelset implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+int
+sigdelset (sigset_t *sigset, int signo)
+{
+ if (signo <= 0 || signo >= NSIG)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ *sigset &= ~sigmask (signo);
+ return 0;
+}
+
diff --git a/sysdeps/generic/sigemptyset.c b/sysdeps/generic/sigemptyset.c
new file mode 100644
index 0000000..690c15b
--- /dev/null
+++ b/sysdeps/generic/sigemptyset.c
@@ -0,0 +1,29 @@
+/* sigemptyset.c - Generic sigemptyset implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <signal.h>
+
+int
+sigemptyset (sigset_t *sigset)
+{
+ *sigset = 0;
+ return 0;
+}
+
diff --git a/sysdeps/generic/sigfillset.c b/sysdeps/generic/sigfillset.c
new file mode 100644
index 0000000..f0ac078
--- /dev/null
+++ b/sysdeps/generic/sigfillset.c
@@ -0,0 +1,29 @@
+/* sigfillset.c - Generic sigfillset implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <signal.h>
+
+int
+sigfillset (sigset_t *sigset)
+{
+ *sigset = (1ULL << (NSIG - 1)) - 1;
+ return 0;
+}
+
diff --git a/sysdeps/generic/siginterrupt.c b/sysdeps/generic/siginterrupt.c
new file mode 100644
index 0000000..0899efb
--- /dev/null
+++ b/sysdeps/generic/siginterrupt.c
@@ -0,0 +1,36 @@
+/* siginterrupt.c - Generic siginterrupt implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+int
+siginterrupt (int sig, int flag)
+{
+ int ret;
+ struct sigaction act;
+
+ sigaction (sig, NULL, &act);
+ if (flag)
+ act.sa_flags &= ~SA_RESTART;
+ else
+ act.sa_flags |= SA_RESTART;
+ ret = sigaction(sig, &act, NULL);
+ return ret;
+}
diff --git a/sysdeps/generic/sigismember.c b/sysdeps/generic/sigismember.c
new file mode 100644
index 0000000..b3d65c9
--- /dev/null
+++ b/sysdeps/generic/sigismember.c
@@ -0,0 +1,36 @@
+/* sigismember.c - Generic sigismember implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+int
+sigismember (const sigset_t *sigset, int signo)
+{
+ if (signo <= 0 || signo >= NSIG)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (*sigset & sigmask (signo))
+ return 1;
+ else
+ return 0;
+}
diff --git a/sysdeps/generic/signal.c b/sysdeps/generic/signal.c
new file mode 100644
index 0000000..7555d0a
--- /dev/null
+++ b/sysdeps/generic/signal.c
@@ -0,0 +1,44 @@
+/* signal.c - Generic signal implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+void (*signal (int sig, void (*handler)(int)))(int)
+{
+ struct sigaction sa;
+
+ sa.sa_handler = handler;
+ sa.sa_flags = SA_RESTART;
+
+ if (sigemptyset (&sa.sa_mask) < 0
+ || sigaddset (&sa.sa_mask, sig) < 0)
+ return SIG_ERR;
+
+ struct sigaction osa;
+ if (sigaction (sig, &sa, &osa) < 0)
+ return SIG_ERR;
+
+ return osa.sa_handler;
+}
+
+void (*bsd_signal (int sig, void (*func)(int)))(int)
+{
+ return signal (sig, func);
+}
diff --git a/sysdeps/generic/sigwait.c b/sysdeps/generic/sigwait.c
new file mode 100644
index 0000000..7d10bf8
--- /dev/null
+++ b/sysdeps/generic/sigwait.c
@@ -0,0 +1,34 @@
+/* sigwait.c - Generic sigwait implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+int
+sigwait (const sigset_t *restrict set, int *restrict signo)
+{
+ siginfo_t info;
+
+ if (sigwaitinfo (set, &info) < 0)
+ return -1;
+
+ *signo = info.si_signo;
+ return 0;
+}
+