summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@schwinge.name>2011-09-07 18:40:56 +0200
committerThomas Schwinge <thomas@schwinge.name>2011-09-07 18:40:56 +0200
commitb9d918c0f28908c7012c9d4f65f1cf2bc103fc4b (patch)
treeaa3ad24977c9dcbe1aed672431d47f035cad85ae
parent0d733170f4056ffef9ae7e3c1f0e627b47433a97 (diff)
parentc2a1b325b7b2ce0d3d16bd1e9430e1d7eddce71e (diff)
Merge commit 'refs/top-bases/t/fix_have_kernel_resources' into t/fix_have_kernel_resources
-rw-r--r--Makefile1
-rw-r--r--Makefile.am1
-rw-r--r--include/pthread/pthread.h16
-rw-r--r--include/pthread/pthreadtypes.h13
-rw-r--r--pthread/pt-yield.c26
-rw-r--r--sysdeps/generic/bits/cancelation.h3
-rw-r--r--sysdeps/generic/bits/condition-attr.h4
-rw-r--r--sysdeps/generic/bits/thread-attr.h5
-rw-r--r--sysdeps/generic/pt-attr-getschedparam.c2
-rw-r--r--sysdeps/generic/pt-attr-setschedparam.c2
10 files changed, 48 insertions, 25 deletions
diff --git a/Makefile b/Makefile
index 04dfb26..2b895e8 100644
--- a/Makefile
+++ b/Makefile
@@ -122,6 +122,7 @@ SRCS := pt-attr.c pt-attr-destroy.c pt-attr-getdetachstate.c \
pt-getcpuclockid.c \
\
pt-getschedparam.c pt-setschedparam.c pt-setschedprio.c \
+ pt-yield.c \
\
sem-close.c sem-destroy.c sem-getvalue.c sem-init.c sem-open.c \
sem-post.c sem-timedwait.c sem-trywait.c sem-unlink.c \
diff --git a/Makefile.am b/Makefile.am
index e59c946..e1c062c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -133,6 +133,7 @@ libpthread_a_SOURCES = pt-attr.c pt-attr-destroy.c pt-attr-getdetachstate.c \
pt-kill.c \
pt-getcpuclockid.c \
pt-getschedparam.c pt-setschedparam.c pt-setschedprio.c \
+ pt-yield.c \
sem-close.c sem-init.c sem-timedwait.c sem-wait.c \
sem-destroy.c sem-open.c sem-trywait.c sem-getvalue.c \
sem-post.c sem-unlink.c \
diff --git a/include/pthread/pthread.h b/include/pthread/pthread.h
index fbe3294..67b8fe4 100644
--- a/include/pthread/pthread.h
+++ b/include/pthread/pthread.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002, 2005, 2006, 2007, 2008, 2009
+/* Copyright (C) 2000, 2002, 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -377,11 +377,11 @@ extern int pthread_condattr_destroy (pthread_condattr_t *attr);
#ifdef __USE_XOPEN2K
/* Return the value of the clock attribute in *ATTR in *CLOCK_ID. */
extern int pthread_condattr_getclock (const pthread_condattr_t *__restrict attr,
- clockid_t *__restrict clock_id);
+ __clockid_t *__restrict clock_id);
/* Set the value of the clock attribute in *ATTR to CLOCK_ID. */
extern int pthread_condattr_setclock (pthread_condattr_t *attr,
- clockid_t clock_id);
+ __clockid_t clock_id);
#endif
@@ -718,7 +718,7 @@ extern int pthread_kill (pthread_t thread, int signo);
#ifdef __USE_XOPEN2K
/* Return the thread cpu clock. */
-extern int pthread_getcpuclockid (pthread_t thread, clockid_t *clock);
+extern int pthread_getcpuclockid (pthread_t thread, __clockid_t *clock);
#endif
@@ -734,6 +734,14 @@ extern int pthread_setschedparam (pthread_t thread, int policy,
/* Set thread THREAD's scheduling priority. */
extern int pthread_setschedprio (pthread_t thread, int prio);
+
+#ifdef __USE_GNU
+/* Yield the processor to another thread or process.
+ This function is similar to the POSIX `sched_yield' function but
+ might be differently implemented in the case of a m-on-n thread
+ implementation. */
+extern int pthread_yield (void);
+#endif
/* Kernel-specific interfaces. */
diff --git a/include/pthread/pthreadtypes.h b/include/pthread/pthreadtypes.h
index 471e08e..33bd009 100644
--- a/include/pthread/pthreadtypes.h
+++ b/include/pthread/pthreadtypes.h
@@ -25,18 +25,7 @@
#include <features.h>
-#define __need_clockid_t
-#include <time.h>
-
-/* If we are in a mode where clockid_t is not automatically defined
- and another header has already included <time.h> then defining
- __need_clockid_t was not enough. */
-#ifndef __clockid_t_defined
-# define __clockid_t_defined 1
-# include <bits/types.h>
-/* Clock ID used in clock and timer functions. */
-typedef __clockid_t clockid_t;
-#endif
+#include <bits/types.h>
__BEGIN_DECLS
diff --git a/pthread/pt-yield.c b/pthread/pt-yield.c
new file mode 100644
index 0000000..27848bb
--- /dev/null
+++ b/pthread/pt-yield.c
@@ -0,0 +1,26 @@
+/* Yield the processor to another thread or process.
+ Copyright (C) 2010 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. */
+
+#include <pthread.h>
+#include <sched.h>
+
+int pthread_yield(void)
+{
+ return sched_yield ();
+}
diff --git a/sysdeps/generic/bits/cancelation.h b/sysdeps/generic/bits/cancelation.h
index db9169a..46486f5 100644
--- a/sysdeps/generic/bits/cancelation.h
+++ b/sysdeps/generic/bits/cancelation.h
@@ -20,8 +20,6 @@
#ifndef _BITS_CANCELATION_H
#define _BITS_CANCELATION_H 1
-#include <assert.h>
-
struct __pthread_cancelation_handler
{
void (*handler)(void *);
@@ -47,7 +45,6 @@ struct __pthread_cancelation_handler **__pthread_get_cleanup_stack (void);
#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 a131128..4cd4e8c 100644
--- a/sysdeps/generic/bits/condition-attr.h
+++ b/sysdeps/generic/bits/condition-attr.h
@@ -20,7 +20,7 @@
#ifndef _BITS_CONDITION_ATTR_H
#define _BITS_CONDITION_ATTR_H 1
-#include <time.h>
+#include <bits/types.h>
enum __pthread_process_shared;
@@ -28,7 +28,7 @@ enum __pthread_process_shared;
struct __pthread_condattr
{
enum __pthread_process_shared pshared;
- clockid_t clock;
+ __clockid_t clock;
};
#endif /* bits/condition.h */
diff --git a/sysdeps/generic/bits/thread-attr.h b/sysdeps/generic/bits/thread-attr.h
index c3a93fd..f2e55f2 100644
--- a/sysdeps/generic/bits/thread-attr.h
+++ b/sysdeps/generic/bits/thread-attr.h
@@ -20,7 +20,8 @@
#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;
@@ -30,7 +31,7 @@ enum __pthread_contentionscope;
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/pt-attr-getschedparam.c b/sysdeps/generic/pt-attr-getschedparam.c
index 25afebd..6c3f15b 100644
--- a/sysdeps/generic/pt-attr-getschedparam.c
+++ b/sysdeps/generic/pt-attr-getschedparam.c
@@ -26,6 +26,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;
}