Changeset 11286

Show
Ignore:
Timestamp:
03/24/10 18:12:05 (4 years ago)
Author:
robert
Message:

Added a compile test for pthread_setaffinity_np to workaround problem with the FreeBSD pthread lib containing the function but the pthread.h header not containing it.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/OpenThreads/pthreads/CMakeLists.txt

    r9949 r11286  
    3030SET(CMAKE_REQUIRED_LIBRARIES_SAFE "${CMAKE_REQUIRED_LIBRARIES}") 
    3131SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 
     32 
    3233 
    3334CHECK_FUNCTION_EXISTS(pthread_yield HAVE_PTHREAD_YIELD) 
     
    6667CHECK_FUNCTION_EXISTS(pthread_setaffinity_np HAVE_PTHREAD_SETAFFINITY_NP) 
    6768IF(HAVE_PTHREAD_SETAFFINITY_NP) 
     69  # double check that pthread_setaffinity_np is available as FreeBSD header doesn't contain required function 
     70  CHECK_CXX_SOURCE_COMPILES(" 
     71        #include <pthread.h> 
     72        int main() { 
     73        cpu_set_t cpumask; 
     74        CPU_ZERO( &cpumask ); 
     75        CPU_SET( 0, &cpumask ); 
     76        pthread_setaffinity_np( pthread_self(), sizeof(cpumask), &cpumask); 
     77        return 0; 
     78        }" COMPILES_PTHREAD_SETAFFINITY_NP) 
     79 
     80    IF (NOT COMPILES_PTHREAD_SETAFFINITY_NP) 
     81        SET(HAVE_PTHREAD_SETAFFINITY_NP OFF) 
     82    ENDIF() 
     83ENDIF() 
     84 
     85IF(HAVE_PTHREAD_SETAFFINITY_NP) 
    6886  ADD_DEFINITIONS(-DHAVE_PTHREAD_SETAFFINITY_NP) 
    6987ELSE() 
    7088  CHECK_CXX_SOURCE_COMPILES(" 
    71 #include <sched.h> 
    72 int main() { 
    73   cpu_set_t cpumask; 
    74   sched_setaffinity( 0, sizeof(cpumask), &cpumask ); 
    75   return 0; 
    76 }" HAVE_THREE_PARAM_SCHED_SETAFFINITY) 
     89        #include <sched.h> 
     90        int main() { 
     91        cpu_set_t cpumask; 
     92        sched_setaffinity( 0, sizeof(cpumask), &cpumask ); 
     93        return 0; 
     94        }" HAVE_THREE_PARAM_SCHED_SETAFFINITY) 
    7795  IF(HAVE_THREE_PARAM_SCHED_SETAFFINITY) 
    7896    ADD_DEFINITIONS(-DHAVE_THREE_PARAM_SCHED_SETAFFINITY)