2009-06-17 Michael Eager <eager@eagercon.com>

* libc/include/pthread.h: Support XMK (Xilinx) BSP, add RTEMS to
        PTHREAD_MUTEX_NORMAL.
        * libc/include/sys/features.h: Same.
        * libc/include/sys/types.h: Same.
This commit is contained in:
Jeff Johnston 2009-06-17 16:47:02 +00:00
parent de8c9afd7a
commit a2c3c5dab4
4 changed files with 78 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2009-06-17 Michael Eager <eager@eagercon.com>
* libc/include/pthread.h: Support XMK (Xilinx) BSP, add RTEMS to
PTHREAD_MUTEX_NORMAL.
* libc/include/sys/features.h: Same.
* libc/include/sys/types.h: Same.
2009-06-16 Corinna Vinschen <corinna@vinschen.de> 2009-06-16 Corinna Vinschen <corinna@vinschen.de>
* libc/include/locale.h (struct lconv): Add missing members required * libc/include/locale.h (struct lconv): Add missing members required

View File

@ -44,7 +44,7 @@ extern "C" {
NOTE: RTEMS does not provide pthread_atfork(). */ NOTE: RTEMS does not provide pthread_atfork(). */
#if !defined(__rtems__) #if !defined(__rtems__) && !defined(__XMK__)
#warning "Add pthread_atfork() prototype" #warning "Add pthread_atfork() prototype"
#endif #endif

View File

@ -75,6 +75,13 @@ extern "C" {
#endif #endif
/* XMK loosely adheres to POSIX -- 1003.1 */
#ifdef __XMK__
#define _POSIX_THREADS 1
#define _POSIX_THREAD_PRIORITY_SCHEDULING 1
#endif
#ifdef __svr4__ #ifdef __svr4__
# define _POSIX_JOB_CONTROL 1 # define _POSIX_JOB_CONTROL 1
# define _POSIX_SAVED_IDS 1 # define _POSIX_SAVED_IDS 1

View File

@ -165,7 +165,12 @@ typedef __uid_t uid_t;
typedef __gid_t gid_t; typedef __gid_t gid_t;
#endif #endif
#if defined(__XMK__)
typedef signed char pid_t;
#else
typedef int pid_t; typedef int pid_t;
#endif
#ifndef __CYGWIN__ #ifndef __CYGWIN__
typedef long key_t; typedef long key_t;
#endif #endif
@ -271,7 +276,11 @@ typedef long suseconds_t;
* 2.5 Primitive System Data Types, P1003.1c/D10, p. 19. * 2.5 Primitive System Data Types, P1003.1c/D10, p. 19.
*/ */
#if defined(__XMK__)
typedef unsigned int pthread_t; /* identify a thread */
#else
typedef __uint32_t pthread_t; /* identify a thread */ typedef __uint32_t pthread_t; /* identify a thread */
#endif
/* P1003.1c/D10, p. 118-119 */ /* P1003.1c/D10, p. 118-119 */
#define PTHREAD_SCOPE_PROCESS 0 #define PTHREAD_SCOPE_PROCESS 0
@ -287,6 +296,51 @@ typedef __uint32_t pthread_t; /* identify a thread */
#define PTHREAD_CREATE_DETACHED 0 #define PTHREAD_CREATE_DETACHED 0
#define PTHREAD_CREATE_JOINABLE 1 #define PTHREAD_CREATE_JOINABLE 1
#if defined(__XMK__) || defined(__rtems__)
/* The following defines are part of the X/Open System Interface (XSI). */
/* This type of mutex does not detect deadlock. A thread attempting to relock this mutex without first unlocking
* it shall deadlock. Attempting to unlock a mutex locked by a different thread results in undefined behavior.
* Attempting to unlock an unlocked mutex results in undefined behavior.
*/
#define PTHREAD_MUTEX_NORMAL 1
/*
* This type of mutex provides error checking. A thread attempting to relock this mutex without first unlocking
* it shall return with an error. A thread attempting to unlock a mutex which another thread has locked shall return
* with an error. A thread attempting to unlock an unlocked mutex shall return with an error.
*/
#define PTHREAD_MUTEX_ERRORCHECK 2
/* A thread attempting to relock this mutex without first unlocking it shall succeed in locking the mutex.
* The relocking deadlock which can occur with mutexes of type PTHREAD_MUTEX_NORMAL cannot occur with this type of mutex.
* Multiple locks of this mutex shall require the same number of unlocks to release the mutex before another thread can
* acquire the mutex. A thread attempting to unlock a mutex which another thread has locked shall return with an error.
* A thread attempting to unlock an unlocked mutex shall return with an error.
*/
#define PTHREAD_MUTEX_RECURSIVE 3
/* Attempting to recursively lock a mutex of this type results in undefined behavior. Attempting to unlock a
* mutex of this type which was not locked by the calling thread results in undefined behavior. Attempting to
* unlock a mutex of this type which is not locked results in undefined behavior. An implementation may map this
* mutex to one of the other mutex types.
*/
#define PTHREAD_MUTEX_DEFAULT 4
#endif /* defined(__XMK__) || defined(__rtems__) */
#if defined(__XMK__)
typedef struct pthread_attr_s {
int contentionscope;
struct sched_param schedparam;
int detachstate;
void *stackaddr;
size_t stacksize;
} pthread_attr_t;
#define PTHREAD_STACK_MIN 200
#else /* !defined(__XMK__) */
typedef struct { typedef struct {
int is_initialized; int is_initialized;
void *stackaddr; void *stackaddr;
@ -295,6 +349,7 @@ typedef struct {
int inheritsched; int inheritsched;
int schedpolicy; int schedpolicy;
struct sched_param schedparam; struct sched_param schedparam;
#endif /* !defined(__XMK__) */
/* P1003.4b/D8, p. 54 adds cputime_clock_allowed attribute. */ /* P1003.4b/D8, p. 54 adds cputime_clock_allowed attribute. */
#if defined(_POSIX_THREAD_CPUTIME) #if defined(_POSIX_THREAD_CPUTIME)
@ -334,6 +389,13 @@ typedef struct {
#endif #endif
#if defined(__XMK__)
typedef unsigned int pthread_mutex_t; /* identify a mutex */
typedef struct {
int type;
} pthread_mutexattr_t;
#else /* !defined(__XMK__) */
typedef __uint32_t pthread_mutex_t; /* identify a mutex */ typedef __uint32_t pthread_mutex_t; /* identify a mutex */
typedef struct { typedef struct {
@ -350,6 +412,7 @@ typedef struct {
#endif #endif
int recursive; int recursive;
} pthread_mutexattr_t; } pthread_mutexattr_t;
#endif /* !defined(__XMK__) */
/* Condition Variables */ /* Condition Variables */