diff mbox series

[libphobos] Committed merge upstream phobos and druntime

Message ID CABOHX+deTXGUnNQRMUn8D4NO+sNYQuZf3qGsGQ43m+03g623sg@mail.gmail.com
State New
Headers show
Series [libphobos] Committed merge upstream phobos and druntime | expand

Commit Message

Iain Buclaw Jan. 26, 2019, 1:41 p.m. UTC
Hi,

This patch merges platform fixes for both druntime and phobos from upstream.

Bootstrapped and regression tested on x86_64-linux-gnu.

Committed to trunk as r268293.
diff mbox series

Patch

diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE
new file mode 100644
index 00000000000..b98e0ed6c16
--- /dev/null
+++ b/libphobos/libdruntime/MERGE
@@ -0,0 +1,4 @@ 
+f2db21937e650553066c30f1a9d5a7d08a1b3573
+
+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/stdc/limits.d b/libphobos/libdruntime/core/stdc/limits.d
index 3ed167216ce..3ab7ed1e4f7 100644
--- a/libphobos/libdruntime/core/stdc/limits.d
+++ b/libphobos/libdruntime/core/stdc/limits.d
@@ -14,6 +14,15 @@ 
 
 module core.stdc.limits;
 
+version (OSX)
+    version = Darwin;
+else version (iOS)
+    version = Darwin;
+else version (TVOS)
+    version = Darwin;
+else version (WatchOS)
+    version = Darwin;
+
 private import core.stdc.config;
 
 extern (C):
@@ -21,6 +30,10 @@  extern (C):
 nothrow:
 @nogc:
 
+//
+// Numerical limits
+//
+
 ///
 enum CHAR_BIT       = 8;
 ///
@@ -59,3 +72,113 @@  enum LLONG_MIN      = long.min;
 enum LLONG_MAX      = long.max;
 ///
 enum ULLONG_MAX     = ulong.max;
+
+//
+// File system limits
+//
+
+version (Darwin)
+{
+    ///
+    enum MAX_CANON      = 1024;
+    ///
+    enum MAX_INPUT      = 1024;
+    ///
+    enum NAME_MAX       = 255;
+    ///
+    enum PATH_MAX       = 1024;
+    ///
+    enum PIPE_BUF       = 512;
+}
+
+version (DragonFlyBSD)
+{
+    ///
+    enum MAX_CANON      = 255;
+    ///
+    enum MAX_INPUT      = 255;
+    ///
+    enum NAME_MAX       = 255;
+    ///
+    enum PATH_MAX       = 1024;
+    ///
+    enum PIPE_BUF       = 512;
+}
+else version (FreeBSD)
+{
+    ///
+    enum MAX_CANON      = 255;
+    ///
+    enum MAX_INPUT      = 255;
+    ///
+    enum NAME_MAX       = 255;
+    ///
+    enum PATH_MAX       = 1024;
+    ///
+    enum PIPE_BUF       = 512;
+}
+else version (linux)
+{
+    ///
+    enum MAX_CANON      = 255;
+    ///
+    enum MAX_INPUT      = 255;
+    ///
+    enum NAME_MAX       = 255;
+    ///
+    enum PATH_MAX       = 4096;
+    ///
+    enum PIPE_BUF       = 4096;
+}
+else version (NetBSD)
+{
+    ///
+    enum MAX_CANON      = 255;
+    ///
+    enum MAX_INPUT      = 255;
+    ///
+    enum NAME_MAX       = 511;
+    ///
+    enum PATH_MAX       = 1024;
+    ///
+    enum PIPE_BUF       = 512;
+}
+else version (OpenBSD)
+{
+    ///
+    enum MAX_CANON      = 255;
+    ///
+    enum MAX_INPUT      = 255;
+    ///
+    enum NAME_MAX       = 255;
+    ///
+    enum PATH_MAX       = 1024;
+    ///
+    enum PIPE_BUF       = 512;
+}
+else version (Solaris)
+{
+    ///
+    enum MAX_CANON      = 256;
+    ///
+    enum MAX_INPUT      = 512;
+    ///
+    enum NAME_MAX       = 255;
+    ///
+    enum PATH_MAX       = 1024;
+    ///
+    enum PIPE_BUF       = 5120;
+}
+else version (Windows)
+{
+    ///
+    enum MAX_CANON      = 256;
+    ///
+    enum MAX_INPUT      = 256;
+    ///
+    enum NAME_MAX       = 256;
+    ///
+    enum PATH_MAX       = 260;
+    ///
+    enum PIPE_BUF       = 5120;
+}
diff --git a/libphobos/libdruntime/core/sys/posix/aio.d b/libphobos/libdruntime/core/sys/posix/aio.d
index 8300d920ca9..be36a03e229 100644
--- a/libphobos/libdruntime/core/sys/posix/aio.d
+++ b/libphobos/libdruntime/core/sys/posix/aio.d
@@ -11,6 +11,15 @@  module core.sys.posix.aio;
 private import core.sys.posix.signal;
 private import core.sys.posix.sys.types;
 
