Backports ports committed to upstream phobos since the last sync.
Reviewed-on: https://github.com/dlang/phobos/pull/6947
From-SVN: r270296
-ef07932811de50a1d5810ea23462d127a60574a6
+cf95639ffd9ed6f3b9d10d98461b2fbd31615757
The first line of this file holds the git revision number of the last
merge done from the dlang/phobos repository.
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)
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)),
// 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)
{
/++
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.");
// - 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
{
{
return readLink("/proc/self/exe");
}
+ else version (DragonFlyBSD)
+ {
+ return readLink("/proc/curproc/file");
+ }
else version (Solaris)
{
import core.sys.posix.unistd : getpid;
{
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;
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; }
}
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)
{
// 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)
{
version = IeeeFlagsSupport;
}
+else version (RISCV_Any)
+{
+ version = IeeeFlagsSupport;
+}
else version (MIPS_Any)
{
version = IeeeFlagsSupport;
| 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
{
alias ControlState = uint;
}
+ else version (RISCV_Any)
+ {
+ alias ControlState = uint;
+ }
else version (X86_Any)
{
alias ControlState = ushort;
;
}
}
+ 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);
{
version = useSysctlbyname;
}
+else version (DragonFlyBSD)
+{
+ version = useSysctlbyname;
+}
else version (NetBSD)
{
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;
}
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();
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);
version = HAS_GETDELIM;
}
+version (DragonFlyBSD)
+{
+ version = GENERIC_IO;
+ version = HAS_GETDELIM;
+}
+
version (Solaris)
{
version = GENERIC_IO;