From patchwork Tue Feb 14 17:37:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 1742542 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=yq1XQ5Yr; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PGT1q3wFvz23y6 for ; Wed, 15 Feb 2023 04:37:51 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 28D8E3858000 for ; Tue, 14 Feb 2023 17:37:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 28D8E3858000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676396268; bh=RRwJs9KfoYSLONnf+VCi9ztUu0dkiLXr2gxfrRnyogA=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=yq1XQ5Yr9mDUnIIbewSVpRouo+NXTVUJT9mOfxZmIUzmB1ndPdh5E1GxS2kYJDQl9 65cTxg6AK+toSI8UzRlH6VQiPqrZV5wxs8CsqiOc4nsVK8Wr5H5QH3GzzGK3eGF4CI iqPwnZckvlC8Isgos/5gGZwrouQvuOqVcAnYPaac= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by sourceware.org (Postfix) with ESMTPS id EB4233858D33 for ; Tue, 14 Feb 2023 17:37:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EB4233858D33 Received: by mail-lf1-x132.google.com with SMTP id j17so24533130lfr.3 for ; Tue, 14 Feb 2023 09:37:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RRwJs9KfoYSLONnf+VCi9ztUu0dkiLXr2gxfrRnyogA=; b=oeuS3P60lcYOOzTeFZWugnPyPkpi2gCba9NpGmcmiBegClmLCHSALluPhikGGyXqbx 0vZIh/jccwU0dARIgPSFznFh82CXRoQLB+RasDT+XdspnbhJBb7sKEnCFSkeIDc2BKcI WUuyxohanQ0X26Xxw5nsZHMckIYV8bsV4cmdjJn4c31DSMhq4PcY+R/DZEHf8mrMON3V l9Y6k3Mlu/7l7NSjideuG8BESeLo9WRC9da0e4Y5pFZPCZUKyzXkbxDpURFJeZDOM+VE c2P4uWd2gmjNm0vb17Gmmk4xHLJkFpGwtwJqjEOONdJjYm8DG9eB/tIZPpJfiLDcvHWd vC9w== X-Gm-Message-State: AO0yUKUxqenjLlsXb2Qfj8899HzFtMQKb++TAWPCLem8wL4wldILh/3u RbpzqvWJjIBYwQK8+gX2PN3IwVN7qsETm2Nx X-Google-Smtp-Source: AK7set+Myy7C5KYjLl1mAkFMdI3P4DAsL1zzAbqDaxO89PzSO02cBDXkDr7PVnsT7K7dlSqHBigSWg== X-Received: by 2002:ac2:5198:0:b0:4d5:99e4:7fcc with SMTP id u24-20020ac25198000000b004d599e47fccmr910595lfi.13.1676396249378; Tue, 14 Feb 2023 09:37:29 -0800 (PST) Received: from surface-pro-6.. ([194.190.106.50]) by smtp.gmail.com with ESMTPSA id w12-20020a19c50c000000b004db3e7dfb8csm424185lfe.189.2023.02.14.09.37.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Feb 2023 09:37:28 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: Sergey Bugaev Subject: [PATCH 1/3] hurd: i386 TLS tweaks Date: Tue, 14 Feb 2023 20:37:20 +0300 Message-Id: <20230214173722.428140-2-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214173722.428140-1-bugaevc@gmail.com> References: <20230214173722.428140-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" * Micro-optimize TLS access using GCC's native support for gs-based addressing when available; * Just use THREAD_GETMEM and THREAD_SETMEM instead of more inline assembly; * Sync tcbhead_t layout with NPTL, in particular update/fix __private_ss offset; * Statically assert that the two offsets that are a part of ABI are what we expect them to be. Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/i386/tls.h | 48 ++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/sysdeps/mach/hurd/i386/tls.h b/sysdeps/mach/hurd/i386/tls.h index a6ff0107..dc43d4c7 100644 --- a/sysdeps/mach/hurd/i386/tls.h +++ b/sysdeps/mach/hurd/i386/tls.h @@ -38,11 +38,12 @@ typedef struct uintptr_t stack_guard; uintptr_t pointer_guard; int gscope_flag; - int private_futex; + unsigned int feature_1; /* Reservation of some values for the TM ABI. */ - void *__private_tm[4]; + void *__private_tm[3]; /* GCC split stack support. */ void *__private_ss; + void *__glibc_padding1; /* Keep these fields last, so offsets of fields above can continue being compatible with the i386 Linux version. */ @@ -53,6 +54,13 @@ typedef struct struct rtld_catch *rtld_catch; } tcbhead_t; +/* GCC generates %gs:0x14 to access the stack guard. */ +_Static_assert (offsetof (tcbhead_t, stack_guard) == 0x14, + "stack guard offset"); +/* libgcc uses %gs:0x30 to access the split stack pointer. */ +_Static_assert (offsetof (tcbhead_t, __private_ss) == 0x30, + "split stack pointer offset"); + /* Return tcbhead_t from a TLS segment descriptor. */ # define HURD_DESC_TLS(desc) \ ({ \ @@ -166,8 +174,25 @@ out: # define TLS_INIT_TP(descr) \ _hurd_tls_init ((tcbhead_t *) (descr)) +# if __GNUC_PREREQ (6, 0) + +# define THREAD_SELF \ + (*(tcbhead_t * __seg_gs *) offsetof (tcbhead_t, tcb)) +# define THREAD_GETMEM(descr, member) \ + (*(__typeof (descr->member) __seg_gs *) offsetof (tcbhead_t, member)) +# define THREAD_GETMEM_NC(descr, member, idx) \ + (*(__typeof (descr->member[0]) __seg_gs *) \ + (offsetof (tcbhead_t, member) + (idx) * sizeof (descr->member[0]))) +# define THREAD_SETMEM(descr, member, value) \ + (*(__typeof (descr->member) __seg_gs *) offsetof (tcbhead_t, member) = value) +# define THREAD_SETMEM_NC(descr, member, index, value) \ + (*(__typeof (descr->member[0]) __seg_gs *) \ + (offsetof (tcbhead_t, member) + (idx) * sizeof (descr->member[0]))) + +# else + /* Return the TCB address of the current thread. */ -# define THREAD_SELF \ +# define THREAD_SELF \ ({ tcbhead_t *__tcb; \ __asm__ ("movl %%gs:%c1,%0" : "=r" (__tcb) \ : "i" (offsetof (tcbhead_t, tcb))); \ @@ -200,7 +225,7 @@ out: /* Same as THREAD_GETMEM, but the member offset can be non-constant. */ -# define THREAD_GETMEM_NC(descr, member, idx) \ +# define THREAD_GETMEM_NC(descr, member, idx) \ ({ __typeof (descr->member[0]) __value; \ _Static_assert (sizeof (__value) == 1 \ || sizeof (__value) == 4 \ @@ -229,7 +254,7 @@ out: /* Set member of the thread descriptor directly. */ -# define THREAD_SETMEM(descr, member, value) \ +# define THREAD_SETMEM(descr, member, value) \ ({ \ _Static_assert (sizeof (descr->member) == 1 \ || sizeof (descr->member) == 4 \ @@ -254,7 +279,7 @@ out: /* Same as THREAD_SETMEM, but the member offset can be non-constant. */ -# define THREAD_SETMEM_NC(descr, member, idx, value) \ +# define THREAD_SETMEM_NC(descr, member, idx, value) \ ({ \ _Static_assert (sizeof (descr->member[0]) == 1 \ || sizeof (descr->member[0]) == 4 \ @@ -279,6 +304,8 @@ out: "r" (idx)); \ }}) +# endif /* __GNUC_PREREQ (6, 0) */ + /* Return the TCB address of a thread given its state. Note: this is expensive. */ # define THREAD_TCB(thread, thread_state) \ @@ -295,15 +322,10 @@ out: HURD_DESC_TLS (___desc);}) /* Install new dtv for current thread. */ -# define INSTALL_NEW_DTV(dtvp) \ - ({ asm volatile ("movl %0,%%gs:%P1" \ - : : "ir" (dtvp), "i" (offsetof (tcbhead_t, dtv))); }) +# define INSTALL_NEW_DTV(dtvp) THREAD_SETMEM (THREAD_SELF, dtv, dtvp) /* Return the address of the dtv for the current thread. */ -# define THREAD_DTV() \ - ({ dtv_t *_dtv; \ - asm ("movl %%gs:%P1,%0" : "=q" (_dtv) : "i" (offsetof (tcbhead_t, dtv)));\ - _dtv; }) +# define THREAD_DTV() THREAD_GETMEM (THREAD_SELF, dtv) /* Set the stack guard field in TCB head. */ From patchwork Tue Feb 14 17:37:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 1742544 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=dks2agke; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PGT1r4cPTz23y6 for ; Wed, 15 Feb 2023 04:37:52 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7C40E385B539 for ; Tue, 14 Feb 2023 17:37:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7C40E385B539 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676396270; bh=wIdTQ6QGhgBgSEG4I6eFTYe1Iu/z6fQL61pnM1ukUWA=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=dks2agkefOUh057IOtcC1Es0iHZXaTsXWBbJaF952zuiv0kVMqoPmPxC5sSoeBFJT sSHCW0IlPfyVWtbkP0u5oe5/fPqGpkfVOo6rll1n/W8OYb0kAv1pRij/hzOK8pP9oA uP9JlJ8+8zT3/yy4pUxosx1aaaR7xnJ2oJmgIG3I= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by sourceware.org (Postfix) with ESMTPS id E4F903858D35 for ; Tue, 14 Feb 2023 17:37:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E4F903858D35 Received: by mail-lf1-x12c.google.com with SMTP id cf42so24546484lfb.1 for ; Tue, 14 Feb 2023 09:37:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wIdTQ6QGhgBgSEG4I6eFTYe1Iu/z6fQL61pnM1ukUWA=; b=1dox76Ac86Q9t584BIpwmta32ZzRuDWlN8MLdXJj05uDd+WagTDwfHyS/wBTUuiixm jySO42gSf41+sG+0qpj5XBGI9X/kkTp70xstQisEPkPReoQijUeCBU+OHrJIZeBWXkX3 8ONY2o/ITOqPFV/D27rk3OwPMwveY2HGaF+zIVVDvwLozUJ00khjEnMfYzHyRgm1Rezf iCILwtkFQ8l9i4oBEJKwusWnkIqn6hgtrOCLk16HEEvF973WZ/i3SedmU/dl4mnTY26j 09qru4c9947fQiJnFP8zRifDij06oymu5PC6+4FAE6jgh4QY0dvZ6h1yIqK+LYsddU2k 9F8w== X-Gm-Message-State: AO0yUKUkmWyJzu/8rEy64fbONr5ELDm2y7UEhwgPkedhxHUxJ+zA5raY KBuBLTfwySAxDN6iqb/RohI= X-Google-Smtp-Source: AK7set/y1HaKiT+jSLchs3MmVQXbeAGGRl92o4s++7OQUB+02lh/7anvEU2XTvO2brAoIIQKz/itNw== X-Received: by 2002:ac2:51cb:0:b0:4b5:90c5:281c with SMTP id u11-20020ac251cb000000b004b590c5281cmr910197lfm.19.1676396250377; Tue, 14 Feb 2023 09:37:30 -0800 (PST) Received: from surface-pro-6.. ([194.190.106.50]) by smtp.gmail.com with ESMTPSA id w12-20020a19c50c000000b004db3e7dfb8csm424185lfe.189.2023.02.14.09.37.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Feb 2023 09:37:29 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: Sergey Bugaev Subject: [PATCH 2/3] mach: undef ENTRY2 Date: Tue, 14 Feb 2023 20:37:21 +0300 Message-Id: <20230214173722.428140-3-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214173722.428140-1-bugaevc@gmail.com> References: <20230214173722.428140-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" This macro from Mach headers conflicts with how sysdeps/x86_64/multiarch/strcmp-sse2.S expects it to be defined. Signed-off-by: Sergey Bugaev --- sysdeps/mach/sysdep.h | 1 + 1 file changed, 1 insertion(+) diff --git a/sysdeps/mach/sysdep.h b/sysdeps/mach/sysdep.h index fe26bcb3..1c869f5c 100644 --- a/sysdeps/mach/sysdep.h +++ b/sysdeps/mach/sysdep.h @@ -30,6 +30,7 @@ /* For ELF we need to add the `.type' directive to make shared libraries work right. */ #undef ENTRY +#undef ENTRY2 #define ENTRY(name) \ .globl name; \ .align ALIGN; \ From patchwork Tue Feb 14 17:37:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 1742549 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=mNUWkgHK; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PGT2j4sBKz23r4 for ; Wed, 15 Feb 2023 04:38:37 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F0DAC385B529 for ; Tue, 14 Feb 2023 17:38:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F0DAC385B529 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676396315; bh=Ud/B61nfyhC1dBt+sjdb8DwsK4MWTkqRFpRA1cM26xw=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=mNUWkgHKz/bkviqFDOv2o85e4TM5klKpO9VkR5gjVEV3rNa5sQrELzQ33F7YEYBAd PJYHVh+cmOiXvndqg7prTSIOYeu85doWRSz1KyOk4XcGLtpNIvF1SMRIVudN/eXgSa kUp/pt6umWfnQgKXMSvQXvdIog3UhWIjBRgmhUso= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id 24F723858C53 for ; Tue, 14 Feb 2023 17:37:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 24F723858C53 Received: by mail-lf1-x12f.google.com with SMTP id g28so11919272lfv.0 for ; Tue, 14 Feb 2023 09:37:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ud/B61nfyhC1dBt+sjdb8DwsK4MWTkqRFpRA1cM26xw=; b=etDSWmO0oI/roUcUiRY9h1JD7eoaTevQURweHB7UXprAqfbxcs0yS/lNx8lQ/Nu2fS XuI/TMEH72Q48XNYeyXhv4JAerE33Lv2eaOL20Q7Pj32tsVSjT2k5JeHkFv1r9svcBrK PF/lXKa+Qet0yqqftlRHwCrT0TAhzIoIii8jEuSY2vmnLE5E0EcVNx3rGansO78dCF0r V17zrDF7JUSx/3VgSSLAwAdwy+CjAwEeL6vB6zlGSs8woeMNiow/c1nFGfKzgqo1sQbm OfwI2EOap6zNN7cXGDk3m1chL5Ru1NxyNmgVK8YSMvQCY/ZMKUcYnE5Son64seVPAitA eGPw== X-Gm-Message-State: AO0yUKUiWIO/+mUxEVYCbH9i8z0f9dPMSywDA2bABY0tfwYzj4iKMZZs iiwIrKjVQ8Bet+fAfoBnG/k= X-Google-Smtp-Source: AK7set+fOY3TE4atJkxlOiTkuF1ImlVIE5RMP4fA5AK6N1fi7zrAaIdaQziM46EkvfbZQkyddcm2qA== X-Received: by 2002:a05:6512:546:b0:4db:971:82cd with SMTP id h6-20020a056512054600b004db097182cdmr112129lfl.17.1676396251609; Tue, 14 Feb 2023 09:37:31 -0800 (PST) Received: from surface-pro-6.. ([194.190.106.50]) by smtp.gmail.com with ESMTPSA id w12-20020a19c50c000000b004db3e7dfb8csm424185lfe.189.2023.02.14.09.37.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Feb 2023 09:37:30 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: Sergey Bugaev Subject: [PATCH 3/3] htl: Make pthread_mutex_t pointer-aligned Date: Tue, 14 Feb 2023 20:37:22 +0300 Message-Id: <20230214173722.428140-4-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214173722.428140-1-bugaevc@gmail.com> References: <20230214173722.428140-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" This is for future-proofing. On i386, it is 4-byte aligned anyway, but on x86_64, we want it 8-byte aligned, not 4-byte aligned. Signed-off-by: Sergey Bugaev --- .../hurd/htl/bits/types/struct___pthread_mutex.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sysdeps/mach/hurd/htl/bits/types/struct___pthread_mutex.h b/sysdeps/mach/hurd/htl/bits/types/struct___pthread_mutex.h index d7b239f4..11caa870 100644 --- a/sysdeps/mach/hurd/htl/bits/types/struct___pthread_mutex.h +++ b/sysdeps/mach/hurd/htl/bits/types/struct___pthread_mutex.h @@ -30,20 +30,23 @@ struct __pthread_mutex int __shpid; int __type; int __flags; - unsigned int __reserved1; - unsigned int __reserved2; + union + { + unsigned int __reserved[2]; + void *__pointer_aligned; + }; }; /* Static mutex initializers. */ #define __PTHREAD_MUTEX_INITIALIZER \ - { 0, 0, 0, 0, __PTHREAD_MUTEX_TIMED, 0, 0, 0 } + { 0, 0, 0, 0, __PTHREAD_MUTEX_TIMED, 0, { { 0, 0 } } } /* The +1 is to mantain binary compatibility with the old * libpthread implementation. */ #define __PTHREAD_ERRORCHECK_MUTEX_INITIALIZER \ - { 0, 0, 0, 0, __PTHREAD_MUTEX_ERRORCHECK + 1, 0, 0, 0 } + { 0, 0, 0, 0, __PTHREAD_MUTEX_ERRORCHECK + 1, 0, { { 0, 0 } } } #define __PTHREAD_RECURSIVE_MUTEX_INITIALIZER \ - { 0, 0, 0, 0, __PTHREAD_MUTEX_RECURSIVE + 1, 0, 0, 0 } + { 0, 0, 0, 0, __PTHREAD_MUTEX_RECURSIVE + 1, 0, { { 0, 0 } } } #endif /* bits/types/struct___pthread_mutex.h */