From patchwork Mon Apr 27 19:16:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 1277880 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=sourceware.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=aU6MpPAA; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 499vfS5Jqpz9sRY for ; Tue, 28 Apr 2020 05:17:04 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 90B49385BF81; Mon, 27 Apr 2020 19:17:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 90B49385BF81 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1588015021; bh=E/ETwrsDvr7LPkdHcobU7XyCECYTF44GX0IEMtl5r40=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=aU6MpPAA00XuIV0520R+p5EBoP8kUS98qj6ZuNmcfkLdSpi4SaXBaUd7pQnc3gZe6 g0EMhg8WXXSuQbq9+jhPgxi47nblP4GpOAP/UI7abxFMNaK0lUjdAwJvr1BcdTBXQc l9+CvFQKl3hzYS5OzQNXZhTuE+wQwkRVsuAh5U0Q= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.efficios.com (mail.efficios.com [167.114.26.124]) by sourceware.org (Postfix) with ESMTPS id AE1F73858D34 for ; Mon, 27 Apr 2020 19:16:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AE1F73858D34 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 5DE3025CE4B; Mon, 27 Apr 2020 15:16:59 -0400 (EDT) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id xKlWNEo0A3mR; Mon, 27 Apr 2020 15:16:59 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 016D625CB6E; Mon, 27 Apr 2020 15:16:59 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 016D625CB6E X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id mUGkTgIjjeiX; Mon, 27 Apr 2020 15:16:58 -0400 (EDT) Received: from localhost.localdomain (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by mail.efficios.com (Postfix) with ESMTPSA id CBBD025CC5E; Mon, 27 Apr 2020 15:16:58 -0400 (EDT) To: Carlos O'Donell Subject: [PATCH glibc 1/1] support: implement xpthread key create/delete (v6) Date: Mon, 27 Apr 2020 15:16:57 -0400 Message-Id: <20200427191657.2759-1-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-29.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Mathieu Desnoyers via Libc-alpha From: Mathieu Desnoyers Reply-To: Mathieu Desnoyers Cc: libc-alpha@sourceware.org, Joseph Myers , Mathieu Desnoyers Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Expose xpthread_key_create () and xpthread_key_delete () wrappers for tests. Signed-off-by: Mathieu Desnoyers CC: Carlos O'Donell CC: Florian Weimer CC: Joseph Myers CC: Szabolcs Nagy CC: libc-alpha@sourceware.org --- Changes since v1: - Update ChangeLog. - Wrap long line in xpthread_key_create. Changes since v2: - Rebase on glibc 2.30. Changes since v3: - Update copyright range to include 2020. Changes since v4: - Update copyright date to specifically only 2020. - Change xpthread_key_create prototype to return a pthread_key_t, similarly to what has been done for xpthread_create. Changes since v5: - Use https:// rather than http://. --- support/Makefile | 2 ++ support/xpthread_key_create.c | 28 ++++++++++++++++++++++++++++ support/xpthread_key_delete.c | 24 ++++++++++++++++++++++++ support/xthread.h | 2 ++ 4 files changed, 56 insertions(+) create mode 100644 support/xpthread_key_create.c create mode 100644 support/xpthread_key_delete.c diff --git a/support/Makefile b/support/Makefile index 9364f3bd3e..51484310cd 100644 --- a/support/Makefile +++ b/support/Makefile @@ -130,6 +130,8 @@ libsupport-routines = \ xpthread_create \ xpthread_detach \ xpthread_join \ + xpthread_key_create \ + xpthread_key_delete \ xpthread_mutex_consistent \ xpthread_mutex_destroy \ xpthread_mutex_init \ diff --git a/support/xpthread_key_create.c b/support/xpthread_key_create.c new file mode 100644 index 0000000000..53bb61ef07 --- /dev/null +++ b/support/xpthread_key_create.c @@ -0,0 +1,28 @@ +/* pthread_key_create with error checking. + Copyright (C) 2020 Free Software Foundation, Inc. + + 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 + +pthread_key_t +xpthread_key_create (void (*destr_function) (void *)) +{ + pthread_key_t key; + + xpthread_check_return ("pthread_key_create", + pthread_key_create (&key, destr_function)); + return key; +} diff --git a/support/xpthread_key_delete.c b/support/xpthread_key_delete.c new file mode 100644 index 0000000000..2425814ba4 --- /dev/null +++ b/support/xpthread_key_delete.c @@ -0,0 +1,24 @@ +/* pthread_key_delete with error checking. + Copyright (C) 2020 Free Software Foundation, Inc. + + 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 + +void +xpthread_key_delete (pthread_key_t key) +{ + xpthread_check_return ("pthread_key_delete", pthread_key_delete (key)); +} diff --git a/support/xthread.h b/support/xthread.h index d350d1506d..05f8d4a7d9 100644 --- a/support/xthread.h +++ b/support/xthread.h @@ -95,6 +95,8 @@ void xpthread_rwlock_wrlock (pthread_rwlock_t *rwlock); void xpthread_rwlock_rdlock (pthread_rwlock_t *rwlock); void xpthread_rwlock_unlock (pthread_rwlock_t *rwlock); void xpthread_rwlock_destroy (pthread_rwlock_t *rwlock); +pthread_key_t xpthread_key_create (void (*destr_function) (void *)); +void xpthread_key_delete (pthread_key_t key); __END_DECLS