From patchwork Tue Jun 2 07:04:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: DJ Delorie X-Patchwork-Id: 479307 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 366B31412E3 for ; Tue, 2 Jun 2015 17:04:46 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=DFWgnq3m; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :message-id:from:to:subject; q=dns; s=default; b=PybEDrBL3PmYQJ9 kkW9r+2oU9IKztaaFhDyjFHwDNBl9/LmQ50wi9wYLGrRLnRyukxAUZrbvo/0h0sU pZ93QmbiMMrmY+3aNvgYiu5St8SHe8nDVz21WaO6NqSmE//aMbnDYPPtv5bH1BQI GEwbG84Ao+fOKCBVrjIJcfDGbSWE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :message-id:from:to:subject; s=default; bh=B/D1+3P86ofKzBmgjM8Gt 8OppGg=; b=DFWgnq3muthSTg3DXile4kYcq0AA3oid3LfQFCfouIlaej2H+UGIa 6EI83kgiLjecmRDuQW/wEO8BMFIgB9otGtJz3OnYWZdLnQqayKgvoLQxM30kuZIi Y2EoB292l3Dh+tjePma/CU969XR5L4IyqZPxsdYRTYIxsQjbCSz/Kk= Received: (qmail 107874 invoked by alias); 2 Jun 2015 07:04:38 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 107863 invoked by uid 89); 2 Jun 2015 07:04:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 02 Jun 2015 07:04:36 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 3F2455A098 for ; Tue, 2 Jun 2015 07:04:35 +0000 (UTC) Received: from greed.delorie.com (ovpn-113-25.phx2.redhat.com [10.3.113.25]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5274Y1e007411 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 2 Jun 2015 03:04:34 -0400 Received: from greed.delorie.com (greed.delorie.com [127.0.0.1]) by greed.delorie.com (8.14.4/8.14.4) with ESMTP id t5274XQh032371; Tue, 2 Jun 2015 03:04:33 -0400 Received: (from dj@localhost) by greed.delorie.com (8.14.4/8.14.4/Submit) id t5274Wa4032369; Tue, 2 Jun 2015 03:04:32 -0400 Date: Tue, 2 Jun 2015 03:04:32 -0400 Message-Id: <201506020704.t5274Wa4032369@greed.delorie.com> From: DJ Delorie To: gcc-patches@gcc.gnu.org Subject: update gthr-tpf.h X-IsSubscribed: yes This patch updates gthr-tpf.h to the current gthr.h API and TPF API. Ok? * gthr-tpf.h (__GTHREADS_CXX0X): Define. (__gthread_t): Define. (__gthread_cond_t): Define. (__gthread_time_t): Define. (__GTHREAD_HAS_COND): Define. (__GTHREAD_COND_INIT): Define. (__gthread_active_p): Check __tpf_pthread_active(). (__gthread_mutex_lock): Remove unneeded conditional. (__gthread_mutex_trylock): Likewise. (__gthread_recursive_mutex_lock): Likewise. (__gthread_recursive_mutex_trylock): Likewise. (__gthread_recursive_mutex_unlock): Likewise. (__gthread_recursive_mutex_init_function): Likewise. (__gthread_join): New. (__gthread_detach): New. (__gthread_equal): New. (__gthread_self): New. (__gthread_yield): New. (__gthread_mutex_timedlock): New. (__gthread_recursive_mutex_timedlock): New. (__gthread_cond_broadcast): New. (__gthread_cond_signal): New. (__gthread_cond_wait): New. (__gthread_cond_wait_recursive): New. (__gthread_cond_timedwait): New. (__gthread_cond_timedwait_recursive): New. (__gthread_cond_destroy): New. Index: libgcc/config/s390/gthr-tpf.h =================================================================== --- libgcc/config/s390/gthr-tpf.h (revision 224011) +++ libgcc/config/s390/gthr-tpf.h (working copy) @@ -35,6 +35,8 @@ Easy, since the interface is just one-to-one mapping. */ #define __GTHREADS 1 +/* To enable the c++0x thread library. */ +#define __GTHREADS_CXX0X 1 /* Some implementations of require this to be defined. */ #ifndef _REENTRANT @@ -44,11 +46,17 @@ #include #include +typedef pthread_t __gthread_t; typedef pthread_key_t __gthread_key_t; typedef pthread_once_t __gthread_once_t; typedef pthread_mutex_t __gthread_mutex_t; typedef pthread_mutex_t __gthread_recursive_mutex_t; +typedef pthread_cond_t __gthread_cond_t; +typedef struct timespec __gthread_time_t; +#define __GTHREAD_HAS_COND 1 +#define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER + #if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER) #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER #elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) @@ -80,9 +88,15 @@ __gthrw(pthread_getspecific) __gthrw(pthread_setspecific) __gthrw(pthread_create) +__gthrw(pthread_join) +__gthrw(pthread_detach) +__gthrw(pthread_equal) +__gthrw(pthread_self) +__gthrw(sched_yield) __gthrw(pthread_mutex_lock) __gthrw(pthread_mutex_trylock) +__gthrw(pthread_mutex_timedlock) __gthrw(pthread_mutex_unlock) __gthrw(pthread_mutexattr_init) __gthrw(pthread_mutexattr_settype) @@ -90,31 +104,81 @@ __gthrw(pthread_mutex_init) __gthrw(pthread_mutex_destroy) +__gthrw(pthread_cond_broadcast) +__gthrw(pthread_cond_signal) +__gthrw(pthread_cond_wait) +__gthrw(pthread_cond_timedwait) +__gthrw(pthread_cond_destroy) + + static inline int __gthread_active_p (void) { - return 1; + return __tpf_pthread_active (); } static inline int -__gthread_once (__gthread_once_t *__once, void (*__func) (void)) +__gthread_create (__gthread_t *__threadid, void *(*__func) (void*), + void *__args) { + return __gthrw_(pthread_create) (__threadid, NULL, __func, __args); +} + +static inline int +__gthread_join (__gthread_t __threadid, void **__value_ptr) +{ if (__tpf_pthread_active ()) - return __gthrw_(pthread_once) (__once, __func); + return __gthrw_(pthread_join) (__threadid, __value_ptr); else return -1; } static inline int -__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) +__gthread_detach (__gthread_t __threadid) { if (__tpf_pthread_active ()) - return __gthrw_(pthread_key_create) (__key, __dtor); + return __gthrw_(pthread_detach) (__threadid); else return -1; } static inline int +__gthread_equal (__gthread_t __t1, __gthread_t __t2) +{ + if (__tpf_pthread_active ()) + return __gthrw_(pthread_equal) (__t1, __t2); + else + return -1; +} + +static inline __gthread_t +__gthread_self (void) +{ + return __gthrw_(pthread_self) (); +} + +static inline int +__gthread_yield (void) +{ + return __gthrw_(sched_yield) (); +} + +static inline int +__gthread_once (__gthread_once_t *__once, void (*__func) (void)) +{ + if (__tpf_pthread_active ()) + return __gthrw_(pthread_once) (__once, __func); + else + return -1; +} + +static inline int +__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) +{ + return __gthrw_(pthread_key_create) (__key, __dtor); +} + +static inline int __gthread_key_delete (__gthread_key_t __key) { if (__tpf_pthread_active ()) @@ -153,22 +217,23 @@ static inline int __gthread_mutex_lock (__gthread_mutex_t *__mutex) { - if (__tpf_pthread_active ()) - return __gthrw_(pthread_mutex_lock) (__mutex); - else - return 0; + return __gthrw_(pthread_mutex_lock) (__mutex); } static inline int __gthread_mutex_trylock (__gthread_mutex_t *__mutex) { - if (__tpf_pthread_active ()) - return __gthrw_(pthread_mutex_trylock) (__mutex); - else - return 0; + return __gthrw_(pthread_mutex_trylock) (__mutex); } static inline int +__gthread_mutex_timedlock (__gthread_mutex_t *__mutex, + const __gthread_time_t *__abs_timeout) +{ + return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout); +} + +static inline int __gthread_mutex_unlock (__gthread_mutex_t *__mutex) { if (__tpf_pthread_active ()) @@ -180,49 +245,43 @@ static inline int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) { - if (__tpf_pthread_active ()) - return __gthread_mutex_lock (__mutex); - else - return 0; + return __gthread_mutex_lock (__mutex); } static inline int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) { - if (__tpf_pthread_active ()) - return __gthread_mutex_trylock (__mutex); - else - return 0; + return __gthread_mutex_trylock (__mutex); } static inline int +__gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex, + const __gthread_time_t *__abs_timeout) +{ + return __gthread_mutex_timedlock (__mutex, __abs_timeout); +} + +static inline int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) { - if (__tpf_pthread_active ()) - return __gthread_mutex_unlock (__mutex); - else - return 0; + return __gthread_mutex_unlock (__mutex); } static inline int __gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) { - if (__tpf_pthread_active ()) - { - pthread_mutexattr_t __attr; - int __r; + pthread_mutexattr_t __attr; + int __r; - __r = __gthrw_(pthread_mutexattr_init) (&__attr); - if (!__r) - __r = __gthrw_(pthread_mutexattr_settype) (&__attr, - PTHREAD_MUTEX_RECURSIVE); - if (!__r) - __r = __gthrw_(pthread_mutex_init) (__mutex, &__attr); - if (!__r) - __r = __gthrw_(pthread_mutexattr_destroy) (&__attr); - return __r; - } - return 0; + __r = __gthrw_(pthread_mutexattr_init) (&__attr); + if (!__r) + __r = __gthrw_(pthread_mutexattr_settype) (&__attr, + PTHREAD_MUTEX_RECURSIVE); + if (!__r) + __r = __gthrw_(pthread_mutex_init) (__mutex, &__attr); + if (!__r) + __r = __gthrw_(pthread_mutexattr_destroy) (&__attr); + return __r; } static inline int @@ -231,4 +290,53 @@ return __gthread_mutex_destroy (__mutex); } +static inline int +__gthread_cond_broadcast (__gthread_cond_t *__cond) +{ + return __gthrw_(pthread_cond_broadcast) (__cond); +} + +static inline int +__gthread_cond_signal (__gthread_cond_t *__cond) +{ + return __gthrw_(pthread_cond_signal) (__cond); +} + +static inline int +__gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex) +{ + return __gthrw_(pthread_cond_wait) (__cond, __mutex); +} + +static inline int +__gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex, + const __gthread_time_t *__abs_timeout) +{ + return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout); +} + +static inline int +__gthread_cond_wait_recursive (__gthread_cond_t *__cond, + __gthread_recursive_mutex_t *__mutex) +{ + return __gthread_cond_wait (__cond, __mutex); +} + +static inline int +__gthread_cond_timedwait_recursive (__gthread_cond_t *__cond, + __gthread_recursive_mutex_t *__mutex, + const __gthread_time_t *__abs_timeout) +{ + return __gthread_cond_timedwait (__cond, __mutex, __abs_timeout); +} + +static inline int +__gthread_cond_destroy (__gthread_cond_t* __cond) +{ + if (__tpf_pthread_active ()) + return __gthrw_(pthread_cond_destroy) (__cond); + else + return 0; +} + #endif /* ! GCC_GTHR_TPF_H */