diff --git a/posix.mak b/posix.mak index 9e34c3f1211..8fb1a71d60f 100644 --- a/posix.mak +++ b/posix.mak @@ -13,7 +13,8 @@ # # make BUILD=debug unittest => builds all unittests (for debug) and runs them # -# make DEBUGGER=ddd std/XXXXX.debug => builds the module XXXXX and executes it in the debugger ddd +# make DEBUGGER=ddd std/XXXXX.debug => builds the module XXXXX and executes it +# in the debugger ddd # # make html => makes html documentation # @@ -25,10 +26,10 @@ ################################################################################ # Configurable stuff, usually from the command line # -# OS can be linux, win32, win32wine, osx, or freebsd. The system will be -# determined by using uname +# OS can be linux, win32, win32wine, osx, freebsd, netbsd or dragonflybsd. +# The system will be determined by using uname -QUIET:= +QUIET:=@ DEBUGGER=gdb GIT_HOME=https://github.com/dlang diff --git a/std/datetime/systime.d b/std/datetime/systime.d index 0c7ccebc159..48fa8325144 100644 --- a/std/datetime/systime.d +++ b/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/std/datetime/timezone.d b/std/datetime/timezone.d index 4743292c9c5..1a6e3d37d35 100644 --- a/std/datetime/timezone.d +++ b/std/datetime/timezone.d @@ -325,10 +325,11 @@ 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 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)), diff --git a/std/experimental/allocator/mallocator.d b/std/experimental/allocator/mallocator.d index e62b9211e88..8befa436b35 100644 --- a/std/experimental/allocator/mallocator.d +++ b/std/experimental/allocator/mallocator.d @@ -278,7 +278,7 @@ struct AlignedMallocator /** Forwards to $(D alignedReallocate(b, newSize, platformAlignment)). - Should be used with bocks obtained with `allocate` otherwise the custom + Should be used with blocks obtained with `allocate` otherwise the custom alignment passed with `alignedAllocate` can be lost. */ @system @nogc nothrow @@ -375,6 +375,9 @@ version(Posix) AlignedMallocator.instance.alignedReallocate(c, 32, 32); assert(c.ptr); + version (DragonFlyBSD) {} else /* FIXME: Malloc on DragonFly does not return NULL when allocating more than UINTPTR_MAX + * $(LINK: https://bugs.dragonflybsd.org/issues/3114, dragonfly bug report) + * $(LINK: https://github.com/dlang/druntime/pull/1999#discussion_r157536030, PR Discussion) */ assert(!AlignedMallocator.instance.alignedReallocate(c, size_t.max, 4096)); AlignedMallocator.instance.deallocate(c); } diff --git a/std/file.d b/std/file.d index d9a8d882c3e..fc0f15b6f70 100644 --- a/std/file.d +++ b/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; diff --git a/std/math.d b/std/math.d index 911d5f1526e..b029c50d375 100644 --- a/std/math.d +++ b/std/math.d @@ -7444,6 +7444,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/std/parallelism.d b/std/parallelism.d index 5d3f731dc50..2f2c0e33053 100644 --- a/std/parallelism.d +++ b/std/parallelism.d @@ -94,6 +94,10 @@ else version(FreeBSD) { version = useSysctlbyname; } +else version(DragonFlyBSD) +{ + version = useSysctlbyname; +} else version(NetBSD) { version = useSysctlbyname; @@ -984,6 +988,10 @@ uint totalCPUsImpl() @nogc nothrow @trusted { 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/std/path.d b/std/path.d index f999453d006..c896421387e 100644 --- a/std/path.d +++ b/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/std/socket.d b/std/socket.d index fcbc39db700..361ec73daa3 100644 --- a/std/socket.d +++ b/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/std/stdio.d b/std/stdio.d index d647177e28e..79397bac75e 100644 --- a/std/stdio.d +++ b/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; diff --git a/std/system.d b/std/system.d index 1af5013f2b0..dbc0f846986 100644 --- a/std/system.d +++ b/std/system.d @@ -32,6 +32,7 @@ immutable 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.");