[xiph-cvs] cvs commit: thread thread.c thread.h

Michael Smith msmith at xiph.org
Sun Dec 29 01:55:50 PST 2002



msmith      02/12/29 04:55:50

  Modified:    .        thread.c thread.h
  Log:
  Rename thread_t to avoid problems on OS X

Revision  Changes    Path
1.18      +22 -21    thread/thread.c

Index: thread.c
===================================================================
RCS file: /usr/local/cvsroot/thread/thread.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- thread.c	22 Nov 2002 13:00:44 -0000	1.17
+++ thread.c	29 Dec 2002 09:55:50 -0000	1.18
@@ -80,7 +80,7 @@
         /* the other stuff we need to make sure this thread is inserted into
         ** the thread tree
         */
-	thread_t *thread;
+	thread_type *thread;
         pthread_t sys_thread;
 } thread_start_t;
 
@@ -118,7 +118,7 @@
 
 void thread_initialize(void)
 {
-	thread_t *thread;
+	thread_type *thread;
 
         /* set up logging */
 
@@ -149,7 +149,7 @@
 
         _threadtree = avl_tree_new(_compare_threads, NULL);
 
-	thread = (thread_t *)malloc(sizeof(thread_t));
+	thread = (thread_type *)malloc(sizeof(thread_type));
 
         thread->thread_id = _next_thread_id++;
         thread->line = 0;
@@ -238,13 +238,14 @@
 }
 
 
-thread_t *thread_create_c(char *name, void *(*start_routine)(void *), void *arg, int detached, int line, char *file)
+thread_type *thread_create_c(char *name, void *(*start_routine)(void *), 
+        void *arg, int detached, int line, char *file)
 {
         int created;
-	thread_t *thread;
+	thread_type *thread;
         thread_start_t *start;
 
-	thread = (thread_t *)malloc(sizeof(thread_t));	
+	thread = (thread_type *)malloc(sizeof(thread_type));	
         start = (thread_start_t *)malloc(sizeof(thread_start_t));
         thread->line = line;
         thread->file = strdup(file);
@@ -318,7 +319,7 @@
 void thread_mutex_lock_c(mutex_t *mutex, int line, char *file)
 {
 #ifdef DEBUG_MUTEXES
-	thread_t *th = thread_self();
+	thread_type *th = thread_self();
 
         if (!th) LOG_WARN("No mt record for %u in lock [%s:%d]", thread_self(), file, line);
 
@@ -390,7 +391,7 @@
 void thread_mutex_unlock_c(mutex_t *mutex, int line, char *file)
 {
 #ifdef DEBUG_MUTEXES
-	thread_t *th = thread_self();
+	thread_type *th = thread_self();
 
         if (!th) {
                 LOG_ERROR3("No record for %u in unlock [%s:%d]", thread_self(), file, line);
@@ -522,7 +523,7 @@
 
 void thread_exit_c(int val, int line, char *file)
 {
-	thread_t *th = thread_self();
+	thread_type *th = thread_self();
 
 #if defined(DEBUG_MUTEXES) && defined(CHECK_MUTEXES)
         if (th) {
@@ -597,7 +598,7 @@
         thread_start_t *start = (thread_start_t *)arg;
         void *(*start_routine)(void *) = start->start_routine;
         void *real_arg = start->arg;
-	thread_t *thread = start->thread;
+	thread_type *thread = start->thread;
     int detach = start->detached;
 
         _block_signals();
@@ -632,10 +633,10 @@
         return NULL;
 }
 
-thread_t *thread_self(void)
+thread_type *thread_self(void)
 {
         avl_node *node;
-	thread_t *th;
+	thread_type *th;
         pthread_t sys_thread = pthread_self();
 
         _mutex_lock(&_threadtree_mutex);
@@ -651,7 +652,7 @@
         node = avl_get_first(_threadtree);
         
         while (node) {
-		th = (thread_t *)node->key;
+		th = (thread_type *)node->key;
 
                 if (th && pthread_equal(sys_thread, th->sys_thread)) {
                         _mutex_unlock(&_threadtree_mutex);
@@ -672,7 +673,7 @@
 
 void thread_rename(const char *name)
 {
-	thread_t *th;
+	thread_type *th;
 
         th = thread_self();
         if (th->name) free(th->name);
@@ -701,7 +702,7 @@
         _mutex_unlock(&_library_mutex);
 }
 
-void thread_join(thread_t *thread)
+void thread_join(thread_type *thread)
 {
         void *ret;
         int i;
@@ -731,10 +732,10 @@
 
 static int _compare_threads(void *compare_arg, void *a, void *b)
 {
-	thread_t *t1, *t2;
+	thread_type *t1, *t2;
 
-	t1 = (thread_t *)a;
-	t2 = (thread_t *)b;
+	t1 = (thread_type *)a;
+	t2 = (thread_type *)b;
 
         if (t1->thread_id > t2->thread_id)
                 return 1;
@@ -761,9 +762,9 @@
 
 static int _free_thread(void *key)
 {
-	thread_t *t;
+	thread_type *t;
 
-	t = (thread_t *)key;
+	t = (thread_type *)key;
 
         if (t->file)
                 free(t->file);
@@ -777,7 +778,7 @@
 
 static int _free_thread_if_detached(void *key)
 {
-    thread_t *t = key;
+    thread_type *t = key;
     if(t->detached)
         return _free_thread(key);
     return 1;

<p><p>1.8       +7 -4      thread/thread.h

Index: thread.h
===================================================================
RCS file: /usr/local/cvsroot/thread/thread.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- thread.h	24 Sep 2002 07:09:08 -0000	1.7
+++ thread.h	29 Dec 2002 09:55:50 -0000	1.8
@@ -24,6 +24,8 @@
 
 #include <pthread.h>
 
+/* renamed from thread_t due to conflict on OS X */
+
 typedef struct thread_tag {
         /* the local id for the thread, and it's name */
         long thread_id;
@@ -41,7 +43,7 @@
 
         /* the system specific thread */
         pthread_t sys_thread;
-} thread_t;
+} thread_type;
 
 typedef struct mutex_tag {
         /* the local id and name of the mutex */
@@ -108,7 +110,8 @@
 void thread_shutdown(void);
 
 /* creation, destruction, locking, unlocking, signalling and waiting */
-thread_t *thread_create_c(char *name, void *(*start_routine)(void *), void *arg, int detached, int line, char *file);
+thread_type *thread_create_c(char *name, void *(*start_routine)(void *), 
+        void *arg, int detached, int line, char *file);
 void thread_mutex_create_c(mutex_t *mutex, int line, char *file);
 void thread_mutex_lock_c(mutex_t *mutex, int line, char *file);
 void thread_mutex_unlock_c(mutex_t *mutex, int line, char *file);
@@ -135,13 +138,13 @@
 #define PROTECT_CODE(code) { thread_library_lock(); code; thread_library_unlock(); }
 
 /* thread information functions */
-thread_t *thread_self(void);
+thread_type *thread_self(void);
 
 /* renames current thread */
 void thread_rename(const char *name);
 
 /* waits until thread_exit is called for another thread */
-void thread_join(thread_t *thread);
+void thread_join(thread_type *thread);
 
 #endif  /* __THREAD_H__ */
 

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list