From patchwork Tue Dec 13 23:03:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 32976 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp410290wrn; Tue, 13 Dec 2022 15:04:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf6OM+dgtJ+O9BefdVJlGkVaIYtg1XBuEe6RnxG3dw+pc7KCo7XEUIa3GdQvJGxONo3BZBEu X-Received: by 2002:a17:906:8d08:b0:7c1:3a0:c0a9 with SMTP id rv8-20020a1709068d0800b007c103a0c0a9mr14135682ejc.12.1670972686193; Tue, 13 Dec 2022 15:04:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670972686; cv=none; d=google.com; s=arc-20160816; b=LurZrP+fbDRdteeo2Udet9t5kKFh72wBZcAGa0bh+0wIqovYM4vz1Fu0V1XG+yUtoU EuWrPNonIuA37RbdH+pV/YK2kaPANGikcoq96ZcTYvXvFVD9iw+wO+5rnOV8zrcH6G+C qL/6f6w2fxU+dsdfII0K8HcssQC6ZE1uc0f2x88j2QZiHYa/mv2kIheXy/TJpLrD+1G5 8q40xPsYth/t0QSsvrS87gyP3jceTereoned9oP++hMTNI4OdZx5e9rOkqkzOsuTu3V7 RXBXQuoNg1ZSLUDaLVKtot6owE1JmrnHmC2XAw5bEKONDZwwX4UI7B4/vVfe+EMEJ466 mRaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=ucVIpS29WJkdV1eDd5iDRLMkELvGJUVOdqCD5bbXY3o=; b=V0nTRuIfFCehGXUDYiQNtU9Ulx80k6WXRcjem81l4LSC/vsKtaQhYO9JMmRknrTGdo kR7Tq20eSQzwnDu4hMNTa87jS0k91JQSlx5NzmrKrdc+bfRbdz41r3CrtnJBUEKIel0x NzNK5LqSE7aPGteyaXyNPOZTeEzVZwyNrK3hV4Xm1qAe6nS1iFl98KonO1xrwJUNvcx9 uuKTmvPSVktSyWzye0Q/ozqtZpaKC0mTpXSJngslkbE2twRb5LN+NqduLoyBw2aeh9e5 /lm2JOv469EbYs8iYQAjhMYEIRUGYe5+Ikutv4pWRGdqWMwK+tYGfV/wDU3ABie/B0Ty IZOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="l0LgU6w/"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id hb41-20020a170907162900b007806c141214si10969326ejc.153.2022.12.13.15.04.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 15:04:46 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="l0LgU6w/"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3388638432D9 for ; Tue, 13 Dec 2022 23:04:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3388638432D9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670972685; bh=ucVIpS29WJkdV1eDd5iDRLMkELvGJUVOdqCD5bbXY3o=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=l0LgU6w/ZAVNdkt2zRquhL8IYQGONLDDzbn9VNeetPTSjVbTRMSmRPExPMNXWyQvr XiBZTH62DJ9wUVhqv8JPcgBXjWMASmCX4bxBPaBsacjfuBCsIef7InVfQPDsoZPsw1 A/X6LGZjB85QrVFWvilUbQxesOTBzs6OVnoEXMcQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [IPv6:2001:67c:2050:0:465::201]) by sourceware.org (Postfix) with ESMTPS id 5D46C38432E9 for ; Tue, 13 Dec 2022 23:03:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5D46C38432E9 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4NWvF24HP0z9sbg; Wed, 14 Dec 2022 00:03:50 +0100 (CET) To: gcc-patches@gcc.gnu.org Cc: Iain Buclaw Subject: [GCC-11][committed] libphobos: Backport library and bindings fixes from mainline Date: Wed, 14 Dec 2022 00:03:44 +0100 Message-Id: <20221213230344.872210-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4NWvF24HP0z9sbg X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752140732698324292?= X-GMAIL-MSGID: =?utf-8?q?1752141855268203403?= Hi, This patch backports some fixes for the libphobos library from mainline that fix build and testsuite failures. Regression tested on x86_64-linux-gnu/-m32/-mx32, committed to releases/gcc-11 branch. D Runtime changes: - Fix MIPS64 bindings for CRuntime_UClibc. Phobos changes: - Fix std.path.expandTilde erroneously raising onOutOfMemory after failed call to getpwnam_r(). - Use GENERIC_IO on CRuntime_UClibc port of std.stdio. libphobos/ChangeLog: * libdruntime/core/stdc/fenv.d: Compile in MIPS uClibc bindings on MIPS_Any targets. * libdruntime/core/stdc/math.d: Likewise. * libdruntime/core/sys/posix/dlfcn.d: Likewise. * libdruntime/core/sys/posix/setjmp.d: Add MIPS64 definitions for CRuntime_UClibc. * libdruntime/core/sys/posix/sys/types.d: Likewise. * src/std/path.d (expandTilde): Handle more errno codes that could be left set by getpwnam_r. * src/std/stdio.d: Set CRuntime_UClibc as GENERIC_IO target. --- libphobos/libdruntime/core/stdc/fenv.d | 2 +- libphobos/libdruntime/core/stdc/math.d | 2 +- libphobos/libdruntime/core/sys/posix/dlfcn.d | 2 +- libphobos/libdruntime/core/sys/posix/setjmp.d | 16 +++++++++++++ .../libdruntime/core/sys/posix/sys/types.d | 12 ++++++++++ libphobos/src/std/path.d | 23 +++++++++++++++---- libphobos/src/std/stdio.d | 3 +-- 7 files changed, 50 insertions(+), 10 deletions(-) diff --git a/libphobos/libdruntime/core/stdc/fenv.d b/libphobos/libdruntime/core/stdc/fenv.d index 3002c022613..665f383167d 100644 --- a/libphobos/libdruntime/core/stdc/fenv.d +++ b/libphobos/libdruntime/core/stdc/fenv.d @@ -481,7 +481,7 @@ else version (CRuntime_UClibc) alias fexcept_t = ushort; } - else version (MIPS32) + else version (MIPS_Any) { struct fenv_t { diff --git a/libphobos/libdruntime/core/stdc/math.d b/libphobos/libdruntime/core/stdc/math.d index 2de6e579575..2a965444f2c 100644 --- a/libphobos/libdruntime/core/stdc/math.d +++ b/libphobos/libdruntime/core/stdc/math.d @@ -113,7 +113,7 @@ else version (CRuntime_UClibc) /// enum int FP_ILOGBNAN = int.min; } - else version (MIPS32) + else version (MIPS_Any) { /// enum int FP_ILOGB0 = -int.max; diff --git a/libphobos/libdruntime/core/sys/posix/dlfcn.d b/libphobos/libdruntime/core/sys/posix/dlfcn.d index f6476ec3106..ff24896cdb6 100644 --- a/libphobos/libdruntime/core/sys/posix/dlfcn.d +++ b/libphobos/libdruntime/core/sys/posix/dlfcn.d @@ -316,7 +316,7 @@ else version (CRuntime_UClibc) enum RTLD_LOCAL = 0; enum RTLD_NODELETE = 0x01000; } - else version (MIPS32) + else version (MIPS_Any) { enum RTLD_LAZY = 0x0001; enum RTLD_NOW = 0x0002; diff --git a/libphobos/libdruntime/core/sys/posix/setjmp.d b/libphobos/libdruntime/core/sys/posix/setjmp.d index b98d321a883..547e52e8edc 100644 --- a/libphobos/libdruntime/core/sys/posix/setjmp.d +++ b/libphobos/libdruntime/core/sys/posix/setjmp.d @@ -366,6 +366,22 @@ else version (CRuntime_UClibc) double[6] __fpregs; } } + else version (MIPS64) + { + struct __jmp_buf + { + long __pc; + long __sp; + long[8] __regs; + long __fp; + long __gp; + int __fpc_csr; + version (MIPS_N64) + double[8] __fpregs; + else + double[6] __fpregs; + } + } else static assert(0, "unimplemented"); diff --git a/libphobos/libdruntime/core/sys/posix/sys/types.d b/libphobos/libdruntime/core/sys/posix/sys/types.d index abcea99019f..529df1bae82 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/types.d +++ b/libphobos/libdruntime/core/sys/posix/sys/types.d @@ -1277,6 +1277,18 @@ else version (CRuntime_UClibc) enum __SIZEOF_PTHREAD_BARRIER_T = 20; enum __SIZEOF_PTHREAD_BARRIERATTR_T = 4; } + else version (MIPS64) + { + enum __SIZEOF_PTHREAD_ATTR_T = 56; + enum __SIZEOF_PTHREAD_MUTEX_T = 40; + enum __SIZEOF_PTHREAD_MUTEXATTR_T = 4; + enum __SIZEOF_PTHREAD_COND_T = 48; + enum __SIZEOF_PTHREAD_CONDATTR_T = 4; + enum __SIZEOF_PTHREAD_RWLOCK_T = 56; + enum __SIZEOF_PTHREAD_RWLOCKATTR_T = 8; + enum __SIZEOF_PTHREAD_BARRIER_T = 32; + enum __SIZEOF_PTHREAD_BARRIERATTR_T = 4; + } else version (ARM) { enum __SIZEOF_PTHREAD_ATTR_T = 36; diff --git a/libphobos/src/std/path.d b/libphobos/src/std/path.d index 4a435efba6c..d250953ee1c 100644 --- a/libphobos/src/std/path.d +++ b/libphobos/src/std/path.d @@ -3850,7 +3850,7 @@ string expandTilde(string inputPath) nothrow version (Posix) { import core.exception : onOutOfMemoryError; - import core.stdc.errno : errno, ERANGE; + import core.stdc.errno : errno, EBADF, ENOENT, EPERM, ERANGE, ESRCH; import core.stdc.stdlib : malloc, free, realloc; /* Joins a path from a C string to the remainder of path. @@ -3950,7 +3950,7 @@ string expandTilde(string inputPath) nothrow scope(exit) free(extra_memory); passwd result; - while (1) + loop: while (1) { extra_memory = cast(char*) realloc(extra_memory, extra_memory_size * char.sizeof); if (extra_memory == null) @@ -3969,10 +3969,23 @@ string expandTilde(string inputPath) nothrow break; } - if (errno != ERANGE && + switch (errno) + { + case ERANGE: // On BSD and OSX, errno can be left at 0 instead of set to ERANGE - errno != 0) - onOutOfMemoryError(); + case 0: + break; + + case ENOENT: + case ESRCH: + case EBADF: + case EPERM: + // The given name or uid was not found. + break loop; + + default: + onOutOfMemoryError(); + } // extra_memory isn't large enough import core.checkedint : mulu; diff --git a/libphobos/src/std/stdio.d b/libphobos/src/std/stdio.d index bbf785773d4..1dc91bc2e35 100644 --- a/libphobos/src/std/stdio.d +++ b/libphobos/src/std/stdio.d @@ -52,8 +52,7 @@ else version (CRuntime_Musl) } else version (CRuntime_UClibc) { - // uClibc supports GCC IO - version = GCC_IO; + version = GENERIC_IO; } else version (OSX) {