17 changes: 13 additions & 4 deletions src/core/stdc/stdio.d
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@

module core.stdc.stdio;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

private
{
import core.stdc.config;
Expand Down Expand Up @@ -104,7 +113,7 @@ else version( CRuntime_Glibc )
L_tmpnam = 20
}
}
else version( OSX )
else version( Darwin )
{
enum
{
Expand Down Expand Up @@ -306,7 +315,7 @@ else version( CRuntime_Glibc )
///
alias shared(_IO_FILE) FILE;
}
else version( OSX )
else version( Darwin )
{
///
alias long fpos_t;
Expand Down Expand Up @@ -591,7 +600,7 @@ else version( CRuntime_Glibc )
///
extern shared FILE* stderr;
}
else version( OSX )
else version( Darwin )
{
enum
{
Expand Down Expand Up @@ -989,7 +998,7 @@ else version( CRuntime_Glibc )
///
int vsnprintf(char* s, size_t n, in char* format, va_list arg);
}
else version( OSX )
else version( Darwin )
{
// No unsafe pointer manipulation.
@trusted
Expand Down
11 changes: 10 additions & 1 deletion src/core/stdc/stdlib.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ module core.stdc.stdlib;
private import core.stdc.config;
public import core.stdc.stddef; // for wchar_t

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

extern (C):
@system:

Expand Down Expand Up @@ -64,7 +73,7 @@ enum MB_CUR_MAX = 1;
///
version(Windows) enum RAND_MAX = 0x7fff;
else version(CRuntime_Glibc) enum RAND_MAX = 0x7fffffff;
else version(OSX) enum RAND_MAX = 0x7fffffff;
else version(Darwin) enum RAND_MAX = 0x7fffffff;
else version(FreeBSD) enum RAND_MAX = 0x7fffffff;
else version(Solaris) enum RAND_MAX = 0x7fff;
else version(CRuntime_Bionic) enum RAND_MAX = 0x7fffffff;
Expand Down
11 changes: 10 additions & 1 deletion src/core/stdc/string.d
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@

module core.stdc.string;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

extern (C):
@system:
nothrow:
Expand Down Expand Up @@ -72,7 +81,7 @@ version (CRuntime_Glibc)
///
const(char)* strerror_r(int errnum, char* buf, size_t buflen);
}
else version (OSX)
else version (Darwin)
{
int strerror_r(int errnum, char* buf, size_t buflen);
}
Expand Down
15 changes: 14 additions & 1 deletion src/core/stdc/time.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ module core.stdc.time;

private import core.stdc.config;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

extern (C):
@trusted: // There are only a few functions here that use unsafe C strings.
nothrow:
Expand Down Expand Up @@ -78,6 +87,10 @@ else version( OSX )
{
enum clock_t CLOCKS_PER_SEC = 100;
}
else version( Darwin ) // other Darwins (iOS, TVOS, WatchOS)
{
enum clock_t CLOCKS_PER_SEC = 1_000_000;
}
else version( FreeBSD )
{
enum clock_t CLOCKS_PER_SEC = 128;
Expand Down Expand Up @@ -124,7 +137,7 @@ version( Windows )
///
extern __gshared const(char)*[2] tzname; // non-standard
}
else version( OSX )
else version( Darwin )
{
///
void tzset(); // non-standard
Expand Down
27 changes: 18 additions & 9 deletions src/core/sync/semaphore.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,25 @@ module core.sync.semaphore;
public import core.sync.exception;
public import core.time;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version( Windows )
{
private import core.sys.windows.windows;
}
else version( OSX )
else version( Darwin )
{
private import core.sync.config;
private import core.stdc.errno;
private import core.sys.posix.time;
private import core.sys.osx.mach.semaphore;
private import core.sys.darwin.mach.semaphore;
}
else version( Posix )
{
Expand Down Expand Up @@ -81,7 +90,7 @@ class Semaphore
if( m_hndl == m_hndl.init )
throw new SyncError( "Unable to create semaphore" );
}
else version( OSX )
else version( Darwin )
{
auto rc = semaphore_create( mach_task_self(), &m_hndl, SYNC_POLICY_FIFO, count );
if( rc )
Expand All @@ -103,7 +112,7 @@ class Semaphore
BOOL rc = CloseHandle( m_hndl );
assert( rc, "Unable to destroy semaphore" );
}
else version( OSX )
else version( Darwin )
{
auto rc = semaphore_destroy( mach_task_self(), m_hndl );
assert( !rc, "Unable to destroy semaphore" );
Expand Down Expand Up @@ -136,7 +145,7 @@ class Semaphore
if( rc != WAIT_OBJECT_0 )
throw new SyncError( "Unable to wait for semaphore" );
}
else version( OSX )
else version( Darwin )
{
while( true )
{
Expand Down Expand Up @@ -215,7 +224,7 @@ class Semaphore
throw new SyncError( "Unable to wait for semaphore" );
}
}
else version( OSX )
else version( Darwin )
{
mach_timespec_t t = void;
(cast(byte*) &t)[0 .. t.sizeof] = 0;
Expand Down Expand Up @@ -270,7 +279,7 @@ class Semaphore
if( !ReleaseSemaphore( m_hndl, 1, null ) )
throw new SyncError( "Unable to notify semaphore" );
}
else version( OSX )
else version( Darwin )
{
auto rc = semaphore_signal( m_hndl );
if( rc )
Expand Down Expand Up @@ -309,7 +318,7 @@ class Semaphore
throw new SyncError( "Unable to wait for semaphore" );
}
}
else version( OSX )
else version( Darwin )
{
return wait( dur!"hnsecs"(0) );
}
Expand All @@ -333,7 +342,7 @@ private:
{
HANDLE m_hndl;
}
else version( OSX )
else version( Darwin )
{
semaphore_t m_hndl;
}
Expand Down
26 changes: 26 additions & 0 deletions src/core/sys/darwin/execinfo.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* D header file for Darwin.
*
* Copyright: Copyright Martin Nowak 2012.
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Authors: Martin Nowak
*/
module core.sys.darwin.execinfo;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Darwin):
extern (C):
nothrow:
@nogc:

int backtrace(void** buffer, int size);
char** backtrace_symbols(const(void*)* buffer, int size);
void backtrace_symbols_fd(const(void*)* buffer, int size, int fd);
38 changes: 38 additions & 0 deletions src/core/sys/darwin/mach/dyld.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright: Copyright Digital Mars 2010.
* License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Jacob Carlborg
* Version: Initial created: Feb 20, 2010
*/

/* Copyright Digital Mars 2010.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.darwin.mach.dyld;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Darwin):
extern (C):
nothrow:
@nogc:

public import core.stdc.stdint; // for intptr_t
public import core.sys.darwin.mach.loader;

uint _dyld_image_count();
const(char)* _dyld_get_image_name(uint image_index);
mach_header* _dyld_get_image_header(uint image_index);
void _dyld_register_func_for_add_image(void function(in mach_header* mh, intptr_t vmaddr_slide));
void _dyld_register_func_for_remove_image(void function(in mach_header* mh, intptr_t vmaddr_slide));


33 changes: 33 additions & 0 deletions src/core/sys/darwin/mach/getsect.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Copyright: Copyright Digital Mars 2010.
* License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Jacob Carlborg
* Version: Initial created: Mar 16, 2010
*/

/* Copyright Digital Mars 2010.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.darwin.mach.getsect;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Darwin):
extern (C):
nothrow:
@nogc:

public import core.sys.darwin.mach.loader;

const(section)* getsectbynamefromheader(in mach_header* mhp, in char* segname, in char* sectname);
const(section_64)* getsectbynamefromheader_64(in mach_header_64* mhp, in char* segname, in char* sectname);

82 changes: 82 additions & 0 deletions src/core/sys/darwin/mach/kern_return.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* D header file for Darwin.
*
* Copyright: Copyright Sean Kelly 2008 - 2009.
* License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Sean Kelly
*/

/* Copyright Sean Kelly 2008 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.darwin.mach.kern_return;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Darwin):
extern (C):

alias int kern_return_t;

enum : kern_return_t
{
KERN_SUCCESS = 0,
KERN_INVALID_ADDRESS = 1,
KERN_PROTECTION_FAILURE = 2,
KERN_NO_SPACE = 3,
KERN_INVALID_ARGUMENT = 4,
KERN_FAILURE = 5,
KERN_RESOURCE_SHORTAGE = 6,
KERN_NOT_RECEIVER = 7,
KERN_NO_ACCESS = 8,
KERN_MEMORY_FAILURE = 9,
KERN_MEMORY_ERROR = 10,
KERN_ALREADY_IN_SET = 11,
KERN_NOT_IN_SET = 12,
KERN_NAME_EXISTS = 13,
KERN_ABORTED = 14,
KERN_INVALID_NAME = 15,
KERN_INVALID_TASK = 16,
KERN_INVALID_RIGHT = 17,
KERN_INVALID_VALUE = 18,
KERN_UREFS_OVERFLOW = 19,
KERN_INVALID_CAPABILITY = 20,
KERN_RIGHT_EXISTS = 21,
KERN_INVALID_HOST = 22,
KERN_MEMORY_PRESENT = 23,
KERN_MEMORY_DATA_MOVED = 24,
KERN_MEMORY_RESTART_COPY = 25,
KERN_INVALID_PROCESSOR_SET = 26,
KERN_POLICY_LIMIT = 27,
KERN_INVALID_POLICY = 28,
KERN_INVALID_OBJECT = 29,
KERN_ALREADY_WAITING = 30,
KERN_DEFAULT_SET = 31,
KERN_EXCEPTION_PROTECTED = 32,
KERN_INVALID_LEDGER = 33,
KERN_INVALID_MEMORY_CONTROL = 34,
KERN_INVALID_SECURITY = 35,
KERN_NOT_DEPRESSED = 36,
KERN_TERMINATED = 37,
KERN_LOCK_SET_DESTROYED = 38,
KERN_LOCK_UNSTABLE = 39,
KERN_LOCK_OWNED = 40,
KERN_LOCK_OWNED_SELF = 41,
KERN_SEMAPHORE_DESTROYED = 42,
KERN_RPC_SERVER_TERMINATED = 43,
KERN_RPC_TERMINATE_ORPHAN = 44,
KERN_RPC_CONTINUE_ORPHAN = 45,
KERN_NOT_SUPPORTED = 46,
KERN_NODE_DOWN = 47,
KERN_OPERATION_TIMED_OUT = 49,
KERN_RETURN_MAX = 0x100,
}
106 changes: 106 additions & 0 deletions src/core/sys/darwin/mach/loader.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/**
* Copyright: Copyright Digital Mars 2010.
* License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Jacob Carlborg
* Version: Initial created: Feb 20, 2010
*/

/* Copyright Digital Mars 2010.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.darwin.mach.loader;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Darwin):
extern (C):

struct mach_header
{
uint magic;
int cputype;
int cpusubtype;
uint filetype;
uint ncmds;
uint sizeofcmds;
uint flags;
}

struct mach_header_64
{
uint magic;
int cputype;
int cpusubtype;
uint filetype;
uint ncmds;
uint sizeofcmds;
uint flags;
uint reserved;
}

enum uint MH_MAGIC = 0xfeedface;
enum uint MH_CIGAM = 0xcefaedfe;
enum uint MH_MAGIC_64 = 0xfeedfacf;
enum uint MH_CIGAM_64 = 0xcffaedfe;

enum SEG_PAGEZERO = "__PAGEZERO";
enum SEG_TEXT = "__TEXT";
enum SECT_TEXT = "__text";
enum SECT_FVMLIB_INIT0 = "__fvmlib_init0";
enum SECT_FVMLIB_INIT1 = "__fvmlib_init1";
enum SEG_DATA = "__DATA";
enum SECT_DATA = "__data";
enum SECT_BSS = "__bss";
enum SECT_COMMON = "__common";
enum SEG_OBJC = "__OBJC";
enum SECT_OBJC_SYMBOLS = "__symbol_table";
enum SECT_OBJC_MODULES = "__module_info";
enum SECT_OBJC_STRINGS = "__selector_strs";
enum SECT_OBJC_REFS = "__selector_refs";
enum SEG_ICON = "__ICON";
enum SECT_ICON_HEADER = "__header";
enum SECT_ICON_TIFF = "__tiff";
enum SEG_LINKEDIT = "__LINKEDIT";
enum SEG_UNIXSTACK = "__UNIXSTACK";
enum SEG_IMPORT = "__IMPORT";

struct section
{
char[16] sectname;
char[16] segname;
uint addr;
uint size;
uint offset;
uint align_;
uint reloff;
uint nreloc;
uint flags;
uint reserved1;
uint reserved2;
}

struct section_64
{
char[16] sectname;
char[16] segname;
ulong addr;
ulong size;
uint offset;
uint align_;
uint reloff;
uint nreloc;
uint flags;
uint reserved1;
uint reserved2;
uint reserved3;
}

36 changes: 36 additions & 0 deletions src/core/sys/darwin/mach/port.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* D header file for Darwin.
*
* Copyright: Copyright Sean Kelly 2008 - 2009.
* License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Sean Kelly
*/

/* Copyright Sean Kelly 2008 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.darwin.mach.port;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Darwin):
extern (C):

version( X86 )
version = i386;
version( X86_64 )
version = i386;
version( i386 )
{
alias uint natural_t;
alias natural_t mach_port_t;
}
67 changes: 67 additions & 0 deletions src/core/sys/darwin/mach/semaphore.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* D header file for Darwin.
*
* Copyright: Copyright Sean Kelly 2008 - 2009.
* License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Sean Kelly
*/

/* Copyright Sean Kelly 2008 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.darwin.mach.semaphore;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Darwin):
extern (C):
nothrow:
@nogc:

public import core.sys.darwin.mach.kern_return;
public import core.sys.darwin.mach.port;

alias mach_port_t task_t;
alias mach_port_t thread_t;
alias mach_port_t semaphore_t;
alias int sync_policy_t;

alias int clock_res_t;
struct mach_timespec_t
{
uint tv_sec;
clock_res_t tv_nsec;
}

enum
{
SYNC_POLICY_FIFO = 0x0,
SYNC_POLICY_FIXED_PRIORITY = 0x1,
SYNC_POLICY_REVERSED = 0x2,
SYNC_POLICY_ORDER_MASK = 0x3,
SYNC_POLICY_LIFO = (SYNC_POLICY_FIFO | SYNC_POLICY_REVERSED),
SYNC_POLICY_MAX = 0x7,
}

task_t mach_task_self();
kern_return_t semaphore_create(task_t, semaphore_t*, int, int);
kern_return_t semaphore_destroy(task_t, semaphore_t);

kern_return_t semaphore_signal(semaphore_t);
kern_return_t semaphore_signal_all(semaphore_t);
kern_return_t semaphore_signal_thread(semaphore_t, thread_t);

kern_return_t semaphore_wait(semaphore_t);
kern_return_t semaphore_wait_signal(semaphore_t, semaphore_t);

kern_return_t semaphore_timedwait(semaphore_t, mach_timespec_t);
kern_return_t semaphore_timedwait_signal(semaphore_t, semaphore_t, mach_timespec_t);
137 changes: 137 additions & 0 deletions src/core/sys/darwin/mach/thread_act.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/**
* D header file for Darwin.
*
* Copyright: Copyright Sean Kelly 2008 - 2009.
* License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Sean Kelly
*/

/* Copyright Sean Kelly 2008 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.darwin.mach.thread_act;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Darwin):
extern (C):
nothrow:
@nogc:

public import core.sys.darwin.mach.kern_return;
public import core.sys.darwin.mach.port;

version( X86 )
version = i386;
version( X86_64 )
version = i386;
version( i386 )
{
alias mach_port_t thread_act_t;
alias void thread_state_t;
alias int thread_state_flavor_t;
alias natural_t mach_msg_type_number_t;

enum
{
x86_THREAD_STATE32 = 1,
x86_FLOAT_STATE32 = 2,
x86_EXCEPTION_STATE32 = 3,
x86_THREAD_STATE64 = 4,
x86_FLOAT_STATE64 = 5,
x86_EXCEPTION_STATE64 = 6,
x86_THREAD_STATE = 7,
x86_FLOAT_STATE = 8,
x86_EXCEPTION_STATE = 9,
x86_DEBUG_STATE32 = 10,
x86_DEBUG_STATE64 = 11,
x86_DEBUG_STATE = 12,
THREAD_STATE_NONE = 13,
}

struct x86_thread_state32_t
{
uint eax;
uint ebx;
uint ecx;
uint edx;
uint edi;
uint esi;
uint ebp;
uint esp;
uint ss;
uint eflags;
uint eip;
uint cs;
uint ds;
uint es;
uint fs;
uint gs;
}

struct x86_thread_state64_t
{
ulong rax;
ulong rbx;
ulong rcx;
ulong rdx;
ulong rdi;
ulong rsi;
ulong rbp;
ulong rsp;
ulong r8;
ulong r9;
ulong r10;
ulong r11;
ulong r12;
ulong r13;
ulong r14;
ulong r15;
ulong rip;
ulong rflags;
ulong cs;
ulong fs;
ulong gs;
}

struct x86_state_hdr_t
{
int flavor;
int count;
}

struct x86_thread_state_t
{
x86_state_hdr_t tsh;
union _uts
{
x86_thread_state32_t ts32;
x86_thread_state64_t ts64;
}
_uts uts;
}

enum : mach_msg_type_number_t
{
x86_THREAD_STATE32_COUNT = cast(mach_msg_type_number_t)( x86_thread_state32_t.sizeof / int.sizeof ),
x86_THREAD_STATE64_COUNT = cast(mach_msg_type_number_t)( x86_thread_state64_t.sizeof / int.sizeof ),
x86_THREAD_STATE_COUNT = cast(mach_msg_type_number_t)( x86_thread_state_t.sizeof / int.sizeof ),
}

alias x86_THREAD_STATE MACHINE_THREAD_STATE;
alias x86_THREAD_STATE_COUNT MACHINE_THREAD_STATE_COUNT;

mach_port_t mach_thread_self();
kern_return_t thread_suspend(thread_act_t);
kern_return_t thread_resume(thread_act_t);
kern_return_t thread_get_state(thread_act_t, thread_state_flavor_t, thread_state_t*, mach_msg_type_number_t*);
}
60 changes: 60 additions & 0 deletions src/core/sys/darwin/pthread.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* D header file for Darwin.
*
* Copyright: Copyright Sean Kelly 2008 - 2009.
* License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Sean Kelly
*/

/* Copyright Sean Kelly 2008 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.darwin.pthread;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Darwin):
extern (C):
nothrow:
@nogc:

public import core.sys.posix.pthread;
public import core.sys.darwin.mach.port;

int pthread_is_threaded_np();
int pthread_threadid_np(pthread_t, ulong*);
// ^ __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
int pthread_rwlock_longrdlock_np(pthread_rwlock_t*);
int pthread_rwlock_yieldwrlock_np(pthread_rwlock_t*);
// ^ __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA);
int pthread_rwlock_downgrade_np(pthread_rwlock_t*);
int pthread_rwlock_upgrade_np(pthread_rwlock_t*);
int pthread_rwlock_tryupgrade_np(pthread_rwlock_t*);
int pthread_rwlock_held_np(pthread_rwlock_t*);
int pthread_rwlock_rdheld_np(pthread_rwlock_t*);
int pthread_rwlock_wrheld_np(pthread_rwlock_t*);
int pthread_getname_np(pthread_t, char*, size_t);
int pthread_setname_np(in char*);
// ^ __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
int pthread_main_np();
mach_port_t pthread_mach_thread_np(pthread_t);
size_t pthread_get_stacksize_np(pthread_t);
void* pthread_get_stackaddr_np(pthread_t);
int pthread_cond_signal_thread_np(pthread_cond_t*, pthread_t);
int pthread_cond_timedwait_relative_np(pthread_cond_t*, pthread_mutex_t*, in timespec*);
int pthread_create_suspended_np(pthread_t*, in pthread_attr_t*, void* function(void*), void*);
int pthread_kill(pthread_t, int);
pthread_t pthread_from_mach_thread_np(mach_port_t);
// ^ __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
int pthread_sigmask(int, in sigset_t*, sigset_t*);
// ^ __DARWIN_ALIAS(pthread_sigmask)
void pthread_yield_np();
25 changes: 25 additions & 0 deletions src/core/sys/darwin/sys/cdefs.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* D header file for Darwin
*
* Authors: Martin Nowak
*/
module core.sys.darwin.sys.cdefs;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Darwin):