+version (OSX)
+    version = Darwin;
+else version (iOS)
+    version = Darwin;
+else version (TVOS)
+    version = Darwin;
+else version (WatchOS)
+    version = Darwin;
+
 version (Posix):
 
 extern (C):
@@ -63,7 +72,7 @@  version (CRuntime_Glibc)
         }
     }
 }
-else version (OSX)
+else version (Darwin)
 {
     struct aiocb
     {
@@ -171,7 +180,7 @@  version (CRuntime_Glibc)
         AIO_ALLDONE
     }
 }
-else version (OSX)
+else version (Darwin)
 {
     enum
     {
@@ -209,7 +218,7 @@  version (CRuntime_Glibc)
         LIO_NOP
     }
 }
-else version (OSX)
+else version (Darwin)
 {
     enum
     {
@@ -246,7 +255,7 @@  version (CRuntime_Glibc)
         LIO_NOWAIT
     }
 }
-else version (OSX)
+else version (Darwin)
 {
     enum
     {
diff --git a/libphobos/libdruntime/rt/arrayassign.d b/libphobos/libdruntime/rt/arrayassign.d
index a128eaec053..389ff92ef78 100644
--- a/libphobos/libdruntime/rt/arrayassign.d
+++ b/libphobos/libdruntime/rt/arrayassign.d
@@ -30,7 +30,12 @@  extern (C) void[] _d_arrayassign(TypeInfo ti, void[] from, void[] to)
 
     // Need a temporary buffer tmp[] big enough to hold one element
     void[16] buf = void;
-    void* ptmp = (elementSize > buf.sizeof) ? alloca(elementSize) : buf.ptr;
+    void* ptmp = (elementSize > buf.sizeof) ? malloc(elementSize) : buf.ptr;
+    scope (exit)
+    {
+        if (ptmp != buf.ptr)
+            free(ptmp);
+    }
     return _d_arrayassign_l(ti, from, to, ptmp);
 }
 
@@ -206,24 +211,20 @@  extern (C) void* _d_arraysetassign(void* p, void* value, int count, TypeInfo ti)
 
     auto element_size = ti.tsize;
 
-    //Need a temporary buffer tmp[] big enough to hold one element
-    void[16] buf = void;
-    void[] tmp;
-    if (element_size > buf.sizeof)
-    {
-        tmp = alloca(element_size)[0 .. element_size];
-    }
-    else
-        tmp = buf[];
+    // Need a temporary buffer tmp[] big enough to hold one element
+    immutable maxAllocaSize = 512;
+    void *ptmp = (element_size > maxAllocaSize) ? malloc(element_size) : alloca(element_size);
 
     foreach (i; 0 .. count)
     {
-        memcpy(tmp.ptr, p, element_size);
+        memcpy(ptmp, p, element_size);
         memcpy(p, value, element_size);
         ti.postblit(p);
-        ti.destroy(tmp.ptr);
+        ti.destroy(ptmp);
         p += element_size;
     }
+    if (element_size > maxAllocaSize)
+        free(ptmp);
     return pstart;
 }
 
