From patchwork Mon Dec 6 13:46:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 48531 X-Patchwork-Delegate: szabolcs.nagy@arm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5F70A3858411 for ; Mon, 6 Dec 2021 13:47:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F70A3858411 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1638798441; bh=RHDVPYam/fgIpTxzbOUST1IgyXecELRQSqxVz4oVH8o=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=sJdMIMR+KJoF2l+6+Wl2gPkEq9KNOxshjTNTxxZ0FYKymY7Zd7hCnGYdhigCpHzgI jFYx2CwVDNBCJLpCuXiRyARfKqrYrhKzcHzR4XcSO7bQLWaNoy6GEU6k7mn0/x3g85 OvWtDxLqVtqLnaZTYo9gJEa99SIOEMAKjqQ0v/yc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id DA025385842B for ; Mon, 6 Dec 2021 13:46:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DA025385842B Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-240-9VNQBh7OONm0xy8zX2xWrg-1; Mon, 06 Dec 2021 08:46:07 -0500 X-MC-Unique: 9VNQBh7OONm0xy8zX2xWrg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0CB0080BCAB; Mon, 6 Dec 2021 13:46:06 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.193.123]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BFF5B10016FE; Mon, 6 Dec 2021 13:46:04 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 1/5] nptl: Add for defining __thread_pointer In-Reply-To: References: X-From-Line: aa65894a9829ba546c4672d3597e90ca29adff4f Mon Sep 17 00:00:00 2001 Message-Id: Date: Mon, 06 Dec 2021 14:46:02 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Cc: Mathieu Desnoyers Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" already contains a definition that is quite similar, but it is not readily accessible. --- sysdeps/csky/nptl/thread_pointer.h | 25 ++++++++++++++++++ sysdeps/hppa/nptl/thread_pointer.h | 25 ++++++++++++++++++ sysdeps/ia64/nptl/thread_pointer.h | 19 ++++++++++++++ sysdeps/m68k/nptl/thread_pointer.h | 20 ++++++++++++++ sysdeps/microblaze/nptl/thread_pointer.h | 19 ++++++++++++++ sysdeps/nptl/thread_pointer.h | 19 ++++++++++++++ sysdeps/powerpc/nptl/thread_pointer.h | 23 +++++++++++++++++ sysdeps/sparc/nptl/thread_pointer.h | 19 ++++++++++++++ sysdeps/x86/nptl/thread_pointer.h | 33 ++++++++++++++++++++++++ 9 files changed, 202 insertions(+) create mode 100644 sysdeps/csky/nptl/thread_pointer.h create mode 100644 sysdeps/hppa/nptl/thread_pointer.h create mode 100644 sysdeps/ia64/nptl/thread_pointer.h create mode 100644 sysdeps/m68k/nptl/thread_pointer.h create mode 100644 sysdeps/microblaze/nptl/thread_pointer.h create mode 100644 sysdeps/nptl/thread_pointer.h create mode 100644 sysdeps/powerpc/nptl/thread_pointer.h create mode 100644 sysdeps/sparc/nptl/thread_pointer.h create mode 100644 sysdeps/x86/nptl/thread_pointer.h diff --git a/sysdeps/csky/nptl/thread_pointer.h b/sysdeps/csky/nptl/thread_pointer.h new file mode 100644 index 0000000000..c8be0b1e84 --- /dev/null +++ b/sysdeps/csky/nptl/thread_pointer.h @@ -0,0 +1,25 @@ +/* __thread_pointer definition. csky version. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +static inline void * +__thread_pointer (void) +{ + void *__result; + __asm__ volatile ("mov %0, r31" : "=r" (__result)); + return __result; +} diff --git a/sysdeps/hppa/nptl/thread_pointer.h b/sysdeps/hppa/nptl/thread_pointer.h new file mode 100644 index 0000000000..118b7f9385 --- /dev/null +++ b/sysdeps/hppa/nptl/thread_pointer.h @@ -0,0 +1,25 @@ +/* __thread_pointer definition. hppa version. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +static inline void * +__thread_pointer (void) +{ + void *__result; + __asm__ ("mfctl %%cr27, %0" : "=r" (__result)); + return __result; +} diff --git a/sysdeps/ia64/nptl/thread_pointer.h b/sysdeps/ia64/nptl/thread_pointer.h new file mode 100644 index 0000000000..412b9f0460 --- /dev/null +++ b/sysdeps/ia64/nptl/thread_pointer.h @@ -0,0 +1,19 @@ +/* __thread_pointer definition. ia64 version. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#define __thread_pointer() ({ register void *__reg asm ("r13"); __reg; }) diff --git a/sysdeps/m68k/nptl/thread_pointer.h b/sysdeps/m68k/nptl/thread_pointer.h new file mode 100644 index 0000000000..932567fddb --- /dev/null +++ b/sysdeps/m68k/nptl/thread_pointer.h @@ -0,0 +1,20 @@ +/* __thread_pointer definition. m68k version. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +extern void * __m68k_read_tp (void); +#define __thread_pointer() __m68k_read_tp () diff --git a/sysdeps/microblaze/nptl/thread_pointer.h b/sysdeps/microblaze/nptl/thread_pointer.h new file mode 100644 index 0000000000..020c73113a --- /dev/null +++ b/sysdeps/microblaze/nptl/thread_pointer.h @@ -0,0 +1,19 @@ +/* __thread_pointer definition. microblaze version. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#define __thread_pointer() ({ register void *__reg asm ("r21"); __reg; }) diff --git a/sysdeps/nptl/thread_pointer.h b/sysdeps/nptl/thread_pointer.h new file mode 100644 index 0000000000..6368b1083e --- /dev/null +++ b/sysdeps/nptl/thread_pointer.h @@ -0,0 +1,19 @@ +/* __thread_pointer definition. Generic version. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#define __thread_pointer() __builtin_thread_pointer () diff --git a/sysdeps/powerpc/nptl/thread_pointer.h b/sysdeps/powerpc/nptl/thread_pointer.h new file mode 100644 index 0000000000..69943a2f24 --- /dev/null +++ b/sysdeps/powerpc/nptl/thread_pointer.h @@ -0,0 +1,23 @@ +/* __thread_pointer definition. powerpc version. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#ifdef __powerpc64__ +# define __thread_pointer() ({ register void *__reg asm ("r13"); __reg; }) +#else +# define __thread_pointer() ({ register void *__reg asm ("r2"); __reg; }) +#endif diff --git a/sysdeps/sparc/nptl/thread_pointer.h b/sysdeps/sparc/nptl/thread_pointer.h new file mode 100644 index 0000000000..6a176cba28 --- /dev/null +++ b/sysdeps/sparc/nptl/thread_pointer.h @@ -0,0 +1,19 @@ +/* __thread_pointer definition. sparc version. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#define __thread_pointer() ({ register void *__reg asm ("%g7"); __reg; }) diff --git a/sysdeps/x86/nptl/thread_pointer.h b/sysdeps/x86/nptl/thread_pointer.h new file mode 100644 index 0000000000..d636839ecf --- /dev/null +++ b/sysdeps/x86/nptl/thread_pointer.h @@ -0,0 +1,33 @@ +/* __thread_pointer definition. x86 version. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#if __GNUC_PREREQ (11, 1) +# define __thread_pointer() __builtin_thread_pointer () +#else +static inline void * +__thread_pointer (void) +{ + void *__result; +# ifdef __x86_64__ + __asm__ volatile ("mov %%fs:0, %0" : "=r" (__result)); +# else + __asm__ volatile ("mov %%gs:0, %0" : "=r" (__result)); +#endif + return __result; +} +#endif