This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] pthread.h, sys/types.h Add missing pthread methods


This is my first shot at adding a handful of missing pthread
methods. Given the work on the guards Yaakov is doing, I wondered
if it would be better to get them in now so they could be included
in his guard patches.

And yes.. the plan is to add these to RTEMS for improved conformance
even if the practical value of some is questionable. :)

--joel

On 2/19/2016 3:49 PM, Joel Sherrill wrote:
	* pthread.h: Add prototypes for pthread_condattr_getclock(),
	pthread_condattr_setclock(), pthread_setschedpri(),
	pthread_getcpuclockid(), pthread_getconcurrency(), and
	pthread_setconcurrency().  Also cleaned up file header to
	remove CVS Id string.
	* sys/types.h: Add clock ID to pthread_condattr_t.
---
  newlib/libc/include/pthread.h   | 27 +++++++++++++++++++++------
  newlib/libc/include/sys/types.h |  5 +++--
  2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/newlib/libc/include/pthread.h b/newlib/libc/include/pthread.h
index 907970f..20df8e4 100644
--- a/newlib/libc/include/pthread.h
+++ b/newlib/libc/include/pthread.h
@@ -1,8 +1,7 @@
-/*  pthread.h
+/*
+ *  Written by Joel Sherrill <joel.sherrill@OARcorp.com>.
   *
- *  Written by Joel Sherrill <joel@OARcorp.com>.
- *
- *  COPYRIGHT (c) 1989-2013.
+ *  COPYRIGHT (c) 1989-2013, 2015.
   *  On-Line Applications Research Corporation (OAR).
   *
   *  Permission to use, copy, modify, and distribute this software for any
@@ -14,8 +13,6 @@
   *  WARRANTY.  IN PARTICULAR,  THE AUTHOR MAKES NO REPRESENTATION
   *  OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS
   *  SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
- *
- *  $Id$
   */

  #ifndef __PTHREAD_h
@@ -96,6 +93,13 @@ int	_EXFUN(pthread_mutex_timedlock,

  int	_EXFUN(pthread_condattr_init, (pthread_condattr_t *__attr));
  int	_EXFUN(pthread_condattr_destroy, (pthread_condattr_t *__attr));
+
+int	_EXFUN(pthread_condattr_getclock,
+		(const pthread_condattr_t *__restrict __attr,
+              clockid_t *__restrict __clock_id));
+int	_EXFUN(pthread_condattr_setclock,
+		(pthread_condattr_t *__attr, clockid_t __clock_id));
+
  int	_EXFUN(pthread_condattr_getpshared,
  		(_CONST pthread_condattr_t *__attr, int *__pshared));
  int	_EXFUN(pthread_condattr_setpshared,
@@ -161,6 +165,9 @@ int	_EXFUN(pthread_getschedparam,
  int	_EXFUN(pthread_setschedparam,
  	(pthread_t __pthread, int __policy, struct sched_param *__param));

+/* Set Scheduling Priority of a Thread */
+int	_EXFUN(pthread_setschedprio, (pthread_t thread, int prio));
+
  #endif /* defined(_POSIX_THREAD_PRIORITY_SCHEDULING) */

  #if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT)
@@ -263,6 +270,14 @@ pthread_t	_EXFUN(pthread_self, (void));

  int	_EXFUN(pthread_equal, (pthread_t __t1, pthread_t __t2));

+/* Retrieve ID of a Thread's CPU Time Clock */
+int	_EXFUN(pthread_getcpuclockid,
+		(pthread_t thread, clockid_t *clock_id));
+
+/* Get/Set Current Thread's Concurrency Level */
+int	_EXFUN(pthread_setconcurrency, (int new_level));
+int	_EXFUN(pthread_getconcurrency, (void));
+
  /* Dynamic Package Initialization */

  /* This is used to statically initialize a pthread_once_t. Example:
diff --git a/newlib/libc/include/sys/types.h b/newlib/libc/include/sys/types.h
index 1e0d075..65e7b9b 100644
--- a/newlib/libc/include/sys/types.h
+++ b/newlib/libc/include/sys/types.h
@@ -409,9 +409,10 @@ typedef struct {
  typedef __uint32_t pthread_cond_t;       /* identify a condition variable */

  typedef struct {
-  int   is_initialized;
+  int      is_initialized;
+  clock_t  clock;             /* specifiy clock for timeouts */
  #if defined(_POSIX_THREAD_PROCESS_SHARED)
-  int   process_shared;       /* allow this to be shared amongst processes */
+  int      process_shared;    /* allow this to be shared amongst processes */
  #endif
  } pthread_condattr_t;         /* a condition attribute object */



--
Joel Sherrill, Ph.D.
Check out RTEMS at https://www.rtems.org
Truly free real-time operating sysem


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]