bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFA/base] Make thr-mach.h private


From: David Ayers
Subject: [RFA/base] Make thr-mach.h private
Date: Wed, 11 Feb 2004 15:26:05 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6) Gecko/20040113

Hello everyone,

Barring objections, I would like to make thr-mach.h a private header with this patch. It should only have a user visible effect for building apple-gnu-gnu. It would be nice, if someone can test this there and tell me if it still builds correctly. (A build log with messages=yes would be nice, but please send privately.) AFAIK there are still issues when trying to run code on apple-gnu-gnu.

       * Headers/Foundation/NSLock.h: Make types of _mutex and _condition
       transparent to avoid including private thr-mach.h header.
       * Headers/Foundation/NSThread.h: Do not include private thr-mach.h
       header.
       * Source/thr-mach.h: Moved here from
       Headers/Additions/GNUstepBase/thr-mach.h.
       * Source/NSLock.m: Include private thr-mach.h header for
       apple-gnu-gnu.  Added defines for typing transparent instance
       variables and use them in various methods.
       * Source/NSThread.m: Include private thr-mach.h header for
       apple-gnu-gnu.
       * Source/thr-mach.m: Include private thr-mach.h header from new
       location.
       * Source/thr-pthread.m: Ditto.
       * Source/GNUmakefile: Do not install private thr-mach.h header.

Cheers,
David

Index: Headers/Additions/GNUstepBase/thr-mach.h
===================================================================
RCS file: Headers/Additions/GNUstepBase/thr-mach.h
diff -N Headers/Additions/GNUstepBase/thr-mach.h
--- Headers/Additions/GNUstepBase/thr-mach.h    31 Jul 2003 23:49:29 -0000      
1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,117 +0,0 @@
-/* Thread and mutex controls for Objective C.
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
-   Contributed by Galen C. Hunt (address@hidden)
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC 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 General Public License for more details.
-
-GNU CC is free software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the Free Software
-Foundation; either version 2, or (at your option) any later version.
-
-GNU CC 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 General Public License for more
-details.
-
-You should have received a copy of the GNU General Public License along with
-GNU CC; see the file COPYING.  If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
-
-/* As a special exception, if you link this library with files
-   compiled with GCC to produce an executable, this does not cause
-   the resulting executable to be covered by the GNU General Public License.
-   This exception does not however invalidate any other reasons why
-   the executable file might be covered by the GNU General Public License.  */
-
-
-#ifndef __thread_INCLUDE_GNU
-#define __thread_INCLUDE_GNU
-
-#include <objc/objc.h>
-
-/*************************************************************************
- *  Universal static variables:
- */
-extern int __objc_thread_exit_status;      /* Global exit status.   */
-
-/********
- *  Thread safe implementation types and functions.  
- */
-
-/* Thread priorities */
-#define OBJC_THREAD_INTERACTIVE_PRIORITY        2
-#define OBJC_THREAD_BACKGROUND_PRIORITY         1
-#define OBJC_THREAD_LOW_PRIORITY                0
-
-/* A thread */
-typedef void * objc_thread_t;
-
-/* This structure represents a single mutual exclusion lock. */
-struct objc_mutex
-{
-  volatile objc_thread_t owner;     /* Id of thread that owns. */
-  volatile int depth;               /* # of acquires. */
-  void * backend;                   /* Specific to backend */
-};
-typedef struct objc_mutex *objc_mutex_t;
-
-/* This structure represents a single condition mutex */
-struct objc_condition
-{
-  void * backend;                   /* Specific to backend */
-};
-typedef struct objc_condition *objc_condition_t;
-
-/* Frontend mutex functions */
-objc_mutex_t objc_mutex_allocate(void);
-int objc_mutex_deallocate(objc_mutex_t mutex);
-int objc_mutex_lock(objc_mutex_t mutex);
-int objc_mutex_unlock(objc_mutex_t mutex);
-int objc_mutex_trylock(objc_mutex_t mutex);
-
-/* Frontend condition mutex functions */
-objc_condition_t objc_condition_allocate(void);
-int objc_condition_deallocate(objc_condition_t condition);
-int objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex);
-int objc_condition_signal(objc_condition_t condition);
-int objc_condition_broadcast(objc_condition_t condition);
-
-/* Frontend thread functions */
-objc_thread_t objc_thread_detach(SEL selector, id object, id argument);
-void objc_thread_yield(void);
-int objc_thread_exit(void);
-int objc_thread_set_priority(int priority);
-int objc_thread_get_priority(void);
-void * objc_thread_get_data(void);
-int objc_thread_set_data(void *value);
-objc_thread_t objc_thread_id(void);
-void objc_thread_add(void);
-void objc_thread_remove(void);
-
-/*
-  Use this to set the hook function that will be called when the 
-  runtime initially becomes multi threaded.
-  The hook function is only called once, meaning only when the 
-  2nd thread is spawned, not for each and every thread.
-
-  It returns the previous hook function or NULL if there is none.
-
-  A program outside of the runtime could set this to some function so
-  it can be informed; for example, the GNUstep Base Library sets it 
-  so it can implement the NSBecomingMultiThreaded notification.
-  */
-typedef void (*objc_thread_callback)();
-objc_thread_callback objc_set_thread_callback(objc_thread_callback func);
-
-#endif /* not __thread_INCLUDE_GNU */
Index: Headers/Foundation/NSLock.h
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Headers/Foundation/NSLock.h,v
retrieving revision 1.2
diff -u -r1.2 NSLock.h
--- Headers/Foundation/NSLock.h 30 Oct 2003 13:44:52 -0000      1.2
+++ Headers/Foundation/NSLock.h 11 Feb 2004 13:54:24 -0000
@@ -32,9 +32,6 @@
 #define _GNUstep_H_NSLock
 
 #include <Foundation/NSObject.h>
