Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions posix.mak
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand All @@ -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
Expand Down
16 changes: 16 additions & 0 deletions std/datetime/systime.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 5 additions & 4 deletions std/datetime/timezone.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
5 changes: 4 additions & 1 deletion std/experimental/allocator/mallocator.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down
5 changes: 5 additions & 0 deletions std/file.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down
28 changes: 28 additions & 0 deletions std/math.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record: I'm not a huge fan of copying blocks as this means a bug fix will very likely miss one of these bits.
Anyhow as far as I know is Walter a huge proponent of using version(A) and not of static if( A || B)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completely agree. I did see this 'argument' pop up several time in different PR's and Forum discussions. I even wanted to suggest a generic 'BSD' version flag, as they all have common origins, similar to the 'Posix' version. But i did not want to reopen this discussion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe we do away with the asm implementation and implement a better poly algorithm.

https://issues.dlang.org/show_bug.cgi?id=12084

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible too to put the implementation in a token string enum polyAsm = q{ asm pure nothrow @nogc { ... } }; and to mix it

Copy link
Contributor Author

@dkgroot dkgroot Dec 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this discussion should be had outside this PR. Sounds more like a structural (ie ASM) discussion, than pertaining to this particular PR (correct ?).

{
// 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);
Expand Down
8 changes: 8 additions & 0 deletions std/parallelism.d
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ else version(FreeBSD)
{
version = useSysctlbyname;
}
else version(DragonFlyBSD)
{
version = useSysctlbyname;
}
else version(NetBSD)
{
version = useSysctlbyname;
Expand Down Expand Up @@ -984,6 +988,10 @@ uint totalCPUsImpl() @nogc nothrow @trusted
{
auto nameStr = "hw.ncpu\0".ptr;
}
else version(DragonFlyBSD)
{
auto nameStr = "hw.ncpu\0".ptr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Off topic: this looks like a very old style. IIRC are strings literals always zero-terminated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know, maybe someone else can answer this one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's true, the string literals are always zero-terminated. I was wondering if something is also doing nameStr.length in which case it makes sense putting this \0 but it doesn't look like it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nemanja-boric-sociomantic
So should i rewrite this to: auto nameStr = "hw.ncpu".ptr;, or just leave it as is.

The surrounding lines are doing the same, though. and i do not want to correct them (Only DragonFlyBSD related lines should be touched in this PR).

Copy link
Contributor

@nemanja-boric-sociomantic nemanja-boric-sociomantic Dec 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave them as is IMHO and do this separately (meaning just leave the "hw.ncpu\0".

}
else version(NetBSD)
{
auto nameStr = "hw.ncpu\0".ptr;
Expand Down
2 changes: 1 addition & 1 deletion std/path.d
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
8 changes: 8 additions & 0 deletions std/socket.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions std/stdio.d
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ version (NetBSD)
version = HAS_GETDELIM;
}

version (DragonFlyBSD)
{
version = GENERIC_IO;
version = HAS_GETDELIM;
}

version (Solaris)
{
version = GENERIC_IO;
Expand Down
2 changes: 2 additions & 0 deletions std/system.d
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ immutable
osx, /// Mac OS X
freeBSD, /// FreeBSD
netBSD, /// NetBSD
dragonFlyBSD, /// DragonFlyBSD
solaris, /// Solaris
android, /// Android
otherPosix /// Other Posix Systems
Expand All @@ -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.");

Expand Down