Skip to content

Commit

Permalink
libphobos: Merge upstream druntime d37ef985.
Browse files Browse the repository at this point in the history
Adds support for FreeBSD/x86 53-bit precision reals, updates bindings
for FreeBSD 12.x, and removes all support code and tests for the
extern(Pascal) calling convention.

Reviewed-on: dlang/druntime#3286
	     dlang/druntime#3287

libphobos/ChangeLog:

	* libdruntime/MERGE: Merge upstream druntime d37ef985.
	* libdruntime/Makefile.am (DRUNTIME_DSOURCES_FREEBSD): Add
	core/sys/freebsd/config.d
	* libdruntime/Makefile.in: Regenerate.
  • Loading branch information
ibuclaw committed Nov 27, 2020
1 parent 6ac67dd commit f886c4a
Show file tree
Hide file tree
Showing 13 changed files with 214 additions and 99 deletions.
2 changes: 1 addition & 1 deletion libphobos/libdruntime/MERGE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
5e4492c45172110b035591f5961b9f9f5adf6f13
d37ef985a97eb446371ab4b2315a52b87233fbf3

The first line of this file holds the git revision number of the last
merge done from the dlang/druntime repository.
20 changes: 10 additions & 10 deletions libphobos/libdruntime/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,16 @@ DRUNTIME_DSOURCES_DRAGONFLYBSD = core/sys/dragonflybsd/dlfcn.d \
core/sys/dragonflybsd/sys/mman.d core/sys/dragonflybsd/sys/socket.d \
core/sys/dragonflybsd/time.d

DRUNTIME_DSOURCES_FREEBSD = core/sys/freebsd/dlfcn.d \
core/sys/freebsd/execinfo.d core/sys/freebsd/netinet/in_.d \
core/sys/freebsd/pthread_np.d core/sys/freebsd/string.d \
core/sys/freebsd/sys/_bitset.d core/sys/freebsd/sys/_cpuset.d \
core/sys/freebsd/sys/cdefs.d core/sys/freebsd/sys/elf.d \
core/sys/freebsd/sys/elf32.d core/sys/freebsd/sys/elf64.d \
core/sys/freebsd/sys/elf_common.d core/sys/freebsd/sys/event.d \
core/sys/freebsd/sys/link_elf.d core/sys/freebsd/sys/mman.d \
core/sys/freebsd/sys/mount.d core/sys/freebsd/time.d \
core/sys/freebsd/unistd.d
DRUNTIME_DSOURCES_FREEBSD = core/sys/freebsd/config.d \
core/sys/freebsd/dlfcn.d core/sys/freebsd/execinfo.d \
core/sys/freebsd/netinet/in_.d core/sys/freebsd/pthread_np.d \
core/sys/freebsd/string.d core/sys/freebsd/sys/_bitset.d \
core/sys/freebsd/sys/_cpuset.d core/sys/freebsd/sys/cdefs.d \
core/sys/freebsd/sys/elf.d core/sys/freebsd/sys/elf32.d \
core/sys/freebsd/sys/elf64.d core/sys/freebsd/sys/elf_common.d \
core/sys/freebsd/sys/event.d core/sys/freebsd/sys/link_elf.d \
core/sys/freebsd/sys/mman.d core/sys/freebsd/sys/mount.d \
core/sys/freebsd/time.d core/sys/freebsd/unistd.d

DRUNTIME_DSOURCES_LINUX = core/sys/linux/config.d \
core/sys/linux/dlfcn.d core/sys/linux/elf.d core/sys/linux/epoll.d \
Expand Down
23 changes: 12 additions & 11 deletions libphobos/libdruntime/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ am__objects_7 = core/sys/dragonflybsd/dlfcn.lo \
am__objects_9 = core/sys/bionic/fcntl.lo core/sys/bionic/string.lo \
core/sys/bionic/unistd.lo
@DRUNTIME_OS_ANDROID_TRUE@am__objects_10 = $(am__objects_9)
am__objects_11 = core/sys/freebsd/dlfcn.lo \
am__objects_11 = core/sys/freebsd/config.lo core/sys/freebsd/dlfcn.lo \
core/sys/freebsd/execinfo.lo core/sys/freebsd/netinet/in_.lo \
core/sys/freebsd/pthread_np.lo core/sys/freebsd/string.lo \
core/sys/freebsd/sys/_bitset.lo \
Expand Down Expand Up @@ -861,16 +861,16 @@ DRUNTIME_DSOURCES_DRAGONFLYBSD = core/sys/dragonflybsd/dlfcn.d \
core/sys/dragonflybsd/sys/mman.d core/sys/dragonflybsd/sys/socket.d \
core/sys/dragonflybsd/time.d

