Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 8fe321d

Browse files
committed
Port of druntime to DragonFlyBSD
1 parent 97d25f2 commit 8fe321d

34 files changed

Lines changed: 847 additions & 11 deletions

posix.mak

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ endif
5757

5858
# build with shared library support
5959
# (defaults to true on supported platforms, can be overridden w/ make SHARED=0)
60-
SHARED=$(if $(findstring $(OS),linux freebsd),1,)
60+
SHARED=$(if $(findstring $(OS),linux freebsd dragonflybsd),1,)
6161

6262
LINKDL=$(if $(findstring $(OS),linux),-L-ldl,)
6363

@@ -204,7 +204,7 @@ $(IMPDIR)/%.d : src/%.d
204204
######################## Build DMD if non-existent ##############################
205205

206206
$(DMD):
207-
make -C $(DMD_DIR)/src -f posix.mak BUILD=$(BUILD) OS=$(OS) MODEL=$(MODEL)
207+
$(MAKE) -C $(DMD_DIR)/src -f posix.mak BUILD=$(BUILD) OS=$(OS) MODEL=$(MODEL)
208208

209209
################### C/ASM Targets ############################
210210

src/core/runtime.d

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,8 @@ extern (C) UnitTestResult runModuleUnitTests()
588588
import core.sys.freebsd.execinfo;
589589
else version( NetBSD )
590590
import core.sys.netbsd.execinfo;
591+
else version( DragonFlyBSD )
592+
import core.sys.dragonflybsd.execinfo;
591593
else version( Windows )
592594
import core.sys.windows.stacktrace;
593595
else version( Solaris )
@@ -705,6 +707,8 @@ Throwable.TraceInfo defaultTraceHandler( void* ptr = null )
705707
import core.sys.freebsd.execinfo;
706708
else version( NetBSD )
707709
import core.sys.netbsd.execinfo;
710+
else version( DragonFlyBSD )
711+
import core.sys.dragonflybsd.execinfo;
708712
else version( Windows )
709713
import core.sys.windows.stacktrace;
710714
else version( Solaris )
@@ -791,6 +795,7 @@ Throwable.TraceInfo defaultTraceHandler( void* ptr = null )
791795

792796
version(linux) enum enableDwarf = true;
793797
else version(FreeBSD) enum enableDwarf = true;
798+
else version(DragonFlyBSD) enum enableDwarf = true;
794799
else enum enableDwarf = false;
795800

