From patchwork Fri May 3 18:42:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 1095018 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-101736-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="cJ3rsnNi"; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.b="C6Ye9yYO"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44wh5b02GJz9s9y for ; Sat, 4 May 2019 04:50:10 +1000 (AEST) 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=NKKH8hItB6/Y4NGE0U67ETPBviNkVvU sbhI4hp2d7rh8drBdURkfI5MF5kbZVMv/5C7zxwpZGeNKI0p2CqvxlZDNQ2db/T7 hohLB1MVqImaoaz+K5sim03HAlDUQ416LXSWfrK2fS6ujNNlS3OzetX216x4u3zG ExjWYSP+zonk= 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=MDAmS052tEjWHq/1rSfvMmG5Gtk=; b=cJ3rs nNix2+i6WVUhC3nQV5CMc350vZ5kG5c9NRxqLbnIXZyukkkISY+/NKun69yO4npr 01pkaEhlkFoK/Iz9VvRz77A7NrZISfu+/xGq2i1wyWUW/1sLN7tNwIqjexkpSTu4 Qogmq3pUU24FssTFx8iK/uFiTIxqHm4mcvu5ZM= Received: (qmail 26279 invoked by alias); 3 May 2019 18:50:04 -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 26267 invoked by uid 89); 3 May 2019 18:50:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=1168, HX-Languages-Length:4583 X-HELO: mail.efficios.com DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 1ADC61DD9EA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1556908947; bh=64pvLHxxhVYFjS4FbglspP79xnunYDx66xMEAcmKod0=; h=From:To:Date:Message-Id; b=C6Ye9yYOUGY2iBsvpSszUknYguvRfQwI0EGE4WnuSEDL0r556WCJE+/YMLvsBN6bg iai9FvTO33ENZkaU7vbIYT/KBkBgpRG2Njl2IquZMqUMI9i/h+R/mXLEx5W5FyoUVL BwJu2xsWPFBxPvo79Au8K5lg1R7W/kDAqFISRjhDkT1SFwECAe/JWcrKAVAd6wmWSI lzu/IbR59lvng4LbO4ZGsHZ0TImMIgUjmP33ClAGteZwSknM9s2EGFHeGwqKzX7vLy pjeBL/Y9S7v7O2cAH9X/nV5wftZbdOlm1lRjQ00QQez05MjZPd17rkAqtlEEAbYub4 CVXRKmZIUXQBg== From: Mathieu Desnoyers To: Carlos O'Donell Cc: Florian Weimer , Joseph Myers , Szabolcs Nagy , libc-alpha@sourceware.org, Mathieu Desnoyers Subject: [PATCH 4/5] support: implement xpthread key create/delete (v2) Date: Fri, 3 May 2019 14:42:18 -0400 Message-Id: <20190503184219.19266-5-mathieu.desnoyers@efficios.com> In-Reply-To: <20190503184219.19266-1-mathieu.desnoyers@efficios.com> References: <20190503184219.19266-1-mathieu.desnoyers@efficios.com> 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. --- ChangeLog | 7 +++++++ support/Makefile | 2 ++ support/xpthread_key_create.c | 25 +++++++++++++++++++++++++ support/xpthread_key_delete.c | 24 ++++++++++++++++++++++++ support/xthread.h | 2 ++ 5 files changed, 60 insertions(+) create mode 100644 support/xpthread_key_create.c create mode 100644 support/xpthread_key_delete.c diff --git a/ChangeLog b/ChangeLog index 3e8ec0de1c..60038cad90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2019-04-23 Mathieu Desnoyers + * 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. + 2019-04-23 Mathieu Desnoyers * sysdeps/unix/sysv/linux/sched_getcpu.c: use rseq cpu_id TLS on diff --git a/support/Makefile b/support/Makefile index 432cf2fe6c..7ae0d9171d 100644 --- a/support/Makefile +++ b/support/Makefile @@ -116,6 +116,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..fb5a89ab3a --- /dev/null +++ b/support/xpthread_key_create.c @@ -0,0 +1,25 @@ +/* pthread_key_create with error checking. + Copyright (C) 2019 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..423ff4584d --- /dev/null +++ b/support/xpthread_key_delete.c @@ -0,0 +1,24 @@ +/* pthread_key_delete with error checking. + Copyright (C) 2019 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 47c23235f3..fce3435d65 100644 --- a/support/xthread.h +++ b/support/xthread.h @@ -84,6 +84,8 @@ void xpthread_rwlockattr_setkind_np (pthread_rwlockattr_t *attr, int pref); 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_key_create (pthread_key_t *key, void (*destr_function) (void *)); +void xpthread_key_delete (pthread_key_t key); __END_DECLS