Commit 9607e404 by Iain Buclaw

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
parent 258ad811
d57fa1ffaecc858229ed7a730e8486b59197dee5 175bf5fc69d26fec60d533ff77f7e915fd5bb468
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the dlang/druntime repository. merge done from the dlang/druntime repository.
...@@ -1643,9 +1643,6 @@ else version (CRuntime_Bionic) ...@@ -1643,9 +1643,6 @@ else version (CRuntime_Bionic)
} }
else version (CRuntime_Musl) else version (CRuntime_Musl)
{ {
import core.sys.posix.sys.types : off_t;
///
int fseeko(FILE *, off_t, int);
@trusted @trusted
{ {
/// ///
......
...@@ -148,21 +148,22 @@ else ...@@ -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) version (Windows)
{ {
...@@ -171,9 +172,9 @@ version (Windows) ...@@ -171,9 +172,9 @@ version (Windows)
/// ///
void _tzset(); // non-standard 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 extern __gshared const(char)*[2] tzname; // non-standard
......
...@@ -23,7 +23,12 @@ public import core.time; ...@@ -23,7 +23,12 @@ public import core.time;
version (Windows) version (Windows)
{ {
private import core.sync.semaphore; 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) else version (Posix)
{ {
......
...@@ -20,7 +20,9 @@ public import core.sync.exception; ...@@ -20,7 +20,9 @@ public import core.sync.exception;
version (Windows) version (Windows)
{ {
private import core.sys.windows.windows; private import core.sys.windows.winbase /+: CRITICAL_SECTION, DeleteCriticalSection,
EnterCriticalSection, InitializeCriticalSection, LeaveCriticalSection,
TryEnterCriticalSection+/;
} }
else version (Posix) else version (Posix)
{ {
...@@ -144,7 +146,7 @@ class Mutex : ...@@ -144,7 +146,7 @@ class Mutex :
{ {
import core.internal.abort : abort; import core.internal.abort : abort;
!pthread_mutex_destroy(&m_hndl) || !pthread_mutex_destroy(&m_hndl) ||
abort("Error: pthread_mutex_init failed."); abort("Error: pthread_mutex_destroy failed.");
} }
this.__monitor = null; this.__monitor = null;
} }
...@@ -318,7 +320,7 @@ unittest ...@@ -318,7 +320,7 @@ unittest
void useResource() shared @safe nothrow @nogc void useResource() shared @safe nothrow @nogc
{ {
mtx.lock_nothrow(); mtx.lock_nothrow();
cargo++; (cast() cargo) += 1;
mtx.unlock_nothrow(); mtx.unlock_nothrow();
} }
} }
...@@ -370,14 +372,15 @@ unittest ...@@ -370,14 +372,15 @@ unittest
// should happen only from a single thread. // should happen only from a single thread.
(cast(Mutex) mtx).__dtor(); (cast(Mutex) mtx).__dtor();
// Verify that the underlying implementation has been destroyed // Verify that the underlying implementation has been destroyed by checking
// by checking that locking is not possible. This assumes // that locking is not possible. This assumes that the underlying
// that the underlying implementation is well behaved // implementation is well behaved and makes the object non-lockable upon
// and makes the object non-lockable upon destruction. // destruction. The Bionic, DragonFly, Musl, and Solaris C runtimes don't
// The Bionic and Musl C runtimes and DragonFly don't appear to do so, so skip this test. // appear to do so, so skip this test.
version (CRuntime_Bionic) {} else version (CRuntime_Bionic) {} else
version (CRuntime_Musl) {} else version (CRuntime_Musl) {} else
version (DragonFlyBSD) {} else version (DragonFlyBSD) {} else
version (Solaris) {} else
assert(!mtx.tryLock_nothrow()); assert(!mtx.tryLock_nothrow());
free(cast(void*) mtx); free(cast(void*) mtx);
......
...@@ -29,7 +29,11 @@ else version (WatchOS) ...@@ -29,7 +29,11 @@ else version (WatchOS)
version (Windows) 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) else version (Darwin)
{ {
...@@ -337,19 +341,17 @@ class Semaphore ...@@ -337,19 +341,17 @@ class Semaphore
} }
private: protected:
version (Windows)
{ /// Aliases the operating-system-specific semaphore type.
HANDLE m_hndl; version (Windows) alias Handle = HANDLE;
} /// ditto
else version (Darwin) else version (Darwin) alias Handle = semaphore_t;
{ /// ditto
semaphore_t m_hndl; else version (Posix) alias Handle = sem_t;
}
else version (Posix) /// Handle to the system-specific semaphore.
{ Handle m_hndl;
sem_t m_hndl;
}
} }
......
...@@ -93,6 +93,60 @@ else version (CRuntime_Musl) ...@@ -93,6 +93,60 @@ else version (CRuntime_Musl)
ubyte[32-2*(void*).sizeof] __dummy4; 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) else version (Darwin)
{ {
struct aiocb struct aiocb
...@@ -210,6 +264,15 @@ else version (CRuntime_Musl) ...@@ -210,6 +264,15 @@ else version (CRuntime_Musl)
AIO_ALLDONE AIO_ALLDONE
} }
} }
else version (CRuntime_UClibc)
{
enum
{
AIO_CANCELED,
AIO_NOTCANCELED,
AIO_ALLDONE
}
}
else version (Darwin) else version (Darwin)
{ {
enum enum
...@@ -257,6 +320,15 @@ else version (CRuntime_Musl) ...@@ -257,6 +320,15 @@ else version (CRuntime_Musl)
LIO_NOP LIO_NOP
} }
} }
else version (CRuntime_UClibc)
{
enum
{
LIO_READ,
LIO_WRITE,
LIO_NOP
}
}
else version (Darwin) else version (Darwin)
{ {
enum enum
...@@ -302,6 +374,14 @@ else version (CRuntime_Musl) ...@@ -302,6 +374,14 @@ else version (CRuntime_Musl)
LIO_NOWAIT LIO_NOWAIT
} }
} }
else version (CRuntime_UClibc)
{
enum
{
LIO_WAIT,
LIO_NOWAIT
}
}
else version (Darwin) else version (Darwin)
{ {
enum enum
...@@ -362,6 +442,40 @@ version (CRuntime_Glibc) ...@@ -362,6 +442,40 @@ version (CRuntime_Glibc)
int lio_listio(int mode, const(aiocb*)* aiocb_list, int nitems, sigevent* sevp); 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 else
{ {
int aio_read(aiocb* aiocbp); int aio_read(aiocb* aiocbp);
...@@ -395,6 +509,26 @@ version (CRuntime_Glibc) ...@@ -395,6 +509,26 @@ version (CRuntime_Glibc)
void aio_init(const(aioinit)* init); 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) else version (FreeBSD)
{ {
int aio_waitcomplete(aiocb** aiocb_list, const(timespec)* timeout); int aio_waitcomplete(aiocb** aiocb_list, const(timespec)* timeout);
......
...@@ -868,7 +868,7 @@ else version (CRuntime_UClibc) ...@@ -868,7 +868,7 @@ else version (CRuntime_UClibc)
enum F_UNLCK = 2; enum F_UNLCK = 2;
enum F_WRLCK = 1; enum F_WRLCK = 1;
version (X86_64) version (X86_Any)
{ {
enum O_CREAT = 0x40; // octal 0100 enum O_CREAT = 0x40; // octal 0100
enum O_EXCL = 0x80; // octal 0200 enum O_EXCL = 0x80; // octal 0200
...@@ -877,12 +877,13 @@ else version (CRuntime_UClibc) ...@@ -877,12 +877,13 @@ else version (CRuntime_UClibc)
enum O_APPEND = 0x400; // octal 02000 enum O_APPEND = 0x400; // octal 02000
enum O_NONBLOCK = 0x800; // octal 04000 enum O_NONBLOCK = 0x800; // octal 04000
enum O_CLOEXEC = 0x80000; // octal 02000000
enum O_SYNC = 0x1000; // octal 010000 enum O_SYNC = 0x1000; // octal 010000
enum O_NDELAY = O_NONBLOCK; enum O_NDELAY = O_NONBLOCK;
enum O_FSYNC = O_SYNC; enum O_FSYNC = O_SYNC;
enum O_ASYNC = 0x2000; // octal 020000 enum O_ASYNC = 0x2000; // octal 020000
} }
else version (MIPS32) else version (MIPS_Any)
{ {
enum O_CREAT = 0x0100; enum O_CREAT = 0x0100;
enum O_EXCL = 0x0400; enum O_EXCL = 0x0400;
...@@ -892,11 +893,12 @@ else version (CRuntime_UClibc) ...@@ -892,11 +893,12 @@ else version (CRuntime_UClibc)
enum O_APPEND = 0x0008; enum O_APPEND = 0x0008;
enum O_SYNC = 0x0010; enum O_SYNC = 0x0010;
enum O_NONBLOCK = 0x0080; enum O_NONBLOCK = 0x0080;
enum O_CLOEXEC = 0x80000; // octal 02000000
enum O_NDELAY = O_NONBLOCK; enum O_NDELAY = O_NONBLOCK;
enum O_FSYNC = O_SYNC; enum O_FSYNC = O_SYNC;
enum O_ASYNC = 0x1000; enum O_ASYNC = 0x1000;
} }
else version (ARM) else version (ARM_Any)
{ {
enum O_CREAT = 0x40; // octal 0100 enum O_CREAT = 0x40; // octal 0100
enum O_EXCL = 0x80; // octal 0200 enum O_EXCL = 0x80; // octal 0200
...@@ -905,6 +907,7 @@ else version (CRuntime_UClibc) ...@@ -905,6 +907,7 @@ else version (CRuntime_UClibc)
enum O_APPEND = 0x400; // octal 02000 enum O_APPEND = 0x400; // octal 02000
enum O_NONBLOCK = 0x800; // octal 04000 enum O_NONBLOCK = 0x800; // octal 04000
enum O_CLOEXEC = 0x80000; // octal 02000000
enum O_SYNC = 0x1000; // octal 010000 enum O_SYNC = 0x1000; // octal 010000
enum O_NDELAY = O_NONBLOCK; enum O_NDELAY = O_NONBLOCK;
enum O_FSYNC = O_SYNC; enum O_FSYNC = O_SYNC;
......
...@@ -180,6 +180,37 @@ else version (CRuntime_UClibc) ...@@ -180,6 +180,37 @@ else version (CRuntime_UClibc)
FILE* tmpfile(); 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) // C Extension (CX)
...@@ -246,6 +277,31 @@ else version (CRuntime_UClibc) ...@@ -246,6 +277,31 @@ else version (CRuntime_UClibc)
off_t ftello(FILE*); 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) else version (Posix)
{ {
int fseeko(FILE*, off_t, int); int fseeko(FILE*, off_t, int);
......
...@@ -1941,31 +1941,37 @@ else version (CRuntime_UClibc) ...@@ -1941,31 +1941,37 @@ else version (CRuntime_UClibc)
int l_linger; int l_linger;
} }
version (X86_64) version (X86_Any)
{ {
enum enum
{ {
SOCK_DGRAM = 2, SOCK_DGRAM = 2,
SOCK_SEQPACKET = 5, 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 enum
{ {
SOCK_DGRAM = 1, SOCK_DGRAM = 1,
SOCK_SEQPACKET = 5, SOCK_SEQPACKET = 5,
SOCK_STREAM = 2, SOCK_STREAM = 2,
SOCK_CLOEXEC = 0x80000, // octal 02000000
SOCK_NONBLOCK = 0x80 // octal 00000200
} }
} }
else version (ARM) else version (ARM_Any)
{ {
enum enum
{ {
SOCK_DGRAM = 2, SOCK_DGRAM = 2,
SOCK_SEQPACKET = 5, SOCK_SEQPACKET = 5,
SOCK_STREAM = 1 SOCK_STREAM = 1,
SOCK_CLOEXEC = 0x80000, // octal 02000000
SOCK_NONBLOCK = 0x800 // octal 00004000
} }
} }
else else
...@@ -1991,6 +1997,7 @@ else version (CRuntime_UClibc) ...@@ -1991,6 +1997,7 @@ else version (CRuntime_UClibc)
SO_TYPE = 3, SO_TYPE = 3,
SOL_SOCKET = 1, SOL_SOCKET = 1,
SOL_TCP = 6,
SOMAXCONN = 128 SOMAXCONN = 128
} }
......
...@@ -9,6 +9,7 @@ module core.sys.solaris.dlfcn; ...@@ -9,6 +9,7 @@ module core.sys.solaris.dlfcn;
version (Solaris): version (Solaris):
extern (C): extern (C):
nothrow: nothrow:
@nogc:
public import core.sys.posix.dlfcn; public import core.sys.posix.dlfcn;
import core.stdc.config; import core.stdc.config;
...@@ -109,4 +110,4 @@ struct Dl_serinfo ...@@ -109,4 +110,4 @@ struct Dl_serinfo
Dl_serpath[1] dls_serpath; Dl_serpath[1] dls_serpath;
} }
// FIXME: Dl_argsinfo, Dl_mapinfo, Dl_amd64_unwindinfo are missing // FIXME: Dl_argsinfo, Dl_mapinfo, Dl_amd64_unwindinfo are missing
\ No newline at end of file
...@@ -15,22 +15,22 @@ import core.stdc.config; ...@@ -15,22 +15,22 @@ import core.stdc.config;
struct Elf32_Dyn struct Elf32_Dyn
{ {
Elf32_Sword d_tag; Elf32_Sword d_tag;
union d_un union _d_un
{ {
Elf32_Word d_val; Elf32_Word d_val;
Elf32_Addr d_ptr; Elf32_Addr d_ptr;
Elf32_Off d_off; Elf32_Off d_off;
} } _d_un d_un;
} }
struct Elf64_Dyn struct Elf64_Dyn
{ {
Elf64_Xword d_tag; Elf64_Xword d_tag;
union d_un union _d_un
{ {
Elf64_Xword d_val; Elf64_Xword d_val;
Elf64_Addr d_ptr; Elf64_Addr d_ptr;
} } _d_un d_un;
} }
enum DT_NULL = 0; enum DT_NULL = 0;
......
...@@ -708,7 +708,7 @@ static if (_WIN32_IE >= 0x500) { ...@@ -708,7 +708,7 @@ static if (_WIN32_IE >= 0x500) {
ULONG dwFlags; ULONG dwFlags;
DWORD dwFileAttributes; DWORD dwFileAttributes;
ULONG dwReserved; ULONG dwReserved;
WCHAR *pwszExt = 0; WCHAR *pwszExt = null;
WCHAR[MAX_PATH] wszFile = 0; WCHAR[MAX_PATH] wszFile = 0;
} }
alias SHCOLUMNDATA* LPSHCOLUMNDATA; alias SHCOLUMNDATA* LPSHCOLUMNDATA;
......
...@@ -24,7 +24,7 @@ import core.stdc.stdlib; ...@@ -24,7 +24,7 @@ import core.stdc.stdlib;
public import core.thread; public import core.thread;
extern(Windows) 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; extern (C) extern __gshared int _tls_index;
...@@ -113,7 +113,7 @@ struct thread_aux ...@@ -113,7 +113,7 @@ struct thread_aux
} }
alias fnNtQuerySystemInformation = extern(Windows) 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; enum ThreadBasicInformation = 0;
...@@ -129,7 +129,7 @@ struct thread_aux ...@@ -129,7 +129,7 @@ struct thread_aux
} }
alias fnNtQueryInformationThread = extern(Windows) 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 SYNCHRONIZE = 0x00100000;
enum THREAD_GET_CONTEXT = 8; enum THREAD_GET_CONTEXT = 8;
...@@ -138,7 +138,7 @@ struct thread_aux ...@@ -138,7 +138,7 @@ struct thread_aux
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
// get the thread environment block (TEB) of the thread with the given handle // 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" ); HANDLE nthnd = GetModuleHandleA( "NTDLL" );
assert( nthnd, "cannot get module handle for ntdll" ); assert( nthnd, "cannot get module handle for ntdll" );
...@@ -153,7 +153,7 @@ struct thread_aux ...@@ -153,7 +153,7 @@ struct thread_aux
} }
// get the thread environment block (TEB) of the thread with the given identifier // 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 ); HANDLE hnd = OpenThread( THREAD_QUERY_INFORMATION, FALSE, id );
assert( hnd, "OpenThread failed" ); assert( hnd, "OpenThread failed" );
...@@ -164,7 +164,7 @@ struct thread_aux ...@@ -164,7 +164,7 @@ struct thread_aux
} }
// get linear address of TEB of current thread // get linear address of TEB of current thread
static void** getTEB() nothrow static void** getTEB() nothrow @nogc
{ {
version (Win32) version (Win32)
{ {
...@@ -210,21 +210,21 @@ struct thread_aux ...@@ -210,21 +210,21 @@ struct thread_aux
} }
// get the stack bottom (the top address) of the thread with the given handle // 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 ); void** teb = getTEB( hnd );
return teb[1]; return teb[1];
} }
// get the stack bottom (the top address) of the thread with the given identifier // 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 ); void** teb = getTEB( id );
return teb[1]; return teb[1];
} }
// create a thread handle with full access to the thread with the given identifier // 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 ); return OpenThread( SYNCHRONIZE|THREAD_GET_CONTEXT|THREAD_QUERY_INFORMATION|THREAD_SUSPEND_RESUME, FALSE, id );
} }
......
...@@ -85,7 +85,7 @@ import core.internal.string; ...@@ -85,7 +85,7 @@ import core.internal.string;
version (Windows) version (Windows)
{ {
import core.sys.windows.windows; import core.sys.windows.winbase /+: QueryPerformanceCounter, QueryPerformanceFrequency+/;
} }
else version (Posix) else version (Posix)
{ {
...@@ -195,7 +195,7 @@ version (CoreDdoc) enum ClockType ...@@ -195,7 +195,7 @@ version (CoreDdoc) enum ClockType
extremely frequently (e.g. hundreds of thousands of times a second) but extremely frequently (e.g. hundreds of thousands of times a second) but
don't care about high precision, the coarse clock might be appropriate. 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). platforms, it's treated as $(D ClockType.normal).
+/ +/
coarse = 2, coarse = 2,
...@@ -207,7 +207,7 @@ version (CoreDdoc) enum ClockType ...@@ -207,7 +207,7 @@ version (CoreDdoc) enum ClockType
more precise clock than the normal one, it's treated as equivalent to more precise clock than the normal one, it's treated as equivalent to
$(D ClockType.normal). $(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_MONOTONIC_PRECISE) for the monotonic time and
$(D CLOCK_REALTIME_PRECISE) for the wall clock time. $(D CLOCK_REALTIME_PRECISE) for the wall clock time.
+/ +/
...@@ -231,7 +231,7 @@ version (CoreDdoc) enum ClockType ...@@ -231,7 +231,7 @@ version (CoreDdoc) enum ClockType
Uses a clock that has a precision of one second (contrast to the coarse 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). 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 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 takes advantage of an in-kernel cached value), but on other systems, the
fastest function available will be used, and the resulting $(D SysTime) fastest function available will be used, and the resulting $(D SysTime)
...@@ -320,6 +320,16 @@ else version (NetBSD) enum ClockType ...@@ -320,6 +320,16 @@ else version (NetBSD) enum ClockType
precise = 3, precise = 3,
second = 6, 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 else version (Solaris) enum ClockType
{ {
normal = 0, normal = 0,
...@@ -386,6 +396,20 @@ version (Posix) ...@@ -386,6 +396,20 @@ version (Posix)
case second: assert(0); 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) else version (Solaris)
{ {
import core.sys.solaris.time; import core.sys.solaris.time;
...@@ -451,6 +475,8 @@ unittest ...@@ -451,6 +475,8 @@ unittest
Examples: Examples:
-------------------- --------------------
import std.datetime;
assert(dur!"days"(12) == dur!"hnsecs"(10_368_000_000_000L)); assert(dur!"days"(12) == dur!"hnsecs"(10_368_000_000_000L));
assert(dur!"hnsecs"(27) == dur!"hnsecs"(27)); assert(dur!"hnsecs"(27) == dur!"hnsecs"(27));
assert(std.datetime.Date(2010, 9, 7) + dur!"days"(5) == assert(std.datetime.Date(2010, 9, 7) + dur!"days"(5) ==
......
...@@ -16,7 +16,8 @@ module gc.os; ...@@ -16,7 +16,8 @@ module gc.os;
version (Windows) 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; alias int pthread_t;
...@@ -40,9 +41,11 @@ else version (Posix) ...@@ -40,9 +41,11 @@ else version (Posix)
import core.sys.posix.sys.mman; import core.sys.posix.sys.mman;
version (FreeBSD) import core.sys.freebsd.sys.mman : MAP_ANON; 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 (NetBSD) import core.sys.netbsd.sys.mman : MAP_ANON;
version (CRuntime_Glibc) import core.sys.linux.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 (Darwin) import core.sys.darwin.sys.mman : MAP_ANON;
version (CRuntime_UClibc) import core.sys.linux.sys.mman : MAP_ANON;
import core.stdc.stdlib; import core.stdc.stdlib;
//version = GC_Use_Alloc_MMap; //version = GC_Use_Alloc_MMap;
...@@ -170,7 +173,7 @@ version (Windows) ...@@ -170,7 +173,7 @@ version (Windows)
return false; return false;
else else
{ {
import core.sys.windows.windows; import core.sys.windows.winbase : GlobalMemoryStatus, MEMORYSTATUS;
MEMORYSTATUS stat; MEMORYSTATUS stat;
GlobalMemoryStatus(&stat); GlobalMemoryStatus(&stat);
// Less than 5 % of virtual address space available // Less than 5 % of virtual address space available
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment