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]

Support for powerpc-xilinx-eabi BSP


Attached is a patch which configures newlib for the
Xilinx PowerPC 405/440 BSP, when _XMK__ is defined.

--
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077
2009-05-06  Michael Eager <eager@eagercon.com>

	* libc/include/pthread.h: Support XMK (Xilinx) BSP
	* libc/include/sys/features.h: Same.
	* libc/include/sys/types.h: Same.

diff -urNp --exclude '*.swp' --exclude DEV-PHASE --exclude .svn newlib-orig/newlib/libc/include/pthread.h newlib/newlib/libc/include/pthread.h
--- newlib-orig/newlib/libc/include/pthread.h	2009-04-02 15:22:23.000000000 -0700
+++ newlib/newlib/libc/include/pthread.h	2009-04-02 15:22:37.000000000 -0700
@@ -44,7 +44,7 @@ extern "C" {
   
     NOTE: RTEMS does not provide pthread_atfork().  */
 
-#if !defined(__rtems__)
+#if !defined(__rtems__) && !defined(__XMK__)
 #warning "Add pthread_atfork() prototype"
 #endif
 
diff -urNp --exclude '*.swp' --exclude DEV-PHASE --exclude .svn newlib-orig/newlib/libc/include/sys/features.h newlib/newlib/libc/include/sys/features.h
--- newlib-orig/newlib/libc/include/sys/features.h	2009-04-02 15:22:23.000000000 -0700
+++ newlib/newlib/libc/include/sys/features.h	2009-04-02 15:22:37.000000000 -0700
@@ -75,6 +75,13 @@ extern "C" {
 
 #endif
 
+/* XMK loosely adheres to POSIX -- 1003.1 */
+#ifdef __XMK__
+#define _POSIX_THREADS				1
+#define _POSIX_THREAD_PRIORITY_SCHEDULING	1
+#endif
+
+
 #ifdef __svr4__
 # define _POSIX_JOB_CONTROL     1
 # define _POSIX_SAVED_IDS       1
diff -urNp --exclude '*.swp' --exclude DEV-PHASE --exclude .svn newlib-orig/newlib/libc/include/sys/types.h newlib/newlib/libc/include/sys/types.h
--- newlib-orig/newlib/libc/include/sys/types.h	2009-04-02 15:22:23.000000000 -0700
+++ newlib/newlib/libc/include/sys/types.h	2009-04-02 15:22:37.000000000 -0700
@@ -165,7 +165,12 @@ typedef __uid_t uid_t;
 typedef __gid_t gid_t;
 #endif
 
+#if defined(__XMK__)
+typedef signed char pid_t;
+#else
 typedef int pid_t;
+#endif
+
 #ifndef __CYGWIN__
 typedef	long key_t;
 #endif
@@ -271,7 +276,11 @@ typedef long suseconds_t;
  *  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 */
+#endif
 
 /* P1003.1c/D10, p. 118-119 */
 #define PTHREAD_SCOPE_PROCESS 0
@@ -287,6 +296,51 @@ typedef __uint32_t pthread_t;           
 #define PTHREAD_CREATE_DETACHED 0
 #define PTHREAD_CREATE_JOINABLE  1
 
+#if defined(__XMK__)
+/* 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__) */
+
+#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
 typedef struct {
   int is_initialized;
   void *stackaddr;
@@ -295,6 +349,7 @@ typedef struct {
   int inheritsched;
   int schedpolicy;
   struct sched_param schedparam;
+#endif /* defined(__XMK__) */
 
   /* P1003.4b/D8, p. 54 adds cputime_clock_allowed attribute.  */
 #if defined(_POSIX_THREAD_CPUTIME)
@@ -334,6 +389,13 @@ typedef struct {
 
 #endif
 
+#if defined(__XMK__)
+typedef unsigned int pthread_mutex_t;    /* identify a mutex */
+
+typedef struct {
+    int type;
+} pthread_mutexattr_t;
+#else
 typedef __uint32_t pthread_mutex_t;      /* identify a mutex */
 
 typedef struct {
@@ -350,6 +412,7 @@ typedef struct {
 #endif
   int   recursive;
 } pthread_mutexattr_t;
+#endif /* defined(__XMK__) */
 
 /* Condition Variables */
 

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