From: Iain Buclaw Date: Thu, 11 Apr 2019 21:11:03 +0000 (+0000) Subject: libphobos: Merge upstream druntime 175bf5fc X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9607e404a5853c68bcfb8d1bab823736597409bc;p=gcc.git libphobos: Merge upstream druntime 175bf5fc Backports extern(C) bindings committed to upstream druntime since the last sync. Reviewed-on: https://github.com/dlang/druntime/pull/2552 From-SVN: r270295 --- diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE index 15a55ab612a..a7bbd3da964 100644 --- a/libphobos/libdruntime/MERGE +++ b/libphobos/libdruntime/MERGE @@ -1,4 +1,4 @@ -d57fa1ffaecc858229ed7a730e8486b59197dee5 +175bf5fc69d26fec60d533ff77f7e915fd5bb468 The first line of this file holds the git revision number of the last merge done from the dlang/druntime repository. diff --git a/libphobos/libdruntime/core/stdc/stdio.d b/libphobos/libdruntime/core/stdc/stdio.d index e708a51763c..6ce3f9d13e5 100644 --- a/libphobos/libdruntime/core/stdc/stdio.d +++ b/libphobos/libdruntime/core/stdc/stdio.d @@ -1643,9 +1643,6 @@ else version (CRuntime_Bionic) } else version (CRuntime_Musl) { - import core.sys.posix.sys.types : off_t; - /// - int fseeko(FILE *, off_t, int); @trusted { /// diff --git a/libphobos/libdruntime/core/stdc/time.d b/libphobos/libdruntime/core/stdc/time.d index 648f782601b..4a571e153bf 100644 --- a/libphobos/libdruntime/core/stdc/time.d +++ b/libphobos/libdruntime/core/stdc/time.d @@ -148,21 +148,22 @@ else } /// -double difftime(time_t time1, time_t time0); +pure double difftime(time_t time1, time_t time0); // MT-Safe /// -time_t mktime(tm* timeptr); +@system time_t mktime(scope tm* timeptr); // @system: MT-Safe env locale /// -time_t time(time_t* timer); +time_t time(scope time_t* timer); + /// -char* asctime(in tm* timeptr); +@system char* asctime(const scope tm* timeptr); // @system: MT-Unsafe race:asctime locale /// -char* ctime(in time_t* timer); +@system char* ctime(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf race:asctime env locale /// -tm* gmtime(in time_t* timer); +@system tm* gmtime(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf env locale /// -tm* localtime(in time_t* timer); +@system tm* localtime(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf env locale /// -@system size_t strftime(char* s, size_t maxsize, in char* format, in tm* timeptr); +@system size_t strftime(scope char* s, size_t maxsize, const scope char* format, const scope tm* timeptr); // @system: MT-Safe env locale version (Windows) { @@ -171,9 +172,9 @@ version (Windows) /// void _tzset(); // non-standard /// - @system char* _strdate(char* s); // non-standard + @system char* _strdate(return scope char* s); // non-standard /// - @system char* _strtime(char* s); // non-standard + @system char* _strtime(return scope char* s); // non-standard /// extern __gshared const(char)*[2] tzname; // non-standard diff --git a/libphobos/libdruntime/core/sync/condition.d b/libphobos/libdruntime/core/sync/condition.d index b6755f2d998..8afa8f7cc38 100644 --- a/libphobos/libdruntime/core/sync/condition.d +++ b/libphobos/libdruntime/core/sync/condition.d @@ -23,7 +23,12 @@ public import core.time; version (Windows) { private import core.sync.semaphore; - private import core.sys.windows.windows; + private import core.sys.windows.basetsd /+: HANDLE+/; + private import core.sys.windows.winbase /+: CloseHandle, CreateSemaphoreA, CRITICAL_SECTION, + DeleteCriticalSection, EnterCriticalSection, INFINITE, InitializeCriticalSection, + LeaveCriticalSection, ReleaseSemaphore, WAIT_OBJECT_0, WaitForSingleObject+/; + private import core.sys.windows.windef /+: BOOL, DWORD+/; + private import core.sys.windows.winerror /+: WAIT_TIMEOUT+/; } else version (Posix) { diff --git a/libphobos/libdruntime/core/sync/mutex.d b/libphobos/libdruntime/core/sync/mutex.d index 798f8412a02..024009f48aa 100644 --- a/libphobos/libdruntime/core/sync/mutex.d +++ b/libphobos/libdruntime/core/sync/mutex.d @@ -20,7 +20,9 @@ public import core.sync.exception; version (Windows) { - private import core.sys.windows.windows; + private import core.sys.windows.winbase /+: CRITICAL_SECTION, DeleteCriticalSection, + EnterCriticalSection, InitializeCriticalSection, LeaveCriticalSection, + TryEnterCriticalSection+/; } else version (Posix) { @@ -144,7 +146,7 @@ class Mutex : { import core.internal.abort : abort; !pthread_mutex_destroy(&m_hndl) || - abort("Error: pthread_mutex_init failed."); + abort("Error: pthread_mutex_destroy failed."); } this.__monitor = null; } @@ -318,7 +320,7 @@ unittest void useResource() shared @safe nothrow @nogc { mtx.lock_nothrow(); - cargo++; + (cast() cargo) += 1; mtx.unlock_nothrow(); } } @@ -370,14 +372,15 @@ unittest // should happen only from a single thread. (cast(Mutex) mtx).__dtor(); - // Verify that the underlying implementation has been destroyed - // by checking that locking is not possible. This assumes - // that the underlying implementation is well behaved - // and makes the object non-lockable upon destruction. - // The Bionic and Musl C runtimes and DragonFly don't appear to do so, so skip this test. + // Verify that the underlying implementation has been destroyed by checking + // that locking is not possible. This assumes that the underlying + // implementation is well behaved and makes the object non-lockable upon + // destruction. The Bionic, DragonFly, Musl, and Solaris C runtimes don't + // appear to do so, so skip this test. version (CRuntime_Bionic) {} else version (CRuntime_Musl) {} else version (DragonFlyBSD) {} else + version (Solaris) {} else assert(!mtx.tryLock_nothrow()); free(cast(void*) mtx); diff --git a/libphobos/libdruntime/core/sync/semaphore.d b/libphobos/libdruntime/core/sync/semaphore.d index 0d6ab70c6d1..56ac7dc3663 100644 --- a/libphobos/libdruntime/core/sync/semaphore.d +++ b/libphobos/libdruntime/core/sync/semaphore.d @@ -29,7 +29,11 @@ else version (WatchOS) version (Windows) { - private import core.sys.windows.windows; + private import core.sys.windows.basetsd /+: HANDLE+/; + private import core.sys.windows.winbase /+: CloseHandle, CreateSemaphoreA, INFINITE, + ReleaseSemaphore, WAIT_OBJECT_0, WaitForSingleObject+/; + private import core.sys.windows.windef /+: BOOL, DWORD+/; + private import core.sys.windows.winerror /+: WAIT_TIMEOUT+/; } else version (Darwin) { @@ -337,19 +341,17 @@ class Semaphore } -private: - version (Windows) - { - HANDLE m_hndl; - } - else version (Darwin) - { - semaphore_t m_hndl; - } - else version (Posix) - { - sem_t m_hndl; - } +protected: + + /// Aliases the operating-system-specific semaphore type. + version (Windows) alias Handle = HANDLE; + /// ditto + else version (Darwin) alias Handle = semaphore_t; + /// ditto + else version (Posix) alias Handle = sem_t; + + /// Handle to the system-specific semaphore. + Handle m_hndl; } diff --git a/libphobos/libdruntime/core/sys/posix/aio.d b/libphobos/libdruntime/core/sys/posix/aio.d index 47458160f2e..954d2c3cc46 100644 --- a/libphobos/libdruntime/core/sys/posix/aio.d +++ b/libphobos/libdruntime/core/sys/posix/aio.d @@ -93,6 +93,60 @@ else version (CRuntime_Musl) ubyte[32-2*(void*).sizeof] __dummy4; } } +else version (CRuntime_UClibc) +{ + import core.sys.posix.config; + import core.sys.posix.sys.types; + + struct aiocb + { + int aio_fildes; + int aio_lio_opcode; + int aio_reqprio; + void* aio_buf; //volatile + size_t aio_nbytes; + sigevent aio_sigevent; + + aiocb* __next_prio; + int __abs_prio; + int __policy; + int __error_code; + ssize_t __return_value; + + static if (__USE_LARGEFILE64) + { + off_t aio_offset; + ubyte[off64_t.sizeof - off_t.sizeof] __pad; + } + else + { + off64_t aio_offset; + } + ubyte[32] __unused; + } + + static if (__USE_LARGEFILE64) + { + struct aiocb64 + { + int aio_fildes; + int aio_lio_opcode; + int aio_reqprio; + void* aio_buf; //volatile + size_t aio_nbytes; + sigevent aio_sigevent; + + aiocb* __next_prio; + int __abs_prio; + int __policy; + int __error_code; + ssize_t __return_value; + + off64_t aio_offset; + ubyte[32] __unused; + } + } +} else version (Darwin) { struct aiocb @@ -210,6 +264,15 @@ else version (CRuntime_Musl) AIO_ALLDONE } } +else version (CRuntime_UClibc) +{ + enum + { + AIO_CANCELED, + AIO_NOTCANCELED, + AIO_ALLDONE + } +} else version (Darwin) { enum @@ -257,6 +320,15 @@ else version (CRuntime_Musl) LIO_NOP } } +else version (CRuntime_UClibc) +{ + enum + { + LIO_READ, + LIO_WRITE, + LIO_NOP + } +} else version (Darwin) { enum @@ -302,6 +374,14 @@ else version (CRuntime_Musl) LIO_NOWAIT } } +else version (CRuntime_UClibc) +{ + enum + { + LIO_WAIT, + LIO_NOWAIT + } +} else version (Darwin) { enum @@ -362,6 +442,40 @@ version (CRuntime_Glibc) int lio_listio(int mode, const(aiocb*)* aiocb_list, int nitems, sigevent* sevp); } } +version (CRuntime_UClibc) +{ + static if (__USE_LARGEFILE64) + { + int aio_read64(aiocb64* aiocbp); + int aio_write64(aiocb64* aiocbp); + int aio_fsync64(int op, aiocb64* aiocbp); + int aio_error64(const(aiocb64)* aiocbp); + ssize_t aio_return64(aiocb64* aiocbp); + int aio_suspend64(const(aiocb64*)* aiocb_list, int nitems, const(timespec)* timeout); + int aio_cancel64(int fd, aiocb64* aiocbp); + int lio_listio64(int mode, const(aiocb64*)* aiocb_list, int nitems, sigevent* sevp); + + alias aio_read = aio_read64; + alias aio_write = aio_write64; + alias aio_fsync = aio_fsync64; + alias aio_error = aio_error64; + alias aio_return = aio_return64; + alias aio_suspend = aio_suspend64; + alias aio_cancel = aio_cancel64; + alias lio_listio = lio_listio64; + } + else + { + int aio_read(aiocb* aiocbp); + int aio_write(aiocb* aiocbp); + int aio_fsync(int op, aiocb* aiocbp); + int aio_error(const(aiocb)* aiocbp); + ssize_t aio_return(aiocb* aiocbp); + int aio_suspend(const(aiocb*)* aiocb_list, int nitems, const(timespec)* timeout); + int aio_cancel(int fd, aiocb* aiocbp); + int lio_listio(int mode, const(aiocb*)* aiocb_list, int nitems, sigevent* sevp); + } +} else { int aio_read(aiocb* aiocbp); @@ -395,6 +509,26 @@ version (CRuntime_Glibc) void aio_init(const(aioinit)* init); } } +version (CRuntime_UClibc) +{ + static if (__USE_GNU) + { + /* To customize the implementation one can use the following struct. */ + struct aioinit + { + int aio_threads; + int aio_num; + int aio_locks; + int aio_usedba; + int aio_debug; + int aio_numusers; + int aio_idle_time; + int aio_reserved; + } + + void aio_init(const(aioinit)* init); + } +} else version (FreeBSD) { int aio_waitcomplete(aiocb** aiocb_list, const(timespec)* timeout); diff --git a/libphobos/libdruntime/core/sys/posix/fcntl.d b/libphobos/libdruntime/core/sys/posix/fcntl.d index 4b06600d9fa..2f1daf6ebc9 100644 --- a/libphobos/libdruntime/core/sys/posix/fcntl.d +++ b/libphobos/libdruntime/core/sys/posix/fcntl.d @@ -868,7 +868,7 @@ else version (CRuntime_UClibc) enum F_UNLCK = 2; enum F_WRLCK = 1; - version (X86_64) + version (X86_Any) { enum O_CREAT = 0x40; // octal 0100 enum O_EXCL = 0x80; // octal 0200 @@ -877,12 +877,13 @@ else version (CRuntime_UClibc) enum O_APPEND = 0x400; // octal 02000 enum O_NONBLOCK = 0x800; // octal 04000 + enum O_CLOEXEC = 0x80000; // octal 02000000 enum O_SYNC = 0x1000; // octal 010000 enum O_NDELAY = O_NONBLOCK; enum O_FSYNC = O_SYNC; enum O_ASYNC = 0x2000; // octal 020000 } - else version (MIPS32) + else version (MIPS_Any) { enum O_CREAT = 0x0100; enum O_EXCL = 0x0400; @@ -892,11 +893,12 @@ else version (CRuntime_UClibc) enum O_APPEND = 0x0008; enum O_SYNC = 0x0010; enum O_NONBLOCK = 0x0080; + enum O_CLOEXEC = 0x80000; // octal 02000000 enum O_NDELAY = O_NONBLOCK; enum O_FSYNC = O_SYNC; enum O_ASYNC = 0x1000; } - else version (ARM) + else version (ARM_Any) { enum O_CREAT = 0x40; // octal 0100 enum O_EXCL = 0x80; // octal 0200 @@ -905,6 +907,7 @@ else version (CRuntime_UClibc) enum O_APPEND = 0x400; // octal 02000 enum O_NONBLOCK = 0x800; // octal 04000 + enum O_CLOEXEC = 0x80000; // octal 02000000 enum O_SYNC = 0x1000; // octal 010000 enum O_NDELAY = O_NONBLOCK; enum O_FSYNC = O_SYNC; diff --git a/libphobos/libdruntime/core/sys/posix/stdio.d b/libphobos/libdruntime/core/sys/posix/stdio.d index 7dbfe9766ad..0c6a144f520 100644 --- a/libphobos/libdruntime/core/sys/posix/stdio.d +++ b/libphobos/libdruntime/core/sys/posix/stdio.d @@ -180,6 +180,37 @@ else version (CRuntime_UClibc) FILE* tmpfile(); } } +else version (Solaris) +{ + static if (__USE_FILE_OFFSET64 && __WORDSIZE != 64) + { + int fgetpos64(FILE*, fpos_t *); + alias fgetpos = fgetpos64; + + FILE* fopen64(in char*, in char*); + alias fopen = fopen64; + + FILE* freopen64(in char*, in char*, FILE*); + alias freopen = freopen64; + + int fseek(FILE*, c_long, int); + + int fsetpos64(FILE*, in fpos_t*); + alias fsetpos = fsetpos64; + + FILE* tmpfile64(); + alias tmpfile = tmpfile64; + } + else + { + int fgetpos(FILE*, fpos_t *); + FILE* fopen(in char*, in char*); + FILE* freopen(in char*, in char*, FILE*); + int fseek(FILE*, c_long, int); + int fsetpos(FILE*, in fpos_t*); + FILE* tmpfile(); + } +} // // C Extension (CX) @@ -246,6 +277,31 @@ else version (CRuntime_UClibc) off_t ftello(FILE*); } } +else version (Solaris) +{ + enum L_ctermid = 9; + enum L_cuserid = 9; + + static if (__USE_FILE_OFFSET64 && __WORDSIZE != 64) + { + int fseeko64(FILE*, off_t, int); + alias fseeko = fseeko64; + } + else + { + int fseeko(FILE*, off_t, int); + } + + static if (__USE_FILE_OFFSET64 && __WORDSIZE != 64) + { + off_t ftello64(FILE*); + alias ftello = ftello64; + } + else + { + off_t ftello(FILE*); + } +} else version (Posix) { int fseeko(FILE*, off_t, int); diff --git a/libphobos/libdruntime/core/sys/posix/sys/socket.d b/libphobos/libdruntime/core/sys/posix/sys/socket.d index d1ebad7318a..197f1d6f712 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/socket.d +++ b/libphobos/libdruntime/core/sys/posix/sys/socket.d @@ -1941,31 +1941,37 @@ else version (CRuntime_UClibc) int l_linger; } - version (X86_64) + version (X86_Any) { enum { SOCK_DGRAM = 2, SOCK_SEQPACKET = 5, - SOCK_STREAM = 1 + SOCK_STREAM = 1, + SOCK_CLOEXEC = 0x80000, // octal 02000000 + SOCK_NONBLOCK = 0x800 // octal 00004000 } } - else version (MIPS32) + else version (MIPS_Any) { enum { SOCK_DGRAM = 1, SOCK_SEQPACKET = 5, SOCK_STREAM = 2, + SOCK_CLOEXEC = 0x80000, // octal 02000000 + SOCK_NONBLOCK = 0x80 // octal 00000200 } } - else version (ARM) + else version (ARM_Any) { enum { SOCK_DGRAM = 2, SOCK_SEQPACKET = 5, - SOCK_STREAM = 1 + SOCK_STREAM = 1, + SOCK_CLOEXEC = 0x80000, // octal 02000000 + SOCK_NONBLOCK = 0x800 // octal 00004000 } } else @@ -1991,6 +1997,7 @@ else version (CRuntime_UClibc) SO_TYPE = 3, SOL_SOCKET = 1, + SOL_TCP = 6, SOMAXCONN = 128 } diff --git a/libphobos/libdruntime/core/sys/solaris/dlfcn.d b/libphobos/libdruntime/core/sys/solaris/dlfcn.d index 95afc89cec5..d23bdaa0b8d 100644 --- a/libphobos/libdruntime/core/sys/solaris/dlfcn.d +++ b/libphobos/libdruntime/core/sys/solaris/dlfcn.d @@ -9,6 +9,7 @@ module core.sys.solaris.dlfcn; version (Solaris): extern (C): nothrow: +@nogc: public import core.sys.posix.dlfcn; import core.stdc.config; @@ -109,4 +110,4 @@ struct Dl_serinfo Dl_serpath[1] dls_serpath; } -// FIXME: Dl_argsinfo, Dl_mapinfo, Dl_amd64_unwindinfo are missing \ No newline at end of file +// FIXME: Dl_argsinfo, Dl_mapinfo, Dl_amd64_unwindinfo are missing diff --git a/libphobos/libdruntime/core/sys/solaris/sys/link.d b/libphobos/libdruntime/core/sys/solaris/sys/link.d index e056cac5216..d9d47c09142 100644 --- a/libphobos/libdruntime/core/sys/solaris/sys/link.d +++ b/libphobos/libdruntime/core/sys/solaris/sys/link.d @@ -15,22 +15,22 @@ import core.stdc.config; struct Elf32_Dyn { Elf32_Sword d_tag; - union d_un + union _d_un { Elf32_Word d_val; Elf32_Addr d_ptr; Elf32_Off d_off; - } + } _d_un d_un; } struct Elf64_Dyn { Elf64_Xword d_tag; - union d_un + union _d_un { Elf64_Xword d_val; Elf64_Addr d_ptr; - } + } _d_un d_un; } enum DT_NULL = 0; diff --git a/libphobos/libdruntime/core/sys/windows/shlobj.d b/libphobos/libdruntime/core/sys/windows/shlobj.d index ff7f8985c35..19b4426edf7 100644 --- a/libphobos/libdruntime/core/sys/windows/shlobj.d +++ b/libphobos/libdruntime/core/sys/windows/shlobj.d @@ -708,7 +708,7 @@ static if (_WIN32_IE >= 0x500) { ULONG dwFlags; DWORD dwFileAttributes; ULONG dwReserved; - WCHAR *pwszExt = 0; + WCHAR *pwszExt = null; WCHAR[MAX_PATH] wszFile = 0; } alias SHCOLUMNDATA* LPSHCOLUMNDATA; diff --git a/libphobos/libdruntime/core/sys/windows/threadaux.d b/libphobos/libdruntime/core/sys/windows/threadaux.d index 4e887b7be4e..e3bdd400668 100644 --- a/libphobos/libdruntime/core/sys/windows/threadaux.d +++ b/libphobos/libdruntime/core/sys/windows/threadaux.d @@ -24,7 +24,7 @@ import core.stdc.stdlib; public import core.thread; extern(Windows) -HANDLE OpenThread(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwThreadId) nothrow; +HANDLE OpenThread(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwThreadId) nothrow @nogc; extern (C) extern __gshared int _tls_index; @@ -113,7 +113,7 @@ struct thread_aux } alias fnNtQuerySystemInformation = extern(Windows) - HRESULT function( uint SystemInformationClass, void* info, uint infoLength, uint* ReturnLength ) nothrow; + HRESULT function( uint SystemInformationClass, void* info, uint infoLength, uint* ReturnLength ) nothrow @nogc; enum ThreadBasicInformation = 0; @@ -129,7 +129,7 @@ struct thread_aux } alias fnNtQueryInformationThread = extern(Windows) - int function( HANDLE ThreadHandle, uint ThreadInformationClass, void* buf, uint size, uint* ReturnLength ) nothrow; + int function( HANDLE ThreadHandle, uint ThreadInformationClass, void* buf, uint size, uint* ReturnLength ) nothrow @nogc; enum SYNCHRONIZE = 0x00100000; enum THREAD_GET_CONTEXT = 8; @@ -138,7 +138,7 @@ struct thread_aux /////////////////////////////////////////////////////////////////// // get the thread environment block (TEB) of the thread with the given handle - static void** getTEB( HANDLE hnd ) nothrow + static void** getTEB( HANDLE hnd ) nothrow @nogc { HANDLE nthnd = GetModuleHandleA( "NTDLL" ); assert( nthnd, "cannot get module handle for ntdll" ); @@ -153,7 +153,7 @@ struct thread_aux } // get the thread environment block (TEB) of the thread with the given identifier - static void** getTEB( uint id ) nothrow + static void** getTEB( uint id ) nothrow @nogc { HANDLE hnd = OpenThread( THREAD_QUERY_INFORMATION, FALSE, id ); assert( hnd, "OpenThread failed" ); @@ -164,7 +164,7 @@ struct thread_aux } // get linear address of TEB of current thread - static void** getTEB() nothrow + static void** getTEB() nothrow @nogc { version (Win32) { @@ -210,21 +210,21 @@ struct thread_aux } // get the stack bottom (the top address) of the thread with the given handle - static void* getThreadStackBottom( HANDLE hnd ) nothrow + static void* getThreadStackBottom( HANDLE hnd ) nothrow @nogc { void** teb = getTEB( hnd ); return teb[1]; } // get the stack bottom (the top address) of the thread with the given identifier - static void* getThreadStackBottom( uint id ) nothrow + static void* getThreadStackBottom( uint id ) nothrow @nogc { void** teb = getTEB( id ); return teb[1]; } // create a thread handle with full access to the thread with the given identifier - static HANDLE OpenThreadHandle( uint id ) nothrow + static HANDLE OpenThreadHandle( uint id ) nothrow @nogc { return OpenThread( SYNCHRONIZE|THREAD_GET_CONTEXT|THREAD_QUERY_INFORMATION|THREAD_SUSPEND_RESUME, FALSE, id ); } diff --git a/libphobos/libdruntime/core/time.d b/libphobos/libdruntime/core/time.d index 5706c809931..1982122858e 100644 --- a/libphobos/libdruntime/core/time.d +++ b/libphobos/libdruntime/core/time.d @@ -85,7 +85,7 @@ import core.internal.string; version (Windows) { -import core.sys.windows.windows; +import core.sys.windows.winbase /+: QueryPerformanceCounter, QueryPerformanceFrequency+/; } else version (Posix) { @@ -195,7 +195,7 @@ version (CoreDdoc) enum ClockType extremely frequently (e.g. hundreds of thousands of times a second) but don't care about high precision, the coarse clock might be appropriate. - Currently, only Linux and FreeBSD support a coarser clock, and on other + Currently, only Linux and FreeBSD/DragonFlyBSD support a coarser clock, and on other platforms, it's treated as $(D ClockType.normal). +/ coarse = 2, @@ -207,7 +207,7 @@ version (CoreDdoc) enum ClockType more precise clock than the normal one, it's treated as equivalent to $(D ClockType.normal). - Currently, only FreeBSD supports a more precise clock, where it uses + Currently, only FreeBSD/DragonFlyBSD supports a more precise clock, where it uses $(D CLOCK_MONOTONIC_PRECISE) for the monotonic time and $(D CLOCK_REALTIME_PRECISE) for the wall clock time. +/ @@ -231,7 +231,7 @@ version (CoreDdoc) enum ClockType Uses a clock that has a precision of one second (contrast to the coarse clock, which has sub-second precision like the normal clock does). - FreeBSD is the only system which specifically has a clock set up for + FreeBSD/DragonFlyBSD are the only systems which specifically have a clock set up for this (it has $(D CLOCK_SECOND) to use with $(D clock_gettime) which takes advantage of an in-kernel cached value), but on other systems, the fastest function available will be used, and the resulting $(D SysTime) @@ -320,6 +320,16 @@ else version (NetBSD) enum ClockType precise = 3, second = 6, } +else version (DragonFlyBSD) enum ClockType +{ + normal = 0, + coarse = 2, + precise = 3, + second = 6, + uptime = 8, + uptimeCoarse = 9, + uptimePrecise = 10, +} else version (Solaris) enum ClockType { normal = 0, @@ -386,6 +396,20 @@ version (Posix) case second: assert(0); } } + else version (DragonFlyBSD) + { + import core.sys.dragonflybsd.time; + with(ClockType) final switch (clockType) + { + case coarse: return CLOCK_MONOTONIC_FAST; + case normal: return CLOCK_MONOTONIC; + case precise: return CLOCK_MONOTONIC_PRECISE; + case uptime: return CLOCK_UPTIME; + case uptimeCoarse: return CLOCK_UPTIME_FAST; + case uptimePrecise: return CLOCK_UPTIME_PRECISE; + case second: assert(0); + } + } else version (Solaris) { import core.sys.solaris.time; @@ -451,6 +475,8 @@ unittest Examples: -------------------- +import std.datetime; + assert(dur!"days"(12) == dur!"hnsecs"(10_368_000_000_000L)); assert(dur!"hnsecs"(27) == dur!"hnsecs"(27)); assert(std.datetime.Date(2010, 9, 7) + dur!"days"(5) == diff --git a/libphobos/libdruntime/gc/os.d b/libphobos/libdruntime/gc/os.d index daac0b8d9d8..cfef7f3f665 100644 --- a/libphobos/libdruntime/gc/os.d +++ b/libphobos/libdruntime/gc/os.d @@ -16,7 +16,8 @@ module gc.os; version (Windows) { - import core.sys.windows.windows; + import core.sys.windows.winbase : GetCurrentThreadId, VirtualAlloc, VirtualFree; + import core.sys.windows.winnt : MEM_COMMIT, MEM_RELEASE, MEM_RESERVE, PAGE_READWRITE; alias int pthread_t; @@ -40,9 +41,11 @@ else version (Posix) import core.sys.posix.sys.mman; version (FreeBSD) import core.sys.freebsd.sys.mman : MAP_ANON; + version (DragonFlyBSD) import core.sys.dragonflybsd.sys.mman : MAP_ANON; version (NetBSD) import core.sys.netbsd.sys.mman : MAP_ANON; version (CRuntime_Glibc) import core.sys.linux.sys.mman : MAP_ANON; version (Darwin) import core.sys.darwin.sys.mman : MAP_ANON; + version (CRuntime_UClibc) import core.sys.linux.sys.mman : MAP_ANON; import core.stdc.stdlib; //version = GC_Use_Alloc_MMap; @@ -170,7 +173,7 @@ version (Windows) return false; else { - import core.sys.windows.windows; + import core.sys.windows.winbase : GlobalMemoryStatus, MEMORYSTATUS; MEMORYSTATUS stat; GlobalMemoryStatus(&stat); // Less than 5 % of virtual address space available