DRUNTIME_DSOURCES_FREEBSD = core/sys/freebsd/dlfcn.d \
core/sys/freebsd/execinfo.d core/sys/freebsd/netinet/in_.d \
core/sys/freebsd/pthread_np.d core/sys/freebsd/string.d \
core/sys/freebsd/sys/_bitset.d core/sys/freebsd/sys/_cpuset.d \
core/sys/freebsd/sys/cdefs.d core/sys/freebsd/sys/elf.d \
core/sys/freebsd/sys/elf32.d core/sys/freebsd/sys/elf64.d \
core/sys/freebsd/sys/elf_common.d core/sys/freebsd/sys/event.d \
core/sys/freebsd/sys/link_elf.d core/sys/freebsd/sys/mman.d \
core/sys/freebsd/sys/mount.d core/sys/freebsd/time.d \
core/sys/freebsd/unistd.d
DRUNTIME_DSOURCES_FREEBSD = core/sys/freebsd/config.d \
core/sys/freebsd/dlfcn.d core/sys/freebsd/execinfo.d \
core/sys/freebsd/netinet/in_.d core/sys/freebsd/pthread_np.d \
core/sys/freebsd/string.d core/sys/freebsd/sys/_bitset.d \
core/sys/freebsd/sys/_cpuset.d core/sys/freebsd/sys/cdefs.d \
core/sys/freebsd/sys/elf.d core/sys/freebsd/sys/elf32.d \
core/sys/freebsd/sys/elf64.d core/sys/freebsd/sys/elf_common.d \
core/sys/freebsd/sys/event.d core/sys/freebsd/sys/link_elf.d \
core/sys/freebsd/sys/mman.d core/sys/freebsd/sys/mount.d \
core/sys/freebsd/time.d core/sys/freebsd/unistd.d

DRUNTIME_DSOURCES_LINUX = core/sys/linux/config.d \
core/sys/linux/dlfcn.d core/sys/linux/elf.d core/sys/linux/epoll.d \
Expand Down Expand Up @@ -1435,6 +1435,7 @@ core/sys/bionic/unistd.lo: core/sys/bionic/$(am__dirstamp)
core/sys/freebsd/$(am__dirstamp):
@$(MKDIR_P) core/sys/freebsd
@: > core/sys/freebsd/$(am__dirstamp)
core/sys/freebsd/config.lo: core/sys/freebsd/$(am__dirstamp)
core/sys/freebsd/dlfcn.lo: core/sys/freebsd/$(am__dirstamp)
core/sys/freebsd/execinfo.lo: core/sys/freebsd/$(am__dirstamp)
core/sys/freebsd/netinet/$(am__dirstamp):
Expand Down
15 changes: 4 additions & 11 deletions libphobos/libdruntime/core/demangle.d
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,6 @@ pure @safe:
F // D
U // C
W // Windows
V // Pascal
R // C++
FuncAttrs:
Expand Down Expand Up @@ -1089,10 +1088,6 @@ pure @safe:
popFront();
put( "extern (Windows) " );
break;
case 'V': // Pascal
popFront();
put( "extern (Pascal) " );
break;
case 'R': // C++
popFront();
put( "extern (C++) " );
Expand Down Expand Up @@ -2380,15 +2375,14 @@ private template isExternCPP(FT) if (is(FT == function))
private template hasPlainMangling(FT) if (is(FT == function))
{
enum lnk = __traits(getLinkage, FT);
// C || Pascal || Windows
enum hasPlainMangling = lnk == "C" || lnk == "Pascal" || lnk == "Windows";
// C || Windows
enum hasPlainMangling = lnk == "C" || lnk == "Windows";
}

