From patchwork Mon Jan 6 15:57:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 1218286 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=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108470-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="dheelU4a"; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.b="JbPxfT+o"; 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 47s0Yg4pHgz9s29 for ; Tue, 7 Jan 2020 02:59:03 +1100 (AEDT) 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=pLJi8F4jlimI+LFFPD/xUgliveVIIgV ypSjKZGLpszMKvJEaAacgrW8XCEYWkDXrAgWE7XIHn3z9hShHHvQn7DoCXCwiSSE HFFG5AOH1AgCCnvgWclUY0L5z4eDLOiU+mSKihAeQZKNbGWANQK9DO+sAEV5oPQA DDnMjOTxHxdU= 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=G8bhR+O/+lU5n9Bp1MjgzJVM1MQ=; b=dheel U4azpbLvTYNwO1uYbGnlTvBrC6741cScHisiEengkmrbA4VWCc3dxJ9bYdwcZP0Q 3sP3RUANbLwDDGCuN1wp60VUgPIW6iUgykP3LrMv0YORXHiDOMGlmQcMvh9DdQeT k9yL/dQrStNmvnl0pqCgxuGIh0MJnJwnF9SS5Y= Received: (qmail 95988 invoked by alias); 6 Jan 2020 15:57:36 -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 95897 invoked by uid 89); 6 Jan 2020 15:57:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.6 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=expose, sk:carlos, wrap, U*carlos X-HELO: mail.efficios.com DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com E765E1EA1E5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1578326241; bh=i92kmCPFIYhA2AzBQQi0It6BOwMOil8RcF5iAv+iUvw=; h=From:To:Date:Message-Id; b=JbPxfT+oQGIuAfa14E78Qo7eKifRriLJHGKTh17xahymWUsnQkoaSFD2HXg+WduSd mePfEFTOrqdg6zH5ZzIaRqUY0D53UjCNxu7vh6vG18QPMyV90sLGJayPQn8+Z86hnW GhSVDk4ah6MeVpaRc+UecnKSyJdShf6NGLqXV1Uv7zOrv7HNZZvw6AeDqjFCBOqbOQ yEFXGXbJEem4Gc4llGghxdXdlXwJwCOQOuHZkHV0TClKvxRnp4fLFbWvKt2qkaXX3w UkQ+ICI7ycBgHZFy0/8dW4oYRQyo9PHgCo3BGWqSjhzV2SgldU2jtQvomHBxpXI6SM yQqn0j/ASHKlQ== From: Mathieu Desnoyers To: Carlos O'Donell Cc: Florian Weimer , Joseph Myers , Szabolcs Nagy , libc-alpha@sourceware.org, Mathieu Desnoyers Subject: [RFC PATCH glibc 12/13] support: implement xpthread key create/delete (v3) Date: Mon, 6 Jan 2020 10:57:12 -0500 Message-Id: <20200106155713.397-13-mathieu.desnoyers@efficios.com> In-Reply-To: <20200106155713.397-1-mathieu.desnoyers@efficios.com> References: <20200106155713.397-1-mathieu.desnoyers@efficios.com> 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. --- 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 23c6d74627..affc598c65 100644 --- a/support/Makefile +++ b/support/Makefile @@ -127,6 +127,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 f39720cb23..4be86b39a0 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