Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/817692/?format=api
{ "id": 817692, "url": "http://patchwork.ozlabs.org/api/patches/817692/?format=api", "web_url": "http://patchwork.ozlabs.org/project/glibc/patch/1506112024-22601-8-git-send-email-adhemerval.zanella@linaro.org/", "project": { "id": 41, "url": "http://patchwork.ozlabs.org/api/projects/41/?format=api", "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-8-git-send-email-adhemerval.zanella@linaro.org>", "list_archive_url": null, "date": "2017-09-22T20:27:03", "name": "[7/8] nptl: Add test cases for ISO C11 threads", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "bc5d8513a5d5413e68cba4fd89ce1893196c5ee7", "submitter": { "id": 66065, "url": "http://patchwork.ozlabs.org/api/people/66065/?format=api", "name": "Adhemerval Zanella Netto", "email": "adhemerval.zanella@linaro.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/glibc/patch/1506112024-22601-8-git-send-email-adhemerval.zanella@linaro.org/mbox/", "series": [ { "id": 4704, "url": "http://patchwork.ozlabs.org/api/series/4704/?format=api", "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/817692/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/817692/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<libc-alpha-return-84880-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-84880-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=\"Kvm3pr1G\"; 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 3xzQ6Z5hlZz9t32\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat, 23 Sep 2017 06:28:38 +1000 (AEST)", "(qmail 67151 invoked by alias); 22 Sep 2017 20:27:30 -0000", "(qmail 67070 invoked by uid 89); 22 Sep 2017 20:27:30 -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=IYlx9ozb+AVATcrVr7YTQIJ37yNnd30\n\tezDZJ7vIhQOt+4aLtiLSk/BCkc9KHWsXIyIQAFmX/sf7QWptXeVJko0t0Pk6hmxp\n\tdGuo1Bj5rPWnBwH3j6lDspssqTaHNyhOud52YCvMeJHGKSXCNA3d62eXL6FD1Goj\n\tsuamScyO8e3o=", "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=ljeGqeAnN0qLgPDUJNq0QwSpzK4=; b=Kvm3p\n\tr1GRy6uer77uRNx25P5VtVKdudmedOtgv2b8xJ5c8YqImLaw8L7Xr7io2z3CmS79\n\tbIzR3wYHdfrfC5+CVDope5ZC3qzwbaIUFXNBdeCwIvIzg7qs+jruLhnXAgPi0lMn\n\tv+11y40nIbVlsG3lS1UznkapS3yDPctL9EwbhY=", "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=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0,\n\tGIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_SORBS_SPAM,\n\tSPF_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;\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=v3z/WsAVi7JQZfrPQ8f22lxXuO1nfrSXDuGe3789BGQ=;\n\tb=adAP4xo7ARODHd2pLVXHApJhrArvYkx/euP8sRLXzovBRAIc5adnUSRv1wCIfmZjE5\n\tPc6ufneGMPFxCyJySFx0Sww6I7TpdIxx+bO2TiRXteSoPQRrBLTT8dkOW6mzo89pgmI7\n\tPl40bceTdn1MvZsl9FDDZJjA3vRLOXNeYu4m3+fwNcWhA6KgkfWPkS3LNUJk6Fgwqk+z\n\tBmCfksQCfNvNDOBoV9bhDhRiD8edyMm/7tdeoP7VC7nWVzQtaNJNz1MpUDtzCMeVr1eZ\n\twBxTGoFieBiiDg8aKxGDw2JmiSwYgdxjg1CKEBQV5ETcIEsEgd5WdBhhU79gJLaDgOuo\n\tmXGQ==", "X-Gm-Message-State": "AHPjjUhbVJ/1DTAUktZ1Wa63U38dLuuvPigZ8B+sZjyxIkdd97x4QZUh\n\tGuKZXvHTlIrnhzQOCwyTCDq5psg4Tts=", "X-Google-Smtp-Source": "AOwi7QAcpvydIkZPyKJYj7jhf4FLcnIdFaeHTW6VPIRcukWEQNIk453IuDj4pullw8AbTKVQhFVaOQ==", "X-Received": "by 10.200.49.202 with SMTP id i10mr583420qte.63.1506112043030;\n\tFri, 22 Sep 2017 13:27:23 -0700 (PDT)", "From": "Adhemerval Zanella <adhemerval.zanella@linaro.org>", "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>" }, "content": "This patch adds to testsuite new test cases to test all new introduced\nC11 threads functions, types and macros are tested.\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\tAdhemerval Zanella <adhemerval.zanella@linaro.org>\n\tJuan Manuel Torres Palma <jmtorrespalma@gmail.com>\n\n\t* nptl/Makefile (tests): Add new test files.\n\t* nptl/tst-call-once.c : New file. Tests C11 functions and types.\n\t* nptl/tst-cnd-basic.c: Likewise.\n\t* nptl/tst-cnd-broadcast.c: Likewise.\n\t* nptl/tst-cnd-timedwait.c: Likewise.\n\t* nptl/tst-mtx-basic.c: Likewise.\n\t* nptl/tst-mtx-recursive.c: Likewise.\n\t* nptl/tst-mtx-timedlock.c: Likewise.\n\t* nptl/tst-mtx-trylock.c: Likewise.\n\t* nptl/tst-thrd-basic.c: Likewise.\n\t* nptl/tst-thrd-detach.c: Likewise.\n\t* nptl/tst-thrd-sleep.c: Likewise.\n\t* nptl/tst-tss-basic.c: Likewise.\n---\n ChangeLog | 17 +++++++++\n nptl/Makefile | 5 ++-\n nptl/tst-call-once.c | 66 ++++++++++++++++++++++++++++++++\n nptl/tst-cnd-basic.c | 68 +++++++++++++++++++++++++++++++++\n nptl/tst-cnd-broadcast.c | 83 ++++++++++++++++++++++++++++++++++++++++\n nptl/tst-cnd-timedwait.c | 70 ++++++++++++++++++++++++++++++++++\n nptl/tst-mtx-basic.c | 73 ++++++++++++++++++++++++++++++++++++\n nptl/tst-mtx-recursive.c | 45 ++++++++++++++++++++++\n nptl/tst-mtx-timedlock.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++\n nptl/tst-mtx-trylock.c | 90 ++++++++++++++++++++++++++++++++++++++++++++\n nptl/tst-thrd-detach.c | 52 +++++++++++++++++++++++++\n nptl/tst-thrd-sleep.c | 51 +++++++++++++++++++++++++\n nptl/tst-tss-basic.c | 75 ++++++++++++++++++++++++++++++++++++\n 13 files changed, 792 insertions(+), 1 deletion(-)\n create mode 100644 nptl/tst-call-once.c\n create mode 100644 nptl/tst-cnd-basic.c\n create mode 100644 nptl/tst-cnd-broadcast.c\n create mode 100644 nptl/tst-cnd-timedwait.c\n create mode 100644 nptl/tst-mtx-basic.c\n create mode 100644 nptl/tst-mtx-recursive.c\n create mode 100644 nptl/tst-mtx-timedlock.c\n create mode 100644 nptl/tst-mtx-trylock.c\n create mode 100644 nptl/tst-thrd-detach.c\n create mode 100644 nptl/tst-thrd-sleep.c\n create mode 100644 nptl/tst-tss-basic.c", "diff": "diff --git a/nptl/Makefile b/nptl/Makefile\nindex 0bf46ce..6e179b0 100644\n--- a/nptl/Makefile\n+++ b/nptl/Makefile\n@@ -308,7 +308,10 @@ tests = tst-attr1 tst-attr2 tst-attr3 tst-default-attr \\\n \t\t\t c89 gnu89 c99 gnu99 c11 gnu11) \\\n \ttst-bad-schedattr \\\n \ttst-thread_local1 tst-mutex-errorcheck tst-robust10 \\\n-\ttst-robust-fork tst-create-detached tst-memstream\n+\ttst-robust-fork tst-create-detached tst-memstream \\\n+\ttst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \\\n+\ttst-cnd-timedwait tst-thrd-detach tst-mtx-basic tst-thrd-sleep \\\n+\ttst-mtx-recursive tst-tss-basic tst-call-once tst-mtx-timedlock\n \n tests-internal := tst-typesizes \\\n \t\t tst-rwlock19 tst-rwlock20 \\\ndiff --git a/nptl/tst-call-once.c b/nptl/tst-call-once.c\nnew file mode 100644\nindex 0000000..331174e\n--- /dev/null\n+++ b/nptl/tst-call-once.c\n@@ -0,0 +1,66 @@\n+/* C11 threads call_once test.\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 <threads.h>\n+#include <stdio.h>\n+#include <unistd.h>\n+\n+#include <support/check.h>\n+\n+/* Flag that controls the first thread access. */\n+static once_flag flag = ONCE_FLAG_INIT;\n+\n+static int value = 0;\n+\n+static void\n+do_once (void)\n+{\n+ value++;\n+}\n+\n+static int\n+func (void* data)\n+{\n+ call_once (&flag, do_once);\n+ thrd_exit (thrd_success);\n+}\n+\n+#define N 20\n+\n+int\n+do_test (void)\n+{\n+ thrd_t ids[N];\n+\n+ for (int i = 0; i < N; ++i)\n+ {\n+ if (thrd_create (&ids[i], func, NULL) != thrd_success)\n+\tFAIL_EXIT1 (\"thrd_create failed\");\n+ }\n+\n+ /* Join threads. */\n+ for (int i = 0; i < N; ++i)\n+ {\n+ if (thrd_join (ids[i], NULL) != thrd_success)\n+\tFAIL_EXIT1 (\"thrd_join failed\");\n+ }\n+\n+ return (value != 1);\n+}\n+\n+#include <support/test-driver.c>\ndiff --git a/nptl/tst-cnd-basic.c b/nptl/tst-cnd-basic.c\nnew file mode 100644\nindex 0000000..56de4d7\n--- /dev/null\n+++ b/nptl/tst-cnd-basic.c\n@@ -0,0 +1,68 @@\n+/* C11 threads condition variable tests.\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 <threads.h>\n+#include <stdio.h>\n+#include <unistd.h>\n+\n+#include <support/check.h>\n+\n+/* Shared condition variable between child and parent. */\n+static cnd_t cond;\n+\n+/* Mutex needed to signal and wait threads. */\n+static mtx_t mutex;\n+\n+static int\n+signal_parent (void)\n+{\n+ if (cnd_signal (&cond) != thrd_success)\n+ FAIL_EXIT1 (\"cnd_signal\");\n+\n+ thrd_exit (thrd_success);\n+}\n+\n+static int\n+do_test (void)\n+{\n+ thrd_t id;\n+\n+ if (cnd_init (&cond) != thrd_success)\n+ FAIL_EXIT1 (\"cnd_init failed\");\n+ if (mtx_init (&mutex, mtx_plain) != thrd_success)\n+ FAIL_EXIT1 (\"mtx_init failed\");\n+\n+ if (thrd_create (&id, (thrd_start_t) signal_parent, NULL)\n+ != thrd_success)\n+ FAIL_EXIT1 (\"thrd_create failed\");\n+\n+ if (cnd_wait (&cond, &mutex) != thrd_success)\n+ FAIL_EXIT1 (\"cnd_wait failed\");\n+\n+ /* Joining is not mandatory here, but still done to assure child thread\n+ ends correctly. */\n+ if (thrd_join (id, NULL) != thrd_success)\n+ FAIL_EXIT1 (\"thrd_join failed\");\n+\n+ mtx_destroy (&mutex);\n+ cnd_destroy (&cond);\n+\n+ return 0;\n+}\n+\n+#include <support/test-driver.c>\ndiff --git a/nptl/tst-cnd-broadcast.c b/nptl/tst-cnd-broadcast.c\nnew file mode 100644\nindex 0000000..1ca87a3\n--- /dev/null\n+++ b/nptl/tst-cnd-broadcast.c\n@@ -0,0 +1,83 @@\n+/* C11 threads condition broadcast variable tests.\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 <threads.h>\n+#include <stdio.h>\n+#include <unistd.h>\n+\n+#include <support/check.h>\n+\n+/* Condition variable where child threads will wait. */\n+static cnd_t cond;\n+\n+/* Mutex to control wait on cond. */\n+static mtx_t mutex;\n+\n+/* Code executed by each thread. */\n+static int\n+child_wait (void* data)\n+{\n+ /* Wait until parent thread sends broadcast here. */\n+ mtx_lock (&mutex);\n+ cnd_wait (&cond, &mutex);\n+ mtx_unlock (&mutex);\n+\n+ thrd_exit (thrd_success);\n+}\n+\n+#define N 5\n+\n+static int\n+do_test (void)\n+{\n+ thrd_t ids[N];\n+ unsigned char i;\n+\n+ if (cnd_init (&cond) != thrd_success)\n+ FAIL_EXIT1 (\"cnd_init failed\");\n+ if (mtx_init (&mutex, mtx_plain) != thrd_success)\n+ FAIL_EXIT1 (\"mtx_init failed\");\n+\n+ /* Create N new threads. */\n+ for (i = 0; i < N; ++i)\n+ {\n+ if (thrd_create (&ids[i], child_wait, NULL) != thrd_success)\n+\tFAIL_EXIT1 (\"thrd_create failed\");\n+ }\n+\n+ /* Wait for other threads to reach their wait func. */\n+ thrd_sleep (&((struct timespec){.tv_sec = 2}), NULL);\n+\n+ mtx_lock (&mutex);\n+ if (cnd_broadcast (&cond) != thrd_success)\n+ FAIL_EXIT1 (\"cnd_broadcast failed\");\n+ mtx_unlock (&mutex);\n+\n+ for (i = 0; i < N; ++i)\n+ {\n+ if (thrd_join (ids[i], NULL) != thrd_success)\n+\tFAIL_EXIT1 (\"thrd_join failed\");\n+ }\n+\n+ mtx_destroy (&mutex);\n+ cnd_destroy (&cond);\n+\n+ return 0;\n+}\n+\n+#include <support/test-driver.c>\ndiff --git a/nptl/tst-cnd-timedwait.c b/nptl/tst-cnd-timedwait.c\nnew file mode 100644\nindex 0000000..64a9546\n--- /dev/null\n+++ b/nptl/tst-cnd-timedwait.c\n@@ -0,0 +1,70 @@\n+/* C11 threads condition timed wait variable tests.\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 <threads.h>\n+#include <stdio.h>\n+#include <unistd.h>\n+\n+#include <support/check.h>\n+\n+/* Shared condition variable between child and parent. */\n+static cnd_t cond;\n+\n+/* Mutex needed to signal and wait threads. */\n+static mtx_t mutex;\n+\n+static int\n+signal_parent (void *arg)\n+{\n+ if (cnd_signal (&cond) != thrd_success)\n+ FAIL_EXIT1 (\"cnd_signal failed\");\n+\n+ thrd_exit (thrd_success);\n+}\n+\n+static int\n+do_test (void)\n+{\n+ thrd_t id;\n+ struct timespec w_time;\n+\n+ if (cnd_init (&cond) != thrd_success)\n+ FAIL_EXIT1 (\"cnd_init failed\");\n+ if (mtx_init (&mutex, mtx_plain) != thrd_success)\n+ FAIL_EXIT1 (\"mtx_init failed\");\n+\n+ if (clock_gettime (CLOCK_REALTIME, &w_time) != 0)\n+ FAIL_EXIT1 (\"clock_gettime failed\");\n+ w_time.tv_nsec += 150000;\n+\n+ if (thrd_create (&id, signal_parent, NULL) != thrd_success)\n+ FAIL_EXIT1 (\"thrd_create failed\");\n+\n+ if (cnd_timedwait (&cond, &mutex, &w_time) != thrd_success)\n+ FAIL_EXIT1 (\"cnd_timedwait failed\");\n+\n+ if (thrd_join (id, NULL) != thrd_success)\n+ FAIL_EXIT1 (\"thrd_join failed\");\n+\n+ mtx_destroy (&mutex);\n+ cnd_destroy (&cond);\n+\n+ return 0;\n+}\n+\n+#include <support/test-driver.c>\ndiff --git a/nptl/tst-mtx-basic.c b/nptl/tst-mtx-basic.c\nnew file mode 100644\nindex 0000000..c064405\n--- /dev/null\n+++ b/nptl/tst-mtx-basic.c\n@@ -0,0 +1,73 @@\n+/* C11 threads basic mutex tests.\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 <threads.h>\n+#include <stdio.h>\n+#include <unistd.h>\n+\n+#include <support/check.h>\n+\n+/* Shared mutex between child and parent. */\n+static mtx_t mutex;\n+\n+/* Shared counter to check possible race conditions. */\n+static int counter;\n+\n+static int\n+child_add (void *arg)\n+{\n+ if (mtx_lock (&mutex) != thrd_success)\n+ FAIL_EXIT1 (\"mtx_lock failed\");\n+\n+ counter++;\n+\n+ if (mtx_unlock (&mutex) != thrd_success)\n+ FAIL_EXIT1 (\"mtx_unlock failed\");\n+\n+ thrd_exit (thrd_success);\n+}\n+\n+static int\n+do_test (void)\n+{\n+ mtx_init (&mutex, mtx_plain);\n+\n+ thrd_t id;\n+ if (thrd_create (&id, child_add, NULL) != thrd_success)\n+ FAIL_EXIT1 (\"thrd_create failed\");\n+\n+ if (mtx_lock (&mutex) != thrd_success)\n+ FAIL_EXIT1 (\"mtx_lock failed\");\n+\n+ counter++;\n+\n+ if (mtx_unlock (&mutex) != thrd_success)\n+ FAIL_EXIT1 (\"mtx_unlock failed\");\n+\n+ if (thrd_join (id, NULL) != thrd_success)\n+ FAIL_EXIT1 (\"thrd_join failed\");\n+\n+ if (counter != 2)\n+ FAIL_EXIT1 (\"counter (%d) != 2\", counter);\n+\n+ mtx_destroy (&mutex);\n+\n+ return 0;\n+}\n+\n+#include <support/test-driver.c>\ndiff --git a/nptl/tst-mtx-recursive.c b/nptl/tst-mtx-recursive.c\nnew file mode 100644\nindex 0000000..df959c7\n--- /dev/null\n+++ b/nptl/tst-mtx-recursive.c\n@@ -0,0 +1,45 @@\n+/* C11 threads recursive mutex tests.\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 <threads.h>\n+#include <stdio.h>\n+#include <unistd.h>\n+\n+#include <support/check.h>\n+\n+static int\n+do_test (void)\n+{\n+ static mtx_t mutex;\n+\n+ if (mtx_init (&mutex, mtx_recursive) != thrd_success)\n+ FAIL_EXIT1 (\"mtx_init failed\");\n+\n+ if (mtx_lock (&mutex) != thrd_success)\n+ FAIL_EXIT1 (\"mtx_lock failed\");\n+\n+ /* Lock mutex second time, if not recursive should deadlock. */\n+ if (mtx_lock (&mutex) != thrd_success)\n+ FAIL_EXIT1 (\"mtx_lock failed\");\n+\n+ mtx_destroy (&mutex);\n+\n+ return 0;\n+}\n+\n+#include <support/test-driver.c>\ndiff --git a/nptl/tst-mtx-timedlock.c b/nptl/tst-mtx-timedlock.c\nnew file mode 100644\nindex 0000000..1f02bd4\n--- /dev/null\n+++ b/nptl/tst-mtx-timedlock.c\n@@ -0,0 +1,98 @@\n+/* C11 threads timed mutex tests.\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 <threads.h>\n+#include <stdio.h>\n+#include <unistd.h>\n+\n+#include <support/check.h>\n+\n+/* Shared mutex between child and parent. */\n+static mtx_t mutex;\n+\n+/* Shared counter to check possible race conditions. */\n+static char shrd_counter;\n+\n+/* Maximum amount of time waiting for mutex. */\n+static struct timespec wait_time;\n+\n+/* Function to choose an action to do, depending on mtx_timedlock\n+ return value. */\n+static inline void\n+choose_action (int action, char* thread_name)\n+{\n+ switch (action)\n+ {\n+ case thrd_success:\n+ ++shrd_counter;\n+\n+\tif (mtx_unlock (&mutex) != thrd_success)\n+\t FAIL_EXIT1 (\"mtx_unlock failed\");\n+ break;\n+\n+ case thrd_timedout:\n+ break;\n+\n+ case thrd_error:\n+\tFAIL_EXIT1 (\"%s lock error\", thread_name);\n+ break;\n+ }\n+}\n+\n+static int\n+child_add (void *arg)\n+{\n+ char child_name[] = \"child\";\n+\n+ /* Try to lock mutex. */\n+ choose_action (mtx_timedlock (&mutex, &wait_time), child_name);\n+ thrd_exit (thrd_success);\n+}\n+\n+static int\n+do_test (void)\n+{\n+ thrd_t id;\n+ char parent_name[] = \"parent\";\n+\n+ if (mtx_init (&mutex, mtx_timed) != thrd_success)\n+ FAIL_EXIT1 (\"mtx_init failed\");\n+\n+ if (clock_gettime (CLOCK_REALTIME, &wait_time) != 0)\n+ FAIL_EXIT1 (\"clock_gettime failed\");\n+ /* Tiny amount of time, to assure that if any thread finds it busy.\n+ It will receive thrd_timedout. */\n+ wait_time.tv_nsec += 1;\n+\n+ if (thrd_create (&id, child_add, NULL) != thrd_success)\n+ FAIL_EXIT1 (\"thrd_create failed\");\n+\n+ choose_action (mtx_timedlock (&mutex, &wait_time), parent_name);\n+\n+ if (thrd_join (id, NULL) != thrd_success)\n+ FAIL_EXIT1 (\"thrd_join failed\");\n+\n+ if (shrd_counter != 2 && shrd_counter != 1)\n+ FAIL_EXIT1 (\"shrd_counter != {1,2} (%d)\", shrd_counter);\n+\n+ mtx_destroy (&mutex);\n+\n+ return 0;\n+}\n+\n+#include <support/test-driver.c>\ndiff --git a/nptl/tst-mtx-trylock.c b/nptl/tst-mtx-trylock.c\nnew file mode 100644\nindex 0000000..5c1e804\n--- /dev/null\n+++ b/nptl/tst-mtx-trylock.c\n@@ -0,0 +1,90 @@\n+/* C11 threads trylock mutex tests.\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 <threads.h>\n+#include <stdio.h>\n+#include <unistd.h>\n+\n+#include <support/check.h>\n+\n+/* Shared mutex between child and parent. */\n+static mtx_t mutex;\n+\n+/* Shared counter to check possible race conditions. */\n+static char shrd_counter;\n+\n+/* Function to choose an action to do, depending on mtx_trylock\n+ return value. */\n+static inline void\n+choose_action (int action, char* thread_name)\n+{\n+ switch (action)\n+ {\n+ case thrd_success:\n+ ++shrd_counter;\n+\n+\tif (mtx_unlock (&mutex) != thrd_success)\n+\t FAIL_EXIT1 (\"mtx_unlock failed\");\n+ break;\n+\n+ case thrd_busy:\n+ break;\n+\n+ case thrd_error:\n+\tFAIL_EXIT1 (\"%s lock error\", thread_name);\n+ break;\n+ }\n+}\n+\n+static int\n+child_add (void *arg)\n+{\n+ char child_name[] = \"child\";\n+\n+ /* Try to lock mutex. */\n+ choose_action (mtx_trylock (&mutex), child_name);\n+\n+ thrd_exit (thrd_success);\n+}\n+\n+static int\n+do_test (void)\n+{\n+ thrd_t id;\n+ char parent_name[] = \"parent\";\n+\n+ if (mtx_init (&mutex, mtx_timed) != thrd_success)\n+ FAIL_EXIT1 (\"mtx_init failed\");\n+\n+ if (thrd_create (&id, child_add, NULL) != thrd_success)\n+ FAIL_EXIT1 (\"thrd_create failed\");\n+\n+ choose_action (mtx_trylock (&mutex), parent_name);\n+\n+ if (thrd_join (id, NULL) != thrd_success)\n+ FAIL_EXIT1 (\"thrd_join failed\");\n+\n+ if (shrd_counter != 2 && shrd_counter != 1)\n+ FAIL_EXIT1 (\"shrd_counter != {1,2} (%d)\", shrd_counter);\n+\n+ mtx_destroy (&mutex);\n+\n+ return 0;\n+}\n+\n+#include <support/test-driver.c>\ndiff --git a/nptl/tst-thrd-detach.c b/nptl/tst-thrd-detach.c\nnew file mode 100644\nindex 0000000..ec28173\n--- /dev/null\n+++ b/nptl/tst-thrd-detach.c\n@@ -0,0 +1,52 @@\n+/* C11 threads thread detach tests.\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 <threads.h>\n+#include <time.h>\n+#include <stdio.h>\n+#include <unistd.h>\n+\n+#include <support/check.h>\n+\n+static int\n+detach_thrd (void *arg)\n+{\n+ if (thrd_detach (thrd_current ()) != thrd_success)\n+ FAIL_EXIT1 (\"thrd_detach failed\");\n+ thrd_exit (thrd_success);\n+}\n+\n+static int\n+do_test (void)\n+{\n+ thrd_t id;\n+\n+ /* Create new thread. */\n+ if (thrd_create (&id, detach_thrd, NULL) != thrd_success)\n+ FAIL_EXIT1 (\"thrd_create failed\");\n+\n+ /* Give some time so the thread can finish. */\n+ thrd_sleep (&(struct timespec){.tv_sec = 2}, NULL);\n+\n+ if (thrd_join (id, NULL) == thrd_success)\n+ FAIL_EXIT1 (\"thrd_join succeed where it should fail\");\n+\n+ return 0;\n+}\n+\n+#include <support/test-driver.c>\ndiff --git a/nptl/tst-thrd-sleep.c b/nptl/tst-thrd-sleep.c\nnew file mode 100644\nindex 0000000..17380b2\n--- /dev/null\n+++ b/nptl/tst-thrd-sleep.c\n@@ -0,0 +1,51 @@\n+/* C11 threads thread sleep tests.\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 <threads.h>\n+#include <time.h>\n+#include <stdio.h>\n+#include <unistd.h>\n+\n+#include <support/check.h>\n+\n+static int\n+sleep_thrd (void *arg)\n+{\n+ struct timespec const *tl = (struct timespec const *) arg;\n+ if (thrd_sleep (tl, NULL) != thrd_success)\n+ FAIL_EXIT1 (\"thrd_sleep failed\");\n+\n+ thrd_exit (thrd_success);\n+}\n+\n+static int\n+do_test (void)\n+{\n+ thrd_t id;\n+ struct timespec wait_time = {.tv_sec = 3};\n+\n+ if (thrd_create (&id, sleep_thrd, (void *) (&wait_time)) != thrd_success)\n+ FAIL_EXIT1 (\"thrd_create failed\");\n+\n+ if (thrd_join (id, NULL) != thrd_success)\n+ FAIL_EXIT1 (\"thrd failed\");\n+\n+ return 0;\n+}\n+\n+#include <support/test-driver.c>\ndiff --git a/nptl/tst-tss-basic.c b/nptl/tst-tss-basic.c\nnew file mode 100644\nindex 0000000..8181dc1\n--- /dev/null\n+++ b/nptl/tst-tss-basic.c\n@@ -0,0 +1,75 @@\n+/* C11 threads specific storage tests.\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 <threads.h>\n+#include <stdio.h>\n+#include <unistd.h>\n+\n+#include <support/check.h>\n+\n+/* Thread specific storage. */\n+static tss_t key;\n+\n+#define TSS_VALUE (void*) 0xFF\n+\n+static int\n+tss_thrd (void *arg)\n+{\n+ if (tss_create (&key, NULL) != thrd_success)\n+ FAIL_EXIT1 (\"tss_create failed\");\n+\n+ if (tss_set (key, TSS_VALUE))\n+ FAIL_EXIT1 (\"tss_set failed\");\n+\n+ void *value = tss_get (key);\n+ if (value == 0)\n+ FAIL_EXIT1 (\"tss_get failed\");\n+ if (value != TSS_VALUE)\n+ FAIL_EXIT1 (\"tss_get returned %p, expected %p\", value, TSS_VALUE);\n+\n+ thrd_exit (thrd_success);\n+}\n+\n+static int\n+do_test (void)\n+{\n+ /* Setting an invalid key should return an error. */\n+ if (tss_set (key, TSS_VALUE) == thrd_success)\n+ FAIL_EXIT1 (\"tss_set succeed where it should have failed\");\n+\n+ if (tss_create (&key, NULL) != thrd_success)\n+ FAIL_EXIT1 (\"tss_create failed\");\n+\n+ thrd_t id;\n+ if (thrd_create (&id, tss_thrd, NULL) != thrd_success)\n+ FAIL_EXIT1 (\"thrd_create failed\");\n+\n+ if (thrd_join (id, NULL) != thrd_success)\n+ FAIL_EXIT1 (\"thrd failed\");\n+\n+ /* The value set in tss_thrd should not be visible here. */\n+ void *value = tss_get (key);\n+ if (value != 0)\n+ FAIL_EXIT1 (\"tss_get succeed where it should have failed\");\n+\n+ tss_delete (key);\n+\n+ return 0;\n+}\n+\n+#include <support/test-driver.c>\n", "prefixes": [ "7/8" ] }