Port of phobos to DragonFlyBSD

Notes:
- FIXME message related to dragonfly malloc issue (issue reported on upstream dragonfly issue database)
This commit is contained in:
Diederik de Groot 2017-12-11 16:27:41 +01:00
parent 801fa1696b
commit 31ca73d58d
No known key found for this signature in database
GPG key ID: AFA728250A1BECD6
11 changed files with 88 additions and 10 deletions

View file

@ -13,7 +13,8 @@
# #
# make BUILD=debug unittest => builds all unittests (for debug) and runs them # 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 # make html => makes html documentation
# #
@ -25,10 +26,10 @@
################################################################################ ################################################################################
# Configurable stuff, usually from the command line # Configurable stuff, usually from the command line
# #
# OS can be linux, win32, win32wine, osx, or freebsd. The system will be # OS can be linux, win32, win32wine, osx, freebsd, netbsd or dragonflybsd.
# determined by using uname # The system will be determined by using uname
QUIET:= QUIET:=@
DEBUGGER=gdb DEBUGGER=gdb
GIT_HOME=https://github.com/dlang GIT_HOME=https://github.com/dlang

View file

@ -214,6 +214,22 @@ public:
hnsecsToUnixEpoch; 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) else version(Solaris)
{ {
static if (clockType == ClockType.second) static if (clockType == ClockType.second)

View file

@ -327,6 +327,7 @@ public:
{ {
version(FreeBSD) enum utcZone = "Etc/UTC"; version(FreeBSD) enum utcZone = "Etc/UTC";
else version(NetBSD) enum utcZone = "UTC"; else version(NetBSD) enum utcZone = "UTC";
else version(DragonFlyBSD) enum utcZone = "UTC";
else version(linux) enum utcZone = "UTC"; else version(linux) enum utcZone = "UTC";
else version(OSX) 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."); else static assert(0, "The location of the UTC timezone file on this Posix platform must be set.");

View file

@ -278,7 +278,7 @@ struct AlignedMallocator
/** /**
Forwards to $(D alignedReallocate(b, newSize, platformAlignment)). 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. alignment passed with `alignedAllocate` can be lost.
*/ */
@system @nogc nothrow @system @nogc nothrow
@ -375,6 +375,9 @@ version(Posix)
AlignedMallocator.instance.alignedReallocate(c, 32, 32); AlignedMallocator.instance.alignedReallocate(c, 32, 32);
assert(c.ptr); 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)); assert(!AlignedMallocator.instance.alignedReallocate(c, size_t.max, 4096));
AlignedMallocator.instance.deallocate(c); AlignedMallocator.instance.deallocate(c);
} }

View file

@ -1488,6 +1488,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R))
// - OS X, where the native filesystem (HFS+) stores filesystem // - OS X, where the native filesystem (HFS+) stores filesystem
// timestamps with 1-second precision. // timestamps with 1-second precision.
version (FreeBSD) {} else version (FreeBSD) {} else
version (DragonFlyBSD) {} else
version (OSX) {} else version (OSX) {} else
@system unittest @system unittest
{ {
@ -2779,6 +2780,10 @@ else version (NetBSD)
{ {
return readLink("/proc/self/exe"); return readLink("/proc/self/exe");
} }
else version (DragonFlyBSD)
{
return readLink("/proc/curproc/file");
}
else version (Solaris) else version (Solaris)
{ {
import core.sys.posix.unistd : getpid; import core.sys.posix.unistd : getpid;

View file

@ -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 else
{ {
static assert(0); static assert(0);

View file

@ -94,6 +94,10 @@ else version(FreeBSD)
{ {
version = useSysctlbyname; version = useSysctlbyname;
} }
else version(DragonFlyBSD)
{
version = useSysctlbyname;
}
else version(NetBSD) else version(NetBSD)
{ {
version = useSysctlbyname; version = useSysctlbyname;
@ -984,6 +988,10 @@ uint totalCPUsImpl() @nogc nothrow @trusted
{ {
auto nameStr = "hw.ncpu\0".ptr; auto nameStr = "hw.ncpu\0".ptr;
} }
else version(DragonFlyBSD)
{
auto nameStr = "hw.ncpu\0".ptr;
}
else version(NetBSD) else version(NetBSD)
{ {
auto nameStr = "hw.ncpu\0".ptr; auto nameStr = "hw.ncpu\0".ptr;

View file

@ -3970,7 +3970,7 @@ string expandTilde(string inputPath) nothrow
} }
if (errno != ERANGE && 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) errno != 0)
onOutOfMemoryError(); onOutOfMemoryError();

View file

@ -187,6 +187,14 @@ string formatSocketError(int err) @trusted
else else
return "Socket error " ~ to!string(err); 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) else version (Solaris)
{ {
auto errs = strerror_r(err, buf.ptr, buf.length); auto errs = strerror_r(err, buf.ptr, buf.length);

View file

@ -63,6 +63,12 @@ version (NetBSD)
version = HAS_GETDELIM; version = HAS_GETDELIM;
} }
version (DragonFlyBSD)
{
version = GENERIC_IO;
version = HAS_GETDELIM;
}
version (Solaris) version (Solaris)
{ {
version = GENERIC_IO; version = GENERIC_IO;

View file

@ -32,6 +32,7 @@ immutable
osx, /// Mac OS X osx, /// Mac OS X
freeBSD, /// FreeBSD freeBSD, /// FreeBSD
netBSD, /// NetBSD netBSD, /// NetBSD
dragonFlyBSD, /// DragonFlyBSD
solaris, /// Solaris solaris, /// Solaris
android, /// Android android, /// Android
otherPosix /// Other Posix Systems otherPosix /// Other Posix Systems
@ -45,6 +46,7 @@ immutable
else version(OSX) OS os = OS.osx; else version(OSX) OS os = OS.osx;
else version(FreeBSD) OS os = OS.freeBSD; else version(FreeBSD) OS os = OS.freeBSD;
else version(NetBSD) OS os = OS.netBSD; else version(NetBSD) OS os = OS.netBSD;
else version(DragonFlyBSD) OS os = OS.dragonFlyBSD;
else version(Posix) OS os = OS.otherPosix; else version(Posix) OS os = OS.otherPosix;
else static assert(0, "Unknown OS."); else static assert(0, "Unknown OS.");