public import core.sys.posix.config;

// http://www.opensource.apple.com/source/xnu/xnu-2422.115.4/bsd/sys/cdefs.h
enum _DARWIN_C_SOURCE = true;

enum __DARWIN_C_FULL = 900_000L;
enum __DARWIN_C_LEVEL = __DARWIN_C_FULL;
141 changes: 141 additions & 0 deletions src/core/sys/darwin/sys/event.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/**
* D header file for Darwin.
*
* Copyright: Copyright Martin Nowak 2012. Etienne Cimon 2015.
* License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Martin Nowak
*/

/* Copyright Martin Nowak 2012. Etienne Cimon 2015.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.darwin.sys.event;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Darwin):
extern (C):
nothrow:
@nogc:

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

enum : short
{
EVFILT_READ = -1,
EVFILT_WRITE = -2,
EVFILT_AIO = -3, /* attached to aio requests */
EVFILT_VNODE = -4, /* attached to vnodes */
EVFILT_PROC = -5, /* attached to struct proc */
EVFILT_SIGNAL = -6, /* attached to struct proc */
EVFILT_TIMER = -7, /* timers */
EVFILT_MACHPORT = -8, /* Mach portsets */
EVFILT_FS = -9, /* filesystem events */
EVFILT_USER = -10, /* User events */
EVFILT_VM = -12, /* virtual memory events */
EVFILT_SYSCOUNT = 11
}

