{"id":817688,"url":"http://patchwork.ozlabs.org/api/patches/817688/?format=json","web_url":"http://patchwork.ozlabs.org/project/glibc/patch/1506112024-22601-4-git-send-email-adhemerval.zanella@linaro.org/","project":{"id":41,"url":"http://patchwork.ozlabs.org/api/projects/41/?format=json","name":"GNU C Library","link_name":"glibc","list_id":"libc-alpha.sourceware.org","list_email":"libc-alpha@sourceware.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1506112024-22601-4-git-send-email-adhemerval.zanella@linaro.org>","list_archive_url":null,"date":"2017-09-22T20:26:59","name":"[3/8] nptl: Add C11 threads call_once functions","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"f55eb6bea4957f7d00dde607e559c3adebc1a6fa","submitter":{"id":66065,"url":"http://patchwork.ozlabs.org/api/people/66065/?format=json","name":"Adhemerval Zanella Netto","email":"adhemerval.zanella@linaro.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/glibc/patch/1506112024-22601-4-git-send-email-adhemerval.zanella@linaro.org/mbox/","series":[{"id":4704,"url":"http://patchwork.ozlabs.org/api/series/4704/?format=json","web_url":"http://patchwork.ozlabs.org/project/glibc/list/?series=4704","date":"2017-09-22T20:26:56","name":"Add support for ISO C threads.h","version":7,"mbox":"http://patchwork.ozlabs.org/series/4704/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/817688/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/817688/checks/","tags":{},"related":[],"headers":{"Return-Path":"<libc-alpha-return-84876-incoming=patchwork.ozlabs.org@sourceware.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list libc-alpha@sourceware.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=sourceware.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=libc-alpha-return-84876-incoming=patchwork.ozlabs.org@sourceware.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tsecure) header.d=sourceware.org header.i=@sourceware.org\n\theader.b=\"TgN8K7b9\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xzQ5h73Jdz9t32\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat, 23 Sep 2017 06:27:52 +1000 (AEST)","(qmail 65980 invoked by alias); 22 Sep 2017 20:27:20 -0000","(qmail 65866 invoked by uid 89); 22 Sep 2017 20:27:20 -0000"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:from:to:subject:date:message-id:in-reply-to\n\t:references; q=dns; s=default; b=uO6K+iw7xbfVYfgarl43UQgpYIdYpN/\n\te51AJK2wu+RN/78JQj9bWQlLqfau3+YCwL+wut+S0zdx5UTFsH3gzE17zK9Yj1cC\n\t22t6xFX73kaO9EIA3VsJayyNYu6ZixwgLVNvBfCtEEIqg9w5l3B0cshHi0qNM0BI\n\tmx/DkgB5G0/g=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:from:to:subject:date:message-id:in-reply-to\n\t:references; s=default; bh=ALPqL8WAYq5559kj//tddRrx2CU=; b=TgN8K\n\t7b9Xb5iZWOMRXUHJPsXv7K6qnZgoIHXGAc7tDkKaViSYoxQXFmhd/KmI3b8RvS1f\n\tmIqkRWqSYN14Vj/7ii+Si5mv4Zad2CEl2Ej8BVXFgqXLPI23qUF2Hb4uNw9PpdSp\n\tAg+u2TrYuSAhohnUbIegAktYtNk3W0uaJbCwU0=","Mailing-List":"contact libc-alpha-help@sourceware.org; run by ezmlm","Precedence":"bulk","List-Id":"<libc-alpha.sourceware.org>","List-Unsubscribe":"<mailto:libc-alpha-unsubscribe-incoming=patchwork.ozlabs.org@sourceware.org>","List-Subscribe":"<mailto:libc-alpha-subscribe@sourceware.org>","List-Archive":"<http://sourceware.org/ml/libc-alpha/>","List-Post":"<mailto:libc-alpha@sourceware.org>","List-Help":"<mailto:libc-alpha-help@sourceware.org>,\n\t<http://sourceware.org/ml/#faqs>","Sender":"libc-alpha-owner@sourceware.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-27.1 required=5.0 tests=BAYES_00, GIT_PATCH_0,\n\tGIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW,\n\tRCVD_IN_SORBS_SPAM,\n\tSPF_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;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=QCaWO0honUX9NScP+KHvFjEQV1QqP75FVi7alj8pEww=;\n\tb=A1rHfkGWZq5lEtnQEzVQt8qR3XJYGVZdHean+V7sDIEgiR/p9rCyIlk6oGYQd3YFd9\n\t8k2oYXxBcQsXBlO7YC8s1d8WETlSIutlyKeKPKiHjEuCbmJibzF6ZIdU8dFIREvnNZRB\n\trsiV7Kix3y8X8MMkeMbLq2ULkhWxwwthU2COXcwBkw8kuna61lyD+9Eq5fPAclvJmsNu\n\tPRVX14uH9HULrYuNFqmPq+4C/fJKLynUyWjipyHHk08oIWQE2cy8uEZFOXacMIMTAvtV\n\tIgQ6/lwvxrPHgODhKzPPVI/kHsoREammW08sknYLRZzF2ha5JGMPIG/eFPr7ZusdEnTY\n\t1K2g==","X-Gm-Message-State":"AHPjjUiGDRBKvkRwjdEvrK73orYd13Xi6yzdcS/Y2jbaCsKQrIpFvm6k\n\tDGTIy2vAPOxgveE9Fa/Ef7YUV7G9tJU=","X-Google-Smtp-Source":"AOwi7QCrycT3gb79Gdf6VumtMcx93ek8sMZCHt5gxVHKcs/XhnjfLiQiX5WY2Z4myf4mwYxiyrBnWg==","X-Received":"by 10.237.37.14 with SMTP id v14mr605328qtc.116.1506112036460;\n\tFri, 22 Sep 2017 13:27:16 -0700 (PDT)","From":"Adhemerval Zanella <adhemerval.zanella@linaro.org>","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>"},"content":"This patch adds the call_* definitions from C11 threads (ISO/IEC 9899:2011),\nmore specifically call_once and required types.\n\nMostly of the definitions are composed based on POSIX conterparts,including\nonce_flag (pthread_once_t).  The idea is to make possible to share POSIX\ninternal implementations for mostly of the code (and making adjustment only\nwhen required).\n\nChecked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,\narm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,\nmicroblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,\npowerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,\ntile{pro,gx}-linux-gnu, and x86_64-linux-gnu).\n\nAlso ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,\narm-linux-gnueabhf, and powerpc64le-linux-gnu.\n\n\t* conform/data/threads.h-data (ONCE_FLAG_INIT): New macro.\n\t(once_flag): New type.\n\t(call_once): New function.\n\t* nptl/Makefile (libpthread-routines): Add call_once object.\n\t* nptl/Versions (libphread) [GLIBC_2.27]: Add call_once symbol.\n\t* nptl/call_once.c: New file.\n\t* sysdeps/nptl/threads.h (ONCE_FLAG_INIT): New define.\n\t(once_flag): New type.\n\t(call_once): New prototype.\n---\n ChangeLog                   | 10 ++++++++++\n conform/data/threads.h-data |  5 +++++\n nptl/Makefile               |  2 +-\n nptl/Versions               |  2 +-\n nptl/call_once.c            | 33 +++++++++++++++++++++++++++++++++\n sysdeps/nptl/threads.h      |  7 +++++++\n 6 files changed, 57 insertions(+), 2 deletions(-)\n create mode 100644 nptl/call_once.c","diff":"diff --git a/conform/data/threads.h-data b/conform/data/threads.h-data\nindex bb5ca75..70b2fe0 100644\n--- a/conform/data/threads.h-data\n+++ b/conform/data/threads.h-data\n@@ -1,5 +1,7 @@\n #if defined ISO11\n \n+macro ONCE_FLAG_INIT\n+\n constant thrd_success\n constant thrd_busy\n constant thrd_error\n@@ -13,6 +15,7 @@ constant mtx_timed\n type thrd_t\n type thrd_start_t\n type mtx_t\n+type once_flag\n \n function int thrd_create (thrd_t*, thrd_start_t, void*)\n function int thrd_equal (thrd_t, thrd_t)\n@@ -30,6 +33,8 @@ function int mtx_trylock (mtx_t*)\n function int mtx_unlock (mtx_t*)\n function void mtx_destroy (mtx_t*)\n \n+function void call_once (once_flag*, void (*)(void))\n+\n #include \"time.h-data\"\n \n #endif\ndiff --git a/nptl/Makefile b/nptl/Makefile\nindex c4f6970..7d2b83f 100644\n--- a/nptl/Makefile\n+++ b/nptl/Makefile\n@@ -142,7 +142,7 @@ libpthread-routines = nptl-init vars events version pt-interp \\\n \t\t      thrd_create thrd_current thrd_detach thrd_equal \\\n \t\t      thrd_exit thrd_join thrd_sleep thrd_yield \\\n \t\t      mtx_destroy mtx_init mtx_lock mtx_timedlock \\\n-\t\t      mtx_trylock mtx_unlock\n+\t\t      mtx_trylock mtx_unlock call_once\n #\t\t      pthread_setuid pthread_seteuid pthread_setreuid \\\n #\t\t      pthread_setresuid \\\n #\t\t      pthread_setgid pthread_setegid pthread_setregid \\\ndiff --git a/nptl/Versions b/nptl/Versions\nindex 5cf581a..b055860 100644\n--- a/nptl/Versions\n+++ b/nptl/Versions\n@@ -269,7 +269,7 @@ libpthread {\n   GLIBC_2.27 {\n     thrd_create; thrd_current; thrd_detach; thrd_equal; thrd_exit; thrd_join;\n     thrd_sleep; thrd_yield; mtx_init; mtx_lock; mtx_timedlock; mtx_trylock;\n-    mtx_unlock; mtx_destroy;\n+    mtx_unlock; mtx_destroy; call_once;\n   }\n \n   GLIBC_PRIVATE {\ndiff --git a/nptl/call_once.c b/nptl/call_once.c\nnew file mode 100644\nindex 0000000..8a15f1f\n--- /dev/null\n+++ b/nptl/call_once.c\n@@ -0,0 +1,33 @@\n+/* C11 threads call once implementation.\n+   Copyright (C) 2017 Free Software Foundation, Inc.\n+   This file is part of the GNU C Library.\n+\n+   The GNU C Library is free software; you can redistribute it and/or\n+   modify it under the terms of the GNU Lesser General Public\n+   License as published by the Free Software Foundation; either\n+   version 2.1 of the License, or (at your option) any later version.\n+\n+   The GNU C Library is distributed in the hope that it will be useful,\n+   but WITHOUT ANY WARRANTY; without even the implied warranty of\n+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+   Lesser General Public License for more details.\n+\n+   You should have received a copy of the GNU Lesser General Public\n+   License along with the GNU C Library; if not, see\n+   <http://www.gnu.org/licenses/>.  */\n+\n+#include <stdalign.h>\n+\n+#include \"thrd_priv.h\"\n+\n+/* Call function func exactly once, even if invoked from several threads.\n+   All calls must be made with the same flag object.  */\n+void\n+call_once (once_flag *flag, void (*func)(void))\n+{\n+  _Static_assert (sizeof (once_flag) == sizeof (pthread_once_t),\n+\t\t  \"once_flag size\");\n+  _Static_assert (alignof (once_flag) == alignof (pthread_once_t),\n+\t\t  \"once_flag alignment\");\n+  __pthread_once (flag, func);\n+}\ndiff --git a/sysdeps/nptl/threads.h b/sysdeps/nptl/threads.h\nindex cd811f4..53fe731 100644\n--- a/sysdeps/nptl/threads.h\n+++ b/sysdeps/nptl/threads.h\n@@ -27,8 +27,11 @@ __BEGIN_DECLS\n #include <bits/pthreadtypes-arch.h>\n #include <bits/types/struct_timespec.h>\n \n+#define ONCE_FLAG_INIT 0\n+\n typedef unsigned long int thrd_t;\n typedef int (*thrd_start_t) (void*);\n+typedef int __ONCE_ALIGNMENT once_flag;\n \n /* Exit and error codes.  */\n enum\n@@ -129,6 +132,10 @@ extern int mtx_unlock (mtx_t *__mutex);\n /* Destroy the mutex object pointed by __mutex.  */\n extern void mtx_destroy (mtx_t *__mutex);\n \n+/* Call function func exactly once, even if invoked from several threads.\n+   All calls must be made with the same __flag object.  */\n+extern void call_once (once_flag *__flag, void (*__func)(void));\n+\n __END_DECLS\n \n #endif /* _THREADS_H */\n","prefixes":["3/8"]}