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);
}
44 changes: 44 additions & 0 deletions src/core/sys/freebsd/pthread_np.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* D header file for FreeBSD.
*
* Authors: Martin Nowak
*/
module core.sys.freebsd.pthread;

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

public import core.sys.posix.sys.types;
// TODO: add full core.sys.freebsd.sys.cpuset;
public import core.sys.freebsd.sys._cpuset;
public import core.sys.posix.time;

enum __BSD_VISIBLE = true;

alias pthread_switch_routine_t = void function(pthread_t, pthread_t);

int pthread_attr_setcreatesuspend_np(pthread_attr_t *);
int pthread_attr_get_np(pthread_t, pthread_attr_t *);
int pthread_attr_getaffinity_np(const(pthread_attr_t)*, size_t, cpuset_t *);
int pthread_attr_setaffinity_np(pthread_attr_t *, size_t, const(cpuset_t)*);
int pthread_getaffinity_np(pthread_t, size_t, cpuset_t *);
int pthread_getthreadid_np();
int pthread_main_np();
int pthread_multi_np();
int pthread_mutexattr_getkind_np(pthread_mutexattr_t);
int pthread_mutexattr_setkind_np(pthread_mutexattr_t *, int);
void pthread_resume_all_np();
int pthread_resume_np(pthread_t);
void pthread_set_name_np(pthread_t, const(char)*);
int pthread_mutex_getspinloops_np(pthread_mutex_t *mutex, int *count);
int pthread_mutex_setspinloops_np(pthread_mutex_t *mutex, int count);
int pthread_mutex_getyieldloops_np(pthread_mutex_t *mutex, int *count);
int pthread_mutex_setyieldloops_np(pthread_mutex_t *mutex, int count);
int pthread_mutex_isowned_np(pthread_mutex_t *mutex);
int pthread_setaffinity_np(pthread_t, size_t, const(cpuset_t)*);
int pthread_single_np();
void pthread_suspend_all_np();
int pthread_suspend_np(pthread_t);
int pthread_switch_add_np(pthread_switch_routine_t);
int pthread_switch_delete_np(pthread_switch_routine_t);
int pthread_timedjoin_np(pthread_t, void **, const(timespec)*);
45 changes: 45 additions & 0 deletions src/core/sys/freebsd/sys/_bitset.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* D header file for FreeBSD.
*
* Authors: Martin Nowak
*/
module core.sys.freebsd.sys._bitset;

version (FreeBSD):
extern (C) pure nothrow @nogc:

import core.stdc.config : c_long;

enum NBBY = 8; // number of bits per byte

enum _BITSET_BITS = c_long.sizeof * NBBY;

enum __bitset_words(size_t s) = (s + _BITSET_BITS - 1) / _BITSET_BITS;

c_long __bitset_mask(size_t s)(size_t n)
{
static if (__bitset_words!s == 1)
return (cast(c_long)1) << n;
else
return (cast(c_long)1) << n % _BITSET_BITS;
}

size_t __bitset_word(size_t s)(size_t n)
{
static if (__bitset_words!s == 1)
return 0;
else
return n / _BITSET_BITS;
}

struct BITSET_DEFINE(size_t s)
{
c_long[__bitset_words!s] __bits;
}

// no idea how to translate those
//#define BITSET_T_INITIALIZER(x) \
// { .__bits = { x } }
//
//#define BITSET_FSET(n) \
// [ 0 ... ((n) - 1) ] = (-1L)
29 changes: 29 additions & 0 deletions src/core/sys/freebsd/sys/_cpuset.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* D header file for FreeBSD.
*
* Authors: Martin Nowak
*/
module core.sys.freebsd.sys._cpuset;

version (FreeBSD):
extern (C) pure nothrow @nogc:

public import core.sys.freebsd.sys._bitset;

static if (is(typeof(_KERNEL)))
alias CPU_SETSIZE = MAXCPU;

enum CPU_MAXSIZE = 256;

static if (!is(typeof(CPU_SETSIZE)))
alias CPU_SETSIZE = CPU_MAXSIZE;

enum _NCPUBITS = _BITSET_BITS;
enum _NCPUWORDS = __bitset_words!CPU_SETSIZE;

alias _cpuset = BITSET_DEFINE!(CPU_SETSIZE);
alias cpuset_t = _cpuset;

// no idea how to translate those
//#define CPUSET_FSET BITSET_FSET(_NCPUWORDS)
//#define CPUSET_T_INITIALIZER BITSET_T_INITIALIZER
2 changes: 1 addition & 1 deletion src/core/sys/linux/dlfcn.d
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ static if (__USE_GNU)
void* dli_saddr;
}

int dladdr(void* __address, Dl_info* __info);
int dladdr(in void* __address, Dl_info* __info);
int dladdr1(void* __address, Dl_info* __info, void** __extra_info, int __flags);

enum
Expand Down
2 changes: 2 additions & 0 deletions src/core/sys/linux/elf.d
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,8 @@ enum AT_BASE_PLATFORM = 24;

enum AT_RANDOM = 25;

enum AT_HWCAP2 = 26;

enum AT_EXECFN = 31;
enum AT_SYSINFO = 32;
enum AT_SYSINFO_EHDR = 33;
Expand Down
223 changes: 223 additions & 0 deletions src/core/sys/linux/sys/auxv.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
/**
* D header file for GNU/Linux.
*
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Authors: Kai Nacke
*/
module core.sys.linux.sys.auxv;

import core.stdc.config;

version (linux):
extern (C):

c_ulong getauxval(c_ulong type) nothrow pure @nogc @system;

