From patchwork Tue Jan 14 18:52:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1222998 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108665-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=wyvJxd/e; dkim-atps=neutral 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 47y03f0pWyz9s29 for ; Wed, 15 Jan 2020 05:53:49 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=phye4PNNoxMTdpzL1I3JWBy7++obvLv7muA5xEfgx7OepJf/SrrCV 7m9ogQXXlAf+IAvgk8VLoVAVniyGY2S//WBAPnicJEFnf9nEnomFpPPZuWNC+Np6 Hq5gNp4m9AhpdGA1CnMGKkIMmM+4SnAjkoJk2unFSIjUP5Wbb+YVRI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=+69pL/Pj9lPTpeNYsrJNJqBadqg=; b=wyvJxd/egzYIjI1v52FSbuQjt970 xCJd1aBdAk4Ak9QgYfW/sQaMpGdus0TSn15sf+zBmu9PaJGTumtuJEAMWuniRLL6 mtMVfxmrNjUaxMR2/dFWAXDlyXeWZRtPVz2BwU3DGhdheLBLLYchZg2WW+qSNVwH uX/fFMib604H2SM= Received: (qmail 91936 invoked by alias); 14 Jan 2020 18:53:17 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 91808 invoked by uid 89); 14 Jan 2020 18:53:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: hera.aquilenet.fr From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault Subject: [PATCH 01/10] htl: Rename _pthread_mutex_init/destroy to __pthread_mutex_init/destroy Date: Tue, 14 Jan 2020 19:52:46 +0100 Message-Id: <20200114185255.25813-3-samuel.thibault@ens-lyon.org> In-Reply-To: <20200114185255.25813-1-samuel.thibault@ens-lyon.org> References: <20200114185255.25813-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 --- htl/Versions | 2 ++ htl/pt-initialize.c | 4 ++-- sysdeps/htl/pt-key.h | 2 +- sysdeps/htl/pt-mutex-destroy.c | 4 ++-- sysdeps/htl/pt-mutex-init.c | 4 ++-- sysdeps/htl/pthreadP.h | 5 +++-- sysdeps/mach/hurd/htl/pt-mutex-destroy.c | 4 ++-- sysdeps/mach/hurd/htl/pt-mutex-init.c | 6 +++--- sysdeps/mach/hurd/i386/libpthread.abilist | 2 -- 9 files changed, 17 insertions(+), 16 deletions(-) diff --git a/htl/Versions b/htl/Versions index 77f7335b9c..3ae4b5c17d 100644 --- a/htl/Versions +++ b/htl/Versions @@ -155,6 +155,8 @@ libpthread { __pthread_setspecific; __pthread_getattr_np; __pthread_attr_getstack; + __pthread_mutex_init; + __pthread_mutex_destroy; __pthread_mutex_timedlock; } } diff --git a/htl/pt-initialize.c b/htl/pt-initialize.c index d5a64f7cd9..89ed742422 100644 --- a/htl/pt-initialize.c +++ b/htl/pt-initialize.c @@ -51,8 +51,8 @@ static const struct pthread_functions pthread_functions = { .ptr___pthread_exit = __pthread_exit, .ptr_pthread_getschedparam = __pthread_getschedparam, .ptr_pthread_setschedparam = __pthread_setschedparam, - .ptr_pthread_mutex_destroy = _pthread_mutex_destroy, - .ptr_pthread_mutex_init = _pthread_mutex_init, + .ptr_pthread_mutex_destroy = __pthread_mutex_destroy, + .ptr_pthread_mutex_init = __pthread_mutex_init, .ptr_pthread_mutex_lock = __pthread_mutex_lock, .ptr_pthread_mutex_trylock = __pthread_mutex_trylock, .ptr_pthread_mutex_unlock = __pthread_mutex_unlock, diff --git a/sysdeps/htl/pt-key.h b/sysdeps/htl/pt-key.h index bfaa19900a..b547e8ad29 100644 --- a/sysdeps/htl/pt-key.h +++ b/sysdeps/htl/pt-key.h @@ -66,7 +66,7 @@ __pthread_key_lock_ready (void) err = __pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); assert_perror (err); - err = _pthread_mutex_init (&__pthread_key_lock, &attr); + err = __pthread_mutex_init (&__pthread_key_lock, &attr); assert_perror (err); err = __pthread_mutexattr_destroy (&attr); diff --git a/sysdeps/htl/pt-mutex-destroy.c b/sysdeps/htl/pt-mutex-destroy.c index 3824e62dd4..796fc11b8d 100644 --- a/sysdeps/htl/pt-mutex-destroy.c +++ b/sysdeps/htl/pt-mutex-destroy.c @@ -23,7 +23,7 @@ #include int -_pthread_mutex_destroy (pthread_mutex_t *mutex) +__pthread_mutex_destroy (pthread_mutex_t *mutex) { if (mutex->__attr == __PTHREAD_ERRORCHECK_MUTEXATTR || mutex->__attr == __PTHREAD_RECURSIVE_MUTEXATTR) @@ -35,4 +35,4 @@ _pthread_mutex_destroy (pthread_mutex_t *mutex) return 0; } -strong_alias (_pthread_mutex_destroy, pthread_mutex_destroy); +strong_alias (__pthread_mutex_destroy, pthread_mutex_destroy); diff --git a/sysdeps/htl/pt-mutex-init.c b/sysdeps/htl/pt-mutex-init.c index c59bd8a3f5..77f041352e 100644 --- a/sysdeps/htl/pt-mutex-init.c +++ b/sysdeps/htl/pt-mutex-init.c @@ -24,7 +24,7 @@ #include int -_pthread_mutex_init (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) +__pthread_mutex_init (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) { *mutex = (pthread_mutex_t) __PTHREAD_MUTEX_INITIALIZER; @@ -47,4 +47,4 @@ _pthread_mutex_init (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) return 0; } -strong_alias (_pthread_mutex_init, pthread_mutex_init); +strong_alias (__pthread_mutex_init, pthread_mutex_init); diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h index affe7cdf53..c6ddf76fd4 100644 --- a/sysdeps/htl/pthreadP.h +++ b/sysdeps/htl/pthreadP.h @@ -27,7 +27,8 @@ extern pthread_t __pthread_self (void); extern int __pthread_kill (pthread_t threadid, int signo); extern struct __pthread **__pthread_threads; -extern int _pthread_mutex_init (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr); +extern int __pthread_mutex_init (pthread_mutex_t *__mutex, const pthread_mutexattr_t *__attr); +extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex); extern int __pthread_mutex_lock (pthread_mutex_t *__mutex); extern int __pthread_mutex_timedlock (pthread_mutex_t *__mutex, const struct timespec *__abstime); @@ -73,7 +74,7 @@ struct __pthread_cancelation_handler **___pthread_get_cleanup_stack (void) attri hidden_proto (__pthread_key_create) hidden_proto (__pthread_getspecific) hidden_proto (__pthread_setspecific) -hidden_proto (_pthread_mutex_init) +hidden_proto (__pthread_mutex_init) #endif #define ASSERT_TYPE_SIZE(type, size) \ diff --git a/sysdeps/mach/hurd/htl/pt-mutex-destroy.c b/sysdeps/mach/hurd/htl/pt-mutex-destroy.c index afab03234e..a8a0adc03f 100644 --- a/sysdeps/mach/hurd/htl/pt-mutex-destroy.c +++ b/sysdeps/mach/hurd/htl/pt-mutex-destroy.c @@ -24,7 +24,7 @@ #include int -_pthread_mutex_destroy (pthread_mutex_t *mtxp) +__pthread_mutex_destroy (pthread_mutex_t *mtxp) { atomic_read_barrier (); if (*(volatile unsigned int *) &mtxp->__lock != 0) @@ -34,4 +34,4 @@ _pthread_mutex_destroy (pthread_mutex_t *mtxp) return 0; } -strong_alias (_pthread_mutex_destroy, pthread_mutex_destroy) +strong_alias (__pthread_mutex_destroy, pthread_mutex_destroy) diff --git a/sysdeps/mach/hurd/htl/pt-mutex-init.c b/sysdeps/mach/hurd/htl/pt-mutex-init.c index 6b804116a5..7a2cc462f3 100644 --- a/sysdeps/mach/hurd/htl/pt-mutex-init.c +++ b/sysdeps/mach/hurd/htl/pt-mutex-init.c @@ -32,7 +32,7 @@ static const pthread_mutexattr_t dfl_attr = { }; int -_pthread_mutex_init (pthread_mutex_t *mtxp, const pthread_mutexattr_t *attrp) +__pthread_mutex_init (pthread_mutex_t *mtxp, const pthread_mutexattr_t *attrp) { ASSERT_TYPE_SIZE (pthread_mutex_t, __SIZEOF_PTHREAD_MUTEX_T); @@ -55,5 +55,5 @@ _pthread_mutex_init (pthread_mutex_t *mtxp, const pthread_mutexattr_t *attrp) return 0; } -strong_alias (_pthread_mutex_init, pthread_mutex_init) -hidden_def (_pthread_mutex_init) +strong_alias (__pthread_mutex_init, pthread_mutex_init) +hidden_def (__pthread_mutex_init) diff --git a/sysdeps/mach/hurd/i386/libpthread.abilist b/sysdeps/mach/hurd/i386/libpthread.abilist index 0ede90859c..cda8755960 100644 --- a/sysdeps/mach/hurd/i386/libpthread.abilist +++ b/sysdeps/mach/hurd/i386/libpthread.abilist @@ -14,8 +14,6 @@ GLIBC_2.12 _cthread_init_routine D 0x4 GLIBC_2.12 _cthreads_flockfile F GLIBC_2.12 _cthreads_ftrylockfile F GLIBC_2.12 _cthreads_funlockfile F -GLIBC_2.12 _pthread_mutex_destroy F -GLIBC_2.12 _pthread_mutex_init F GLIBC_2.12 _pthread_mutex_lock F GLIBC_2.12 _pthread_mutex_trylock F GLIBC_2.12 _pthread_mutex_unlock F From patchwork Tue Jan 14 18:52:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1222996 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108663-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=Fpwe3tU4; dkim-atps=neutral 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 47y03H6GJRz9s29 for ; Wed, 15 Jan 2020 05:53:31 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=TOJ9zj278UODi++B5f/phC6lTges8LV6e0M8iNQ/Q+QTTRPdOtlbZ ma+2NsZ1xoEkxXjgZUodrk8vU5G9YQ5W/z251x8J4obZtpc8SLLKg4wAc7uq3qrW iPc22qTz8AyhGK8mMxs/Yf8Lfg5UHPMQgJqM3fWvi6PKOQPGiarg6k= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=eQ2YKN/dByFGDUs8Lk6/u55uM9Q=; b=Fpwe3tU4vRloQF8Tt5ZPfnxPhTdg Op5qTeoj36bIskEOKkZlQCbe6pyvRedobkiq2UtUZDNQDDOJobnOs/Ay0Lu0DlfD xPkQMl5mnQ3hCp6pMBfNi9Cvgwl1IM0CBoyVBBH4j4Mt+ZF7h2f4G2EJYCnvHhzL twqrjYPbN2KqMHU= Received: (qmail 91842 invoked by alias); 14 Jan 2020 18:53:17 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 91806 invoked by uid 89); 14 Jan 2020 18:53:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: hera.aquilenet.fr From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault Subject: [PATCH 02/10] htl: Add missing internal functions declarations Date: Tue, 14 Jan 2020 19:52:47 +0100 Message-Id: <20200114185255.25813-4-samuel.thibault@ens-lyon.org> In-Reply-To: <20200114185255.25813-1-samuel.thibault@ens-lyon.org> References: <20200114185255.25813-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 --- sysdeps/htl/pthreadP.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h index c6ddf76fd4..b1c7575f89 100644 --- a/sysdeps/htl/pthreadP.h +++ b/sysdeps/htl/pthreadP.h @@ -30,11 +30,22 @@ extern struct __pthread **__pthread_threads; extern int __pthread_mutex_init (pthread_mutex_t *__mutex, const pthread_mutexattr_t *__attr); extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex); extern int __pthread_mutex_lock (pthread_mutex_t *__mutex); +extern int __pthread_mutex_trylock (pthread_mutex_t *_mutex); extern int __pthread_mutex_timedlock (pthread_mutex_t *__mutex, const struct timespec *__abstime); extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex); +extern int __pthread_mutexattr_init (pthread_mutexattr_t *attr); +extern int __pthread_mutexattr_settype (pthread_mutexattr_t *attr, int kind); +extern int __pthread_cond_init (pthread_cond_t *cond, + const pthread_condattr_t *cond_attr); +extern int __pthread_cond_signal (pthread_cond_t *cond); extern int __pthread_cond_broadcast (pthread_cond_t *cond); +extern int __pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex); +extern int __pthread_cond_timedwait (pthread_cond_t *cond, + pthread_mutex_t *mutex, + const struct timespec *abstime); +extern int __pthread_cond_destroy (pthread_cond_t *cond); typedef struct __cthread *__cthread_t; typedef int __cthread_key_t; @@ -55,6 +66,8 @@ int __cthread_setspecific (__cthread_key_t, void *); int __pthread_key_create (pthread_key_t *key, void (*destr) (void *)); void *__pthread_getspecific (pthread_key_t key); int __pthread_setspecific (pthread_key_t key, const void *value); +int __pthread_key_delete (pthread_key_t key); +int __pthread_once (pthread_once_t *once_control, void (*init_routine) (void)); int __pthread_setcancelstate (int state, int *oldstate); From patchwork Tue Jan 14 18:52:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1222995 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108662-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=kL8MGN27; dkim-atps=neutral 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 47y0372w1yz9s29 for ; Wed, 15 Jan 2020 05:53:23 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=setQv2dSamWjQPa0MwOyA5NMuu0dp7naXKsv0YQ3LhAXM8BKKr0Oc Y0TJfc5XJ4NkhvSR+48evH9Agr+DxotisPon1lDMVMX++eUjT4EjCOS0Zp9a5T6C wyeQ5b1BSbe4it6lZbYRxfJ665qmnVp3YUX58uN3/wd1oB6gy2e228= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=uPzuev83uDzuWYpE/dB17lZLHC4=; b=kL8MGN27cufy0b9tT7d9jHys1tVN RRKSQz7xpc4di262FgngnIXGluLIyYiUbF3mR3rXLJ2iVnMA/udfxr3MXeIy2u/e a9cyeTIRtqVM2COr0SO0Z8Pp36qPAztLxjQROr+PEA1xRRDGC02f8Q2GwdObbsTp YZ1Hr0bFhAAUM6M= Received: (qmail 91834 invoked by alias); 14 Jan 2020 18:53:17 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 91807 invoked by uid 89); 14 Jan 2020 18:53:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: hera.aquilenet.fr From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault Subject: [PATCH 03/10] htl: Add support for C11 threads behavior Date: Tue, 14 Jan 2020 19:52:48 +0100 Message-Id: <20200114185255.25813-5-samuel.thibault@ens-lyon.org> In-Reply-To: <20200114185255.25813-1-samuel.thibault@ens-lyon.org> References: <20200114185255.25813-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 Essentially properly calling the thread function which returns an int instead of a void*. Reviewed-by: Adhemerval Zanella --- htl/pt-create.c | 20 +++++++++++++++++++- htl/pt-internal.h | 3 +++ sysdeps/htl/pthreadP.h | 3 +++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/htl/pt-create.c b/htl/pt-create.c index 0b3237f46a..090d394f53 100644 --- a/htl/pt-create.c +++ b/htl/pt-create.c @@ -59,7 +59,17 @@ entry_point (struct __pthread *self, void *(*start_routine) (void *), void *arg) __pthread_startup (); - __pthread_exit (start_routine (arg)); + if (self->c11) + { + /* The function pointer of the c11 thread start is cast to an incorrect + type on __pthread_create call, however it is casted back to correct + one so the call behavior is well-defined (it is assumed that pointers + to void are able to represent all values of int). */ + int (*start)(void*) = (int (*) (void*)) start_routine; + __pthread_exit ((void*) (uintptr_t) start (arg)); + } + else + __pthread_exit (start_routine (arg)); } /* Create a thread with attributes given by ATTR, executing @@ -99,6 +109,14 @@ __pthread_create_internal (struct __pthread **thread, if (err) goto failed; + if (attr == ATTR_C11_THREAD) + { + attr = NULL; + pthread->c11 = true; + } + else + pthread->c11 = false; + /* Use the default attributes if ATTR is NULL. */ setup = attr ? attr : &__pthread_default_attr; diff --git a/htl/pt-internal.h b/htl/pt-internal.h index f8d7d74244..8a45854070 100644 --- a/htl/pt-internal.h +++ b/htl/pt-internal.h @@ -100,6 +100,9 @@ struct __pthread /* Resolver state. */ struct __res_state res_state; + /* Indicates whether is a C11 thread created by thrd_creat. */ + bool c11; + /* Thread context. */ struct pthread_mcontext mcontext; diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h index b1c7575f89..fc8c9bc591 100644 --- a/sysdeps/htl/pthreadP.h +++ b/sysdeps/htl/pthreadP.h @@ -21,6 +21,9 @@ #include +/* Attribute to indicate thread creation was issued from C11 thrd_create. */ +#define ATTR_C11_THREAD ((void*)(uintptr_t)-1) + /* These represent the interface used by glibc itself. */ extern pthread_t __pthread_self (void); From patchwork Tue Jan 14 18:52:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1222999 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108666-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=wKfeisbG; dkim-atps=neutral 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 47y03q5k1Zz9s29 for ; Wed, 15 Jan 2020 05:53:59 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=MoaIwyQmR4zUWk7LwfahibRsnXhEf2IdYdkkKffwsylXK0uKqw4vQ YkD74P0m5lDm2unAJCzgjSa/X1bt/6ea75x1mPXdm+PXyDHhAWVm/73xQICvCzhA pHoHifxvd8teHK0M6n6wV+W0iGJ6hvhKljNN5iwauhOhYoQm++7sfs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=Jo0QIcImrUfm7cgpSx49kCahFzY=; b=wKfeisbGRfavT1tGtFpwp18+lteg VAiWCYCVr7zDXfnjSuerwmnIWuR+4OHSWQaMzWqOAwmbRS6p9W1fUxDeLP20R2dR MFqf86XhcaAdWSaYT00S3yMjDZpLzpvrv4LgA5MJpJyoLnljSrDwcWvMq/SJyhaI D7XBqaDUV6MVZVk= Received: (qmail 93558 invoked by alias); 14 Jan 2020 18:53:29 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 93474 invoked by uid 89); 14 Jan 2020 18:53:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: hera.aquilenet.fr From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault Subject: [PATCH 04/10] htl: Make __PTHREAD_ONCE_INIT more flexible Date: Tue, 14 Jan 2020 19:52:49 +0100 Message-Id: <20200114185255.25813-6-samuel.thibault@ens-lyon.org> In-Reply-To: <20200114185255.25813-1-samuel.thibault@ens-lyon.org> References: <20200114185255.25813-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 by moving its (struct __pthread_once) cast into PTHREAD_ONCE_INIT. Reviewed-by: Adhemerval Zanella --- sysdeps/htl/bits/types/struct___pthread_once.h | 2 +- sysdeps/htl/pthread.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sysdeps/htl/bits/types/struct___pthread_once.h b/sysdeps/htl/bits/types/struct___pthread_once.h index 31a0c0817b..a6b6db708c 100644 --- a/sysdeps/htl/bits/types/struct___pthread_once.h +++ b/sysdeps/htl/bits/types/struct___pthread_once.h @@ -28,6 +28,6 @@ struct __pthread_once }; #define __PTHREAD_ONCE_INIT \ - (struct __pthread_once) { 0, __PTHREAD_SPIN_LOCK_INITIALIZER } + 0, __PTHREAD_SPIN_LOCK_INITIALIZER #endif /* bits/types/struct___pthread_once.h */ diff --git a/sysdeps/htl/pthread.h b/sysdeps/htl/pthread.h index 3216860493..38c61e8da3 100644 --- a/sysdeps/htl/pthread.h +++ b/sysdeps/htl/pthread.h @@ -802,7 +802,7 @@ extern int pthread_setspecific (pthread_key_t __key, const void *__value) #include -#define PTHREAD_ONCE_INIT __PTHREAD_ONCE_INIT +#define PTHREAD_ONCE_INIT (struct __pthread_once) { __PTHREAD_ONCE_INIT } /* Call INIT_ROUTINE if this function has never been called with *ONCE_CONTROL, otherwise do nothing. */ From patchwork Tue Jan 14 18:52:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1223001 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108668-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=vDDD0AR1; dkim-atps=neutral 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 47y04B0zjbz9s29 for ; Wed, 15 Jan 2020 05:54:17 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=OQAHevPw49EXcP1zqNqD62RvBkyWzxq5jogrY9qsLfFBWE2gufuB1 edTvnqZ0ZsfEp1fJL7KaWUVBsadOZOeYdEns6L7WgQrGkKyMrwB0U/YbjGWz8rEh NszT88L9GmMKjcH+XNQN7eVw74O1R7EubhKlnkE4pW3VHdgZm7C29A= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=McvU+Vhw/8D5r/7taWRrrdI+3JY=; b=vDDD0AR1Xu/j699rLNa9uqjpWoOk WCRF41HXw1F2JMHt5FnORFKDiecy0N0ydZs9AlG78GLxtW2WGnju8VT/376n5r/h tAkPWjamXUxnXhDk2o0giJkkANEBvx9w0gkWyv+RSukftlYwywdX4MbUGdLRfUIw Ew0LMHfsAm2b6oc= Received: (qmail 93728 invoked by alias); 14 Jan 2020 18:53:30 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 93477 invoked by uid 89); 14 Jan 2020 18:53:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: hera.aquilenet.fr From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault Subject: [PATCH 05/10] nptl: Move nptl-specific types to separate header Date: Tue, 14 Jan 2020 19:52:50 +0100 Message-Id: <20200114185255.25813-7-samuel.thibault@ens-lyon.org> In-Reply-To: <20200114185255.25813-1-samuel.thibault@ens-lyon.org> References: <20200114185255.25813-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 --- nptl/call_once.c | 2 +- sysdeps/nptl/bits/thread-shared-types.h | 10 ++++++++++ sysdeps/nptl/threads.h | 13 +++++-------- 3 files changed, 16 insertions(+), 9 deletions(-) Reviewed-by: Adhemerval Zanella diff --git a/nptl/call_once.c b/nptl/call_once.c index 3f880a9073..25e2964c76 100644 --- a/nptl/call_once.c +++ b/nptl/call_once.c @@ -27,5 +27,5 @@ call_once (once_flag *flag, void (*func)(void)) "sizeof (once_flag) != sizeof (pthread_once_t)"); _Static_assert (alignof (once_flag) == alignof (pthread_once_t), "alignof (once_flag) != alignof (pthread_once_t)"); - __pthread_once (&flag->__data, func); + __pthread_once ((pthread_once_t *) flag, func); } diff --git a/sysdeps/nptl/bits/thread-shared-types.h b/sysdeps/nptl/bits/thread-shared-types.h index fd08b6916a..fbbdd0bb36 100644 --- a/sysdeps/nptl/bits/thread-shared-types.h +++ b/sysdeps/nptl/bits/thread-shared-types.h @@ -116,4 +116,14 @@ struct __pthread_cond_s unsigned int __g_signals[2]; }; +typedef unsigned int __tss_t; +typedef unsigned long int __thrd_t; + +typedef struct +{ + int __data __ONCE_ALIGNMENT; +} __once_flag; + +#define __ONCE_FLAG_INIT { 0 } + #endif /* _THREAD_SHARED_TYPES_H */ diff --git a/sysdeps/nptl/threads.h b/sysdeps/nptl/threads.h index 6d5e4bfe02..0ac489b4a1 100644 --- a/sysdeps/nptl/threads.h +++ b/sysdeps/nptl/threads.h @@ -24,7 +24,7 @@ __BEGIN_DECLS -#include +#include #include #ifndef __cplusplus @@ -32,10 +32,10 @@ __BEGIN_DECLS #endif #define TSS_DTOR_ITERATIONS 4 -typedef unsigned int tss_t; +typedef __tss_t tss_t; typedef void (*tss_dtor_t) (void*); -typedef unsigned long int thrd_t; +typedef __thrd_t thrd_t; typedef int (*thrd_start_t) (void*); /* Exit and error codes. */ @@ -56,11 +56,8 @@ enum mtx_timed = 2 }; -typedef struct -{ - int __data __ONCE_ALIGNMENT; -} once_flag; -#define ONCE_FLAG_INIT { 0 } +typedef __once_flag once_flag; +#define ONCE_FLAG_INIT __ONCE_FLAG_INIT typedef union { From patchwork Tue Jan 14 18:52:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1223007 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108670-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=ocQv2sm7; dkim-atps=neutral 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 47y0Gb081Sz9s29 for ; Wed, 15 Jan 2020 06:03:18 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=a6hcNscMhEAbVl4syhrc4Thsq3FvPSqSH2Lt+iZGq8R+pVLSCu0lB JHQtMZUxYTSYxbqPHPeKsAPJBnJT/Z2bX8FwllkMtxI+fpSny0DpAhetTk9ed0+g J1/ruopGW9BAofK2SyxXI+BRUPyNcUaZ3RIrDySfYmi7do9/UbTg/I= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=HDcZbH9oMi+/OSH8H5oXehpIQws=; b=ocQv2sm7zKSGq56z0qylcR953/M4 t85bwxcVWaSS0w/4zMvSwqJYEloUVx22xG5rUD3Ns1TQAwFJ37rWa4KeDIiu/Vs1 3tqk4DFiEduDuVNPsxugc5lOKHoVsQFLmB2BQVrtLuRtVcS5lAENxwe01ziwGJlH k1lj/+ra60QR7lw= Received: (qmail 121515 invoked by alias); 14 Jan 2020 19:03:13 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 121496 invoked by uid 89); 14 Jan 2020 19:03:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: hera.aquilenet.fr From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault Subject: [PATCH 06/10] C11 threads: do not require PTHREAD_DESTRUCTOR_ITERATIONS Date: Tue, 14 Jan 2020 19:52:51 +0100 Message-Id: <20200114185255.25813-8-samuel.thibault@ens-lyon.org> In-Reply-To: <20200114185255.25813-1-samuel.thibault@ens-lyon.org> References: <20200114185255.25813-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 It is optional in POSIX. Reviewed-by: Adhemerval Zanella --- nptl/tss_create.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nptl/tss_create.c b/nptl/tss_create.c index ea1f2e0fba..4e170dd4fc 100644 --- a/nptl/tss_create.c +++ b/nptl/tss_create.c @@ -23,8 +23,10 @@ tss_create (tss_t *tss_id, tss_dtor_t destructor) { _Static_assert (sizeof (tss_t) == sizeof (pthread_key_t), "sizeof (tss_t) != sizeof (pthread_key_t)"); +#ifdef PTHREAD_DESTRUCTOR_ITERATIONS _Static_assert (TSS_DTOR_ITERATIONS == PTHREAD_DESTRUCTOR_ITERATIONS, "TSS_DTOR_ITERATIONS != PTHREAD_DESTRUCTOR_ITERATIONS"); +#endif int err_code = __pthread_key_create (tss_id, destructor); return thrd_err_map (err_code); From patchwork Tue Jan 14 18:52:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1223009 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108672-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=pvvv+A0J; dkim-atps=neutral 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 47y0Gw594Fz9s4Y for ; Wed, 15 Jan 2020 06:03:36 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=uVA/O0UBiIh+s9xtmkBODHFQv5764EtBxfpelA3mkWirLKYYX9N6S tMYgOpKjBsFvMV1KsXHv2UCoFWkdGEPvp9hnp8pMP+fvKt5HhKlPVwc6R280U49N i64iH6Ir9l0F18vT8/hfzDmppVvO7VEPsPwL2NnVB0ozykU4N+UxrY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=77bGMwepa53lQSc9eEWtKVSpiW0=; b=pvvv+A0JiACyYRXwZmGCqLvz7TRo Ui0h8VWo0sqrCGQT1YsdRUSHdGhxym0pIEWhQoeFxRykC9ZZQrSzPd46gBdtX55y WgbHgrweZW5zsAGjKlSeb7f7o9wfkOVMnGcoFjhViqKsCewoEnnYvqLvYbYU+5Ae PdmA0+XtE2Mh64U= Received: (qmail 121558 invoked by alias); 14 Jan 2020 19:03:13 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 121494 invoked by uid 89); 14 Jan 2020 19:03:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: hera.aquilenet.fr From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault Subject: [PATCH 07/10] C11 threads: Fix thrd_t / pthread_t compatibility assertion Date: Tue, 14 Jan 2020 19:52:52 +0100 Message-Id: <20200114185255.25813-9-samuel.thibault@ens-lyon.org> In-Reply-To: <20200114185255.25813-1-samuel.thibault@ens-lyon.org> References: <20200114185255.25813-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 --- nptl/thrd_create.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) Reviewed-by: Adhemerval Zanella diff --git a/nptl/thrd_create.c b/nptl/thrd_create.c index 8474e234c9..fe08e22973 100644 --- a/nptl/thrd_create.c +++ b/nptl/thrd_create.c @@ -21,8 +21,8 @@ int thrd_create (thrd_t *thr, thrd_start_t func, void *arg) { - _Static_assert (sizeof (thr) == sizeof (pthread_t), - "sizeof (thr) != sizeof (pthread_t)"); + _Static_assert (sizeof (*thr) == sizeof (pthread_t), + "sizeof (*thr) != sizeof (pthread_t)"); int err_code = __pthread_create_2_1 (thr, ATTR_C11_THREAD, (void* (*) (void*))func, arg); From patchwork Tue Jan 14 18:52:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1223008 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108671-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=bs6+WTeb; dkim-atps=neutral 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 47y0Gl6kLDz9s29 for ; Wed, 15 Jan 2020 06:03:27 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=i+243GsL6V98bPIMMBEFWzeIFoyHVgv0i8EpkchAVjppJD+EJsyfk Fb6nKv0nTUdBTV4dGRdINzqETcMvxsOgWHUPwuL6Z1cdLtZmiAVsXEkV6MiXA/rp UwYrnsZReLaGjBUnmWEV8e8sqlajm9ocNDnaW5HPOxYN6p4tJIP2Vw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=ZAA2dkaSDtNlw0Liio2TlPSbHBI=; b=bs6+WTebJksqFVbvT9HKbYTJpO6J 4XclQmGoncL0uz9LNrbXcJOYutRnzEO04sngrKTJ9UB0aJLDH7CwbeSTbKKr8pFI G3cbKR3HVaTeMsxg9TFQDT7N3c3lIIA5snTejPjJWAYmj+ZI/Iucig9G6HArDB8X 9vzza6ml8Osygm4= Received: (qmail 121527 invoked by alias); 14 Jan 2020 19:03:13 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 121495 invoked by uid 89); 14 Jan 2020 19:03:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: hera.aquilenet.fr From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault Subject: [PATCH 08/10] C11 threads: make thrd_join more portable Date: Tue, 14 Jan 2020 19:52:53 +0100 Message-Id: <20200114185255.25813-10-samuel.thibault@ens-lyon.org> In-Reply-To: <20200114185255.25813-1-samuel.thibault@ens-lyon.org> References: <20200114185255.25813-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 by making a __pthread_join call instead of an equivalent __pthread_clockjoin_ex call. Reviewed-by: Adhemerval Zanella --- nptl/thrd_join.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nptl/thrd_join.c b/nptl/thrd_join.c index 783e36f02b..0c482959d5 100644 --- a/nptl/thrd_join.c +++ b/nptl/thrd_join.c @@ -22,7 +22,7 @@ int thrd_join (thrd_t thr, int *res) { void *pthread_res; - int err_code = __pthread_clockjoin_ex (thr, &pthread_res, 0, NULL, true); + int err_code = __pthread_join (thr, &pthread_res); if (res) *res = (int) (uintptr_t) pthread_res; From patchwork Tue Jan 14 18:52:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1223002 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108669-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=MU+Tynsw; dkim-atps=neutral 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 47y04M53YMz9s29 for ; Wed, 15 Jan 2020 05:54:27 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=wi4s0nZ/bNCUyIYecu4qvwMP+Xmg31BUyqwHdY2BF5ByLaz3Vlz+E p1Xz7kYNfa7pfDQnVN3hX8Ujl2J3kjLNHp1xUPNhu0c4JNqA46kUnE+tp8BxQj4h jTDT28QynpTI4QXeJt+ngpDIVfO0MIvEe4y4mUcKgZJjxDj4cw8rJ4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=y2aT8qVfOP+bRx7eVfh3y8XJR0A=; b=MU+TynswdE6tJ8PgR4EDHE6Z8qUN JiZkFYLA+x5T0OGrCrcHjLur612GJPyMZJrKBumJiHjZgSfb2aIW+7xMC/9y48PS qpNYrn0CBDGg4l7RJkDIH4Rg1QNicVnguL1HbIAtFm56s+QfMeauutorCsyOC+xA CNagkm/7i1u5YDo= Received: (qmail 93765 invoked by alias); 14 Jan 2020 18:53:31 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 93473 invoked by uid 89); 14 Jan 2020 18:53:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: hera.aquilenet.fr From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault Subject: [PATCH 09/10] htl: Add C11 threads types definitions Date: Tue, 14 Jan 2020 19:52:54 +0100 Message-Id: <20200114185255.25813-11-samuel.thibault@ens-lyon.org> In-Reply-To: <20200114185255.25813-1-samuel.thibault@ens-lyon.org> References: <20200114185255.25813-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 --- sysdeps/htl/bits/thread-shared-types.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sysdeps/htl/bits/thread-shared-types.h b/sysdeps/htl/bits/thread-shared-types.h index c280f2e182..819682a07b 100644 --- a/sysdeps/htl/bits/thread-shared-types.h +++ b/sysdeps/htl/bits/thread-shared-types.h @@ -20,5 +20,18 @@ #define _THREAD_SHARED_TYPES_H 1 #include +#include + +typedef int __tss_t; +typedef int __thrd_t; + +typedef union +{ + struct __pthread_once __data; + int __align __ONCE_ALIGNMENT; + char __size[__SIZEOF_PTHREAD_ONCE_T]; +} __once_flag; + +#define __ONCE_FLAG_INIT { { __PTHREAD_ONCE_INIT } } #endif /* _THREAD_SHARED_TYPES_H */ From patchwork Tue Jan 14 18:52:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1223010 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108673-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=Ak83oYjT; dkim-atps=neutral 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 47y0H61mt1z9s4Y for ; Wed, 15 Jan 2020 06:03:46 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=qWdltohto8Xy051ygGhlGRklfSB8ymKHnS6CLfi30vNXooEnjilUa h1+YAlHyQHzoB200Vp+3zrliRIVQQAGNrLT9Idyhbex1nuSW8stpodhkYEsdodfl mJ/mbGbL+kTQSPtyc+oqrszxDQAZYMWQD49P0oHAYx2+bidCAhuIco= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=hS+ExVu2WBbExxznr+mx9xoAsoo=; b=Ak83oYjTGM0szye1ZMT+ESgRS8np cLm2il/w5OlD5MFLRY+fXSI03W55Nf1iTO85o8fFJgoLyouyybI0vhC8ntJKYjT4 uDu373yWjS+LTGO8q6Bc833bz5uSNNTZKZeSkihBH4TQOmdlDZvdPL89Qn8RwvC/ oA3q7Dk45CAh1CU= Received: (qmail 121606 invoked by alias); 14 Jan 2020 19:03:13 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 121520 invoked by uid 89); 14 Jan 2020 19:03:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL autolearn=ham version=3.3.1 spammy=synchronized, glibcs, Square X-HELO: hera.aquilenet.fr From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault Subject: [PATCH 10/10] C11 threads: Move implementation to sysdeps/pthread Date: Tue, 14 Jan 2020 19:52:55 +0100 Message-Id: <20200114185255.25813-12-samuel.thibault@ens-lyon.org> In-Reply-To: <20200114185255.25813-1-samuel.thibault@ens-lyon.org> References: <20200114185255.25813-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 so it gets shared by nptl and htl. Also add htl versions of thrd_current and thrd_yield. Reviewed-by: Adhemerval Zanella --- htl/Versions | 16 +++++ nptl/Makefile | 14 +---- sysdeps/htl/pt-mutex-destroy.c | 1 + sysdeps/htl/pt-mutex-timedlock.c | 1 + sysdeps/htl/pthreadP.h | 2 + sysdeps/htl/thrd_current.c | 31 +++++++++ sysdeps/htl/threads.h | 1 - sysdeps/hurd/stdc-predef.h | 63 ------------------- sysdeps/mach/htl/thrd_yield.c | 26 ++++++++ sysdeps/mach/hurd/htl/pt-mutex-destroy.c | 1 + sysdeps/mach/hurd/htl/pt-mutex-timedlock.c | 1 + sysdeps/mach/hurd/i386/libc.abilist | 4 ++ sysdeps/mach/hurd/i386/libpthread.abilist | 21 +++++++ sysdeps/nptl/thrd_create.c | 2 + sysdeps/pthread/Makefile | 18 ++++++ {nptl => sysdeps/pthread}/call_once.c | 0 {nptl => sysdeps/pthread}/cnd_broadcast.c | 0 {nptl => sysdeps/pthread}/cnd_destroy.c | 0 {nptl => sysdeps/pthread}/cnd_init.c | 0 {nptl => sysdeps/pthread}/cnd_signal.c | 0 {nptl => sysdeps/pthread}/cnd_timedwait.c | 0 {nptl => sysdeps/pthread}/cnd_wait.c | 0 {nptl => sysdeps/pthread}/mtx_destroy.c | 0 {nptl => sysdeps/pthread}/mtx_init.c | 0 {nptl => sysdeps/pthread}/mtx_lock.c | 0 {nptl => sysdeps/pthread}/mtx_timedlock.c | 0 {nptl => sysdeps/pthread}/mtx_trylock.c | 0 {nptl => sysdeps/pthread}/mtx_unlock.c | 0 {nptl => sysdeps/pthread}/thrd_create.c | 4 +- {nptl => sysdeps/pthread}/thrd_detach.c | 0 {nptl => sysdeps/pthread}/thrd_equal.c | 0 {nptl => sysdeps/pthread}/thrd_exit.c | 0 {nptl => sysdeps/pthread}/thrd_join.c | 0 {nptl => sysdeps/pthread}/thrd_priv.h | 0 {nptl => sysdeps/pthread}/thrd_sleep.c | 0 sysdeps/{nptl => pthread}/threads.h | 0 {nptl => sysdeps/pthread}/tss_create.c | 0 {nptl => sysdeps/pthread}/tss_delete.c | 0 {nptl => sysdeps/pthread}/tss_get.c | 0 {nptl => sysdeps/pthread}/tss_set.c | 0 {nptl => sysdeps/pthread}/tst-call-once.c | 0 {nptl => sysdeps/pthread}/tst-cnd-basic.c | 0 {nptl => sysdeps/pthread}/tst-cnd-broadcast.c | 0 {nptl => sysdeps/pthread}/tst-cnd-timedwait.c | 0 {nptl => sysdeps/pthread}/tst-mtx-basic.c | 0 {nptl => sysdeps/pthread}/tst-mtx-recursive.c | 0 {nptl => sysdeps/pthread}/tst-mtx-timedlock.c | 0 {nptl => sysdeps/pthread}/tst-mtx-trylock.c | 0 {nptl => sysdeps/pthread}/tst-thrd-detach.c | 0 {nptl => sysdeps/pthread}/tst-thrd-sleep.c | 0 {nptl => sysdeps/pthread}/tst-tss-basic.c | 0 51 files changed, 129 insertions(+), 77 deletions(-) create mode 100644 sysdeps/htl/thrd_current.c delete mode 100644 sysdeps/htl/threads.h delete mode 100644 sysdeps/hurd/stdc-predef.h create mode 100644 sysdeps/mach/htl/thrd_yield.c create mode 100644 sysdeps/nptl/thrd_create.c rename {nptl => sysdeps/pthread}/call_once.c (100%) rename {nptl => sysdeps/pthread}/cnd_broadcast.c (100%) rename {nptl => sysdeps/pthread}/cnd_destroy.c (100%) rename {nptl => sysdeps/pthread}/cnd_init.c (100%) rename {nptl => sysdeps/pthread}/cnd_signal.c (100%) rename {nptl => sysdeps/pthread}/cnd_timedwait.c (100%) rename {nptl => sysdeps/pthread}/cnd_wait.c (100%) rename {nptl => sysdeps/pthread}/mtx_destroy.c (100%) rename {nptl => sysdeps/pthread}/mtx_init.c (100%) rename {nptl => sysdeps/pthread}/mtx_lock.c (100%) rename {nptl => sysdeps/pthread}/mtx_timedlock.c (100%) rename {nptl => sysdeps/pthread}/mtx_trylock.c (100%) rename {nptl => sysdeps/pthread}/mtx_unlock.c (100%) rename {nptl => sysdeps/pthread}/thrd_create.c (91%) rename {nptl => sysdeps/pthread}/thrd_detach.c (100%) rename {nptl => sysdeps/pthread}/thrd_equal.c (100%) rename {nptl => sysdeps/pthread}/thrd_exit.c (100%) rename {nptl => sysdeps/pthread}/thrd_join.c (100%) rename {nptl => sysdeps/pthread}/thrd_priv.h (100%) rename {nptl => sysdeps/pthread}/thrd_sleep.c (100%) rename sysdeps/{nptl => pthread}/threads.h (100%) rename {nptl => sysdeps/pthread}/tss_create.c (100%) rename {nptl => sysdeps/pthread}/tss_delete.c (100%) rename {nptl => sysdeps/pthread}/tss_get.c (100%) rename {nptl => sysdeps/pthread}/tss_set.c (100%) rename {nptl => sysdeps/pthread}/tst-call-once.c (100%) rename {nptl => sysdeps/pthread}/tst-cnd-basic.c (100%) rename {nptl => sysdeps/pthread}/tst-cnd-broadcast.c (100%) rename {nptl => sysdeps/pthread}/tst-cnd-timedwait.c (100%) rename {nptl => sysdeps/pthread}/tst-mtx-basic.c (100%) rename {nptl => sysdeps/pthread}/tst-mtx-recursive.c (100%) rename {nptl => sysdeps/pthread}/tst-mtx-timedlock.c (100%) rename {nptl => sysdeps/pthread}/tst-mtx-trylock.c (100%) rename {nptl => sysdeps/pthread}/tst-thrd-detach.c (100%) rename {nptl => sysdeps/pthread}/tst-thrd-sleep.c (100%) rename {nptl => sysdeps/pthread}/tst-tss-basic.c (100%) diff --git a/htl/Versions b/htl/Versions index 3ae4b5c17d..c44507c21d 100644 --- a/htl/Versions +++ b/htl/Versions @@ -20,6 +20,12 @@ libc { GLIBC_2.22 { __register_atfork; } + + # C11 thread symbols. + GLIBC_2.32 { + thrd_current; thrd_equal; thrd_sleep; thrd_yield; + } + GLIBC_PRIVATE { __libc_alloca_cutoff; __libc_pthread_init; @@ -142,6 +148,16 @@ libpthread { pthread_hurd_cond_wait_np; pthread_hurd_cond_timedwait_np; } + + # C11 thread symbols. + GLIBC_2.32 { + thrd_create; thrd_detach; thrd_exit; thrd_join; + mtx_init; mtx_lock; mtx_timedlock; mtx_trylock; mtx_unlock; mtx_destroy; + call_once; + cnd_broadcast; cnd_destroy; cnd_init; cnd_signal; cnd_timedwait; cnd_wait; + tss_create; tss_delete; tss_get; tss_set; + } + GLIBC_PRIVATE { __shm_directory; __pthread_threads; diff --git a/nptl/Makefile b/nptl/Makefile index 584e0ffd96..820b757692 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -22,7 +22,7 @@ subdir := nptl include ../Makeconfig -headers := pthread.h semaphore.h bits/semaphore.h threads.h \ +headers := pthread.h semaphore.h bits/semaphore.h \ bits/struct_mutex.h bits/struct_rwlock.h extra-libs := libpthread @@ -30,8 +30,7 @@ extra-libs-others := $(extra-libs) routines = alloca_cutoff forward libc-lowlevellock libc-cancellation \ libc-cleanup libc_pthread_init libc_multiple_threads \ - register-atfork pthread_atfork pthread_self thrd_current \ - thrd_equal thrd_sleep thrd_yield pthread_equal \ + register-atfork pthread_atfork pthread_self pthread_equal \ pthread_attr_destroy pthread_attr_init pthread_attr_getdetachstate \ pthread_attr_setdetachstate pthread_attr_getinheritsched \ pthread_attr_setinheritsched pthread_attr_getschedparam \ @@ -141,11 +140,7 @@ libpthread-routines = nptl-init nptlfreeres vars events version pt-interp \ pthread_mutex_setprioceiling \ pthread_setname pthread_getname \ pthread_setattr_default_np pthread_getattr_default_np \ - thrd_create thrd_detach thrd_exit thrd_join \ - mtx_destroy mtx_init mtx_lock mtx_timedlock \ - mtx_trylock mtx_unlock call_once cnd_broadcast \ - cnd_destroy cnd_init cnd_signal cnd_timedwait cnd_wait \ - tss_create tss_delete tss_get tss_set pthread_mutex_conf \ + pthread_mutex_conf \ libpthread-compat # pthread_setuid pthread_seteuid pthread_setreuid \ # pthread_setresuid \ @@ -319,9 +314,6 @@ tests = tst-attr1 tst-attr2 tst-attr3 tst-default-attr \ tst-robust-fork tst-create-detached tst-memstream \ tst-thread-exit-clobber tst-minstack-cancel tst-minstack-exit \ tst-minstack-throw \ - tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \ - tst-cnd-timedwait tst-thrd-detach tst-mtx-basic tst-thrd-sleep \ - tst-mtx-recursive tst-tss-basic tst-call-once tst-mtx-timedlock \ tst-rwlock-pwn \ tst-rwlock-tryrdlock-stall tst-rwlock-trywrlock-stall \ tst-unwind-thread diff --git a/sysdeps/htl/pt-mutex-destroy.c b/sysdeps/htl/pt-mutex-destroy.c index 796fc11b8d..6a3b5be874 100644 --- a/sysdeps/htl/pt-mutex-destroy.c +++ b/sysdeps/htl/pt-mutex-destroy.c @@ -36,3 +36,4 @@ __pthread_mutex_destroy (pthread_mutex_t *mutex) } strong_alias (__pthread_mutex_destroy, pthread_mutex_destroy); +hidden_def (__pthread_mutex_destroy) diff --git a/sysdeps/htl/pt-mutex-timedlock.c b/sysdeps/htl/pt-mutex-timedlock.c index 0e50f38ef2..81013984a6 100644 --- a/sysdeps/htl/pt-mutex-timedlock.c +++ b/sysdeps/htl/pt-mutex-timedlock.c @@ -195,3 +195,4 @@ __pthread_mutex_timedlock (struct __pthread_mutex *mutex, return __pthread_mutex_timedlock_internal (mutex, abstime); } strong_alias (__pthread_mutex_timedlock, pthread_mutex_timedlock) +hidden_def (__pthread_mutex_timedlock) diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h index fc8c9bc591..fd1e697e39 100644 --- a/sysdeps/htl/pthreadP.h +++ b/sysdeps/htl/pthreadP.h @@ -91,6 +91,8 @@ hidden_proto (__pthread_key_create) hidden_proto (__pthread_getspecific) hidden_proto (__pthread_setspecific) hidden_proto (__pthread_mutex_init) +hidden_proto (__pthread_mutex_destroy) +hidden_proto (__pthread_mutex_timedlock) #endif #define ASSERT_TYPE_SIZE(type, size) \ diff --git a/sysdeps/htl/thrd_current.c b/sysdeps/htl/thrd_current.c new file mode 100644 index 0000000000..efc0d11b5d --- /dev/null +++ b/sysdeps/htl/thrd_current.c @@ -0,0 +1,31 @@ +/* C11 threads current thread implementation. + Copyright (C) 2018-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include "thrd_priv.h" + +#pragma weak __pthread_self +#pragma weak __pthread_threads + +thrd_t +thrd_current (void) +{ + if (__pthread_threads) + return (thrd_t) __pthread_self (); + + return (thrd_t) 0; +} diff --git a/sysdeps/htl/threads.h b/sysdeps/htl/threads.h deleted file mode 100644 index 3c04fbcc79..0000000000 --- a/sysdeps/htl/threads.h +++ /dev/null @@ -1 +0,0 @@ -#error "HTL does not implement ISO C threads" diff --git a/sysdeps/hurd/stdc-predef.h b/sysdeps/hurd/stdc-predef.h deleted file mode 100644 index a7bb5f7c5f..0000000000 --- a/sysdeps/hurd/stdc-predef.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (C) 2018-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#ifndef _STDC_PREDEF_H -#define _STDC_PREDEF_H 1 - -/* This header is separate from features.h so that the compiler can - include it implicitly at the start of every compilation. It must - not itself include or any other header that includes - because the implicit include comes before any feature - test macros that may be defined in a source file before it first - explicitly includes a system header. GCC knows the name of this - header in order to preinclude it. */ - -/* glibc's intent is to support the IEC 559 math functionality, real - and complex. If the GCC (4.9 and later) predefined macros - specifying compiler intent are available, use them to determine - whether the overall intent is to support these features; otherwise, - presume an older compiler has intent to support these features and - define these macros by default. */ - -#ifdef __GCC_IEC_559 -# if __GCC_IEC_559 > 0 -# define __STDC_IEC_559__ 1 -# endif -#else -# define __STDC_IEC_559__ 1 -#endif - -#ifdef __GCC_IEC_559_COMPLEX -# if __GCC_IEC_559_COMPLEX > 0 -# define __STDC_IEC_559_COMPLEX__ 1 -# endif -#else -# define __STDC_IEC_559_COMPLEX__ 1 -#endif - -/* wchar_t uses Unicode 10.0.0. Version 10.0 of the Unicode Standard is - synchronized with ISO/IEC 10646:2017, fifth edition, plus - the following additions from Amendment 1 to the fifth edition: - - 56 emoji characters - - 285 hentaigana - - 3 additional Zanabazar Square characters */ -#define __STDC_ISO_10646__ 201706L - -/* We do not support C11 . */ -#define __STDC_NO_THREADS__ 1 - -#endif diff --git a/sysdeps/mach/htl/thrd_yield.c b/sysdeps/mach/htl/thrd_yield.c new file mode 100644 index 0000000000..09e218cf2e --- /dev/null +++ b/sysdeps/mach/htl/thrd_yield.c @@ -0,0 +1,26 @@ +/* sched_yield -- yield the processor. Mach version. + Copyright (C) 2000-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include "thrd_priv.h" + +void +thrd_yield (void) +{ + (void) __swtch (); +} diff --git a/sysdeps/mach/hurd/htl/pt-mutex-destroy.c b/sysdeps/mach/hurd/htl/pt-mutex-destroy.c index a8a0adc03f..a5bfaddcb2 100644 --- a/sysdeps/mach/hurd/htl/pt-mutex-destroy.c +++ b/sysdeps/mach/hurd/htl/pt-mutex-destroy.c @@ -35,3 +35,4 @@ __pthread_mutex_destroy (pthread_mutex_t *mtxp) } strong_alias (__pthread_mutex_destroy, pthread_mutex_destroy) +hidden_def (__pthread_mutex_destroy) diff --git a/sysdeps/mach/hurd/htl/pt-mutex-timedlock.c b/sysdeps/mach/hurd/htl/pt-mutex-timedlock.c index e83bc57875..3aa7d798b2 100644 --- a/sysdeps/mach/hurd/htl/pt-mutex-timedlock.c +++ b/sysdeps/mach/hurd/htl/pt-mutex-timedlock.c @@ -77,3 +77,4 @@ __pthread_mutex_timedlock (pthread_mutex_t *mtxp, const struct timespec *tsp) return ret; } strong_alias (__pthread_mutex_timedlock, pthread_mutex_timedlock) +hidden_def (__pthread_mutex_timedlock) diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist index 7c2cb2b05a..dd0d3c7317 100644 --- a/sysdeps/mach/hurd/i386/libc.abilist +++ b/sysdeps/mach/hurd/i386/libc.abilist @@ -2181,6 +2181,10 @@ GLIBC_2.3.4 setsourcefilter F GLIBC_2.3.4 xdr_quad_t F GLIBC_2.3.4 xdr_u_quad_t F GLIBC_2.30 twalk_r F +GLIBC_2.32 thrd_current F +GLIBC_2.32 thrd_equal F +GLIBC_2.32 thrd_sleep F +GLIBC_2.32 thrd_yield F GLIBC_2.4 __confstr_chk F GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_unlocked_chk F diff --git a/sysdeps/mach/hurd/i386/libpthread.abilist b/sysdeps/mach/hurd/i386/libpthread.abilist index cda8755960..0b90f9bf63 100644 --- a/sysdeps/mach/hurd/i386/libpthread.abilist +++ b/sysdeps/mach/hurd/i386/libpthread.abilist @@ -147,3 +147,24 @@ GLIBC_2.2.6 __errno_location F GLIBC_2.2.6 __h_errno_location F GLIBC_2.21 pthread_hurd_cond_timedwait_np F GLIBC_2.21 pthread_hurd_cond_wait_np F +GLIBC_2.32 call_once F +GLIBC_2.32 cnd_broadcast F +GLIBC_2.32 cnd_destroy F +GLIBC_2.32 cnd_init F +GLIBC_2.32 cnd_signal F +GLIBC_2.32 cnd_timedwait F +GLIBC_2.32 cnd_wait F +GLIBC_2.32 mtx_destroy F +GLIBC_2.32 mtx_init F +GLIBC_2.32 mtx_lock F +GLIBC_2.32 mtx_timedlock F +GLIBC_2.32 mtx_trylock F +GLIBC_2.32 mtx_unlock F +GLIBC_2.32 thrd_create F +GLIBC_2.32 thrd_detach F +GLIBC_2.32 thrd_exit F +GLIBC_2.32 thrd_join F +GLIBC_2.32 tss_create F +GLIBC_2.32 tss_delete F +GLIBC_2.32 tss_get F +GLIBC_2.32 tss_set F diff --git a/sysdeps/nptl/thrd_create.c b/sysdeps/nptl/thrd_create.c new file mode 100644 index 0000000000..a9219db7bc --- /dev/null +++ b/sysdeps/nptl/thrd_create.c @@ -0,0 +1,2 @@ +#define __pthread_create __pthread_create_2_1 +#include "../pthread/thrd_create.c" diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile index 7f9eadd0e2..889f10d8b1 100644 --- a/sysdeps/pthread/Makefile +++ b/sysdeps/pthread/Makefile @@ -25,3 +25,21 @@ $(objpfx)tst-timer: $(objpfx)librt.a $(static-thread-library) endif endif + +ifneq (,$(filter $(subdir),htl nptl)) +headers += threads.h + +routines += thrd_current thrd_equal thrd_sleep thrd_yield + +libpthread-routines += thrd_create thrd_detach thrd_exit thrd_join \ + call_once \ + mtx_destroy mtx_init mtx_lock mtx_timedlock \ + mtx_trylock mtx_unlock \ + cnd_broadcast \ + cnd_destroy cnd_init cnd_signal cnd_timedwait cnd_wait \ + tss_create tss_delete tss_get tss_set + +tests += tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \ + tst-cnd-timedwait tst-thrd-detach tst-mtx-basic tst-thrd-sleep \ + tst-mtx-recursive tst-tss-basic tst-call-once tst-mtx-timedlock +endif diff --git a/nptl/call_once.c b/sysdeps/pthread/call_once.c similarity index 100% rename from nptl/call_once.c rename to sysdeps/pthread/call_once.c diff --git a/nptl/cnd_broadcast.c b/sysdeps/pthread/cnd_broadcast.c similarity index 100% rename from nptl/cnd_broadcast.c rename to sysdeps/pthread/cnd_broadcast.c diff --git a/nptl/cnd_destroy.c b/sysdeps/pthread/cnd_destroy.c similarity index 100% rename from nptl/cnd_destroy.c rename to sysdeps/pthread/cnd_destroy.c diff --git a/nptl/cnd_init.c b/sysdeps/pthread/cnd_init.c similarity index 100% rename from nptl/cnd_init.c rename to sysdeps/pthread/cnd_init.c diff --git a/nptl/cnd_signal.c b/sysdeps/pthread/cnd_signal.c similarity index 100% rename from nptl/cnd_signal.c rename to sysdeps/pthread/cnd_signal.c diff --git a/nptl/cnd_timedwait.c b/sysdeps/pthread/cnd_timedwait.c similarity index 100% rename from nptl/cnd_timedwait.c rename to sysdeps/pthread/cnd_timedwait.c diff --git a/nptl/cnd_wait.c b/sysdeps/pthread/cnd_wait.c similarity index 100% rename from nptl/cnd_wait.c rename to sysdeps/pthread/cnd_wait.c diff --git a/nptl/mtx_destroy.c b/sysdeps/pthread/mtx_destroy.c similarity index 100% rename from nptl/mtx_destroy.c rename to sysdeps/pthread/mtx_destroy.c diff --git a/nptl/mtx_init.c b/sysdeps/pthread/mtx_init.c similarity index 100% rename from nptl/mtx_init.c rename to sysdeps/pthread/mtx_init.c diff --git a/nptl/mtx_lock.c b/sysdeps/pthread/mtx_lock.c similarity index 100% rename from nptl/mtx_lock.c rename to sysdeps/pthread/mtx_lock.c diff --git a/nptl/mtx_timedlock.c b/sysdeps/pthread/mtx_timedlock.c similarity index 100% rename from nptl/mtx_timedlock.c rename to sysdeps/pthread/mtx_timedlock.c diff --git a/nptl/mtx_trylock.c b/sysdeps/pthread/mtx_trylock.c similarity index 100% rename from nptl/mtx_trylock.c rename to sysdeps/pthread/mtx_trylock.c diff --git a/nptl/mtx_unlock.c b/sysdeps/pthread/mtx_unlock.c similarity index 100% rename from nptl/mtx_unlock.c rename to sysdeps/pthread/mtx_unlock.c diff --git a/nptl/thrd_create.c b/sysdeps/pthread/thrd_create.c similarity index 91% rename from nptl/thrd_create.c rename to sysdeps/pthread/thrd_create.c index fe08e22973..25af955419 100644 --- a/nptl/thrd_create.c +++ b/sysdeps/pthread/thrd_create.c @@ -24,7 +24,7 @@ thrd_create (thrd_t *thr, thrd_start_t func, void *arg) _Static_assert (sizeof (*thr) == sizeof (pthread_t), "sizeof (*thr) != sizeof (pthread_t)"); - int err_code = __pthread_create_2_1 (thr, ATTR_C11_THREAD, - (void* (*) (void*))func, arg); + int err_code = __pthread_create (thr, ATTR_C11_THREAD, + (void* (*) (void*))func, arg); return thrd_err_map (err_code); } diff --git a/nptl/thrd_detach.c b/sysdeps/pthread/thrd_detach.c similarity index 100% rename from nptl/thrd_detach.c rename to sysdeps/pthread/thrd_detach.c diff --git a/nptl/thrd_equal.c b/sysdeps/pthread/thrd_equal.c similarity index 100% rename from nptl/thrd_equal.c rename to sysdeps/pthread/thrd_equal.c diff --git a/nptl/thrd_exit.c b/sysdeps/pthread/thrd_exit.c similarity index 100% rename from nptl/thrd_exit.c rename to sysdeps/pthread/thrd_exit.c diff --git a/nptl/thrd_join.c b/sysdeps/pthread/thrd_join.c similarity index 100% rename from nptl/thrd_join.c rename to sysdeps/pthread/thrd_join.c diff --git a/nptl/thrd_priv.h b/sysdeps/pthread/thrd_priv.h similarity index 100% rename from nptl/thrd_priv.h rename to sysdeps/pthread/thrd_priv.h diff --git a/nptl/thrd_sleep.c b/sysdeps/pthread/thrd_sleep.c similarity index 100% rename from nptl/thrd_sleep.c rename to sysdeps/pthread/thrd_sleep.c diff --git a/sysdeps/nptl/threads.h b/sysdeps/pthread/threads.h similarity index 100% rename from sysdeps/nptl/threads.h rename to sysdeps/pthread/threads.h diff --git a/nptl/tss_create.c b/sysdeps/pthread/tss_create.c similarity index 100% rename from nptl/tss_create.c rename to sysdeps/pthread/tss_create.c diff --git a/nptl/tss_delete.c b/sysdeps/pthread/tss_delete.c similarity index 100% rename from nptl/tss_delete.c rename to sysdeps/pthread/tss_delete.c diff --git a/nptl/tss_get.c b/sysdeps/pthread/tss_get.c similarity index 100% rename from nptl/tss_get.c rename to sysdeps/pthread/tss_get.c diff --git a/nptl/tss_set.c b/sysdeps/pthread/tss_set.c similarity index 100% rename from nptl/tss_set.c rename to sysdeps/pthread/tss_set.c diff --git a/nptl/tst-call-once.c b/sysdeps/pthread/tst-call-once.c similarity index 100% rename from nptl/tst-call-once.c rename to sysdeps/pthread/tst-call-once.c diff --git a/nptl/tst-cnd-basic.c b/sysdeps/pthread/tst-cnd-basic.c similarity index 100% rename from nptl/tst-cnd-basic.c rename to sysdeps/pthread/tst-cnd-basic.c diff --git a/nptl/tst-cnd-broadcast.c b/sysdeps/pthread/tst-cnd-broadcast.c similarity index 100% rename from nptl/tst-cnd-broadcast.c rename to sysdeps/pthread/tst-cnd-broadcast.c diff --git a/nptl/tst-cnd-timedwait.c b/sysdeps/pthread/tst-cnd-timedwait.c similarity index 100% rename from nptl/tst-cnd-timedwait.c rename to sysdeps/pthread/tst-cnd-timedwait.c diff --git a/nptl/tst-mtx-basic.c b/sysdeps/pthread/tst-mtx-basic.c similarity index 100% rename from nptl/tst-mtx-basic.c rename to sysdeps/pthread/tst-mtx-basic.c diff --git a/nptl/tst-mtx-recursive.c b/sysdeps/pthread/tst-mtx-recursive.c similarity index 100% rename from nptl/tst-mtx-recursive.c rename to sysdeps/pthread/tst-mtx-recursive.c diff --git a/nptl/tst-mtx-timedlock.c b/sysdeps/pthread/tst-mtx-timedlock.c similarity index 100% rename from nptl/tst-mtx-timedlock.c rename to sysdeps/pthread/tst-mtx-timedlock.c diff --git a/nptl/tst-mtx-trylock.c b/sysdeps/pthread/tst-mtx-trylock.c similarity index 100% rename from nptl/tst-mtx-trylock.c rename to sysdeps/pthread/tst-mtx-trylock.c diff --git a/nptl/tst-thrd-detach.c b/sysdeps/pthread/tst-thrd-detach.c similarity index 100% rename from nptl/tst-thrd-detach.c rename to sysdeps/pthread/tst-thrd-detach.c diff --git a/nptl/tst-thrd-sleep.c b/sysdeps/pthread/tst-thrd-sleep.c similarity index 100% rename from nptl/tst-thrd-sleep.c rename to sysdeps/pthread/tst-thrd-sleep.c diff --git a/nptl/tst-tss-basic.c b/sysdeps/pthread/tst-tss-basic.c similarity index 100% rename from nptl/tst-tss-basic.c rename to sysdeps/pthread/tst-tss-basic.c