From patchwork Thu Apr 11 21:23:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1084289 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-499142-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=gdcproject.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="YcUV/gqd"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44gDZD2qZlz9s4V for ; Fri, 12 Apr 2019 07:24:52 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=i1qvAFG65X4BYbwILlcoP4PaoCyxq34cRDCJFRmoxybZH3 509T35wFn5WGbd6wS2vQfxpt2pN38vRDR4du4x3IhYLxOEhls4IkUpklH21NIkGS LojGaPSmsdyjxGzFdSRt6Thb2GZELo7bQUoutBINoDnkW/yRto27ll5DqzOxA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=eA+pRAe+XWCc6YFYlWx7S1WJMUo=; b=YcUV/gqdwEL2sXBQnMs9 0KGlZGqtKxNeCwldUoPNrD5Om+N4sKQGEa2OqCVVS32RJZVE2ZeeLaUllLDte2Ks 6CRYTofzgGcf/t/4AJv0YmjkZpwJsbRSqx2M9sfemusBZPlV2iT44EFTdPBuNqJw 8CIEN7G9aUQccc3FHxXmWds= Received: (qmail 117700 invoked by alias); 11 Apr 2019 21:24:41 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 112413 invoked by uid 89); 11 Apr 2019 21:24:26 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=pst, Database, bright, 6312 X-HELO: mail-qt1-f175.google.com Received: from mail-qt1-f175.google.com (HELO mail-qt1-f175.google.com) (209.85.160.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 11 Apr 2019 21:24:22 +0000 Received: by mail-qt1-f175.google.com with SMTP id x12so8910923qts.7 for ; Thu, 11 Apr 2019 14:24:12 -0700 (PDT) MIME-Version: 1.0 From: Iain Buclaw Date: Thu, 11 Apr 2019 23:23:59 +0200 Message-ID: Subject: [PATCH, libphobos] Committed merge with upstream phobos To: gcc-patches X-IsSubscribed: yes Hi, This patch merges the libphobos library with upstream phobos cf95639ff. Backports port fixes from upstream that have been committed since last sync. Bootstrapped and regression tested on x86_64-linux-gnu. Committed to trunk as r270296. diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE index 63bd46834c5..b4d44b55624 100644 --- a/libphobos/src/MERGE +++ b/libphobos/src/MERGE @@ -1,4 +1,4 @@ -ef07932811de50a1d5810ea23462d127a60574a6 +cf95639ffd9ed6f3b9d10d98461b2fbd31615757 The first line of this file holds the git revision number of the last merge done from the dlang/phobos repository. diff --git a/libphobos/src/std/datetime/systime.d b/libphobos/src/std/datetime/systime.d index e65d296e427..326b5441724 100644 --- a/libphobos/src/std/datetime/systime.d +++ b/libphobos/src/std/datetime/systime.d @@ -214,6 +214,22 @@ public: hnsecsToUnixEpoch; } } + else version (DragonFlyBSD) + { + import core.sys.dragonflybsd.time : clock_gettime, CLOCK_REALTIME, + CLOCK_REALTIME_FAST, CLOCK_REALTIME_PRECISE, CLOCK_SECOND; + static if (clockType == ClockType.coarse) alias clockArg = CLOCK_REALTIME_FAST; + else static if (clockType == ClockType.normal) alias clockArg = CLOCK_REALTIME; + else static if (clockType == ClockType.precise) alias clockArg = CLOCK_REALTIME_PRECISE; + else static if (clockType == ClockType.second) alias clockArg = CLOCK_SECOND; + else static assert(0, "Previous static if is wrong."); + timespec ts; + if (clock_gettime(clockArg, &ts) != 0) + throw new TimeException("Call to clock_gettime() failed"); + return convert!("seconds", "hnsecs")(ts.tv_sec) + + ts.tv_nsec / 100 + + hnsecsToUnixEpoch; + } else version (Solaris) { static if (clockType == ClockType.second) diff --git a/libphobos/src/std/datetime/timezone.d b/libphobos/src/std/datetime/timezone.d index e923a34a98d..7ae19020243 100644 --- a/libphobos/src/std/datetime/timezone.d +++ b/libphobos/src/std/datetime/timezone.d @@ -292,10 +292,12 @@ public: version (Posix) { - version (FreeBSD) enum utcZone = "Etc/UTC"; - else version (NetBSD) enum utcZone = "UTC"; - else version (linux) enum utcZone = "UTC"; - else version (OSX) enum utcZone = "UTC"; + version (FreeBSD) enum utcZone = "Etc/UTC"; + else version (NetBSD) enum utcZone = "UTC"; + else version (DragonFlyBSD) enum utcZone = "UTC"; + else version (linux) enum utcZone = "UTC"; + else version (OSX) enum utcZone = "UTC"; + else version (Solaris) enum utcZone = "UTC"; else static assert(0, "The location of the UTC timezone file on this Posix platform must be set."); auto tzs = [testTZ("America/Los_Angeles", "PST", "PDT", dur!"hours"(-8), dur!"hours"(1)), @@ -1891,6 +1893,14 @@ public: // Android concatenates all time zone data into a single file and stores it here. enum defaultTZDatabaseDir = "/system/usr/share/zoneinfo/"; } + else version (Solaris) + { + /++ + The default directory where the TZ Database files are. It's empty + for Windows, since Windows doesn't have them. + +/ + enum defaultTZDatabaseDir = "/usr/share/lib/zoneinfo/"; + } else version (Posix) { /++ diff --git a/libphobos/src/std/experimental/allocator/building_blocks/region.d b/libphobos/src/std/experimental/allocator/building_blocks/region.d index dfcecce72bd..3d8431c23ca 100644 --- a/libphobos/src/std/experimental/allocator/building_blocks/region.d +++ b/libphobos/src/std/experimental/allocator/building_blocks/region.d @@ -392,6 +392,8 @@ struct InSituRegion(size_t size, size_t minAlign = platformAlignment) else version (PPC64) enum growDownwards = Yes.growDownwards; else version (MIPS32) enum growDownwards = Yes.growDownwards; else version (MIPS64) enum growDownwards = Yes.growDownwards; + else version (RISCV32) enum growDownwards = Yes.growDownwards; + else version (RISCV64) enum growDownwards = Yes.growDownwards; else version (SPARC) enum growDownwards = Yes.growDownwards; else version (SystemZ) enum growDownwards = Yes.growDownwards; else static assert(0, "Dunno how the stack grows on this architecture."); diff --git a/libphobos/src/std/file.d b/libphobos/src/std/file.d index 17b7ca82654..9ba992944eb 100644 --- a/libphobos/src/std/file.d +++ b/libphobos/src/std/file.d @@ -1488,6 +1488,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R)) // - OS X, where the native filesystem (HFS+) stores filesystem // timestamps with 1-second precision. version (FreeBSD) {} else +version (DragonFlyBSD) {} else version (OSX) {} else @system unittest { @@ -2779,6 +2780,10 @@ else version (NetBSD) { return readLink("/proc/self/exe"); } + else version (DragonFlyBSD) + { + return readLink("/proc/curproc/file"); + } else version (Solaris) { import core.sys.posix.unistd : getpid; @@ -3092,8 +3097,12 @@ else version (Posix) { import std.path : buildPath; - immutable len = core.stdc.string.strlen(fd.d_name.ptr); - _name = buildPath(path, fd.d_name[0 .. len]); + static if (is(typeof(fd.d_namlen))) + immutable len = fd.d_namlen; + else + immutable len = (() @trusted => core.stdc.string.strlen(fd.d_name.ptr))(); + + _name = buildPath(path, (() @trusted => fd.d_name.ptr[0 .. len])()); _didLStat = false; _didStat = false; diff --git a/libphobos/src/std/internal/cstring.d b/libphobos/src/std/internal/cstring.d index 257a1007b26..e5bc7f744bc 100644 --- a/libphobos/src/std/internal/cstring.d +++ b/libphobos/src/std/internal/cstring.d @@ -131,17 +131,20 @@ if (isSomeChar!To && (isInputRange!From || isSomeString!From) && private: To* _ptr; size_t _length; // length of the string + + // the 'small string optimization' version (unittest) { - enum buffLength = 16 / To.sizeof; // smaller size to trigger reallocations + // smaller size to trigger reallocations. Padding is to account for + // unittest/non-unittest cross-compilation (to avoid corruption) + To[16 / To.sizeof] _buff; + To[(256 - 16) / To.sizeof] _unittest_pad; } else { - enum buffLength = 256 / To.sizeof; // production size + To[256 / To.sizeof] _buff; // production size } - To[buffLength] _buff; // the 'small string optimization' - static Res trustedVoidInit() { Res res = void; return res; } } diff --git a/libphobos/src/std/math.d b/libphobos/src/std/math.d index e98e746a856..daee6ec3c33 100644 --- a/libphobos/src/std/math.d +++ b/libphobos/src/std/math.d @@ -162,6 +162,8 @@ version (AArch64) version = ARM_Any; version (ARM) version = ARM_Any; version (SPARC) version = SPARC_Any; version (SPARC64) version = SPARC_Any; +version (RISCV32) version = RISCV_Any; +version (RISCV64) version = RISCV_Any; version (D_InlineAsm_X86) { @@ -4683,6 +4685,7 @@ private: // The Pentium SSE2 status register is 32 bits. // The ARM and PowerPC FPSCR is a 32-bit register. // The SPARC FSR is a 32bit register (64 bits for SPARC 7 & 8, but high bits are uninteresting). + // The RISC-V (32 & 64 bit) fcsr is 32-bit register. uint flags; version (CRuntime_Microsoft) @@ -4987,6 +4990,10 @@ else version (PPC_Any) { version = IeeeFlagsSupport; } +else version (RISCV_Any) +{ + version = IeeeFlagsSupport; +} else version (MIPS_Any) { version = IeeeFlagsSupport; @@ -5226,6 +5233,21 @@ struct FloatingPointControl | inexactException, } } + else version (RISCV_Any) + { + enum : ExceptionMask + { + inexactException = 0x01, + divByZeroException = 0x02, + underflowException = 0x04, + overflowException = 0x08, + invalidException = 0x10, + severeExceptions = overflowException | divByZeroException + | invalidException, + allExceptions = severeExceptions | underflowException + | inexactException, + } + } else version (X86_Any) { enum : ExceptionMask @@ -5338,6 +5360,10 @@ private: { alias ControlState = uint; } + else version (RISCV_Any) + { + alias ControlState = uint; + } else version (X86_Any) { alias ControlState = ushort; @@ -7595,6 +7621,34 @@ private real polyImpl(real x, in real[] A) @trusted pure nothrow @nogc ; } } + else version (DragonFlyBSD) + { + asm pure nothrow @nogc // assembler by W. Bright + { + // EDX = (A.length - 1) * real.sizeof + mov ECX,A[EBP] ; // ECX = A.length + dec ECX ; + lea EDX,[ECX*8] ; + lea EDX,[EDX][ECX*4] ; + add EDX,A+4[EBP] ; + fld real ptr [EDX] ; // ST0 = coeff[ECX] + jecxz return_ST ; + fld x[EBP] ; // ST0 = x + fxch ST(1) ; // ST1 = x, ST0 = r + align 4 ; + L2: fmul ST,ST(1) ; // r *= x + fld real ptr -12[EDX] ; + sub EDX,12 ; // deg-- + faddp ST(1),ST ; + dec ECX ; + jne L2 ; + fxch ST(1) ; // ST1 = r, ST0 = x + fstp ST(0) ; // dump x + align 4 ; + return_ST: ; + ; + } + } else { static assert(0); diff --git a/libphobos/src/std/parallelism.d b/libphobos/src/std/parallelism.d index df07baf5ba2..64fa2f93c7e 100644 --- a/libphobos/src/std/parallelism.d +++ b/libphobos/src/std/parallelism.d @@ -94,6 +94,10 @@ else version (FreeBSD) { version = useSysctlbyname; } +else version (DragonFlyBSD) +{ + version = useSysctlbyname; +} else version (NetBSD) { version = useSysctlbyname; @@ -146,6 +150,10 @@ else version (useSysctlbyname) { auto nameStr = "hw.ncpu\0".ptr; } + else version (DragonFlyBSD) + { + auto nameStr = "hw.ncpu\0".ptr; + } else version (NetBSD) { auto nameStr = "hw.ncpu\0".ptr; diff --git a/libphobos/src/std/path.d b/libphobos/src/std/path.d index 32870ea118d..4a435efba6c 100644 --- a/libphobos/src/std/path.d +++ b/libphobos/src/std/path.d @@ -3970,7 +3970,7 @@ string expandTilde(string inputPath) nothrow } if (errno != ERANGE && - // On FreeBSD and OSX, errno can be left at 0 instead of set to ERANGE + // On BSD and OSX, errno can be left at 0 instead of set to ERANGE errno != 0) onOutOfMemoryError(); diff --git a/libphobos/src/std/socket.d b/libphobos/src/std/socket.d index 78479c85b58..2853dbde0c6 100644 --- a/libphobos/src/std/socket.d +++ b/libphobos/src/std/socket.d @@ -187,6 +187,14 @@ string formatSocketError(int err) @trusted else return "Socket error " ~ to!string(err); } + else version (DragonFlyBSD) + { + auto errs = strerror_r(err, buf.ptr, buf.length); + if (errs == 0) + cs = buf.ptr; + else + return "Socket error " ~ to!string(err); + } else version (Solaris) { auto errs = strerror_r(err, buf.ptr, buf.length); diff --git a/libphobos/src/std/stdio.d b/libphobos/src/std/stdio.d index 91646e79c1a..63bc32e9694 100644 --- a/libphobos/src/std/stdio.d +++ b/libphobos/src/std/stdio.d @@ -63,6 +63,12 @@ version (NetBSD) version = HAS_GETDELIM; } +version (DragonFlyBSD) +{ + version = GENERIC_IO; + version = HAS_GETDELIM; +} + version (Solaris) { version = GENERIC_IO;