diff options
-rw-r--r-- | configure.in | 4 | ||||
-rw-r--r-- | include/my_pthread.h | 17 | ||||
-rw-r--r-- | mysys/my_pthread.c | 23 |
3 files changed, 33 insertions, 11 deletions
diff --git a/configure.in b/configure.in index 4719cdda44e..460c5e73abe 100644 --- a/configure.in +++ b/configure.in @@ -849,8 +849,8 @@ case $SYSTEM_TYPE in ;; *hpux10.20*) echo "Enabling workarounds for hpux 10.20" - CFLAGS="$CFLAGS -DHAVE_BROKEN_SNPRINTF -DSIGNALS_DONT_BREAK_READ -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHPUX -DSIGNAL_WITH_VIO_CLOSE -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT -DPTHREAD_MUTEX_TRYLOCK_INVERTED_RET_VAL" - CXXFLAGS="$CXXFLAGS -DHAVE_BROKEN_SNPRINTF -D_INCLUDE_LONGLONG -DSIGNALS_DONT_BREAK_READ -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHPUX -DSIGNAL_WITH_VIO_CLOSE -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT -DPTHREAD_MUTEX_TRYLOCK_INVERTED_RET_VAL" + CFLAGS="$CFLAGS -DHAVE_BROKEN_SNPRINTF -DSIGNALS_DONT_BREAK_READ -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHPUX -DSIGNAL_WITH_VIO_CLOSE -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT" + CXXFLAGS="$CXXFLAGS -DHAVE_BROKEN_SNPRINTF -D_INCLUDE_LONGLONG -DSIGNALS_DONT_BREAK_READ -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHPUX -DSIGNAL_WITH_VIO_CLOSE -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT" if test "$with_named_thread" = "no" then echo "Using --with-named-thread=-lpthread" diff --git a/include/my_pthread.h b/include/my_pthread.h index 004c908e08e..bfb33c38013 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -428,6 +428,16 @@ struct tm *localtime_r(const time_t *clock, struct tm *res); #endif /* defined(__WIN__) */ +#if defined(HPUX) && !defined(DONT_REMAP_PTHREAD_FUNCTIONS) +#undef pthread_cond_timedwait +#undef pthread_mutex_trylock +#define pthread_cond_timedwait(a,b,c) my_pthread_cond_timedwait((a),(b),(c)) +#define pthread_mutex_trylock(a) my_pthread_mutex_trylock((a)) +int my_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, + struct timespec *abstime); +int my_pthread_mutex_trylock(pthread_mutex_t *mutex); +#endif + /* safe_mutex adds checking to mutex for easier debugging */ typedef struct st_safe_mutex_t @@ -464,14 +474,7 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp, #define pthread_mutex_destroy(A) safe_mutex_destroy((A),__FILE__,__LINE__) #define pthread_cond_wait(A,B) safe_cond_wait((A),(B),__FILE__,__LINE__) #define pthread_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__) -#ifdef PTHREAD_MUTEX_TRYLOCK_INVERTED_RET_VAL - /* In HP-UX-10.20 and other old Posix 1003.4a Draft 4 implementations - pthread_mutex_trylock returns 1 on success, not 0 like - pthread_mutex_lock */ -#define pthread_mutex_trylock(A) (1 - pthread_mutex_lock(A)) -#else #define pthread_mutex_trylock(A) pthread_mutex_lock(A) -#endif #define pthread_mutex_t safe_mutex_t #endif /* SAFE_MUTEX */ diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c index 696b62f8b0e..e4e0eff95e6 100644 --- a/mysys/my_pthread.c +++ b/mysys/my_pthread.c @@ -409,7 +409,7 @@ int my_pthread_cond_init(pthread_cond_t *mp, const pthread_condattr_t *attr) /* Change functions on HP to work according to POSIX */ -#ifdef HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT +#if defined(HPUX) || defined(HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT) #undef pthread_cond_timedwait int my_pthread_cond_timedwait(pthread_cond_t *cond, @@ -426,7 +426,26 @@ int my_pthread_cond_timedwait(pthread_cond_t *cond, error= ETIMEDOUT; return error; } -#endif /* HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT */ +#endif + + +#ifdef HPUX +/* + In HP-UX-10.20 and other old Posix 1003.4a Draft 4 implementations + pthread_mutex_trylock returns 1 on success, not 0 like + pthread_mutex_lock +*/ + +int my_pthread_mutex_trylock(pthread_mutex_t *mutex) +{ + int error=pthread_mutex_trylock(mutex); + if (error == 1) /* Safety if the lib is fixed */ + return 0; /* Mutex was locked */ + if (error == -1) /* Safety if the lib is fixed */ + error=errno; + return error; +} +#endif /* Some help functions */ |