From patchwork Sun May 17 17:02:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1292190 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=vFvNwnEj; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Q7ks6mpMz9sT4 for ; Mon, 18 May 2020 03:03:15 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9DA69386F83C; Sun, 17 May 2020 17:03:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9DA69386F83C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1589734985; bh=nL5aDG1whRiy5v7bVHRAvw9SP2fSk+Kv8+5pJnljeMY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=vFvNwnEj1Whjd/CiWTsDnEbErFqlUlLWewtFLZn4+j37FlyNvlftPkbx1xqfMzU5Q 1fsdZigSSDAT9k+62AQ4idfNelgGYMfRNFb2rri0nSBl0H6pK4baoRsoLDdjC+nxBq Dfoh2ykUz0hPXcY1s9piSrX7lgZ3+g7zzyhnnsjo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by sourceware.org (Postfix) with ESMTPS id EB790386F432 for ; Sun, 17 May 2020 17:03:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EB790386F432 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 49Q7kY3gDWzKmWN for ; Sun, 17 May 2020 19:03:01 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter05.heinlein-hosting.de (spamfilter05.heinlein-hosting.de [80.241.56.123]) (amavisd-new, port 10030) with ESMTP id OpRLmt2-wnL2 for ; Sun, 17 May 2020 19:02:58 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] libphobos: Merge upstream druntime 5cc061a8, phobos 64ed4684f Date: Sun, 17 May 2020 19:02:57 +0200 Message-Id: <20200517170257.16726-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 731B4174C X-Rspamd-Score: -0.68 / 15.00 / 15.00 X-Spam-Status: No, score=-19.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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@gcc.gnu.org Sender: "Gcc-patches" Hi, This patch merges the D runtime library with upstream druntime 5cc061a8, and the D standard library with upstream phobos 64ed4684f. Fixes included within are: - core.cpuid has been fixed to not use i7 detection on AMD processors (fixes PR95166). - std.net.curl has been fixed to correctly handle HTTP/2 status lines (fixes PR95168). - std.zip has had a test fixed to not rely on unzip being installed (fixes PR95167). Bootstrapped and regression tested on x86_64-linux-gnu, and committed to mainline. Regards, Iain --- libphobos/libdruntime/MERGE | 2 +- libphobos/libdruntime/core/cpuid.d | 18 ++++++++++-- libphobos/src/MERGE | 2 +- libphobos/src/std/net/curl.d | 44 ++++++++++++++++++++++-------- libphobos/src/std/zip.d | 6 ++++ 5 files changed, 56 insertions(+), 16 deletions(-) diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE index c61ad7ca7ed..5e3bf3b795a 100644 --- a/libphobos/libdruntime/MERGE +++ b/libphobos/libdruntime/MERGE @@ -1,4 +1,4 @@ -7bdd83d7b4bd9fd4cb9ffca0d50babc90b31bfd6 +5cc061a8733731d5b40334c0eb7a927b6d6241ce The first line of this file holds the git revision number of the last merge done from the dlang/druntime repository. diff --git a/libphobos/libdruntime/core/cpuid.d b/libphobos/libdruntime/core/cpuid.d index 839605aee1e..2ba13b55bf1 100644 --- a/libphobos/libdruntime/core/cpuid.d +++ b/libphobos/libdruntime/core/cpuid.d @@ -941,13 +941,27 @@ void cpuidX86() datacache[0].lineSize = 32; } } - if (max_cpuid >= 0x0B) { + if (cf.probablyIntel && max_cpuid >= 0x0B) { // For Intel i7 and later, use function 0x0B to determine // cores and hyperthreads. getCpuInfo0B(); } else { if (hyperThreadingBit) cf.maxThreads = (apic>>>16) & 0xFF; else cf.maxThreads = cf.maxCores; + + if (cf.probablyAMD && max_extended_cpuid >= 0x8000_001E) { + version (GNU) asm pure nothrow @nogc { + "cpuid" : "=a" (a), "=b" (b) : "a" (0x8000_001E) : "ecx", "edx"; + } else { + asm pure nothrow @nogc { + mov EAX, 0x8000_001e; + cpuid; + mov b, EBX; + } + } + ubyte coresPerComputeUnit = ((b >> 8) & 3) + 1; + cf.maxCores = cf.maxThreads / coresPerComputeUnit; + } } } @@ -975,7 +989,7 @@ bool hasCPUID() xor {(%%esp), %%eax|eax, [esp]} # eax = whichever bits were changed popf{l|d} # Restore original EFLAGS - " : "=a" flags; + " : "=a" (flags); } } else version (D_InlineAsm_X86) diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE index 6025cdcc1f7..5900ca7c6a4 100644 --- a/libphobos/src/MERGE +++ b/libphobos/src/MERGE @@ -1,4 +1,4 @@ -bf0d0a37c4c2d8762ceff7d8677e7584b770800f +64ed4684fa2a0f2401f5b6df34f6dcb4c3973945 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/net/curl.d b/libphobos/src/std/net/curl.d index 32ba45ce2de..445f996ea08 100644 --- a/libphobos/src/std/net/curl.d +++ b/libphobos/src/std/net/curl.d @@ -2451,7 +2451,6 @@ struct HTTP in char[] value) callback) { import std.algorithm.searching : startsWith; - import std.conv : to; import std.regex : regex, match; import std.uni : toLower; @@ -2471,18 +2470,8 @@ struct HTTP if (header.startsWith("HTTP/")) { headersIn.clear(); - - const m = match(header, regex(r"^HTTP/(\d+)\.(\d+) (\d+) (.*)$")); - if (m.empty) + if (parseStatusLine(header, status)) { - // Invalid status line - } - else - { - status.majorVersion = to!ushort(m.captures[1]); - status.minorVersion = to!ushort(m.captures[2]); - status.code = to!ushort(m.captures[3]); - status.reason = m.captures[4].idup; if (onReceiveStatusLine != null) onReceiveStatusLine(status); } @@ -2517,6 +2506,37 @@ struct HTTP private RefCounted!Impl p; + /// Parse status line, as received from / generated by cURL. + private static bool parseStatusLine(in char[] header, out StatusLine status) @safe + { + import std.conv : to; + import std.regex : regex, match; + + const m = match(header, regex(r"^HTTP/(\d+)(?:\.(\d+))? (\d+)(?: (.*))?$")); + if (m.empty) + return false; // Invalid status line + else + { + status.majorVersion = to!ushort(m.captures[1]); + status.minorVersion = m.captures[2].length ? to!ushort(m.captures[2]) : 0; + status.code = to!ushort(m.captures[3]); + status.reason = m.captures[4].idup; + return true; + } + } + + @safe unittest + { + StatusLine status; + assert(parseStatusLine("HTTP/1.1 200 OK", status) + && status == StatusLine(1, 1, 200, "OK")); + assert(parseStatusLine("HTTP/1.0 304 Not Modified", status) + && status == StatusLine(1, 0, 304, "Not Modified")); + // The HTTP2 protocol is binary; cURL generates this fake text header. + assert(parseStatusLine("HTTP/2 200", status) + && status == StatusLine(2, 0, 200, null)); + } + /** Time condition enumeration as an alias of $(REF CurlTimeCond, etc,c,curl) $(HTTP www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.25, _RFC2616 Section 14.25) diff --git a/libphobos/src/std/zip.d b/libphobos/src/std/zip.d index db47ddef0c9..8b130ea2dd9 100644 --- a/libphobos/src/std/zip.d +++ b/libphobos/src/std/zip.d @@ -970,6 +970,12 @@ version (Posix) @system unittest { import std.datetime, std.file, std.format, std.path, std.process, std.stdio; + if (executeShell("unzip").status != 0) + { + writeln("Can't run unzip, skipping unzip test"); + return; + } + auto zr = new ZipArchive(); auto am = new ArchiveMember(); am.compressionMethod = CompressionMethod.deflate;