diff --git a/libphobos/libdruntime/rt/dmain2.d b/libphobos/libdruntime/rt/dmain2.d
index e1cfb7c23aa..d9376892769 100644
--- a/libphobos/libdruntime/rt/dmain2.d
+++ b/libphobos/libdruntime/rt/dmain2.d
@@ -31,8 +31,7 @@  version (Windows)
     private import core.stdc.wchar_;
     private import core.sys.windows.windows;
 
-    version (GNU) {}
-    else pragma(lib, "shell32.lib"); // needed for CommandLineToArgvW
+    pragma(lib, "shell32.lib"); // needed for CommandLineToArgvW
 }
 
 version (FreeBSD)
diff --git a/libphobos/libdruntime/rt/sections_elf_shared.d b/libphobos/libdruntime/rt/sections_elf_shared.d
index 3d4d75d025c..3f43bbd7663 100644
--- a/libphobos/libdruntime/rt/sections_elf_shared.d
+++ b/libphobos/libdruntime/rt/sections_elf_shared.d
@@ -18,6 +18,7 @@  static if (SharedELF):
 
 // debug = PRINTF;
 import core.memory;
+import core.stdc.config;
 import core.stdc.stdio;
 import core.stdc.stdlib : calloc, exit, free, malloc, EXIT_FAILURE;
 import core.stdc.string : strlen;
@@ -955,8 +956,27 @@  version (Shared) void* handleForAddr(void* addr) nothrow @nogc
  */
 struct tls_index
 {
-    size_t ti_module;
-    size_t ti_offset;
+    version (CRuntime_Glibc)
+    {
+        // For x86_64, fields are of type uint64_t, this is important for x32
+        // where tls_index would otherwise have the wrong size.
+        // See https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86_64/dl-tls.h
+        version (X86_64)
+        {
+            ulong ti_module;
+            ulong ti_offset;
+        }
+        else
+        {
+            c_ulong ti_module;
+            c_ulong ti_offset;
+        }
+    }
+    else
+    {
+        size_t ti_module;
+        size_t ti_offset;
+    }
 }
 
 extern(C) void* __tls_get_addr(tls_index* ti) nothrow @nogc;
diff --git a/libphobos/libdruntime/rt/sections_solaris.d b/libphobos/libdruntime/rt/sections_solaris.d
index ec608db1323..75a43943f45 100644
--- a/libphobos/libdruntime/rt/sections_solaris.d
+++ b/libphobos/libdruntime/rt/sections_solaris.d
@@ -29,24 +29,24 @@  struct SectionGroup
         return dg(_sections);
     }
 
-    @property immutable(ModuleInfo*)[] modules() const
+    @property immutable(ModuleInfo*)[] modules() const nothrow @nogc
     {
         return _moduleGroup.modules;
     }
 
-    @property ref inout(ModuleGroup) moduleGroup() inout
+    @property ref inout(ModuleGroup) moduleGroup() inout nothrow @nogc
     {
         return _moduleGroup;
     }
 
-    @property immutable(FuncTable)[] ehTables() const
+    @property immutable(FuncTable)[] ehTables() const nothrow @nogc
     {
         auto pbeg = cast(immutable(FuncTable)*)&__start_deh;
         auto pend = cast(immutable(FuncTable)*)&__stop_deh;
         return pbeg[0 .. pend - pbeg];
     }
 
-    @property inout(void[])[] gcRanges() inout
+    @property inout(void[])[] gcRanges() inout nothrow @nogc
     {
         return _gcRanges[];
     }
diff --git a/libphobos/libdruntime/rt/sections_win32.d b/libphobos/libdruntime/rt/sections_win32.d
index f79f4af37b4..14d91ba9c2d 100644
--- a/libphobos/libdruntime/rt/sections_win32.d
+++ b/libphobos/libdruntime/rt/sections_win32.d
@@ -31,17 +31,17 @@  struct SectionGroup
         return dg(_sections);
     }
 