version(ARM)
{
// See https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/arm/bits/hwcap.h

enum HWCAP_ARM_SWP = 1;
enum HWCAP_ARM_HALF = 2;
enum HWCAP_ARM_THUMB = 4;
enum HWCAP_ARM_26BIT = 8;
enum HWCAP_ARM_FAST_MULT = 16;
enum HWCAP_ARM_FPA = 32;
enum HWCAP_ARM_VFP = 64;
enum HWCAP_ARM_EDSP = 128;
enum HWCAP_ARM_JAVA = 256;
enum HWCAP_ARM_IWMMXT = 512;
enum HWCAP_ARM_CRUNCH = 1024;
enum HWCAP_ARM_THUMBEE = 2048;
enum HWCAP_ARM_NEON = 4096;
enum HWCAP_ARM_VFPv3 = 8192;
enum HWCAP_ARM_VFPv3D16 = 16384;
enum HWCAP_ARM_TLS = 32768;
enum HWCAP_ARM_VFPv4 = 65536;
enum HWCAP_ARM_IDIVA = 131072;
enum HWCAP_ARM_IDIVT = 262144;
enum HWCAP_ARM_VFPD32 = 524288;
enum HWCAP_ARM_LPAE = 1048576;
enum HWCAP_ARM_EVTSTRM = 2097152;
}
else version(AArch64)
{
// See https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/aarch64/bits/hwcap.h

enum HWCAP_FP = 1;
enum HWCAP_ASIMD = 2;
enum HWCAP_EVTSTRM = 4;
enum HWCAP_AES = 8;
enum HWCAP_PMULL = 16;
enum HWCAP_SHA1 = 32;
enum HWCAP_SHA2 = 64;
enum HWCAP_CRC32 = 128;
enum HWCAP_ATOMICS = 256;
enum HWCAP_FPHP = 512;
enum HWCAP_ASIMDHP = 1024;
}
else version(PPC)
{
// See https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/powerpc/bits/hwcap.h

enum PPC_FEATURE_32 = 0x80000000;
enum PPC_FEATURE_64 = 0x40000000;
enum PPC_FEATURE_601_INSTR = 0x20000000;
enum PPC_FEATURE_HAS_ALTIVEC = 0x10000000;
enum PPC_FEATURE_HAS_FPU = 0x08000000;
enum PPC_FEATURE_HAS_MMU = 0x04000000;
enum PPC_FEATURE_HAS_4xxMAC = 0x02000000;
enum PPC_FEATURE_UNIFIED_CACHE = 0x01000000;
enum PPC_FEATURE_HAS_SPE = 0x00800000;
enum PPC_FEATURE_HAS_EFP_SINGLE = 0x00400000;
enum PPC_FEATURE_HAS_EFP_DOUBLE = 0x00200000;
enum PPC_FEATURE_NO_TB = 0x00100000;
enum PPC_FEATURE_POWER4 = 0x00080000;
enum PPC_FEATURE_POWER5 = 0x00040000;
enum PPC_FEATURE_POWER5_PLUS = 0x00020000;
enum PPC_FEATURE_CELL_BE = 0x00010000;
enum PPC_FEATURE_BOOKE = 0x00008000;
enum PPC_FEATURE_SMT = 0x00004000;

enum PPC_FEATURE_ICACHE_SNOOP = 0x00002000;
enum PPC_FEATURE_ARCH_2_05 = 0x00001000;
enum PPC_FEATURE_PA6T = 0x00000800;
enum PPC_FEATURE_HAS_DFP = 0x00000400;
enum PPC_FEATURE_POWER6_EXT = 0x00000200;
enum PPC_FEATURE_ARCH_2_06 = 0x00000100;
enum PPC_FEATURE_HAS_VSX = 0x00000080;
enum PPC_FEATURE_PSERIES_PERFMON_COMPAT = 0x00000040;
enum PPC_FEATURE_TRUE_LE = 0x00000002;
enum PPC_FEATURE_PPC_LE = 0x00000001;

enum PPC_FEATURE2_ARCH_2_07 = 0x80000000;
enum PPC_FEATURE2_HAS_HTM = 0x40000000;
enum PPC_FEATURE2_HAS_DSCR = 0x20000000;
enum PPC_FEATURE2_HAS_EBB = 0x10000000;
enum PPC_FEATURE2_HAS_ISEL = 0x08000000;
enum PPC_FEATURE2_HAS_TAR = 0x04000000;
enum PPC_FEATURE2_HAS_VEC_CRYPTO = 0x02000000;
}
else version(PPC64)
{
// See https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/powerpc/bits/hwcap.h

enum PPC_FEATURE_32 = 0x80000000;
enum PPC_FEATURE_64 = 0x40000000;
enum PPC_FEATURE_601_INSTR = 0x20000000;
enum PPC_FEATURE_HAS_ALTIVEC = 0x10000000;
enum PPC_FEATURE_HAS_FPU = 0x08000000;
enum PPC_FEATURE_HAS_MMU = 0x04000000;
enum PPC_FEATURE_HAS_4xxMAC = 0x02000000;
enum PPC_FEATURE_UNIFIED_CACHE = 0x01000000;
enum PPC_FEATURE_HAS_SPE = 0x00800000;
enum PPC_FEATURE_HAS_EFP_SINGLE = 0x00400000;
enum PPC_FEATURE_HAS_EFP_DOUBLE = 0x00200000;
enum PPC_FEATURE_NO_TB = 0x00100000;
enum PPC_FEATURE_POWER4 = 0x00080000;
enum PPC_FEATURE_POWER5 = 0x00040000;
enum PPC_FEATURE_POWER5_PLUS = 0x00020000;
enum PPC_FEATURE_CELL_BE = 0x00010000;
enum PPC_FEATURE_BOOKE = 0x00008000;
enum PPC_FEATURE_SMT = 0x00004000;

enum PPC_FEATURE_ICACHE_SNOOP = 0x00002000;
enum PPC_FEATURE_ARCH_2_05 = 0x00001000;
enum PPC_FEATURE_PA6T = 0x00000800;
enum PPC_FEATURE_HAS_DFP = 0x00000400;
enum PPC_FEATURE_POWER6_EXT = 0x00000200;
enum PPC_FEATURE_ARCH_2_06 = 0x00000100;
enum PPC_FEATURE_HAS_VSX = 0x00000080;
enum PPC_FEATURE_PSERIES_PERFMON_COMPAT = 0x00000040;
enum PPC_FEATURE_TRUE_LE = 0x00000002;
enum PPC_FEATURE_PPC_LE = 0x00000001;

enum PPC_FEATURE2_ARCH_2_07 = 0x80000000;
enum PPC_FEATURE2_HAS_HTM = 0x40000000;
enum PPC_FEATURE2_HAS_DSCR = 0x20000000;
enum PPC_FEATURE2_HAS_EBB = 0x10000000;
enum PPC_FEATURE2_HAS_ISEL = 0x08000000;
enum PPC_FEATURE2_HAS_TAR = 0x04000000;
enum PPC_FEATURE2_HAS_VEC_CRYPTO = 0x02000000;
}
else version(SPARC)
{
// See https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/sparc/bits/hwcap.h

enum HWCAP_SPARC_FLUSH = 0x00000001;
enum HWCAP_SPARC_STBAR = 0x00000002;
enum HWCAP_SPARC_SWAP = 0x00000004;
enum HWCAP_SPARC_MULDIV = 0x00000008;
enum HWCAP_SPARC_V9 = 0x00000010;
enum HWCAP_SPARC_ULTRA3 = 0x00000020;
enum HWCAP_SPARC_BLKINIT = 0x00000040;
enum HWCAP_SPARC_N2 = 0x00000080;
enum HWCAP_SPARC_MUL32 = 0x00000100;
enum HWCAP_SPARC_DIV32 = 0x00000200;
enum HWCAP_SPARC_FSMULD = 0x00000400;
enum HWCAP_SPARC_V8PLUS = 0x00000800;
enum HWCAP_SPARC_POPC = 0x00001000;
enum HWCAP_SPARC_VIS = 0x00002000;
enum HWCAP_SPARC_VIS2 = 0x00004000;
enum HWCAP_SPARC_ASI_BLK_INIT = 0x00008000;
enum HWCAP_SPARC_FMAF = 0x00010000;
enum HWCAP_SPARC_VIS3 = 0x00020000;
enum HWCAP_SPARC_HPC = 0x00040000;
enum HWCAP_SPARC_RANDOM = 0x00080000;
enum HWCAP_SPARC_TRANS = 0x00100000;
enum HWCAP_SPARC_FJFMAU = 0x00200000;
enum HWCAP_SPARC_IMA = 0x00400000;
enum HWCAP_SPARC_ASI_CACHE_SPARING = 0x00800000;
enum HWCAP_SPARC_PAUSE = 0x01000000;
enum HWCAP_SPARC_CBCOND = 0x02000000;
enum HWCAP_SPARC_CRYPTO = 0x04000000;
}
else version(SPARC64)
{
// See https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/sparc/bits/hwcap.h

enum HWCAP_SPARC_FLUSH = 0x00000001;
enum HWCAP_SPARC_STBAR = 0x00000002;
enum HWCAP_SPARC_SWAP = 0x00000004;
enum HWCAP_SPARC_MULDIV = 0x00000008;
enum HWCAP_SPARC_V9 = 0x00000010;
enum HWCAP_SPARC_ULTRA3 = 0x00000020;
enum HWCAP_SPARC_BLKINIT = 0x00000040;
enum HWCAP_SPARC_N2 = 0x00000080;
enum HWCAP_SPARC_MUL32 = 0x00000100;
enum HWCAP_SPARC_DIV32 = 0x00000200;
enum HWCAP_SPARC_FSMULD = 0x00000400;
enum HWCAP_SPARC_V8PLUS = 0x00000800;
enum HWCAP_SPARC_POPC = 0x00001000;
enum HWCAP_SPARC_VIS = 0x00002000;
enum HWCAP_SPARC_VIS2 = 0x00004000;
enum HWCAP_SPARC_ASI_BLK_INIT = 0x00008000;
enum HWCAP_SPARC_FMAF = 0x00010000;
enum HWCAP_SPARC_VIS3 = 0x00020000;
enum HWCAP_SPARC_HPC = 0x00040000;
enum HWCAP_SPARC_RANDOM = 0x00080000;
enum HWCAP_SPARC_TRANS = 0x00100000;
enum HWCAP_SPARC_FJFMAU = 0x00200000;
enum HWCAP_SPARC_IMA = 0x00400000;
enum HWCAP_SPARC_ASI_CACHE_SPARING = 0x00800000;
enum HWCAP_SPARC_PAUSE = 0x01000000;
enum HWCAP_SPARC_CBCOND = 0x02000000;
enum HWCAP_SPARC_CRYPTO = 0x04000000;
}
else version(SystemZ)
{
// See https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/s390/bits/hwcap.h

enum HWCAP_S390_ESAN3 = 1;
enum HWCAP_S390_ZARCH = 2;
enum HWCAP_S390_STFLE = 4;
enum HWCAP_S390_MSA = 8;
enum HWCAP_S390_LDISP = 16;
enum HWCAP_S390_EIMM = 32;
enum HWCAP_S390_DFP = 64;
enum HWCAP_S390_HPAGE = 128;
enum HWCAP_S390_ETF3EH = 256;
enum HWCAP_S390_HIGH_GPRS = 512;
enum HWCAP_S390_TE = 1024;
enum HWCAP_S390_VX = 2048;
}
5 changes: 4 additions & 1 deletion src/core/sys/linux/sys/inotify.d
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ enum: uint
IN_DELETE = 0x00000200,
IN_DELETE_SELF = 0x00000400,
IN_MOVE_SELF = 0x00000800,
IN_UMOUNT = 0x00002000,
IN_UNMOUNT = 0x00002000,
IN_Q_OVERFLOW = 0x00004000,
IN_IGNORED = 0x00008000,
IN_CLOSE = 0x00000018,
Expand All @@ -48,6 +48,9 @@ enum: uint
IN_ALL_EVENTS = 0x80000FFF,
}

