Browse Source

NetBSD missing functions workaround

master
Artyom Beilis 9 years ago
parent
commit
4778bcfff9
3 changed files with 28 additions and 1 deletions
  1. +11
    -0
      CMakeLists.txt
  2. +1
    -0
      config.cmake.h
  3. +16
    -1
      private/posix_util.h

+ 11
- 0
CMakeLists.txt View File

@@ -292,6 +292,17 @@ endif()


check_function_exists(canonicalize_file_name CPPCMS_HAVE_CANONICALIZE_FILE_NAME)
check_function_exists(pthread_mutexattr_setpshared CPPCMS_HAS_THREAD_PSHARED_LIBC)
if(NOT CPPCMS_HAS_THREAD_PSHARED_LIBC AND LIB_PTHREAD)
check_library_exists(${LIB_PTHREAD} pthread_mutexattr_setpshared "" CPPCMS_HAS_THREAD_PSHARED_PTHREAD)
endif()

if(CPPCMS_HAS_THREAD_PSHARED_LIBC OR CPPCMS_HAS_THREAD_PSHARED_PTHREAD)
set(CPPCMS_HAS_THREAD_PSHARED ON)
else()
set(CPPCMS_HAS_THREAD_PSHARED OFF)
endif()


add_definitions(-DCPPCMS_BOOST_ALL_NO_LIB)



+ 1
- 0
config.cmake.h View File

@@ -109,6 +109,7 @@
#cmakedefine CPPCMS_NO_PREFOK_CACHE
#cmakedefine CPPCMS_NO_GZIP
#cmakedefine CPPCMS_SQLITE_LINK_STATIC
#cmakedefine CPPCMS_HAS_THREAD_PSHARED


#endif

+ 16
- 1
private/posix_util.h View File

@@ -49,6 +49,7 @@ namespace impl {
pthread_mutex_init(m,0);
}
else {
#ifdef CPPCMS_HAS_THREAD_PSHARED
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
try {
@@ -64,6 +65,9 @@ namespace impl {
pthread_mutexattr_destroy(&attr);
throw;
}
#else
throw cppcms_error("Process shared mutex is not supported");
#endif
}
}

@@ -78,6 +82,7 @@ namespace impl {
pthread_rwlock_init(m,0);
}
else {
#ifdef CPPCMS_HAS_THREAD_PSHARED
pthread_rwlockattr_t attr;
pthread_rwlockattr_init(&attr);
try {
@@ -93,6 +98,9 @@ namespace impl {
pthread_rwlockattr_destroy(&attr);
throw;
}
#else
throw cppcms_error("Process shared mutex is not supported");
#endif
}
}

@@ -102,7 +110,7 @@ namespace impl {
}


#ifdef CPPCMS_HAS_THREAD_PSHARED
inline bool test_pthread_mutex_pshared_impl()
{
void *memory=mmap_anonymous(sizeof(pthread_mutex_t));
@@ -124,6 +132,13 @@ namespace impl {
static bool has = test_pthread_mutex_pshared_impl();
return has;
}
#else
inline bool test_pthread_mutex_pshared()
{
return false;
}

#endif


class mutex : public booster::noncopyable {


Loading…
Cancel
Save