-    @property immutable(ModuleInfo*)[] modules() const
+    @property immutable(ModuleInfo*)[] modules() const nothrow @nogc
     {
         return _moduleGroup.modules;
     }
 
-    @property ref inout(ModuleGroup) moduleGroup() inout
+    @property ref inout(ModuleGroup) moduleGroup() inout nothrow @nogc
     {
         return _moduleGroup;
     }
 
-    @property inout(void[])[] gcRanges() inout
+    @property inout(void[])[] gcRanges() inout nothrow @nogc
     {
         return _gcRanges[];
     }
diff --git a/libphobos/libdruntime/rt/sections_win64.d b/libphobos/libdruntime/rt/sections_win64.d
index be8a3066992..346be3b79a8 100644
--- a/libphobos/libdruntime/rt/sections_win64.d
+++ b/libphobos/libdruntime/rt/sections_win64.d
@@ -42,7 +42,7 @@  struct SectionGroup
     }
 
     version (Win64)
-    @property immutable(FuncTable)[] ehTables() const
+    @property immutable(FuncTable)[] ehTables() const nothrow @nogc
     {
         auto pbeg = cast(immutable(FuncTable)*)&_deh_beg;
         auto pend = cast(immutable(FuncTable)*)&_deh_end;
diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE
index f32fc597d95..eee413903c0 100644
--- a/libphobos/src/MERGE
+++ b/libphobos/src/MERGE
@@ -1,4 +1,4 @@ 
-b022e552aaca84810e3dda3a18179440943c7096
+d4933a90b1e8446c04d64cd044658f2b33250bd3
 
 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 b8ef2eee760..e65d296e427 100644
--- a/libphobos/src/std/datetime/systime.d
+++ b/libphobos/src/std/datetime/systime.d
@@ -220,7 +220,7 @@  public:
                     return unixTimeToStdTime(core.stdc.time.time(null));
                 else
                 {
-                    import core.sys.solaris.time : CLOCK_REALTIME;
+                    import core.sys.solaris.time : clock_gettime, CLOCK_REALTIME;
                     static if (clockType == ClockType.coarse)       alias clockArg = CLOCK_REALTIME;
                     else static if (clockType == ClockType.normal)  alias clockArg = CLOCK_REALTIME;
                     else static if (clockType == ClockType.precise) alias clockArg = CLOCK_REALTIME;
diff --git a/libphobos/src/std/experimental/allocator/mallocator.d b/libphobos/src/std/experimental/allocator/mallocator.d
index 146c974f48f..2d1dec39a74 100644
--- a/libphobos/src/std/experimental/allocator/mallocator.d
+++ b/libphobos/src/std/experimental/allocator/mallocator.d
@@ -105,10 +105,6 @@  struct Mallocator
     test!Mallocator();
 }
 
-version (Posix)
-@nogc nothrow
-private extern(C) int posix_memalign(void**, size_t, size_t);
-
 version (Windows)
 {
     // DMD Win 32 bit, DigitalMars C standard library misses the _aligned_xxx
@@ -231,6 +227,7 @@  struct AlignedMallocator
     void[] alignedAllocate(size_t bytes, uint a) shared
     {
         import core.stdc.errno : ENOMEM, EINVAL;
+        import core.sys.posix.stdlib : posix_memalign;
         assert(a.isGoodDynamicAlignment);
         void* result;
         auto code = posix_memalign(&result, a, bytes);
diff --git a/libphobos/src/std/experimental/typecons.d b/libphobos/src/std/experimental/typecons.d
index e1d90d77f7f..6906f05a4a8 100644
--- a/libphobos/src/std/experimental/typecons.d
+++ b/libphobos/src/std/experimental/typecons.d
@@ -113,8 +113,12 @@  if (Targets.length >= 1 && allSatisfy!(isMutable, Targets))
             else
             {
                 enum foundFunc = findCovariantFunction!(TargetMembers[i], Source, SourceMembers);
-                static if (foundFunc == -1)
-                    pragma(msg, "Could not locate matching function for: " ~ TargetMembers[i].stringof);
+                debug
+                {
+                    static if (foundFunc == -1)
+                        pragma(msg, "Could not locate matching function for: ",
+                               TargetMembers[i].stringof);
+                }
                 enum hasRequiredMethods =
                     foundFunc != -1 &&
                     hasRequiredMethods!(i + 1);
diff --git a/libphobos/src/std/file.d b/libphobos/src/std/file.d
index 6b12c043490..17b7ca82654 100644
--- a/libphobos/src/std/file.d
+++ b/libphobos/src/std/file.d
@@ -4293,11 +4293,6 @@  string tempDir() @trusted
             DWORD len = GetTempPathW(buf.length, buf.ptr);
             if (len) cache = buf[0 .. len].to!string;
         }
-        else version (Android)
-        {
-            // Don't check for a global temporary directory as
-            // Android doesn't have one.
-        }
         else version (Posix)
         {
             import std.process : environment;
diff --git a/libphobos/src/std/math.d b/libphobos/src/std/math.d
index 7bb4d7c23db..e98e746a856 100644
--- a/libphobos/src/std/math.d
+++ b/libphobos/src/std/math.d
@@ -160,6 +160,8 @@  version (MIPS32)    version = MIPS_Any;
 version (MIPS64)    version = MIPS_Any;
 version (AArch64)   version = ARM_Any;
 version (ARM)       version = ARM_Any;
+version (SPARC)     version = SPARC_Any;
+version (SPARC64)   version = SPARC_Any;
 
 version (D_InlineAsm_X86)
 {
@@ -380,15 +382,22 @@  template floatTraits(T)
         enum ushort EXPMASK = 0x7FF0;
         enum ushort EXPSHIFT = 4;
         enum realFormat = RealFormat.ibmExtended;
-        // the exponent byte is not unique
+
+        // For IBM doubledouble the larger magnitude double comes first.
+        // It's really a double[2] and arrays don't index differently
+        // between little and big-endian targets.
+        enum DOUBLEPAIR_MSB = 0;
+        enum DOUBLEPAIR_LSB = 1;
+
+        // The exponent/sign byte is for most significant part.
         version (LittleEndian)
         {
-            enum EXPPOS_SHORT = 7; // [3] is also an exp short
-            enum SIGNPOS_BYTE = 15;
+            enum EXPPOS_SHORT = 3;
+            enum SIGNPOS_BYTE = 7;
         }
         else
         {
-            enum EXPPOS_SHORT = 0; // [4] is also an exp short
+            enum EXPPOS_SHORT = 0;
             enum SIGNPOS_BYTE = 0;
         }
     }
@@ -420,19 +429,20 @@  T floorImpl(T)(const T x) @trusted pure nothrow @nogc
     {
         T rv;
         ushort[T.sizeof/2] vu;
+
+        // Other kinds of extractors for real formats.
+        static if (F.realFormat == RealFormat.ieeeSingle)
+            int vi;
     }
     floatBits y = void;
     y.rv = x;
 
     // Find the exponent (power of 2)
+    // Do this by shifting the raw value so that the exponent lies in the low bits,
+    // then mask out the sign bit, and subtract the bias.
     static if (F.realFormat == RealFormat.ieeeSingle)
     {
-        int exp = ((y.vu[F.EXPPOS_SHORT] >> 7) & 0xff) - 0x7f;
-
-        version (LittleEndian)
-            int pos = 0;
-        else
-            int pos = 3;
+        int exp = ((y.vi >> (T.mant_dig - 1)) & 0xff) - 0x7f;
     }
     else static if (F.realFormat == RealFormat.ieeeDouble)
     {
@@ -472,24 +482,43 @@  T floorImpl(T)(const T x) @trusted pure nothrow @nogc
             return 0.0;
     }
 
-    exp = (T.mant_dig - 1) - exp;
-
-    // Zero 16 bits at a time.
-    while (exp >= 16)
+    static if (F.realFormat == RealFormat.ieeeSingle)
     {
-        version (LittleEndian)
-            y.vu[pos++] = 0;
-        else
-            y.vu[pos--] = 0;
-        exp -= 16;
+        if (exp < (T.mant_dig - 1))
+        {
+            // Clear all bits representing the fraction part.
+            const uint fraction_mask = F.MANTISSAMASK_INT >> exp;
+
+            if ((y.vi & fraction_mask) != 0)
+            {
+                // If 'x' is negative, then first substract 1.0 from the value.
+                if (y.vi < 0)
+                    y.vi += 0x00800000 >> exp;
+                y.vi &= ~fraction_mask;
+            }
+        }
     }
+    else
+    {
+        exp = (T.mant_dig - 1) - exp;
+
+        // Zero 16 bits at a time.
+        while (exp >= 16)
+        {
+            version (LittleEndian)
+                y.vu[pos++] = 0;
+            else
+                y.vu[pos--] = 0;
+            exp -= 16;
+        }
 
-    // Clear the remaining bits.
-    if (exp > 0)
-        y.vu[pos] &= 0xffff ^ ((1 << exp) - 1);
+        // Clear the remaining bits.
+        if (exp > 0)
+            y.vu[pos] &= 0xffff ^ ((1 << exp) - 1);
 
-    if ((x < 0.0) && (x != y.rv))
-        y.rv -= 1.0;
+        if ((x < 0.0) && (x != y.rv))
+            y.rv -= 1.0;
+    }
 
     return y.rv;
 }
@@ -4870,10 +4899,7 @@  public:
 ///
 version (GNU)
 {
-    unittest
-    {
-        pragma(msg, "ieeeFlags test disabled, see LDC Issue #888");
-    }
+    // ieeeFlags test disabled, see LDC Issue #888.
 }
 else
 @system unittest
@@ -4904,10 +4930,7 @@  else
 
 version (GNU)
 {
-    unittest
-    {
-        pragma(msg, "ieeeFlags test disabled, see LDC Issue #888");
-    }
+    // ieeeFlags test disabled, see LDC Issue #888.
 }
 else
 @system unittest
@@ -4956,10 +4979,6 @@  else
     }
 }
 
-version (X86_Any)
-{
-    version = IeeeFlagsSupport;
-}
 version (X86_Any)
 {
     version = IeeeFlagsSupport;
@@ -5132,37 +5151,52 @@  struct FloatingPointControl
                                  | inexactException | subnormalException,
         }
     }