// Old typo, preserved for compatibility
enum IN_UMOUNT = IN_UNMOUNT;

version (X86)
{
enum IN_CLOEXEC = 0x80000; // octal!2000000
Expand Down
30 changes: 30 additions & 0 deletions src/core/sys/openbsd/dlfcn.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* D header file for OpenBSD.
*
* $(LINK2 http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/include/link_elf.h?rev=1.6&content-type=text/x-cvsweb-markup, dlfcn.h)
*/
module core.sys.openbsd.dlfcn;

public import core.sys.posix.dlfcn;

version (OpenBSD):
extern (C):
nothrow:

static assert(RTLD_LAZY == 1);
static assert(RTLD_NOW == 2);
static assert(RTLD_GLOBAL == 0x100);
static assert(RTLD_LOCAL == 0);
enum RTLD_TRACE = 0x200;

enum RTLD_NEXT = cast(void *)-1;
enum RTLD_DEFAULT = cast(void *)-2;
enum RTLD_SELF = cast(void *)-3;

enum DL_GETERRNO = 1;
enum DL_SETTHREADLCK = 2;
enum DL_SETBINDLCK = 3;

enum DL_LAZY = RTLD_LAZY;

int dlctl(void *, int, void *);
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
109 changes: 92 additions & 17 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 @@ -148,6 +162,36 @@ else version( FreeBSD )

dirent* readdir(DIR*);
}
else version( OpenBSD )
{
enum
{
DT_UNKNOWN = 0,
DT_FIFO = 1,
DT_CHR = 2,
DT_DIR = 4,
DT_BLK = 6,
DT_REG = 8,
DT_LNK = 10,
DT_SOCK = 12,
}

align(4)
struct dirent
{
ino_t d_fileno;
off_t d_off;
ushort d_reclen;
ubyte d_type;
ubyte d_namlen;
ubyte[4] __d_padding;
char[256] d_name;
}

alias void* DIR;

dirent* readdir(DIR*);
}
else version (Solaris)
{
struct dirent
Expand All @@ -166,14 +210,22 @@ else version (Solaris)
char* dd_buf;
}

