From a3e12db1499b04efbd6db28f644d34c965d1c250 Mon Sep 17 00:00:00 2001 From: Joakim Date: Tue, 4 Dec 2018 17:10:00 +0530 Subject: [PATCH 1/2] Android: much of /proc was made inaccessible since Oreo, but cpuinfo is still readable. --- std/file.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/file.d b/std/file.d index 55a85a6b9c4..b707c68e5e9 100644 --- a/std/file.d +++ b/std/file.d @@ -466,7 +466,7 @@ version (Windows) private void[] readImpl(scope const(char)[] name, scope const( version (linux) @safe unittest { // A file with "zero" length that doesn't have 0 length at all - auto s = std.file.readText("/proc/sys/kernel/osrelease"); + auto s = std.file.readText("/proc/cpuinfo"); assert(s.length > 0); //writefln("'%s'", s); } From 073ea406c624ee7a75716925980cfd89d90daffa Mon Sep 17 00:00:00 2001 From: Joakim Date: Tue, 4 Dec 2018 17:12:12 +0530 Subject: [PATCH 2/2] Loosen two tests for IEEE Quadruple precision and make sure std.variant.VariantN is properly aligned for Quadruples. --- std/complex.d | 2 +- std/math.d | 2 +- std/traits.d | 2 +- std/variant.d | 16 +++++++++++++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/std/complex.d b/std/complex.d index eef57f864eb..00f05313d9e 100644 --- a/std/complex.d +++ b/std/complex.d @@ -932,7 +932,7 @@ deprecated assert(coshisinh(3.0L) == complex(std.math.cosh(3.0L), std.math.sinh(3.0L))); auto z1 = coshisinh(1.234); auto z2 = std.math.coshisinh(1.234); - static if (real.mant_dig == 53) + static if (real.mant_dig == 53 || real.mant_dig == 113) { assert(std.math.feqrel(z1.re, z2.re) >= real.mant_dig - 1 && std.math.feqrel(z1.im, z2.im) >= real.mant_dig - 1); diff --git a/std/math.d b/std/math.d index 50ab3e83f81..05d6e0c8250 100644 --- a/std/math.d +++ b/std/math.d @@ -4110,7 +4110,7 @@ real log(real x) @safe pure nothrow @nogc /// @safe pure nothrow @nogc unittest { - assert(log(E) == 1); + assert(feqrel(log(E), 1) >= real.mant_dig - 1); } /************************************** diff --git a/std/traits.d b/std/traits.d index 2373e8e3c56..33d05c9eafc 100644 --- a/std/traits.d +++ b/std/traits.d @@ -4759,7 +4759,7 @@ template TemplateArgsOf(T : Base!Args, alias Base, Args...) } -private template maxAlignment(U...) +package template maxAlignment(U...) if (isTypeTuple!U) { import std.meta : staticMap; diff --git a/std/variant.d b/std/variant.d index 08c10787cfd..6818ab76956 100644 --- a/std/variant.d +++ b/std/variant.d @@ -102,6 +102,20 @@ struct This; private alias This2Variant(V, T...) = AliasSeq!(ReplaceType!(This, V, T)); +// We can't just use maxAlignment because no types might be specified +// to VariantN, so handle that here and then pass along the rest. +private template maxVariantAlignment(U...) +if (isTypeTuple!U) +{ + static if (U.length == 0) + { + import std.algorithm.comparison : max; + enum maxVariantAlignment = max(real.alignof, size_t.alignof); + } + else + enum maxVariantAlignment = maxAlignment!(U); +} + /** * Back-end type seldom used directly by user * code. Two commonly-used types using `VariantN` are: @@ -169,7 +183,7 @@ private: = &handler!(void); union { - ubyte[size] store; + align(maxVariantAlignment!(AllowedTypes)) ubyte[size] store; // conservatively mark the region as pointers static if (size >= (void*).sizeof) void*[size / (void*).sizeof] p;