-    else version (MIPS_Any)
+    else version (PPC_Any)
     {
         enum : ExceptionMask
         {
-            inexactException      = 0x0080,
-            underflowException    = 0x0100,
-            overflowException     = 0x0200,
-            divByZeroException    = 0x0400,
-            invalidException      = 0x0800,
+            inexactException      = 0x0008,
+            divByZeroException    = 0x0010,
+            underflowException    = 0x0020,
+            overflowException     = 0x0040,
+            invalidException      = 0x0080,
             severeExceptions   = overflowException | divByZeroException
                                  | invalidException,
             allExceptions      = severeExceptions | underflowException
                                  | inexactException,
         }
     }
-    else version (PPC_Any)
+    else version (HPPA)
     {
         enum : ExceptionMask
         {
-            inexactException      = 0x08,
-            divByZeroException    = 0x10,
-            underflowException    = 0x20,
-            overflowException     = 0x40,
-            invalidException      = 0x80,
+            inexactException      = 0x01,
+            underflowException    = 0x02,
+            overflowException     = 0x04,
+            divByZeroException    = 0x08,
+            invalidException      = 0x10,
             severeExceptions   = overflowException | divByZeroException
                                  | invalidException,
             allExceptions      = severeExceptions | underflowException
                                  | inexactException,
         }
     }