static if (__USE_LARGEFILE64)
version (D_LP64)
{
dirent* readdir64(DIR*);
alias readdir64 readdir;
dirent* readdir(DIR*);
alias readdir64 = readdir;
}
else
{
dirent* readdir(DIR*);
static if (__USE_LARGEFILE64)
{
dirent* readdir64(DIR*);
alias readdir64 readdir;
}
else
{
dirent* readdir(DIR*);
}
}
}
else version( CRuntime_Bionic )
Expand Down Expand Up @@ -211,6 +263,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,14 +310,21 @@ 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 )
{
int readdir_r(DIR*, dirent*, dirent**);
}
else version( OpenBSD )
{
int readdir_r(DIR*, dirent*, dirent**);
}
else version (Solaris)
{
static if (__USE_LARGEFILE64)
Expand Down Expand Up @@ -302,19 +364,32 @@ else version( FreeBSD )
void seekdir(DIR*, c_long);
c_long telldir(DIR*);
}
else version ( OSX )
else version( OpenBSD )
{
version ( D_LP64 )
void seekdir(DIR*, c_long);
c_long telldir(DIR*);
}
else version (Darwin)
{
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
34 changes: 32 additions & 2 deletions 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 @@ -111,7 +120,7 @@ version( CRuntime_Glibc )

deprecated("Please use core.sys.linux.dlfcn for non-POSIX extensions")
{
int dladdr(void* addr, Dl_info* info);
int dladdr(in void* addr, Dl_info* info);
void* dlvsym(void* handle, in char* symbol, in char* version_);

struct Dl_info
Expand All @@ -123,7 +132,7 @@ version( CRuntime_Glibc )
}
}
}
else version( OSX )
else version( Darwin )
{
enum RTLD_LAZY = 0x00001;
enum RTLD_NOW = 0x00002;
Expand Down Expand Up @@ -165,6 +174,27 @@ else version( FreeBSD )
void* dli_saddr;
}
}
else version( OpenBSD )
{
enum RTLD_LAZY = 1;
enum RTLD_NOW = 2;
enum RTLD_GLOBAL = 0x100;
enum RTLD_LOCAL = 0;

int dlclose(void*);
char* dlerror();
void* dlopen(in char*, int);
void* dlsym(void*, in char*);
int dladdr(const(void)* addr, Dl_info* info);

struct Dl_info
{
const(char)* dli_fname;
void* dli_fbase;
const(char)* dli_sname;
void* dli_saddr;
}
}
else version( Solaris )
{
enum RTLD_LAZY = 1;
Expand Down
86 changes: 85 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 @@ -258,8 +267,11 @@ version( CRuntime_Glibc )
int creat(in char*, mode_t);
int open(in char*, int, ...);
}

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 Expand Up @@ -366,6 +378,78 @@ else version( FreeBSD )

int creat(in char*, mode_t);
int open(in char*, int, ...);