-#ifdef NeXT_RUNTIME
-#include <GNUstepBase/thr-mach.h>
-#endif
 
 /*
  * NSLocking protocol
@@ -53,7 +50,7 @@
 @interface NSLock : NSObject <NSLocking, GCFinalization>
 {
 @private
-  objc_mutex_t _mutex;
+  void *_mutex;
 }
 
 - (BOOL) tryLock;
@@ -71,9 +68,9 @@
 @interface NSConditionLock : NSObject <NSLocking, GCFinalization>
 {
 @private
-  objc_condition_t     _condition;
-  objc_mutex_t         _mutex;
-  int                  _condition_value;
+  void *_condition;
+  void *_mutex;
+  int   _condition_value;
 }
 
 /*
@@ -117,7 +114,7 @@
 @interface NSRecursiveLock : NSObject <NSLocking, GCFinalization>
 {
 @private
-  objc_mutex_t _mutex;
+  void *_mutex;
 }
 
 - (BOOL) tryLock;
Index: Headers/Foundation/NSThread.h
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Headers/Foundation/NSThread.h,v
retrieving revision 1.1
diff -u -r1.1 NSThread.h
--- Headers/Foundation/NSThread.h       31 Jul 2003 23:49:30 -0000      1.1
+++ Headers/Foundation/NSThread.h       11 Feb 2004 13:54:24 -0000
@@ -25,9 +25,6 @@
 #ifndef __NSThread_h_GNUSTEP_BASE_INCLUDE
 #define __NSThread_h_GNUSTEP_BASE_INCLUDE
 
-#ifdef NeXT_RUNTIME
-#include <GNUstepBase/thr-mach.h>
-#endif
 #include <Foundation/NSDictionary.h>
 #include <Foundation/NSDate.h>
 #include <Foundation/NSException.h>
Index: Source/GNUmakefile
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/GNUmakefile,v
retrieving revision 1.140
diff -u -r1.140 GNUmakefile
--- Source/GNUmakefile  22 Jan 2004 09:37:07 -0000      1.140
+++ Source/GNUmakefile  11 Feb 2004 13:54:24 -0000
@@ -126,10 +126,6 @@
 
 GNU_HEADERS = $(ADD_HEADERS)
 
-ifneq ($(OBJC_RUNTIME_LIB), gnu)
-GNU_HEADERS += thr-mach.h
-endif
-
 # GNUStep source files
 
 BASE_MFILES = \
Index: Source/NSLock.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSLock.m,v
retrieving revision 1.27
diff -u -r1.27 NSLock.m
--- Source/NSLock.m     30 Oct 2003 13:44:53 -0000      1.27
+++ Source/NSLock.m     11 Feb 2004 13:54:24 -0000
@@ -35,6 +35,12 @@
 #include "Foundation/NSException.h"
 #include "Foundation/NSDebug.h"
 #include "Foundation/NSThread.h"
+#ifdef NeXT_RUNTIME
+#include "thr-mach.h"
+#endif
+
+#define _MUTEX     ((objc_mutex_t)_mutex)
+#define _CONDITION ((objc_condition_t)_condition)
 
 extern void            GSSleepUntilIntervalSinceReferenceDate(NSTimeInterval);
 extern NSTimeInterval  GSTimeNow();
@@ -167,7 +173,7 @@
     {
       // Ask the runtime to deallocate the mutex
       // If there are outstanding locks then it will block
-      if (objc_mutex_deallocate(_mutex) == -1)
+      if (objc_mutex_deallocate(_MUTEX) == -1)
        {
          NSWarnMLog(@"objc_mutex_deallocate() failed");
        }
@@ -184,13 +190,13 @@
 - (BOOL) tryLock
 {
   /* Return NO if we're already locked */