796801
static if (enableDwarf)
@@ -914,6 +919,18 @@ Throwable.TraceInfo defaultTraceHandler( void* ptr = null )
914919
symEnd = eptr - buf.ptr;
915920
}
916921
}
922+
else version( DragonFlyBSD )
923+
{
924+
// format is: 0x00000000 <_D6module4funcAFZv+0x78> at module
925+
auto bptr = cast(char*) memchr( buf.ptr, '<', buf.length );
926+
auto eptr = cast(char*) memchr( buf.ptr, '+', buf.length );
927+
928+
if( bptr++ && eptr )
929+
{
930+
symBeg = bptr - buf.ptr;
931+
symEnd = eptr - buf.ptr;
932+
}
933+
}
917934
else version( Solaris )
918935
{
919936
// format is object'symbol+offset [pc]

src/core/stdc/assert_.d

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ else version (FreeBSD)
5353
*/
5454
void __assert(const(char)* exp, const(char)* file, uint line);
5555
}
56+
else version (DragonFlyBSD)
57+
{
58+
/***
59+
* Assert failure function in the DragonFlyBSD C library.
60+
*/
61+
void __assert(const(char)* exp, const(char)* file, uint line);
62+
}
5663
else version (CRuntime_Glibc)
5764
{
5865
/***

src/core/stdc/config.d

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ else version( DigitalMars )
129129
alias real c_long_double;
130130
else version( NetBSD )
131131
alias real c_long_double;
132+
else version( DragonFlyBSD )
133+
alias real c_long_double;
132134
else version( Solaris )
133135
alias real c_long_double;
134136
else version( Darwin )

src/core/stdc/errno.d

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ else version (FreeBSD)
5959
alias errno = __error;
6060
}
6161
}
62+
else version (DragonFlyBSD)
63+
{
64+
pragma(mangle, "errno") extern int __errno;
65+
ref int errno() { return __errno;}
66+
}
6267
else version (CRuntime_Bionic)
6368
{
6469
extern (C)
@@ -1822,6 +1827,109 @@ else version( OpenBSD )
18221827
enum ENOTSUP = 91; /// Not supported
18231828
enum ELAST = 91; /// Must be equal largest errno
18241829
}
1830+
else version( DragonFlyBSD )
1831+
{
1832+
enum EPERM = 1; /// Operation not permitted
1833+
enum ENOENT = 2; /// No such file or directory
1834+
enum ESRCH = 3; /// No such process
1835+
enum EINTR = 4; /// Interrupted system call
1836+
enum EIO = 5; /// Input/output error
1837+
enum ENXIO = 6; /// Device not configured
1838+
enum E2BIG = 7; /// Argument list too long
1839+
enum ENOEXEC = 8; /// Exec format error
1840+
enum EBADF = 9; /// Bad file descriptor
1841+
enum ECHILD = 10; /// No child processes
1842+
enum EDEADLK = 11; /// Resource deadlock avoided
1843+
enum ENOMEM = 12; /// Cannot allocate memory
1844+
enum EACCES = 13; /// Permission denied
1845+
enum EFAULT = 14; /// Bad address
1846+
enum ENOTBLK = 15; /// Block device required
1847+
enum EBUSY = 16; /// Device busy
1848+
enum EEXIST = 17; /// File exists
1849+
enum EXDEV = 18; /// Cross-device link
1850+
enum ENODEV = 19; /// Operation not supported by device
1851+
enum ENOTDIR = 20; /// Not a directory
1852+
enum EISDIR = 21; /// Is a directory
1853+
enum EINVAL = 22; /// Invalid argument
1854+
enum ENFILE = 23; /// Too many open files in system
1855+
enum EMFILE = 24; /// Too many open files
1856+
enum ENOTTY = 25; /// Inappropriate ioctl for device
1857+
enum ETXTBSY = 26; /// Text file busy
1858+
enum EFBIG = 27; /// File too large
1859+
enum ENOSPC = 28; /// No space left on device
1860+
enum ESPIPE = 29; /// Illegal seek
1861+
enum EROFS = 30; /// Read-only file system
1862+
enum EMLINK = 31; /// Too many links
1863+
enum EPIPE = 32; /// Broken pipe
1864+
enum EDOM = 33; /// Numerical argument out of domain
1865+
enum ERANGE = 34; /// Result too large
1866+
enum EAGAIN = 35; /// Resource temporarily unavailable
1867+
enum EWOULDBLOCK = EAGAIN; /// Operation would block
1868+
enum EINPROGRESS = 36; /// Operation now in progress
1869+
enum EALREADY = 37; /// Operation already in progress
1870+
enum ENOTSOCK = 38; /// Socket operation on non-socket
1871+
enum EDESTADDRREQ = 39; /// Destination address required
1872+
enum EMSGSIZE = 40; /// Message too long
1873+
enum EPROTOTYPE = 41; /// Protocol wrong type for socket
1874+
enum ENOPROTOOPT = 42; /// Protocol not available
1875+
enum EPROTONOSUPPORT = 43; /// Protocol not supported
1876+
enum ENOTSUP = 45; /// Operation not supported
1877+
enum EOPNOTSUPP = ENOTSUP; /// Operation not supported on socket
1878+
enum EPFNOSUPPORT = 46; /// Protocol family not supported
1879+
enum EAFNOSUPPORT = 47; /// Address family not supported by protocol family
1880+
enum EADDRINUSE = 48; /// Address already in use
1881+
enum EADDRNOTAVAIL = 49; /// Can't assign requested address
1882+
enum ENETDOWN = 50; /// Network is down
1883+
enum ENETUNREACH = 51; /// Network is unreachable
1884+
enum ENETRESET = 52; /// Network dropped connection on reset
1885+
enum ECONNABORTED = 53; /// Software caused connection abort
1886+
enum ECONNRESET = 54; /// Connection reset by peer
1887+
enum ENOBUFS = 55; /// No buffer space available
1888+
enum EISCONN = 56; /// Socket is already connected
1889+
enum ENOTCONN = 57; /// Socket is not connected
1890+
enum ESHUTDOWN = 58; /// Can't send after socket shutdown
1891+
enum ETOOMANYREFS = 59; /// Too many refrences; can't splice
1892+
enum ETIMEDOUT = 60; /// Operation timed out
1893+
enum ECONNREFUSED = 61; /// Connection refused
1894+
enum ELOOP = 62; /// Too many levels of symbolic links
1895+
enum ENAMETOOLONG = 63; /// File name too long
1896+
enum EHOSTUNREACH = 65; /// No route to host
1897+
enum ENOTEMPTY = 66; /// Directory not empty
1898+
enum EPROCLIM = 67; /// Too many processes
1899+
enum EUSERS = 68; /// Too many users
1900+
enum EDQUOT = 69; /// Disc quota exceeded
1901+
enum ESTALE = 70; /// Stale NFS file handle
1902+
enum EREMOTE = 71; /// Too many levels of remote in path
1903+
enum EBADRPC = 72; /// RPC struct is bad
1904+
enum ERPCMISMATCH = 73; /// RPC version wrong
1905+
enum EPROGUNAVAIL = 74; /// RPC prog. not avail
1906+
enum EPROGMISMATCH = 75; /// Program version wrong
1907+
enum EPROCUNAVAIL = 76; /// Bad procedure for program
1908+
enum ENOLCK = 77; /// No locks available
1909+
enum ENOSYS = 78; /// Function not implemented
1910+
enum EFTYPE = 79; /// Inappropriate file type or format
1911+
enum EAUTH = 80; /// Authentication error
1912+
enum ENEEDAUTH = 81; /// Need authenticator
1913+
enum EIDRM = 82; /// Itendifier removed
1914+
enum ENOMSG = 83; /// No message of desired type
1915+
enum EOVERFLOW = 84; /// Value too large to be stored in data type
1916+
enum ECANCELED = 85; /// Operation canceled
1917+
enum EILSEQ = 86; /// Illegal byte sequence
1918+
enum ENOATTR = 87; /// Attribute not found
1919+
enum EDOOFUS = 88; /// Programming error
1920+
enum EBADMSG = 89; /// Bad message
1921+
enum EMULTIHOP = 90; /// Multihop attempted
1922+
enum ENOLINK = 91; /// Link has been severed
1923+
enum EPROTO = 92; /// Protocol error
1924+
enum ENOMEDIUM = 93;
1925+
enum EUNUSED94 = 94;
1926+
enum EUNUSED95 = 95;
1927+
enum EUNUSED96 = 96;
1928+
enum EUNUSED97 = 97;
1929+
enum EUNUSED98 = 98;
1930+
enum EASYNC = 99;
1931+
enum ELAST = 99; /// Must be equal largest errno
1932+
}
18251933
else version (Solaris)
18261934
{
18271935
enum EPERM = 1 /** Not super-user */;

src/core/stdc/fenv.d

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,24 @@ else version ( OpenBSD )
263263

264264
alias fexcept_t = uint;
265265
}
266+
else version ( DragonFlyBSD )
267+
{
268+
struct fenv_t
269+
{
270+
struct _x87
271+
{
272+
uint control;
273+
uint status;
274+
uint tag;
275+
uint[4] others;
276+
};
277+
_x87 x87;
278+
279+
uint mxcsr;
280+
}
281+
282+
alias uint fexcept_t;
283+
}
266284
else version( CRuntime_Bionic )
267285
{
268286
version(X86)
@@ -649,6 +667,12 @@ else version( OpenBSD )
649667
///
650668
enum FE_DFL_ENV = &__fe_dfl_env;
651669
}
670+
else version( DragonFlyBSD )
671+
{
672+
private extern const fenv_t __fe_dfl_env;
673+
///
674+
enum FE_DFL_ENV = &__fe_dfl_env;
675+
}
652676
else version( CRuntime_Bionic )
653677
{
654678
private extern const fenv_t __fe_dfl_env;

src/core/stdc/locale.d

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,23 @@ else version(OpenBSD)
169169
///
170170
enum LC_MESSAGES = 6;
171171
}
172+
else version(DragonFlyBSD)
173+
{
174+
///
175+
enum LC_ALL = 0;
176+
///
177+
enum LC_COLLATE = 1;
178+
///
179+
enum LC_CTYPE = 2;
180+
///
181+
enum LC_MONETARY = 3;
182+
///
183+
enum LC_NUMERIC = 4;
184+
///
185+
enum LC_TIME = 5;
186+
///
187+
enum LC_MESSAGES = 6;
188+
}
172189
else version(CRuntime_Bionic)
173190
{
174191
enum

0 commit comments

Comments
 (0)