apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject svn commit: r596402 - in /apr/apr/trunk: build/apr_hints.m4 locks/unix/proc_mutex.c locks/unix/thread_cond.c locks/unix/thread_mutex.c locks/unix/thread_rwlock.c threadproc/unix/signals.c threadproc/unix/thread.c
Date Mon, 19 Nov 2007 19:19:22 GMT
Author: trawick
Date: Mon Nov 19 11:19:21 2007
New Revision: 596402

URL: http://svn.apache.org/viewvc?rev=596402&view=rev
Log:
Simplify handling of z/OS pthread API nuances.  Beyond the
simplification, it fixes a compile error in the call to
pthread_yield() on z/OS.

Submitted by: David Jones

I modified it slightly to use AC_DEFINE() as suggested
by jorton.

Modified:
    apr/apr/trunk/build/apr_hints.m4
    apr/apr/trunk/locks/unix/proc_mutex.c
    apr/apr/trunk/locks/unix/thread_cond.c
    apr/apr/trunk/locks/unix/thread_mutex.c
    apr/apr/trunk/locks/unix/thread_rwlock.c
    apr/apr/trunk/threadproc/unix/signals.c
    apr/apr/trunk/threadproc/unix/thread.c

Modified: apr/apr/trunk/build/apr_hints.m4
URL: http://svn.apache.org/viewvc/apr/apr/trunk/build/apr_hints.m4?rev=596402&r1=596401&r2=596402&view=diff
==============================================================================
--- apr/apr/trunk/build/apr_hints.m4 (original)
+++ apr/apr/trunk/build/apr_hints.m4 Mon Nov 19 11:19:21 2007
@@ -419,7 +419,8 @@
        APR_SETIFNULL(apr_sysvsem_is_global, [yes])
        APR_SETIFNULL(apr_gethostbyname_is_thread_safe, [yes])
        APR_SETIFNULL(apr_gethostbyaddr_is_thread_safe, [yes])
-       APR_ADDTO(CPPFLAGS, [-U_NO_PROTO -DPTHREAD_ATTR_SETDETACHSTATE_ARG2_ADDR -DPTHREAD_SETS_ERRNO
-DPTHREAD_DETACH_ARG1_ADDR -DSIGPROCMASK_SETS_THREAD_MASK -DTCP_NODELAY=1])
+       AC_DEFINE(HAVE_ZOS_PTHREADS, 1, [Define for z/OS pthread API nuances])
+       APR_ADDTO(CPPFLAGS, [-U_NO_PROTO -DSIGPROCMASK_SETS_THREAD_MASK -DTCP_NODELAY=1])
        ;;
     *-ibm-as400)
        APR_SETIFNULL(apr_lock_method, [USE_SYSVSEM_SERIALIZE])