extern(D) void EV_SET(kevent_t* kevp, typeof(kevent_t.tupleof) args)
{
*kevp = kevent_t(args);
}

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 */
}

enum
{
/* actions */
EV_ADD = 0x0001, /* add event to kq (implies enable) */
EV_DELETE = 0x0002, /* delete event from kq */
EV_ENABLE = 0x0004, /* enable event */
EV_DISABLE = 0x0008, /* disable event (not reported) */

/* flags */
EV_ONESHOT = 0x0010, /* only report one occurrence */
EV_CLEAR = 0x0020, /* clear event state after reporting */
EV_RECEIPT = 0x0040, /* force EV_ERROR on success, data=0 */
EV_DISPATCH = 0x0080, /* disable event after reporting */

EV_SYSFLAGS = 0xF000, /* reserved by system */
EV_FLAG1 = 0x2000, /* filter-specific flag */

/* returned values */
EV_EOF = 0x8000, /* EOF detected */
EV_ERROR = 0x4000, /* error, data contains errno */
}

enum
{
/*
* data/hint flags/masks for EVFILT_USER, shared with userspace
*
* On input, the top two bits of fflags specifies how the lower twenty four
* bits should be applied to the stored value of fflags.
*
* On output, the top two bits will always be set to NOTE_FFNOP and the
* remaining twenty four bits will contain the stored fflags value.
*/
NOTE_FFNOP = 0x00000000, /* ignore input fflags */
NOTE_FFAND = 0x40000000, /* AND fflags */
NOTE_FFOR = 0x80000000, /* OR fflags */
NOTE_FFCOPY = 0xc0000000, /* copy fflags */
NOTE_FFCTRLMASK = 0xc0000000, /* masks for operations */
NOTE_FFLAGSMASK = 0x00ffffff,

NOTE_TRIGGER = 0x01000000, /* Cause the event to be
triggered for output. */

/*
* data/hint flags for EVFILT_{READ|WRITE}, shared with userspace
*/
NOTE_LOWAT = 0x0001, /* low water mark */

/*
* data/hint flags for EVFILT_VNODE, shared with userspace
*/
NOTE_DELETE = 0x0001, /* vnode was removed */
NOTE_WRITE = 0x0002, /* data contents changed */
NOTE_EXTEND = 0x0004, /* size increased */
NOTE_ATTRIB = 0x0008, /* attributes changed */
NOTE_LINK = 0x0010, /* link count changed */
NOTE_RENAME = 0x0020, /* vnode was renamed */
NOTE_REVOKE = 0x0040, /* vnode access was revoked */

/*
* data/hint flags for EVFILT_PROC, shared with userspace
*/
NOTE_EXIT = 0x80000000, /* process exited */
NOTE_FORK = 0x40000000, /* process forked */
NOTE_EXEC = 0x20000000, /* process exec'd */
NOTE_PCTRLMASK = 0xf0000000, /* mask for hint bits */
NOTE_PDATAMASK = 0x000fffff, /* mask for pid */

/* additional flags for EVFILT_PROC */
NOTE_TRACK = 0x00000001, /* follow across forks */
NOTE_TRACKERR = 0x00000002, /* could not track child */
NOTE_CHILD = 0x00000004, /* am a child process */
}

int kqueue();
int kevent(int kq, const kevent_t *changelist, int nchanges,
kevent_t *eventlist, int nevents,
const timespec *timeout);
112 changes: 112 additions & 0 deletions src/core/sys/darwin/sys/mman.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/**
* D header file for Darwin
*
* Authors: Martin Nowak
*/
module core.sys.darwin.sys.mman;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Darwin):
extern (C):
nothrow:
@nogc:

public import core.sys.posix.sys.mman;
import core.sys.darwin.sys.cdefs;
import core.sys.posix.sys.types;

// already in core.sys.posix.sys.mman
// enum PROT_NONE = 0x00;
// enum PROT_READ = 0x01;
// enum PROT_WRITE = 0x02;
// enum PROT_EXEC = 0x04;

// already in core.sys.posix.sys.mman
// enum MAP_SHARED = 0x0001;
// enum MAP_PRIVATE = 0x0002;
static if (_DARWIN_C_SOURCE)
alias MAP_COPY = MAP_PRIVATE;
// enum MAP_FIXED = 0x0010;

static if (_DARWIN_C_SOURCE)
{
enum MAP_RENAME = 0x0020;
enum MAP_NORESERVE = 0x0040;
enum MAP_RESERVED0080 = 0x0080;
enum MAP_NOEXTEND = 0x0100;
enum MAP_HASSEMAPHORE = 0x0200;
enum MAP_NOCACHE = 0x0400;
enum MAP_JIT = 0x0800;
}

// already in core.sys.posix.sys.mman
// enum MCL_CURRENT = 0x0001;
// enum MCL_FUTURE = 0x0002;

// enum MAP_FAILED = cast(void*)-1;

// enum MS_ASYNC = 0x0001;
// enum MS_INVALIDATE = 0x0002;
// enum MS_SYNC = 0x0010;

static if (_DARWIN_C_SOURCE)
{
enum MS_KILLPAGES = 0x0004;
enum MS_DEACTIVATE = 0x0008;

enum MAP_FILE = 0x0000;

// already in core.sys.posix.sys.mman
// enum MAP_ANON = 0x1000;

// enum POSIX_MADV_NORMAL = 0;
// enum POSIX_MADV_RANDOM = 1;
// enum POSIX_MADV_SEQUENTIAL = 2;
// enum POSIX_MADV_WILLNEED = 3;
// enum POSIX_MADV_DONTNEED = 4;

alias MADV_NORMAL = POSIX_MADV_NORMAL;
alias MADV_RANDOM = POSIX_MADV_RANDOM;
alias MADV_SEQUENTIAL = POSIX_MADV_SEQUENTIAL;
alias MADV_WILLNEED = POSIX_MADV_WILLNEED;
alias MADV_DONTNEED = POSIX_MADV_DONTNEED;
enum MADV_FREE = 5;
enum MADV_ZERO_WIRED_PAGES = 6;
enum MADV_FREE_REUSABLE = 7;
enum MADV_FREE_REUSE = 8;
enum MADV_CAN_REUSE = 9;

enum MINCORE_INCORE = 0x1;
enum MINCORE_REFERENCED = 0x2;
enum MINCORE_MODIFIED = 0x4;
enum MINCORE_REFERENCED_OTHER = 0x8;
enum MINCORE_MODIFIED_OTHER = 0x10;
}

// already in core.sys.posix.sys.mman
// int mlockall(int);
// int munlockall(void);
// int mlock(const void *, size_t);
// void * mmap(void *, size_t, int, int, int, off_t);
// int mprotect(void *, size_t, int);
// int msync(void *, size_t, int);
// int munlock(const void *, size_t);
// int munmap(void *, size_t);
// int shm_open(const char *, int, ...);
// int shm_unlink(const char *);
// int posix_madvise(void *, size_t, int);

static if (_DARWIN_C_SOURCE)
{
int madvise(void *, size_t, int);
int mincore(const(void)*, size_t, char *);
int minherit(void *, size_t, int);
}
11 changes: 4 additions & 7 deletions src/core/sys/osx/execinfo.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/**
* $(RED Deprecated. Use $(D core.sys.darwin.execinfo) instead. This module
* will be removed in June 2018.)
*
* D header file for OSX.
*
* Copyright: Copyright Martin Nowak 2012.
Expand All @@ -7,10 +10,4 @@
*/
module core.sys.osx.execinfo;

version (OSX):
extern (C):
nothrow:

int backtrace(void** buffer, int size);
char** backtrace_symbols(const(void*)* buffer, int size);
void backtrace_symbols_fd(const(void*)* buffer, int size, int fd);
public import core.sys.darwin.execinfo;
17 changes: 4 additions & 13 deletions src/core/sys/osx/mach/dyld.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/**
* $(RED Deprecated. Use $(D core.sys.darwin.mach.dyld) instead. This module
* will be removed in June 2018.)
*
* Copyright: Copyright Digital Mars 2010.
* License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Jacob Carlborg
Expand All @@ -12,16 +15,4 @@
*/
module core.sys.osx.mach.dyld;

version (OSX):
extern (C):

public import core.stdc.stdint; // for intptr_t
public import core.sys.osx.mach.loader;

uint _dyld_image_count();
const(char)* _dyld_get_image_name(uint image_index);
mach_header* _dyld_get_image_header(uint image_index);
void _dyld_register_func_for_add_image(void function(in mach_header* mh, intptr_t vmaddr_slide));
void _dyld_register_func_for_remove_image(void function(in mach_header* mh, intptr_t vmaddr_slide));


public import core.sys.darwin.mach.dyld;
12 changes: 4 additions & 8 deletions src/core/sys/osx/mach/getsect.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/**
* $(RED Deprecated. Use $(D core.sys.darwin.mach.getsect) instead. This
* module will be removed in June 2018.)
*
* Copyright: Copyright Digital Mars 2010.
* License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Jacob Carlborg
Expand All @@ -12,11 +15,4 @@
*/
module core.sys.osx.mach.getsect;

