From patchwork Thu Mar 1 00:50:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 879508 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-90693-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="ylXshe+F"; 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 3zsDPJ2vWnz9s25 for ; Thu, 1 Mar 2018 11:50:28 +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; q=dns; s= default; b=HNxFKYuFXQYpJjVoBUsljKcv/EDSych02mw4VItZ9s30B1/wJfCo8 TcabdQaOrjohogo5J/gvxTyD4kzEzk6Xz4oNPmE4jDw8EjUeBN/NvalaRzNSEmVB bkE/3v/PVszAPfzx4Lb1I0jiwBx6K/g49L5tf8RVqV97lfJr7/fWH4= 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; s=default; bh=zpZZ1rzPXrBYszhasBv6+4G4Uqk=; b=ylXshe+FSQvGX0aTJN2wlIOLkYNK HmErObNpCNU2DIe0pmjjh4KXz7pdPdJ7kC6TDEtJK0O6yOhli7u67OlMs1Bbh8Mb wKIF+QzjVYAJR9pVO+3euJ6eDG90Y7WGZzdSMUygV1nKkWOptaHBdxPK41anj8Cb +pyAyYYOcnLTFXw= Received: (qmail 84904 invoked by alias); 1 Mar 2018 00:50:22 -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 83847 invoked by uid 89); 1 Mar 2018 00:50:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, SPF_NEUTRAL autolearn=ham version=3.3.2 spammy=Temporary, dtv, Hx-languages-length:2384, H*r:sk:static- X-HELO: hera.aquilenet.fr From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault Subject: [PATCH] hurd: add gscope support Date: Thu, 1 Mar 2018 01:50:14 +0100 Message-Id: <20180301005014.10220-1-samuel.thibault@ens-lyon.org> * elf/dl-support.c [THREAD_GSCOPE_GLOBAL] (_dl_thread_gscope_count): Define variable. * sysdeps/generic/ldsodefs.h [THREAD_GSCOPE_GLOBAL] (struct rtld_global): Add _dl_thread_gscope_count member. * sysdeps/mach/hurd/tls.h: Include . [!defined __ASSEMBLER__] (THREAD_GSCOPE_GLOBAL, THREAD_GSCOPE_SET_FLAG, THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_WAIT): Define macros. --- ChangeLog | 10 ++++++++++ elf/dl-support.c | 3 +++ sysdeps/generic/ldsodefs.h | 3 +++ sysdeps/mach/hurd/tls.h | 16 ++++++++++++++++ 4 files changed, 32 insertions(+) diff --git a/elf/dl-support.c b/elf/dl-support.c index 114f77a8e5..be564306f2 100644 --- a/elf/dl-support.c +++ b/elf/dl-support.c @@ -188,6 +188,9 @@ int (*_dl_make_stack_executable_hook) (void **) = _dl_make_stack_executable; /* Function in libpthread to wait for termination of lookups. */ void (*_dl_wait_lookup_done) (void); +#ifdef THREAD_GSCOPE_GLOBAL +int _dl_thread_gscope_count; +#endif struct dl_scope_free_list *_dl_scope_free_list; #ifdef NEED_DL_SYSINFO diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 5e1b24ecb5..2447cd6717 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -435,6 +435,9 @@ struct rtld_global size_t count; void *list[50]; } *_dl_scope_free_list; +#ifdef THREAD_GSCOPE_GLOBAL + EXTERN int _dl_thread_gscope_count; +#endif #ifdef SHARED }; # define __rtld_global_attribute__ diff --git a/sysdeps/mach/hurd/tls.h b/sysdeps/mach/hurd/tls.h index faff87c7b5..47a9a357c8 100644 --- a/sysdeps/mach/hurd/tls.h +++ b/sysdeps/mach/hurd/tls.h @@ -27,6 +27,7 @@ # include # include # include +# include /* This is the size of the initial TCB. */ @@ -51,6 +52,21 @@ # define GET_DTV(descr) \ (((tcbhead_t *) (descr))->dtv) +/* Temporary poor-man's global scope switch support */ +#define THREAD_GSCOPE_GLOBAL +#define THREAD_GSCOPE_SET_FLAG() \ + atomic_increment(&GL(dl_thread_gscope_count)) +#define THREAD_GSCOPE_RESET_FLAG() do { \ + if (atomic_decrement_val(&GL(dl_thread_gscope_count)) == 0) \ + lll_wake(&GL(dl_thread_gscope_count), 0); \ +} while (0) +#define THREAD_GSCOPE_WAIT() do { \ + int count; \ + while ((count = GL(dl_thread_gscope_count))) { \ + lll_wait(&GL(dl_thread_gscope_count), count, 0); \ + } \ +} while (0) + #endif /* !ASSEMBLER */