From patchwork Thu Mar 19 14:41:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 38581 Return-Path: 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 6DCF33940CE4 for ; Thu, 19 Mar 2020 14:41:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6DCF33940CE4 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 168EA2785BA; Thu, 19 Mar 2020 10:41:39 -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 0znyI-LDNQ3H; Thu, 19 Mar 2020 10:41:38 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 7C2EB27864F; Thu, 19 Mar 2020 10:41:35 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 7C2EB27864F 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 rF0Ie_AITO3A; Thu, 19 Mar 2020 10:41:35 -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 6CC47278716; Thu, 19 Mar 2020 10:41:30 -0400 (EDT) From: Mathieu Desnoyers To: Carlos O'Donell Cc: Florian Weimer , Joseph Myers , Szabolcs Nagy , libc-alpha@sourceware.org, Mathieu Desnoyers Subject: [RFC PATCH glibc 7/8] support: implement xpthread key create/delete (v4) Date: Thu, 19 Mar 2020 10:41:09 -0400 Message-Id: <20200319144110.3733-8-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200319144110.3733-1-mathieu.desnoyers@efficios.com> References: <20200319144110.3733-1-mathieu.desnoyers@efficios.com> X-Spam-Status: No, score=-25.2 required=5.0 tests=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 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-List-Received-Date: Thu, 19 Mar 2020 14:41:41 -0000 Expose xpthread_key_create () and xpthread_key_delete () wrappers for tests. * support/Makefile: Add xpthread_key_create and xpthread_key_delete. * support/xthread.h: Add prototype for xpthread_key_create and xpthread_key_delete. * support/xpthread_key_create.c: New file. * support/xpthread_key_delete.c: New file. 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. --- support/Makefile | 2 ++ support/xpthread_key_create.c | 25 +++++++++++++++++++++++++ support/xpthread_key_delete.c | 24 ++++++++++++++++++++++++ support/xthread.h | 2 ++ 4 files changed, 53 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 6e38b87ebe..4498192a0a 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..1988dee138 --- /dev/null +++ b/support/xpthread_key_create.c @@ -0,0 +1,25 @@ +/* pthread_key_create with error checking. + Copyright (C) 2019-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_create (pthread_key_t *key, void (*destr_function) (void *)) +{ + xpthread_check_return ("pthread_key_create", + pthread_key_create (key, destr_function)); +} diff --git a/support/xpthread_key_delete.c b/support/xpthread_key_delete.c new file mode 100644 index 0000000000..99144512d4 --- /dev/null +++ b/support/xpthread_key_delete.c @@ -0,0 +1,24 @@ +/* pthread_key_delete with error checking. + Copyright (C) 2019-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..2a519874bf 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); +void xpthread_key_create (pthread_key_t *key, void (*destr_function) (void *)); +void xpthread_key_delete (pthread_key_t key); __END_DECLS