version (OSX):
extern (C):

public import core.sys.osx.mach.loader;

const(section)* getsectbynamefromheader(in mach_header* mhp, in char* segname, in char* sectname);
const(section_64)* getsectbynamefromheader_64(in mach_header_64* mhp, in char* segname, in char* sectname);

public import core.sys.darwin.mach.getsect;
62 changes: 4 additions & 58 deletions src/core/sys/osx/mach/kern_return.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/**
* $(RED Deprecated. Use $(D core.sys.darwin.mach.kern_return) instead. This
* module will be removed in June 2018.)
*
* D header file for OSX.
*
* Copyright: Copyright Sean Kelly 2008 - 2009.
Expand All @@ -13,61 +16,4 @@
*/
module core.sys.osx.mach.kern_return;

version (OSX):
extern (C):

alias int kern_return_t;

enum : kern_return_t
{
KERN_SUCCESS = 0,
KERN_INVALID_ADDRESS = 1,
KERN_PROTECTION_FAILURE = 2,
KERN_NO_SPACE = 3,
KERN_INVALID_ARGUMENT = 4,
KERN_FAILURE = 5,
KERN_RESOURCE_SHORTAGE = 6,
KERN_NOT_RECEIVER = 7,
KERN_NO_ACCESS = 8,
KERN_MEMORY_FAILURE = 9,
KERN_MEMORY_ERROR = 10,
KERN_ALREADY_IN_SET = 11,
KERN_NOT_IN_SET = 12,
KERN_NAME_EXISTS = 13,
KERN_ABORTED = 14,
KERN_INVALID_NAME = 15,
KERN_INVALID_TASK = 16,
KERN_INVALID_RIGHT = 17,
KERN_INVALID_VALUE = 18,
KERN_UREFS_OVERFLOW = 19,
KERN_INVALID_CAPABILITY = 20,
KERN_RIGHT_EXISTS = 21,
KERN_INVALID_HOST = 22,
KERN_MEMORY_PRESENT = 23,
KERN_MEMORY_DATA_MOVED = 24,
KERN_MEMORY_RESTART_COPY = 25,
KERN_INVALID_PROCESSOR_SET = 26,
KERN_POLICY_LIMIT = 27,
KERN_INVALID_POLICY = 28,
KERN_INVALID_OBJECT = 29,
KERN_ALREADY_WAITING = 30,
KERN_DEFAULT_SET = 31,
KERN_EXCEPTION_PROTECTED = 32,
KERN_INVALID_LEDGER = 33,
KERN_INVALID_MEMORY_CONTROL = 34,
KERN_INVALID_SECURITY = 35,
KERN_NOT_DEPRESSED = 36,
KERN_TERMINATED = 37,
KERN_LOCK_SET_DESTROYED = 38,
KERN_LOCK_UNSTABLE = 39,
KERN_LOCK_OWNED = 40,
KERN_LOCK_OWNED_SELF = 41,
KERN_SEMAPHORE_DESTROYED = 42,
KERN_RPC_SERVER_TERMINATED = 43,
KERN_RPC_TERMINATE_ORPHAN = 44,
KERN_RPC_CONTINUE_ORPHAN = 45,
KERN_NOT_SUPPORTED = 46,
KERN_NODE_DOWN = 47,
KERN_OPERATION_TIMED_OUT = 49,
KERN_RETURN_MAX = 0x100,
}
public import core.sys.darwin.mach.kern_return;
87 changes: 4 additions & 83 deletions src/core/sys/osx/mach/loader.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/**
* $(RED Deprecated. Use $(D core.sys.darwin.mach.loader) instead. This module
* will be removed in June 2018.)
*
* Copyright: Copyright Digital Mars 2010.
* License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Jacob Carlborg
Expand All @@ -12,86 +15,4 @@
*/
module core.sys.osx.mach.loader;

version (OSX):
extern (C):

struct mach_header
{
uint magic;
int cputype;
int cpusubtype;
uint filetype;
uint ncmds;
uint sizeofcmds;
uint flags;
}

struct mach_header_64
{
uint magic;
int cputype;
int cpusubtype;
uint filetype;
uint ncmds;
uint sizeofcmds;
uint flags;
uint reserved;
}

enum uint MH_MAGIC = 0xfeedface;
enum uint MH_CIGAM = 0xcefaedfe;
enum uint MH_MAGIC_64 = 0xfeedfacf;
enum uint MH_CIGAM_64 = 0xcffaedfe;

enum SEG_PAGEZERO = "__PAGEZERO";
enum SEG_TEXT = "__TEXT";
enum SECT_TEXT = "__text";
enum SECT_FVMLIB_INIT0 = "__fvmlib_init0";
enum SECT_FVMLIB_INIT1 = "__fvmlib_init1";
enum SEG_DATA = "__DATA";
enum SECT_DATA = "__data";
enum SECT_BSS = "__bss";
enum SECT_COMMON = "__common";
enum SEG_OBJC = "__OBJC";
enum SECT_OBJC_SYMBOLS = "__symbol_table";
enum SECT_OBJC_MODULES = "__module_info";
enum SECT_OBJC_STRINGS = "__selector_strs";
enum SECT_OBJC_REFS = "__selector_refs";
enum SEG_ICON = "__ICON";
enum SECT_ICON_HEADER = "__header";
enum SECT_ICON_TIFF = "__tiff";
enum SEG_LINKEDIT = "__LINKEDIT";
enum SEG_UNIXSTACK = "__UNIXSTACK";
enum SEG_IMPORT = "__IMPORT";

struct section
{
char[16] sectname;
char[16] segname;
uint addr;
uint size;
uint offset;
uint align_;
uint reloff;
uint nreloc;
uint flags;
uint reserved1;
uint reserved2;
}

struct section_64
{
char[16] sectname;
char[16] segname;
ulong addr;
ulong size;
uint offset;
uint align_;
uint reloff;
uint nreloc;
uint flags;
uint reserved1;
uint reserved2;
uint reserved3;
}

public import core.sys.darwin.mach.loader;
16 changes: 4 additions & 12 deletions src/core/sys/osx/mach/port.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/**
* $(RED Deprecated. Use $(D core.sys.darwin.mach.port) instead. This module
* will be removed in June 2018.)
*
* D header file for OSX.
*
* Copyright: Copyright Sean Kelly 2008 - 2009.
Expand All @@ -13,15 +16,4 @@
*/
module core.sys.osx.mach.port;

version (OSX):
extern (C):

version( X86 )
version = i386;
version( X86_64 )
version = i386;
version( i386 )
{
alias uint natural_t;
alias natural_t mach_port_t;
}
public import core.sys.darwin.mach.port;
46 changes: 4 additions & 42 deletions src/core/sys/osx/mach/semaphore.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/**
* $(RED Deprecated. Use $(D core.sys.darwin.mach.semaphore) instead. This
* module will be removed in June 2018.)
*
* D header file for OSX.
*
* Copyright: Copyright Sean Kelly 2008 - 2009.
Expand All @@ -13,45 +16,4 @@
*/
module core.sys.osx.mach.semaphore;

version (OSX):
extern (C):
nothrow:

public import core.sys.osx.mach.kern_return;
public import core.sys.osx.mach.port;

alias mach_port_t task_t;
alias mach_port_t thread_t;
alias mach_port_t semaphore_t;
alias int sync_policy_t;

alias int clock_res_t;
struct mach_timespec_t
{
uint tv_sec;
clock_res_t tv_nsec;
}

enum
{
SYNC_POLICY_FIFO = 0x0,
SYNC_POLICY_FIXED_PRIORITY = 0x1,
SYNC_POLICY_REVERSED = 0x2,
SYNC_POLICY_ORDER_MASK = 0x3,
SYNC_POLICY_LIFO = (SYNC_POLICY_FIFO | SYNC_POLICY_REVERSED),
SYNC_POLICY_MAX = 0x7,
}

task_t mach_task_self();
kern_return_t semaphore_create(task_t, semaphore_t*, int, int);
kern_return_t semaphore_destroy(task_t, semaphore_t);

kern_return_t semaphore_signal(semaphore_t);
kern_return_t semaphore_signal_all(semaphore_t);
kern_return_t semaphore_signal_thread(semaphore_t, thread_t);

kern_return_t semaphore_wait(semaphore_t);
kern_return_t semaphore_wait_signal(semaphore_t, semaphore_t);

kern_return_t semaphore_timedwait(semaphore_t, mach_timespec_t);
kern_return_t semaphore_timedwait_signal(semaphore_t, semaphore_t, mach_timespec_t);
public import core.sys.darwin.mach.semaphore;
116 changes: 4 additions & 112 deletions src/core/sys/osx/mach/thread_act.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/**
* $(RED Deprecated. Use $(D core.sys.darwin.mach.thread_act) instead. This
* module will be removed in June 2018.)
*
* D header file for OSX.
*
* Copyright: Copyright Sean Kelly 2008 - 2009.
Expand All @@ -13,115 +16,4 @@
*/
module core.sys.osx.mach.thread_act;

version (OSX):
extern (C):
nothrow:

public import core.sys.osx.mach.kern_return;
public import core.sys.osx.mach.port;