@safe pure nothrow unittest
{
static extern(D) void fooD();
static extern(C) void fooC();
static extern(Pascal) void fooP();
static extern(Windows) void fooW();
static extern(C++) void fooCPP();

Expand All @@ -2399,13 +2393,11 @@ private template hasPlainMangling(FT) if (is(FT == function))
}
static assert(check!(typeof(fooD))(true, false, false));
static assert(check!(typeof(fooC))(false, false, true));
static assert(check!(typeof(fooP))(false, false, true));
static assert(check!(typeof(fooW))(false, false, true));
static assert(check!(typeof(fooCPP))(false, true, false));

static assert(__traits(compiles, mangleFunc!(typeof(&fooD))("")));
static assert(__traits(compiles, mangleFunc!(typeof(&fooC))("")));
static assert(__traits(compiles, mangleFunc!(typeof(&fooP))("")));
static assert(__traits(compiles, mangleFunc!(typeof(&fooW))("")));
static assert(!__traits(compiles, mangleFunc!(typeof(&fooCPP))("")));
}
Expand Down Expand Up @@ -2505,7 +2497,8 @@ version (unittest)
"pure @safe void testexpansion.s!(testexpansion.s!(int).s(int).Result).s(testexpansion.s!(int).s(int).Result).Result.foo()"],
["_D13testexpansion__T1sTSQw__TQjTiZQoFiZ6ResultZQBbFQBcZQq3fooMFNaNfZv",
"pure @safe void testexpansion.s!(testexpansion.s!(int).s(int).Result).s(testexpansion.s!(int).s(int).Result).Result.foo()"],
// ambiguity on 'V', template value argument or pascal function
// formerly ambiguous on 'V', template value argument or pascal function
// pascal functions have now been removed (in v2.095.0)
["_D3std4conv__T7enumRepTyAaTEQBa12experimental9allocator15building_blocks15stats_collector7OptionsVQCti64ZQDnyQDh",
"immutable(char[]) std.conv.enumRep!(immutable(char[]), std.experimental.allocator.building_blocks.stats_collector.Options, 64).enumRep"],
// symbol back reference to location with symbol back reference
Expand Down
11 changes: 9 additions & 2 deletions libphobos/libdruntime/core/internal/convert.d
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const(ubyte)[] toUbyte(T)(const ref T val) if (is(Unqual!T == float) || is(Unqua
{
if (__ctfe)
{
static if (T.mant_dig == float.mant_dig || T.mant_dig == double.mant_dig)
static if (floatFormat!T == FloatFormat.Float || floatFormat!T == FloatFormat.Double)
{
static if (is(T : ireal)) // https://issues.dlang.org/show_bug.cgi?id=19932
const f = val.im;
Expand Down Expand Up @@ -628,7 +628,14 @@ template floatFormat(T) if (is(T:real) || is(T:ireal))
static if (T.mant_dig == 24)
enum floatFormat = FloatFormat.Float;
else static if (T.mant_dig == 53)
enum floatFormat = FloatFormat.Double;
{
// Double precision, or real == double
static if (T.sizeof == double.sizeof)
enum floatFormat = FloatFormat.Double;
// 80-bit real with rounding precision set to 53 bits.
else static if (T.sizeof == real.sizeof)
enum floatFormat = FloatFormat.Real80;
}
else static if (T.mant_dig == 64)
enum floatFormat = FloatFormat.Real80;
else static if (T.mant_dig == 106)
Expand Down
24 changes: 24 additions & 0 deletions libphobos/libdruntime/core/sys/freebsd/config.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* D header file for FreeBSD
*
* Authors: Iain Buclaw
*/
module core.sys.freebsd.config;

version (FreeBSD):

public import core.sys.posix.config;

// https://svnweb.freebsd.org/base/head/sys/sys/param.h?view=markup
// __FreeBSD_version numbers are documented in the Porter's Handbook.
// NOTE: When adding newer versions of FreeBSD, verify all current versioned
// bindings are still compatible with the release.
version (FreeBSD_12) enum __FreeBSD_version = 1202000;
else version (FreeBSD_11) enum __FreeBSD_version = 1104000;
else version (FreeBSD_10) enum __FreeBSD_version = 1004000;
else version (FreeBSD_9) enum __FreeBSD_version = 903000;
else version (FreeBSD_8) enum __FreeBSD_version = 804000;
else static assert(false, "Unsupported version of FreeBSD");

// First version of FreeBSD to support 64-bit stat buffer.
enum INO64_FIRST = 1200031;
35 changes: 26 additions & 9 deletions libphobos/libdruntime/core/sys/freebsd/sys/event.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extern (C):
nothrow:
@nogc:

import core.sys.freebsd.config;
import core.stdc.stdint; // intptr_t, uintptr_t
import core.sys.posix.time; // timespec

Expand All @@ -38,19 +39,35 @@ enum
EVFILT_SYSCOUNT = 11,
}

extern(D) void EV_SET(kevent_t* kevp, typeof(kevent_t.tupleof) args)
static if (__FreeBSD_version >= 1200000)
{
*kevp = kevent_t(args);
struct kevent_t
{
uintptr_t ident;
short filter;
ushort flags;
uint fflags;
long data;
void* udata;
ulong[4] ext;
}
}
else
{
struct kevent_t
{
uintptr_t ident; /* identifier for this event */
short filter; /* filter for event */
ushort flags;
uint fflags;
intptr_t data;
void *udata; /* opaque user data identifier */
}
}

struct kevent_t
extern(D) void EV_SET(kevent_t* kevp, typeof(kevent_t.tupleof) args)
{
uintptr_t ident; /* identifier for this event */
short filter; /* filter for event */
ushort flags;
uint fflags;
intptr_t data;
void *udata; /* opaque user data identifier */
*kevp = kevent_t(args);
}

enum
Expand Down
14 changes: 12 additions & 2 deletions libphobos/libdruntime/core/sys/freebsd/sys/mount.d
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module core.sys.freebsd.sys.mount;

version (FreeBSD):

import core.sys.freebsd.config;
import core.stdc.config : c_long;
import core.sys.posix.sys.stat : stat_t;
import core.sys.posix.sys.types : uid_t;
Expand All @@ -32,8 +33,17 @@ struct fid
}

enum MFSNAMELEN = 16;
enum MNAMELEN = 88;
enum STATFS_VERSION = 0x20030518;

static if (__FreeBSD_version >= 1200000)
{
enum MNAMELEN = 1024;
enum STATFS_VERSION = 0x20140518;
}
else
{
enum MNAMELEN = 88;
enum STATFS_VERSION = 0x20030518;
}

struct statfs_t
{
Expand Down
33 changes: 26 additions & 7 deletions libphobos/libdruntime/core/sys/posix/dirent.d
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ else version (Darwin)
}
else version (FreeBSD)
{
import core.sys.freebsd.config;

// https://github.com/freebsd/freebsd/blob/master/sys/sys/dirent.h
enum
{
Expand All @@ -149,14 +151,31 @@ else version (FreeBSD)
DT_WHT = 14
}

align(4)
struct dirent
static if (__FreeBSD_version >= 1200000)
{
uint d_fileno;
ushort d_reclen;
ubyte d_type;
ubyte d_namlen;
char[256] d_name = 0;
struct dirent
{
ino_t d_fileno;
off_t d_off;
ushort d_reclen;
ubyte d_type;
ubyte d_pad0;
ushort d_namlen;
ushort d_pad1;
char[256] d_name = 0;
}
}
else
{
align(4)
struct dirent
{
uint d_fileno;
ushort d_reclen;
ubyte d_type;
ubyte d_namlen;
char[256] d_name = 0;
}
}

alias void* DIR;
Expand Down
Loading

0 comments on commit f886c4a

Please sign in to comment.