Changeset 21049

Show
Ignore:
Timestamp:
02/23/08 12:45:32 (6 months ago)
Author:
patrick
Message:

Test for unnamed POSIX semaphore support instead of tracking
ploatform-specific information in SemaphorePosix?.{cpp,h}.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • juggler/trunk/modules/vapor/configure.ac

    r21038 r21049  
    341341        AC_MSG_WARN(*** POSIX threads will not be used (no library found) ***) 
    342342    fi 
     343 
     344    DPP_LANG_SAVE 
     345    DPP_LANG_C 
     346 
     347    vprsave_CFLAGS="$CFLAGS" 
     348    vprsave_LIBS="$LIBS" 
     349 
     350    CFLAGS="$CFLAGS $PTHREAD_ARG" 
     351    LIBS="$LIBS $PTHREAD_LIB" 
     352 
     353    # If the code below compiles, links, and returns 0, then we can use 
     354    # unnamed POSIX semaphores. 
     355    AC_CACHE_CHECK([for unnamed POSIX semaphore support], 
     356                   [ac_cv_has_unnamed_posix_semaphores], 
     357                   [AC_RUN_IFELSE([ 
     358#include <semaphore.h> 
     359 
     360int main() 
     361{ 
     362   sem_t sema; 
     363   return sem_init(&sema, 0, 1); 
     364}], 
     365                        [ac_cv_has_unnamed_posix_semaphores='yes'], 
     366                        [ac_cv_has_unnamed_posix_semaphores='no'])] 
     367                  ) 
     368 
     369    if test "x$ac_cv_has_unnamed_posix_semaphores" = "xyes" ; then 
     370        AC_DEFINE(VPR_HAVE_UNNAMED_POSIX_SEMAPHORE, , 
     371                  [Define if unnamed POSIX semaphores are available.]) 
     372    fi 
     373 
     374    CFLAGS="$vprsave_CFLAGS" 
     375    LIBS="$vprsave_LIBS" 
     376 
     377    DPP_LANG_RESTORE 
    343378 
    344379    # Do not define _POSIX_C_SOURCE here because it will cause problems when 
  • juggler/trunk/modules/vapor/vpr/md/POSIX/Sync/SemaphorePosix.cpp

    r20974 r21049  
    4646#include <vpr/md/POSIX/Sync/SemaphorePosix.h> 
    4747 
    48 #if defined(VPR_OS_Darwin) && VPR_OS_RELEASE_MAJOR <= 9 
    49 #define VPR_USE_NAMED_SEMAPHORE 1 
    50 #endif 
    51  
    5248 
    5349namespace vpr 
     
    5652SemaphorePosix::SemaphorePosix(const int initialValue) 
    5753{ 
    58 #ifdef VPR_USE_NAMED_SEMAPHORE 
     54#if ! defined(VPR_HAVE_UNNAMED_POSIX_SEMAPHORE) 
    5955   // Use strdup(3) here so that mktemp(3) can modify the memory.  Trying 
    6056   // to modify a constant string would be bad. 
     
    104100{ 
    105101   // ---- Delete the semaphore --- // 
    106 #ifdef VPR_USE_NAMED_SEMAPHORE 
     102#if ! defined(VPR_HAVE_UNNAMED_POSIX_SEMAPHORE) 
    107103   const int result = sem_close(mSema); 
    108104   vprASSERT(result == 0); 
     
    120116void SemaphorePosix::reset(const int val) 
    121117{ 
    122 #ifdef VPR_USE_NAMED_SEMAPHORE 
     118#if ! defined(VPR_HAVE_UNNAMED_POSIX_SEMAPHORE) 
    123119   // First deallocate the current semaphore. 
    124120   const int result = sem_close(mSema); 
  • juggler/trunk/modules/vapor/vpr/md/POSIX/Sync/SemaphorePosix.h

    r20974 r21049  
    5757#include <vpr/Sync/DeadlockException.h> 
    5858 
    59 #if defined(VPR_OS_Darwin) && VPR_OS_RELEASE_MAJOR <= 9 
    60 #define VPR_USE_NAMED_SEMAPHORE 1 
    61 #endif 
    62  
    6359 
    6460namespace vpr 
     
    291287 
    292288protected: 
    293 #ifdef VPR_USE_NAMED_SEMAPHORE 
     289#if ! defined(VPR_HAVE_UNNAMED_POSIX_SEMAPHORE) 
    294290   char* mSemaFile; 
    295291#endif 
     
    299295} // End of vpr namespace 
    300296 
    301 #undef VPR_USE_NAMED_SEMAPHORE 
    302297 
    303298#endif  /* _VPR_SEMAPHORE_POSIX_H_ */