version( X86 )
version = i386;
version( X86_64 )
version = i386;
version( i386 )
{
alias mach_port_t thread_act_t;
alias void thread_state_t;
alias int thread_state_flavor_t;
alias natural_t mach_msg_type_number_t;

enum
{
x86_THREAD_STATE32 = 1,
x86_FLOAT_STATE32 = 2,
x86_EXCEPTION_STATE32 = 3,
x86_THREAD_STATE64 = 4,
x86_FLOAT_STATE64 = 5,
x86_EXCEPTION_STATE64 = 6,
x86_THREAD_STATE = 7,
x86_FLOAT_STATE = 8,
x86_EXCEPTION_STATE = 9,
x86_DEBUG_STATE32 = 10,
x86_DEBUG_STATE64 = 11,
x86_DEBUG_STATE = 12,
THREAD_STATE_NONE = 13,
}

struct x86_thread_state32_t
{
uint eax;
uint ebx;
uint ecx;
uint edx;
uint edi;
uint esi;
uint ebp;
uint esp;
uint ss;
uint eflags;
uint eip;
uint cs;
uint ds;
uint es;
uint fs;
uint gs;
}

struct x86_thread_state64_t
{
ulong rax;
ulong rbx;
ulong rcx;
ulong rdx;
ulong rdi;
ulong rsi;
ulong rbp;
ulong rsp;
ulong r8;
ulong r9;
ulong r10;
ulong r11;
ulong r12;
ulong r13;
ulong r14;
ulong r15;
ulong rip;
ulong rflags;
ulong cs;
ulong fs;
ulong gs;
}

struct x86_state_hdr_t
{
int flavor;
int count;
}

struct x86_thread_state_t
{
x86_state_hdr_t tsh;
union _uts
{
x86_thread_state32_t ts32;
x86_thread_state64_t ts64;
}
_uts uts;
}

enum : mach_msg_type_number_t
{
x86_THREAD_STATE32_COUNT = cast(mach_msg_type_number_t)( x86_thread_state32_t.sizeof / int.sizeof ),
x86_THREAD_STATE64_COUNT = cast(mach_msg_type_number_t)( x86_thread_state64_t.sizeof / int.sizeof ),
x86_THREAD_STATE_COUNT = cast(mach_msg_type_number_t)( x86_thread_state_t.sizeof / int.sizeof ),
}

alias x86_THREAD_STATE MACHINE_THREAD_STATE;
alias x86_THREAD_STATE_COUNT MACHINE_THREAD_STATE_COUNT;

mach_port_t mach_thread_self();
kern_return_t thread_suspend(thread_act_t);
kern_return_t thread_resume(thread_act_t);
kern_return_t thread_get_state(thread_act_t, thread_state_flavor_t, thread_state_t*, mach_msg_type_number_t*);
}
public import core.sys.darwin.mach.thread_act;
39 changes: 4 additions & 35 deletions src/core/sys/osx/pthread.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/**
* $(RED Deprecated. Use $(D core.sys.darwin.pthread) instead. This module
* will be removed in June 2018.)
*
* D header file for OSX.
*
* Copyright: Copyright Sean Kelly 2008 - 2009.
Expand All @@ -13,38 +16,4 @@
*/
module core.sys.osx.pthread;

version (OSX):
extern (C):
nothrow:

public import core.sys.posix.pthread;
public import core.sys.osx.mach.port;

int pthread_is_threaded_np();
int pthread_threadid_np(pthread_t, ulong*);
// ^ __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
int pthread_rwlock_longrdlock_np(pthread_rwlock_t*);
int pthread_rwlock_yieldwrlock_np(pthread_rwlock_t*);
// ^ __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA);
int pthread_rwlock_downgrade_np(pthread_rwlock_t*);
int pthread_rwlock_upgrade_np(pthread_rwlock_t*);
int pthread_rwlock_tryupgrade_np(pthread_rwlock_t*);
int pthread_rwlock_held_np(pthread_rwlock_t*);
int pthread_rwlock_rdheld_np(pthread_rwlock_t*);
int pthread_rwlock_wrheld_np(pthread_rwlock_t*);
int pthread_getname_np(pthread_t, char*, size_t);
int pthread_setname_np(in char*);
// ^ __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
int pthread_main_np();
mach_port_t pthread_mach_thread_np(pthread_t);
size_t pthread_get_stacksize_np(pthread_t);
void* pthread_get_stackaddr_np(pthread_t);
int pthread_cond_signal_thread_np(pthread_cond_t*, pthread_t);
int pthread_cond_timedwait_relative_np(pthread_cond_t*, pthread_mutex_t*, in timespec*);
int pthread_create_suspended_np(pthread_t*, in pthread_attr_t*, void* function(void*), void*);
int pthread_kill(pthread_t, int);
pthread_t pthread_from_mach_thread_np(mach_port_t);
// ^ __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
int pthread_sigmask(int, in sigset_t*, sigset_t*);
// ^ __DARWIN_ALIAS(pthread_sigmask)
void pthread_yield_np();
public import core.sys.darwin.pthread;
13 changes: 4 additions & 9 deletions src/core/sys/osx/sys/cdefs.d
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
/**
* $(RED Deprecated. Use $(D core.sys.darwin.sys.cdefs) instead. This module
* will be removed in June 2018.)
*
* D header file for OSX
*
* Authors: Martin Nowak
*/
module core.sys.osx.sys.cdefs;

version (OSX):

public import core.sys.posix.config;

// http://www.opensource.apple.com/source/xnu/xnu-2422.115.4/bsd/sys/cdefs.h
enum _DARWIN_C_SOURCE = true;

enum __DARWIN_C_FULL = 900000L;
enum __DARWIN_C_LEVEL = __DARWIN_C_FULL;
public import core.sys.darwin.sys.cdefs;
119 changes: 4 additions & 115 deletions src/core/sys/osx/sys/event.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/**
* $(RED Deprecated. Use $(D core.sys.darwin.sys.event) instead. This module
* will be removed in June 2018.)
*
* D header file for OSX.
*
* Copyright: Copyright Martin Nowak 2012. Etienne Cimon 2015.
Expand All @@ -13,118 +16,4 @@
*/
module core.sys.osx.sys.event;

version (OSX):
extern (C):

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

enum : short
{
EVFILT_READ = -1,
EVFILT_WRITE = -2,
EVFILT_AIO = -3, /* attached to aio requests */
EVFILT_VNODE = -4, /* attached to vnodes */
EVFILT_PROC = -5, /* attached to struct proc */
EVFILT_SIGNAL = -6, /* attached to struct proc */
EVFILT_TIMER = -7, /* timers */
EVFILT_MACHPORT = -8, /* Mach portsets */
EVFILT_FS = -9, /* filesystem events */
EVFILT_USER = -10, /* User events */
EVFILT_VM = -12, /* virtual memory events */
EVFILT_SYSCOUNT = 11
}

extern(D) void EV_SET(kevent_t* kevp, typeof(kevent_t.tupleof) args)
{
*kevp = kevent_t(args);
}

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 */
}

enum
{
/* actions */
EV_ADD = 0x0001, /* add event to kq (implies enable) */
EV_DELETE = 0x0002, /* delete event from kq */
EV_ENABLE = 0x0004, /* enable event */
EV_DISABLE = 0x0008, /* disable event (not reported) */

/* flags */
EV_ONESHOT = 0x0010, /* only report one occurrence */
EV_CLEAR = 0x0020, /* clear event state after reporting */
EV_RECEIPT = 0x0040, /* force EV_ERROR on success, data=0 */
EV_DISPATCH = 0x0080, /* disable event after reporting */

EV_SYSFLAGS = 0xF000, /* reserved by system */
EV_FLAG1 = 0x2000, /* filter-specific flag */

/* returned values */
EV_EOF = 0x8000, /* EOF detected */
EV_ERROR = 0x4000, /* error, data contains errno */
}

enum
{
/*
* data/hint flags/masks for EVFILT_USER, shared with userspace
*
* On input, the top two bits of fflags specifies how the lower twenty four
* bits should be applied to the stored value of fflags.
*
* On output, the top two bits will always be set to NOTE_FFNOP and the
* remaining twenty four bits will contain the stored fflags value.
*/
NOTE_FFNOP = 0x00000000, /* ignore input fflags */
NOTE_FFAND = 0x40000000, /* AND fflags */
NOTE_FFOR = 0x80000000, /* OR fflags */
NOTE_FFCOPY = 0xc0000000, /* copy fflags */
NOTE_FFCTRLMASK = 0xc0000000, /* masks for operations */
NOTE_FFLAGSMASK = 0x00ffffff,

NOTE_TRIGGER = 0x01000000, /* Cause the event to be
triggered for output. */

/*
* data/hint flags for EVFILT_{READ|WRITE}, shared with userspace
*/
NOTE_LOWAT = 0x0001, /* low water mark */

/*
* data/hint flags for EVFILT_VNODE, shared with userspace
*/
NOTE_DELETE = 0x0001, /* vnode was removed */
NOTE_WRITE = 0x0002, /* data contents changed */
NOTE_EXTEND = 0x0004, /* size increased */
NOTE_ATTRIB = 0x0008, /* attributes changed */
NOTE_LINK = 0x0010, /* link count changed */
NOTE_RENAME = 0x0020, /* vnode was renamed */
NOTE_REVOKE = 0x0040, /* vnode access was revoked */

/*
* data/hint flags for EVFILT_PROC, shared with userspace
*/
NOTE_EXIT = 0x80000000, /* process exited */
NOTE_FORK = 0x40000000, /* process forked */
NOTE_EXEC = 0x20000000, /* process exec'd */
NOTE_PCTRLMASK = 0xf0000000, /* mask for hint bits */
NOTE_PDATAMASK = 0x000fffff, /* mask for pid */

/* additional flags for EVFILT_PROC */
NOTE_TRACK = 0x00000001, /* follow across forks */
NOTE_TRACKERR = 0x00000002, /* could not track child */
NOTE_CHILD = 0x00000004, /* am a child process */
}

int kqueue();
int kevent(int kq, const kevent_t *changelist, int nchanges,
kevent_t *eventlist, int nevents,
const timespec *timeout);
public import core.sys.darwin.sys.event;
99 changes: 4 additions & 95 deletions src/core/sys/osx/sys/mman.d
Original file line number Diff line number Diff line change
@@ -1,102 +1,11 @@
/**
* $(RED Deprecated. Use $(D core.sys.darwin.sys.mman) instead. This module
* will be removed in June 2018.)
*
* D header file for FreeBSD
*
* Authors: Martin Nowak
*/
module core.sys.osx.sys.mman;

version (OSX):
extern (C):
nothrow:

public import core.sys.posix.sys.mman;
import core.sys.osx.sys.cdefs;
import core.sys.posix.sys.types;

// already in core.sys.posix.sys.mman
// enum PROT_NONE = 0x00;
// enum PROT_READ = 0x01;
// enum PROT_WRITE = 0x02;
// enum PROT_EXEC = 0x04;

// already in core.sys.posix.sys.mman
// enum MAP_SHARED = 0x0001;
// enum MAP_PRIVATE = 0x0002;
static if (_DARWIN_C_SOURCE)
alias MAP_COPY = MAP_PRIVATE;
// enum MAP_FIXED = 0x0010;

static if (_DARWIN_C_SOURCE)
{
enum MAP_RENAME = 0x0020;
enum MAP_NORESERVE = 0x0040;
enum MAP_RESERVED0080 = 0x0080;
enum MAP_NOEXTEND = 0x0100;
enum MAP_HASSEMAPHORE = 0x0200;
enum MAP_NOCACHE = 0x0400;
enum MAP_JIT = 0x0800;
}

