[libstdc++-v3 PATCH/RFA] Protect use of optional POSIX features
Jason R Thorpe
thorpej@wasabisystems.com
Mon Oct 28 15:46:00 GMT 2002
In a similar vein to my recent patch to gcc/gthr-posix.h, this protects
use of features from the optional Thread Priority Scheduling group in
the "pthread5" test.
Since this question came up wrt. gthr-posix.h, does the inclusion of
<unistd.h> need to be protected? POSIX systems must provide this header
for feature testing, and since pthreads is a POSIX feature, seems reasonable
to assume that the header is there.
OK for mainline?
* testsuite/thread/pthread5.cc: Include <unistd.h>.
(main): Only use pthread_attr_setscope if
_POSIX_THREAD_PRIORITY_SCHEDULING is defined.
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
-------------- next part --------------
Index: pthread5.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/thread/pthread5.cc,v
retrieving revision 1.2
diff -c -r1.2 pthread5.cc
*** pthread5.cc 25 Jan 2002 16:05:48 -0000 1.2
--- pthread5.cc 28 Oct 2002 05:45:10 -0000
***************
*** 32,37 ****
--- 32,39 ----
// configured for the port, then it is picked up free from STL headers.
#if __GTHREADS
+ #include <unistd.h> // To test for _POSIX_THREAD_PRIORITY_SCHEDULING
+
using namespace std;
#define NTHREADS 8
***************
*** 97,103 ****
--- 99,107 ----
pthread_attr_t tattr;
int ret = pthread_attr_init (&tattr);
+ #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
ret = pthread_attr_setscope(&tattr, PTHREAD_SCOPE_SYSTEM);
+ #endif
for (worker = 0; worker < NTHREADS; worker++)
{
More information about the Libstdc++
mailing list