[libjava PATCH] Conditionalize use of thread priority scheduling
Jason R Thorpe
thorpej@wasabisystems.com
Fri Feb 28 00:04:00 GMT 2003
Thread priority scheduling is an option in POSIX. The canonical way
to test for this feature is to include <unistd.h> and test for the
_POSIX_THREAD_PRIORITY_SCHEDULING macro. The libstdc++-v3 testsuite
already does this, in fact.
This fixes building libjava on i386-unknown-netbsdelf2.0 (threads
enabled). OK for mainline and 3.3 branch?
* posix-threads.cc: Include <unistd.h> if HAVE_UNISTD_H is defined.
(_Jv_ThreadSetPriority): Test for _POSIX_THREAD_PRIORITY_SCHEDULING.
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
-------------- next part --------------
Index: posix-threads.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/posix-threads.cc,v
retrieving revision 1.32
diff -c -r1.32 posix-threads.cc
*** posix-threads.cc 21 Mar 2002 00:26:44 -0000 1.32
--- posix-threads.cc 27 Feb 2003 23:58:14 -0000
***************
*** 24,29 ****
--- 24,32 ----
#include <signal.h>
#include <errno.h>
#include <limits.h>
+ #ifdef HAVE_UNISTD_H
+ #include <unistd.h> // To test for _POSIX_THREAD_PRIORITY_SCHEDULING
+ #endif
#include <gcj/cni.h>
#include <jvm.h>
***************
*** 318,323 ****
--- 321,327 ----
void
_Jv_ThreadSetPriority (_Jv_Thread_t *data, jint prio)
{
+ #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
if (data->flags & FLAG_START)
{
struct sched_param param;
***************
*** 325,330 ****
--- 329,335 ----
param.sched_priority = prio;
pthread_setschedparam (data->thread, SCHED_RR, ¶m);
}
+ #endif
}
void
More information about the Java-patches
mailing list