// already in core.sys.posix.sys.mman
// enum MCL_CURRENT = 0x0001;
// enum MCL_FUTURE = 0x0002;

// enum MAP_FAILED = cast(void*)-1;

// enum MS_ASYNC = 0x0001;
// enum MS_INVALIDATE = 0x0002;
// enum MS_SYNC = 0x0010;

static if (_DARWIN_C_SOURCE)
{
enum MS_KILLPAGES = 0x0004;
enum MS_DEACTIVATE = 0x0008;

enum MAP_FILE = 0x0000;

// already in core.sys.posix.sys.mman
// enum MAP_ANON = 0x1000;

// enum POSIX_MADV_NORMAL = 0;
// enum POSIX_MADV_RANDOM = 1;
// enum POSIX_MADV_SEQUENTIAL = 2;
// enum POSIX_MADV_WILLNEED = 3;
// enum POSIX_MADV_DONTNEED = 4;

alias MADV_NORMAL = POSIX_MADV_NORMAL;
alias MADV_RANDOM = POSIX_MADV_RANDOM;
alias MADV_SEQUENTIAL = POSIX_MADV_SEQUENTIAL;
alias MADV_WILLNEED = POSIX_MADV_WILLNEED;
alias MADV_DONTNEED = POSIX_MADV_DONTNEED;
enum MADV_FREE = 5;
enum MADV_ZERO_WIRED_PAGES = 6;
enum MADV_FREE_REUSABLE = 7;
enum MADV_FREE_REUSE = 8;
enum MADV_CAN_REUSE = 9;

enum MINCORE_INCORE = 0x1;
enum MINCORE_REFERENCED = 0x2;
enum MINCORE_MODIFIED = 0x4;
enum MINCORE_REFERENCED_OTHER = 0x8;
enum MINCORE_MODIFIED_OTHER = 0x10;
}

// already in core.sys.posix.sys.mman
// int mlockall(int);
// int munlockall(void);
// int mlock(const void *, size_t);
// void * mmap(void *, size_t, int, int, int, off_t);
// int mprotect(void *, size_t, int);
// int msync(void *, size_t, int);
// int munlock(const void *, size_t);
// int munmap(void *, size_t);
// int shm_open(const char *, int, ...);
// int shm_unlink(const char *);
// int posix_madvise(void *, size_t, int);

static if (_DARWIN_C_SOURCE)
{
int madvise(void *, size_t, int);
int mincore(const(void)*, size_t, char *);
int minherit(void *, size_t, int);
}
public import core.sys.darwin.sys.mman;
13 changes: 11 additions & 2 deletions src/core/sys/posix/arpa/inet.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ private import core.sys.posix.config;
public import core.stdc.inttypes; // for uint32_t, uint16_t
public import core.sys.posix.sys.socket; // for socklen_t

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C) nothrow @nogc:

Expand Down Expand Up @@ -74,7 +83,7 @@ version( CRuntime_Glibc )
const(char)* inet_ntop(int, in void*, char*, socklen_t);
int inet_pton(int, in char*, void*);
}
else version( OSX )
else version( Darwin )
{
alias uint16_t in_port_t;
alias uint32_t in_addr_t;
Expand Down Expand Up @@ -203,7 +212,7 @@ version( CRuntime_Glibc )
{
enum INET6_ADDRSTRLEN = 46;
}
else version( OSX )
else version( Darwin )
{
enum INET6_ADDRSTRLEN = 46;
}
Expand Down
54 changes: 41 additions & 13 deletions src/core/sys/posix/dirent.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ module core.sys.posix.dirent;
private import core.sys.posix.config;
public import core.sys.posix.sys.types; // for ino_t

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C):
nothrow:
Expand Down Expand Up @@ -81,7 +90,7 @@ version( CRuntime_Glibc )
dirent* readdir(DIR*);
}
}
else version( OSX )
else version( Darwin )
{
enum
{
Expand Down Expand Up @@ -117,7 +126,12 @@ else version( OSX )

// OS X maintains backwards compatibility with older binaries using 32-bit
// inode functions by appending $INODE64 to newer 64-bit inode functions.
pragma(mangle, "readdir$INODE64") dirent* readdir(DIR*);
// Other Darwin variants (iOS, TVOS, WatchOS) only support 64-bit inodes,
// no suffix needed
version( OSX )
pragma(mangle, "readdir$INODE64") dirent* readdir(DIR*);
else
dirent* readdir(DIR*);
}
else version( FreeBSD )
{
Expand Down Expand Up @@ -211,6 +225,9 @@ else
static assert(false, "Unsupported platform");
}

// Only OS X out of the Darwin family needs special treatment. Other Darwins
// (iOS, TVOS, WatchOS) are fine with normal symbol names for these functions
// in else below.
version( OSX )
{
version( D_LP64 )
Expand Down Expand Up @@ -255,9 +272,12 @@ version( CRuntime_Glibc )
int readdir_r(DIR*, dirent*, dirent**);
}
}
else version( OSX )
else version( Darwin )
{
pragma(mangle, "readdir_r$INODE64") int readdir_r(DIR*, dirent*, dirent**);
version( OSX )
pragma(mangle, "readdir_r$INODE64") int readdir_r(DIR*, dirent*, dirent**);
else
int readdir_r(DIR*, dirent*, dirent**);
}
else version( FreeBSD )
{
Expand Down Expand Up @@ -302,19 +322,27 @@ else version( FreeBSD )
void seekdir(DIR*, c_long);
c_long telldir(DIR*);
}
else version ( OSX )
else version (Darwin)
{
version ( D_LP64 )
version( OSX )
{
pragma(mangle, "seekdir$INODE64") void seekdir(DIR*, c_long);
pragma(mangle, "telldir$INODE64") c_long telldir(DIR*);
version ( D_LP64 )
{
pragma(mangle, "seekdir$INODE64") void seekdir(DIR*, c_long);
pragma(mangle, "telldir$INODE64") c_long telldir(DIR*);
}
else
{
// 32-bit mangles __DARWIN_UNIX03 specific functions with $UNIX2003 to
// maintain backward compatibility with binaries build pre 10.5
pragma(mangle, "seekdir$INODE64$UNIX2003") void seekdir(DIR*, c_long);
pragma(mangle, "telldir$INODE64$UNIX2003") c_long telldir(DIR*);
}
}
else
else // other Darwins (e.g. iOS, TVOS, WatchOS)
{
// 32-bit mangles __DARWIN_UNIX03 specific functions with $UNIX2003 to
// maintain backward compatibility with binaries build pre 10.5
pragma(mangle, "seekdir$INODE64$UNIX2003") void seekdir(DIR*, c_long);
pragma(mangle, "telldir$INODE64$UNIX2003") c_long telldir(DIR*);
void seekdir(DIR*, c_long);
c_long telldir(DIR*);
}
}
else version (Solaris)
Expand Down
11 changes: 10 additions & 1 deletion src/core/sys/posix/dlfcn.d
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ module core.sys.posix.dlfcn;

private import core.sys.posix.config;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C):
nothrow:
Expand Down Expand Up @@ -123,7 +132,7 @@ version( CRuntime_Glibc )
}
}
}
else version( OSX )
else version( Darwin )
{
enum RTLD_LAZY = 0x00001;
enum RTLD_NOW = 0x00002;
Expand Down
11 changes: 10 additions & 1 deletion src/core/sys/posix/fcntl.d
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ private import core.stdc.stdint;
public import core.sys.posix.sys.types; // for off_t, mode_t
public import core.sys.posix.sys.stat; // for S_IFMT, etc.

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C):

Expand Down Expand Up @@ -262,7 +271,7 @@ version( CRuntime_Glibc )
enum AT_SYMLINK_NOFOLLOW = 0x100;
enum AT_FDCWD = -100;
}
else version( OSX )
else version( Darwin )
{
enum F_DUPFD = 0;
enum F_GETFD = 1;
Expand Down
15 changes: 12 additions & 3 deletions src/core/sys/posix/grp.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ module core.sys.posix.grp;
private import core.sys.posix.config;
public import core.sys.posix.sys.types; // for gid_t, uid_t

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C):
nothrow:
Expand Down Expand Up @@ -48,7 +57,7 @@ version( CRuntime_Glibc )
char** gr_mem;
}
}
else version( OSX )
else version( Darwin )
{
struct group
{
Expand Down Expand Up @@ -109,7 +118,7 @@ version( CRuntime_Glibc )
int getgrnam_r(in char*, group*, char*, size_t, group**);
int getgrgid_r(gid_t, group*, char*, size_t, group**);
}
else version( OSX )
else version( Darwin )
{
int getgrnam_r(in char*, group*, char*, size_t, group**);
int getgrgid_r(gid_t, group*, char*, size_t, group**);
Expand Down Expand Up @@ -147,7 +156,7 @@ version( CRuntime_Glibc )
@trusted void endgrent();
@trusted void setgrent();
}
else version( OSX )
else version( Darwin )
{
group* getgrent();
@trusted void endgrent();
Expand Down
11 changes: 10 additions & 1 deletion src/core/sys/posix/net/if_.d
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ module core.sys.posix.net.if_;

private import core.sys.posix.config;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C) nothrow @nogc:

Expand Down Expand Up @@ -52,7 +61,7 @@ version( CRuntime_Glibc )
if_nameindex_t* if_nameindex();
void if_freenameindex(if_nameindex_t*);
}
else version( OSX )
else version( Darwin )
{
struct if_nameindex_t
{
Expand Down
11 changes: 10 additions & 1 deletion src/core/sys/posix/netdb.d
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ public import core.sys.posix.netinet.in_; // for in_port_t, in_addr_t
public import core.sys.posix.sys.types; // for ino_t
public import core.sys.posix.sys.socket; // for socklen_t

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C):
nothrow:
Expand Down Expand Up @@ -219,7 +228,7 @@ version( CRuntime_Glibc )
enum EAI_SYSTEM = -11;
enum EAI_OVERFLOW = -12;
}
else version( OSX )
else version( Darwin )
{
struct hostent
{
Expand Down
15 changes: 12 additions & 3 deletions src/core/sys/posix/netinet/in_.d
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ public import core.stdc.inttypes; // for uint32_t, uint16_t, uint8_t
public import core.sys.posix.arpa.inet;
public import core.sys.posix.sys.socket; // for sa_family_t

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C) nothrow @nogc:

Expand Down Expand Up @@ -114,7 +123,7 @@ version( CRuntime_Glibc )

//enum INET_ADDRSTRLEN = 16;
}
else version( OSX )
else version( Darwin )
{
//alias uint16_t in_port_t;
//alias uint32_t in_addr_t;
Expand Down Expand Up @@ -450,7 +459,7 @@ version ( CRuntime_Glibc )
((cast(uint8_t*) addr)[1] & 0xf) == 0xe;
}
}
else version( OSX )
else version( Darwin )
{
struct in6_addr
{
Expand Down Expand Up @@ -981,7 +990,7 @@ version( CRuntime_Glibc )
{
enum uint IPPROTO_RAW = 255;
}
else version( OSX )
else version( Darwin )
{
enum uint IPPROTO_RAW = 255;
}
Expand Down
11 changes: 10 additions & 1 deletion src/core/sys/posix/netinet/tcp.d
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ module core.sys.posix.netinet.tcp;

private import core.sys.posix.config;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C):

Expand All @@ -30,7 +39,7 @@ version( CRuntime_Glibc )
{
enum TCP_NODELAY = 1;
}
else version( OSX )
else version( Darwin )
{
enum TCP_NODELAY = 1;
}
Expand Down
11 changes: 10 additions & 1 deletion src/core/sys/posix/poll.d
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ module core.sys.posix.poll;

private import core.sys.posix.config;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C):
nothrow:
Expand Down Expand Up @@ -75,7 +84,7 @@ version( CRuntime_Glibc )