enum AT_SYMLINK_NOFOLLOW = 0x200;
enum AT_FDCWD = -100;
}
else version( OpenBSD )
{
enum F_DUPFD = 0;
enum F_GETFD = 1;
enum F_SETFD = 2;
enum F_GETFL = 3;
enum F_SETFL = 4;
enum F_GETOWN = 5;
enum F_SETOWN = 6;
enum F_GETLK = 7;
enum F_SETLK = 8;
enum F_SETLKW = 9;
enum F_DUPFD_CLOEXEC= 10;
enum F_ISATTY = 11;

enum FD_CLOEXEC = 1;

enum F_RDLCK = 1;
enum F_UNLCK = 2;
enum F_WRLCK = 3;

enum O_CREAT = 0x0200;
enum O_EXCL = 0x0800;
enum O_NOCTTY = 0x8000;
enum O_TRUNC = 0x0400;

enum O_RDONLY = 0x0000;
enum O_WRONLY = 0x0001;
enum O_RDWR = 0x0002;
enum O_ACCMODE = 0x0003;
enum O_SHLOCK = 0x0010;
enum O_EXLOCK = 0x0020;
enum O_ASYNC = 0x0040;
enum O_FSYNC = 0x0080;
enum O_NOFOLLOW = 0x0100;

enum O_NONBLOCK = 0x0004;
enum O_APPEND = 0x0008;
enum O_SYNC = 0x0080;
enum O_DSYNC = O_SYNC;
enum O_RSYNC = O_SYNC;

enum O_CLOEXEC = 0x10000;
enum O_DIRECTORY = 0x20000;

enum LOCK_SH = 0x01;
enum LOCK_EX = 0x02;
enum LOCK_NB = 0x04;
enum LOCK_UN = 0x08;

struct flock
{
off_t l_start;
off_t l_len;
pid_t l_pid;
short l_type;
short l_whence;
}

int creat(in char*, mode_t);
int open(in char*, int, ...);

enum AT_FDCWD = -100;

enum AT_EACCESS = 0x01;
enum AT_SYMLINK_NOFOLLOW = 0x02;
enum AT_SYMLINK_FOLLOW = 0x04;
enum AT_REMOVEDIR = 0x08;
}
else version (Solaris)
{
Expand Down
36 changes: 33 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 All @@ -68,6 +77,16 @@ else version( FreeBSD )
char** gr_mem;
}
}
else version( OpenBSD )
{
struct group
{
char* gr_name;
char* gr_passwd;
gid_t gr_gid;
char** gr_mem;
}
}
else version( Solaris )
{
struct group
Expand Down Expand Up @@ -109,7 +128,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 All @@ -119,6 +138,11 @@ else version( FreeBSD )
int getgrnam_r(in char*, group*, char*, size_t, group**);
int getgrgid_r(gid_t, group*, char*, size_t, group**);
}
else version( OpenBSD )
{
int getgrnam_r(in char*, group*, char*, size_t, group**);
int getgrgid_r(gid_t, group*, char*, size_t, group**);
}
else version( Solaris )
{
int getgrnam_r(in char*, group*, char*, int, group**);
Expand Down Expand Up @@ -147,7 +171,7 @@ version( CRuntime_Glibc )
@trusted void endgrent();
@trusted void setgrent();
}
else version( OSX )
else version( Darwin )
{
group* getgrent();
@trusted void endgrent();
Expand All @@ -159,6 +183,12 @@ else version( FreeBSD )
@trusted void endgrent();
@trusted void setgrent();
}
else version( OpenBSD )
{
group* getgrent();
@trusted void endgrent();
@trusted void setgrent();
}
else version( Solaris )
{
group* getgrent();
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
102 changes: 101 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 Expand Up @@ -387,6 +396,97 @@ else version( FreeBSD )
enum EAI_SYSTEM = 11;
enum EAI_OVERFLOW = 14;
}
else version( OpenBSD )
{
struct hostent
{
char* h_name;
char** h_aliases;
int h_addrtype;
int h_length;
char** h_addr_list;
extern (D) char* h_addr() @property { return h_addr_list[0]; } // non-standard
}

struct netent
{
char* n_name;
char** n_aliases;
int n_addrtype;
in_addr_t n_net;
}

struct protoent
{
char* p_name;
char** p_aliases;
int p_proto;
}

struct servent
{
char* s_name;
char** s_aliases;
int s_port;
char* s_proto;
}

enum IPPORT_RESERVED = 1024;

//h_errno

enum NETDB_INTERNAL = -1;
enum NETDB_SUCCESS = 0;
enum HOST_NOT_FOUND = 1;
enum NO_DATA = 4;
enum NO_RECOVERY = 3;
enum TRY_AGAIN = 2;

struct addrinfo
{
int ai_flags;
int ai_family;
int ai_socktype;
int ai_protocol;
socklen_t ai_addrlen;
char* ai_canonname;
sockaddr* ai_addr;
addrinfo* ai_next;
}

enum AI_PASSIVE = 0x1;
enum AI_CANONNAME = 0x2;
enum AI_NUMERICHOST = 0x4;
enum AI_EXT = 0x8;
enum AI_NUMERICSERV = 0x10;
enum AI_FQDN = 0x20;
enum AI_ADDRCONFIG = 0x40;
enum AI_MASK = AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_FQDN | AI_ADDRCONFIG;

enum NI_NUMERICHOST = 1;
enum NI_NUMERICSERV = 2;
enum NI_NOFQDN = 4;
enum NI_NAMEREQD = 8;
enum NI_DGRAM = 16;
//enum NI_NUMERICSCOPE = 32;
enum NI_MAXHOST = 256; // non-standard
enum NI_MAXSERV = 32; // non-standard

enum EAI_NONAME = -1;
enum EAI_BADFLAGS = -2;
enum EAI_AGAIN = -3;
enum EAI_FAIL = -4;
enum EAI_NODATA = -5;
enum EAI_FAMILY = -6;
enum EAI_SOCKTYPE = -7;
enum EAI_SERVICE = -8;
enum EAI_ADDRFAMILY = -9;
enum EAI_MEMORY = -10;
enum EAI_SYSTEM = -11;
enum EAI_BADHINTS = -12;
enum EAI_PROTOCOL = -13;
enum EAI_OVERFLOW = -14;
}
else version (Solaris)
{
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
42 changes: 41 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 Expand Up @@ -143,6 +152,37 @@ else version( FreeBSD )

int poll(pollfd*, nfds_t, int);
}
else version( OpenBSD )
{
alias uint nfds_t;

struct pollfd
{
int fd;
short events;
short revents;
};

enum
{
POLLIN = 0x0001,
POLLPRI = 0x0002,
POLLOUT = 0x0004,
POLLRDNORM = 0x0040,
POLLNORM = POLLRDNORM,
POLLWRNORM = POLLOUT,
POLLRDBAND = 0x0080,
POLLWRBAND = 0x0100,
POLLERR = 0x0008,
POLLHUP = 0x0010,
POLLNVAL = 0x0020,

POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
}

int poll(pollfd*, nfds_t, int);
}
else version( Solaris )
{
alias c_ulong nfds_t;
Expand Down
282 changes: 206 additions & 76 deletions src/core/sys/posix/pthread.d

Large diffs are not rendered by default.

42 changes: 39 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 @@ -85,6 +94,22 @@ else version( FreeBSD )
int pw_fields; /* internal: fields filled in */
}
}
else version( OpenBSD )
{
struct passwd
{
char* pw_name; /* user name */
char* pw_passwd; /* encrypted password */
uid_t pw_uid; /* user uid */
gid_t pw_gid; /* user gid */
time_t pw_change; /* password change time */
char* pw_class; /* user access class */
char* pw_gecos; /* Honeywell login info */
char* pw_dir; /* home directory */
char* pw_shell; /* default shell */
time_t pw_expire; /* account expiration */
}
}
else version (Solaris)
{
struct passwd
Expand Down Expand Up @@ -133,7 +158,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 All @@ -143,6 +168,11 @@ else version( FreeBSD )
int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
}
else version( OpenBSD )
{
int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
}
else version (Solaris)
{
int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
Expand Down Expand Up @@ -171,7 +201,7 @@ version( CRuntime_Glibc )
passwd* getpwent();
void setpwent();
}
else version ( OSX )
else version ( Darwin )
{
void endpwent();
passwd* getpwent();
Expand All @@ -183,6 +213,12 @@ else version ( FreeBSD )
passwd* getpwent();
void setpwent();
}
else version ( OpenBSD )
{
void endpwent();
passwd* getpwent();
void setpwent();
}
else version (Solaris)
{
void endpwent();
Expand Down
36 changes: 33 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 All @@ -86,6 +95,17 @@ else version( FreeBSD )
enum SCHED_OTHER = 2;
enum SCHED_RR = 3;
}
else version( OpenBSD )
{
struct sched_param
{
int sched_priority;
}

enum SCHED_FIFO = 1;
enum SCHED_OTHER = 2;
enum SCHED_RR = 3;
}
else version (Solaris)
{
struct sched_param
Expand Down Expand Up @@ -136,14 +156,18 @@ version( CRuntime_Glibc )
{
int sched_yield();
}
else version( OSX )
else version( Darwin )
{
int sched_yield();
}
else version( FreeBSD )
{
int sched_yield();
}
else version( OpenBSD )
{
int sched_yield();
}
else version (Solaris)
{
int sched_yield();
Expand Down Expand Up @@ -172,7 +196,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 All @@ -184,6 +208,12 @@ else version( FreeBSD )
int sched_get_priority_max(int);
int sched_rr_get_interval(pid_t, timespec*);
}
else version( OpenBSD )
{
int sched_get_priority_min(int);
int sched_get_priority_max(int);
int sched_rr_get_interval(pid_t, timespec*);
}
else version (Solaris)
{
int sched_get_priority_max(int);
Expand Down
24 changes: 22 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 All @@ -81,6 +90,13 @@ else version( FreeBSD )

enum SEM_FAILED = cast(sem_t*) null;
}
else version( OpenBSD )
{
struct __sem { }
alias sem_t = __sem*;

enum SEM_FAILED = cast(sem_t*) null;
}
else version (Solaris)
{
struct sem_t
Expand Down Expand Up @@ -129,14 +145,18 @@ version( CRuntime_Glibc )
{
int sem_timedwait(sem_t*, in timespec*);
}
else version( OSX )
else version( Darwin )
{
int sem_timedwait(sem_t*, in timespec*);
}
else version( FreeBSD )
{
int sem_timedwait(sem_t*, in timespec*);
}
else version( OpenBSD )
{
int sem_timedwait(sem_t*, in timespec*);
}
else version (Solaris)
{
int sem_timedwait(sem_t*, in timespec*);
Expand Down
51 changes: 51 additions & 0 deletions src/core/sys/posix/setjmp.d
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,45 @@ else version( FreeBSD )
int setjmp(ref jmp_buf);
void longjmp(ref jmp_buf, int);
}
else version( OpenBSD )
{
// <machine/setjmp.h>
version( X86 )
{
enum _JBLEN = 10;
}
else version( X86_64)
{
enum _JBLEN = 11;
}
else version( ARM )
{
enum _JBLEN = 64;
}
else version( PPC )
{
enum _JBLEN = 100;
}
else version( MIPS64 )
{
enum _JBLEN = 83;
}
else version( SPARC )
{
enum _JBLEN = 10;
}
else version( SPARC64 )
{
enum _JBLEN = 14;
}
else
static assert(0);

alias jmp_buf = c_long[_JBLEN];

int setjmp(ref jmp_buf);
void longjmp(ref jmp_buf, int);
}
else version( CRuntime_Bionic )
{
// <machine/setjmp.h>
Expand Down Expand Up @@ -238,6 +277,13 @@ else version( FreeBSD )
int sigsetjmp(ref sigjmp_buf);
void siglongjmp(ref sigjmp_buf, int);
}
else version( OpenBSD )
{
alias sigjmp_buf = c_long[_JBLEN + 1];

int sigsetjmp(ref sigjmp_buf);
void siglongjmp(ref sigjmp_buf, int);
}
else version( CRuntime_Bionic )
{
alias c_long[_JBLEN + 1] sigjmp_buf;
Expand All @@ -264,6 +310,11 @@ else version( FreeBSD )
int _setjmp(ref jmp_buf);
void _longjmp(ref jmp_buf, int);
}
else version( OpenBSD )
{
int _setjmp(ref jmp_buf);
void _longjmp(ref jmp_buf, int);
}
else version( CRuntime_Bionic )
{
int _setjmp(ref jmp_buf);
Expand Down
270 changes: 263 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 @@ -425,6 +434,30 @@ else version( FreeBSD )
enum SIGUSR2 = 31;
enum SIGURG = 16;
}
else version( OpenBSD )
{
//SIGABRT (defined in core.stdc.signal)
enum SIGALRM = 14;
enum SIGBUS = 10;
enum SIGCHLD = 20;
enum SIGCONT = 19;
//SIGFPE (defined in core.stdc.signal)
enum SIGHUP = 1;
//SIGILL (defined in core.stdc.signal)
//SIGINT (defined in core.stdc.signal)
enum SIGKILL = 9;
enum SIGPIPE = 13;
enum SIGQUIT = 3;
//SIGSEGV (defined in core.stdc.signal)
enum SIGSTOP = 17;
//SIGTERM (defined in core.stdc.signal)
enum SIGTSTP = 18;
enum SIGTTIN = 21;
enum SIGTTOU = 22;
enum SIGUSR1 = 30;
enum SIGUSR2 = 31;
enum SIGURG = 16;
}
else version (Solaris)
{
enum SIGALRM = 14;
Expand Down Expand Up @@ -483,6 +516,21 @@ else version( FreeBSD )
sigset_t sa_mask;
}
}
else version( OpenBSD )
{
struct sigaction_t
{
union
{
sigfn_t __sa_handler;
alias sa_handler = __sa_handler;
sigactfn_t __sa_sigaction;
alias sa_sigaction = __sa_sigaction;
}
sigset_t sa_mask;
int sa_flags;
}
}
else version (Solaris)
{
struct sigaction_t
Expand Down Expand Up @@ -538,7 +586,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 +803,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 @@ -885,6 +933,82 @@ else version( FreeBSD )
int sigsuspend(in sigset_t *);
int sigwait(in sigset_t*, int*);
}
else version( OpenBSD )
{
enum SIG_CATCH = cast(sigfn_t2) 2;
enum SIG_HOLD = cast(sigfn_t2) 3;

alias sigset_t = uint;

enum SA_NOCLDSTOP = 0x0008;

enum SIG_BLOCK = 1;
enum SIG_UNBLOCK = 2;
enum SIG_SETMASK = 3;

private enum SI_MAXSZ = 128;
private enum SI_PAD = (SI_MAXSZ / int.sizeof) - 3;

struct siginfo_t
{
int si_signo;
int si_errno;
int si_code;
union _data
{
int[SI_PAD] _pad;
struct _proc
{
pid_t _pid;
union _pdata
{
struct _kill
{
uid_t _uid;
sigval _value;
}
struct _cld
{
clock_t _utime;
clock_t _stime;
int _status;
}
}
}
struct _fault
{
caddr_t _addr;
int _trapno;
}
}
alias si_pid = _data._proc._pid;
alias si_status = _data._proc._pdata._cld._status;
alias si_stime = _data._proc._pdata._cld._stime;
alias si_utime = _data._proc._pdata._cld._utime;
alias si_uid = _data._proc._pdata._kill._uid;
alias si_value = _data._proc._pdata._kill._value;
alias si_addr = _data._fault._addr;
alias si_trapno = _data._fault._trapno;
}

enum SI_NOINFO = 32767;
enum SI_USER = 0;
enum SI_LWP = -1;
enum SI_QUEUE = -2;
enum SI_TIMER = -3;

int kill(pid_t, int);
int sigaction(int, in sigaction_t*, sigaction_t*);
int sigaddset(sigset_t*, int);
int sigdelset(sigset_t*, int);
int sigemptyset(sigset_t *);
int sigfillset(sigset_t *);
int sigismember(in sigset_t *, int);
int sigpending(sigset_t *);
int sigprocmask(int, in sigset_t*, sigset_t*);
int sigsuspend(in sigset_t *);
int sigwait(in sigset_t*, int*);
}
else version (Solaris)
{
enum SIG_HOLD = cast(sigfn_t2)2;
Expand Down Expand Up @@ -1422,7 +1546,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 @@ -1656,6 +1780,122 @@ else version( FreeBSD )
int sigpause(int);
int sigrelse(int);
}
else version (OpenBSD)
{
// No SIGPOLL on *BSD
enum SIGPROF = 27;
enum SIGSYS = 12;
enum SIGTRAP = 5;
enum SIGVTALRM = 26;
enum SIGXCPU = 24;
enum SIGXFSZ = 25;

enum
{
SA_ONSTACK = 0x0001,
SA_RESTART = 0x0002,
SA_RESETHAND = 0x0004,
SA_NODEFER = 0x0010,
SA_NOCLDWAIT = 0x0020,
SA_SIGINFO = 0x0040,
}

enum
{
SS_ONSTACK = 0x0001,
SS_DISABLE = 0x0004,
}

enum MINSIGSTKSZ = 8192;
enum SIGSTKSZ = (MINSIGSTKSZ + 32768);

//ucontext_t (defined in core.sys.posix.ucontext)
//mcontext_t (defined in core.sys.posix.ucontext)

struct stack_t
{
void* ss_sp;
size_t ss_size;
int ss_flags;
}

enum
{
ILL_ILLOPC = 1,
ILL_ILLOPN,
ILL_ILLADR,
ILL_ILLTRP,
ILL_PRVOPC,
ILL_PRVREG,
ILL_COPROC,
ILL_BADSTK,
NSIGILL = ILL_BADSTK,
}

enum
{
BUS_ADRALN = 1,
BUS_ADRERR,
BUS_OBJERR,
NSIGBUS = BUS_OBJERR,
}

enum
{
SEGV_MAPERR = 1,
SEGV_ACCERR,
NSIGSEGV = SEGV_ACCERR,
}

enum
{
FPE_INTDIV = 1,
FPE_INTOVF,
FPE_FLTDIV,
FPE_FLTOVF,
FPE_FLTUND,
FPE_FLTRES,
FPE_FLTINV,
FPE_FLTSUB,
NSIGFPE = FPE_FLTSUB,
}

enum
{
TRAP_BRKPT = 1,
TRAP_TRACE,
NSIGTRAP = TRAP_TRACE,
}

enum
{
CLD_EXITED = 1,
CLD_KILLED,
CLD_DUMPED,
CLD_TRAPPED,
CLD_STOPPED,
CLD_CONTINUED,
NSIGCLD = CLD_CONTINUED,
}

enum
{
POLL_IN = 1,
POLL_OUT,
POLL_MSG,
POLL_ERR,
POLL_PRI,
POLL_HUP,
NSIGPOLL = POLL_HUP,
}

nothrow:
@nogc:
int killpg(pid_t, int);
int sigaltstack(in stack_t*, stack_t*);
int siginterrupt(int, int);
int sigpause(int);
}
else version (Solaris)
{
enum SIGPOLL = 22;
Expand Down Expand Up @@ -1943,7 +2183,7 @@ version( linux )
c_long tv_nsec;
}
}
else version( OSX )
else version( Darwin )
{
struct timespec
{
Expand All @@ -1959,6 +2199,14 @@ else version( FreeBSD )
c_long tv_nsec;
}
}
else version( OpenBSD )
{
struct timespec
{
time_t tv_sec;
c_long tv_nsec;
}
}
else version (Solaris)
{
struct timespec
Expand Down Expand Up @@ -2054,7 +2302,10 @@ else version( FreeBSD )
int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
int sigwaitinfo(in sigset_t*, siginfo_t*);
}
else version (OSX)
else version (OpenBSD)
{
}
else version (Darwin)
{
}
else version (Solaris)
Expand Down Expand Up @@ -2117,7 +2368,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 All @@ -2127,6 +2378,11 @@ else version( FreeBSD )
int pthread_kill(pthread_t, int);
int pthread_sigmask(int, in sigset_t*, sigset_t*);
}
else version( OpenBSD )
{
int pthread_kill(pthread_t, int);
int pthread_sigmask(int, in sigset_t*, sigset_t*);
}
else version (Solaris)
{
int pthread_kill(pthread_t, int);
Expand Down
25 changes: 24 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 @@ -237,6 +246,16 @@ version( CRuntime_Glibc )
int putc_unlocked(int, FILE*);
int putchar_unlocked(int);
}
else version( OpenBSD )
{
void flockfile(FILE*);
int ftrylockfile(FILE*);
void funlockfile(FILE*);
int getc_unlocked(FILE*);
int getchar_unlocked();
int putc_unlocked(int, FILE*);
int putchar_unlocked(int);
}
else version( Solaris )
{
void flockfile(FILE*);
Expand Down Expand Up @@ -264,14 +283,18 @@ version( CRuntime_Glibc )
{
enum P_tmpdir = "/tmp";
}
version( OSX )
version( Darwin )
{
enum P_tmpdir = "/var/tmp";
}
version( FreeBSD )
{
enum P_tmpdir = "/var/tmp/";
}
version( OpenBSD )
{
enum P_tmpdir = "/tmp/";
}
version( Solaris )
{
enum P_tmpdir = "/var/tmp/";
Expand Down
71 changes: 68 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 @@ -91,6 +100,10 @@ else version( FreeBSD )
{
int posix_memalign(void**, size_t, size_t);
}
else version( OpenBSD )
{
int posix_memalign(void**, size_t, size_t);
}
else version( Solaris )
{
int posix_memalign(void**, size_t, size_t);
Expand All @@ -111,7 +124,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 All @@ -125,6 +138,13 @@ else version( FreeBSD )

void* valloc(size_t); // LEGACY non-standard
}
else version( OpenBSD )
{
int setenv(in char*, in char*, int);
int unsetenv(in char*);

void* valloc(size_t); // LEGACY non-standard
}
else version( CRuntime_Bionic )
{
int setenv(in char*, in char*, int);
Expand All @@ -151,14 +171,18 @@ version( CRuntime_Glibc )
{
int rand_r(uint*);
}
else version( OSX )
else version( Darwin )
{
int rand_r(uint*);
}
else version( FreeBSD )
{
int rand_r(uint*);
}
else version( OpenBSD )
{
int rand_r(uint*);
}
else version( Solaris )
{
int rand_r(uint*);
Expand Down Expand Up @@ -260,7 +284,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 Expand Up @@ -342,6 +366,47 @@ else version( FreeBSD )
void srandom(uint);
int unlockpt(int);
}
else version( OpenBSD )
{
//WNOHANG (defined in core.sys.posix.sys.wait)
//WUNTRACED (defined in core.sys.posix.sys.wait)
//WEXITSTATUS (defined in core.sys.posix.sys.wait)
//WIFEXITED (defined in core.sys.posix.sys.wait)
//WIFSIGNALED (defined in core.sys.posix.sys.wait)
//WIFSTOPPED (defined in core.sys.posix.sys.wait)
//WSTOPSIG (defined in core.sys.posix.sys.wait)
//WTERMSIG (defined in core.sys.posix.sys.wait)

c_long a64l(in char*);
double drand48();
//char* ecvt(double, int, int *, int *); // LEGACY
double erand48(ref ushort[3]);
//char* fcvt(double, int, int *, int *); // LEGACY
//char* gcvt(double, int, char*); // LEGACY
int getsubopt(char**, in char**, char**);
int grantpt(int);
char* initstate(uint, char*, size_t);
c_long jrand48(ref ushort[3]);
char* l64a(c_long);
void lcong48(ref ushort[7]);
c_long lrand48();
char* mktemp(char*); // LEGACY
int mkstemp(char*);
char* mkdtemp(char*); // Defined in IEEE 1003.1, 2008 Edition
c_long mrand48();
c_long nrand48(ref ushort[3]);
int posix_openpt(int);
char* ptsname(int);
int putenv(char*);
c_long random();
char* realpath(in char*, char*);
ushort *seed48(ref ushort[3]);
// void setkey(in char*); // not implemented
char* setstate(in char*);
void srand48(c_long);
void srandom(uint);
int unlockpt(int);
}
else version( CRuntime_Bionic )
{
double drand48();
Expand Down
26 changes: 26 additions & 0 deletions src/core/sys/posix/sys/filio.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* D header file for POSIX.
*
* License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
*/

module core.sys.posix.sys.filio;

import core.sys.posix.sys.ioccom;

version (Posix):

nothrow @nogc:

version (OSX)
{
// File-descriptor ioctl's
enum uint FIOCLEX = _IO('f', 1); // set close on exec on fd
enum uint FIONCLEX = _IO('f', 2); // remove close on exec
enum uint FIONREAD = _IOR!(int)('f', 127); // get # bytes to read
enum uint FIONBIO = _IOW!(int)('f', 126); // set/clear non-blocking i/o
enum uint FIOASYNC = _IOW!(int)('f', 125); // set/clear async i/o
enum uint FIOSETOWN = _IOW!(int)('f', 124); // set owner
enum uint FIOGETOWN = _IOR!(int)('f', 123); // get owner
enum uint FIODTYPE = _IOR!(int)('f', 122); // get d_type
}
68 changes: 68 additions & 0 deletions src/core/sys/posix/sys/ioccom.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* D header file for POSIX.
*
* License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
*/

module core.sys.posix.sys.ioccom;

version (Posix):

nothrow @nogc:

version (OSX)
{
/* OSX ioctl's (based on FreeBSD) encode the command in the lower 16-bits
* and the size of any in/out parameters in the lower 13 bits of the upper
* 16-bits of a 32 bit unsigned integer. The high 3 bits of the upper
* 16-bits encode the in/out status of the parameter.
*/
enum uint IOCPARM_MASK = 0x1fff; // parameter length, at most 13 bits
uint IOCPARM_LEN(uint x) // to extract the encoded parameter length
{
return ((x >> 16) & IOCPARM_MASK);
}
uint IOCBASECMD(uint x) // to extract the encoded command
{
return (x & ~(IOCPARM_MASK << 16));
}
uint IOCGROUP(uint x) // to extract the encoded group
{
return ((x >> 8) & 0xff);
}

enum uint IOCPARM_MAX = (IOCPARM_MASK + 1); // max size of ioctl args

enum uint IOC_VOID = 0x20000000; // no parameters
enum uint IOC_OUT = 0x40000000; // copy parameters back
enum uint IOC_IN = 0x80000000; // copy parameters into
enum uint IOC_INOUT = (IOC_IN | IOC_OUT); // copy parameter into and get back
enum uint IOC_DIRMASK = 0xe0000000; // mask to extract above direction parameters

// encode the ioctl info into 32 bits
uint _IOC(T=typeof(null))(uint inorout, uint group, uint num, size_t len)
{
return (inorout | ((len & IOCPARM_MASK) << 16) | (group << 8) | num);
}

// encode a command with no parameters
uint _IO(char g, int n)
{
return _IOC(IOC_VOID, cast(uint)g, cast(uint)n, cast(size_t)0);
}
// encode a command that returns info
uint _IOR(T)(char g, int n)
{
return _IOC!(T)(IOC_OUT, cast(uint)g, cast(uint)n, T.sizeof);
}
// encode a command that takes info
uint _IOW(T)(char g, int n)
{
return _IOC!(T)(IOC_IN, cast(uint)g, cast(uint)n, T.sizeof);
}
// encode a command that takes info and returns info
uint _IOWR(T)(char g, int n)
{
return _IOC!(T)(IOC_INOUT, cast(uint)g, cast(uint)n, T.sizeof);
}
}
Loading