This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


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

ObjC runtime update


Hi,

I've added the function

objc_condition_timedwait

to the Objective-C part of egcs. I testet it on RHLinux 6.0 and it works
fine.

I attached the diff file, so that you should have no problems patching
egcs.


Thanx in advance - Patrick Stein

diff -u objc/THREADS /Users/jolly/tmp/objc/THREADS
--- objc/THREADS	Thu Jul 15 17:25:59 1999
+++ /Users/jolly/tmp/objc/THREADS	Sat Dec  6 18:29:41 1997
@@ -334,17 +334,6 @@
 	The mutex is used to lock access to the shared data that make up the
 	"condition" predicate.
 	Return -1 if error otherwise return 0.
-
-objc_condition_timedwait( objc_condition_t condition, objc_mutex_t mutex, 
-				const struct timespec *abstime), int
-	Wait on the condition like objc_condition_wait() does, but it also bounds
-	the duration of the wait. If cond has not been signaled within the amount
-	of time specified by abstime, the mutex mutex is re-acquired and retuns that
-	the condition was not met.
-	Return  ETIMEDOUT the condition variable was not signaled until the timeout
-			  specified by abstime.
-	Return	0	  condition variable was signaled within the time.
-	Return  errno     from native function otherwise.
 	
 objc_condition_broadcast(objc_condition_t condition), int
 	Wake up all threads waiting on this condition. It is recommended that 
diff -u objc/thr-posix.c /Users/jolly/tmp/objc/thr-posix.c
--- objc/thr-posix.c	Tue Jul 13 18:36:15 1999
+++ /Users/jolly/tmp/objc/thr-posix.c	Sat Dec  6 18:30:07 1997
@@ -25,7 +25,6 @@
    however invalidate any other reasons why the executable file might be
    covered by the GNU General Public License.  */
 
-#include <errno.h>
 #include <objc/thr.h>
 #include "runtime.h"
 #include <pthread.h>
@@ -211,15 +210,6 @@
 {
   return pthread_cond_wait((pthread_cond_t *)condition->backend,
 			   (pthread_mutex_t *)mutex->backend);
-}
-
-/* Wait on the condition till an enddate */
-int
-__objc_condition_timedwait(objc_condition_t condition, objc_mutex_t mutex,const struct timespec *timeout)
-{
-	return pthread_cond_timedwait((pthread_cond_t *)condition->backend,
-					(pthread_mutex_t *)mutex->backend,
-					(const struct timespec *)timeout);
 }
 
 /* Wake up all threads waiting on this condition. */
diff -u objc/thr-single.c /Users/jolly/tmp/objc/thr-single.c
--- objc/thr-single.c	Wed Jul  7 14:57:24 1999
+++ /Users/jolly/tmp/objc/thr-single.c	Mon Aug 11 17:58:11 1997
@@ -175,13 +175,6 @@
   return 0;
 }
 
-/* Wait on the condition till an enddate */
-int
-__objc_condition_timedwait(objc_condition_t condition, objc_mutex_t mutex, struct timespec *abstime)
-{
-  return 0;
-}
-
 /* Wake up all threads waiting on this condition. */
 int
 __objc_condition_broadcast(objc_condition_t condition)
diff -u objc/thr.c /Users/jolly/tmp/objc/thr.c
--- objc/thr.c	Fri Jul  9 10:53:15 1999
+++ /Users/jolly/tmp/objc/thr.c	Mon Aug 11 17:58:11 1997
@@ -1,8 +1,7 @@
 /* GNU Objective C Runtime Thread Interface
    Copyright (C) 1996, 1997 Free Software Foundation, Inc.
    Contributed by Galen C. Hunt (gchunt@cs.rochester.edu)
-   Added condition_timed_wait by Patrick Stein <jolly@jinx.de>
-   
+
 This file is part of GNU CC.
 
 GNU CC is free software; you can redistribute it and/or modify it under the
@@ -498,39 +497,6 @@
   mutex->depth = 1;
 
   return 0;
-}
-
-int
-objc_condition_timedwait(objc_condition_t condition, objc_mutex_t mutex,const struct timespec *timeout)
-{
-  objc_thread_t thread_id;
-  int value;
-
-  /* Valid arguments? */
-  if (!mutex || !condition)
-    return -1;
-
-  /* Make sure we are owner of mutex */
-  thread_id = objc_thread_id();
-  if (mutex->owner != thread_id)
-    return -1;
-
-  /* Cannot be locked more than once */
-  if (mutex->depth > 1)
-    return -1;
-
-  /* Virtually unlock the mutex */
-  mutex->depth = 0;
-  mutex->owner = (objc_thread_t)NULL;
-
-  /* Call the backend to wait */
-  value = __objc_condition_timedwait(condition, mutex, timeout);
-
-  /* Make ourselves owner of the mutex */
-  mutex->owner = thread_id;
-  mutex->depth = 1;
-
-  return value;
 }
 
 /*
diff -u objc/thr.h /Users/jolly/tmp/objc/thr.h
--- objc/thr.h	Thu Jul 15 17:21:37 1999
+++ /Users/jolly/tmp/objc/thr.h	Mon Aug 11 17:58:12 1997
@@ -1,7 +1,6 @@
 /* Thread and mutex controls for Objective C.
    Copyright (C) 1996, 1997 Free Software Foundation, Inc.
    Contributed by Galen C. Hunt (gchunt@cs.rochester.edu)
-   Added condition_timed_wait by Patrick Stein <jolly@jinx.de>
 
 This file is part of GNU CC.
 
@@ -38,7 +37,7 @@
 
 #ifndef __thread_INCLUDE_GNU
 #define __thread_INCLUDE_GNU
-#include <time.h>			// this is for struct timespec *
+
 #include "objc/objc.h"
 
 /*************************************************************************
@@ -85,7 +84,6 @@
 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_timedwait(objc_condition_t condition, objc_mutex_t mutex,const struct timespec *timeout);
 int objc_condition_signal(objc_condition_t condition);
 int objc_condition_broadcast(objc_condition_t condition);
 
@@ -129,7 +127,6 @@
 int __objc_condition_allocate(objc_condition_t condition);
 int __objc_condition_deallocate(objc_condition_t condition);
 int __objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex);
-int __objc_condition_timedwait(objc_condition_t condition, objc_mutex_t mutex,const struct timespec *timeout);
 int __objc_condition_broadcast(objc_condition_t condition);
 int __objc_condition_signal(objc_condition_t condition);
 

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