summaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2015-10-31 10:17:18 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2015-10-31 10:17:18 +0000
commit9d4b20e48059564bf3061e9672133020544c2759 (patch)
tree7ca649eddf5deec02cfc2336d0df45df2acd807a /sysdeps
parentc7c777b3d43d490c2012f6b8e6a61c455479fbbc (diff)
parent6348dc004579b2f2580f346b636ec59f40888b15 (diff)
Merge branch 'master' into master-glibc
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/raise.c21
-rw-r--r--sysdeps/hurd/pt-kill.c5
-rw-r--r--sysdeps/mach/hurd/bits/pthread-np.h2
-rw-r--r--sysdeps/pthread/bits/semaphore.h3
-rw-r--r--sysdeps/pthread/semaphore.h81
5 files changed, 98 insertions, 14 deletions
diff --git a/sysdeps/generic/raise.c b/sysdeps/generic/raise.c
index 15348ce..3c497da 100644
--- a/sysdeps/generic/raise.c
+++ b/sysdeps/generic/raise.c
@@ -19,6 +19,8 @@
<http://www.gnu.org/licenses/>. */
#include <pthread.h>
+#include <signal.h>
+#include <unistd.h>
#pragma weak pthread_kill
#pragma weak pthread_self
@@ -29,17 +31,18 @@ raise (int signo)
"the effect of the raise() function shall be equivalent to
calling: pthread_kill(pthread_self(), sig);" */
- int err;
if (pthread_kill)
- err = pthread_kill (pthread_self (), signo);
- else
- err = __kill (__getpid (), signo);
- if (err)
{
- errno = err;
- return -1;
+ int err;
+ err = pthread_kill (pthread_self (), signo);
+ if (err)
+ {
+ errno = err;
+ return -1;
+ }
+ return 0;
}
-
- return 0;
+ else
+ return __kill (__getpid (), signo);
}
diff --git a/sysdeps/hurd/pt-kill.c b/sysdeps/hurd/pt-kill.c
index d204e3f..49dfd7d 100644
--- a/sysdeps/hurd/pt-kill.c
+++ b/sysdeps/hurd/pt-kill.c
@@ -46,7 +46,6 @@ pthread_kill (pthread_t thread, int sig)
detail.code = sig;
detail.error = 0;
- _hurd_raise_signal (ss, sig, &detail);
-
- return 0;
+ __spin_lock (&ss->lock);
+ return _hurd_raise_signal (ss, sig, &detail);
}
diff --git a/sysdeps/mach/hurd/bits/pthread-np.h b/sysdeps/mach/hurd/bits/pthread-np.h
index 5f75e06..4487ffd 100644
--- a/sysdeps/mach/hurd/bits/pthread-np.h
+++ b/sysdeps/mach/hurd/bits/pthread-np.h
@@ -33,6 +33,6 @@ extern int pthread_hurd_cond_wait_np (pthread_cond_t *__restrict __cond,
See hurd_thread_cancel. */
extern int pthread_hurd_cond_timedwait_np (pthread_cond_t *__restrict __cond,
pthread_mutex_t *__restrict __mutex,
- const struct timespec *abstime);
+ const struct timespec *__abstime);
#endif /* bits/pthread-np.h */
diff --git a/sysdeps/pthread/bits/semaphore.h b/sysdeps/pthread/bits/semaphore.h
index 5e987c1..4c78409 100644
--- a/sysdeps/pthread/bits/semaphore.h
+++ b/sysdeps/pthread/bits/semaphore.h
@@ -24,7 +24,8 @@
#error Never include <bits/semaphore.h> directly.
#endif
-#include <pthread.h>
+#include <bits/spin-lock.h>
+#include <bits/pthread.h>
/* User visible part of a semaphore. */
struct __semaphore
diff --git a/sysdeps/pthread/semaphore.h b/sysdeps/pthread/semaphore.h
new file mode 100644
index 0000000..64249f6
--- /dev/null
+++ b/sysdeps/pthread/semaphore.h
@@ -0,0 +1,81 @@
+/* Copyright (C) 2005, 2007 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. */
+
+#ifndef _SEMAPHORE_H
+#define _SEMAPHORE_H 1
+
+#include <features.h>
+#include <sys/types.h>
+#ifdef __USE_XOPEN2K
+# define __need_timespec
+# include <time.h>
+#endif
+
+/* Get the definition for struct __semaphore. */
+#include <bits/semaphore.h>
+
+
+__BEGIN_DECLS
+
+#define SEM_FAILED ((void *) 0)
+
+typedef struct __semaphore sem_t;
+
+/* Initialize semaphore *SEM with value VALUE. */
+extern int sem_init (sem_t *__sem, int __pshared, unsigned int __value)
+ __THROW;
+/* Destroy semaphore *SEM created with sem_init. */
+extern int sem_destroy (sem_t *__sem) __THROW;
+
+/* Open a named semaphore. */
+extern sem_t *sem_open (const char *__name, int __oflag, ...) __THROW;
+
+/* Close a semaphore returned by sem_open. */
+extern int sem_close (sem_t *__sem) __THROW;
+
+/* Unlink a named semaphore. */
+extern int sem_unlink (const char *__name) __THROW;
+
+/* Perform a down operation on semaphore *SEM.
+
+ This function is a cancellation point and therefore not marked with
+ __THROW. */
+extern int sem_wait (sem_t *__sem);
+
+#ifdef __USE_XOPEN2K
+/* Perform a down operation on semaphore *SEM but don't wait longer
+ than TIMEOUT. */
+extern int sem_timedwait (sem_t *__restrict __sem,
+ const struct timespec *__restrict __abstime);
+#endif
+
+/* Perform a down operation on semaphore *SEM if it can be done so
+ without blocking. */
+extern int sem_trywait (sem_t *__sem) __THROWNL;
+
+/* Perform an up operation on semaphore *SEM. */
+extern int sem_post (sem_t *__sem) __THROWNL;
+
+/* Store the value of semaphore *SEM in *VALUE. */
+extern int sem_getvalue (sem_t *__restrict __sem, int *__restrict __sval)
+ __THROW;
+
+
+__END_DECLS
+
+#endif /* semaphore.h */