From patchwork Fri Sep 22 20:26:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 114090 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp3473659edb; Fri, 22 Sep 2017 13:27:39 -0700 (PDT) X-Received: by 10.99.117.81 with SMTP id f17mr306707pgn.314.1506112059266; Fri, 22 Sep 2017 13:27:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506112059; cv=none; d=google.com; s=arc-20160816; b=GPec4RT8XXnwj9Z5NKNrA2+UCn4vlFjZDZNV3zEw50nudpxQM3TU92LMVFli4QtR7e WMBvm1exRN6GaWYJpBuSEpnImAa+kICZOCq+FLirq2qFnT4Clfij1zCJdKv8TXS2mbWQ tX7ZH95uuaJX5u05ymldXlvgsIT7wpeBUpv2uU7bDvCLTv9WmuFqW87FlT4myQeONKh5 zLJsbC1Z083IedHwbiAKDPk7yRpwio7niGsRKUSL8qulrRMy/WxD8jhPIsW89OAzfSAo 9/lqxyVnRX6trAh9rNA9xmMBzyBncmYgEi7YdLq1WIZKI318dQ52pMAHj4cln9siwF9E VaLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=1GXfV7+fvees1p1zROHg7jrSljERKpLwOTkfFqApNEU=; b=nekbFFN4JArrdNHLsvbyd7p3UwHm8oNoD8+A76kMhCVZ4lCLPD9285WSdLdeiPXuy+ fEpFhYO5eBuDGIJgxtdraIVGAzsZWet/gz+wJfGX3QoSuDXlwfaW8+ZKk8pQgfG4A505 RO9uI1mc949xngH37+N5RdBYnuc+B3g8CI9m4P/WHiuNJi6LuCrm82SeA96RXgh9QnJQ 1bRajDJw3Rg2AoH9maJcxnV+B1KdvmrIw5hdO+0p0G1zm4D3r+pTBQdSX1RLeDqIWTTC YygYEipJdBt93CA8bdkJhcukGEDfcJanihk08G2wpsDMdIkj5yitjoKh9VOoopa22CTp whbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=sovy54uJ; spf=pass (google.com: domain of libc-alpha-return-84874-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-84874-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 6si330114pld.790.2017.09.22.13.27.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Sep 2017 13:27:39 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-84874-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=sovy54uJ; spf=pass (google.com: domain of libc-alpha-return-84874-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-84874-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=HFkjDvsSfWPNopHTh+z+y6a2MDAla6R RJ6k63RNWWx266On5ceQ8k4oWR83gtaRlyNdms2+shpqAEChOwoojkJ9AF/lFAzl X4aJ+LaytrPwe/wYuvfOEaj04B/iPhpgt2oovm1yjkjy+ETIvFc3LaysM1Bfbu23 PykSrwq7+ZKY= 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:subject:date:message-id:in-reply-to :references; s=default; bh=axGVktEMVS7PGmcrcjGyblikYdA=; b=sovy5 4uJGOS1ap+jhXTgeHAIQpO5faHr8/tzb7wdGjiMhQgN1bgn2bAYQR7RRqggBW+md ehhlSOgbW9THpd2vOPv5+f+IB1Xl3oz9lHjeD71AjNqDvzj7RCDjEdI7DO9CUTti ZSoqoan2AqANv++2giHpWg3/deXpBghPHIPuYI= Received: (qmail 65893 invoked by alias); 22 Sep 2017 20:27:20 -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 65830 invoked by uid 89); 22 Sep 2017 20:27:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=cancellation X-HELO: mail-qt0-f175.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=1GXfV7+fvees1p1zROHg7jrSljERKpLwOTkfFqApNEU=; b=mTcqduvrIkzzR2XjFCoRYhD9DMUq8/cSiTudYvft7EPmWwoS7CuW/ut+k8PT/caV23 QuHtyHuMOVn8ZIG7ObCY6CHXzoU6kOwog9MYj+UFcupLWcIVWZz0vHqBtDfvyTLJUrFy vSXp/emglUSas6pFoIgJKUVsLt3ToWxSaZG446z/fn2Q32amNhq3J18nGq5sjwmFB7Uq fuZgCsxOPylTE8EIF7UqlY2YYZFHwgi7bOHEj7kYFIoRMImat/SRmLlZ/tyBFTvc6wLY kjORWi5KKYxf5LutYZfFa1ioaZjAxrZnvP7SVk30etOELVra3XRlVhYJA1Ww5nwUQIiG J+fA== X-Gm-Message-State: AHPjjUjdIPcd6+KXVcwcJBG5MM1HzFge3+r/8GKLkGYuUBHNG/E/rciH uVsjV/mhBazCnHVUOBeqTM3A16XhVV0= X-Google-Smtp-Source: AOwi7QByxciOZABWz0KsoiaZ2K7SNPccoaFb7ybZCZVCH/6eTilx3SPKHkh9k7BOkdBDBuoRmOAzxg== X-Received: by 10.237.42.79 with SMTP id k15mr624421qtf.222.1506112033148; Fri, 22 Sep 2017 13:27:13 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 1/8] nptl: Add C11 threads thrd_* functions Date: Fri, 22 Sep 2017 17:26:57 -0300 Message-Id: <1506112024-22601-2-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1506112024-22601-1-git-send-email-adhemerval.zanella@linaro.org> References: <1506112024-22601-1-git-send-email-adhemerval.zanella@linaro.org> This patch adds the thrd_* definitions from C11 threads (ISO/IEC 9899:2011), more specifically thrd_create, thrd_curent, rhd_detach, thrd_equal, thrd_exit, thrd_join, thrd_sleep, thrd_yield, and required types. Mostly of the definitions are composed based on POSIX conterparts, such as thrd_t (using pthread_t). For thrd_* function internally direct POSIX pthread call are used with the exceptions: 1. thrd_start uses pthread_create internal implementation, but changes how to actually calls the start routine. This is due the difference in signature between POSIX and C11, where former return a 'void *' and latter 'int'. To avoid calling convention issues due 'void *' to int cast, routines from C11 threads are started slight different than default pthread one. Explicit cast to expected return are used internally on pthread_create and the result is stored back to void also with an explicit cast. 2. thrd_sleep uses nanosleep internal direct syscall to avoid clobbering errno, to handle expected standard return codes, and to avoid making the call a POSIX cancellation entrypoint. 3. thrd_yield also uses internal direct syscall to avoid errno clobbering. Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu, arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu, microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu, powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu, tile{pro,gx}-linux-gnu, and x86_64-linux-gnu). Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu, arm-linux-gnueabhf, and powerpc64le-linux-gnu. * conform/Makefile (conformtest-headers-ISO11): Add threads.h. (linknamespace-libs-ISO11): Add libpthread.a. * conform/data/threads.h-data: New file: add C11 thrd_* types and functions. * include/stdc-predef.h (__STDC_NO_THREADS__): Remove definition. * nptl/Makefile (headers): Add threads.h. (libpthread-routines): Add new C11 thread thrd_create, thrd_current, thrd_detach, thrd_equal, thrd_exit, thrd_join, thrd_sleep, and thrd_yield. * nptl/Versions (libpthread) [GLIBC_2.27]): Add new C11 thread thrd_create, thrd_current, thrd_detach, thrd_equal, thrd_exit, thrd_join, thrd_sleep, and thrd_yield symbols. * nptl/descr.h (struct pthread): Add c11 field. * nptl/pthreadP.h (ATTR_C11_THREAD): New define. * nptl/pthread_create.c (START_THREAD_DEFN): Call C11 thread start routine with expected function prototype. (__pthread_create_2_1): Add C11 threads check based on attribute value. * nptl/thrd_create.c: New file. * nptl/thrd_current.c: Likewise. * nptl/thrd_detach.c: Likewise. * nptl/thrd_equal.c: Likewise. * nptl/thrd_exit.c: Likewise. * nptl/thrd_join.c: Likewise. * nptl/thrd_priv.h: Likewise. * nptl/thrd_sleep.c: Likewise. * nptl/thrd_yield.c: Likewise. * sysdeps/nptl/threads.h: Likewise. --- ChangeLog | 31 ++++++++++++++++ conform/Makefile | 7 ++-- conform/data/threads.h-data | 23 ++++++++++++ include/stdc-predef.h | 3 -- nptl/Makefile | 6 ++- nptl/Versions | 6 +++ nptl/descr.h | 2 + nptl/pthreadP.h | 3 ++ nptl/pthread_create.c | 18 ++++++++- nptl/thrd_create.c | 32 ++++++++++++++++ nptl/thrd_current.c | 26 +++++++++++++ nptl/thrd_detach.c | 30 +++++++++++++++ nptl/thrd_equal.c | 26 +++++++++++++ nptl/thrd_exit.c | 27 ++++++++++++++ nptl/thrd_join.c | 32 ++++++++++++++++ nptl/thrd_priv.h | 46 +++++++++++++++++++++++ nptl/thrd_sleep.c | 41 +++++++++++++++++++++ nptl/thrd_yield.c | 29 +++++++++++++++ sysdeps/nptl/threads.h | 90 +++++++++++++++++++++++++++++++++++++++++++++ 19 files changed, 468 insertions(+), 10 deletions(-) create mode 100644 conform/data/threads.h-data create mode 100644 nptl/thrd_create.c create mode 100644 nptl/thrd_current.c create mode 100644 nptl/thrd_detach.c create mode 100644 nptl/thrd_equal.c create mode 100644 nptl/thrd_exit.c create mode 100644 nptl/thrd_join.c create mode 100644 nptl/thrd_priv.h create mode 100644 nptl/thrd_sleep.c create mode 100644 nptl/thrd_yield.c create mode 100644 sysdeps/nptl/threads.h -- 2.7.4 diff --git a/conform/Makefile b/conform/Makefile index 3883a4b..9e00d41 100644 --- a/conform/Makefile +++ b/conform/Makefile @@ -34,9 +34,9 @@ conformtest-headers-ISO := assert.h ctype.h errno.h float.h limits.h locale.h \ conformtest-headers-ISO99 := $(conformtest-headers-ISO) complex.h fenv.h \ inttypes.h iso646.h stdbool.h stdint.h tgmath.h \ wchar.h wctype.h -# Missing ISO11 expectations for: stdatomic.h threads.h. +# Missing ISO11 expectations for: stdatomic.h conformtest-headers-ISO11 := $(conformtest-headers-ISO99) stdalign.h \ - stdnoreturn.h uchar.h + stdnoreturn.h threads.h uchar.h conformtest-headers-POSIX := $(conformtest-headers-ISO) aio.h dirent.h \ fcntl.h fnmatch.h glob.h grp.h mqueue.h \ pthread.h pwd.h regex.h sched.h semaphore.h \ @@ -197,7 +197,8 @@ linknamespace-libs-xsi = $(linknamespace-libs-posix) \ $(common-objpfx)crypt/libcrypt.a linknamespace-libs-ISO = $(linknamespace-libs-isoc) linknamespace-libs-ISO99 = $(linknamespace-libs-isoc) -linknamespace-libs-ISO11 = $(linknamespace-libs-isoc) +linknamespace-libs-ISO11 = $(linknamespace-libs-isoc) \ + $(common-objpfx)nptl/libpthread.a linknamespace-libs-XPG4 = $(linknamespace-libs-isoc) \ $(common-objpfx)crypt/libcrypt.a linknamespace-libs-XPG42 = $(linknamespace-libs-XPG4) diff --git a/conform/data/threads.h-data b/conform/data/threads.h-data new file mode 100644 index 0000000..bc2d857 --- /dev/null +++ b/conform/data/threads.h-data @@ -0,0 +1,23 @@ +#if defined ISO11 + +constant thrd_success +constant thrd_busy +constant thrd_error +constant thrd_nomem +constant thrd_timedout + +type thrd_t +type thrd_start_t + +function int thrd_create (thrd_t*, thrd_start_t, void*) +function int thrd_equal (thrd_t, thrd_t) +function thrd_t thrd_current (void) +function int thrd_sleep (const struct timespec*, struct timespec*) +function void thrd_exit (int) +function int thrd_detach (thrd_t) +function int thrd_join (thrd_t, int*) +function void thrd_yield (void) + +#include "time.h-data" + +#endif diff --git a/include/stdc-predef.h b/include/stdc-predef.h index 74ade90..1cd3d73 100644 --- a/include/stdc-predef.h +++ b/include/stdc-predef.h @@ -57,7 +57,4 @@ - 3 additional Zanabazar Square characters */ #define __STDC_ISO_10646__ 201706L -/* We do not support C11 . */ -#define __STDC_NO_THREADS__ 1 - #endif diff --git a/nptl/Makefile b/nptl/Makefile index d819349..31761a6 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -22,7 +22,7 @@ subdir := nptl include ../Makeconfig -headers := pthread.h semaphore.h bits/semaphore.h +headers := pthread.h semaphore.h bits/semaphore.h threads.h extra-libs := libpthread extra-libs-others := $(extra-libs) @@ -138,7 +138,9 @@ libpthread-routines = nptl-init vars events version pt-interp \ pthread_mutex_getprioceiling \ pthread_mutex_setprioceiling \ pthread_setname pthread_getname \ - pthread_setattr_default_np pthread_getattr_default_np + pthread_setattr_default_np pthread_getattr_default_np \ + thrd_create thrd_current thrd_detach thrd_equal \ + thrd_exit thrd_join thrd_sleep thrd_yield # pthread_setuid pthread_seteuid pthread_setreuid \ # pthread_setresuid \ # pthread_setgid pthread_setegid pthread_setregid \ diff --git a/nptl/Versions b/nptl/Versions index 0ae5def..a282ceb 100644 --- a/nptl/Versions +++ b/nptl/Versions @@ -265,6 +265,12 @@ libpthread { GLIBC_2.22 { } + # C11 thread symbols. + GLIBC_2.27 { + thrd_create; thrd_current; thrd_detach; thrd_equal; thrd_exit; thrd_join; + thrd_sleep; thrd_yield; + } + GLIBC_PRIVATE { __pthread_initialize_minimal; __pthread_clock_gettime; __pthread_clock_settime; diff --git a/nptl/descr.h b/nptl/descr.h index c5ad0c8..c1ff711 100644 --- a/nptl/descr.h +++ b/nptl/descr.h @@ -371,6 +371,8 @@ struct pthread to the function. */ void *(*start_routine) (void *); void *arg; + /* Indicates whether is a C11 thread created by thrd_creat. */ + bool c11; /* Debug state. */ td_eventbuf_t eventbuf; diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index dbf46b0..ded7547 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -173,6 +173,9 @@ enum #define __PTHREAD_ONCE_DONE 2 #define __PTHREAD_ONCE_FORK_GEN_INCR 4 +/* Attribute to indicate thread creation was issued from C11 thrd_create. */ +#define ATTR_C11_THREAD ((void*)(uintptr_t)-1) + /* Condition variable definitions. See __pthread_cond_wait_common. Need to be defined here so there is one place from which diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index 992331e..bef3042 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -460,7 +460,19 @@ START_THREAD_DEFN LIBC_PROBE (pthread_start, 3, (pthread_t) pd, pd->start_routine, pd->arg); /* Run the code the user provided. */ - THREAD_SETMEM (pd, result, pd->start_routine (pd->arg)); + void *ret; + if (pd->c11) + { + /* The function pointer of the c11 thread start is cast to an incorrect + type on __pthread_create_2_1 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*)) pd->start_routine; + ret = (void*) (intptr_t) start (pd->arg); + } + else + ret = pd->start_routine (pd->arg); + THREAD_SETMEM (pd, result, ret); } /* Call destructors for the thread_local TLS variables. */ @@ -613,7 +625,8 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr, const struct pthread_attr *iattr = (struct pthread_attr *) attr; struct pthread_attr default_attr; bool free_cpuset = false; - if (iattr == NULL) + bool c11 = (attr == ATTR_C11_THREAD); + if (iattr == NULL || c11) { lll_lock (__default_pthread_attr_lock, LLL_PRIVATE); default_attr = __default_pthread_attr; @@ -671,6 +684,7 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr, get the information from its thread descriptor. */ pd->start_routine = start_routine; pd->arg = arg; + pd->c11 = c11; /* Copy the thread attribute flags. */ struct pthread *self = THREAD_SELF; diff --git a/nptl/thrd_create.c b/nptl/thrd_create.c new file mode 100644 index 0000000..0b6b822 --- /dev/null +++ b/nptl/thrd_create.c @@ -0,0 +1,32 @@ +/* C11 threads thread creation implementation. + Copyright (C) 2017 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" + +/* Create a new thread executing the function func. Arguments to func + are passed through arg. If succesful, thr is set to new thread + identifier. */ +int +thrd_create (thrd_t *thr, thrd_start_t func, void *arg) +{ + _Static_assert (sizeof (thr) == sizeof (pthread_t), "thrd_t size"); + + int err_code = __pthread_create_2_1 (thr, ATTR_C11_THREAD, + (void* (*) (void*))func, arg); + return thrd_err_map (err_code); +} diff --git a/nptl/thrd_current.c b/nptl/thrd_current.c new file mode 100644 index 0000000..7269d4b --- /dev/null +++ b/nptl/thrd_current.c @@ -0,0 +1,26 @@ +/* C11 threads current thread implementation. + Copyright (C) 2017 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" + +/* Return current thread identifier. */ +thrd_t +thrd_current (void) +{ + return __pthread_self (); +} diff --git a/nptl/thrd_detach.c b/nptl/thrd_detach.c new file mode 100644 index 0000000..187d078 --- /dev/null +++ b/nptl/thrd_detach.c @@ -0,0 +1,30 @@ +/* C11 threads thread detach implementation. + Copyright (C) 2017 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" + +/* Detache the thread identified by thr from the current environment. + It does not allow join or wait for the thread. */ +int +thrd_detach (thrd_t thr) +{ + int err_code; + + err_code = __pthread_detach (thr); + return thrd_err_map (err_code); +} diff --git a/nptl/thrd_equal.c b/nptl/thrd_equal.c new file mode 100644 index 0000000..fcda488 --- /dev/null +++ b/nptl/thrd_equal.c @@ -0,0 +1,26 @@ +/* C11 threads thread equality check implementation. + Copyright (C) 2017 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" + +/* Check if lhs and rhs point to the same thread. */ +int +thrd_equal (thrd_t lhs, thrd_t rhs) +{ + return __pthread_equal (lhs, rhs); +} diff --git a/nptl/thrd_exit.c b/nptl/thrd_exit.c new file mode 100644 index 0000000..a49d8e0 --- /dev/null +++ b/nptl/thrd_exit.c @@ -0,0 +1,27 @@ +/* C11 threads thread exit implementation. + Copyright (C) 2017 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" + +/* Terminate current thread execution, cleaning up any thread local + storage and freeing resources. Returns the value specified in res. */ +_Noreturn void +thrd_exit (int res) +{ + __pthread_exit ((void*)(uintptr_t) res); +} diff --git a/nptl/thrd_join.c b/nptl/thrd_join.c new file mode 100644 index 0000000..1d69918 --- /dev/null +++ b/nptl/thrd_join.c @@ -0,0 +1,32 @@ +/* C11 threads thread join implementation. + Copyright (C) 2017 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" + +/* Block current thread until execution of thr is complete. In case that + res is not NULL, will store the return value of thr when exiting. */ +int +thrd_join (thrd_t thr, int *res) +{ + void *pthread_res; + int err_code = __pthread_join (thr, &pthread_res); + if (res) + *res = (int)((uintptr_t) pthread_res); + + return thrd_err_map (err_code); +} diff --git a/nptl/thrd_priv.h b/nptl/thrd_priv.h new file mode 100644 index 0000000..a431d60 --- /dev/null +++ b/nptl/thrd_priv.h @@ -0,0 +1,46 @@ +/* Internal C11 threads definitions. + Copyright (C) 2017 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 THRD_PRIV_H +# define THRD_PRIV_H + +#include +#include +#include +#include "pthreadP.h" /* For pthread_{mutex,cond}_t definitions. */ + +/* Maps pthread error codes with thrd error codes. */ +static __always_inline int +thrd_err_map (int err_code) +{ + switch (err_code) + { + case 0: + return thrd_success; + case ENOMEM: + return thrd_nomem; + case ETIMEDOUT: + return thrd_timedout; + case EBUSY: + return thrd_busy; + default: + return thrd_error; + } +} + +#endif diff --git a/nptl/thrd_sleep.c b/nptl/thrd_sleep.c new file mode 100644 index 0000000..a49fdc4 --- /dev/null +++ b/nptl/thrd_sleep.c @@ -0,0 +1,41 @@ +/* C11 threads thread sleep implementation. + Copyright (C) 2017 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" +#include + +/* Block current thread execution for at least the time pointed by time_point. + The current thread may resume if receives a signal. In that case, if + remaining is not NULL, the remaining time is stored in the object pointed + by it. */ +int +thrd_sleep (const struct timespec* time_point, struct timespec* remaining) +{ + INTERNAL_SYSCALL_DECL (err); + int ret = INTERNAL_SYSCALL_CALL (nanosleep, err, time_point, remaining); + if (INTERNAL_SYSCALL_ERROR_P (ret, err)) + { + /* C11 states thrd_sleep function returns -1 if it has been interrupted + by a signal, or a negative value if it fails. */ + ret = INTERNAL_SYSCALL_ERRNO (ret, err); + if (ret == EINTR) + return -1; + return -2; + } + return 0; +} diff --git a/nptl/thrd_yield.c b/nptl/thrd_yield.c new file mode 100644 index 0000000..13a02f3 --- /dev/null +++ b/nptl/thrd_yield.c @@ -0,0 +1,29 @@ +/* C11 threads thread yield implementation. + Copyright (C) 2017 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" + +/* Stop current thread execution and call the scheduler to decide which + thread should execute next. The current thread may be selected by the + scheduler to keep running. */ +void +thrd_yield (void) +{ + INTERNAL_SYSCALL_DECL (err); + INTERNAL_SYSCALL_CALL (sched_yield, err); +} diff --git a/sysdeps/nptl/threads.h b/sysdeps/nptl/threads.h new file mode 100644 index 0000000..4b89a30 --- /dev/null +++ b/sysdeps/nptl/threads.h @@ -0,0 +1,90 @@ +/* ISO C11 Standard: 7.26 - Thread support library . + Copyright (C) 2017 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 _THREADS_H +#define _THREADS_H 1 + +#include +#include + +__BEGIN_DECLS + +#include + +typedef unsigned long int thrd_t; +typedef int (*thrd_start_t) (void*); + +/* Exit and error codes. */ +enum +{ + thrd_success = 0, + thrd_busy = 1, + thrd_error = 2, + thrd_nomem = 3, + thrd_timedout = 4 +}; + +/* Threads functions. */ + +/* Create a new thread executing the function __func. Arguments to __func + are passed through __arg. If succesful, __thr is set to new thread + identifier. */ +extern int thrd_create (thrd_t *__thr, thrd_start_t __func, void *__arg); + +/* Check if __lhs and __rhs point to the same thread. */ +extern int thrd_equal (thrd_t __lhs, thrd_t __rhs); + +/* Return current thread identifier. */ +extern thrd_t thrd_current (void); + +/* Block current thread execution for at least the time pointed by + __time_point. The current thread may resume if receives a signal. In + that case, if __remaining is not NULL, the remaining time is stored in + the object pointed by it. */ +extern int thrd_sleep (const struct timespec *__time_point, + struct timespec *__remaining); + +/* Terminate current thread execution, cleaning up any thread local + storage and freeing resources. Returns the value specified in __res. */ +extern void thrd_exit (int __res) __attribute__ ((__noreturn__)); + +/* Detache the thread identified by __thr from the current environment. + It does not allow join or wait for __thr. */ +extern int thrd_detach (thrd_t __thr); + +/* Block current thread until execution of __thr is complete. In case that + __res is not NULL, will store the return value of __thr when exiting. */ +extern int thrd_join (thrd_t __thr, int *__res); + +/* Stop current thread execution and call the scheduler to decide which + thread should execute next. The current thread may be selected by the + scheduler to keep running. */ +extern void thrd_yield (void); + +#ifdef __USE_EXTERN_INLINES +/* Optimizations. */ +__extern_inline int +thrd_equal (thrd_t __thread1, thrd_t __thread2) +{ + return __thread1 == __thread2; +} +#endif + +__END_DECLS + +#endif /* _THREADS_H */ From patchwork Fri Sep 22 20:26:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 114091 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp3473766edb; Fri, 22 Sep 2017 13:27:48 -0700 (PDT) X-Received: by 10.101.81.1 with SMTP id f1mr313611pgq.204.1506112068359; Fri, 22 Sep 2017 13:27:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506112068; cv=none; d=google.com; s=arc-20160816; b=CVvx8XZ17AnTHNDzU21BKTaiyhocBRFIuYvx022JXpNeSY4AdaRcP7Min1pmIk7p+I XJgSo6P4N74ebhnL6WOVbxX1P6ZIFTbK/lK7qmHc/36WT/I+PlvK2GDOYokdapbr8qNA I9E7TdjJQKerx8j3pl1LJ8ddxX9tcj8Nn6JQ+N/xxErkkEVr3ouhd96HUxUW628BhEhA CGTUXuKjEMJOuevye3Ay4IGRB26hVeY1dXNehg+X0WwGWwGFCsUBH9LPpIKHpCrz9Upj 6jvBH5dUPga3e028RPKiY0Kw68YlZq9rf5K/rjQjhw9pd8T7OVzyJnfKhre6OCNs9woI qSWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=Kv62uBou1JeU/l1U9IFZ4uQ2l8+uhdlle++NCjKX9lA=; b=f/8PqFi0Em001k5ZkO+09PhqUxLIFkIfd6pSsV/xl/RSSVk0ob5ybo1LmgNZEqNdHW Dd9QAnN52LAnFi/SLU0O+fbrQ1qMWr39jVcHQ29bUCHeTOpKKyn8UicFzSpB+1SKY7Yj 6f7yqMDIJr36bEs2kBxHBQ6tepb/rd6zFZZvPiidxWtp9KRfCo7Rd9teur0lqHEOIoIB fO5nG2c7Xz6H4NWsng7Vpp+QUcyoI7GjabptRsFmdaDduLGlHaP6rWpYWHOSoglziNSS RCX01RFrXg4e16Kv6DTMKMF+Jh4Yy9IZik+8nPgELslVyhItWmwZKcaATCKdWyaCdqMY CfAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=fFBSGJXx; spf=pass (google.com: domain of libc-alpha-return-84875-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-84875-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id l22si324787pfk.589.2017.09.22.13.27.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Sep 2017 13:27:48 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-84875-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=fFBSGJXx; spf=pass (google.com: domain of libc-alpha-return-84875-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-84875-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=h/4NEXpy6I1V3ZKtPJsygKyJTIh57t0 ttZKST+DL7GAZOIOAeii/bBVSl3YxSeUEow4hBV4H74rQGOY8N2JIm7ROKQNEoFu FtSovDayEzoFLHsksigQLMPh70/Tehg7Fwj80BuHECMswwkXZml5Av6ysJEwHvzc YGNhqfGMk2Qs= 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:subject:date:message-id:in-reply-to :references; s=default; bh=JGO/TCz87FI0EaMaBGCKCDpKEFQ=; b=fFBSG JXxC+II9JGwPYBroLDNkf9sb0UIoNEVACkUYG6HmqYrGfZsQJw1ORKcvP47eA7oM d/gYDqIt9mK8AwZ0/dhrbkfbWly14JJC/2U0YQ2egQsflszsaDSyZ43UIPiXHp3/ L/FJqJ15St0ummRdtHjZ5DEh3Hw1YSiB1UERW8= Received: (qmail 65926 invoked by alias); 22 Sep 2017 20:27:20 -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 65859 invoked by uid 89); 22 Sep 2017 20:27:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f174.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Kv62uBou1JeU/l1U9IFZ4uQ2l8+uhdlle++NCjKX9lA=; b=ISHMGFiVcy7SliB54bchI59DTdH47F4eIeZ/yqp/686DBahmUYT/5V47C/u0N2KEeU o7RB7FWhHexnkqTVWNO3S4bFEfYr08qnokdQ2fMVrUIubV9XWzcdskBfygF6o8qAiutV fXGDXF5vXVyX96tueHop9L45yOcxEWeYf0FK/rHElT2Xvi5CiRA1cOxAS6QeCVxtuZFf 7FtYB81dpJrIdeJtWpIXAZ6gERpBbvwQ536BYbJknPTQkM1pYWQEnC8q0ELdtzIYkl3q sDzS9OsWI7mcLnWllQqkyQMMtlkqBdK1M5XB6qfzKrf8DYsXbrL/LQwaeim3N17jwgSh plww== X-Gm-Message-State: AHPjjUgV2jTGJepwRWUIRtLPh9VFYSAva984uAhOel3q2O9Fn9uiDEeR yl59bpsr/KbFnXScwXmRTSvfr27T4XA= X-Google-Smtp-Source: AOwi7QBBgB1ATirIYt+KVazjEpMhG1rw8lvBkCxl3c/buxQE0pQ4wda/WxTV6tUzWyWv5d6bl1fTHA== X-Received: by 10.200.38.110 with SMTP id v43mr614915qtv.296.1506112034857; Fri, 22 Sep 2017 13:27:14 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 2/8] nptl: Add C11 threads mtx_* functions Date: Fri, 22 Sep 2017 17:26:58 -0300 Message-Id: <1506112024-22601-3-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1506112024-22601-1-git-send-email-adhemerval.zanella@linaro.org> References: <1506112024-22601-1-git-send-email-adhemerval.zanella@linaro.org> This patch adds the mtx_* definitions from C11 threads (ISO/IEC 9899:2011), more specifically mtx_init, mtx_destroy, mtx_lock, mtx_timedlock, mtx_trylock, mtx_unlock, and required types. Mostly of the definitions are composed based on POSIX conterparts, and mtx_t is also based on internal pthread fields, but with a distinct internal layout to avoid possible issues with code interchange (such as trying to pass POSIX structure on C11 functions and to avoid inclusion of pthread.h). The idea is to make possible to share POSIX internal implementations for mostly of the code (and making adjustment only when required). Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu, arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu, microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu, powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu, tile{pro,gx}-linux-gnu, and x86_64-linux-gnu). Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu, arm-linux-gnueabhf, and powerpc64le-linux-gnu. * conform/data/threads.h-data (mtx_plain): New constant. (mtx_recursive): Likewise. (mtx_timed): Likewise. (mtx_t): New type. (mtx_init): New function. (mtx_lock): Likewise. (mtx_timedlock): Likewise. (mtx_trylock): Likewise. (mtx_unlock): Likewise. (mtx_destroy): Likewise. * nptl/Makefile (libpthread-routines): Add mtx_destroy, mtx_init, mtx_lock, mtx_timedlock, mtx_trylock, and mtx_unlock object. * nptl/Versions (libpthread) [GLIBC_2.27]): Add mtx_init, mtx_lock, mtx_timedlock, mtx_trylock, mtx_unlock, and mtx_destroy. * nptl/mtx_destroy.c: New file. * nptl/mtx_init.c: Likewise. * nptl/mtx_lock.c: Likewise. * nptl/mtx_timedlock.c: Likewise. * nptl/mtx_trylock.c: Likewise. * nptl/mtx_unlock.c: Likewise. * sysdeps/nptl/threads.h (mtx_plain): New enumeration. (mtx_recursive): Likewise. (mtx_timed): Likewise. (mtx_t): New type. (mtx_init): New prototype. (mtx_lock): Likewise. (mtx_timedlock): Likewise. (mtx_trylock): Likewise. (mtx_unlock): Likewise. (mtx_destroy): Likewise. --- ChangeLog | 31 ++++++++++++++++++++++++++ conform/data/threads.h-data | 12 ++++++++++ nptl/Makefile | 4 +++- nptl/Versions | 3 ++- nptl/mtx_destroy.c | 27 +++++++++++++++++++++++ nptl/mtx_init.c | 54 +++++++++++++++++++++++++++++++++++++++++++++ nptl/mtx_lock.c | 28 +++++++++++++++++++++++ nptl/mtx_timedlock.c | 31 ++++++++++++++++++++++++++ nptl/mtx_trylock.c | 29 ++++++++++++++++++++++++ nptl/mtx_unlock.c | 28 +++++++++++++++++++++++ sysdeps/nptl/threads.h | 44 ++++++++++++++++++++++++++++++++++++ 11 files changed, 289 insertions(+), 2 deletions(-) create mode 100644 nptl/mtx_destroy.c create mode 100644 nptl/mtx_init.c create mode 100644 nptl/mtx_lock.c create mode 100644 nptl/mtx_timedlock.c create mode 100644 nptl/mtx_trylock.c create mode 100644 nptl/mtx_unlock.c -- 2.7.4 diff --git a/conform/data/threads.h-data b/conform/data/threads.h-data index bc2d857..bb5ca75 100644 --- a/conform/data/threads.h-data +++ b/conform/data/threads.h-data @@ -6,8 +6,13 @@ constant thrd_error constant thrd_nomem constant thrd_timedout +constant mtx_plain +constant mtx_recursive +constant mtx_timed + type thrd_t type thrd_start_t +type mtx_t function int thrd_create (thrd_t*, thrd_start_t, void*) function int thrd_equal (thrd_t, thrd_t) @@ -18,6 +23,13 @@ function int thrd_detach (thrd_t) function int thrd_join (thrd_t, int*) function void thrd_yield (void) +function int mtx_init (mtx_t*, int) +function int mtx_lock (mtx_t*) +function int mtx_timedlock (mtx_t*, const struct timespec*) +function int mtx_trylock (mtx_t*) +function int mtx_unlock (mtx_t*) +function void mtx_destroy (mtx_t*) + #include "time.h-data" #endif diff --git a/nptl/Makefile b/nptl/Makefile index 31761a6..c4f6970 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -140,7 +140,9 @@ libpthread-routines = nptl-init vars events version pt-interp \ pthread_setname pthread_getname \ pthread_setattr_default_np pthread_getattr_default_np \ thrd_create thrd_current thrd_detach thrd_equal \ - thrd_exit thrd_join thrd_sleep thrd_yield + thrd_exit thrd_join thrd_sleep thrd_yield \ + mtx_destroy mtx_init mtx_lock mtx_timedlock \ + mtx_trylock mtx_unlock # pthread_setuid pthread_seteuid pthread_setreuid \ # pthread_setresuid \ # pthread_setgid pthread_setegid pthread_setregid \ diff --git a/nptl/Versions b/nptl/Versions index a282ceb..5cf581a 100644 --- a/nptl/Versions +++ b/nptl/Versions @@ -268,7 +268,8 @@ libpthread { # C11 thread symbols. GLIBC_2.27 { thrd_create; thrd_current; thrd_detach; thrd_equal; thrd_exit; thrd_join; - thrd_sleep; thrd_yield; + thrd_sleep; thrd_yield; mtx_init; mtx_lock; mtx_timedlock; mtx_trylock; + mtx_unlock; mtx_destroy; } GLIBC_PRIVATE { diff --git a/nptl/mtx_destroy.c b/nptl/mtx_destroy.c new file mode 100644 index 0000000..1fcc534 --- /dev/null +++ b/nptl/mtx_destroy.c @@ -0,0 +1,27 @@ +/* C11 threads mutex destroy implementation. + Copyright (C) 2017 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" +#include "pthreadP.h" + +/* Destroy the mutex object pointed by mutex. */ +void +mtx_destroy (mtx_t *mutex) +{ + __pthread_mutex_destroy ((pthread_mutex_t *) mutex); +} diff --git a/nptl/mtx_init.c b/nptl/mtx_init.c new file mode 100644 index 0000000..da27156 --- /dev/null +++ b/nptl/mtx_init.c @@ -0,0 +1,54 @@ +/* C11 threads mutex initialization implementation. + Copyright (C) 2017 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" + +/* Creates a new mutex object with type type. If successful the new object + is pointed by mutex. */ +int +mtx_init (mtx_t *mutex, int type) +{ + _Static_assert (sizeof (mtx_t) == sizeof (pthread_mutex_t), "mtx_t size"); + _Static_assert (alignof (mtx_t) == alignof (pthread_mutex_t), + "mtx_t alignment"); + + pthread_mutexattr_t attr; + + __pthread_mutexattr_init (&attr); + + /* Another possible solution would be to set the flags directly in + mutex object. */ + switch (type) + { + case mtx_plain | mtx_recursive: + case mtx_timed | mtx_recursive: + __pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); + break; + case mtx_plain: + case mtx_timed: /* No difference between both in standard */ + default: + __pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_NORMAL); + break; + } + + int err_code = __pthread_mutex_init ((pthread_mutex_t *) mutex, &attr); + /* pthread_mutexattr_destroy implementation is a noop. */ + return thrd_err_map (err_code); +} diff --git a/nptl/mtx_lock.c b/nptl/mtx_lock.c new file mode 100644 index 0000000..bd4c530 --- /dev/null +++ b/nptl/mtx_lock.c @@ -0,0 +1,28 @@ +/* C11 threads mutex lock implementation. + Copyright (C) 2017 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" + +/* Block the current thread until the mutex pointed to by mutex is + unlocked. In that case current thread will not be blocked. */ +int +mtx_lock (mtx_t *mutex) +{ + int err_code = __pthread_mutex_lock ((pthread_mutex_t *) mutex); + return thrd_err_map (err_code); +} diff --git a/nptl/mtx_timedlock.c b/nptl/mtx_timedlock.c new file mode 100644 index 0000000..3770d5c --- /dev/null +++ b/nptl/mtx_timedlock.c @@ -0,0 +1,31 @@ +/* C11 threads mutex timed lock implementation. + Copyright (C) 2017 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" + +/* Block the current thread until the mutex pointed by mutex is unlocked + or time pointed by time_point is reached. In case the mutex is unlocked + current thread will not be blocked. */ +int +mtx_timedlock (mtx_t *restrict mutex, + const struct timespec *restrict time_point) +{ + int err_code = __pthread_mutex_timedlock ((pthread_mutex_t *)mutex, + time_point); + return thrd_err_map (err_code); +} diff --git a/nptl/mtx_trylock.c b/nptl/mtx_trylock.c new file mode 100644 index 0000000..406229a --- /dev/null +++ b/nptl/mtx_trylock.c @@ -0,0 +1,29 @@ +/* C11 threads mutex try lock implementation. + Copyright (C) 2017 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" + +/* Try to lock the mutex pointed by mutex without blocking. If the mutex + is free the current threads takes control of it, otherwise it returns + immediately. */ +int +mtx_trylock (mtx_t *mutex) +{ + int err_code = __pthread_mutex_trylock ((pthread_mutex_t *) mutex); + return thrd_err_map (err_code); +} diff --git a/nptl/mtx_unlock.c b/nptl/mtx_unlock.c new file mode 100644 index 0000000..d5f9c32 --- /dev/null +++ b/nptl/mtx_unlock.c @@ -0,0 +1,28 @@ +/* C11 threads mutex unlock implementation. + Copyright (C) 2017 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" + +/* Unlock the mutex pointed by mutex. It may potentially awake other + threads waiting on this mutex. */ +int +mtx_unlock (mtx_t *mutex) +{ + int err_code = __pthread_mutex_unlock ((pthread_mutex_t *) mutex); + return thrd_err_map (err_code); +} diff --git a/sysdeps/nptl/threads.h b/sysdeps/nptl/threads.h index 4b89a30..cd811f4 100644 --- a/sysdeps/nptl/threads.h +++ b/sysdeps/nptl/threads.h @@ -24,6 +24,7 @@ __BEGIN_DECLS +#include #include typedef unsigned long int thrd_t; @@ -39,6 +40,20 @@ enum thrd_timedout = 4 }; +/* Mutex types. */ +enum +{ + mtx_plain = 0, + mtx_recursive = 1, + mtx_timed = 2 +}; + +typedef union +{ + char __size[__SIZEOF_PTHREAD_MUTEX_T]; + long int __align __LOCK_ALIGNMENT; +} mtx_t; + /* Threads functions. */ /* Create a new thread executing the function __func. Arguments to __func @@ -85,6 +100,35 @@ thrd_equal (thrd_t __thread1, thrd_t __thread2) } #endif + +/* Mutex functions. */ + +/* Creates a new mutex object with type __type. If successful the new + object is pointed by __mutex. */ +extern int mtx_init (mtx_t *__mutex, int __type); + +/* Block the current thread until the mutex pointed to by __mutex is + unlocked. In that case current thread will not be blocked. */ +extern int mtx_lock (mtx_t *__mutex); + +/* Block the current thread until the mutex pointed by __mutex is unlocked + or time pointed by __time_point is reached. In case the mutex is unlock, + the current thread will not be blocked. */ +extern int mtx_timedlock (mtx_t *__restrict __mutex, + const struct timespec *__restrict __time_point); + +/* Try to lock the mutex pointed by __mutex without blocking. If the mutex + is free the current threads takes control of it, otherwise it returns + immediately. */ +extern int mtx_trylock (mtx_t *__mutex); + +/* Unlock the mutex pointed by __mutex. It may potentially awake other + threads waiting on this mutex. */ +extern int mtx_unlock (mtx_t *__mutex); + +/* Destroy the mutex object pointed by __mutex. */ +extern void mtx_destroy (mtx_t *__mutex); + __END_DECLS #endif /* _THREADS_H */ From patchwork Fri Sep 22 20:26:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 114092 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp3473853edb; Fri, 22 Sep 2017 13:27:56 -0700 (PDT) X-Received: by 10.98.152.199 with SMTP id d68mr301832pfk.250.1506112076739; Fri, 22 Sep 2017 13:27:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506112076; cv=none; d=google.com; s=arc-20160816; b=0wirV9BM3bqx2UCVrzuuYujfh11qEJqjih6quPXsCWCj5SBehB0hQeF7X9VPzkIRvo ORVufYYQQw9dZYRVAFBc+bXw9MgkN+SWKkMeAq4LG+PsP1te6fAadxf+0uxde7ok2oFu 3sTj7Tn+uQRsKf2ETxu0xLMuco+LrMIj5GizNLy8CeJjuLbjMTzQ9VOkj8J/3NDFiAe7 92VIPzX7F0URJD4gyHajLJAEUArhNSYCvJIyVburzpBPti3EYyLHYwtWvib3+zrHJhkZ X7fQ9rU5UGKm3uJ+eCpEvFrJEJZ6wSUrnA73wVISmz9+NWP7Q5txy1mYh4Klqo0uieyv VIOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=QCaWO0honUX9NScP+KHvFjEQV1QqP75FVi7alj8pEww=; b=mP5jwq8bDqhN+9295Gt9PlCvE6m7CHu88pm2nj/ibKOz36sJ7qXaEjMnHBmAlmn/PU uzYSaRKubzV5RkxIXJvUIjCIbT3PV5TFMsuRjSTpxLkq8P2W/6ckWlm2gMNhJW+8okrm E/u0l9/uGVLgUVTwCXygK2pcAzP0jnOznxLFqRJ3NnZDerP9ArZqZl0U+xZBQzlmfNPE 8lQdUURpnmWxyZG7Qe7cmUytclCORfCRaIkxuS15zjNKzicraF+p5UzJoKfpMJTMZDhW tzVEHqBSMC6+G1GYyQbM8ddm6d1tOIIn+4P44fL0LV24npTk/jVG2IAvFyDa4Fcq+ipD L52A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Ie9YdYi8; spf=pass (google.com: domain of libc-alpha-return-84876-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-84876-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id w18si332885pgc.681.2017.09.22.13.27.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Sep 2017 13:27:56 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-84876-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Ie9YdYi8; spf=pass (google.com: domain of libc-alpha-return-84876-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-84876-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=glsO1fnwQSPEt9zqOigsU91dgFWRyzH hryspaVV8pG4BL3hF6L1FtcXnptEqtybbwu1m9Zt6tmQTmEmKaweMpmnTFJtAsod ofWxnKxhp7FPk31Wl69bP0GzLhePtjwxmJCmxZb3BY0/yoEqHy7W42gJyK9Hznhn 2FBTRyG3J8oU= 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:subject:date:message-id:in-reply-to :references; s=default; bh=ALPqL8WAYq5559kj//tddRrx2CU=; b=Ie9Yd Yi8gRnX2wldBjrKvzLfvBYluCs9dq4txbcggObVAh5LRrYatbjD/XEDy6RTtQzy8 hxSVS9mjgSyt4w9FT7Hs2xP2wB4s8GPXCSKf//32aB7sgFqv+AseGdzZYzyqdBiO v66H8Hoj7hNVh4nrCCbEWPesj/GW8GKuGaRWUk= Received: (qmail 65980 invoked by alias); 22 Sep 2017 20:27:20 -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 65866 invoked by uid 89); 22 Sep 2017 20:27:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f179.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=QCaWO0honUX9NScP+KHvFjEQV1QqP75FVi7alj8pEww=; b=A1rHfkGWZq5lEtnQEzVQt8qR3XJYGVZdHean+V7sDIEgiR/p9rCyIlk6oGYQd3YFd9 8k2oYXxBcQsXBlO7YC8s1d8WETlSIutlyKeKPKiHjEuCbmJibzF6ZIdU8dFIREvnNZRB rsiV7Kix3y8X8MMkeMbLq2ULkhWxwwthU2COXcwBkw8kuna61lyD+9Eq5fPAclvJmsNu PRVX14uH9HULrYuNFqmPq+4C/fJKLynUyWjipyHHk08oIWQE2cy8uEZFOXacMIMTAvtV IgQ6/lwvxrPHgODhKzPPVI/kHsoREammW08sknYLRZzF2ha5JGMPIG/eFPr7ZusdEnTY 1K2g== X-Gm-Message-State: AHPjjUiGDRBKvkRwjdEvrK73orYd13Xi6yzdcS/Y2jbaCsKQrIpFvm6k DGTIy2vAPOxgveE9Fa/Ef7YUV7G9tJU= X-Google-Smtp-Source: AOwi7QCrycT3gb79Gdf6VumtMcx93ek8sMZCHt5gxVHKcs/XhnjfLiQiX5WY2Z4myf4mwYxiyrBnWg== X-Received: by 10.237.37.14 with SMTP id v14mr605328qtc.116.1506112036460; Fri, 22 Sep 2017 13:27:16 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 3/8] nptl: Add C11 threads call_once functions Date: Fri, 22 Sep 2017 17:26:59 -0300 Message-Id: <1506112024-22601-4-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1506112024-22601-1-git-send-email-adhemerval.zanella@linaro.org> References: <1506112024-22601-1-git-send-email-adhemerval.zanella@linaro.org> This patch adds the call_* definitions from C11 threads (ISO/IEC 9899:2011), more specifically call_once and required types. Mostly of the definitions are composed based on POSIX conterparts,including once_flag (pthread_once_t). The idea is to make possible to share POSIX internal implementations for mostly of the code (and making adjustment only when required). Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu, arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu, microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu, powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu, tile{pro,gx}-linux-gnu, and x86_64-linux-gnu). Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu, arm-linux-gnueabhf, and powerpc64le-linux-gnu. * conform/data/threads.h-data (ONCE_FLAG_INIT): New macro. (once_flag): New type. (call_once): New function. * nptl/Makefile (libpthread-routines): Add call_once object. * nptl/Versions (libphread) [GLIBC_2.27]: Add call_once symbol. * nptl/call_once.c: New file. * sysdeps/nptl/threads.h (ONCE_FLAG_INIT): New define. (once_flag): New type. (call_once): New prototype. --- ChangeLog | 10 ++++++++++ conform/data/threads.h-data | 5 +++++ nptl/Makefile | 2 +- nptl/Versions | 2 +- nptl/call_once.c | 33 +++++++++++++++++++++++++++++++++ sysdeps/nptl/threads.h | 7 +++++++ 6 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 nptl/call_once.c -- 2.7.4 diff --git a/conform/data/threads.h-data b/conform/data/threads.h-data index bb5ca75..70b2fe0 100644 --- a/conform/data/threads.h-data +++ b/conform/data/threads.h-data @@ -1,5 +1,7 @@ #if defined ISO11 +macro ONCE_FLAG_INIT + constant thrd_success constant thrd_busy constant thrd_error @@ -13,6 +15,7 @@ constant mtx_timed type thrd_t type thrd_start_t type mtx_t +type once_flag function int thrd_create (thrd_t*, thrd_start_t, void*) function int thrd_equal (thrd_t, thrd_t) @@ -30,6 +33,8 @@ function int mtx_trylock (mtx_t*) function int mtx_unlock (mtx_t*) function void mtx_destroy (mtx_t*) +function void call_once (once_flag*, void (*)(void)) + #include "time.h-data" #endif diff --git a/nptl/Makefile b/nptl/Makefile index c4f6970..7d2b83f 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -142,7 +142,7 @@ libpthread-routines = nptl-init vars events version pt-interp \ thrd_create thrd_current thrd_detach thrd_equal \ thrd_exit thrd_join thrd_sleep thrd_yield \ mtx_destroy mtx_init mtx_lock mtx_timedlock \ - mtx_trylock mtx_unlock + mtx_trylock mtx_unlock call_once # pthread_setuid pthread_seteuid pthread_setreuid \ # pthread_setresuid \ # pthread_setgid pthread_setegid pthread_setregid \ diff --git a/nptl/Versions b/nptl/Versions index 5cf581a..b055860 100644 --- a/nptl/Versions +++ b/nptl/Versions @@ -269,7 +269,7 @@ libpthread { GLIBC_2.27 { thrd_create; thrd_current; thrd_detach; thrd_equal; thrd_exit; thrd_join; thrd_sleep; thrd_yield; mtx_init; mtx_lock; mtx_timedlock; mtx_trylock; - mtx_unlock; mtx_destroy; + mtx_unlock; mtx_destroy; call_once; } GLIBC_PRIVATE { diff --git a/nptl/call_once.c b/nptl/call_once.c new file mode 100644 index 0000000..8a15f1f --- /dev/null +++ b/nptl/call_once.c @@ -0,0 +1,33 @@ +/* C11 threads call once implementation. + Copyright (C) 2017 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" + +/* Call function func exactly once, even if invoked from several threads. + All calls must be made with the same flag object. */ +void +call_once (once_flag *flag, void (*func)(void)) +{ + _Static_assert (sizeof (once_flag) == sizeof (pthread_once_t), + "once_flag size"); + _Static_assert (alignof (once_flag) == alignof (pthread_once_t), + "once_flag alignment"); + __pthread_once (flag, func); +} diff --git a/sysdeps/nptl/threads.h b/sysdeps/nptl/threads.h index cd811f4..53fe731 100644 --- a/sysdeps/nptl/threads.h +++ b/sysdeps/nptl/threads.h @@ -27,8 +27,11 @@ __BEGIN_DECLS #include #include +#define ONCE_FLAG_INIT 0 + typedef unsigned long int thrd_t; typedef int (*thrd_start_t) (void*); +typedef int __ONCE_ALIGNMENT once_flag; /* Exit and error codes. */ enum @@ -129,6 +132,10 @@ extern int mtx_unlock (mtx_t *__mutex); /* Destroy the mutex object pointed by __mutex. */ extern void mtx_destroy (mtx_t *__mutex); +/* Call function func exactly once, even if invoked from several threads. + All calls must be made with the same __flag object. */ +extern void call_once (once_flag *__flag, void (*__func)(void)); + __END_DECLS #endif /* _THREADS_H */ From patchwork Fri Sep 22 20:27:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 114093 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp3474004edb; Fri, 22 Sep 2017 13:28:07 -0700 (PDT) X-Received: by 10.84.179.67 with SMTP id a61mr295016plc.230.1506112087220; Fri, 22 Sep 2017 13:28:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506112087; cv=none; d=google.com; s=arc-20160816; b=C22fdp9M9MW5WDGNqG7g03DmWX73Q3tzirdCfaYa4UiXzIO1uMl5KLNcfM5p0B0EJW pHkmnpuPipASBLzBapDJhkfVLbhu2jrBY1UYS1SIAB/8xSFbyyk2VWzuaAduvk2YwW7g AYO3Q/XKoNc64/l8VKQ67VwxsiHfRg04ukuzkuQ3IUBYq/La75r2aSJV+IGXGlvNUVnA H+I56AAxlWuW71P6wcYyywdiFwSvi9rXVyUXugZcSJCD64/gFH2ayslXkzF4elQMq7GE 15nrNDn5/cCJAQXQchLQkXYAhArbkmrM5o5fs+PpmTNdwY3e/8Y2apZYGNoJp7dGboGH V4nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=23qWRd6sZWbyf2GKLVEfN1Y7WkPIvwuT0l8d535bHZk=; b=BUTda2f6veCsDdUZv9sXceHLaGuOVhn9iabzuH/nVo77DnWWxAuooWQb3pbxgc7QRk 0U6qIzSaQmNJNAeCGebn5EJ5DCSWwa4OVC2GPLHFTgBzJIJHhk6/CDCE/5Wi1MLRqQWh S4THm5M6k5E6VyhKWSOJONHnbVhbXvViQ6mwM/3dcns8MmfUDy2JNdMVqdtZlqJzo0Zi EBucBHMHCHaDUzaKw7vXYLAOoL/Mh9ZB+q/ffzL1pjDibzYe0o5VA2fhszXTvh1EvOXt n48CGzS/1WqfK7+q5W+h6+llBz7w7mHtE+BeMgOxG/Is0oz00ZhMXwLBdjvUU3gagDUR oTnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=D1on6+Vu; spf=pass (google.com: domain of libc-alpha-return-84877-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-84877-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id w22si336016pge.598.2017.09.22.13.28.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Sep 2017 13:28:07 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-84877-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=D1on6+Vu; spf=pass (google.com: domain of libc-alpha-return-84877-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-84877-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=X9PDzVkZjvQ8jtdmjIK6hYPIZuOPYwc kuVNJq0NOa5PqhKFMEx0aDUw6PVYP2X2vDveVQvWm2hgDxGidNmpJvMesp+0xJHe j5/HDWU8FqzXRgGeB2fndSAXeiZUVJ+egnllTTn67/N4eFhqkcX6N7TGgER91kxT zrcj610vN1Uw= 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:subject:date:message-id:in-reply-to :references; s=default; bh=RJUpVbXuHxNQTkda+de6tN61fPQ=; b=D1on6 +VuEpjdvnL9OiJ3Nmsdwg8m0j4hzPqIdu/q3Oze6VkquMUkWZftVTIegTdT8JZSS TEOWTA04B4T1gaV6lQ+g8KiDiJ2kxadi+rj9zWMYpCg9TJKrP2LwKAinS1A/ijiC XU5Y1LuLhoN+22IpEqVAQSRX2Io4PjhUph9l30= Received: (qmail 66401 invoked by alias); 22 Sep 2017 20:27:24 -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 66337 invoked by uid 89); 22 Sep 2017 20:27:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk0-f178.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=23qWRd6sZWbyf2GKLVEfN1Y7WkPIvwuT0l8d535bHZk=; b=AHWxLZIWw2vrnYDRCfyvM+zlWnNJr4ytRCT+E05TY319p+Bs4d9P6m2k2oJrDUdLtU jx6hplSEadVIpl0IWJ1LwC7AapXiwK6NA5KxKaUJ7AABM1uSXD3f/X2e2rVscGKewC/e 5kF+Gui//P4/F+s259SE0rLWI0ZcxNaxiddaV3ofvyZqw5E9uWj84gyN2dconsy6bgXd OncHAYPU3zgNAatDSAqoiAzeKtwsXs0RFZvSaFmwr+c8YaWP1gEFvsX13rQ+vtLP4xt1 vYw+aSTMWCv60nqipXl0NRTMHIrD77vATtNcxgxkV33dV+Cz3I/lEcjFgqgm1F7qjjrq JkHA== X-Gm-Message-State: AHPjjUgVH5mZzKhpJ9Ugt71jsLBmwn2NxgEKnZofi+ph7pxxbGV0rJyx iPElE7PH7HKE8fYn8gvB/NqBB+TSHCU= X-Google-Smtp-Source: AOwi7QDZtQPNN418cRGp3irENZt8TqvlUs589RUdWHtK0/9oISILlNDS0g1qyWvDA5QKxCftwOdtkg== X-Received: by 10.55.36.3 with SMTP id w3mr544547qkg.284.1506112037999; Fri, 22 Sep 2017 13:27:17 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 4/8] nptl: Add C11 threads cnd_* functions Date: Fri, 22 Sep 2017 17:27:00 -0300 Message-Id: <1506112024-22601-5-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1506112024-22601-1-git-send-email-adhemerval.zanella@linaro.org> References: <1506112024-22601-1-git-send-email-adhemerval.zanella@linaro.org> This patch adds the cnd_* definitions from C11 threads (ISO/IEC 9899:2011), more specifically cnd_broadcast, cnd_destroy, cnd_init, cnd_signal, cnd_timedwait, cnd_wait, and required types. Mostly of the definitions are composed based on POSIX conterparts, and cnd_t is also based on internal pthreads fields, but with distinct internal layout to avoid possible issues with code interchange (such as trying to pass POSIX structure on C11 functions and to avoid inclusion of pthread.h). The idea is to make it possible to share POSIX internal implementation for mostly of the code making adjust where only required. Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu, arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu, microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu, powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu, tile{pro,gx}-linux-gnu, and x86_64-linux-gnu). Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu, arm-linux-gnueabhf, and powerpc64le-linux-gnu. * conform/data/threads.h-data (cnd_t): New type. (cnd_init): New function. (cnd_signal): Likewise. (cnd_broadcast): Likewise. (cnd_wait): Likewise. (cnd_timedwait): Likewise. (cnd_destroy): Likewise. * nptl/Makefile (libpthread-routines): Add cnd_broadcast, cnd_destroy, cnd_init, cnd_signal, cnd_timedwait, and cnd_wait object. * nptl/Versions (libpthread) [GLIBC_2.27]: Likewise. * nptl/cnd_broadcast.c: New file. * nptl/cnd_destroy.c: Likewise. * nptl/cnd_init.c: Likewise. * nptl/cnd_signal.c: Likewise. * nptl/cnd_timedwait.c: Likewise. * nptl/cnd_wait.c: Likewise. * sysdeps/nptl/threads.h (cnd_t): New type. (cnd_init): New prototype. (cnd_signa): Likewise. (cnd_broadcast): Likewise. (cnd_wait): Likewise. (cnd_timedwait): Likewise. (cnd_destroy): Likewise. --- ChangeLog | 25 +++++++++++++++++++++++++ conform/data/threads.h-data | 8 ++++++++ nptl/Makefile | 3 ++- nptl/Versions | 3 ++- nptl/cnd_broadcast.c | 28 ++++++++++++++++++++++++++++ nptl/cnd_destroy.c | 28 ++++++++++++++++++++++++++++ nptl/cnd_init.c | 33 +++++++++++++++++++++++++++++++++ nptl/cnd_signal.c | 28 ++++++++++++++++++++++++++++ nptl/cnd_timedwait.c | 31 +++++++++++++++++++++++++++++++ nptl/cnd_wait.c | 28 ++++++++++++++++++++++++++++ sysdeps/nptl/threads.h | 34 ++++++++++++++++++++++++++++++++++ 11 files changed, 247 insertions(+), 2 deletions(-) create mode 100644 nptl/cnd_broadcast.c create mode 100644 nptl/cnd_destroy.c create mode 100644 nptl/cnd_init.c create mode 100644 nptl/cnd_signal.c create mode 100644 nptl/cnd_timedwait.c create mode 100644 nptl/cnd_wait.c -- 2.7.4 diff --git a/conform/data/threads.h-data b/conform/data/threads.h-data index 70b2fe0..d7c562e 100644 --- a/conform/data/threads.h-data +++ b/conform/data/threads.h-data @@ -16,6 +16,7 @@ type thrd_t type thrd_start_t type mtx_t type once_flag +type cnd_t function int thrd_create (thrd_t*, thrd_start_t, void*) function int thrd_equal (thrd_t, thrd_t) @@ -35,6 +36,13 @@ function void mtx_destroy (mtx_t*) function void call_once (once_flag*, void (*)(void)) +function int cnd_init (cnd_t*) +function int cnd_signal (cnd_t*) +function int cnd_broadcast (cnd_t*) +function int cnd_wait (cnd_t*, mtx_t*) +function int cnd_timedwait (cnd_t*, mtx_t*, const struct timespec*) +function void cnd_destroy (cnd_t*) + #include "time.h-data" #endif diff --git a/nptl/Makefile b/nptl/Makefile index 7d2b83f..ddef534 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -142,7 +142,8 @@ libpthread-routines = nptl-init vars events version pt-interp \ thrd_create thrd_current thrd_detach thrd_equal \ thrd_exit thrd_join thrd_sleep thrd_yield \ mtx_destroy mtx_init mtx_lock mtx_timedlock \ - mtx_trylock mtx_unlock call_once + mtx_trylock mtx_unlock call_once cnd_broadcast \ + cnd_destroy cnd_init cnd_signal cnd_timedwait cnd_wait # pthread_setuid pthread_seteuid pthread_setreuid \ # pthread_setresuid \ # pthread_setgid pthread_setegid pthread_setregid \ diff --git a/nptl/Versions b/nptl/Versions index b055860..53e6b9a 100644 --- a/nptl/Versions +++ b/nptl/Versions @@ -269,7 +269,8 @@ libpthread { GLIBC_2.27 { thrd_create; thrd_current; thrd_detach; thrd_equal; thrd_exit; thrd_join; thrd_sleep; thrd_yield; mtx_init; mtx_lock; mtx_timedlock; mtx_trylock; - mtx_unlock; mtx_destroy; call_once; + mtx_unlock; mtx_destroy; call_once; cnd_broadcast; cnd_destroy; cnd_init; + cnd_signal; cnd_timedwait; cnd_wait; mtx_destroy; } GLIBC_PRIVATE { diff --git a/nptl/cnd_broadcast.c b/nptl/cnd_broadcast.c new file mode 100644 index 0000000..8e5f165 --- /dev/null +++ b/nptl/cnd_broadcast.c @@ -0,0 +1,28 @@ +/* C11 thread conditional broadcast implementation. + Copyright (C) 2017 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" + +/* Unblock all threads currently waiting on condition variable pointed + by cond. */ +int +cnd_broadcast (cnd_t *cond) +{ + int err_code = __pthread_cond_broadcast ((pthread_cond_t*) cond); + return thrd_err_map (err_code); +} diff --git a/nptl/cnd_destroy.c b/nptl/cnd_destroy.c new file mode 100644 index 0000000..4b46132 --- /dev/null +++ b/nptl/cnd_destroy.c @@ -0,0 +1,28 @@ +/* C11 threads conditional destroy implementation. + Copyright (C) 2017 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" +#include "pthreadP.h" + +/* Destroy condition variable pointed by cond and free all of its + resources. */ +void +cnd_destroy (cnd_t *cond) +{ + __pthread_cond_destroy ((pthread_cond_t *) cond); +} diff --git a/nptl/cnd_init.c b/nptl/cnd_init.c new file mode 100644 index 0000000..eb8a544 --- /dev/null +++ b/nptl/cnd_init.c @@ -0,0 +1,33 @@ +/* C11 thread conditional initialization implementation. + Copyright (C) 2017 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" + +/* Initialize new condition variable pointed by cond. */ +int +cnd_init (cnd_t *cond) +{ + _Static_assert (sizeof (cnd_t) == sizeof (pthread_cond_t), "cnd_t size"); + _Static_assert (alignof (cnd_t) == alignof (pthread_cond_t), + "cnd_t alignment"); + + int err_code = __pthread_cond_init ((pthread_cond_t *)cond, NULL); + return thrd_err_map (err_code); +} diff --git a/nptl/cnd_signal.c b/nptl/cnd_signal.c new file mode 100644 index 0000000..e843957 --- /dev/null +++ b/nptl/cnd_signal.c @@ -0,0 +1,28 @@ +/* C11 threads conditional signal implementation. + Copyright (C) 2017 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" + +/* Unblock one thread that currently waits on condition variable pointed + by cond. */ +int +cnd_signal (cnd_t *cond) +{ + int err_code = __pthread_cond_signal ((pthread_cond_t *) cond); + return thrd_err_map (err_code); +} diff --git a/nptl/cnd_timedwait.c b/nptl/cnd_timedwait.c new file mode 100644 index 0000000..b3c60e8 --- /dev/null +++ b/nptl/cnd_timedwait.c @@ -0,0 +1,31 @@ +/* C11 threads conditional timed wait implementation. + Copyright (C) 2017 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" + +/* Block current thread on the condition variable until condition variable + pointed by cond is signaled or time pointed by time_point is reached. */ +int +cnd_timedwait (cnd_t *restrict cond, mtx_t *restrict mutex, + const struct timespec* restrict time_point) +{ + int err_code = __pthread_cond_timedwait ((pthread_cond_t *) cond, + (pthread_mutex_t *) mutex, + time_point); + return thrd_err_map (err_code); +} diff --git a/nptl/cnd_wait.c b/nptl/cnd_wait.c new file mode 100644 index 0000000..298d049 --- /dev/null +++ b/nptl/cnd_wait.c @@ -0,0 +1,28 @@ +/* C11 threads conditional wait implementaiton. + Copyright (C) 2017 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" + +/* Block current thread on the condition variable pointed by cond. */ +int +cnd_wait (cnd_t *cond, mtx_t *mutex) +{ + int err_code = __pthread_cond_wait ((pthread_cond_t *) cond, + (pthread_mutex_t *) mutex); + return thrd_err_map (err_code); +} diff --git a/sysdeps/nptl/threads.h b/sysdeps/nptl/threads.h index 53fe731..568e2d4 100644 --- a/sysdeps/nptl/threads.h +++ b/sysdeps/nptl/threads.h @@ -57,6 +57,12 @@ typedef union long int __align __LOCK_ALIGNMENT; } mtx_t; +typedef union +{ + char __size[__SIZEOF_PTHREAD_COND_T]; + __extension__ long long int __align __LOCK_ALIGNMENT; +} cnd_t; + /* Threads functions. */ /* Create a new thread executing the function __func. Arguments to __func @@ -136,6 +142,34 @@ extern void mtx_destroy (mtx_t *__mutex); All calls must be made with the same __flag object. */ extern void call_once (once_flag *__flag, void (*__func)(void)); + +/* Condition variable functions. */ + +/* Initialize new condition variable pointed by __cond. */ +extern int cnd_init (cnd_t *__cond); + +/* Unblock one thread that currently waits on condition variable pointed + by __cond. */ +extern int cnd_signal (cnd_t *__cond); + +/* Unblock all threads currently waiting on condition variable pointed by + __cond. */ +extern int cnd_broadcast (cnd_t *__cond); + +/* Block current thread on the condition variable pointed by __cond. */ +extern int cnd_wait (cnd_t *__cond, mtx_t *__mutex); + +/* Block current thread on the condition variable until condition variable + pointed by __cond is signaled or time pointed by __time_point is + reached. */ +extern int cnd_timedwait (cnd_t *__restrict __cond, + mtx_t *__restrict __mutex, + const struct timespec *__restrict __time_point); + +/* Destroy condition variable pointed by __cond and free all of its + resources. */ +extern void cnd_destroy (cnd_t *__cond); + __END_DECLS #endif /* _THREADS_H */ From patchwork Fri Sep 22 20:27:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 114094 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp3474139edb; Fri, 22 Sep 2017 13:28:19 -0700 (PDT) X-Received: by 10.84.229.7 with SMTP id b7mr273842plk.75.1506112099026; Fri, 22 Sep 2017 13:28:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506112099; cv=none; d=google.com; s=arc-20160816; b=iIqQq9keZr88lOM2Yq8x6CiBTVqU8qcsfngavoTDjv0oOzAecVvLjTj3s2/TTqg5pN DiXFkUbxsfuz6qcAB+ifXwdFT0zZFQ4wHH9KqkYlvJOXgkvan1k6e3laZ1Mik0M9hPJR 7KZVymGLSmB4oIU0jYIIzExIfoIs+S7eE4z9dbgQgNoEbv7BK12csDw3wF1M0TxxYa7a 7huE9TukcLPX/EIWT2oR1caeWZ1Fx8rWd8TPE/yhMXQw7+1RPlwMLtygle1Nn3ITSW4W YQpuLuSYkf2gOlr/CUhydx5Ef09lFQ+VV9iALM1QxjvqrMhLQlv0JuY0gH8YD96QB2Ep RP5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=uWLaFcEXgUeTBDuJf7Yo4Fa7i4ae6L4piyxTJcP7tTY=; b=GZpVMaWrpCTm7FLUox+Z1Kx6CuRr5ys981M3mua4aKAlfc+1Z7/u/9qLOe+nCG8Jsd +Ek5Zlk1z5bb/k338oHflSMmryda6MrRhXtjdH+ZbNFaUf/R1Dnk1UnLHBA9hNYPSiyF 1vk9cAo63zL9E/uIUvdL/zc9b3aAwbL6coxUqhzqzl+nvCfVlTV0pCjVLsuL9L6ZKG/w FLQODh70WTWrXJsa6YsAu6ovY5FSL3A+9NwdzSthod/OK8+82I1KCkingvHorVATxQXS dcGzHp2blHFFAF5Y3/aZsXWQ9v/oRn4yczENoomcg93p1foRUM8JrSvMKGwqGjDH1HRU 7aIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=EVwVKBOT; spf=pass (google.com: domain of libc-alpha-return-84878-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-84878-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id l4si326691plb.627.2017.09.22.13.28.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Sep 2017 13:28:19 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-84878-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=EVwVKBOT; spf=pass (google.com: domain of libc-alpha-return-84878-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-84878-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=EXlq8AWpGhx9bOFDQZLdWYisu4DfMPz gqglRX2q4MXkD4ou+F9nL1XNiAQLf4nxtYfHuUp54+YruFVizlM1cLQL/6+dT/4q 3B2KqpwprUYpqIJOLcVxhSdBf4gFjM5OhFBv121F0ZmoS/oX1w7DZ4VRtwdpOhAn yZs4zu/MnX+Y= 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:subject:date:message-id:in-reply-to :references; s=default; bh=rvlGDzBX7D4ieG6o1+hbAB0tsko=; b=EVwVK BOTiX5b9LOC8Umf0dtYMQ2Yi8M8RvUHWYx2hy9dq0DI1xJ4xGhNxcVAoCmEq7QiA CC7v1VqaT8fw/xiK3QR9Kh8PffDZmGcwx35jyRQpSUjkHn1bNpde/HHBzD/gSdx1 jDn/G8MdqZgN0vykqTe1sVVu2jC9Z5QcpdT8+Q= Received: (qmail 66512 invoked by alias); 22 Sep 2017 20:27:24 -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 66459 invoked by uid 89); 22 Sep 2017 20:27:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk0-f172.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=uWLaFcEXgUeTBDuJf7Yo4Fa7i4ae6L4piyxTJcP7tTY=; b=f9Xo35Z+U48KFHFPFnIMeM9DUjqKL/yFS7+bXthlVXzGkq4nlafkCkXdSaHKHHTxrO cIRlZHukEXnQNJsDD09S2ZU4SHGW0LeohKzd7OWK4J1nC7P+ESDI8wlqxw4UjurrDtGd 0kZKzNNCS1SY37rzErf4Z8SIAP1Zxqxy41EjMkt4Ly6bBKM7WZPC76xs01nrRxrJkmsG /42Og9Rf5laGdKEAtFmQ+T1qwmK0xYhqzCBu7XEY2dIKcv5Mfe4DWVHvXBy6WtGBBTWG lowuUFhlhvbszI/H7Kmrlze1NZb2zLy4ffSxwNJ2BzDvErZ+koz6t/SvUYtQRA6AKvE8 lErg== X-Gm-Message-State: AHPjjUhKD0eaBAZlYfjQnKg7wFTifUi6E4qPwbZ+DccCcqwBNC71P++j UixtJC2FP5FR0a0gTFcOutqpHN6ShPU= X-Google-Smtp-Source: AOwi7QCfBvYax5Dlc5CWVOj+dmqNqtDZkcbliCXaAYFqyw3e5hhTIFO1uKKOsKpdYl5zvY5dv4tAJQ== X-Received: by 10.55.156.147 with SMTP id f141mr585181qke.72.1506112039616; Fri, 22 Sep 2017 13:27:19 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 5/8] nptl: Add C11 threads tss_* functions Date: Fri, 22 Sep 2017 17:27:01 -0300 Message-Id: <1506112024-22601-6-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1506112024-22601-1-git-send-email-adhemerval.zanella@linaro.org> References: <1506112024-22601-1-git-send-email-adhemerval.zanella@linaro.org> This patch adds the tss_* definitions from C11 threads (ISO/IEC 9899:2011), more specifically tss_create, tss_delete, tss_get, tss_set, and required types. Mostly of the definitions are composed based on POSIX conterparts, including tss_t (pthread_key_t). Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu, arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu, microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu, powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu, tile{pro,gx}-linux-gnu, and x86_64-linux-gnu). Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu, arm-linux-gnueabhf, and powerpc64le-linux-gnu. * conform/data/threads.h-data (thread_local): New macro. (TSS_DTOR_ITERATIONS): Likewise. (tss_t): New type. (tss_dtor_t): Likewise. (tss_create): New function. (tss_get): Likewise. (tss_set): Likewise. (tss_delete): Likewise. * nptl/Makefile (libpthread-routines): Add tss_create, tss_delete, tss_get, and tss_set objects. * nptl/Versions (libpthread) [GLIBC_2.27]: Likewise. * nptl/tss_create.c: New file. * nptl/tss_delete.c: Likewise. * nptl/tss_get.c: Likewise. * nptl/tss_set.c: Likewise. * sysdeps/nptl/threads.h (thread_local): New define. (TSS_DTOR_ITERATIONS): Likewise. (tss_t): New typedef. (tss_dtor_t): Likewise. (tss_create): New prototype. (tss_get): Likewise. (tss_set): Likewise. (tss_delete): Likewise. --- ChangeLog | 24 ++++++++++++++++++++++++ conform/data/threads.h-data | 9 +++++++++ nptl/Makefile | 3 ++- nptl/Versions | 3 ++- nptl/tss_create.c | 31 +++++++++++++++++++++++++++++++ nptl/tss_delete.c | 27 +++++++++++++++++++++++++++ nptl/tss_get.c | 27 +++++++++++++++++++++++++++ nptl/tss_set.c | 28 ++++++++++++++++++++++++++++ sysdeps/nptl/threads.h | 23 +++++++++++++++++++++++ 9 files changed, 173 insertions(+), 2 deletions(-) create mode 100644 nptl/tss_create.c create mode 100644 nptl/tss_delete.c create mode 100644 nptl/tss_get.c create mode 100644 nptl/tss_set.c -- 2.7.4 diff --git a/conform/data/threads.h-data b/conform/data/threads.h-data index d7c562e..406e497 100644 --- a/conform/data/threads.h-data +++ b/conform/data/threads.h-data @@ -1,6 +1,8 @@ #if defined ISO11 macro ONCE_FLAG_INIT +macro thread_local +macro-int-constant TSS_DTOR_ITERATIONS constant thrd_success constant thrd_busy @@ -17,6 +19,8 @@ type thrd_start_t type mtx_t type once_flag type cnd_t +type tss_t +type tss_dtor_t function int thrd_create (thrd_t*, thrd_start_t, void*) function int thrd_equal (thrd_t, thrd_t) @@ -43,6 +47,11 @@ function int cnd_wait (cnd_t*, mtx_t*) function int cnd_timedwait (cnd_t*, mtx_t*, const struct timespec*) function void cnd_destroy (cnd_t*) +function int tss_create (tss_t*, tss_dtor_t) +function {void*} tss_get (tss_t) +function int tss_set (tss_t, void*) +function void tss_delete (tss_t) + #include "time.h-data" #endif diff --git a/nptl/Makefile b/nptl/Makefile index ddef534..0bf46ce 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -143,7 +143,8 @@ libpthread-routines = nptl-init vars events version pt-interp \ thrd_exit thrd_join thrd_sleep thrd_yield \ 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 + cnd_destroy cnd_init cnd_signal cnd_timedwait cnd_wait \ + tss_create tss_delete tss_get tss_set # pthread_setuid pthread_seteuid pthread_setreuid \ # pthread_setresuid \ # pthread_setgid pthread_setegid pthread_setregid \ diff --git a/nptl/Versions b/nptl/Versions index 53e6b9a..d4dc750 100644 --- a/nptl/Versions +++ b/nptl/Versions @@ -270,7 +270,8 @@ libpthread { thrd_create; thrd_current; thrd_detach; thrd_equal; thrd_exit; thrd_join; thrd_sleep; thrd_yield; 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; mtx_destroy; + cnd_signal; cnd_timedwait; cnd_wait; mtx_destroy; tss_create; tss_delete; + tss_get; tss_set; } GLIBC_PRIVATE { diff --git a/nptl/tss_create.c b/nptl/tss_create.c new file mode 100644 index 0000000..ef6d7bb --- /dev/null +++ b/nptl/tss_create.c @@ -0,0 +1,31 @@ +/* C11 threads thread-specific creation implementation. + Copyright (C) 2017 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" + +/* Create new thread-specific storage key and stores it in the object + pointed by tss_id. If destructor is not NULL, destructor function is + called when the thread terminates. */ +int +tss_create (tss_t *tss_id, tss_dtor_t destructor) +{ + _Static_assert (sizeof (tss_t) == sizeof (pthread_key_t), "tss_t size"); + + int err_code = __pthread_key_create (tss_id, destructor); + return thrd_err_map (err_code); +} diff --git a/nptl/tss_delete.c b/nptl/tss_delete.c new file mode 100644 index 0000000..bcbc748 --- /dev/null +++ b/nptl/tss_delete.c @@ -0,0 +1,27 @@ +/* C11 threads thread-specific delete implementation. + Copyright (C) 2017 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" + +/* Destroys the thread-specific storage identified by tss_id. The + destructor is not called until thrd_exit is called. */ +void +tss_delete (tss_t tss_id) +{ + __pthread_key_delete (tss_id); +} diff --git a/nptl/tss_get.c b/nptl/tss_get.c new file mode 100644 index 0000000..784a1cf --- /dev/null +++ b/nptl/tss_get.c @@ -0,0 +1,27 @@ +/* C11 threads thread-specific get implementation. + Copyright (C) 2017 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" + +/* Return the value held in thread-specific storage for the current + thread identified by tss_id. */ +void * +tss_get (tss_t tss_id) +{ + return __pthread_getspecific (tss_id); +} diff --git a/nptl/tss_set.c b/nptl/tss_set.c new file mode 100644 index 0000000..16a0b04 --- /dev/null +++ b/nptl/tss_set.c @@ -0,0 +1,28 @@ +/* C11 threads thread-specific set implementation. + Copyright (C) 2017 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" + +/* Sets the value of the thread-specific storage identified by tss_id for + the current thread to val. */ +int +tss_set (tss_t tss_id, void *val) +{ + int err_code = __pthread_setspecific (tss_id, val); + return thrd_err_map (err_code); +} diff --git a/sysdeps/nptl/threads.h b/sysdeps/nptl/threads.h index 568e2d4..9ca3695 100644 --- a/sysdeps/nptl/threads.h +++ b/sysdeps/nptl/threads.h @@ -28,6 +28,10 @@ __BEGIN_DECLS #include #define ONCE_FLAG_INIT 0 +#define thread_local _Thread_local +#define TSS_DTOR_ITERATIONS 4 +typedef unsigned int tss_t; +typedef void (*tss_dtor_t) (void*); typedef unsigned long int thrd_t; typedef int (*thrd_start_t) (void*); @@ -170,6 +174,25 @@ extern int cnd_timedwait (cnd_t *__restrict __cond, resources. */ extern void cnd_destroy (cnd_t *__cond); +/* Thread specific storage functions. */ + +/* Create new thread-specific storage key and stores it in the object pointed + by __tss_id. If __destructor is not NULL, __destructor function is called + when the thread terminates. */ +extern int tss_create (tss_t *__tss_id, tss_dtor_t __destructor); + +/* Return the value held in thread-specific storage for the current thread + identified by __tss_id. */ +extern void *tss_get (tss_t __tss_id); + +/* Sets the value of the thread-specific storage identified by __tss_id for + the current thread to __val. */ +extern int tss_set (tss_t __tss_id, void *__val); + +/* Destroys the thread-specific storage identified by __tss_id. The + destructor is not called until thrd_exit is called. */ +extern void tss_delete (tss_t __tss_id); + __END_DECLS #endif /* _THREADS_H */ From patchwork Fri Sep 22 20:27:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 114095 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp3474336edb; Fri, 22 Sep 2017 13:28:32 -0700 (PDT) X-Received: by 10.101.74.133 with SMTP id b5mr311913pgu.100.1506112112303; Fri, 22 Sep 2017 13:28:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506112112; cv=none; d=google.com; s=arc-20160816; b=s7WJLi537/lY5xM65BWEmuFqrRdbR8/3ykc/icM634PMT2sIOtCbV78j7dcQggbXzY XUV4pTO1QGZPL4050bEjcQxTRQ4a75rd940BM8p1ve6I5gSveRaTvgZhpuqLmaOLIpcI MYXKxrhLMiAtNRNv0pxRjQzNoQfQicXQ7kRvhi4dJ/Ffk6+k+E+G9ov53375HBSbRkST vwqK5XS2N+1051/y1f0kOx+AoCXje2DNx5OXRjRtcC5pNrD5Iy55kZ+FtTc4PHjFegB2 AbEh586XIEgrb2k7YDliGK8S+Qez2aZkiRJIRmf0QYQZLMNyCrE/tinv/VnjhjpMwmBG gIWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=jNcSnKKGTchaQl5KTPrC1BwfoDLL4dd49iP3wqUhA1Y=; b=L6fWcaUEp9pR7WkVnBZDLaUSvhjBGSS8QJ6pnZZZ999br2G6NfHiCOTGsyUxMVhB7N sktQ3QvJZ7LTkaaMnvH9ZxYHLU1R62NTeOM1Y5MLvgdG0GkQfHf5puzbVeTIStbmUR5P 2W3jzeiXkTSMIHQTl3SLkHHPA2irT/m87nQfcuV6hKdgIzoHT1fGb5MFDV45/O6uNWzO RwhEAmEyaG9ToxaPE29n2TcNjjR/brRYs0thEr7rp9QzbFC9evCp7mNgLBdNNTqYMSjj gXYO9qv/AL4CLLehBb8TYFHYg6sXqfyqxcpFMHof7qWGaEfq9rRNY5nWamsHOJGy+zae M5Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=iD2//nuO; spf=pass (google.com: domain of libc-alpha-return-84879-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-84879-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id l91si123328plb.514.2017.09.22.13.28.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Sep 2017 13:28:32 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-84879-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=iD2//nuO; spf=pass (google.com: domain of libc-alpha-return-84879-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-84879-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=hBgoFFDcQ1uhibtVc8ZgpwikZDvKtEL 6DlsnkLTr0lB6zyY5/T0oGBCCoco4fFnFSOMaJdJU5s8Xtal8kkjxQRHoXCr5tkw QjSMiBsueK1Ry/wCxd29BT7WiqFKAJLENT0pPbgSfeyQYnQXr5PNE4HE6C7Ebkg4 uU/hi0ikP9nE= 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:subject:date:message-id:in-reply-to :references; s=default; bh=29JtqTt3Q2+l40/nMzxWGNRJK1Y=; b=iD2// nuOzmYYqpkrorrS5uHEhQtNfjI3VcilH4le9YnbBL2ppUGp5Pk363Tk+hV3+GmkR tgbagDjZvePBjgqkgYilw4Tb7ax2Tw0ETA/EjAKCB026WAmB/3ik/q1SsUEMT0NN 4KOirHW0Hw1Gq2ranazWXKhJRaG6HljB3zso60= Received: (qmail 66888 invoked by alias); 22 Sep 2017 20:27:28 -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 66852 invoked by uid 89); 22 Sep 2017 20:27:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk0-f178.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=jNcSnKKGTchaQl5KTPrC1BwfoDLL4dd49iP3wqUhA1Y=; b=GxfpTHOsJQtCyYHosrIOaoarEOK8LagN6cPZMOL7kZaWsVDGJUeEocS8cA6mhePPQ8 Phyo35HDT1+4y5CR86tuiBGGHO7BNE9BbGdCd751d5MilViNy6MJcIJcnNL+RS/FYIMm A0pDJCn2TuczGIxzc7w6F9c/XSkU6oKfNVG4uAuBPk/lC3vff3Qz3ikh3mCEULBjlE+P izMtEYmFjrhpPJp70bmtPEnyKOiYEpx90/HSvdIy7LKF067Z5Hxw8P23nH6YO9kjyECW WGUb/wEzcPXeonHROWa8e6kUWX5BCJ0hoylapG3MRjb3VzYuJJjB2fUjsyl4/4Ft9UBW 7rBw== X-Gm-Message-State: AHPjjUhcAkE4hyhOEkLqWr+XiB3iWrNH7OXpdlgh8YjVocT8MEkwMqhj Ql/LJheZrkHNkdFQ7PDOnZi4t7WzEpM= X-Google-Smtp-Source: AOwi7QD/TEB2NF/x54oQY5CRlCpGGIJs+Bqa/EF9SR88uE+RDaj/vP/W3SI7SUsAj2KEp9ICrCjHCw== X-Received: by 10.55.64.136 with SMTP id n130mr580227qka.38.1506112041485; Fri, 22 Sep 2017 13:27:21 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 6/8] nptl: Add abilist symbols for C11 threads Date: Fri, 22 Sep 2017 17:27:02 -0300 Message-Id: <1506112024-22601-7-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1506112024-22601-1-git-send-email-adhemerval.zanella@linaro.org> References: <1506112024-22601-1-git-send-email-adhemerval.zanella@linaro.org> This patch adds the required abilist symbols for C11 thread support. Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu, arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu, microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu, powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu, tile{pro,gx}-linux-gnu, and x86_64-linux-gnu). Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu, arm-linux-gnueabhf, and powerpc64le-linux-gnu. * sysdeps/unix/sysv/linux/aarch64/libpthread.abilist: Add C11 thread symbols. * sysdeps/unix/sysv/linux/alpha/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/arm/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/hppa/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/i386/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/ia64/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/microblaze/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/nios2/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist: Likewise. * sysdpes/unix/sysv/linux/s390/s390-32/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/sh/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilepro/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist: Likewise. --- ChangeLog | 32 ++++++++++++++++++++++ sysdeps/unix/sysv/linux/aarch64/libpthread.abilist | 26 ++++++++++++++++++ sysdeps/unix/sysv/linux/alpha/libpthread.abilist | 26 ++++++++++++++++++ sysdeps/unix/sysv/linux/arm/libpthread.abilist | 26 ++++++++++++++++++ sysdeps/unix/sysv/linux/hppa/libpthread.abilist | 26 ++++++++++++++++++ sysdeps/unix/sysv/linux/i386/libpthread.abilist | 26 ++++++++++++++++++ sysdeps/unix/sysv/linux/ia64/libpthread.abilist | 26 ++++++++++++++++++ .../sysv/linux/m68k/coldfire/libpthread.abilist | 26 ++++++++++++++++++ .../unix/sysv/linux/m68k/m680x0/libpthread.abilist | 26 ++++++++++++++++++ .../unix/sysv/linux/microblaze/libpthread.abilist | 26 ++++++++++++++++++ .../unix/sysv/linux/mips/mips32/libpthread.abilist | 26 ++++++++++++++++++ .../unix/sysv/linux/mips/mips64/libpthread.abilist | 26 ++++++++++++++++++ sysdeps/unix/sysv/linux/nios2/libpthread.abilist | 26 ++++++++++++++++++ .../linux/powerpc/powerpc32/libpthread.abilist | 26 ++++++++++++++++++ .../linux/powerpc/powerpc64/libpthread-le.abilist | 26 ++++++++++++++++++ .../linux/powerpc/powerpc64/libpthread.abilist | 26 ++++++++++++++++++ .../sysv/linux/s390/s390-32/libpthread.abilist | 26 ++++++++++++++++++ .../sysv/linux/s390/s390-64/libpthread.abilist | 26 ++++++++++++++++++ sysdeps/unix/sysv/linux/sh/libpthread.abilist | 26 ++++++++++++++++++ .../sysv/linux/sparc/sparc32/libpthread.abilist | 26 ++++++++++++++++++ .../sysv/linux/sparc/sparc64/libpthread.abilist | 26 ++++++++++++++++++ .../linux/tile/tilegx/tilegx32/libpthread.abilist | 26 ++++++++++++++++++ .../linux/tile/tilegx/tilegx64/libpthread.abilist | 26 ++++++++++++++++++ .../sysv/linux/tile/tilepro/libpthread.abilist | 26 ++++++++++++++++++ .../unix/sysv/linux/x86_64/64/libpthread.abilist | 26 ++++++++++++++++++ .../unix/sysv/linux/x86_64/x32/libpthread.abilist | 26 ++++++++++++++++++ 26 files changed, 682 insertions(+) -- 2.7.4 diff --git a/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist b/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist index 0cf30ee..dceef50 100644 --- a/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist @@ -224,3 +224,29 @@ GLIBC_2.17 write F GLIBC_2.18 GLIBC_2.18 A GLIBC_2.18 pthread_getattr_default_np F GLIBC_2.18 pthread_setattr_default_np F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F diff --git a/sysdeps/unix/sysv/linux/alpha/libpthread.abilist b/sysdeps/unix/sysv/linux/alpha/libpthread.abilist index 7e121d4..b55f124 100644 --- a/sysdeps/unix/sysv/linux/alpha/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/alpha/libpthread.abilist @@ -216,6 +216,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A GLIBC_2.2.3 pthread_getattr_np F GLIBC_2.2.6 GLIBC_2.2.6 A GLIBC_2.2.6 __nanosleep F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F GLIBC_2.3.2 GLIBC_2.3.2 A GLIBC_2.3.2 pthread_cond_broadcast F GLIBC_2.3.2 pthread_cond_destroy F diff --git a/sysdeps/unix/sysv/linux/arm/libpthread.abilist b/sysdeps/unix/sysv/linux/arm/libpthread.abilist index 91545c1..2ca90a1 100644 --- a/sysdeps/unix/sysv/linux/arm/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/arm/libpthread.abilist @@ -9,6 +9,32 @@ GLIBC_2.12 pthread_setname_np F GLIBC_2.18 GLIBC_2.18 A GLIBC_2.18 pthread_getattr_default_np F GLIBC_2.18 pthread_setattr_default_np F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F GLIBC_2.4 GLIBC_2.4 A GLIBC_2.4 _IO_flockfile F GLIBC_2.4 _IO_ftrylockfile F diff --git a/sysdeps/unix/sysv/linux/hppa/libpthread.abilist b/sysdeps/unix/sysv/linux/hppa/libpthread.abilist index a73aa43..f44d016 100644 --- a/sysdeps/unix/sysv/linux/hppa/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/hppa/libpthread.abilist @@ -204,6 +204,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A GLIBC_2.2.3 pthread_getattr_np F GLIBC_2.2.6 GLIBC_2.2.6 A GLIBC_2.2.6 __nanosleep F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F GLIBC_2.3.2 GLIBC_2.3.2 A GLIBC_2.3.2 pthread_cond_broadcast F GLIBC_2.3.2 pthread_cond_destroy F diff --git a/sysdeps/unix/sysv/linux/i386/libpthread.abilist b/sysdeps/unix/sysv/linux/i386/libpthread.abilist index 8f9c325..81f3c10 100644 --- a/sysdeps/unix/sysv/linux/i386/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/i386/libpthread.abilist @@ -216,6 +216,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A GLIBC_2.2.3 pthread_getattr_np F GLIBC_2.2.6 GLIBC_2.2.6 A GLIBC_2.2.6 __nanosleep F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F GLIBC_2.3.2 GLIBC_2.3.2 A GLIBC_2.3.2 pthread_cond_broadcast F GLIBC_2.3.2 pthread_cond_destroy F diff --git a/sysdeps/unix/sysv/linux/ia64/libpthread.abilist b/sysdeps/unix/sysv/linux/ia64/libpthread.abilist index d4c8ded..71be092 100644 --- a/sysdeps/unix/sysv/linux/ia64/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/ia64/libpthread.abilist @@ -204,6 +204,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A GLIBC_2.2.3 pthread_getattr_np F GLIBC_2.2.6 GLIBC_2.2.6 A GLIBC_2.2.6 __nanosleep F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F GLIBC_2.3.2 GLIBC_2.3.2 A GLIBC_2.3.2 pthread_cond_broadcast F GLIBC_2.3.2 pthread_cond_destroy F diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist index 91545c1..2ca90a1 100644 --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist @@ -9,6 +9,32 @@ GLIBC_2.12 pthread_setname_np F GLIBC_2.18 GLIBC_2.18 A GLIBC_2.18 pthread_getattr_default_np F GLIBC_2.18 pthread_setattr_default_np F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F GLIBC_2.4 GLIBC_2.4 A GLIBC_2.4 _IO_flockfile F GLIBC_2.4 _IO_ftrylockfile F diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist index 8f9c325..81f3c10 100644 --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist @@ -216,6 +216,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A GLIBC_2.2.3 pthread_getattr_np F GLIBC_2.2.6 GLIBC_2.2.6 A GLIBC_2.2.6 __nanosleep F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F GLIBC_2.3.2 GLIBC_2.3.2 A GLIBC_2.3.2 pthread_cond_broadcast F GLIBC_2.3.2 pthread_cond_destroy F diff --git a/sysdeps/unix/sysv/linux/microblaze/libpthread.abilist b/sysdeps/unix/sysv/linux/microblaze/libpthread.abilist index 00d948b..697fe71 100644 --- a/sysdeps/unix/sysv/linux/microblaze/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/libpthread.abilist @@ -223,3 +223,29 @@ GLIBC_2.18 vfork F GLIBC_2.18 wait F GLIBC_2.18 waitpid F GLIBC_2.18 write F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist b/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist index 280d99d..f65d65c 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist @@ -213,6 +213,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A GLIBC_2.2.3 pthread_getattr_np F GLIBC_2.2.6 GLIBC_2.2.6 A GLIBC_2.2.6 __nanosleep F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F GLIBC_2.3.2 GLIBC_2.3.2 A GLIBC_2.3.2 pthread_cond_broadcast F GLIBC_2.3.2 pthread_cond_destroy F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist b/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist index ad55bdd..e70182a 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist @@ -213,6 +213,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A GLIBC_2.2.3 pthread_getattr_np F GLIBC_2.2.6 GLIBC_2.2.6 A GLIBC_2.2.6 __nanosleep F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F GLIBC_2.3.2 GLIBC_2.3.2 A GLIBC_2.3.2 pthread_cond_broadcast F GLIBC_2.3.2 pthread_cond_destroy F diff --git a/sysdeps/unix/sysv/linux/nios2/libpthread.abilist b/sysdeps/unix/sysv/linux/nios2/libpthread.abilist index a10bbde..c16a527 100644 --- a/sysdeps/unix/sysv/linux/nios2/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/nios2/libpthread.abilist @@ -221,3 +221,29 @@ GLIBC_2.21 tcdrain F GLIBC_2.21 wait F GLIBC_2.21 waitpid F GLIBC_2.21 write F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist index 14c3a86..0d007e3 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist @@ -216,6 +216,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A GLIBC_2.2.3 pthread_getattr_np F GLIBC_2.2.6 GLIBC_2.2.6 A GLIBC_2.2.6 __nanosleep F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F GLIBC_2.3.2 GLIBC_2.3.2 A GLIBC_2.3.2 pthread_cond_broadcast F GLIBC_2.3.2 pthread_cond_destroy F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist index 0cf30ee..dceef50 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist @@ -224,3 +224,29 @@ GLIBC_2.17 write F GLIBC_2.18 GLIBC_2.18 A GLIBC_2.18 pthread_getattr_default_np F GLIBC_2.18 pthread_setattr_default_np F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist index 464b91a..da8acf2 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist @@ -9,6 +9,32 @@ GLIBC_2.12 pthread_setname_np F GLIBC_2.18 GLIBC_2.18 A GLIBC_2.18 pthread_getattr_default_np F GLIBC_2.18 pthread_setattr_default_np F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F GLIBC_2.3 GLIBC_2.3 A GLIBC_2.3 _IO_flockfile F GLIBC_2.3 _IO_ftrylockfile F diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist index 3c5e11a..6db9021 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist @@ -219,6 +219,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A GLIBC_2.2.3 pthread_getattr_np F GLIBC_2.2.6 GLIBC_2.2.6 A GLIBC_2.2.6 __nanosleep F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F GLIBC_2.3.2 GLIBC_2.3.2 A GLIBC_2.3.2 pthread_cond_broadcast F GLIBC_2.3.2 pthread_cond_destroy F diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist index 83a1fcd..82a82b9 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist @@ -207,6 +207,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A GLIBC_2.2.3 pthread_getattr_np F GLIBC_2.2.6 GLIBC_2.2.6 A GLIBC_2.2.6 __nanosleep F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F GLIBC_2.3.2 GLIBC_2.3.2 A GLIBC_2.3.2 pthread_cond_broadcast F GLIBC_2.3.2 pthread_cond_destroy F diff --git a/sysdeps/unix/sysv/linux/sh/libpthread.abilist b/sysdeps/unix/sysv/linux/sh/libpthread.abilist index a73aa43..f44d016 100644 --- a/sysdeps/unix/sysv/linux/sh/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/sh/libpthread.abilist @@ -204,6 +204,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A GLIBC_2.2.3 pthread_getattr_np F GLIBC_2.2.6 GLIBC_2.2.6 A GLIBC_2.2.6 __nanosleep F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F GLIBC_2.3.2 GLIBC_2.3.2 A GLIBC_2.3.2 pthread_cond_broadcast F GLIBC_2.3.2 pthread_cond_destroy F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist index 7e121d4..b55f124 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist @@ -216,6 +216,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A GLIBC_2.2.3 pthread_getattr_np F GLIBC_2.2.6 GLIBC_2.2.6 A GLIBC_2.2.6 __nanosleep F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F GLIBC_2.3.2 GLIBC_2.3.2 A GLIBC_2.3.2 pthread_cond_broadcast F GLIBC_2.3.2 pthread_cond_destroy F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist index d4c8ded..71be092 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist @@ -204,6 +204,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A GLIBC_2.2.3 pthread_getattr_np F GLIBC_2.2.6 GLIBC_2.2.6 A GLIBC_2.2.6 __nanosleep F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F GLIBC_2.3.2 GLIBC_2.3.2 A GLIBC_2.3.2 pthread_cond_broadcast F GLIBC_2.3.2 pthread_cond_destroy F diff --git a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libpthread.abilist b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libpthread.abilist index d16158f..9193461 100644 --- a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libpthread.abilist @@ -224,3 +224,29 @@ GLIBC_2.12 write F GLIBC_2.18 GLIBC_2.18 A GLIBC_2.18 pthread_getattr_default_np F GLIBC_2.18 pthread_setattr_default_np F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F diff --git a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libpthread.abilist b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libpthread.abilist index d16158f..9193461 100644 --- a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libpthread.abilist @@ -224,3 +224,29 @@ GLIBC_2.12 write F GLIBC_2.18 GLIBC_2.18 A GLIBC_2.18 pthread_getattr_default_np F GLIBC_2.18 pthread_setattr_default_np F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F diff --git a/sysdeps/unix/sysv/linux/tile/tilepro/libpthread.abilist b/sysdeps/unix/sysv/linux/tile/tilepro/libpthread.abilist index d16158f..9193461 100644 --- a/sysdeps/unix/sysv/linux/tile/tilepro/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/tile/tilepro/libpthread.abilist @@ -224,3 +224,29 @@ GLIBC_2.12 write F GLIBC_2.18 GLIBC_2.18 A GLIBC_2.18 pthread_getattr_default_np F GLIBC_2.18 pthread_setattr_default_np F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist index 85365c0..c942c64 100644 --- a/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist @@ -203,6 +203,32 @@ GLIBC_2.2.5 waitpid F GLIBC_2.2.5 write F GLIBC_2.2.6 GLIBC_2.2.6 A GLIBC_2.2.6 __nanosleep F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F GLIBC_2.3.2 GLIBC_2.3.2 A GLIBC_2.3.2 pthread_cond_broadcast F GLIBC_2.3.2 pthread_cond_destroy F diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist index 6cd0fc3..5908592 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist @@ -224,3 +224,29 @@ GLIBC_2.16 write F GLIBC_2.18 GLIBC_2.18 A GLIBC_2.18 pthread_getattr_default_np F GLIBC_2.18 pthread_setattr_default_np F +GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 call_once F +GLIBC_2.27 cnd_broadcast F +GLIBC_2.27 cnd_destroy F +GLIBC_2.27 cnd_init F +GLIBC_2.27 cnd_signal F +GLIBC_2.27 cnd_timedwait F +GLIBC_2.27 cnd_wait F +GLIBC_2.27 mtx_destroy F +GLIBC_2.27 mtx_init F +GLIBC_2.27 mtx_lock F +GLIBC_2.27 mtx_timedlock F +GLIBC_2.27 mtx_trylock F +GLIBC_2.27 mtx_unlock F +GLIBC_2.27 thrd_create F +GLIBC_2.27 thrd_current F +GLIBC_2.27 thrd_detach F +GLIBC_2.27 thrd_equal F +GLIBC_2.27 thrd_exit F +GLIBC_2.27 thrd_join F +GLIBC_2.27 thrd_sleep F +GLIBC_2.27 thrd_yield F +GLIBC_2.27 tss_create F +GLIBC_2.27 tss_delete F +GLIBC_2.27 tss_get F +GLIBC_2.27 tss_set F From patchwork Fri Sep 22 20:27:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 114096 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp3474481edb; Fri, 22 Sep 2017 13:28:41 -0700 (PDT) X-Received: by 10.99.114.29 with SMTP id n29mr305496pgc.218.1506112121588; Fri, 22 Sep 2017 13:28:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506112121; cv=none; d=google.com; s=arc-20160816; b=0kbJkGaKCGIoFUHvdCJQ8RSP2qldO85B/0e0Q/Wls4GkjHDulEdjBdaZfLyQUnDcsq Muv1OEAEWs8njJ9vTZSl2epKGdoU5gTA12pHOxRfM4RWhGo3HgqJWiDqzh5Pd4dE8KdS yxSkoSKuuIu1xQ1Lm5x3OhYXw9K4FxDS8qyks9oGcmgEj0ji844cZa6K/xWjfq1r3dHV uCl+tj2CvwHoxGUBMfuZdAgST1vIR/offVJ4AGJA0TcfgBDUf7oCZlMAkt808/8w9IS5 nzx9rIJ2KDq08bLn/5QGbQRKzvtcS07+zA9ndr3muZkHuxFhV1Wdd7FZ/+SfhVNqN5nc aPJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=v3z/WsAVi7JQZfrPQ8f22lxXuO1nfrSXDuGe3789BGQ=; b=EZremt3iRXDtK5geh5/UnpaYy0Dq/E/7+FAcQ9XkEwrTWzkye7uvpL58w6zDLeOR3x fKNwJEDPWGslemV7/MX/+zd6cBJ5NbNwxYItjPSdAo7vlQnrkLN/M5aGFqt2lif06VUr aDJTJnffRrsHvM1WqmivYadNR3y0pF/joPhdg+ZT6NhMUvRQqnZCFQ24HXzlAjwuV0j7 +45Z1lQ3NsKe8F7WEBKaSvfnzmwFyetMG4K++iidYtI7Vz26YCryoKJ1ai1/1QzqRT2G ec60Y2Z0B+hJuFzAYYV3a3RJ/b95ah0q5M8a4KIhP5+iUf18qQBUX/8CVTcJ/r30xxqJ VV+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Ie2yHcwh; spf=pass (google.com: domain of libc-alpha-return-84880-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-84880-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id z15si324345pfd.587.2017.09.22.13.28.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Sep 2017 13:28:41 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-84880-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Ie2yHcwh; spf=pass (google.com: domain of libc-alpha-return-84880-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-84880-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=oQT/dNxdxsKYqzHmE1nuh7mMFAn0/uc S/VRJLtcK+3d/OSHDp2NP+vJTyf47JnO698zS1th/JPdzzRxbrUzQ0rvh7F7S5Mw 4haTAnDkssnpKhOgyNpxAWPCrDJGygba6helSirs2ScLLfLWmgdLusCA+gRhJ2l/ hezfzf4H0lOc= 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:subject:date:message-id:in-reply-to :references; s=default; bh=ljeGqeAnN0qLgPDUJNq0QwSpzK4=; b=Ie2yH cwhUPI+WrvOXTxwVK09nwPhfDneWk08sgdbNhUtE2rWW41U563W5PswgRT5md398 yvV1xO1IVtOsGba7+m6epT0Y3+sW6Ac6E2poHhHCNH2V6fiekG9b8pAsw4y4rbZC OcnQyigWfjuDDBz88yaJXrqO+sNEf8lpVl7Rhs= Received: (qmail 67151 invoked by alias); 22 Sep 2017 20:27: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 67070 invoked by uid 89); 22 Sep 2017 20:27:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f170.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=v3z/WsAVi7JQZfrPQ8f22lxXuO1nfrSXDuGe3789BGQ=; b=adAP4xo7ARODHd2pLVXHApJhrArvYkx/euP8sRLXzovBRAIc5adnUSRv1wCIfmZjE5 Pc6ufneGMPFxCyJySFx0Sww6I7TpdIxx+bO2TiRXteSoPQRrBLTT8dkOW6mzo89pgmI7 Pl40bceTdn1MvZsl9FDDZJjA3vRLOXNeYu4m3+fwNcWhA6KgkfWPkS3LNUJk6Fgwqk+z BmCfksQCfNvNDOBoV9bhDhRiD8edyMm/7tdeoP7VC7nWVzQtaNJNz1MpUDtzCMeVr1eZ wBxTGoFieBiiDg8aKxGDw2JmiSwYgdxjg1CKEBQV5ETcIEsEgd5WdBhhU79gJLaDgOuo mXGQ== X-Gm-Message-State: AHPjjUhbVJ/1DTAUktZ1Wa63U38dLuuvPigZ8B+sZjyxIkdd97x4QZUh GuKZXvHTlIrnhzQOCwyTCDq5psg4Tts= X-Google-Smtp-Source: AOwi7QAcpvydIkZPyKJYj7jhf4FLcnIdFaeHTW6VPIRcukWEQNIk453IuDj4pullw8AbTKVQhFVaOQ== X-Received: by 10.200.49.202 with SMTP id i10mr583420qte.63.1506112043030; Fri, 22 Sep 2017 13:27:23 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 7/8] nptl: Add test cases for ISO C11 threads Date: Fri, 22 Sep 2017 17:27:03 -0300 Message-Id: <1506112024-22601-8-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1506112024-22601-1-git-send-email-adhemerval.zanella@linaro.org> References: <1506112024-22601-1-git-send-email-adhemerval.zanella@linaro.org> This patch adds to testsuite new test cases to test all new introduced C11 threads functions, types and macros are tested. Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu, arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu, microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu, powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu, tile{pro,gx}-linux-gnu, and x86_64-linux-gnu). Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu, arm-linux-gnueabhf, and powerpc64le-linux-gnu. Adhemerval Zanella Juan Manuel Torres Palma * nptl/Makefile (tests): Add new test files. * nptl/tst-call-once.c : New file. Tests C11 functions and types. * nptl/tst-cnd-basic.c: Likewise. * nptl/tst-cnd-broadcast.c: Likewise. * nptl/tst-cnd-timedwait.c: Likewise. * nptl/tst-mtx-basic.c: Likewise. * nptl/tst-mtx-recursive.c: Likewise. * nptl/tst-mtx-timedlock.c: Likewise. * nptl/tst-mtx-trylock.c: Likewise. * nptl/tst-thrd-basic.c: Likewise. * nptl/tst-thrd-detach.c: Likewise. * nptl/tst-thrd-sleep.c: Likewise. * nptl/tst-tss-basic.c: Likewise. --- ChangeLog | 17 +++++++++ nptl/Makefile | 5 ++- nptl/tst-call-once.c | 66 ++++++++++++++++++++++++++++++++ nptl/tst-cnd-basic.c | 68 +++++++++++++++++++++++++++++++++ nptl/tst-cnd-broadcast.c | 83 ++++++++++++++++++++++++++++++++++++++++ nptl/tst-cnd-timedwait.c | 70 ++++++++++++++++++++++++++++++++++ nptl/tst-mtx-basic.c | 73 ++++++++++++++++++++++++++++++++++++ nptl/tst-mtx-recursive.c | 45 ++++++++++++++++++++++ nptl/tst-mtx-timedlock.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++ nptl/tst-mtx-trylock.c | 90 ++++++++++++++++++++++++++++++++++++++++++++ nptl/tst-thrd-detach.c | 52 +++++++++++++++++++++++++ nptl/tst-thrd-sleep.c | 51 +++++++++++++++++++++++++ nptl/tst-tss-basic.c | 75 ++++++++++++++++++++++++++++++++++++ 13 files changed, 792 insertions(+), 1 deletion(-) create mode 100644 nptl/tst-call-once.c create mode 100644 nptl/tst-cnd-basic.c create mode 100644 nptl/tst-cnd-broadcast.c create mode 100644 nptl/tst-cnd-timedwait.c create mode 100644 nptl/tst-mtx-basic.c create mode 100644 nptl/tst-mtx-recursive.c create mode 100644 nptl/tst-mtx-timedlock.c create mode 100644 nptl/tst-mtx-trylock.c create mode 100644 nptl/tst-thrd-detach.c create mode 100644 nptl/tst-thrd-sleep.c create mode 100644 nptl/tst-tss-basic.c -- 2.7.4 diff --git a/nptl/Makefile b/nptl/Makefile index 0bf46ce..6e179b0 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -308,7 +308,10 @@ tests = tst-attr1 tst-attr2 tst-attr3 tst-default-attr \ c89 gnu89 c99 gnu99 c11 gnu11) \ tst-bad-schedattr \ tst-thread_local1 tst-mutex-errorcheck tst-robust10 \ - tst-robust-fork tst-create-detached tst-memstream + tst-robust-fork tst-create-detached tst-memstream \ + 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 tests-internal := tst-typesizes \ tst-rwlock19 tst-rwlock20 \ diff --git a/nptl/tst-call-once.c b/nptl/tst-call-once.c new file mode 100644 index 0000000..331174e --- /dev/null +++ b/nptl/tst-call-once.c @@ -0,0 +1,66 @@ +/* C11 threads call_once test. + Copyright (C) 2017 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 +#include + +#include + +/* Flag that controls the first thread access. */ +static once_flag flag = ONCE_FLAG_INIT; + +static int value = 0; + +static void +do_once (void) +{ + value++; +} + +static int +func (void* data) +{ + call_once (&flag, do_once); + thrd_exit (thrd_success); +} + +#define N 20 + +int +do_test (void) +{ + thrd_t ids[N]; + + for (int i = 0; i < N; ++i) + { + if (thrd_create (&ids[i], func, NULL) != thrd_success) + FAIL_EXIT1 ("thrd_create failed"); + } + + /* Join threads. */ + for (int i = 0; i < N; ++i) + { + if (thrd_join (ids[i], NULL) != thrd_success) + FAIL_EXIT1 ("thrd_join failed"); + } + + return (value != 1); +} + +#include diff --git a/nptl/tst-cnd-basic.c b/nptl/tst-cnd-basic.c new file mode 100644 index 0000000..56de4d7 --- /dev/null +++ b/nptl/tst-cnd-basic.c @@ -0,0 +1,68 @@ +/* C11 threads condition variable tests. + Copyright (C) 2017 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 +#include + +#include + +/* Shared condition variable between child and parent. */ +static cnd_t cond; + +/* Mutex needed to signal and wait threads. */ +static mtx_t mutex; + +static int +signal_parent (void) +{ + if (cnd_signal (&cond) != thrd_success) + FAIL_EXIT1 ("cnd_signal"); + + thrd_exit (thrd_success); +} + +static int +do_test (void) +{ + thrd_t id; + + if (cnd_init (&cond) != thrd_success) + FAIL_EXIT1 ("cnd_init failed"); + if (mtx_init (&mutex, mtx_plain) != thrd_success) + FAIL_EXIT1 ("mtx_init failed"); + + if (thrd_create (&id, (thrd_start_t) signal_parent, NULL) + != thrd_success) + FAIL_EXIT1 ("thrd_create failed"); + + if (cnd_wait (&cond, &mutex) != thrd_success) + FAIL_EXIT1 ("cnd_wait failed"); + + /* Joining is not mandatory here, but still done to assure child thread + ends correctly. */ + if (thrd_join (id, NULL) != thrd_success) + FAIL_EXIT1 ("thrd_join failed"); + + mtx_destroy (&mutex); + cnd_destroy (&cond); + + return 0; +} + +#include diff --git a/nptl/tst-cnd-broadcast.c b/nptl/tst-cnd-broadcast.c new file mode 100644 index 0000000..1ca87a3 --- /dev/null +++ b/nptl/tst-cnd-broadcast.c @@ -0,0 +1,83 @@ +/* C11 threads condition broadcast variable tests. + Copyright (C) 2017 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 +#include + +#include + +/* Condition variable where child threads will wait. */ +static cnd_t cond; + +/* Mutex to control wait on cond. */ +static mtx_t mutex; + +/* Code executed by each thread. */ +static int +child_wait (void* data) +{ + /* Wait until parent thread sends broadcast here. */ + mtx_lock (&mutex); + cnd_wait (&cond, &mutex); + mtx_unlock (&mutex); + + thrd_exit (thrd_success); +} + +#define N 5 + +static int +do_test (void) +{ + thrd_t ids[N]; + unsigned char i; + + if (cnd_init (&cond) != thrd_success) + FAIL_EXIT1 ("cnd_init failed"); + if (mtx_init (&mutex, mtx_plain) != thrd_success) + FAIL_EXIT1 ("mtx_init failed"); + + /* Create N new threads. */ + for (i = 0; i < N; ++i) + { + if (thrd_create (&ids[i], child_wait, NULL) != thrd_success) + FAIL_EXIT1 ("thrd_create failed"); + } + + /* Wait for other threads to reach their wait func. */ + thrd_sleep (&((struct timespec){.tv_sec = 2}), NULL); + + mtx_lock (&mutex); + if (cnd_broadcast (&cond) != thrd_success) + FAIL_EXIT1 ("cnd_broadcast failed"); + mtx_unlock (&mutex); + + for (i = 0; i < N; ++i) + { + if (thrd_join (ids[i], NULL) != thrd_success) + FAIL_EXIT1 ("thrd_join failed"); + } + + mtx_destroy (&mutex); + cnd_destroy (&cond); + + return 0; +} + +#include diff --git a/nptl/tst-cnd-timedwait.c b/nptl/tst-cnd-timedwait.c new file mode 100644 index 0000000..64a9546 --- /dev/null +++ b/nptl/tst-cnd-timedwait.c @@ -0,0 +1,70 @@ +/* C11 threads condition timed wait variable tests. + Copyright (C) 2017 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 +#include + +#include + +/* Shared condition variable between child and parent. */ +static cnd_t cond; + +/* Mutex needed to signal and wait threads. */ +static mtx_t mutex; + +static int +signal_parent (void *arg) +{ + if (cnd_signal (&cond) != thrd_success) + FAIL_EXIT1 ("cnd_signal failed"); + + thrd_exit (thrd_success); +} + +static int +do_test (void) +{ + thrd_t id; + struct timespec w_time; + + if (cnd_init (&cond) != thrd_success) + FAIL_EXIT1 ("cnd_init failed"); + if (mtx_init (&mutex, mtx_plain) != thrd_success) + FAIL_EXIT1 ("mtx_init failed"); + + if (clock_gettime (CLOCK_REALTIME, &w_time) != 0) + FAIL_EXIT1 ("clock_gettime failed"); + w_time.tv_nsec += 150000; + + if (thrd_create (&id, signal_parent, NULL) != thrd_success) + FAIL_EXIT1 ("thrd_create failed"); + + if (cnd_timedwait (&cond, &mutex, &w_time) != thrd_success) + FAIL_EXIT1 ("cnd_timedwait failed"); + + if (thrd_join (id, NULL) != thrd_success) + FAIL_EXIT1 ("thrd_join failed"); + + mtx_destroy (&mutex); + cnd_destroy (&cond); + + return 0; +} + +#include diff --git a/nptl/tst-mtx-basic.c b/nptl/tst-mtx-basic.c new file mode 100644 index 0000000..c064405 --- /dev/null +++ b/nptl/tst-mtx-basic.c @@ -0,0 +1,73 @@ +/* C11 threads basic mutex tests. + Copyright (C) 2017 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 +#include + +#include + +/* Shared mutex between child and parent. */ +static mtx_t mutex; + +/* Shared counter to check possible race conditions. */ +static int counter; + +static int +child_add (void *arg) +{ + if (mtx_lock (&mutex) != thrd_success) + FAIL_EXIT1 ("mtx_lock failed"); + + counter++; + + if (mtx_unlock (&mutex) != thrd_success) + FAIL_EXIT1 ("mtx_unlock failed"); + + thrd_exit (thrd_success); +} + +static int +do_test (void) +{ + mtx_init (&mutex, mtx_plain); + + thrd_t id; + if (thrd_create (&id, child_add, NULL) != thrd_success) + FAIL_EXIT1 ("thrd_create failed"); + + if (mtx_lock (&mutex) != thrd_success) + FAIL_EXIT1 ("mtx_lock failed"); + + counter++; + + if (mtx_unlock (&mutex) != thrd_success) + FAIL_EXIT1 ("mtx_unlock failed"); + + if (thrd_join (id, NULL) != thrd_success) + FAIL_EXIT1 ("thrd_join failed"); + + if (counter != 2) + FAIL_EXIT1 ("counter (%d) != 2", counter); + + mtx_destroy (&mutex); + + return 0; +} + +#include diff --git a/nptl/tst-mtx-recursive.c b/nptl/tst-mtx-recursive.c new file mode 100644 index 0000000..df959c7 --- /dev/null +++ b/nptl/tst-mtx-recursive.c @@ -0,0 +1,45 @@ +/* C11 threads recursive mutex tests. + Copyright (C) 2017 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 +#include + +#include + +static int +do_test (void) +{ + static mtx_t mutex; + + if (mtx_init (&mutex, mtx_recursive) != thrd_success) + FAIL_EXIT1 ("mtx_init failed"); + + if (mtx_lock (&mutex) != thrd_success) + FAIL_EXIT1 ("mtx_lock failed"); + + /* Lock mutex second time, if not recursive should deadlock. */ + if (mtx_lock (&mutex) != thrd_success) + FAIL_EXIT1 ("mtx_lock failed"); + + mtx_destroy (&mutex); + + return 0; +} + +#include diff --git a/nptl/tst-mtx-timedlock.c b/nptl/tst-mtx-timedlock.c new file mode 100644 index 0000000..1f02bd4 --- /dev/null +++ b/nptl/tst-mtx-timedlock.c @@ -0,0 +1,98 @@ +/* C11 threads timed mutex tests. + Copyright (C) 2017 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 +#include + +#include + +/* Shared mutex between child and parent. */ +static mtx_t mutex; + +/* Shared counter to check possible race conditions. */ +static char shrd_counter; + +/* Maximum amount of time waiting for mutex. */ +static struct timespec wait_time; + +/* Function to choose an action to do, depending on mtx_timedlock + return value. */ +static inline void +choose_action (int action, char* thread_name) +{ + switch (action) + { + case thrd_success: + ++shrd_counter; + + if (mtx_unlock (&mutex) != thrd_success) + FAIL_EXIT1 ("mtx_unlock failed"); + break; + + case thrd_timedout: + break; + + case thrd_error: + FAIL_EXIT1 ("%s lock error", thread_name); + break; + } +} + +static int +child_add (void *arg) +{ + char child_name[] = "child"; + + /* Try to lock mutex. */ + choose_action (mtx_timedlock (&mutex, &wait_time), child_name); + thrd_exit (thrd_success); +} + +static int +do_test (void) +{ + thrd_t id; + char parent_name[] = "parent"; + + if (mtx_init (&mutex, mtx_timed) != thrd_success) + FAIL_EXIT1 ("mtx_init failed"); + + if (clock_gettime (CLOCK_REALTIME, &wait_time) != 0) + FAIL_EXIT1 ("clock_gettime failed"); + /* Tiny amount of time, to assure that if any thread finds it busy. + It will receive thrd_timedout. */ + wait_time.tv_nsec += 1; + + if (thrd_create (&id, child_add, NULL) != thrd_success) + FAIL_EXIT1 ("thrd_create failed"); + + choose_action (mtx_timedlock (&mutex, &wait_time), parent_name); + + if (thrd_join (id, NULL) != thrd_success) + FAIL_EXIT1 ("thrd_join failed"); + + if (shrd_counter != 2 && shrd_counter != 1) + FAIL_EXIT1 ("shrd_counter != {1,2} (%d)", shrd_counter); + + mtx_destroy (&mutex); + + return 0; +} + +#include diff --git a/nptl/tst-mtx-trylock.c b/nptl/tst-mtx-trylock.c new file mode 100644 index 0000000..5c1e804 --- /dev/null +++ b/nptl/tst-mtx-trylock.c @@ -0,0 +1,90 @@ +/* C11 threads trylock mutex tests. + Copyright (C) 2017 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 +#include + +#include + +/* Shared mutex between child and parent. */ +static mtx_t mutex; + +/* Shared counter to check possible race conditions. */ +static char shrd_counter; + +/* Function to choose an action to do, depending on mtx_trylock + return value. */ +static inline void +choose_action (int action, char* thread_name) +{ + switch (action) + { + case thrd_success: + ++shrd_counter; + + if (mtx_unlock (&mutex) != thrd_success) + FAIL_EXIT1 ("mtx_unlock failed"); + break; + + case thrd_busy: + break; + + case thrd_error: + FAIL_EXIT1 ("%s lock error", thread_name); + break; + } +} + +static int +child_add (void *arg) +{ + char child_name[] = "child"; + + /* Try to lock mutex. */ + choose_action (mtx_trylock (&mutex), child_name); + + thrd_exit (thrd_success); +} + +static int +do_test (void) +{ + thrd_t id; + char parent_name[] = "parent"; + + if (mtx_init (&mutex, mtx_timed) != thrd_success) + FAIL_EXIT1 ("mtx_init failed"); + + if (thrd_create (&id, child_add, NULL) != thrd_success) + FAIL_EXIT1 ("thrd_create failed"); + + choose_action (mtx_trylock (&mutex), parent_name); + + if (thrd_join (id, NULL) != thrd_success) + FAIL_EXIT1 ("thrd_join failed"); + + if (shrd_counter != 2 && shrd_counter != 1) + FAIL_EXIT1 ("shrd_counter != {1,2} (%d)", shrd_counter); + + mtx_destroy (&mutex); + + return 0; +} + +#include diff --git a/nptl/tst-thrd-detach.c b/nptl/tst-thrd-detach.c new file mode 100644 index 0000000..ec28173 --- /dev/null +++ b/nptl/tst-thrd-detach.c @@ -0,0 +1,52 @@ +/* C11 threads thread detach tests. + Copyright (C) 2017 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 +#include +#include + +#include + +static int +detach_thrd (void *arg) +{ + if (thrd_detach (thrd_current ()) != thrd_success) + FAIL_EXIT1 ("thrd_detach failed"); + thrd_exit (thrd_success); +} + +static int +do_test (void) +{ + thrd_t id; + + /* Create new thread. */ + if (thrd_create (&id, detach_thrd, NULL) != thrd_success) + FAIL_EXIT1 ("thrd_create failed"); + + /* Give some time so the thread can finish. */ + thrd_sleep (&(struct timespec){.tv_sec = 2}, NULL); + + if (thrd_join (id, NULL) == thrd_success) + FAIL_EXIT1 ("thrd_join succeed where it should fail"); + + return 0; +} + +#include diff --git a/nptl/tst-thrd-sleep.c b/nptl/tst-thrd-sleep.c new file mode 100644 index 0000000..17380b2 --- /dev/null +++ b/nptl/tst-thrd-sleep.c @@ -0,0 +1,51 @@ +/* C11 threads thread sleep tests. + Copyright (C) 2017 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 +#include +#include + +#include + +static int +sleep_thrd (void *arg) +{ + struct timespec const *tl = (struct timespec const *) arg; + if (thrd_sleep (tl, NULL) != thrd_success) + FAIL_EXIT1 ("thrd_sleep failed"); + + thrd_exit (thrd_success); +} + +static int +do_test (void) +{ + thrd_t id; + struct timespec wait_time = {.tv_sec = 3}; + + if (thrd_create (&id, sleep_thrd, (void *) (&wait_time)) != thrd_success) + FAIL_EXIT1 ("thrd_create failed"); + + if (thrd_join (id, NULL) != thrd_success) + FAIL_EXIT1 ("thrd failed"); + + return 0; +} + +#include diff --git a/nptl/tst-tss-basic.c b/nptl/tst-tss-basic.c new file mode 100644 index 0000000..8181dc1 --- /dev/null +++ b/nptl/tst-tss-basic.c @@ -0,0 +1,75 @@ +/* C11 threads specific storage tests. + Copyright (C) 2017 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 +#include + +#include + +/* Thread specific storage. */ +static tss_t key; + +#define TSS_VALUE (void*) 0xFF + +static int +tss_thrd (void *arg) +{ + if (tss_create (&key, NULL) != thrd_success) + FAIL_EXIT1 ("tss_create failed"); + + if (tss_set (key, TSS_VALUE)) + FAIL_EXIT1 ("tss_set failed"); + + void *value = tss_get (key); + if (value == 0) + FAIL_EXIT1 ("tss_get failed"); + if (value != TSS_VALUE) + FAIL_EXIT1 ("tss_get returned %p, expected %p", value, TSS_VALUE); + + thrd_exit (thrd_success); +} + +static int +do_test (void) +{ + /* Setting an invalid key should return an error. */ + if (tss_set (key, TSS_VALUE) == thrd_success) + FAIL_EXIT1 ("tss_set succeed where it should have failed"); + + if (tss_create (&key, NULL) != thrd_success) + FAIL_EXIT1 ("tss_create failed"); + + thrd_t id; + if (thrd_create (&id, tss_thrd, NULL) != thrd_success) + FAIL_EXIT1 ("thrd_create failed"); + + if (thrd_join (id, NULL) != thrd_success) + FAIL_EXIT1 ("thrd failed"); + + /* The value set in tss_thrd should not be visible here. */ + void *value = tss_get (key); + if (value != 0) + FAIL_EXIT1 ("tss_get succeed where it should have failed"); + + tss_delete (key); + + return 0; +} + +#include From patchwork Fri Sep 22 20:27:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 114097 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp3474614edb; Fri, 22 Sep 2017 13:28:50 -0700 (PDT) X-Received: by 10.99.96.10 with SMTP id u10mr321933pgb.70.1506112130646; Fri, 22 Sep 2017 13:28:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506112130; cv=none; d=google.com; s=arc-20160816; b=WkQZpnKLN+d9pZQ9tjwSuwPk6006n5Fi4AK4sj8gJAaHvV/HGs2/5+BKlChRt57XMC tMvBJZRp96TPbLGkZs+PrqPbVMZW8OPu6D3AfUrRiRDB0jp8kvS4JBHag98mjQNSYUt4 RPQIBnhUqJGNRMeuH9uziUUlKPk8cBIj6DPWRPT0tjDCVdPPmieuSSHYBhm7I9QCIp/S Zdx6FWSAPrYmksRrK7Am/w2jR250+mzMNt1s+tUCzBWUnrNuYBs1S/oNrbNua23QFwdX BJfEhl30cyUrBB61PcyPQnexA0IsX1pbOhYTH9tqeWQDhbXf3bJ9miIGEMP+R5+7idUn kO+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :delivered-to:sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=skDukZHN+ab2ANXygfBkgjH2niVl8KtGCWfs8CxoRzQ=; b=C+Q+tVxgA3TbgQOKNvyFUbNpAhYGD/irwszHIXKDSokfcAtkL3LGW0TnZwg++23ziq Wz59rY5mNpTMmmZgk7YjlxxKVJHOmn34BvYh7uJfDBL62e79VUR1GrDgRicFnBjRbEl5 m6UHv+jEfjlH/zEnciyf6KzW/4EBBqUjcWqdR5A7KR4Hv3ivl3aWT/SUv3b65x+euvOo PmD5oKW617euXk1NtBRlsguA1vct83ydGbZmfO/ZFJPSte/X/rlYKr5NfbXqIkP4dbz3 NB+juQ8sJLuUNw03qQuyzBfg8r4Gzj1Dxzg41/omcQrq736Q5BKo1USzQ+70/RUdb68C 8q6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=KcjUGMCQ; spf=pass (google.com: domain of libc-alpha-return-84881-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-84881-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id t85si347040pfg.23.2017.09.22.13.28.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Sep 2017 13:28:50 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-84881-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=KcjUGMCQ; spf=pass (google.com: domain of libc-alpha-return-84881-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-84881-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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; q=dns; s=default; b=id1PLrGcAM7jzu63lxrQZu5Pyw6abfm oTcL5BjzGbrNuODkYO0joW9UYEpVrMb6Q4puN0Vbc+ZFMhaogeFLj7UibZER7oYB bHfzRbT3c1FvH7UE1tZ3ufVvS7kf8v0moLI++Qq5LzLYYjswUhpHvYzT2mkfXpRx 2dWBtLbm/TpI= 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; s=default; bh=Kc9v+0pD+A5wLOKlFc5Pd8jt6XU=; b=KcjUG MCQymD2fWD481iuMZAQ7ocf1y+z5HlkIG2eXWvkfK1ETPlfPhJBFtrAvl4vos03U SE2NzfwP2wkfpb184zfzkamje4meTr+G/Ew7W+AW+oY2fTVUDrhatEC10QbT/m+l DADyAIeClJBnGWYXBRbogE8+Nral9WLmnodOI0= Received: (qmail 67168 invoked by alias); 22 Sep 2017 20:27: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 67110 invoked by uid 89); 22 Sep 2017 20:27:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=mutual, ipc, acquiring, TSS X-HELO: mail-qk0-f175.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=skDukZHN+ab2ANXygfBkgjH2niVl8KtGCWfs8CxoRzQ=; b=R1L4B7kEpNO25PYJjFESudrbqMR4vv/JF7hV9u3bG8cZYwaLz5X+que5CgG2CqTQij exi/IMIgs3PN8I5THTjCfog2c0GWHGQ6azE+sBCMQeXZCWyHOhZLdXudcWVzvoXMNaRI xWj14WCxYqPy5NorGpq+YXfJhsHHxpBHs1Qne3nb9a0BeqYWcMQqu4MyOKxBrDTj1Mo9 D6PSo447UIRSC+F+VPam3TAH1hH08AmKgixhUS6pvH0HC88P4ZqPvzz7KzNsPPLJXUlT awVgGxYYdUo1U0ZlNJtJG5ykn/XTLhXoqIFB31VNAGn5gPtPAqrO3M48lAQvHojdYOeZ eHsA== X-Gm-Message-State: AHPjjUgevCZpI+jaNsZUrhR/xMJPWC/7G/qCz+I9KVcB7nSYmuupKP0/ hdge16Ytq0QgRTakbPT/GFx6yeV95jc= X-Google-Smtp-Source: AOwi7QDuB9qjFpDUrMhn5LctLoHD2L3PXax1w6czBTvJ7nBGTn7wctdMo5AWYu391HzRVhdhcI611Q== X-Received: by 10.55.74.133 with SMTP id x127mr477904qka.239.1506112044617; Fri, 22 Sep 2017 13:27:24 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Juan Manuel Torres Palma Subject: [PATCH 8/8] Add manual documentation for threads.h Date: Fri, 22 Sep 2017 17:27:04 -0300 Message-Id: <1506112024-22601-9-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1506112024-22601-1-git-send-email-adhemerval.zanella@linaro.org> References: <1506112024-22601-1-git-send-email-adhemerval.zanella@linaro.org> From: Juan Manuel Torres Palma This patch updates the manual and adds a new chapter to the manual, explaining types macros, constants and functions defined by ISO C11 threads.h standard. * manual/Makefile (chapters): Add isothreads.texi. * manual/isothreads.texi: New file. Add new chapter for ISO C11 threads documentation. --- ChangeLog | 4 + manual/Makefile | 2 +- manual/isothreads.texi | 355 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 360 insertions(+), 1 deletion(-) create mode 100644 manual/isothreads.texi -- 2.7.4 diff --git a/manual/Makefile b/manual/Makefile index 4ed63a8..e54e0cf 100644 --- a/manual/Makefile +++ b/manual/Makefile @@ -39,7 +39,7 @@ chapters = $(addsuffix .texi, \ pipe socket terminal syslog math arith time \ resource setjmp signal startup process ipc job \ nss users sysinfo conf crypt debug threads \ - probes tunables) + probes tunables isothreads) add-chapters = $(wildcard $(foreach d, $(add-ons), ../$d/$d.texi)) appendices = lang.texi header.texi install.texi maint.texi platform.texi \ contrib.texi diff --git a/manual/isothreads.texi b/manual/isothreads.texi new file mode 100644 index 0000000..bcdf127 --- /dev/null +++ b/manual/isothreads.texi @@ -0,0 +1,355 @@ +@node ISO Threads, , , Top +@chapter ISO C11 threads + +This chapter describes @theglibc{} ISO C11 threads implementation. +To have a deeper understanding of this API, is strongly recomended +to read ISO/IEC 9899:2011, section 7.26 where ISO C11 threads +are specified. +All types and function prototypes are declared in +@file{threads.h} header. +@pindex threads.h + +@menu +* Thread Creation and Control:: Support for basic threading. +* Call Once:: Single call macros and functions. +* Mutex:: Low level mechanism for mutual exclusion. +* Condition variable:: High level objects for thread synchronization. +* Thread-local storage:: Functions to support thread-local storage. +* C11 error types:: Symbolic constants that represent functions return value. +@end menu + +@node Thread Creation and Control, Call Once, , ISO Threads +@section Thread Creation and Control + +@Theglibc{} implements a set of functions that allow the user to easily +create and use threads. Many extra functionalities are provided to control +the behaviour of threads. The following functions and types are defined: + +@deftp {Data Type} {thrd_t} +Unique object that identifies a thread unequivocally. +@end deftp + +@deftp {Data Type} {thrd_start_t} +It is a (@code{int (*)(void *)}) typedef that is passed to @code{thrd_create} +when creating a new thread. Should point to the first function that thread +will run. +@end deftp + +@deftypefun int thrd_create (thrd_t *@var{thr}, thrd_start_t @var{func}, void *@var{arg}) +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +Create a new thread executing the function @var{func}. The object pointed +by @var{arg} will be taken as @var{func} arguments. If successful, +@var{thr} is set to the new thread identifier. +@end deftypefun + +@deftypefun int thrd_equal (thrd_t @var{lhs}, thrd_t @var{rhs}) +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +Checks whether @var{lhs} and @var{rhs} refer to the same thread. +@end deftypefun + +@deftypefun thrd_t thrd_current (void) +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +Returns the identifier of the calling thread. +@end deftypefun + +@deftypefun int thrd_sleep (const struct timespec *@var{time_point}, struct timespec *@var{remaining}) +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +Blocks the execution of the current thread for at least until the wall-clock +time point pointed to by @var{time_point} has been reached. This function +does not take an absolute time, but a duration that the thread is required +to be blocked. + +The sleep may resume earlier if a signal that is not ignored is received. +In such case, if remaining is not NULL, the remaining time duration is stored +into the object pointed to by @var{remaining} +@end deftypefun + +@deftypefun void thrd_yield (void) +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +Provides a hint to the implementation to reschedule the execution of threads, +allowing other threads to run. +@end deftypefun + +@deftypefun _Noreturn void thrd_exit (int @var{res}) +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +Terminates execution of the calling thread and sets its result code to +@var{res}. +If this function is called from a single thread process, the call to this +function is equivalent to @code{exit(0)}. Returning from a thread-start +function is equivalent to calling @code{thrd_exit}. +@end deftypefun + +@deftypefun int thrd_detach (thrd_t @var{thr}) +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +Detaches the thread identified by @var{thr} from the current control thread. +The resources held by the thread will be freed automatically once the thread +exits. The parent thread will never be notified by any @var{thr} signal. +@end deftypefun + +@deftypefun int thrd_join (thrd_t @var{thr}, int *@var{res}) +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +Blocks the current thread until the thread identified by @var{thr} finishes +execution. If @var{res} is not a null pointer, the result code of the thread +is put to the location pointed to by @var{res}. The termination of the thread +synchronizes-with the completion of this function. +The behavior is undefined if the thread was previously detached or joined by +another thread. +@end deftypefun + +@node Call Once, Mutex, Thread Creation and Control, ISO Threads +@section Call Once + +In order to guarantee single access to a function, @theglibc implements a call +once function to allow unique access in case a function is required to be +called only once in presence of several threads. + +@deftp {Data Type} {once_flag} +Complete object type capable of holding a flag used by @code{call_once} +@end deftp + +@deftypevr Macro {} ONCE_FLAG_INIT +Value established to initialize an object of type @code{once_flag}. +@end deftypevr + +@deftypefun void call_once (once_flag *@var{flag}, void (*@var{func})(void)) +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +Calls function @var{func} exactly once, even if invoked from several threads. +The completion of the function @var{func} synchronizes with all previous or +subsequent calls to @code{call_once} with the same @var{flag} variable. +@end deftypefun + +@node Mutex, Condition variable, Call Once, ISO Threads +@section Mutex + +To have a better control of resources and how threads access them, @theglibc{} +also implements a mutex object, that allows to avoid race conditions and some +other concurrency issues. + +@deftp {Data Type} {mtx_t} +Mutex object identifier. +@end deftp + +@deftypefun int mtx_init (mtx_t *@var{mutex}, int @var{type}) +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +Creates a new mutex object with type @var{type}. The object pointed to by +@var{mutex} is set to an identifier of the newly created mutex. +@end deftypefun + +@deftypefun int mtx_lock (mtx_t *@var{mutex}) +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}} Blocks +the current thread until the mutex pointed to by @var{mutex} is locked. +The behavior is undefined if the current thread has already locked the mutex +and the mutex is not recursive. +Prior calls to @code{mtx_unlock} on the same mutex synchronize-with this +operation, and all lock/unlock operations on any given mutex form a single +total order (similar to the modification order of an atomic). +@end deftypefun + +@deftypefun int mtx_timedlock (mtx_t *restrict @var{mutex}, const struct timespec *restrict @var{time_point}) +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}} +Blocks the current thread until the mutex pointed to by @var{mutex} is locked +or until the wall-clock time pointed to by @var{time_point} has been reached. +This function takes an absolute time, so if a duration is required, must be +calculated manually and passed to this function. + +The behavior is undefined if the current thread has already locked the mutex +and the mutex is not recursive. The behavior is undefined if the mutex does +not support timeout. +Prior calls to @code{mtx_unlock} on the same mutex synchronize-with this +operation (if this operation succeeds), and all lock/unlock operations on any +given mutex form a single total order (similar to the modification order of +an atomic). +@end deftypefun + +@deftypefun int mtx_trylock (mtx_t *@var{mutex}) +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}} +Tries to lock the mutex pointed to by @var{mutex} without blocking. Returns +immediately if the mutex is already locked. +Prior calls to @code{mtx_unlock} on the same mutex synchronize-with this +operation (if this operation succeeds), and all lock/unlock operations on any +given mutex form a single total order (similar to the modification order of +an atomic). +@end deftypefun + +@deftypefun int mtx_unlock (mtx_t *@var{mutex}) +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +Unlocks the mutex pointed to by @var{mutex}. The behavior is undefined if the +mutex is not locked by the calling thread. This function synchronizes-with +subsequent @code{mtx_lock}, @code{mtx_trylock}, or @code{mtx_timedlock} on +the same mutex. All lock/unlock operations on any given mutex form a single +total order (similar to the modification order of an atomic). +@end deftypefun + +@deftypefun void mtx_destroy (mtx_t *@var{mutex}) +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +Destroys the mutex pointed to by @var{mutex}. If there are threads waiting +on mutex, the behavior is undefined. +@end deftypefun + +The ISO C11 standard also defines several types of mutex that are also +supported. They are represented with symbolic constants (enumeration type +values) and are the following: + +@vtable @code + +@item mtx_plain +Mutex type that does not support timeout or test and return. + +@item mtx_recursive +Mutex type that supports recursive locking, what means that owner thread can +lock it twice or more without causing deadlock. + +@item mtx_timed +Mutex type that supports timeout. + +@end vtable + +@node Condition variable, Thread-local storage, Mutex, ISO Threads +@section Condition Variable + +Mutexes are not the only synchronization mechanisms available. For some more +complex tasks, @theglibc{} also implements conditional variables, that allow +the user to think in a higher level to solve complex synchronization problems. +They are used to synchronize threads waiting on a certain condition to happen. + +@deftp {Data Type} {cnd_t} +Condition variable object identifier. +@end deftp + +@deftypefun int cnd_init (cnd_t *@var{cond}) +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +Initializes new conditional variable. The object pointed to by @var{cond} +will be set to value that identifies the conditional variable. +@end deftypefun + +@deftypefun int cnd_signal (cnd_t *@var{cond}) +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +Unblocks one thread that currently waits on conditional variable pointed to +by @var{cond}. If no threads are blocked, does nothing and returns +@code{thrd_success}. +@end deftypefun + +@deftypefun int cnd_broadcast (cnd_t *@var{cond}) +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +Unblocks all threads that currently wait on conditional variable pointed to +by @var{cond}. If no threads are blocked, does nothing and returns +@code{thrd_success}. +@end deftypefun + +@deftypefun int cnd_wait (cnd_t *@var{cond}, mtx_t *@var{mutex}) +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}} +Atomically unlocks the mutex pointed to by @var{mutex} and blocks on the +conditional variable pointed to by @var{cond} until the thread is signalled +by @code{cnd_signal} or @code{cnd_broadcast}. The mutex is locked again +before the function returns. +@end deftypefun + +@deftypefun int cnd_timedwait (cnd_t *restrict @var{cond}, mtx_t *restrict @var{mutex}, const struct timespec *restrict @var{time_point}) +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}} +Atomically unlocks the mutex pointed to by @var{mutex} and blocks on the +conditional variable pointed to by @var{cond} until the thread is signalled +by @code{cnd_signal} or @code{cnd_broadcast}, or until the wall-clock time +pointed to by @var{time_point} has been reached. The mutex is locked again +before the function returns. +As for @code{mtx_timedlock}, this function also takes an absolute time +rather than a duration. +@end deftypefun + +@deftypefun void cnd_destroy (cnd_t *@var{cond}) +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +Destroys the conditional variable pointed to by @var{cond}. If there are +threads waiting on @var{cond}, the behavior is undefined. +@end deftypefun + +@node Thread-local storage, C11 error types, Condition variable, ISO Threads +@section Thread-local Storage + +@Theglibc{} also implements different functions that adds funtionality for +thread-local storage. That means that each thread can have their own +variables and are not visible by other threads. The functions and types +provided are: + +@deftp {Data Type} {tss_t} +Thread-specific storage object. Even if shared, every thread will have +its own instance of that variable with different values. +@end deftp + +@deftp {Data Type} {tss_dtor_t} +Function pointer of type @code{void(*)(void*)}, used for TSS destructor. +This function will be called when the current thread calls @code{thrd_exit}, +but never when calling @code{tss_delete} or @code{exit} +@end deftp + +@deftypevr Macro {} thread_local +Used to mark a variable with thread storage duration, that means created +when the thread starts and cleaned up when the thread ends. +@end deftypevr + +@deftypevr Macro {} TSS_DTOR_ITERATIONS +Integer constant expression representing the maximum number of times that +destructors will be called when a thread terminates. +@end deftypevr + +@deftypefun int tss_create (tss_t *@var{tss_key}, tss_dtor_t @var{destructor}) +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +Creates new thread-specific storage key and stores it in the object pointed +to by @var{tss_key}. Although the same key value may be used by different +threads, the values bound to the key by @code{tss_set} are maintained on a +per-thread basis and persist for the life of the calling thread. + +If @var{destructor} is different to NULL, a destructor function will be set, +and called when the thread finishes its execution by calling @code{thrd_exit}. +@end deftypefun + +@deftypefun void *tss_get (tss_t @var{tss_key}) +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +Returns the value held in thread-specific storage for the current thread +identified by @var{tss_key}. Different threads may get different values +identified by the same key. +@end deftypefun + +@deftypefun int tss_set (tss_t @var{tss_id}, void *@var{val}) +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +Sets the value of the thread-specific storage identified by @var{tss_id} for +the current thread to @var{val}. Different threads may set different values +to the same key. The destructor, if available, is not invoked. +@end deftypefun + +@deftypefun void tss_delete (tss_t @var{tss_id}) +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +Destroys the thread-specific storage identified by @var{tss_id}. The +destructor, if one was registered by @code{tss_create}, is not called. +@end deftypefun + +@node C11 error types, , Thread-local storage, ISO Threads +@section Error Types + +The ISO C11 specification also provides new error types that belong +specifically to @code{threads.h}. @Theglibc{} has also implemented this +feature and every function in this API always returns one of the following +error codes: + +@vtable @code + +@item thrd_timedout +Value returned by a function to indicate that a specified time was reached +without acquiring the requested resource, usually a mutex or conditional +variable. + +@item thrd_sucess +Value returned by a function to indicate that the requested operation +succeded. + +@item thrd_busy +Value returned by a function to indicate that the requested operation +failed because a resource requested is already in use. + +@item thrd_error +Value returned by a function to indicate that the requested operation +failed. + +@item thrd_nomem +Value returned by a function to indicate that the requested operation +failed because it was unable to allocate enough memory. + +@end vtable