-  if (_mutex->owner == objc_thread_id())
+  if (_MUTEX->owner == objc_thread_id())
     {  
       return NO;
     }
 
   // Ask the runtime to acquire a lock on the mutex
-  if (objc_mutex_trylock(_mutex) == -1)
+  if (objc_mutex_trylock(_MUTEX) == -1)
     {
       return NO;
     }
@@ -212,8 +218,8 @@
 
   /* This is really the behavior of OpenStep, if the current thread has
      the lock, we just block until the time limit is up. Very odd */
-  while (_mutex->owner == objc_thread_id()
-    || (x = objc_mutex_trylock(_mutex)) == -1)
+  while (_MUTEX->owner == objc_thread_id()
+    || (x = objc_mutex_trylock(_MUTEX)) == -1)
     {
       if (GSSleepOrFail(&ctxt) == NO)
        {
@@ -228,11 +234,11 @@
  */
 - (void) lock
 {
-  CHECK_RECURSIVE_LOCK(_mutex);
+  CHECK_RECURSIVE_LOCK(_MUTEX);
 
   // Ask the runtime to acquire a lock on the mutex
   // This will block
-  if (objc_mutex_lock(_mutex) == -1)
+  if (objc_mutex_lock(_MUTEX) == -1)
     {
       [NSException raise: NSLockException
         format: @"failed to lock mutex"];
@@ -243,7 +249,7 @@
 - (void) unlock
 {
   // Ask the runtime to release a lock on the mutex
-  if (objc_mutex_unlock(_mutex) == -1)
+  if (objc_mutex_unlock(_MUTEX) == -1)
     {
       [NSException raise: NSLockException
                  format: @"unlock: failed to unlock mutex"];
@@ -303,7 +309,7 @@
   if (_condition != 0)
     {
       // Ask the runtime to deallocate the condition
-      if (objc_condition_deallocate(_condition) == -1)
+      if (objc_condition_deallocate(_CONDITION) == -1)
        {
          NSWarnMLog(@"objc_condition_deallocate() failed");
        }
@@ -312,7 +318,7 @@
     {
       // Ask the runtime to deallocate the mutex
       // If there are outstanding locks then it will block
-      if (objc_mutex_deallocate(_mutex) == -1)
+      if (objc_mutex_deallocate(_MUTEX) == -1)
        {
          NSWarnMLog(@"objc_mutex_deallocate() failed");
        }
@@ -328,9 +334,9 @@
 // Acquiring and release the lock
 - (void) lockWhenCondition: (int)value
 {
-  CHECK_RECURSIVE_CONDITION_LOCK(_mutex);
+  CHECK_RECURSIVE_CONDITION_LOCK(_MUTEX);
 
-  if (objc_mutex_lock(_mutex) == -1)
+  if (objc_mutex_lock(_MUTEX) == -1)
     {
       [NSException raise: NSConditionLockException
         format: @"lockWhenCondition: failed to lock mutex"];
@@ -339,7 +345,7 @@
 
   while (_condition_value != value)
     {
-      if (objc_condition_wait(_condition, _mutex) == -1)
+      if (objc_condition_wait(_CONDITION, _MUTEX) == -1)
         {
           [NSException raise: NSConditionLockException
             format: @"objc_condition_wait failed"];
@@ -353,7 +359,7 @@
   int depth;
 
   // First check to make sure we have the lock
-  depth = objc_mutex_trylock(_mutex);
+  depth = objc_mutex_trylock(_MUTEX);
 
   // Another thread has the lock so abort
   if (depth == -1)
@@ -376,7 +382,7 @@
   _condition_value = value;
 
   // wake up blocked threads
-  if (objc_condition_broadcast(_condition) == -1)
+  if (objc_condition_broadcast(_CONDITION) == -1)
     {
       [NSException raise: NSConditionLockException
         format: @"unlockWithCondition: objc_condition_broadcast failed"];
@@ -384,8 +390,8 @@
     }
 
   // and unlock twice
-  if ((objc_mutex_unlock(_mutex) == -1)
-    || (objc_mutex_unlock(_mutex) == -1))
+  if ((objc_mutex_unlock(_MUTEX) == -1)
+    || (objc_mutex_unlock(_MUTEX) == -1))
     {
       [NSException raise: NSConditionLockException
         format: @"unlockWithCondition: failed to unlock mutex"];
@@ -395,10 +401,10 @@
 
 - (BOOL) tryLock
 {
-  CHECK_RECURSIVE_CONDITION_LOCK(_mutex);
+  CHECK_RECURSIVE_CONDITION_LOCK(_MUTEX);
 
   // Ask the runtime to acquire a lock on the mutex
-  if (objc_mutex_trylock(_mutex) == -1)
+  if (objc_mutex_trylock(_MUTEX) == -1)
     return NO;
   else
     return YES;
@@ -428,11 +434,11 @@
 { 
   GSSleepInfo  ctxt;
 
-  CHECK_RECURSIVE_CONDITION_LOCK(_mutex);
+  CHECK_RECURSIVE_CONDITION_LOCK(_MUTEX);
 
   GSSleepInit(limit, &ctxt);
 
-  while (objc_mutex_trylock(_mutex) == -1)
+  while (objc_mutex_trylock(_MUTEX) == -1)
     {
       if (GSSleepOrFail(&ctxt) == NO)
        {
@@ -449,7 +455,7 @@
 #ifndef HAVE_OBJC_CONDITION_TIMEDWAIT
   GSSleepInfo  ctxt;
 
-  CHECK_RECURSIVE_CONDITION_LOCK(_mutex);
+  CHECK_RECURSIVE_CONDITION_LOCK(_MUTEX);
 
   GSSleepInit(limitDate, &ctxt);
 
@@ -457,7 +463,7 @@
     {
       if (_condition_value == condition_to_meet)
        {
-         while (objc_mutex_trylock(_mutex) == -1)
+         while (objc_mutex_trylock(_MUTEX) == -1)
            {
              if (GSSleepOrFail(&ctxt) == NO)
                {
@@ -468,7 +474,7 @@
            {
              return YES;
            }
-         if (objc_mutex_unlock(_mutex) == -1)
+         if (objc_mutex_unlock(_MUTEX) == -1)
            {
              [NSException raise: NSConditionLockException
                           format: @"%s failed to unlock mutex",
@@ -485,9 +491,9 @@
   NSTimeInterval atimeinterval;
   struct timespec endtime;
   
-  CHECK_RECURSIVE_CONDITION_LOCK(_mutex);
+  CHECK_RECURSIVE_CONDITION_LOCK(_MUTEX);
   
-  if (-1 == objc_mutex_lock(_mutex))
+  if (-1 == objc_mutex_lock(_MUTEX))
     [NSException raise: NSConditionLockException 
                 format: @"lockWhenCondition: failed to lock mutex"];
        
@@ -501,7 +507,7 @@
   
   while (_condition_value != condition_to_meet)
     {
-      switch (objc_condition_timedwait(_condition, _mutex, &endtime))
+      switch (objc_condition_timedwait(_CONDITION, _MUTEX, &endtime))
        {
          case 0: 
            break;
@@ -525,11 +531,11 @@
 // These methods ignore the condition
 - (void) lock
 {
-  CHECK_RECURSIVE_CONDITION_LOCK(_mutex);
+  CHECK_RECURSIVE_CONDITION_LOCK(_MUTEX);
 
   // Ask the runtime to acquire a lock on the mutex
   // This will block
-  if (objc_mutex_lock(_mutex) == -1)
+  if (objc_mutex_lock(_MUTEX) == -1)
     {
       [NSException raise: NSConditionLockException
         format: @"lock: failed to lock mutex"];
@@ -540,7 +546,7 @@
 - (void) unlock
 {
   // wake up blocked threads
-  if (objc_condition_broadcast(_condition) == -1)
+  if (objc_condition_broadcast(_CONDITION) == -1)
     {
       [NSException raise: NSConditionLockException
         format: @"unlockWithCondition: objc_condition_broadcast failed"];
@@ -548,7 +554,7 @@
     }
 
   // Ask the runtime to release a lock on the mutex
-  if (objc_mutex_unlock(_mutex) == -1)
+  if (objc_mutex_unlock(_MUTEX) == -1)
     {
       [NSException raise: NSConditionLockException
         format: @"unlock: failed to unlock mutex"];
@@ -600,7 +606,7 @@
     {
       // Ask the runtime to deallocate the mutex
       // If there are outstanding locks then it will block
-      if (objc_mutex_deallocate(_mutex) == -1)
+      if (objc_mutex_deallocate(_MUTEX) == -1)
        {
          NSWarnMLog(@"objc_mutex_deallocate() failed");
        }
@@ -616,7 +622,7 @@
 - (BOOL) tryLock
 {
   // Ask the runtime to acquire a lock on the mutex
-  if (objc_mutex_trylock(_mutex) == -1)
+  if (objc_mutex_trylock(_MUTEX) == -1)
     return NO;
   else
     return YES;
@@ -632,7 +638,7 @@
   GSSleepInfo  ctxt;
 
   GSSleepInit(limit, &ctxt);
-  while (objc_mutex_trylock(_mutex) == -1)
+  while (objc_mutex_trylock(_MUTEX) == -1)
     {
       if (GSSleepOrFail(&ctxt) == NO)
        {
@@ -647,7 +653,7 @@
 {
   // Ask the runtime to acquire a lock on the mutex
   // This will block
-  if (objc_mutex_lock(_mutex) == -1)
+  if (objc_mutex_lock(_MUTEX) == -1)
     {
       [NSException raise: NSRecursiveLockException
         format: @"lock: failed to lock mutex"];
@@ -658,7 +664,7 @@
 - (void) unlock
 {
   // Ask the runtime to release a lock on the mutex
-  if (objc_mutex_unlock(_mutex) == -1)
+  if (objc_mutex_unlock(_MUTEX) == -1)
     {
       [NSException raise: NSRecursiveLockException
         format: @"unlock: failed to unlock mutex"];
Index: Source/NSThread.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSThread.m,v
retrieving revision 1.75
diff -u -r1.75 NSThread.m
--- Source/NSThread.m   23 Dec 2003 17:41:38 -0000      1.75
+++ Source/NSThread.m   11 Feb 2004 13:54:24 -0000
@@ -38,6 +38,9 @@
 #ifdef HAVE_NANOSLEEP
 #include <time.h>
 #endif
+#ifdef NeXT_RUNTIME
+#include "thr-mach.h"
+#endif
 
 #include "Foundation/NSException.h"
 #include "Foundation/NSThread.h"
Index: Source/thr-mach.h
===================================================================
RCS file: Source/thr-mach.h
diff -N Source/thr-mach.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ Source/thr-mach.h   11 Feb 2004 13:54:24 -0000
@@ -0,0 +1,117 @@
+/* Thread and mutex controls for Objective C.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Contributed by Galen C. Hunt (address@hidden)
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC 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 General Public License for more details.
+
+GNU CC is free software; you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2, or (at your option) any later version.
+
+GNU CC 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 General Public License for more
+details.
+
+You should have received a copy of the GNU General Public License along with
+GNU CC; see the file COPYING.  If not, write to the Free Software
+Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* As a special exception, if you link this library with files
+   compiled with GCC to produce an executable, this does not cause
+   the resulting executable to be covered by the GNU General Public License.
+   This exception does not however invalidate any other reasons why
+   the executable file might be covered by the GNU General Public License.  */
+
+
+#ifndef __thread_INCLUDE_GNU
+#define __thread_INCLUDE_GNU
+
+#include <objc/objc.h>
+
+/*************************************************************************
+ *  Universal static variables:
+ */
+extern int __objc_thread_exit_status;      /* Global exit status.   */
+
+/********
+ *  Thread safe implementation types and functions.  
+ */
+
+/* Thread priorities */
+#define OBJC_THREAD_INTERACTIVE_PRIORITY        2
+#define OBJC_THREAD_BACKGROUND_PRIORITY         1
+#define OBJC_THREAD_LOW_PRIORITY                0
+
+/* A thread */
+typedef void * objc_thread_t;
+
+/* This structure represents a single mutual exclusion lock. */
+struct objc_mutex
+{
+  volatile objc_thread_t owner;     /* Id of thread that owns. */
+  volatile int depth;               /* # of acquires. */
+  void * backend;                   /* Specific to backend */
+};
+typedef struct objc_mutex *objc_mutex_t;
+
+/* This structure represents a single condition mutex */
+struct objc_condition
+{
+  void * backend;                   /* Specific to backend */
+};
+typedef struct objc_condition *objc_condition_t;
+
+/* Frontend mutex functions */
+objc_mutex_t objc_mutex_allocate(void);
+int objc_mutex_deallocate(objc_mutex_t mutex);
+int objc_mutex_lock(objc_mutex_t mutex);
+int objc_mutex_unlock(objc_mutex_t mutex);
+int objc_mutex_trylock(objc_mutex_t mutex);
+
+/* Frontend condition mutex functions */
+objc_condition_t objc_condition_allocate(void);
+int objc_condition_deallocate(objc_condition_t condition);
+int objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex);
+int objc_condition_signal(objc_condition_t condition);
+int objc_condition_broadcast(objc_condition_t condition);
+
+/* Frontend thread functions */
+objc_thread_t objc_thread_detach(SEL selector, id object, id argument);
+void objc_thread_yield(void);
+int objc_thread_exit(void);
+int objc_thread_set_priority(int priority);
+int objc_thread_get_priority(void);
+void * objc_thread_get_data(void);
+int objc_thread_set_data(void *value);
+objc_thread_t objc_thread_id(void);
+void objc_thread_add(void);
+void objc_thread_remove(void);
+
+/*
+  Use this to set the hook function that will be called when the 
+  runtime initially becomes multi threaded.
+  The hook function is only called once, meaning only when the 
+  2nd thread is spawned, not for each and every thread.
+
+  It returns the previous hook function or NULL if there is none.
+
+  A program outside of the runtime could set this to some function so
+  it can be informed; for example, the GNUstep Base Library sets it 
+  so it can implement the NSBecomingMultiThreaded notification.
+  */
+typedef void (*objc_thread_callback)();
+objc_thread_callback objc_set_thread_callback(objc_thread_callback func);
+
+#endif /* not __thread_INCLUDE_GNU */
Index: Source/thr-mach.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/thr-mach.m,v
retrieving revision 1.4
diff -u -r1.4 thr-mach.m
--- Source/thr-mach.m   31 Jul 2003 23:49:32 -0000      1.4
+++ Source/thr-mach.m   11 Feb 2004 13:54:24 -0000
@@ -29,7 +29,7 @@
 #include <mach/mach.h>
 #include <mach/cthreads.h>
 #include "GNUstepBase/objc-gnu2next.h"
-#include "GNUstepBase/thr-mach.h"
+#include "thr-mach.h"
 
 /* Global exit status. */
 int __objc_thread_exit_status = 0;
Index: Source/thr-pthread.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/thr-pthread.m,v
retrieving revision 1.5
diff -u -r1.5 thr-pthread.m
--- Source/thr-pthread.m        31 Jul 2003 23:49:32 -0000      1.5
+++ Source/thr-pthread.m        11 Feb 2004 13:54:24 -0000
@@ -28,7 +28,7 @@
 #include <pthread.h>
 #include <stdarg.h>
 #include "GNUstepBase/objc-gnu2next.h"
-#include "GNUstepBase/thr-mach.h"
+#include "thr-mach.h"
 
 /* Key structure for maintaining thread specific storage */
 static pthread_key_t _objc_thread_storage;


reply via email to

[Prev in Thread] Current Thread [Next in Thread]