From patchwork Sun Feb 12 11:10:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 64775 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 037B5385482E for ; Sun, 12 Feb 2023 11:11:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 037B5385482E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676200301; bh=C9+NaNpAg7vPA76/TRGiEsXV6D2rDWanTvlDbeSRnGc=; 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=MUEyXl7e+7Q5rx8gxYaZvasDct2OeZN8mjuijBdm1AtCefAALaf9rdUkbzMbKCE7o m0Hos8QzR3UJS4hBb30Qr4YuEiCxygpVC+EI72Id+9f+HV46OJtHmkACnhd1Jpwf8s jgIZDbELOwkSGAyxesA1XWPGHcmKkZuWM55M/+2Q= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by sourceware.org (Postfix) with ESMTPS id B3CC63858D32 for ; Sun, 12 Feb 2023 11:11:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B3CC63858D32 Received: by mail-ej1-x62b.google.com with SMTP id hx15so25561330ejc.11 for ; Sun, 12 Feb 2023 03:11:14 -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=C9+NaNpAg7vPA76/TRGiEsXV6D2rDWanTvlDbeSRnGc=; b=JBLRsMoQvFP/ZO35tLqn3u5t0ISAdHaGWNkcP9XoU9/NMXDMsJCOExATyk08VAVr2y ngGX+D8k7AlCYIALaxBSsCGEsmQkDvtc2h88Sn4uURkgC/73+ivGKrP4Yn0iIGeDRTE0 P3zbBhCPI8Iww0Mlw44lbjprbC0U03PvKcQdxxQ1UoCO82vXZfnqm4cj0o/WF5YC1hez uyMcLMqnHmQ/fq2pFySojkghm+xZqgfmRvfAh+/t0y+P+I829gBKpPCmMe2HnclkF/P9 8vIhro5OCgiPnbYRqiEiC4HsD3h2vM743iboxYgBfdqMU0jt5/623hi+pmdDKmj5FiY4 dmeA== X-Gm-Message-State: AO0yUKXXbgOsZB0NtvXhmwLLDpGOwZAnSeI2CD9eCTnJrSdsCBlI3dJL YqDZ/doksKrK2NyXVSb6EHk= X-Google-Smtp-Source: AK7set9nlmvYPG9FomC2b0GNES30ZZCrt6fb8gD1Ru6Y/5zCjObuwwWuTteXOJ3GqwoMA93nHfwk/Q== X-Received: by 2002:a17:907:a413:b0:8af:54d2:2088 with SMTP id sg19-20020a170907a41300b008af54d22088mr9105634ejc.37.1676200273439; Sun, 12 Feb 2023 03:11:13 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:2186:c463:9ced:e6fe]) by smtp.gmail.com with ESMTPSA id c61-20020a509fc3000000b004acbe0b36d2sm1266910edf.6.2023.02.12.03.11.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Feb 2023 03:11:13 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?utf-8?q?Fl=C3=A1vio_Cruz?= , Sergey Bugaev Subject: [RFC PATCH glibc 1/12] hurd: Refactor readlinkat() Date: Sun, 12 Feb 2023 14:10:32 +0300 Message-Id: <20230212111044.610942-2-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230212111044.610942-1-bugaevc@gmail.com> References: <20230212111044.610942-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.4 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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Make the code flow more linear using early returns where possible. This makes it so much easier to reason about what runs on error / successful code paths. Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/readlinkat.c | 55 ++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/sysdeps/mach/hurd/readlinkat.c b/sysdeps/mach/hurd/readlinkat.c index 1efb09ca..dabdbb37 100644 --- a/sysdeps/mach/hurd/readlinkat.c +++ b/sysdeps/mach/hurd/readlinkat.c @@ -31,38 +31,47 @@ __readlinkat (int fd, const char *file_name, char *buf, size_t len) error_t err; file_t file_stat; struct stat64 st; + enum retry_type doretry; + char retryname[1024]; + file_t file; + char *rbuf = buf; file_stat = __file_name_lookup_at (fd, 0, file_name, O_NOLINK, 0); if (file_stat == MACH_PORT_NULL) return -1; err = __io_stat (file_stat, &st); - if (! err) - if (S_ISLNK (st.st_mode)) - { - enum retry_type doretry; - char retryname[1024]; - file_t file; - char *rbuf = buf; + if (err) + goto out; + if (!S_ISLNK (st.st_mode)) + { + err = EINVAL; + goto out; + } - err = __dir_lookup (file_stat, "", O_READ | O_NOLINK, 0, &doretry, retryname, &file); - if (! err && (doretry != FS_RETRY_NORMAL || retryname[0] != '\0')) - err = EGRATUITOUS; - if (! err) - { - err = __io_read (file, &rbuf, &len, 0, len); - if (!err && rbuf != buf) - { - memcpy (buf, rbuf, len); - __vm_deallocate (__mach_task_self (), (vm_address_t)rbuf, len); - } + err = __dir_lookup (file_stat, "", O_READ | O_NOLINK, + 0, &doretry, retryname, &file); + if (err) + goto out; + if (doretry != FS_RETRY_NORMAL || retryname[0] != '\0') + { + err = EGRATUITOUS; + goto out; + } + + err = __io_read (file, &rbuf, &len, 0, len); + __mach_port_deallocate (__mach_task_self (), file); + if (err) + goto out; + + if (rbuf != buf) + { + memcpy (buf, rbuf, len); + __vm_deallocate (__mach_task_self (), (vm_address_t) rbuf, len); + } - __mach_port_deallocate (__mach_task_self (), file); - } - } - else - err = EINVAL; + out: __mach_port_deallocate (__mach_task_self (), file_stat); return err ? __hurd_fail (err) : len; From patchwork Sun Feb 12 11:10:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 64779 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 87ABA383FB9B for ; Sun, 12 Feb 2023 11:12:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 87ABA383FB9B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676200346; bh=/+M7YEqr3plk5x5xwoyPA6m+Vblc9lSy3U6rHz9HeKI=; 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=SN9/MDRp9o2RsYETEOVSBGaPCIgAIT7xpwPMPjgoEE2VpctQ4YdoluTVIyHYshDnC OVaaHjxkvnHH1oV4C0teNs6Z5E7Xyy5GWnBGTgYvZHrRT/w7QWrkVQIWarmUePX6YC 7oAcq6EDmlAJKKBv3EosctKJwjcfDJlf8aHx+Nsw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by sourceware.org (Postfix) with ESMTPS id BB30F3858D37 for ; Sun, 12 Feb 2023 11:11:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BB30F3858D37 Received: by mail-ed1-x52f.google.com with SMTP id cq19so6682937edb.5 for ; Sun, 12 Feb 2023 03:11:15 -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=/+M7YEqr3plk5x5xwoyPA6m+Vblc9lSy3U6rHz9HeKI=; b=cI9ZLHE2i3pCCfFLddz51F4wLBvb9YeXWROffimqXjGD+7k0M0oX4ZwsebupicBLGL TksUw6bU0By7AVRuQb76Wm/V5DvWcdPw/HjU+XeMEKfVfWTmENqDxM07bd25iqk5VkCv zT/nGz5H4KcBfplXuARCPI0Z41u/W91crCOV4k0pbcKjk47VfIs2DcSIbjonZ+Q2V+s8 IQsoEaSx7EVgaAfREFPypyqLtCCMfH24AhxXHnmYpZBi2dc5mtI04Mz3eB4jhfJng296 8atkdaaVPPIlkCc3P9aK2rT3O0U+wTvvLC3tpbo0RjFgVVy2yVbNO3J2/jdZaG5ALtVD zzSQ== X-Gm-Message-State: AO0yUKXTBEPCQNeQRFpDyIMk8JN1fIU+04JRU/zo3Wip52B5z4ACgytw nK12YcfAkLJGHjVvAmzu3NQ= X-Google-Smtp-Source: AK7set9eH2ZEiVvTNQfYNaSx46yHDxNc4yk4Dc/ZF7vPcI9mvXPGsn0EmpLfRI1dwVRHplnQBNVXGw== X-Received: by 2002:a50:aac5:0:b0:4aa:cc26:c3f with SMTP id r5-20020a50aac5000000b004aacc260c3fmr24349842edc.29.1676200274538; Sun, 12 Feb 2023 03:11:14 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:2186:c463:9ced:e6fe]) by smtp.gmail.com with ESMTPSA id c61-20020a509fc3000000b004acbe0b36d2sm1266910edf.6.2023.02.12.03.11.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Feb 2023 03:11:14 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?utf-8?q?Fl=C3=A1vio_Cruz?= , Sergey Bugaev Subject: [RFC PATCH glibc 2/12] hurd: Use mach_msg_type_number_t where appropriate Date: Sun, 12 Feb 2023 14:10:33 +0300 Message-Id: <20230212111044.610942-3-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230212111044.610942-1-bugaevc@gmail.com> References: <20230212111044.610942-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, 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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" It has been decided that on x86_64, mach_msg_type_number_t stays 32-bit. Therefore, it's not possible to use mach_msg_type_number_t interchangeably with size_t, in particular this breaks when a pointer to a variable is passed to a MIG routine. Signed-off-by: Sergey Bugaev --- hurd/hurdioctl.c | 2 +- hurd/hurdprio.c | 2 +- hurd/lookup-retry.c | 2 +- hurd/xattr.c | 4 ++-- sysdeps/mach/hurd/getcwd.c | 2 +- sysdeps/mach/hurd/readlinkat.c | 6 ++++-- sysdeps/mach/hurd/sendfile64.c | 2 +- 7 files changed, 11 insertions(+), 9 deletions(-) diff --git a/hurd/hurdioctl.c b/hurd/hurdioctl.c index e9a6a7ea..59e6a5c1 100644 --- a/hurd/hurdioctl.c +++ b/hurd/hurdioctl.c @@ -311,7 +311,7 @@ static int siocgifconf (int fd, int request, struct ifconf *ifc) { error_t err; - size_t data_len = ifc->ifc_len; + mach_msg_type_number_t data_len = ifc->ifc_len; char *data = ifc->ifc_buf; if (data_len <= 0) diff --git a/hurd/hurdprio.c b/hurd/hurdprio.c index dbeb272b..954d3987 100644 --- a/hurd/hurdprio.c +++ b/hurd/hurdprio.c @@ -58,7 +58,7 @@ _hurd_priority_which_map (enum __priority_which which, int who, int *oldpi = pi; mach_msg_type_number_t oldpisize = pisize; char *tw = 0; - size_t twsz = 0; + mach_msg_type_number_t twsz = 0; err = __USEPORT (PROC, __proc_getprocinfo (port, pids[i], &pi_flags, &pi, &pisize, diff --git a/hurd/lookup-retry.c b/hurd/lookup-retry.c index 0d344026..8850c4fd 100644 --- a/hurd/lookup-retry.c +++ b/hurd/lookup-retry.c @@ -162,7 +162,7 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port) { char buf[1024]; char *trans = buf; - size_t translen = sizeof buf; + mach_msg_type_number_t translen = sizeof buf; err = __file_get_translator (*result, &trans, &translen); if (!err diff --git a/hurd/xattr.c b/hurd/xattr.c index f98e548c..48914bcf 100644 --- a/hurd/xattr.c +++ b/hurd/xattr.c @@ -60,7 +60,7 @@ _hurd_xattr_get (io_t port, const char *name, void *value, size_t *size) if (!strcmp (name, "translator")) { char *buf = value; - size_t bufsz = value ? *size : 0; + mach_msg_type_number_t bufsz = value ? *size : 0; error_t err = __file_get_translator (port, &buf, &bufsz); if (err) return err; @@ -144,7 +144,7 @@ _hurd_xattr_set (io_t port, const char *name, const void *value, size_t size, { /* Must make sure it's already there. */ char *buf = NULL; - size_t bufsz = 0; + mach_msg_type_number_t bufsz = 0; error_t err = __file_get_translator (port, &buf, &bufsz); if (err) return err; diff --git a/sysdeps/mach/hurd/getcwd.c b/sysdeps/mach/hurd/getcwd.c index fc5e78e7..f24b35b3 100644 --- a/sysdeps/mach/hurd/getcwd.c +++ b/sysdeps/mach/hurd/getcwd.c @@ -117,7 +117,7 @@ __hurd_canonicalize_directory_name_internal (file_t thisdir, int mount_point; file_t newp; char *dirdata; - size_t dirdatasize; + mach_msg_type_number_t dirdatasize; int direntry, nentries; diff --git a/sysdeps/mach/hurd/readlinkat.c b/sysdeps/mach/hurd/readlinkat.c index dabdbb37..5bb8b753 100644 --- a/sysdeps/mach/hurd/readlinkat.c +++ b/sysdeps/mach/hurd/readlinkat.c @@ -35,6 +35,7 @@ __readlinkat (int fd, const char *file_name, char *buf, size_t len) char retryname[1024]; file_t file; char *rbuf = buf; + mach_msg_type_number_t nread = len; file_stat = __file_name_lookup_at (fd, 0, file_name, O_NOLINK, 0); if (file_stat == MACH_PORT_NULL) @@ -59,15 +60,16 @@ __readlinkat (int fd, const char *file_name, char *buf, size_t len) goto out; } - err = __io_read (file, &rbuf, &len, 0, len); + err = __io_read (file, &rbuf, &nread, 0, len); __mach_port_deallocate (__mach_task_self (), file); if (err) goto out; + len = nread; if (rbuf != buf) { memcpy (buf, rbuf, len); - __vm_deallocate (__mach_task_self (), (vm_address_t) rbuf, len); + __vm_deallocate (__mach_task_self (), (vm_address_t) rbuf, nread); } diff --git a/sysdeps/mach/hurd/sendfile64.c b/sysdeps/mach/hurd/sendfile64.c index 658b0282..e36b9790 100644 --- a/sysdeps/mach/hurd/sendfile64.c +++ b/sysdeps/mach/hurd/sendfile64.c @@ -35,7 +35,7 @@ __sendfile64 (int out_fd, int in_fd, off64_t *offset, size_t count) which might blow if it's huge or address space is real tight. */ char *data = 0; - size_t datalen = 0; + mach_msg_type_number_t datalen = 0; error_t err = HURD_DPORT_USE (in_fd, __io_read (port, &data, &datalen, offset ? *offset : (off_t) -1, From patchwork Sun Feb 12 11:10:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 64776 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 4E96B385B51E for ; Sun, 12 Feb 2023 11:11:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E96B385B51E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676200311; bh=ExvITH9csy6j84WPPsWCYjVch19Ibcxg7RVGXyO3gV0=; 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=i3pKHn0bHHMTox/YMehizJfaSl6Wzv/VPno+YImD2Skx7DJuzD3Nopso3DfKh4ve1 WFTBW9uDx6yIJko0rTQHVKe+sBsFRbDTuvnl8rh6nM5Aza28/fIe4hvQynJ79GaihC QWozk3eQfXKok/+pWXVwWiuD2Deb3+K6k44zMiQI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by sourceware.org (Postfix) with ESMTPS id 1B63B3858C52 for ; Sun, 12 Feb 2023 11:11:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1B63B3858C52 Received: by mail-ed1-x52b.google.com with SMTP id w3so2426749edc.2 for ; Sun, 12 Feb 2023 03:11:16 -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=ExvITH9csy6j84WPPsWCYjVch19Ibcxg7RVGXyO3gV0=; b=3zKTQw/bshE8uBpBjEZSGmzOnymuLvd6inXm43GV0sWSoz8P9u/t9U7G0V2zSLYznL cFJKEpVJNlCOnrbRYn+w6UH7B6uk0QHuwjx+5nAj9VdOWrErjOE9j+DvE1d5xdzMF1P9 3+zF8UCh0/VdzRX+QhHXjALy+5zaEOv0gBMtTc4GIjgp14cRvyGeNB6pWFF+0vIGeP62 hnBOqoSxGx4DrQ+xEq9RX6VQqEUzCq6XewauSpiLgulMi9NMTYfTtvUs0e5G8ta9OhJ4 DN4RLKcgckUUJqHAnagLsDS7AuyMLg5wfS3pW8AEsxq6UXR45qi7Ls1ZGJdqI0SA1qlm /sKw== X-Gm-Message-State: AO0yUKWflKqd9c5dEK66CxH9ZZNBrenJ087utIPEMhp7LDAmepre/AP7 bH00q4RMNmnzR/kVoSI/2/M= X-Google-Smtp-Source: AK7set82kaPv5Adcp4zJn5rgT9SGy/hm5PvEZhduHQwBgD22Ia98O8VgEjgMiWr/jXxOJo+CERRmPA== X-Received: by 2002:a50:d79e:0:b0:4ab:499e:ae54 with SMTP id w30-20020a50d79e000000b004ab499eae54mr8258751edi.19.1676200275679; Sun, 12 Feb 2023 03:11:15 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:2186:c463:9ced:e6fe]) by smtp.gmail.com with ESMTPSA id c61-20020a509fc3000000b004acbe0b36d2sm1266910edf.6.2023.02.12.03.11.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Feb 2023 03:11:15 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?utf-8?q?Fl=C3=A1vio_Cruz?= , Sergey Bugaev Subject: [RFC PATCH glibc 3/12] mach, hurd: Cast through uintptr_t Date: Sun, 12 Feb 2023 14:10:34 +0300 Message-Id: <20230212111044.610942-4-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230212111044.610942-1-bugaevc@gmail.com> References: <20230212111044.610942-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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" When casting between a pointer and an integer of a different size, GCC emits a warning (which is escalated to a build failure by -Werror). Indeed, if what you start with is a pointer, which you then cast to a shorter integer and then back again, you're going to cut off some bits of the pointer. But if you start with an integer (such as mach_port_t), then cast it to a longer pointer (void *), and then back to a shorter integer, you are fine. To keep GCC happy, cast through an intermediary uintptr_t, which is always the same size as a pointer. Signed-off-by: Sergey Bugaev --- htl/cthreads-compat.c | 5 +++-- hurd/fopenport.c | 15 ++++++++++----- hurd/hurd/port.h | 2 +- hurd/port-cleanup.c | 3 ++- hurd/vpprintf.c | 6 ++++-- mach/devstream.c | 9 +++++---- 6 files changed, 25 insertions(+), 15 deletions(-) diff --git a/htl/cthreads-compat.c b/htl/cthreads-compat.c index 55043a8b..2a0a95b6 100644 --- a/htl/cthreads-compat.c +++ b/htl/cthreads-compat.c @@ -25,8 +25,9 @@ void __cthread_detach (__cthread_t thread) { int err; + pthread_t pthread = (pthread_t) (uintptr_t) thread; - err = __pthread_detach ((pthread_t) thread); + err = __pthread_detach (pthread); assert_perror (err); } weak_alias (__cthread_detach, cthread_detach) @@ -40,7 +41,7 @@ __cthread_fork (__cthread_fn_t func, void *arg) err = __pthread_create (&thread, NULL, func, arg); assert_perror (err); - return (__cthread_t) thread; + return (__cthread_t) (uintptr_t) thread; } weak_alias (__cthread_fork, cthread_fork) diff --git a/hurd/fopenport.c b/hurd/fopenport.c index 60afb445..be6aa30c 100644 --- a/hurd/fopenport.c +++ b/hurd/fopenport.c @@ -28,9 +28,10 @@ readio (void *cookie, char *buf, size_t n) mach_msg_type_number_t nread; error_t err; char *bufp = buf; + io_t io = (io_t) (uintptr_t) cookie; nread = n; - if (err = __io_read ((io_t) cookie, &bufp, &nread, -1, n)) + if (err = __io_read (io, &bufp, &nread, -1, n)) return __hurd_fail (err); if (bufp != buf) @@ -50,8 +51,9 @@ writeio (void *cookie, const char *buf, size_t n) { vm_size_t wrote; error_t err; + io_t io = (io_t) (uintptr_t) cookie; - if (err = __io_write ((io_t) cookie, buf, n, -1, &wrote)) + if (err = __io_write (io, buf, n, -1, &wrote)) return __hurd_fail (err); return wrote; @@ -65,7 +67,8 @@ seekio (void *cookie, off64_t *pos, int whence) { - error_t err = __io_seek ((file_t) cookie, *pos, whence, pos); + io_t io = (io_t) (uintptr_t) cookie; + error_t err = __io_seek (io, *pos, whence, pos); return err ? __hurd_fail (err) : 0; } @@ -74,8 +77,9 @@ seekio (void *cookie, static int closeio (void *cookie) { + io_t io = (io_t) (uintptr_t) cookie; error_t error = __mach_port_deallocate (__mach_task_self (), - (mach_port_t) cookie); + io); if (error) return __hurd_fail (error); return 0; @@ -127,6 +131,7 @@ __fopenport (mach_port_t port, const char *mode) return NULL; } - return fopencookie ((void *) port, mode, funcsio); + return fopencookie ((void *) (uintptr_t) port, + mode, funcsio); } weak_alias (__fopenport, fopenport) diff --git a/hurd/hurd/port.h b/hurd/hurd/port.h index fdba8db5..1e473978 100644 --- a/hurd/hurd/port.h +++ b/hurd/hurd/port.h @@ -96,7 +96,7 @@ _hurd_port_locked_get (struct hurd_port *port, if (result != MACH_PORT_NULL) { link->cleanup = &_hurd_port_cleanup; - link->cleanup_data = (void *) result; + link->cleanup_data = (void *) (uintptr_t) result; _hurd_userlink_link (&port->users, link); } __spin_unlock (&port->lock); diff --git a/hurd/port-cleanup.c b/hurd/port-cleanup.c index 08ab3d47..ad43b830 100644 --- a/hurd/port-cleanup.c +++ b/hurd/port-cleanup.c @@ -26,7 +26,8 @@ void _hurd_port_cleanup (void *cleanup_data, jmp_buf env, int val) { - __mach_port_deallocate (__mach_task_self (), (mach_port_t) cleanup_data); + mach_port_t port = (mach_port_t) (uintptr_t) cleanup_data; + __mach_port_deallocate (__mach_task_self (), port); } /* We were cancelled while using a port, and called from the cleanup unwinding. diff --git a/hurd/vpprintf.c b/hurd/vpprintf.c index fe734946..010f04ca 100644 --- a/hurd/vpprintf.c +++ b/hurd/vpprintf.c @@ -25,8 +25,9 @@ static ssize_t do_write (void *cookie, const char *buf, size_t n) { + io_t io = (io_t) (uintptr_t) cookie; vm_size_t amount = n; - error_t error = __io_write ((io_t) cookie, buf, n, -1, &amount); + error_t error = __io_write (io, buf, n, -1, &amount); if (error) return __hurd_fail (error); return n; @@ -51,7 +52,8 @@ vpprintf (io_t port, const char *format, va_list arg) #endif _IO_cookie_init (&temp_f.cfile, _IO_NO_READS, - (void *) port, (cookie_io_functions_t) { write: do_write }); + (void *) (uintptr_t) port, + (cookie_io_functions_t) { write: do_write }); done = __vfprintf_internal (&temp_f.cfile.__fp.file, format, arg, 0); diff --git a/mach/devstream.c b/mach/devstream.c index 09272d10..cfa9a4f4 100644 --- a/mach/devstream.c +++ b/mach/devstream.c @@ -28,7 +28,7 @@ static ssize_t devstream_write (void *cookie, const char *buffer, size_t n) { - const device_t dev = (device_t) cookie; + const device_t dev = (device_t) (uintptr_t) cookie; int write_some (const char *p, size_t to_write) { @@ -83,7 +83,7 @@ devstream_write (void *cookie, const char *buffer, size_t n) static ssize_t devstream_read (void *cookie, char *buffer, size_t to_read) { - const device_t dev = (device_t) cookie; + const device_t dev = (device_t) (uintptr_t) cookie; kern_return_t err; mach_msg_type_number_t nread = to_read; @@ -112,7 +112,8 @@ devstream_read (void *cookie, char *buffer, size_t to_read) static int dealloc_ref (void *cookie) { - if (__mach_port_deallocate (mach_task_self (), (mach_port_t) cookie)) + const device_t dev = (device_t) (uintptr_t) cookie; + if (__mach_port_deallocate (mach_task_self (), dev)) { errno = EINVAL; return -1; @@ -131,7 +132,7 @@ mach_open_devstream (mach_port_t dev, const char *mode) return NULL; } - stream = _IO_fopencookie ((void *) dev, mode, + stream = _IO_fopencookie ((void *) (uintptr_t) dev, mode, (cookie_io_functions_t) { write: devstream_write, read: devstream_read, close: dealloc_ref }); From patchwork Sun Feb 12 11:10:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 64780 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 579ED38654A3 for ; Sun, 12 Feb 2023 11:12:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 579ED38654A3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676200361; bh=H/ZBpbn7xwlXkd2NGAJAqZdzWG/T+RELX+zXAFKUFB8=; 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=a5bw3kOZphg5AuEb2KGSn2cxoTBuJ1DNxwC/J9efGBjGtmy1//fKjN2JPOBDE956J L4R3OCtBsRVp67VfjUsqYrXOdV57edP6bO3VnLiTrzdqPsvEnY/chBG+4F//t8+/Vf YaLq7D5Es7e2oWaagUxRPb3CgrREbwXIO1FmsG1o= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id 2A50038582BC for ; Sun, 12 Feb 2023 11:11:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2A50038582BC Received: by mail-ed1-x532.google.com with SMTP id u21so9450861edv.3 for ; Sun, 12 Feb 2023 03:11:18 -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=H/ZBpbn7xwlXkd2NGAJAqZdzWG/T+RELX+zXAFKUFB8=; b=dggsG+5nIwwr4yMkOONkppherhC1UMShZQUgoV6SvHXeY/xSzJmk+tPBTRHSo5wgob yzGT+pVELDcsENqDwULZUIJYLGLxxg4T59YS1mG+LI4LGKeLq9kme9DgSaZPByJ3uyZ9 8zDkJ5kKSI/NxyHn0fHr/7gV6ZhRAFuPJ9d8dnHamU973IG/CY514siGjbOTo4UTulpi TQFlVu17Grxba6yoYiKKW9/GFX56V7XRz5TANtTUlbt+vhUF1Qzw3svSDbknaUczBDCg tzFMm2t/Fg3RdxsVKdn/kzp6Qr45kUn5bjKpP2+PZd8SCDcOvVcudM46cVBd+dTBP87f T9hg== X-Gm-Message-State: AO0yUKXt1+CEBM1b3UOMOYAp5HzoTP3DRqxGO2PAqmZ6sICWJvY08DyP v48Uykprzph/71ePy/+3uQVKkmnYEcyRFQ== X-Google-Smtp-Source: AK7set/bJBdzeagYZ8Y0hP1OOqTxEpS1RJxovQDR6wTs7XEQ6ndQhNYncX8w5T2W+gVte0BlCPGrKQ== X-Received: by 2002:a50:cc9d:0:b0:4ab:2504:c7ff with SMTP id q29-20020a50cc9d000000b004ab2504c7ffmr11486264edi.23.1676200276908; Sun, 12 Feb 2023 03:11:16 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:2186:c463:9ced:e6fe]) by smtp.gmail.com with ESMTPSA id c61-20020a509fc3000000b004acbe0b36d2sm1266910edf.6.2023.02.12.03.11.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Feb 2023 03:11:16 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?utf-8?q?Fl=C3=A1vio_Cruz?= , Sergey Bugaev Subject: [RFC PATCH glibc 4/12] hurd: Fix xattr error value Date: Sun, 12 Feb 2023 14:10:35 +0300 Message-Id: <20230212111044.610942-5-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230212111044.610942-1-bugaevc@gmail.com> References: <20230212111044.610942-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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" This does not seem like it is supposed to return negative error codes. Signed-off-by: Sergey Bugaev --- hurd/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hurd/xattr.c b/hurd/xattr.c index 48914bcf..5a0fc263 100644 --- a/hurd/xattr.c +++ b/hurd/xattr.c @@ -68,7 +68,7 @@ _hurd_xattr_get (io_t port, const char *name, void *value, size_t *size) { if (buf != value) __munmap (buf, bufsz); - return -ERANGE; + return ERANGE; } if (buf != value && bufsz > 0) { From patchwork Sun Feb 12 11:10:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 64783 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 D9DEE3885C2C for ; Sun, 12 Feb 2023 11:13:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D9DEE3885C2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676200403; bh=Gb8UeyCxfAvsMmYbV2q1je0dtXtgo8KztQwbHMHfMZE=; 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=mqiOarwHwmaIVxXILE+JlbvgEVQZU9/f7tWzp/qo9FajMOW7gsv10+QRgjz1C5NOx A1S34REQn2An6pfbf1UBY/Tmqt5Bac9DfgKzWBguMAUzZ9zAZZG7wgsNFQ3b8X9ZcV i3pAWWET4b1k+uph26/9eK24ADI6+0Udc2FHUEs8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by sourceware.org (Postfix) with ESMTPS id 63EB63858C27 for ; Sun, 12 Feb 2023 11:11:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 63EB63858C27 Received: by mail-ed1-x52f.google.com with SMTP id cq19so6683052edb.5 for ; Sun, 12 Feb 2023 03:11:18 -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=Gb8UeyCxfAvsMmYbV2q1je0dtXtgo8KztQwbHMHfMZE=; b=MQlu6W7SBsLS1x6osdgRMMMv9pGvO4cXB/Gt9iOizvHCFYaAq+hZDtHqzVjutb3Uvy 9esY3k7ic5OJko8v0gQ320Ao4gYHnQmoirWLUtqrbDZ2xZPwLaMwnf//tAlMSuH0g7oL KP8UFASd/T6gRLx4WtjxlFkLnvDEAFJCIUeMq9BswwEA9bGtN/ZD89nSsigF6M+TbSPK aUuZyujPm2c8phhMq1zTWhGgWKdC2uF3jRjzZYLTrBaafuGDmCr9Dwi385L9UXq+AnLk zkv8myT9alwm/oP9rKPllMaOiBvZE09V+43ii0qWnMGy03e9wRHAQRrcCxDaYkf/zuW3 tq0A== X-Gm-Message-State: AO0yUKXTaF1jRQkQhW8PTCjri14U5XI8F22iCc7CxP0b1ofrb/yobLzT 0uR8oljdFfQ129EYsjItxw/igNv59kNb4A== X-Google-Smtp-Source: AK7set/fW+m4oWvvqtRjujDA7PiUw/Cjaz373AL5lzsC6oHsiM3gyhZgirHerGM9yBA620uEf/1daA== X-Received: by 2002:a50:d547:0:b0:4ab:15d9:2dae with SMTP id f7-20020a50d547000000b004ab15d92daemr15723852edj.14.1676200277996; Sun, 12 Feb 2023 03:11:17 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:2186:c463:9ced:e6fe]) by smtp.gmail.com with ESMTPSA id c61-20020a509fc3000000b004acbe0b36d2sm1266910edf.6.2023.02.12.03.11.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Feb 2023 03:11:17 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?utf-8?q?Fl=C3=A1vio_Cruz?= , Sergey Bugaev Subject: [RFC PATCH glibc 5/12] htl: Fix semaphore reference Date: Sun, 12 Feb 2023 14:10:36 +0300 Message-Id: <20230212111044.610942-6-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230212111044.610942-1-bugaevc@gmail.com> References: <20230212111044.610942-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 'sem' is the opaque 'sem_t', 'isem' is the actual 'struct new_sem'. Signed-off-by: Sergey Bugaev --- sysdeps/htl/sem-timedwait.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sysdeps/htl/sem-timedwait.c b/sysdeps/htl/sem-timedwait.c index 8f2df6e7..9974e9ae 100644 --- a/sysdeps/htl/sem-timedwait.c +++ b/sysdeps/htl/sem-timedwait.c @@ -60,7 +60,7 @@ __sem_timedwait_internal (sem_t *restrict sem, int cancel_oldtype = LIBC_CANCEL_ASYNC(); #if __HAVE_64B_ATOMICS - uint64_t d = atomic_fetch_add_relaxed (&sem->data, + uint64_t d = atomic_fetch_add_relaxed (&isem->data, (uint64_t) 1 << SEM_NWAITERS_SHIFT); pthread_cleanup_push (__sem_wait_cleanup, isem); @@ -72,11 +72,11 @@ __sem_timedwait_internal (sem_t *restrict sem, /* No token, sleep. */ if (timeout) err = __lll_abstimed_wait_intr ( - ((unsigned int *) &sem->data) + SEM_VALUE_OFFSET, + ((unsigned int *) &isem->data) + SEM_VALUE_OFFSET, 0, timeout, flags, clock_id); else err = __lll_wait_intr ( - ((unsigned int *) &sem->data) + SEM_VALUE_OFFSET, + ((unsigned int *) &isem->data) + SEM_VALUE_OFFSET, 0, flags); if (err != 0 && err != KERN_INVALID_ARGUMENT) @@ -92,12 +92,12 @@ __sem_timedwait_internal (sem_t *restrict sem, } /* Token changed */ - d = atomic_load_relaxed (&sem->data); + d = atomic_load_relaxed (&isem->data); } else { /* Try to acquire and dequeue. */ - if (atomic_compare_exchange_weak_acquire (&sem->data, + if (atomic_compare_exchange_weak_acquire (&isem->data, &d, d - 1 - ((uint64_t) 1 << SEM_NWAITERS_SHIFT))) { /* Success */ From patchwork Sun Feb 12 11:10:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 64782 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 204AC3858428 for ; Sun, 12 Feb 2023 11:13:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 204AC3858428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676200390; bh=viRxtOIjrzVj5JGUgZwQmGe0DRmUT9GU1Kszuij/hi0=; 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=rZYSC/aiy3REHYi+mPplJu2yxQ5acsfsgSty64DlhDHGM2mkzNNJU/y7MUaqid5Mg h4UvCna3VPzjpY7WsViMxXckisj61APhD2jf+1dWM7m25z8wgpGzb0FWGGsc9iuPi/ 6mUrjZZYe2Pdyp75ESyq2kBYrjSmWrYEGiru+Q5M= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by sourceware.org (Postfix) with ESMTPS id 677F83857438 for ; Sun, 12 Feb 2023 11:11:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 677F83857438 Received: by mail-ed1-x52d.google.com with SMTP id bt8so3612164edb.12 for ; Sun, 12 Feb 2023 03:11:20 -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=viRxtOIjrzVj5JGUgZwQmGe0DRmUT9GU1Kszuij/hi0=; b=oeLk4Yf0zCkudL2Kq6nhFYXDZot0MfEYLpPyXmABADCoFzJfSdeHgZBl6fBq7B7WO5 +uOI6YXCHdXqth6JJ7hWzOI77Mm2+QhlWo5j6ztlJZmKE9jvJM7/Wry+++sM/ppGZZ/r Cv4bNcHnoslYnD+8MXh0UWPnMKegZSjIsQ1yK2tXyX2f8C0VcnzR2LOB/K64eluPI+4n ZOkZDBW/uUQaT8sINleluX8IjEkCcJSopzJ63cmxKAkymwbsOfRS1qn/H5bf9KlFaefC MCTXVeRxIsixqelvRUmrT6AsALkUV2j+6BVbV3h7JFbW4wEXL76IaU+C2xNMNn4El/mj G0Pw== X-Gm-Message-State: AO0yUKUubIWusrq+TsNGceAcnPFdP8Mm7+LweMlESJ2yL5E9N32XNCne FOCwa/Y9KZ1h8/ct/Kv6lW4= X-Google-Smtp-Source: AK7set+t5QvLzqNYR+bCvVyzpuBgnYFRp8xVGrpzyMdi8UBD9tDOo18yiwVTiWob5y7PKnubI+5HZw== X-Received: by 2002:a50:baea:0:b0:4ab:16a8:bc60 with SMTP id x97-20020a50baea000000b004ab16a8bc60mr14650525ede.25.1676200279082; Sun, 12 Feb 2023 03:11:19 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:2186:c463:9ced:e6fe]) by smtp.gmail.com with ESMTPSA id c61-20020a509fc3000000b004acbe0b36d2sm1266910edf.6.2023.02.12.03.11.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Feb 2023 03:11:18 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?utf-8?q?Fl=C3=A1vio_Cruz?= , Sergey Bugaev Subject: [RFC PATCH hurd 6/12] hurd: Fix modes_t and speeds_t types on 64-bit Date: Sun, 12 Feb 2023 14:10:37 +0300 Message-Id: <20230212111044.610942-7-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230212111044.610942-1-bugaevc@gmail.com> References: <20230212111044.610942-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" --- hurd/tioctl.defs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) Signed-off-by: Sergey Bugaev diff --git a/hurd/tioctl.defs b/hurd/tioctl.defs index 905a4a38..a04f5ae4 100644 --- a/hurd/tioctl.defs +++ b/hurd/tioctl.defs @@ -34,9 +34,9 @@ import ; /* XXX */ /* These are the pieces of a struct termios as specified by the definition of _IOT_termios in . */ -type modes_t = array[4] of int; +type modes_t = array[4] of long; type ccs_t = array[20] of char; -type speeds_t = array[2] of int; +type speeds_t = array[2] of long; /* This is the arg for a struct winsize as specified by the definition of _IOT_winsize in . */ From patchwork Sun Feb 12 11:10:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 64777 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 0DCC3383FBA9 for ; Sun, 12 Feb 2023 11:12:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0DCC3383FBA9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676200327; bh=dSSYXh14yYiTbCQ8RbdmYyIT1VRWj4s8kvUy0Oe1lyo=; 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=QDhkacNm4zysjfPjVz0NdybR3eHvqqrcPgpkm/13pnOl64JjKiHrpkSbl5Ea3NH9X TeuYByQjpg8PNjRW5wLp/X3aaNrkt+vnmVylmLkDKRF/KBJe0dRIPxdMlg+yE3oYDJ nIKvCwQftURI6PedHRcqrDQA3F7b9JurDbTd2fZw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by sourceware.org (Postfix) with ESMTPS id 86CA03857C45 for ; Sun, 12 Feb 2023 11:11:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 86CA03857C45 Received: by mail-ed1-x52f.google.com with SMTP id cq19so6683127edb.5 for ; Sun, 12 Feb 2023 03:11:20 -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=dSSYXh14yYiTbCQ8RbdmYyIT1VRWj4s8kvUy0Oe1lyo=; b=dHxV+nTmkBc2matfg2pMfcXkbWWUX26CZEoLzQYhiDXsX/KJOX2MnufmCElEDn8+n4 Tz32kZn11wfjxshzflUlRKmkBLlCKZJnCgaWTsGuGFXLxB+UKt58vYfcOsBLqFSDR0xx qhQnxsfMCve+v9r6QFNGk2o162hfNEKfNOWzbZoybVe4pqgMgn/a/qisW0FYeDa8zpI5 bWGu6PlM5Q7Q0hjPLHPKawWsNYVv1BbBD6PyiNmJysE97U9uk/kHbZMEzduXqnOj4rBO i8VA4vNCOy/G3OxGbuMB+92lNUgyUhjImtsNUj1cU7YadMbBUF9+arQP8ZYwRswPWfvT NalQ== X-Gm-Message-State: AO0yUKXXxOPAtgaslvxlt6r5vOXsoekas0cvBCtqXdaDT1VROw0fmEwC EdjgnQRAygUhqXOU+7fm4QU= X-Google-Smtp-Source: AK7set93AzcQEz2TJZEEiy22xcc1QpYghDSkinrAIbvmxqN635UkHuUTL8pF8OsYCOW+8pdiMF+evg== X-Received: by 2002:a50:950e:0:b0:4a2:3637:5be2 with SMTP id u14-20020a50950e000000b004a236375be2mr22672801eda.39.1676200280139; Sun, 12 Feb 2023 03:11:20 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:2186:c463:9ced:e6fe]) by smtp.gmail.com with ESMTPSA id c61-20020a509fc3000000b004acbe0b36d2sm1266910edf.6.2023.02.12.03.11.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Feb 2023 03:11:19 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?utf-8?q?Fl=C3=A1vio_Cruz?= , Sergey Bugaev Subject: [RFC PATCH mig 7/12] Drop -undef -ansi from cpp flags Date: Sun, 12 Feb 2023 14:10:38 +0300 Message-Id: <20230212111044.610942-8-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230212111044.610942-1-bugaevc@gmail.com> References: <20230212111044.610942-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Since GNU Mach commit d30481122a5d24ad6b921062f93b9172ef922fc3, i386/machine_types.defs defines types based on defined(__x86_64__). Supressing the built-in macro definitions will now result in the wrong type being silently selected. -undef was initially introduced in commit 78b6a7665db7b2eae367e17102821cbdca231d19 without much of an explanation. -ansi was introduced in commit 6940fb91859e46b2e96a331a029f2dc2a0ee51c9 "to avoid -Di386=1 and the like". Since glibc has been using MIG with CPP set to a custom GCC invocation which did *not* use either flag, it appears that everything works well enough even without them. On the other hand, not having __x86_64__ defined most definetely causes issues for anything that does not set a custom CPP when invoking MIG (i.e., most users). Other built-in definitions could be used in the future in a similar way (e.g. on other architectures); it's really more of a coincidence that they have not been used until now, and things kept working with -undef. --- mig.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mig.in b/mig.in index 63e0269..94fd500 100644 --- a/mig.in +++ b/mig.in @@ -38,7 +38,7 @@ migcom=${MIGDIR-$libexecdir}/${MIGCOM-@MIGCOM@} # The expansion of TARGET_CC might refer to ${CC}, so make sure it is defined. default_cc="@CC@" CC="${CC-${default_cc}}" -default_cpp="@TARGET_CC@ -E -x c -undef -ansi" +default_cpp="@TARGET_CC@ -E -x c" cpp="${CPP-${default_cpp}}" cppflags= From patchwork Sun Feb 12 11:10:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 64785 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 103503895FC7 for ; Sun, 12 Feb 2023 11:13:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 103503895FC7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676200433; bh=IGwtJsb1s4/DHhXvmuYmeFW8npbTdn3I1r4dOk3ONlU=; 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=OJS6fmIlV3G/xNlS184RAtb+ROZZBYSlx2M155L8TaQ4M5EZnygl6dHLeb3jMpR5Y VwsShzYPPjt5KL5wnShOg/hzQxDNdjJLo2nze9FnfTaQsRig6230L3Ol0nXztcueWe Cfnvpe9dq7Jd8GMYPL7o7JfSiAbAw0fh/r4MxM14= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id 7875A3858005 for ; Sun, 12 Feb 2023 11:11:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7875A3858005 Received: by mail-ed1-x532.google.com with SMTP id a10so9392521edu.9 for ; Sun, 12 Feb 2023 03:11:22 -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=IGwtJsb1s4/DHhXvmuYmeFW8npbTdn3I1r4dOk3ONlU=; b=H7vTGfzgJkesqfPzazsY+8E4f3bYfFQaEdBbDzrQIGd/2KfLXU3J+DjjSiOdL9ZwN6 4nyGZY8lT8XnPfe2uZ2OK4sUqWqoY/zMNqCb83z1pFs1lbdZxODhIPJ3FY2mriIWT0Kr khk2RB2ctIzSvMCQYr+1Qjb01T76oP+xK+iAw6TtOA57CQd7bN5ROovczuL/ZRWxw69h WF4BowDDUUQ+i2raWApidJ33ZZeFHYqM9NnXUXvn1nOW8rvADpwTw1uF56Zi9GW3wTbS GmGyG1zHUSYjMRUpwWOPGAnDkeT16w7KxzUI9KGPhDSheRb3BGqX2XI0V5POsqT//uhU 91rA== X-Gm-Message-State: AO0yUKWf8zd3l9s7wPtiubYxAnPXKqr5QJKEw7PZAGuBjZVJ9AmCWUFd OqXw7V30IbUl+vJViln4pjzsUUVKXBW2+Q== X-Google-Smtp-Source: AK7set91L1XfKHMWS+WCYyCuPgZNnRNLSc9x27ovj5Bgn0PcVNuYj10aLU7OwzngmYSEJt8WFtS3EA== X-Received: by 2002:a50:c05a:0:b0:49e:1f0e:e209 with SMTP id u26-20020a50c05a000000b0049e1f0ee209mr4096017edd.10.1676200281368; Sun, 12 Feb 2023 03:11:21 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:2186:c463:9ced:e6fe]) by smtp.gmail.com with ESMTPSA id c61-20020a509fc3000000b004acbe0b36d2sm1266910edf.6.2023.02.12.03.11.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Feb 2023 03:11:21 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?utf-8?q?Fl=C3=A1vio_Cruz?= , Sergey Bugaev Subject: [RFC PATCH mig 8/12] Set max type alignment to sizeof(long) Date: Sun, 12 Feb 2023 14:10:39 +0300 Message-Id: <20230212111044.610942-9-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230212111044.610942-1-bugaevc@gmail.com> References: <20230212111044.610942-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" ...not sizeof(int). This appears to be required on x86_64. PLEASE NOTE: There is now a patch from Flavio Cruz ("Make MIG work for pure 64 bit kernel and userland") that appears to tackle this same issue (and more). Most likely this simplistic patch should be dropped in favor of the one from Flavio. --- type.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/type.c b/type.c index b104c66..7765200 100644 --- a/type.c +++ b/type.c @@ -542,7 +542,7 @@ itLongDecl(u_int inname, const_string_t instr, u_int outname, it->itOutName = outname; it->itOutNameStr = outstr; it->itSize = size; - it->itAlignment = MIN(word_size, size / 8); + it->itAlignment = MIN(sizeof_long, size / 8); if (inname == MACH_MSG_TYPE_STRING_C) { it->itStruct = false; From patchwork Sun Feb 12 11:10:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 64786 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 248433881D2F for ; Sun, 12 Feb 2023 11:14:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 248433881D2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676200475; bh=usGMy3laSiZa2ZRDDACVVxwiU/H6G/Kf/W73xUU5Wyg=; 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=AhK3YZxS/6DTn+yhmvjUdqqRdGzMyTVO1AEUdOXPRb3uZsMpWD1Jdhy2/bIyueIdr B4ED5KH0kt/plOUsHbzVREaCoIgnv+uqEkqiXazimyQtw7RpxRq7/w7Flew0r/6YMx 8qcBVHhRdzllkiOJQxTYAApg8ocg8UT1Q2OMqYvE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id 8DEF43858428 for ; Sun, 12 Feb 2023 11:11:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8DEF43858428 Received: by mail-ed1-x532.google.com with SMTP id d40so8174967eda.8 for ; Sun, 12 Feb 2023 03:11:23 -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=usGMy3laSiZa2ZRDDACVVxwiU/H6G/Kf/W73xUU5Wyg=; b=5U7sowtlkDO7eqBuj2aOOVaQ/UZPKCz1p1kD9VvBQItzVV5K+/wXZIA85seOChpfO0 l31587EBUgkFUAe4d1fJ0TvYZc3cqNQ+l6TNp1zTYRrxOQ8BBBNdrvlFr5F1ciyX+vk1 StTMx4hRoM8LyYemwHGLPcm2iLitxmxJEsxLRaoueXiZd0RWOwQ/mesrqk2GR4tdU6nw mopB6jR5CxFSgd2NUs0LIqQe7RVGl6di6njUj2h+BCH7vhT5mOxHVJ9trijvEjGkkuiE 8QeaLViJ6Ul6+PB04iNZpXBmcLcuqA6Y136g/eSsMAwiKOyXwbn73j/p41n7U6eX7WIQ MApQ== X-Gm-Message-State: AO0yUKVV2NCUUmMEAtN4rUr2w5W/n9acMmphhdWrfVZeGbP8Z7F6ZvQm CYPnf91GKEg9K92BztxwFJ4= X-Google-Smtp-Source: AK7set8sIZ0zjc6lnxEZdXsFqwJr/C7gf1TuZZmzZ5XmCWNwJ+4hVqaFmfJHPxgvmoc6peBYNn/h2Q== X-Received: by 2002:a50:c345:0:b0:4ab:d0de:f7f0 with SMTP id q5-20020a50c345000000b004abd0def7f0mr6487381edb.5.1676200282406; Sun, 12 Feb 2023 03:11:22 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:2186:c463:9ced:e6fe]) by smtp.gmail.com with ESMTPSA id c61-20020a509fc3000000b004acbe0b36d2sm1266910edf.6.2023.02.12.03.11.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Feb 2023 03:11:22 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?utf-8?q?Fl=C3=A1vio_Cruz?= , Sergey Bugaev Subject: [RFC PATCH glibc 9/12] mach: Look for mach_i386.defs on x86_64 too Date: Sun, 12 Feb 2023 14:10:40 +0300 Message-Id: <20230212111044.610942-10-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230212111044.610942-1-bugaevc@gmail.com> References: <20230212111044.610942-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Signed-off-by: Sergey Bugaev --- mach/Makefile | 3 ++- sysdeps/mach/configure | 6 +++--- sysdeps/mach/configure.ac | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/mach/Makefile b/mach/Makefile index 39358fdb..f2fdd7da 100644 --- a/mach/Makefile +++ b/mach/Makefile @@ -64,7 +64,8 @@ CFLAGS-RPC_i386_set_ldt.o = $(no-stack-protector) CFLAGS-RPC_task_get_special_port.o = $(no-stack-protector) # Translate GNU names for CPUs into the names used in Mach header files. -mach-machine = $(patsubst powerpc,ppc,$(base-machine)) +mach-machine := $(patsubst powerpc,ppc,$(base-machine)) +mach-machine := $(patsubst x86_64,i386,$(mach-machine)) # Define mach-syscalls and sysno-*. ifndef inhibit_mach_syscalls diff --git a/sysdeps/mach/configure b/sysdeps/mach/configure index 3f0a9029..8c341d59 100644 --- a/sysdeps/mach/configure +++ b/sysdeps/mach/configure @@ -249,7 +249,7 @@ for ifc in mach mach4 gnumach \ clock clock_priv host_priv host_security ledger lock_set \ processor processor_set task task_notify thread_act vm_map \ memory_object memory_object_default default_pager \ - i386/mach_i386 \ + machine/mach_i386 \ ; do as_ac_Header=`$as_echo "ac_cv_header_mach/${ifc}.defs" | $as_tr_sh` ac_fn_c_check_header_preproc "$LINENO" "mach/${ifc}.defs" "$as_ac_Header" @@ -440,7 +440,7 @@ if ${libc_cv_mach_i386_ioports+:} false; then : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include +#include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | @@ -466,7 +466,7 @@ if ${libc_cv_mach_i386_gdt+:} false; then : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include +#include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | diff --git a/sysdeps/mach/configure.ac b/sysdeps/mach/configure.ac index a57cb259..579c0021 100644 --- a/sysdeps/mach/configure.ac +++ b/sysdeps/mach/configure.ac @@ -64,7 +64,7 @@ for ifc in mach mach4 gnumach \ clock clock_priv host_priv host_security ledger lock_set \ processor processor_set task task_notify thread_act vm_map \ memory_object memory_object_default default_pager \ - i386/mach_i386 \ + machine/mach_i386 \ ; do AC_CHECK_HEADER(mach/${ifc}.defs, [dnl mach_interface_list="$mach_interface_list $ifc"],, -) @@ -89,7 +89,7 @@ AC_CHECK_HEADER(machine/ndr_def.h, [dnl AC_CACHE_CHECK(for i386_io_perm_modify in mach_i386.defs, libc_cv_mach_i386_ioports, [dnl -AC_EGREP_HEADER(i386_io_perm_modify, mach/i386/mach_i386.defs, +AC_EGREP_HEADER(i386_io_perm_modify, mach/machine/mach_i386.defs, libc_cv_mach_i386_ioports=yes, libc_cv_mach_i386_ioports=no)]) if test $libc_cv_mach_i386_ioports = yes; then @@ -98,7 +98,7 @@ fi AC_CACHE_CHECK(for i386_set_gdt in mach_i386.defs, libc_cv_mach_i386_gdt, [dnl -AC_EGREP_HEADER(i386_set_gdt, mach/i386/mach_i386.defs, +AC_EGREP_HEADER(i386_set_gdt, mach/machine/mach_i386.defs, libc_cv_mach_i386_gdt=yes, libc_cv_mach_i386_gdt=no)]) if test $libc_cv_mach_i386_gdt = yes; then From patchwork Sun Feb 12 11:10:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 64781 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 A2E0A3889E17 for ; Sun, 12 Feb 2023 11:12:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A2E0A3889E17 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676200370; bh=cgww0FBnC6IXE2m/pGi3HBEXDJPHWjisQc4rSyYQZ3M=; 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=X6Zm65KtX9za6PpbfzBeOdM8ZhhxWfjnXzjQAEAKNpXg+mTP/MGEmqtnT/fJJgyIg xdxxoQLGtPucTMH8pXa7GPPRRaNiWJ/sWu5QB9nUyYmVhNhZ+XHbsB17rMJdvHjZWS hs9WEJ+BdMu3fcy6e57OJp3eW64AWxahMrC3mXXk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by sourceware.org (Postfix) with ESMTPS id ED298385783F for ; Sun, 12 Feb 2023 11:11:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ED298385783F Received: by mail-ed1-x52f.google.com with SMTP id cq19so6683221edb.5 for ; Sun, 12 Feb 2023 03:11:23 -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=cgww0FBnC6IXE2m/pGi3HBEXDJPHWjisQc4rSyYQZ3M=; b=S6f6x+ONYlGnxATqaYE9dTTCnzFBHob+cFR6gXZifErFUnC0gNWialDl3om/jXBI2Z j6ROPoBYdOE96orbe039xPr6wnzx/BsrjPq+2KcpNwujfo9jua11lC4phvYqOyzmbxix wT6CA5AYYkgsE7/SMffXvpEOlH7hRFnSxUya6fFgR4NovQzoZbt1dkGwXfOr7atF7Td7 S1rLNm5Ux8tJBRPdEFYgYMuuF13OOoEnTq0NuZbV7JXz0pMSNFd08BF3GlQe7nrCoW/O 8Nw7bq0VG+dKIWjW1KKaTflOegBzaIlueg2kLqMRPunur5hG2GBZvItxQqNy9P6R1ExN Vm/g== X-Gm-Message-State: AO0yUKU2GtJ6atLGGiTmfxMf4tQELCmY+X0sNaDLH3sJzGvxKP4BIdur EZDgWOHr7Q7S5dsmPQqahGw= X-Google-Smtp-Source: AK7set/qnkcZQhU3xgKAUP++bwRCUUxKZ5XH568wrKvUFsjVzVOp+jZAa/c53lN+DPmk7qywOGhAkg== X-Received: by 2002:a50:d4c7:0:b0:4aa:b281:bedd with SMTP id e7-20020a50d4c7000000b004aab281beddmr22393552edj.20.1676200283628; Sun, 12 Feb 2023 03:11:23 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:2186:c463:9ced:e6fe]) by smtp.gmail.com with ESMTPSA id c61-20020a509fc3000000b004acbe0b36d2sm1266910edf.6.2023.02.12.03.11.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Feb 2023 03:11:23 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?utf-8?q?Fl=C3=A1vio_Cruz?= , Sergey Bugaev Subject: [RFC PATCH glibc 10/12] hurd: Set up the basic tree for x86_64-gnu Date: Sun, 12 Feb 2023 14:10:41 +0300 Message-Id: <20230212111044.610942-11-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230212111044.610942-1-bugaevc@gmail.com> References: <20230212111044.610942-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" And move pt-setup.c to the generic x86 tree. Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/Implies | 1 + sysdeps/mach/hurd/{i386 => x86}/htl/pt-setup.c | 4 ++-- sysdeps/mach/hurd/x86_64/Implies | 2 ++ sysdeps/mach/hurd/x86_64/htl/Implies | 3 +++ sysdeps/mach/x86_64/Implies | 1 + 5 files changed, 9 insertions(+), 2 deletions(-) rename sysdeps/mach/hurd/{i386 => x86}/htl/pt-setup.c (97%) create mode 100644 sysdeps/mach/hurd/x86_64/Implies create mode 100644 sysdeps/mach/hurd/x86_64/htl/Implies create mode 100644 sysdeps/mach/x86_64/Implies diff --git a/sysdeps/mach/hurd/Implies b/sysdeps/mach/hurd/Implies index d2d5234c..e19dd1fd 100644 --- a/sysdeps/mach/hurd/Implies +++ b/sysdeps/mach/hurd/Implies @@ -3,3 +3,4 @@ gnu # The Hurd provides a rough superset of the functionality of 4.4 BSD. unix/bsd +mach/hurd/htl diff --git a/sysdeps/mach/hurd/i386/htl/pt-setup.c b/sysdeps/mach/hurd/x86/htl/pt-setup.c similarity index 97% rename from sysdeps/mach/hurd/i386/htl/pt-setup.c rename to sysdeps/mach/hurd/x86/htl/pt-setup.c index 94caed82..3abd92b2 100644 --- a/sysdeps/mach/hurd/i386/htl/pt-setup.c +++ b/sysdeps/mach/hurd/x86/htl/pt-setup.c @@ -1,4 +1,4 @@ -/* Setup thread stack. Hurd/i386 version. +/* Setup thread stack. Hurd/x86 version. Copyright (C) 2000-2023 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -22,7 +22,7 @@ #include -/* The stack layout used on the i386 is: +/* The stack layout used on the x86 is: ----------------- | ARG | diff --git a/sysdeps/mach/hurd/x86_64/Implies b/sysdeps/mach/hurd/x86_64/Implies new file mode 100644 index 00000000..6b5e6f47 --- /dev/null +++ b/sysdeps/mach/hurd/x86_64/Implies @@ -0,0 +1,2 @@ +mach/hurd/x86 +mach/hurd/x86_64/htl diff --git a/sysdeps/mach/hurd/x86_64/htl/Implies b/sysdeps/mach/hurd/x86_64/htl/Implies new file mode 100644 index 00000000..1ae8f16e --- /dev/null +++ b/sysdeps/mach/hurd/x86_64/htl/Implies @@ -0,0 +1,3 @@ +mach/hurd/htl +mach/hurd/x86/htl +x86_64/htl diff --git a/sysdeps/mach/x86_64/Implies b/sysdeps/mach/x86_64/Implies new file mode 100644 index 00000000..da8291f4 --- /dev/null +++ b/sysdeps/mach/x86_64/Implies @@ -0,0 +1 @@ +mach/x86 From patchwork Sun Feb 12 11:10:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 64784 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 9ABB43894C1B for ; Sun, 12 Feb 2023 11:13:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9ABB43894C1B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676200413; bh=Qg23qVIpI9j8sW+vvfKlHFATf9cX+/0LOFsPVLaBKds=; 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=PRqoe0LaBPILtOE95zmN0KtWfmfblQl+CgVXeiYBo/YfklEV2hvDebVluFabJFZiG q96mShI7HXCF4BbYmzSVLCGNXgeD1slps3G7lNfG1SoxSitHlYz7gQWb9zjMZrMWRC 5Ug7hp7doL9SyPZ3EAuL4LsOIJjtPnnKfywqp9cM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id 2A3C3385B50D for ; Sun, 12 Feb 2023 11:11:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2A3C3385B50D Received: by mail-ed1-x532.google.com with SMTP id a10so9392622edu.9 for ; Sun, 12 Feb 2023 03:11:25 -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=Qg23qVIpI9j8sW+vvfKlHFATf9cX+/0LOFsPVLaBKds=; b=IQ+6LJOy0GDPCbzVb1BFNOVbGNNGIJI0VXQTDjdJrF7PVj+57rHgWpJ0IfWXzb7zrz LcQmFJNEhrdtY7JgR8gFMF8c9wxlRTf8yhWFD9U0Kl77QlGvFLZu7RsYchG3CEZ5i/4Y WtiBqhqgBrDU2nD+O2/FD2MILQ0Df2b/8zAmY+tKphjrwzIuzmfXDsVUGrGvlTROQ8H6 8KjcRDxn+/8pKBVF69z9qEIoaXHlGeLDUJlaqR83KQJneNw5hUKRu2ZSzacDA/H1bqib NzQ9R/LzqhjLSZpHbT5bu1LKb1SDLQL6CY2knNjCldp52AK9pJaz5+1KEMofScSdtAHW 4l3g== X-Gm-Message-State: AO0yUKUvO8RVe2GQyC04nBVF8X758+UdovaUf3ObUqSSwMvSjYemDuF8 zviDPnmAqOdfXM08RFO0YBs9ZF34v8+auQ== X-Google-Smtp-Source: AK7set9pWmujzmucfKACJdAPqB9cImnUXNqkuy/+lEFIC1vvIYteMSGedvT4+tqtmNPYEkWfROoPiQ== X-Received: by 2002:a50:c30d:0:b0:4ab:4411:2f71 with SMTP id a13-20020a50c30d000000b004ab44112f71mr9439659edb.37.1676200284735; Sun, 12 Feb 2023 03:11:24 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:2186:c463:9ced:e6fe]) by smtp.gmail.com with ESMTPSA id c61-20020a509fc3000000b004acbe0b36d2sm1266910edf.6.2023.02.12.03.11.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Feb 2023 03:11:24 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?utf-8?q?Fl=C3=A1vio_Cruz?= , Sergey Bugaev Subject: [RFC PATCH glibc 11/12] hurd, htl: Add some x86_64-specific code Date: Sun, 12 Feb 2023 14:10:42 +0300 Message-Id: <20230212111044.610942-12-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230212111044.610942-1-bugaevc@gmail.com> References: <20230212111044.610942-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, 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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" tls.h in particular is very unfinished. Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/x86_64/static-start.S | 27 +++ sysdeps/mach/hurd/x86_64/tls.h | 182 ++++++++++++++++++++ sysdeps/mach/hurd/x86_64/tlsdesc.sym | 22 +++ sysdeps/x86_64/htl/bits/pthreadtypes-arch.h | 36 ++++ sysdeps/x86_64/htl/machine-sp.h | 29 ++++ sysdeps/x86_64/htl/pt-machdep.h | 28 +++ 6 files changed, 324 insertions(+) create mode 100644 sysdeps/mach/hurd/x86_64/static-start.S create mode 100644 sysdeps/mach/hurd/x86_64/tls.h create mode 100644 sysdeps/mach/hurd/x86_64/tlsdesc.sym create mode 100644 sysdeps/x86_64/htl/bits/pthreadtypes-arch.h create mode 100644 sysdeps/x86_64/htl/machine-sp.h create mode 100644 sysdeps/x86_64/htl/pt-machdep.h diff --git a/sysdeps/mach/hurd/x86_64/static-start.S b/sysdeps/mach/hurd/x86_64/static-start.S new file mode 100644 index 00000000..982d3d52 --- /dev/null +++ b/sysdeps/mach/hurd/x86_64/static-start.S @@ -0,0 +1,27 @@ +/* Startup code for statically linked Hurd/x86_64 binaries. + Copyright (C) 1998-2023 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 + . */ + + .text + .globl _start +_start: + call _hurd_stack_setup + xorq %rdx, %rdx + jmp _start1 + +#define _start _start1 +#include diff --git a/sysdeps/mach/hurd/x86_64/tls.h b/sysdeps/mach/hurd/x86_64/tls.h new file mode 100644 index 00000000..027304d9 --- /dev/null +++ b/sysdeps/mach/hurd/x86_64/tls.h @@ -0,0 +1,182 @@ +/* Definitions for thread-local data handling. Hurd/x86_64 version. + Copyright (C) 2003-2023 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 + . */ + +#ifndef _X86_64_TLS_H +#define _X86_64_TLS_H + + +/* Some things really need not be machine-dependent. */ +#include + + +#ifndef __ASSEMBLER__ +# include + +/* Type of the TCB. */ +typedef struct +{ + void *tcb; /* Points to this structure. */ + dtv_t *dtv; /* Vector of pointers to TLS data. */ + thread_t self; /* This thread's control port. */ + int __glibc_padding1; + int multiple_threads; + int gscope_flag; + uintptr_t sysinfo; + uintptr_t stack_guard; + uintptr_t pointer_guard; + long __glibc_padding2[2]; + int private_futex; + int __glibc_padding3; + /* Reservation of some values for the TM ABI. */ + void *__private_tm[4]; + /* GCC split stack support. */ + void *__private_ss; + /* The lowest address of shadow stack. */ + unsigned long long int ssp_base; + + /* Keep these fields last, so offsets of fields above can continue being + compatible with the x86_64 NPTL version. */ + mach_port_t reply_port; /* This thread's reply port. */ + struct hurd_sigstate *_hurd_sigstate; + + /* Used by the exception handling implementation in the dynamic loader. */ + struct rtld_catch *rtld_catch; +} tcbhead_t; + +/* GCC generates %fs:0x28 to access the stack guard. */ +_Static_assert (offsetof (tcbhead_t, stack_guard) == 0x28, + "stack guard offset"); +/* libgcc uses %fs:0x70 to access the split stack pointer. */ +_Static_assert (offsetof (tcbhead_t, __private_ss) == 0x70, + "split stack pointer offset"); + +/* FIXME */ +# define __LIBC_NO_TLS() 0 + +/* The TCB can have any size and the memory following the address the + thread pointer points to is unspecified. Allocate the TCB there. */ +# define TLS_TCB_AT_TP 1 +# define TLS_DTV_AT_TP 0 + +# define TCB_ALIGNMENT 64 + +# define TLS_INIT_TP(descr) 0 + +# if __GNUC_PREREQ (6, 0) + +# define THREAD_SELF \ + (*(tcbhead_t * __seg_fs *) offsetof (tcbhead_t, tcb)) +# define THREAD_GETMEM(descr, member) \ + (*(__typeof (descr->member) __seg_fs *) offsetof (tcbhead_t, member)) +# define THREAD_SETMEM(descr, member, value) \ + (*(__typeof (descr->member) __seg_fs *) offsetof (tcbhead_t, member) = value) + +# else + +# define THREAD_SELF \ + ({ tcbhead_t *__tcb; \ + asm ("movq %%fs:%c1,%0" : "=r" (__tcb) \ + : "i" (offsetof (tcbhead_t, tcb))); \ + __tcb; }) + +/* Read member of the thread descriptor directly. */ +# define THREAD_GETMEM(descr, member) \ + ({ __typeof (descr->member) __value; \ + _Static_assert (sizeof (__value) == 1 \ + || sizeof (__value) == 4 \ + || sizeof (__value) == 8, \ + "size of per-thread data"); \ + if (sizeof (__value) == 1) \ + asm volatile ("movb %%fs:%P2,%b0" \ + : "=q" (__value) \ + : "0" (0), "i" (offsetof (tcbhead_t, member))); \ + else if (sizeof (__value) == 4) \ + asm volatile ("movl %%fs:%P1,%0" \ + : "=r" (__value) \ + : "i" (offsetof (tcbhead_t, member))); \ + else /* 8 */ \ + asm volatile ("movq %%fs:%P1,%0" \ + : "=r" (__value) \ + : "i" (offsetof (tcbhead_t, member))); \ + __value; }) + +/* Write member of the thread descriptor directly. */ +# define THREAD_SETMEM(descr, member, value) \ + ({ \ + _Static_assert (sizeof (descr->member) == 1 \ + || sizeof (descr->member) == 4 \ + || sizeof (descr->member) == 8, \ + "size of per-thread data"); \ + if (sizeof (descr->member) == 1) \ + asm volatile ("movb %b0,%%fs:%P1" : \ + : "iq" (value), \ + "i" (offsetof (tcbhead_t, member))); \ + else if (sizeof (descr->member) == 4) \ + asm volatile ("movl %0,%%fs:%P1" : \ + : "ir" (value), \ + "i" (offsetof (tcbhead_t, member))); \ + else /* 8 */ \ + asm volatile ("movq %0,%%fs:%P1" : \ + : "ir" (value), \ + "i" (offsetof (tcbhead_t, member))); \ + }) +# endif /* __GNUC_PREREQ (6, 0) */ + +/* Set the stack guard field in TCB head. */ +# define THREAD_SET_STACK_GUARD(value) \ + THREAD_SETMEM (THREAD_SELF, stack_guard, value) +# define THREAD_COPY_STACK_GUARD(descr) \ + ((descr)->stack_guard \ + = THREAD_GETMEM (THREAD_SELF, stack_guard)) + +/* Set the pointer guard field in the TCB head. */ +# define THREAD_SET_POINTER_GUARD(value) \ + THREAD_SETMEM (THREAD_SELF, pointer_guard, value) +# define THREAD_COPY_POINTER_GUARD(descr) \ + ((descr)->pointer_guard \ + = THREAD_GETMEM (THREAD_SELF, pointer_guard)) + +/* Install new dtv for current thread. */ +# define INSTALL_NEW_DTV(dtvp) THREAD_SETMEM (THREAD_SELF, dtv, dtvp) + +/* Return the address of the dtv for the current thread. */ +# define THREAD_DTV() THREAD_GETMEM (THREAD_SELF, dtv) + +/* Global scope switch support. */ +# define THREAD_GSCOPE_FLAG_UNUSED 0 +# define THREAD_GSCOPE_FLAG_USED 1 +# define THREAD_GSCOPE_FLAG_WAIT 2 + +# define THREAD_GSCOPE_SET_FLAG() \ + THREAD_SETMEM (THREAD_SELF, gscope_flag, THREAD_GSCOPE_FLAG_USED) + +# define THREAD_GSCOPE_RESET_FLAG() \ + ({ \ + int __flag; \ + asm volatile ("xchgl %0, %%fs:%P1" \ + : "=r" (__flag) \ + : "i" (offsetof (tcbhead_t, gscope_flag)), \ + "0" (THREAD_GSCOPE_FLAG_UNUSED)); \ + if (__flag == THREAD_GSCOPE_FLAG_WAIT) \ + lll_wake (THREAD_SELF->gscope_flag, LLL_PRIVATE); \ + }) + + + +#endif /* __ASSEMBLER__ */ +#endif /* x86_64/tls.h */ diff --git a/sysdeps/mach/hurd/x86_64/tlsdesc.sym b/sysdeps/mach/hurd/x86_64/tlsdesc.sym new file mode 100644 index 00000000..da3b96c1 --- /dev/null +++ b/sysdeps/mach/hurd/x86_64/tlsdesc.sym @@ -0,0 +1,22 @@ +#include +#include +#include +#include +#include + +-- + +-- We have to override sysdeps/x86_64/tlsdesc.sym to adapt to our libpthread. + +-- Abuse tls.h macros to derive offsets relative to the thread register. + +DTV_OFFSET offsetof(tcbhead_t, dtv) + +TLSDESC_ARG offsetof(struct tlsdesc, arg) + +TLSDESC_GEN_COUNT offsetof(struct tlsdesc_dynamic_arg, gen_count) +TLSDESC_MODID offsetof(struct tlsdesc_dynamic_arg, tlsinfo.ti_module) +TLSDESC_MODOFF offsetof(struct tlsdesc_dynamic_arg, tlsinfo.ti_offset) + +TI_MODULE_OFFSET offsetof(tls_index, ti_module) +TI_OFFSET_OFFSET offsetof(tls_index, ti_offset) diff --git a/sysdeps/x86_64/htl/bits/pthreadtypes-arch.h b/sysdeps/x86_64/htl/bits/pthreadtypes-arch.h new file mode 100644 index 00000000..c3ac991b --- /dev/null +++ b/sysdeps/x86_64/htl/bits/pthreadtypes-arch.h @@ -0,0 +1,36 @@ +/* Machine-specific pthread type layouts. Hurd x86_64 version. + Copyright (C) 2002-2023 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 + . */ + +#ifndef _BITS_PTHREADTYPES_ARCH_H +#define _BITS_PTHREADTYPES_ARCH_H 1 + +#define __SIZEOF_PTHREAD_MUTEX_T 32 +#define __SIZEOF_PTHREAD_ATTR_T 48 +#define __SIZEOF_PTHREAD_RWLOCK_T 48 +#define __SIZEOF_PTHREAD_BARRIER_T 40 +#define __SIZEOF_PTHREAD_MUTEXATTR_T 16 +#define __SIZEOF_PTHREAD_COND_T 40 +#define __SIZEOF_PTHREAD_CONDATTR_T 8 +#define __SIZEOF_PTHREAD_RWLOCKATTR_T 4 +#define __SIZEOF_PTHREAD_BARRIERATTR_T 4 +#define __SIZEOF_PTHREAD_ONCE_T 8 + +#define __LOCK_ALIGNMENT __attribute__ ((__aligned__(4))) +#define __ONCE_ALIGNMENT + +#endif /* bits/pthreadtypes.h */ diff --git a/sysdeps/x86_64/htl/machine-sp.h b/sysdeps/x86_64/htl/machine-sp.h new file mode 100644 index 00000000..7ae1c941 --- /dev/null +++ b/sysdeps/x86_64/htl/machine-sp.h @@ -0,0 +1,29 @@ +/* Machine-specific function to return the stack pointer. x86_64 version. + Copyright (C) 1994-2023 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 + . */ + +#ifndef _MACHINE_SP_H +#define _MACHINE_SP_H + +/* Return the current stack pointer. */ + +#define __thread_stack_pointer() ({ \ + register uintptr_t __sp__ asm("rsp"); \ + __sp__; \ +}) + +#endif /* machine-sp.h */ diff --git a/sysdeps/x86_64/htl/pt-machdep.h b/sysdeps/x86_64/htl/pt-machdep.h new file mode 100644 index 00000000..2e2846fa --- /dev/null +++ b/sysdeps/x86_64/htl/pt-machdep.h @@ -0,0 +1,28 @@ +/* Machine dependent pthreads internal defenitions. x86_64 version. + Copyright (C) 2000-2023 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 + . */ + +#ifndef _PT_MACHDEP_H +#define _PT_MACHDEP_H 1 + +struct pthread_mcontext +{ + void *pc; + void *sp; +}; + +#endif /* pt-machdep.h */ From patchwork Sun Feb 12 11:10:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 64778 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 91997382E69E for ; Sun, 12 Feb 2023 11:12:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 91997382E69E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676200343; bh=2Dl1TKP+S/3nKll7aODuMT1g6QUnU4gsO4DIikPN5bU=; 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=fCr95evTbV2lwxa0y46pVBbqaciLPwJ4EfgUeC6pyNmxsBL/mBhI7k9780xmzCQSC ysChXW5tXUJOmaJkPdcW+WxV2i7fikWOjKBDP/lxUFntc7BhuEojGrpfIXxKJ1GMWG 9SH05PzkpDoDrurSpNFtXORCyL/xoMzseqg9+J2o= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by sourceware.org (Postfix) with ESMTPS id 224FC3858017 for ; Sun, 12 Feb 2023 11:11:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 224FC3858017 Received: by mail-ed1-x52e.google.com with SMTP id s11so1693660edd.10 for ; Sun, 12 Feb 2023 03:11:27 -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=2Dl1TKP+S/3nKll7aODuMT1g6QUnU4gsO4DIikPN5bU=; b=PzR+q3Z1wCCwMlijqLzxHKjV6gGzQP2q+1/vkQGCbDyUPS/BYORTv0JNYsZmoPlfMB JU0GCFTa6Z+ml4SBB5CreX4RpUoblKdh2r+X8I23iCon6l0Hd07mYJNkMddJt+WUCP1r rEw7W6VfkGZD+T5A179Np1cfS6qMIIyAa3tftbpd/3CQv6h1goDdXFrpjd1O7cldikgO rvAm9a8MdTD2aCcBlKHswIKaylib06LDGVnz10WmoDMzJqCSoeCcjE2KEm5La4sxYi2u UUnj0/bn2kH56+xobuCQn+advWVNt4LM5HPRUAa1cQycSaCXWryVT3lX+jNI4itOIiM6 Sftg== X-Gm-Message-State: AO0yUKWqxmQUMiS5RrQ++/eUXnafYF/xo4ig6VnRYoEGcfXbY+DtprgT 53IgS5vQJY1BjiCgOnW9SkU+bONU0bMl8w== X-Google-Smtp-Source: AK7set8RFkJvMJ3pCKdoNiEWxuxONr1KksdRFqdD76y4GGMyh0xLkYkvfMbphIn2eVTKWZ8bEFMSxg== X-Received: by 2002:a50:9f21:0:b0:4ac:b559:4730 with SMTP id b30-20020a509f21000000b004acb5594730mr5258604edf.25.1676200285815; Sun, 12 Feb 2023 03:11:25 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:2186:c463:9ced:e6fe]) by smtp.gmail.com with ESMTPSA id c61-20020a509fc3000000b004acbe0b36d2sm1266910edf.6.2023.02.12.03.11.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Feb 2023 03:11:25 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?utf-8?q?Fl=C3=A1vio_Cruz?= , Sergey Bugaev Subject: [RFC PATCH glibc 12/12] C11 thrd: Downgrade the default alignment of mtx_t Date: Sun, 12 Feb 2023 14:10:43 +0300 Message-Id: <20230212111044.610942-13-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230212111044.610942-1-bugaevc@gmail.com> References: <20230212111044.610942-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" ..so that it can match the alignment of pthread_mutex_t on x86_64-gnu. This likely breaks many other arches (if not all of them), though. Signed-off-by: Sergey Bugaev --- sysdeps/pthread/threads.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/pthread/threads.h b/sysdeps/pthread/threads.h index 860d597d..207c1dee 100644 --- a/sysdeps/pthread/threads.h +++ b/sysdeps/pthread/threads.h @@ -64,7 +64,7 @@ typedef __once_flag once_flag; typedef union { char __size[__SIZEOF_PTHREAD_MUTEX_T]; - long int __align __LOCK_ALIGNMENT; + int __align __LOCK_ALIGNMENT; } mtx_t; typedef union