int poll(pollfd*, nfds_t, int);
}
else version( OSX )
else version( Darwin )
{
struct pollfd
{
Expand Down
31 changes: 20 additions & 11 deletions src/core/sys/posix/pthread.d
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ public import core.sys.posix.time;

import core.stdc.stdint;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C)
nothrow:
Expand Down Expand Up @@ -132,7 +141,7 @@ version( CRuntime_Glibc )
PTHREAD_PROCESS_SHARED
}
}
else version( OSX )
else version( Darwin )
{
enum
{
Expand Down Expand Up @@ -300,7 +309,7 @@ version( CRuntime_Glibc )
}
}
}
else version( OSX )
else version( Darwin )
{
alias void function(void*) _pthread_cleanup_routine;

Expand Down Expand Up @@ -507,7 +516,7 @@ else version( FreeBSD )
int pthread_barrierattr_init(pthread_barrierattr_t*);
int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
}
else version (OSX)
else version (Darwin)
{
}
else version (Solaris)
Expand Down Expand Up @@ -565,7 +574,7 @@ else version( FreeBSD )
int pthread_spin_trylock(pthread_spinlock_t*);
int pthread_spin_unlock(pthread_spinlock_t*);
}
else version (OSX)
else version (Darwin)
{
}
else version (Solaris)
Expand Down Expand Up @@ -615,7 +624,7 @@ version( CRuntime_Glibc )
int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
int pthread_setconcurrency(int);
}
else version( OSX )
else version( Darwin )
{
enum PTHREAD_MUTEX_NORMAL = 0;
enum PTHREAD_MUTEX_ERRORCHECK = 1;
Expand Down Expand Up @@ -698,7 +707,7 @@ else version( FreeBSD )
{
int pthread_getcpuclockid(pthread_t, clockid_t*);
}
else version (OSX)
else version (Darwin)
{
}
else version (Solaris)
Expand Down Expand Up @@ -728,7 +737,7 @@ version( CRuntime_Glibc )
int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
}
else version( OSX )
else version( Darwin )
{
int pthread_mutex_timedlock(pthread_mutex_t*, in timespec*);
int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
Expand Down Expand Up @@ -771,7 +780,7 @@ int pthread_mutexattr_getprotocol(in pthread_mutexattr_t*, int*); (TPI|TPP)
int pthread_mutexattr_setprioceiling(pthread_mutexattr_t*, int); (TPP)
int pthread_mutexattr_setprotocol(pthread_mutexattr_t*, int); (TPI|TPP)
*/
version( OSX )
version( Darwin )
{
enum
{
Expand Down Expand Up @@ -840,7 +849,7 @@ version( CRuntime_Glibc )
int pthread_setschedparam(pthread_t, int, in sched_param*);
int pthread_setschedprio(pthread_t, int);
}
else version( OSX )
else version( Darwin )
{
enum
{
Expand Down Expand Up @@ -935,7 +944,7 @@ version( CRuntime_Glibc )
int pthread_attr_setstackaddr(pthread_attr_t*, void*);
int pthread_attr_setstacksize(pthread_attr_t*, size_t);
}
else version( OSX )
else version( Darwin )
{
int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
int pthread_attr_getstackaddr(in pthread_attr_t*, void**);
Expand Down Expand Up @@ -1006,7 +1015,7 @@ else version( FreeBSD )
int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
}
else version( OSX )
else version( Darwin )
{
int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
int pthread_condattr_setpshared(pthread_condattr_t*, int);
Expand Down
15 changes: 12 additions & 3 deletions src/core/sys/posix/pwd.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ module core.sys.posix.pwd;
private import core.sys.posix.config;
public import core.sys.posix.sys.types; // for gid_t, uid_t

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C):
nothrow:
Expand Down Expand Up @@ -52,7 +61,7 @@ version( CRuntime_Glibc )
char* pw_shell;
}
}
else version( OSX )
else version( Darwin )
{
struct passwd
{
Expand Down Expand Up @@ -133,7 +142,7 @@ version( CRuntime_Glibc )
int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
}
else version( OSX )
else version( Darwin )
{
int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
Expand Down Expand Up @@ -171,7 +180,7 @@ version( CRuntime_Glibc )
passwd* getpwent();
void setpwent();
}
else version ( OSX )
else version ( Darwin )
{
void endpwent();
passwd* getpwent();
Expand Down
15 changes: 12 additions & 3 deletions src/core/sys/posix/sched.d
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ private import core.sys.posix.config;
public import core.sys.posix.time;
public import core.sys.posix.sys.types;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C):
nothrow:
Expand Down Expand Up @@ -60,7 +69,7 @@ version( CRuntime_Glibc )
enum SCHED_RR = 2;
//SCHED_SPORADIC (SS|TSP)
}
else version( OSX )
else version( Darwin )
{
enum SCHED_OTHER = 1;
enum SCHED_FIFO = 4;
Expand Down Expand Up @@ -136,7 +145,7 @@ version( CRuntime_Glibc )
{
int sched_yield();
}
else version( OSX )
else version( Darwin )
{
int sched_yield();
}
Expand Down Expand Up @@ -172,7 +181,7 @@ version( CRuntime_Glibc )
int sched_get_priority_min(int);
int sched_rr_get_interval(pid_t, timespec*);
}
else version( OSX )
else version( Darwin )
{
int sched_get_priority_min(int);
int sched_get_priority_max(int);
Expand Down
13 changes: 11 additions & 2 deletions src/core/sys/posix/semaphore.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ module core.sys.posix.semaphore;
private import core.sys.posix.config;
private import core.sys.posix.time;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C):
nothrow:
Expand Down Expand Up @@ -59,7 +68,7 @@ version( CRuntime_Glibc )

enum SEM_FAILED = cast(sem_t*) null;
}
else version( OSX )
else version( Darwin )
{
alias int sem_t;

Expand Down Expand Up @@ -129,7 +138,7 @@ version( CRuntime_Glibc )
{
int sem_timedwait(sem_t*, in timespec*);
}
else version( OSX )
else version( Darwin )
{
int sem_timedwait(sem_t*, in timespec*);
}
Expand Down
23 changes: 16 additions & 7 deletions src/core/sys/posix/signal.d
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ public import core.stdc.signal;
public import core.sys.posix.sys.types; // for pid_t
//public import core.sys.posix.time; // for timespec, now defined here

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C):
//nothrow: // this causes Issue 12738
Expand Down Expand Up @@ -377,7 +386,7 @@ version( linux )
else
static assert(0, "unimplemented");
}
else version( OSX )
else version( Darwin )
{
//SIGABRT (defined in core.stdc.signal)
enum SIGALRM = 14;
Expand Down Expand Up @@ -538,7 +547,7 @@ else version (linux)
static assert(false, "Architecture not supported.");
}
}
else version( OSX )
else version( Darwin )
{
struct sigaction_t
{
Expand Down Expand Up @@ -755,7 +764,7 @@ version( CRuntime_Glibc )
int sigsuspend(in sigset_t*);
int sigwait(in sigset_t*, int*);
}
else version( OSX )
else version( Darwin )
{
enum SIG_HOLD = cast(sigfn_t2) 5;

Expand Down Expand Up @@ -1422,7 +1431,7 @@ version( CRuntime_Glibc )
int sigpause(int);
int sigrelse(int);
}
else version( OSX )
else version( Darwin )
{
enum SIGPOLL = 7;
enum SIGPROF = 27;
Expand Down Expand Up @@ -1943,7 +1952,7 @@ version( linux )
c_long tv_nsec;
}
}
else version( OSX )
else version( Darwin )
{
struct timespec
{
Expand Down Expand Up @@ -2054,7 +2063,7 @@ else version( FreeBSD )
int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
int sigwaitinfo(in sigset_t*, siginfo_t*);
}
else version (OSX)
else version (Darwin)
{
}
else version (Solaris)
Expand Down Expand Up @@ -2117,7 +2126,7 @@ version( CRuntime_Glibc )
int pthread_kill(pthread_t, int);
int pthread_sigmask(int, in sigset_t*, sigset_t*);
}
else version( OSX )
else version( Darwin )
{
int pthread_kill(pthread_t, int);
int pthread_sigmask(int, in sigset_t*, sigset_t*);
Expand Down
11 changes: 10 additions & 1 deletion src/core/sys/posix/stdio.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ private import core.sys.posix.config;
public import core.stdc.stdio;
public import core.sys.posix.sys.types; // for off_t

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C):

