-d57fa1ffaecc858229ed7a730e8486b59197dee5
+175bf5fc69d26fec60d533ff77f7e915fd5bb468
The first line of this file holds the git revision number of the last
merge done from the dlang/druntime repository.
}
else version (CRuntime_Musl)
{
- import core.sys.posix.sys.types : off_t;
- ///
- int fseeko(FILE *, off_t, int);
@trusted
{
///
}
///
-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)
{
///
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
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)
{
version (Windows)
{
- private import core.sys.windows.windows;
+ private import core.sys.windows.winbase /+: CRITICAL_SECTION, DeleteCriticalSection,
+ EnterCriticalSection, InitializeCriticalSection, LeaveCriticalSection,
+ TryEnterCriticalSection+/;
}
else version (Posix)
{
{
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;
}
void useResource() shared @safe nothrow @nogc
{
mtx.lock_nothrow();
- cargo++;
+ (cast() cargo) += 1;
mtx.unlock_nothrow();
}
}
// 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);
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)
{
}
-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;
}
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
AIO_ALLDONE
}
}
+else version (CRuntime_UClibc)
+{
+ enum
+ {
+ AIO_CANCELED,
+ AIO_NOTCANCELED,
+ AIO_ALLDONE
+ }
+}
else version (Darwin)
{
enum
LIO_NOP
}
}
+else version (CRuntime_UClibc)
+{
+ enum
+ {
+ LIO_READ,
+ LIO_WRITE,
+ LIO_NOP
+ }
+}
else version (Darwin)
{
enum
LIO_NOWAIT
}
}
+else version (CRuntime_UClibc)
+{
+ enum
+ {
+ LIO_WAIT,
+ LIO_NOWAIT
+ }
+}
else version (Darwin)
{
enum
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);
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);
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
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;
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
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;
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)
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);
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
SO_TYPE = 3,
SOL_SOCKET = 1,
+ SOL_TCP = 6,
SOMAXCONN = 128
}
version (Solaris):
extern (C):
nothrow:
+@nogc:
public import core.sys.posix.dlfcn;
import core.stdc.config;
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
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;
ULONG dwFlags;
DWORD dwFileAttributes;
ULONG dwReserved;
- WCHAR *pwszExt = 0;
+ WCHAR *pwszExt = null;
WCHAR[MAX_PATH] wszFile = 0;
}
alias SHCOLUMNDATA* LPSHCOLUMNDATA;
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;
}
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;
}
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;
///////////////////////////////////////////////////////////////////
// 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" );
}
// 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" );
}
// get linear address of TEB of current thread
- static void** getTEB() nothrow
+ static void** getTEB() nothrow @nogc
{
version (Win32)
{
}
// 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 );
}
version (Windows)
{
-import core.sys.windows.windows;
+import core.sys.windows.winbase /+: QueryPerformanceCounter, QueryPerformanceFrequency+/;
}
else version (Posix)
{
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,
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.
+/
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)
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,
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;
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) ==
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;
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;
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