-    else version (SPARC64)
+    else version (MIPS_Any)
+    {
+        enum : ExceptionMask
+        {
+            inexactException      = 0x0080,
+            divByZeroException    = 0x0400,
+            overflowException     = 0x0200,
+            underflowException    = 0x0100,
+            invalidException      = 0x0800,
+            severeExceptions   = overflowException | divByZeroException
+                                 | invalidException,
+            allExceptions      = severeExceptions | underflowException
+                                 | inexactException,
+        }
+    }
+    else version (SPARC_Any)
     {
         enum : ExceptionMask
         {
@@ -5284,6 +5318,10 @@  private:
     {
         alias ControlState = uint;
     }
+    else version (HPPA)
+    {
+        alias ControlState = uint;
+    }
     else version (PPC_Any)
     {
         alias ControlState = uint;
@@ -5292,7 +5330,7 @@  private:
     {
         alias ControlState = uint;
     }
-    else version (SPARC64)
+    else version (SPARC_Any)
     {
         alias ControlState = ulong;
     }
@@ -5480,13 +5518,8 @@  private:
     }
 }
 
-@system unittest
+version (D_HardFloat) @system unittest
 {
-    // GCC floating point emulation doesn't allow changing
-    // rounding modes, getting error bits etc
-    version (GNU) version (D_SoftFloat)
-        return;
-
     void ensureDefaults()
     {
         assert(FloatingPointControl.rounding
@@ -5500,15 +5533,12 @@  private:
     }
     ensureDefaults();
 
-    version (D_HardFloat)
     {
-        {
-            FloatingPointControl ctrl;
-            ctrl.rounding = FloatingPointControl.roundDown;
-            assert(FloatingPointControl.rounding == FloatingPointControl.roundDown);
-        }
-        ensureDefaults();
+        FloatingPointControl ctrl;
+        ctrl.rounding = FloatingPointControl.roundDown;
+        assert(FloatingPointControl.rounding == FloatingPointControl.roundDown);
     }
+    ensureDefaults();
 
     if (FloatingPointControl.hasExceptionTraps)
     {
@@ -5525,7 +5555,7 @@  private:
     ensureDefaults();
 }
 
-@system unittest // rounding
+version (D_HardFloat) @system unittest // rounding
 {
     import std.meta : AliasSeq;
 
@@ -6662,19 +6692,14 @@  if (isFloatingPoint!(F) && isIntegral!(G))
 
     assert(pow(x, neg1) == 1 / x);
 
-    version (X86_64)
-    {
-        pragma(msg, "test disabled on x86_64, see bug 5628");
-    }
-    else version (ARM)
-    {
-        pragma(msg, "test disabled on ARM, see bug 5628");
-    }
-    else version (GNU)
-    {
-        pragma(msg, "test disabled on GNU, see bug 5628");
-    }
-    else
+    // Test disabled on most targets.
+    // See https://issues.dlang.org/show_bug.cgi?id=5628
+    version (X86_64)   enum BUG5628 = false;
+    else version (ARM) enum BUG5628 = false;
+    else version (GNU) enum BUG5628 = false;
+    else               enum BUG5628 = true;
+
+    static if (BUG5628)
     {
         assert(pow(xd, neg2) == 1 / (x * x));
         assert(pow(xf, neg8) == 1 / ((x * x) * (x * x) * (x * x) * (x * x)));
diff --git a/libphobos/src/std/net/curl.d b/libphobos/src/std/net/curl.d
index 3465bdf8685..9d751411705 100644
--- a/libphobos/src/std/net/curl.d
+++ b/libphobos/src/std/net/curl.d
@@ -659,7 +659,7 @@  if (is(T == char) || is(T == ubyte))
             s.send(httpOK(req.bdy));
         });
         auto res = post(host ~ "/path", ["name1" : "value1", "name2" : "value2"]);
-        assert(res == "name1=value1&name2=value2");
+        assert(res == "name1=value1&name2=value2" || res == "name2=value2&name1=value1");
     }
 }
 
diff --git a/libphobos/src/std/stdio.d b/libphobos/src/std/stdio.d
index 9683c9862c3..91646e79c1a 100644
--- a/libphobos/src/std/stdio.d
+++ b/libphobos/src/std/stdio.d
@@ -4517,8 +4517,15 @@  Initialize with a message and an error code.
     }
 }
 