Expand Down Expand Up @@ -264,7 +273,7 @@ version( CRuntime_Glibc )
{
enum P_tmpdir = "/tmp";
}
version( OSX )
version( Darwin )
{
enum P_tmpdir = "/var/tmp";
}
Expand Down
15 changes: 12 additions & 3 deletions src/core/sys/posix/stdlib.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ private import core.sys.posix.config;
public import core.stdc.stdlib;
public import core.sys.posix.sys.wait;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C):
nothrow:
Expand Down Expand Up @@ -111,7 +120,7 @@ version( CRuntime_Glibc )

void* valloc(size_t); // LEGACY non-standard
}
else version( OSX )
else version( Darwin )
{
int setenv(in char*, in char*, int);
int unsetenv(in char*);
Expand Down Expand Up @@ -151,7 +160,7 @@ version( CRuntime_Glibc )
{
int rand_r(uint*);
}
else version( OSX )
else version( Darwin )
{
int rand_r(uint*);
}
Expand Down Expand Up @@ -260,7 +269,7 @@ version( CRuntime_Glibc )
int mkstemp(char*);
}
}
else version( OSX )
else version( Darwin )
{
//WNOHANG (defined in core.sys.posix.sys.wait)
//WUNTRACED (defined in core.sys.posix.sys.wait)
Expand Down
11 changes: 10 additions & 1 deletion src/core/sys/posix/sys/ioctl.d
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ module core.sys.posix.sys.ioctl;

import core.stdc.config;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):

extern (C) nothrow @nogc:
Expand Down Expand Up @@ -318,7 +327,7 @@ version (CRuntime_Glibc)

int ioctl(int __fd, c_ulong __request, ...);
}
else version (OSX)
else version (Darwin)
{
import core.sys.posix.termios; // termios
import core.sys.posix.sys.time; // timeval
Expand Down
11 changes: 10 additions & 1 deletion src/core/sys/posix/sys/ipc.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ module core.sys.posix.sys.ipc;
private import core.sys.posix.config;
public import core.sys.posix.sys.types; // for uid_t, gid_t, mode_t, key_t

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C) nothrow @nogc:

Expand Down Expand Up @@ -75,7 +84,7 @@ version( CRuntime_Glibc )

key_t ftok(in char*, int);
}
else version( OSX )
else version( Darwin )
{

}
Expand Down
25 changes: 17 additions & 8 deletions src/core/sys/posix/sys/mman.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ module core.sys.posix.sys.mman;
private import core.sys.posix.config;
public import core.sys.posix.sys.types; // for off_t, mode_t

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C) nothrow @nogc:

Expand Down Expand Up @@ -58,7 +67,7 @@ version( CRuntime_Glibc )
int posix_madvise(void *__addr, size_t __len, int __advice);
}
}
else version( OSX )
else version( Darwin )
{
enum POSIX_MADV_NORMAL = 0;
enum POSIX_MADV_RANDOM = 1;
Expand Down Expand Up @@ -104,7 +113,7 @@ version( CRuntime_Glibc )
enum PROT_WRITE = 0x2;
enum PROT_EXEC = 0x4;
}
else version( OSX )
else version( Darwin )
{
enum PROT_NONE = 0x00;
enum PROT_READ = 0x01;
Expand Down Expand Up @@ -154,7 +163,7 @@ version( CRuntime_Glibc )
void* mmap(void*, size_t, int, int, int, off_t);
int munmap(void*, size_t);
}
else version( OSX )
else version( Darwin )
{
void* mmap(void*, size_t, int, int, int, off_t);
int munmap(void*, size_t);
Expand Down Expand Up @@ -288,7 +297,7 @@ version( CRuntime_Glibc )

int msync(void*, size_t, int);
}
else version( OSX )
else version( Darwin )
{
enum MAP_SHARED = 0x0001;
enum MAP_PRIVATE = 0x0002;
Expand Down Expand Up @@ -413,7 +422,7 @@ version( CRuntime_Glibc )
int munlockall();

}
else version( OSX )
else version( Darwin )
{
enum MCL_CURRENT = 0x0001;
enum MCL_FUTURE = 0x0002;
Expand Down Expand Up @@ -463,7 +472,7 @@ version( CRuntime_Glibc )
int mlock(in void*, size_t);
int munlock(in void*, size_t);
}
else version( OSX )
else version( Darwin )
{
int mlock(in void*, size_t);
int munlock(in void*, size_t);
Expand Down Expand Up @@ -499,7 +508,7 @@ version (CRuntime_Glibc)
{
int mprotect(void*, size_t, int);
}
else version( OSX )
else version( Darwin )
{
int mprotect(void*, size_t, int);
}
Expand Down Expand Up @@ -533,7 +542,7 @@ version( CRuntime_Glibc )
int shm_open(in char*, int, mode_t);
int shm_unlink(in char*);
}
else version( OSX )
else version( Darwin )
{
int shm_open(in char*, int, mode_t);
int shm_unlink(in char*);
Expand Down
15 changes: 12 additions & 3 deletions src/core/sys/posix/sys/resource.d
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ public import core.sys.posix.sys.time;
public import core.sys.posix.sys.types: id_t;
import core.sys.posix.config;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

nothrow extern(C):

//
Expand Down Expand Up @@ -134,7 +143,7 @@ version (CRuntime_Glibc)
RLIMIT_AS = 9,
}
}
else version (OSX)
else version (Darwin)
{
enum
{
Expand Down Expand Up @@ -366,7 +375,7 @@ else version (Solaris)
int getpriority(int, id_t);
int setpriority(int, id_t, int);
}
else version (OSX)
else version (Darwin)
{
int getpriority(int, id_t);
int setpriority(int, id_t, int);
Expand Down Expand Up @@ -394,7 +403,7 @@ else version (CRuntime_Bionic)
int getrusage(int, rusage*);
int setrlimit(int, in rlimit*);
}
else version (OSX)
else version (Darwin)
{
int getrlimit(int, rlimit*);
int getrusage(int, rusage*);
Expand Down
11 changes: 10 additions & 1 deletion src/core/sys/posix/sys/select.d
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ public import core.sys.posix.signal; // for sigset_t
//debug=select; // uncomment to turn on debugging printf's
version(unittest) import core.stdc.stdio: printf;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C) nothrow @nogc:

Expand Down Expand Up @@ -131,7 +140,7 @@ version( CRuntime_Glibc )
int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
int select(int, fd_set*, fd_set*, fd_set*, timeval*);
}
else version( OSX )
else version( Darwin )
{
private
{
Expand Down
11 changes: 10 additions & 1 deletion src/core/sys/posix/sys/shm.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ private import core.sys.posix.config;
public import core.sys.posix.sys.types; // for pid_t, time_t, key_t
public import core.sys.posix.sys.ipc;

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C) nothrow @nogc:

Expand Down Expand Up @@ -121,7 +130,7 @@ else version( FreeBSD )
int shmdt(in void*);
int shmget(key_t, size_t, int);
}
else version( OSX )
else version( Darwin )
{

}
15 changes: 12 additions & 3 deletions src/core/sys/posix/sys/socket.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ private import core.sys.posix.config;
public import core.sys.posix.sys.types; // for ssize_t
public import core.sys.posix.sys.uio; // for iovec

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C) nothrow @nogc:

Expand Down Expand Up @@ -596,7 +605,7 @@ version( CRuntime_Glibc )
int sockatmark(int);
int socketpair(int, int, int, ref int[2]);
}
else version( OSX )
else version( Darwin )
{
alias uint socklen_t;
alias ubyte sa_family_t;
Expand Down Expand Up @@ -1297,7 +1306,7 @@ version( CRuntime_Glibc )
AF_INET6 = 10
}
}
else version( OSX )
else version( Darwin )
{
enum
{
Expand Down Expand Up @@ -1344,7 +1353,7 @@ version( CRuntime_Glibc )
SOCK_RAW = 3
}
}
else version( OSX )
else version( Darwin )
{
enum
{
Expand Down
30 changes: 24 additions & 6 deletions src/core/sys/posix/sys/stat.d
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ private import core.stdc.stdint;
private import core.sys.posix.time; // for timespec
public import core.sys.posix.sys.types; // for off_t, mode_t

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C) nothrow @nogc:

Expand Down Expand Up @@ -637,7 +646,7 @@ version( CRuntime_Glibc )
ref const(timespec)[2] times, int flags);
int futimens(int fd, ref const(timespec)[2] times);
}
else version( OSX )
else version( Darwin )
{
// _DARWIN_FEATURE_64_BIT_INODE stat is default for Mac OSX >10.5 and is
// only meaningful type for other OS X/Darwin variants (e.g. iOS).
Expand Down Expand Up @@ -1110,13 +1119,22 @@ else version (Solaris)
}
}
}
else version( OSX )
else version( Darwin )
{
// OS X maintains backwards compatibility with older binaries using 32-bit
// inode functions by appending $INODE64 to newer 64-bit inode functions.
pragma(mangle, "fstat$INODE64") int fstat(int, stat_t*);
pragma(mangle, "lstat$INODE64") int lstat(in char*, stat_t*);
pragma(mangle, "stat$INODE64") int stat(in char*, stat_t*);
version( OSX )
{
pragma(mangle, "fstat$INODE64") int fstat(int, stat_t*);
pragma(mangle, "lstat$INODE64") int lstat(in char*, stat_t*);
pragma(mangle, "stat$INODE64") int stat(in char*, stat_t*);
}
else
{
int fstat(int, stat_t*);
int lstat(in char*, stat_t*);
int stat(in char*, stat_t*);
}
}
else version( FreeBSD )
{
Expand Down Expand Up @@ -1167,7 +1185,7 @@ version( CRuntime_Glibc )

int mknod(in char*, mode_t, dev_t);
}
else version( OSX )
else version( Darwin )
{
enum S_IFMT = 0xF000; // octal 0170000
enum S_IFBLK = 0x6000; // octal 0060000
Expand Down
11 changes: 10 additions & 1 deletion src/core/sys/posix/sys/time.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ private import core.sys.posix.config;
public import core.sys.posix.sys.types; // for time_t, suseconds_t
public import core.sys.posix.sys.select; // for fd_set, FD_CLR() FD_ISSET() FD_SET() FD_ZERO() FD_SETSIZE, select()

version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;

version (Posix):
extern (C) nothrow @nogc:

Expand Down Expand Up @@ -71,7 +80,7 @@ version( CRuntime_Glibc )
int setitimer(int, in itimerval*, itimerval*);
int utimes(in char*, ref const(timeval)[2]); // LEGACY
}
else version( OSX )
else version( Darwin )
{
struct timeval
{
Expand Down
Loading