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]
Other format: [Raw text]

[PATCH] Fix objective-C use of _POSIX_THREAD_PRIORITY_SCHEDULING/_POSIX_PRIORITY_SCHEDULING


Reading <http://standards.ieee.org/reading/ieee/interp/1003-1c-95_int/pasc -1003.1c-29.html>,
I see that GCC is using _POSIX_THREAD_PRIORITY_SCHEDULING wrong and should also check for
_POSIX_PRIORITY_SCHEDULING. This patch fixes that by checking for both, it also fixes
compiling libobjc with threading support on OpenBSD 3.4.


OK? (I think this outside of my area but it is only used when _LIBOBJC is defined)

Thanks,
Andrew Pinski

ChangeLog:
	* gthr-posix.h: Check for _POSIX_PRIORITY_SCHEDULING
	when checking for _POSIX_THREAD_PRIORITY_SCHEDULING.
	Remove comment about not checking for
	_POSIX_PRIORITY_SCHEDULING.
	* gthr-posix.c: Likewise.


Patch: Index: gthr-posix.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/gthr-posix.c,v retrieving revision 2.1 diff -u -p -r2.1 gthr-posix.c --- gthr-posix.c 31 Jul 2003 12:01:05 -0000 2.1 +++ gthr-posix.c 11 Apr 2004 18:21:48 -0000 @@ -147,7 +147,7 @@ pthread_self (void) { return (pthread_t) 0; } - +#ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING int sched_get_priority_max (int policy ATTRIBUTE_UNUSED) @@ -161,6 +161,7 @@ sched_get_priority_min (int policy ATTRI return 0; } #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ +#endif /* _POSIX_PRIORITY_SCHEDULING */

 int
 sched_yield (void)
Index: gthr-posix.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gthr-posix.h,v
retrieving revision 1.27
diff -u -p -r1.27 gthr-posix.h
--- gthr-posix.h	31 Jul 2003 12:01:05 -0000	1.27
+++ gthr-posix.h	11 Apr 2004 18:21:48 -0000
@@ -74,12 +74,12 @@ typedef pthread_mutex_t __gthread_mutex_
 #pragma weak pthread_mutex_init
 #pragma weak pthread_mutex_destroy
 #pragma weak pthread_self
-/* These really should be protected by _POSIX_PRIORITY_SCHEDULING, but
-   we use them inside a _POSIX_THREAD_PRIORITY_SCHEDULING block.  */
+#ifdef _POSIX_PRIORITY_SCHEDULING
 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
 #pragma weak sched_get_priority_max
 #pragma weak sched_get_priority_min
 #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
+#endif /* _POSIX_PRIORITY_SCHEDULING */
 #pragma weak sched_yield
 #pragma weak pthread_attr_destroy
 #pragma weak pthread_attr_init
@@ -187,6 +187,7 @@ __gthread_objc_thread_set_priority (int
     return -1;
   else
     {
+#ifdef _POSIX_PRIORITY_SCHEDULING
 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
       pthread_t thread_id = pthread_self ();
       int policy;
@@ -216,6 +217,7 @@ __gthread_objc_thread_set_priority (int
 	    return 0;
 	}
 #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
+#endif /* _POSIX_PRIORITY_SCHEDULING */
       return -1;
     }
 }
@@ -224,6 +226,7 @@ __gthread_objc_thread_set_priority (int
 static inline int
 __gthread_objc_thread_get_priority (void)
 {
+#ifdef _POSIX_PRIORITY_SCHEDULING
 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
   if (__gthread_active_p ())
     {
@@ -237,6 +240,7 @@ __gthread_objc_thread_get_priority (void
     }
   else
 #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
+#endif /* _POSIX_PRIORITY_SCHEDULING */
     return OBJC_THREAD_INTERACTIVE_PRIORITY;
 }

Attachment: fix_threading.txt
Description: Text document


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