+enum StdFileHandle: string
+{
+    stdin  = "core.stdc.stdio.stdin",
+    stdout = "core.stdc.stdio.stdout",
+    stderr = "core.stdc.stdio.stderr",
+}
+
 // Undocumented but public because the std* handles are aliasing it.
-@property ref File makeGlobal(alias handle)()
+@property ref File makeGlobal(StdFileHandle _iob)()
 {
     __gshared File.Impl impl;
     __gshared File result;
@@ -4537,7 +4544,9 @@  Initialize with a message and an error code.
                 break;
             if (atomicOp!"+="(spinlock, 1) == 1)
             {
-                impl.handle = handle;
+                with (StdFileHandle)
+                    assert(_iob == stdin || _iob == stdout || _iob == stderr);
+                impl.handle = mixin(_iob);
                 result._p = &impl;
                 atomicOp!"+="(spinlock, uint.max / 2);
                 break;
@@ -4554,7 +4563,7 @@  Initialize with a message and an error code.
         it is thread un-safe to reassign `stdin` to a different `File` instance
         than the default.
 */
-alias stdin = makeGlobal!(core.stdc.stdio.stdin);
+alias stdin = makeGlobal!(StdFileHandle.stdin);
 
 ///
 @safe unittest
@@ -4582,7 +4591,7 @@  alias stdin = makeGlobal!(core.stdc.stdio.stdin);
         it is thread un-safe to reassign `stdout` to a different `File` instance
         than the default.
 */
-alias stdout = makeGlobal!(core.stdc.stdio.stdout);
+alias stdout = makeGlobal!(StdFileHandle.stdout);
 
 /**
     The standard error stream.
@@ -4591,7 +4600,7 @@  alias stdout = makeGlobal!(core.stdc.stdio.stdout);
         it is thread un-safe to reassign `stderr` to a different `File` instance
         than the default.
 */
-alias stderr = makeGlobal!(core.stdc.stdio.stderr);
+alias stderr = makeGlobal!(StdFileHandle.stderr);
 
 @system unittest
 {
diff --git a/libphobos/src/std/system.d b/libphobos/src/std/system.d
index f8c23b78e29..e0b3dee8dae 100644
--- a/libphobos/src/std/system.d
+++ b/libphobos/src/std/system.d
@@ -28,10 +28,11 @@  immutable
     {
         win32 = 1, /// Microsoft 32 bit Windows systems
         win64,     /// Microsoft 64 bit Windows systems
-        linux,     /// All Linux Systems
+        linux,     /// All Linux Systems, except for Android
         osx,       /// Mac OS X
         freeBSD,   /// FreeBSD
         netBSD,    /// NetBSD
+        dragonFlyBSD, /// DragonFlyBSD
         solaris,   /// Solaris
         android,   /// Android
         otherPosix /// Other Posix Systems
@@ -45,6 +46,7 @@  immutable
     else version (OSX)     OS os = OS.osx;
     else version (FreeBSD) OS os = OS.freeBSD;
     else version (NetBSD)  OS os = OS.netBSD;
+    else version (DragonFlyBSD) OS os = OS.dragonFlyBSD;
     else version (Posix)   OS os = OS.otherPosix;
     else static assert(0, "Unknown OS.");
 
diff --git a/libphobos/src/std/uri.d b/libphobos/src/std/uri.d
index 0852955a9b8..fcc902c8236 100644
--- a/libphobos/src/std/uri.d
+++ b/libphobos/src/std/uri.d
@@ -403,7 +403,8 @@  package string urlEncode(in string[string] values)
     string[string] a;
     assert(urlEncode(a) == "");
     assert(urlEncode(["name1" : "value1"]) == "name1=value1");
-    assert(urlEncode(["name1" : "value1", "name2" : "value2"]) == "name1=value1&name2=value2");
+    auto enc = urlEncode(["name1" : "value1", "name2" : "value2"]);
+    assert(enc == "name1=value1&name2=value2" || enc == "name2=value2&name1=value1");
 }
 
 /***************************