Modified: apr/apr/trunk/locks/unix/proc_mutex.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/locks/unix/proc_mutex.c?rev=596402&r1=596401&r2=596402&view=diff
==============================================================================
--- apr/apr/trunk/locks/unix/proc_mutex.c (original)
+++ apr/apr/trunk/locks/unix/proc_mutex.c Mon Nov 19 11:19:21 2007
@@ -290,7 +290,7 @@
 
     if (mutex->curr_locked == 1) {
         if ((rv = pthread_mutex_unlock(mutex->pthread_interproc))) {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
             rv = errno;
 #endif
             return rv;
@@ -299,7 +299,7 @@
     /* curr_locked is set to -1 until the mutex has been created */
     if (mutex->curr_locked != -1) {
         if ((rv = pthread_mutex_destroy(mutex->pthread_interproc))) {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
             rv = errno;
 #endif
             return rv;
@@ -337,14 +337,14 @@
     new_mutex->curr_locked = -1; /* until the mutex has been created */
 
     if ((rv = pthread_mutexattr_init(&mattr))) {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
         rv = errno;
 #endif
         proc_mutex_proc_pthread_cleanup(new_mutex);
         return rv;
     }
     if ((rv = pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED))) {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
         rv = errno;
 #endif
         proc_mutex_proc_pthread_cleanup(new_mutex);
@@ -355,7 +355,7 @@
 #ifdef HAVE_PTHREAD_MUTEX_ROBUST
     if ((rv = pthread_mutexattr_setrobust_np(&mattr, 
                                                PTHREAD_MUTEX_ROBUST_NP))) {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
         rv = errno;
 #endif
         proc_mutex_proc_pthread_cleanup(new_mutex);
@@ -363,7 +363,7 @@
         return rv;
     }
     if ((rv = pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT))) {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
         rv = errno;
 #endif
         proc_mutex_proc_pthread_cleanup(new_mutex);
@@ -373,7 +373,7 @@
 #endif /* HAVE_PTHREAD_MUTEX_ROBUST */
 
     if ((rv = pthread_mutex_init(new_mutex->pthread_interproc, &mattr))) {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
         rv = errno;
 #endif
         proc_mutex_proc_pthread_cleanup(new_mutex);
@@ -384,7 +384,7 @@
     new_mutex->curr_locked = 0; /* mutex created now */
 
     if ((rv = pthread_mutexattr_destroy(&mattr))) {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
         rv = errno;
 #endif
         proc_mutex_proc_pthread_cleanup(new_mutex);
@@ -403,7 +403,7 @@
     apr_status_t rv;
 
     if ((rv = pthread_mutex_lock(mutex->pthread_interproc))) {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
         rv = errno;
 #endif
 #ifdef HAVE_PTHREAD_MUTEX_ROBUST
@@ -426,7 +426,7 @@
     apr_status_t rv;
  
     if ((rv = pthread_mutex_trylock(mutex->pthread_interproc))) {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS 
         rv = errno;
 #endif
         if (rv == EBUSY) {
@@ -454,7 +454,7 @@
 
     mutex->curr_locked = 0;
     if ((rv = pthread_mutex_unlock(mutex->pthread_interproc))) {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
         rv = errno;
 #endif
         return rv;

Modified: apr/apr/trunk/locks/unix/thread_cond.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/locks/unix/thread_cond.c?rev=596402&r1=596401&r2=596402&view=diff
==============================================================================
--- apr/apr/trunk/locks/unix/thread_cond.c (original)
+++ apr/apr/trunk/locks/unix/thread_cond.c Mon Nov 19 11:19:21 2007
@@ -27,7 +27,7 @@
     apr_status_t rv;
 
     rv = pthread_cond_destroy(&cond->cond);
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
     if (rv) {
         rv = errno;
     }
@@ -46,7 +46,7 @@
     new_cond->pool = pool;
 
     if ((rv = pthread_cond_init(&new_cond->cond, NULL))) {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
         rv = errno;
 #endif
         return rv;
@@ -66,7 +66,7 @@
     apr_status_t rv;
 
     rv = pthread_cond_wait(&cond->cond, &mutex->mutex);
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
     if (rv) {
         rv = errno;
     }
@@ -87,7 +87,7 @@
     abstime.tv_nsec = apr_time_usec(then) * 1000; /* nanoseconds */
 
     rv = pthread_cond_timedwait(&cond->cond, &mutex->mutex, &abstime);
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
     if (rv) {
         rv = errno;
     }
@@ -104,7 +104,7 @@
     apr_status_t rv;
 
     rv = pthread_cond_signal(&cond->cond);
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
     if (rv) {
         rv = errno;
     }
@@ -117,7 +117,7 @@
     apr_status_t rv;
 
     rv = pthread_cond_broadcast(&cond->cond);
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
     if (rv) {
         rv = errno;
     }

Modified: apr/apr/trunk/locks/unix/thread_mutex.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/locks/unix/thread_mutex.c?rev=596402&r1=596401&r2=596402&view=diff
==============================================================================
--- apr/apr/trunk/locks/unix/thread_mutex.c (original)
+++ apr/apr/trunk/locks/unix/thread_mutex.c Mon Nov 19 11:19:21 2007
@@ -26,7 +26,7 @@
     apr_status_t rv;
 
     rv = pthread_mutex_destroy(&mutex->mutex);
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
     if (rv) {
         rv = errno;
     }
@@ -71,7 +71,7 @@
         rv = pthread_mutex_init(&new_mutex->mutex, NULL);
 
     if (rv) {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
         rv = errno;
 #endif
         return rv;
@@ -90,7 +90,7 @@
     apr_status_t rv;
 
     rv = pthread_mutex_lock(&mutex->mutex);
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
     if (rv) {
         rv = errno;
     }
@@ -105,7 +105,7 @@
 
     rv = pthread_mutex_trylock(&mutex->mutex);
     if (rv) {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
         rv = errno;
 #endif
         return (rv == EBUSY) ? APR_EBUSY : rv;
@@ -119,7 +119,7 @@
     apr_status_t status;
 
     status = pthread_mutex_unlock(&mutex->mutex);
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
     if (status) {
         status = errno;
     }

Modified: apr/apr/trunk/locks/unix/thread_rwlock.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/locks/unix/thread_rwlock.c?rev=596402&r1=596401&r2=596402&view=diff
==============================================================================
--- apr/apr/trunk/locks/unix/thread_rwlock.c (original)
+++ apr/apr/trunk/locks/unix/thread_rwlock.c Mon Nov 19 11:19:21 2007
@@ -29,7 +29,7 @@
     apr_status_t stat;
 
     stat = pthread_rwlock_destroy(&rwlock->rwlock);
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
     if (stat) {
         stat = errno;
     }
@@ -47,7 +47,7 @@
     new_rwlock->pool = pool;
 
     if ((stat = pthread_rwlock_init(&new_rwlock->rwlock, NULL))) {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
         stat = errno;
 #endif
         return stat;
@@ -66,7 +66,7 @@
     apr_status_t stat;
 
     stat = pthread_rwlock_rdlock(&rwlock->rwlock);
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
     if (stat) {
         stat = errno;
     }
@@ -79,7 +79,7 @@
     apr_status_t stat;
 
     stat = pthread_rwlock_tryrdlock(&rwlock->rwlock);
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
     if (stat) {
         stat = errno;
     }
@@ -95,7 +95,7 @@
     apr_status_t stat;
 
     stat = pthread_rwlock_wrlock(&rwlock->rwlock);
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
     if (stat) {
         stat = errno;
     }
@@ -108,7 +108,7 @@
     apr_status_t stat;
 
     stat = pthread_rwlock_trywrlock(&rwlock->rwlock);
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
     if (stat) {
         stat = errno;
     }
@@ -124,7 +124,7 @@
     apr_status_t stat;
 
     stat = pthread_rwlock_unlock(&rwlock->rwlock);
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
     if (stat) {
         stat = errno;
     }

Modified: apr/apr/trunk/threadproc/unix/signals.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/threadproc/unix/signals.c?rev=596402&r1=596401&r2=596402&view=diff
==============================================================================
--- apr/apr/trunk/threadproc/unix/signals.c (original)
+++ apr/apr/trunk/threadproc/unix/signals.c Mon Nov 19 11:19:21 2007
@@ -422,7 +422,7 @@
     }
 #else
     if ((rv = pthread_sigmask(SIG_SETMASK, &sig_mask, NULL)) != 0) {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
         rv = errno;
 #endif
     }
@@ -448,7 +448,7 @@
     }
 #else
     if ((rv = pthread_sigmask(SIG_BLOCK, &sig_mask, NULL)) != 0) {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
         rv = errno;
 #endif
     }
@@ -475,7 +475,7 @@
     }
 #else
     if ((rv = pthread_sigmask(SIG_UNBLOCK, &sig_mask, NULL)) != 0) {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
         rv = errno;
 #endif
     }

Modified: apr/apr/trunk/threadproc/unix/thread.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/threadproc/unix/thread.c?rev=596402&r1=596401&r2=596402&view=diff
==============================================================================
--- apr/apr/trunk/threadproc/unix/thread.c (original)
+++ apr/apr/trunk/threadproc/unix/thread.c Mon Nov 19 11:19:21 2007
@@ -29,7 +29,7 @@
     apr_status_t rv;
 
     rv = pthread_attr_destroy(&attr->attr);
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
     if (rv) {
         rv = errno;
     }
@@ -51,7 +51,7 @@
                                   apr_pool_cleanup_null);
         return APR_SUCCESS;
     }
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
     stat = errno;
 #endif
 
@@ -68,7 +68,7 @@
                                                     apr_int32_t on)
 {
     apr_status_t stat;
-#ifdef PTHREAD_ATTR_SETDETACHSTATE_ARG2_ADDR
+#ifdef HAVE_ZOS_PTHREADS
     int arg = DETACH_ARG(on);
 
     if ((stat = pthread_attr_setdetachstate(&attr->attr, &arg)) == 0) {
@@ -79,7 +79,7 @@
         return APR_SUCCESS;
     }
     else {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
         stat = errno;
 #endif
 
@@ -110,7 +110,7 @@
     if (stat == 0) {
         return APR_SUCCESS;
     }
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
     stat = errno;
 #endif
 
@@ -127,7 +127,7 @@
     if (rv == 0) {
         return APR_SUCCESS;
     }
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
     rv = errno;
 #endif
     return rv;
@@ -180,7 +180,7 @@
         return APR_SUCCESS;
     }
     else {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
         stat = errno;
 #endif
 
@@ -219,7 +219,7 @@
         return APR_SUCCESS;
     }
     else {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
         stat = errno;
 #endif
 
@@ -231,7 +231,7 @@
 {
     apr_status_t stat;
 
-#ifdef PTHREAD_DETACH_ARG1_ADDR
+#ifdef HAVE_ZOS_PTHREADS
     if ((stat = pthread_detach(thd->td)) == 0) {
 #else
     if ((stat = pthread_detach(*thd->td)) == 0) {
@@ -240,7 +240,7 @@
         return APR_SUCCESS;
     }
     else {
-#ifdef PTHREAD_SETS_ERRNO
+#ifdef HAVE_ZOS_PTHREADS
         stat = errno;
 #endif
 
@@ -251,7 +251,11 @@
 APR_DECLARE(void) apr_thread_yield(void)
 {
 #ifdef HAVE_PTHREAD_YIELD
+#ifdef HAVE_ZOS_PTHREADS
+    pthread_yield(NULL);
+#else
     pthread_yield();
+#endif /* HAVE_ZOS_PTHREADS */
 #else
 #ifdef HAVE_SCHED_YIELD
     sched_yield();



Mime
View raw message