Added druntime (this should be removed once it works).

This commit is contained in:
Robert Clipsham
2009-06-02 17:43:06 +01:00
parent 435d3069f6
commit c9ca799f88
269 changed files with 83741 additions and 1 deletions

View File

@@ -0,0 +1,262 @@
/**
* This module contains a collection of bit-level operations.
*
* Copyright: Copyright (c) 2005-2008, The D Runtime Project
* License: BSD Style, see LICENSE
* Authors: Walter Bright, Don Clugston, Sean Kelly
*/
module core.bitmanip;
version( DDoc )
{
/**
* Scans the bits in v starting with bit 0, looking
* for the first set bit.
* Returns:
* The bit number of the first bit set.
* The return value is undefined if v is zero.
*/
int bsf( uint v );
/**
* Scans the bits in v from the most significant bit
* to the least significant bit, looking
* for the first set bit.
* Returns:
* The bit number of the first bit set.
* The return value is undefined if v is zero.
* Example:
* ---
* import bitmanip;
*
* int main()
* {
* uint v;
* int x;
*
* v = 0x21;
* x = bsf(v);
* printf("bsf(x%x) = %d\n", v, x);
* x = bsr(v);
* printf("bsr(x%x) = %d\n", v, x);
* return 0;
* }
* ---
* Output:
* bsf(x21) = 0<br>
* bsr(x21) = 5
*/
int bsr( uint v );
/**
* Tests the bit.
*/
int bt( uint* p, uint bitnum );
/**
* Tests and complements the bit.
*/
int btc( uint* p, uint bitnum );
/**
* Tests and resets (sets to 0) the bit.
*/
int btr( uint* p, uint bitnum );
/**
* Tests and sets the bit.
* Params:
* p = a non-NULL pointer to an array of uints.
* index = a bit number, starting with bit 0 of p[0],
* and progressing. It addresses bits like the expression:
---
p[index / (uint.sizeof*8)] & (1 << (index & ((uint.sizeof*8) - 1)))
---
* Returns:
* A non-zero value if the bit was set, and a zero
* if it was clear.
*
* Example:
* ---
import bitmanip;
int main()
{
uint array[2];
array[0] = 2;
array[1] = 0x100;
printf("btc(array, 35) = %d\n", <b>btc</b>(array, 35));
printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
printf("btc(array, 35) = %d\n", <b>btc</b>(array, 35));
printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
printf("bts(array, 35) = %d\n", <b>bts</b>(array, 35));
printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
printf("btr(array, 35) = %d\n", <b>btr</b>(array, 35));
printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
printf("bt(array, 1) = %d\n", <b>bt</b>(array, 1));
printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
return 0;
}
* ---
* Output:
<pre>
btc(array, 35) = 0
array = [0]:x2, [1]:x108
btc(array, 35) = -1
array = [0]:x2, [1]:x100
bts(array, 35) = 0
array = [0]:x2, [1]:x108
btr(array, 35) = -1
array = [0]:x2, [1]:x100
bt(array, 1) = -1
array = [0]:x2, [1]:x100
</pre>
*/
int bts( uint* p, uint bitnum );
/**
* Swaps bytes in a 4 byte uint end-to-end, i.e. byte 0 becomes
* byte 3, byte 1 becomes byte 2, byte 2 becomes byte 1, byte 3
* becomes byte 0.
*/
uint bswap( uint v );
/**
* Reads I/O port at port_address.
*/
ubyte inp( uint port_address );
/**
* ditto
*/
ushort inpw( uint port_address );
/**
* ditto
*/
uint inpl( uint port_address );
/**
* Writes and returns value to I/O port at port_address.
*/
ubyte outp( uint port_address, ubyte value );
/**
* ditto
*/
ushort outpw( uint port_address, ushort value );
/**
* ditto
*/
uint outpl( uint port_address, uint value );
}
else
{
public import std.intrinsic;
}
/**
* Calculates the number of set bits in a 32-bit integer.
*/
int popcnt( uint x )
{
// Avoid branches, and the potential for cache misses which
// could be incurred with a table lookup.
// We need to mask alternate bits to prevent the
// sum from overflowing.
// add neighbouring bits. Each bit is 0 or 1.
x = x - ((x>>1) & 0x5555_5555);
// now each two bits of x is a number 00,01 or 10.
// now add neighbouring pairs
x = ((x&0xCCCC_CCCC)>>2) + (x&0x3333_3333);
// now each nibble holds 0000-0100. Adding them won't
// overflow any more, so we don't need to mask any more
// Now add the nibbles, then the bytes, then the words
// We still need to mask to prevent double-counting.
// Note that if we used a rotate instead of a shift, we
// wouldn't need the masks, and could just divide the sum
// by 8 to account for the double-counting.
// On some CPUs, it may be faster to perform a multiply.
x += (x>>4);
x &= 0x0F0F_0F0F;
x += (x>>8);
x &= 0x00FF_00FF;
x += (x>>16);
x &= 0xFFFF;
return x;
}
/**
* Reverses the order of bits in a 32-bit integer.
*/
uint bitswap( uint x )
{
version( D_InlineAsm_X86 )
{
asm
{
// Author: Tiago Gasiba.
mov EDX, EAX;
shr EAX, 1;
and EDX, 0x5555_5555;
and EAX, 0x5555_5555;
shl EDX, 1;
or EAX, EDX;
mov EDX, EAX;
shr EAX, 2;
and EDX, 0x3333_3333;
and EAX, 0x3333_3333;
shl EDX, 2;
or EAX, EDX;
mov EDX, EAX;
shr EAX, 4;
and EDX, 0x0f0f_0f0f;
and EAX, 0x0f0f_0f0f;
shl EDX, 4;
or EAX, EDX;
bswap EAX;
}
}
else
{
// swap odd and even bits
x = ((x >> 1) & 0x5555_5555) | ((x & 0x5555_5555) << 1);
// swap consecutive pairs
x = ((x >> 2) & 0x3333_3333) | ((x & 0x3333_3333) << 2);
// swap nibbles
x = ((x >> 4) & 0x0F0F_0F0F) | ((x & 0x0F0F_0F0F) << 4);
// swap bytes
x = ((x >> 8) & 0x00FF_00FF) | ((x & 0x00FF_00FF) << 8);
// swap 2-byte long pairs
x = ( x >> 16 ) | ( x << 16);
return x;
}
}

View File

@@ -0,0 +1,107 @@
/**
* D header file for C99.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: ISO/IEC 9899:1999 (E)
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.stdc.complex;
extern (C):
alias creal complex;
alias ireal imaginary;
cdouble cacos(cdouble z);
cfloat cacosf(cfloat z);
creal cacosl(creal z);
cdouble casin(cdouble z);
cfloat casinf(cfloat z);
creal casinl(creal z);
cdouble catan(cdouble z);
cfloat catanf(cfloat z);
creal catanl(creal z);
cdouble ccos(cdouble z);
cfloat ccosf(cfloat z);
creal ccosl(creal z);
cdouble csin(cdouble z);
cfloat csinf(cfloat z);
creal csinl(creal z);
cdouble ctan(cdouble z);
cfloat ctanf(cfloat z);
creal ctanl(creal z);
cdouble cacosh(cdouble z);
cfloat cacoshf(cfloat z);
creal cacoshl(creal z);
cdouble casinh(cdouble z);
cfloat casinhf(cfloat z);
creal casinhl(creal z);
cdouble catanh(cdouble z);
cfloat catanhf(cfloat z);
creal catanhl(creal z);
cdouble ccosh(cdouble z);
cfloat ccoshf(cfloat z);
creal ccoshl(creal z);
cdouble csinh(cdouble z);
cfloat csinhf(cfloat z);
creal csinhl(creal z);
cdouble ctanh(cdouble z);
cfloat ctanhf(cfloat z);
creal ctanhl(creal z);
cdouble cexp(cdouble z);
cfloat cexpf(cfloat z);
creal cexpl(creal z);
cdouble clog(cdouble z);
cfloat clogf(cfloat z);
creal clogl(creal z);
double cabs(cdouble z);
float cabsf(cfloat z);
real cabsl(creal z);
cdouble cpow(cdouble x, cdouble y);
cfloat cpowf(cfloat x, cfloat y);
creal cpowl(creal x, creal y);
cdouble csqrt(cdouble z);
cfloat csqrtf(cfloat z);
creal csqrtl(creal z);
double carg(cdouble z);
float cargf(cfloat z);
real cargl(creal z);
double cimag(cdouble z);
float cimagf(cfloat z);
real cimagl(creal z);
cdouble conj(cdouble z);
cfloat conjf(cfloat z);
creal conjl(creal z);
cdouble cproj(cdouble z);
cfloat cprojf(cfloat z);
creal cprojl(creal z);
// double creal(cdouble z);
float crealf(cfloat z);
real creall(creal z);

View File

@@ -0,0 +1,35 @@
/**
* D header file for C99.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: ISO/IEC 9899:1999 (E)
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.stdc.config;
extern (C):
version( Windows )
{
alias int c_long;
alias uint c_ulong;
}
else
{
static if( (void*).sizeof > int.sizeof )
{
alias long c_long;
alias ulong c_ulong;
}
else
{
alias int c_long;
alias uint c_ulong;
}
}

View File

@@ -0,0 +1,31 @@
/**
* D header file for C99.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: ISO/IEC 9899:1999 (E)
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.stdc.ctype;
extern (C):
int isalnum(int c);
int isalpha(int c);
int isblank(int c);
int iscntrl(int c);
int isdigit(int c);
int isgraph(int c);
int islower(int c);
int isprint(int c);
int ispunct(int c);
int isspace(int c);
int isupper(int c);
int isxdigit(int c);
int tolower(int c);
int toupper(int c);

View File

@@ -0,0 +1,377 @@
/**
* D header file for C99.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: ISO/IEC 9899:1999 (E)
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.stdc.errno;
extern (C) int getErrno(); // for internal use
extern (C) int setErrno(int); // for internal use
alias getErrno errno;
alias setErrno errno;
extern (C):
version( Windows )
{
enum EPERM = 1; // Operation not permitted
enum ENOENT = 2; // No such file or directory
enum ESRCH = 3; // No such process
enum EINTR = 4; // Interrupted system call
enum EIO = 5; // I/O error
enum ENXIO = 6; // No such device or address
enum E2BIG = 7; // Argument list too long
enum ENOEXEC = 8; // Exec format error
enum EBADF = 9; // Bad file number
enum ECHILD = 10; // No child processes
enum EAGAIN = 11; // Try again
enum ENOMEM = 12; // Out of memory
enum EACCES = 13; // Permission denied
enum EFAULT = 14; // Bad address
enum EBUSY = 16; // Device or resource busy
enum EEXIST = 17; // File exists
enum EXDEV = 18; // Cross-device link
enum ENODEV = 19; // No such device
enum ENOTDIR = 20; // Not a directory
enum EISDIR = 21; // Is a directory
enum EINVAL = 22; // Invalid argument
enum ENFILE = 23; // File table overflow
enum EMFILE = 24; // Too many open files
enum ENOTTY = 25; // Not a typewriter
enum EFBIG = 27; // File too large
enum ENOSPC = 28; // No space left on device
enum ESPIPE = 29; // Illegal seek
enum EROFS = 30; // Read-only file system
enum EMLINK = 31; // Too many links
enum EPIPE = 32; // Broken pipe
enum EDOM = 33; // Math argument out of domain of func
enum ERANGE = 34; // Math result not representable
enum EDEADLK = 36; // Resource deadlock would occur
enum ENAMETOOLONG = 38; // File name too long
enum ENOLCK = 39; // No record locks available
enum ENOSYS = 40; // Function not implemented
enum ENOTEMPTY = 41; // Directory not empty
enum EILSEQ = 42; // Illegal byte sequence
enum EDEADLOCK = EDEADLK;
}
else version( linux )
{
enum EPERM = 1; // Operation not permitted
enum ENOENT = 2; // No such file or directory
enum ESRCH = 3; // No such process
enum EINTR = 4; // Interrupted system call
enum EIO = 5; // I/O error
enum ENXIO = 6; // No such device or address
enum E2BIG = 7; // Argument list too long
enum ENOEXEC = 8; // Exec format error
enum EBADF = 9; // Bad file number
enum ECHILD = 10; // No child processes
enum EAGAIN = 11; // Try again
enum ENOMEM = 12; // Out of memory
enum EACCES = 13; // Permission denied
enum EFAULT = 14; // Bad address
enum ENOTBLK = 15; // Block device required
enum EBUSY = 16; // Device or resource busy
enum EEXIST = 17; // File exists
enum EXDEV = 18; // Cross-device link
enum ENODEV = 19; // No such device
enum ENOTDIR = 20; // Not a directory
enum EISDIR = 21; // Is a directory
enum EINVAL = 22; // Invalid argument
enum ENFILE = 23; // File table overflow
enum EMFILE = 24; // Too many open files
enum ENOTTY = 25; // Not a typewriter
enum ETXTBSY = 26; // Text file busy
enum EFBIG = 27; // File too large
enum ENOSPC = 28; // No space left on device
enum ESPIPE = 29; // Illegal seek
enum EROFS = 30; // Read-only file system
enum EMLINK = 31; // Too many links
enum EPIPE = 32; // Broken pipe
enum EDOM = 33; // Math argument out of domain of func
enum ERANGE = 34; // Math result not representable
enum EDEADLK = 35; // Resource deadlock would occur
enum ENAMETOOLONG = 36; // File name too long
enum ENOLCK = 37; // No record locks available
enum ENOSYS = 38; // Function not implemented
enum ENOTEMPTY = 39; // Directory not empty
enum ELOOP = 40; // Too many symbolic links encountered
enum EWOULDBLOCK = EAGAIN; // Operation would block
enum ENOMSG = 42; // No message of desired type
enum EIDRM = 43; // Identifier removed
enum ECHRNG = 44; // Channel number out of range
enum EL2NSYNC = 45; // Level 2 not synchronized
enum EL3HLT = 46; // Level 3 halted
enum EL3RST = 47; // Level 3 reset
enum ELNRNG = 48; // Link number out of range
enum EUNATCH = 49; // Protocol driver not attached
enum ENOCSI = 50; // No CSI structure available
enum EL2HLT = 51; // Level 2 halted
enum EBADE = 52; // Invalid exchange
enum EBADR = 53; // Invalid request descriptor
enum EXFULL = 54; // Exchange full
enum ENOANO = 55; // No anode
enum EBADRQC = 56; // Invalid request code
enum EBADSLT = 57; // Invalid slot
enum EDEADLOCK = EDEADLK;
enum EBFONT = 59; // Bad font file format
enum ENOSTR = 60; // Device not a stream
enum ENODATA = 61; // No data available
enum ETIME = 62; // Timer expired
enum ENOSR = 63; // Out of streams resources
enum ENONET = 64; // Machine is not on the network
enum ENOPKG = 65; // Package not installed
enum EREMOTE = 66; // Object is remote
enum ENOLINK = 67; // Link has been severed
enum EADV = 68; // Advertise error
enum ESRMNT = 69; // Srmount error
enum ECOMM = 70; // Communication error on send
enum EPROTO = 71; // Protocol error
enum EMULTIHOP = 72; // Multihop attempted
enum EDOTDOT = 73; // RFS specific error
enum EBADMSG = 74; // Not a data message
enum EOVERFLOW = 75; // Value too large for defined data type
enum ENOTUNIQ = 76; // Name not unique on network
enum EBADFD = 77; // File descriptor in bad state
enum EREMCHG = 78; // Remote address changed
enum ELIBACC = 79; // Can not access a needed shared library
enum ELIBBAD = 80; // Accessing a corrupted shared library
enum ELIBSCN = 81; // .lib section in a.out corrupted
enum ELIBMAX = 82; // Attempting to link in too many shared libraries
enum ELIBEXEC = 83; // Cannot exec a shared library directly
enum EILSEQ = 84; // Illegal byte sequence
enum ERESTART = 85; // Interrupted system call should be restarted
enum ESTRPIPE = 86; // Streams pipe error
enum EUSERS = 87; // Too many users
enum ENOTSOCK = 88; // Socket operation on non-socket
enum EDESTADDRREQ = 89; // Destination address required
enum EMSGSIZE = 90; // Message too long
enum EPROTOTYPE = 91; // Protocol wrong type for socket
enum ENOPROTOOPT = 92; // Protocol not available
enum EPROTONOSUPPORT = 93; // Protocol not supported
enum ESOCKTNOSUPPORT = 94; // Socket type not supported
enum EOPNOTSUPP = 95; // Operation not supported on transport endpoint
enum EPFNOSUPPORT = 96; // Protocol family not supported
enum EAFNOSUPPORT = 97; // Address family not supported by protocol
enum EADDRINUSE = 98; // Address already in use
enum EADDRNOTAVAIL = 99; // Cannot assign requested address
enum ENETDOWN = 100; // Network is down
enum ENETUNREACH = 101; // Network is unreachable
enum ENETRESET = 102; // Network dropped connection because of reset
enum ECONNABORTED = 103; // Software caused connection abort
enum ECONNRESET = 104; // Connection reset by peer
enum ENOBUFS = 105; // No buffer space available
enum EISCONN = 106; // Transport endpoint is already connected
enum ENOTCONN = 107; // Transport endpoint is not connected
enum ESHUTDOWN = 108; // Cannot send after transport endpoint shutdown
enum ETOOMANYREFS = 109; // Too many references: cannot splice
enum ETIMEDOUT = 110; // Connection timed out
enum ECONNREFUSED = 111; // Connection refused
enum EHOSTDOWN = 112; // Host is down
enum EHOSTUNREACH = 113; // No route to host
enum EALREADY = 114; // Operation already in progress
enum EINPROGRESS = 115; // Operation now in progress
enum ESTALE = 116; // Stale NFS file handle
enum EUCLEAN = 117; // Structure needs cleaning
enum ENOTNAM = 118; // Not a XENIX named type file
enum ENAVAIL = 119; // No XENIX semaphores available
enum EISNAM = 120; // Is a named type file
enum EREMOTEIO = 121; // Remote I/O error
enum EDQUOT = 122; // Quota exceeded
enum ENOMEDIUM = 123; // No medium found
enum EMEDIUMTYPE = 124; // Wrong medium type
enum ECANCELED = 125; // Operation Canceled
enum ENOKEY = 126; // Required key not available
enum EKEYEXPIRED = 127; // Key has expired
enum EKEYREVOKED = 128; // Key has been revoked
enum EKEYREJECTED = 129; // Key was rejected by service
enum EOWNERDEAD = 130; // Owner died
enum ENOTRECOVERABLE = 131; // State not recoverable
}
else version( OSX )
{
enum EPERM = 1; // Operation not permitted
enum ENOENT = 2; // No such file or directory
enum ESRCH = 3; // No such process
enum EINTR = 4; // Interrupted system call
enum EIO = 5; // Input/output error
enum ENXIO = 6; // Device not configured
enum E2BIG = 7; // Argument list too long
enum ENOEXEC = 8; // Exec format error
enum EBADF = 9; // Bad file descriptor
enum ECHILD = 10; // No child processes
enum EDEADLK = 11; // Resource deadlock avoided
enum ENOMEM = 12; // Cannot allocate memory
enum EACCES = 13; // Permission denied
enum EFAULT = 14; // Bad address
enum EBUSY = 16; // Device busy
enum EEXIST = 17; // File exists
enum EXDEV = 18; // Cross-device link
enum ENODEV = 19; // Operation not supported by device
enum ENOTDIR = 20; // Not a directory
enum EISDIR = 21; // Is a directory
enum EINVAL = 22; // Invalid argument
enum ENFILE = 23; // Too many open files in system
enum EMFILE = 24; // Too many open files
enum ENOTTY = 25; // Inappropriate ioctl for device
enum ETXTBSY = 26; // Text file busy
enum EFBIG = 27; // File too large
enum ENOSPC = 28; // No space left on device
enum ESPIPE = 29; // Illegal seek
enum EROFS = 30; // Read-only file system
enum EMLINK = 31; // Too many links
enum EPIPE = 32; // Broken pipe
enum EDOM = 33; // Numerical argument out of domain
enum ERANGE = 34; // Result too large
enum EAGAIN = 35; // Resource temporarily unavailable
enum EWOULDBLOCK = EAGAIN; // Operation would block
enum EINPROGRESS = 36; // Operation now in progress
enum EALREADY = 37; // Operation already in progress
enum ENOTSOCK = 38; // Socket operation on non-socket
enum EDESTADDRREQ = 39; // Destination address required
enum EMSGSIZE = 40; // Message too long
enum EPROTOTYPE = 41; // Protocol wrong type for socket
enum ENOPROTOOPT = 42; // Protocol not available
enum EPROTONOSUPPORT = 43; // Protocol not supported
enum ENOTSUP = 45; // Operation not supported
enum EOPNOTSUPP = ENOTSUP; // Operation not supported on socket
enum EAFNOSUPPORT = 47; // Address family not supported by protocol family
enum EADDRINUSE = 48; // Address already in use
enum EADDRNOTAVAIL = 49; // Can't assign requested address
enum ENETDOWN = 50; // Network is down
enum ENETUNREACH = 51; // Network is unreachable
enum ENETRESET = 52; // Network dropped connection on reset
enum ECONNABORTED = 53; // Software caused connection abort
enum ECONNRESET = 54; // Connection reset by peer
enum ENOBUFS = 55; // No buffer space available
enum EISCONN = 56; // Socket is already connected
enum ENOTCONN = 57; // Socket is not connected
enum ETIMEDOUT = 60; // Operation timed out
enum ECONNREFUSED = 61; // Connection refused
enum ELOOP = 62; // Too many levels of symbolic links
enum ENAMETOOLONG = 63; // File name too long
enum EHOSTUNREACH = 65; // No route to host
enum ENOTEMPTY = 66; // Directory not empty
enum EDQUOT = 69; // Disc quota exceeded
enum ESTALE = 70; // Stale NFS file handle
enum ENOLCK = 77; // No locks available
enum ENOSYS = 78; // Function not implemented
enum EOVERFLOW = 84; // Value too large to be stored in data type
enum ECANCELED = 89; // Operation canceled
enum EIDRM = 90; // Identifier removed
enum ENOMSG = 91; // No message of desired type
enum EILSEQ = 92; // Illegal byte sequence
enum EBADMSG = 94; // Bad message
enum EMULTIHOP = 95; // Reserved
enum ENODATA = 96; // No message available on STREAM
enum ENOLINK = 97; // Reserved
enum ENOSR = 98; // No STREAM resources
enum ENOSTR = 99; // Not a STREAM
enum EPROTO = 100; // Protocol error
enum ETIME = 101; // STREAM ioctl timeout
enum ELAST = 101; // Must be equal largest errno
}
else version( freebsd )
{
enum EPERM = 1; // Operation not permitted
enum ENOENT = 2; // No such file or directory
enum ESRCH = 3; // No such process
enum EINTR = 4; // Interrupted system call
enum EIO = 5; // Input/output error
enum ENXIO = 6; // Device not configured
enum E2BIG = 7; // Argument list too long
enum ENOEXEC = 8; // Exec format error
enum EBADF = 9; // Bad file descriptor
enum ECHILD = 10; // No child processes
enum EDEADLK = 11; // Resource deadlock avoided
enum ENOMEM = 12; // Cannot allocate memory
enum EACCES = 13; // Permission denied
enum EFAULT = 14; // Bad address
enum ENOTBLK = 15; // Block device required
enum EBUSY = 16; // Device busy
enum EEXIST = 17; // File exists
enum EXDEV = 18; // Cross-device link
enum ENODEV = 19; // Operation not supported by device
enum ENOTDIR = 20; // Not a directory
enum EISDIR = 21; // Is a directory
enum EINVAL = 22; // Invalid argument
enum ENFILE = 23; // Too many open files in system
enum EMFILE = 24; // Too many open files
enum ENOTTY = 25; // Inappropriate ioctl for device
enum ETXTBSY = 26; // Text file busy
enum EFBIG = 27; // File too large
enum ENOSPC = 28; // No space left on device
enum ESPIPE = 29; // Illegal seek
enum EROFS = 30; // Read-only file system
enum EMLINK = 31; // Too many links
enum EPIPE = 32; // Broken pipe
enum EDOM = 33; // Numerical argument out of domain
enum ERANGE = 34; // Result too large
enum EAGAIN = 35; // Resource temporarily unavailable
enum EWOULDBLOCK = EAGAIN; // Operation would block
enum EINPROGRESS = 36; // Operation now in progress
enum EALREADY = 37; // Operation already in progress
enum ENOTSOCK = 38; // Socket operation on non-socket
enum EDESTADDRREQ = 39; // Destination address required
enum EMSGSIZE = 40; // Message too long
enum EPROTOTYPE = 41; // Protocol wrong type for socket
enum ENOPROTOOPT = 42; // Protocol not available
enum EPROTONOSUPPORT = 43; // Protocol not supported
enum ENOTSUP = 45; // Operation not supported
enum EOPNOTSUPP = ENOTSUP; // Operation not supported on socket
enum EAFNOSUPPORT = 47; // Address family not supported by protocol family
enum EADDRINUSE = 48; // Address already in use
enum EADDRNOTAVAIL = 49; // Can't assign requested address
enum ENETDOWN = 50; // Network is down
enum ENETUNREACH = 51; // Network is unreachable
enum ENETRESET = 52; // Network dropped connection on reset
enum ECONNABORTED = 53; // Software caused connection abort
enum ECONNRESET = 54; // Connection reset by peer
enum ENOBUFS = 55; // No buffer space available
enum EISCONN = 56; // Socket is already connected
enum ENOTCONN = 57; // Socket is not connected
enum ESHUTDOWN = 58; // Can't send after socket shutdown
enum ETOOMANYREFS = 59; // Too many refrences; can't splice
enum ETIMEDOUT = 60; // Operation timed out
enum ECONNREFUSED = 61; // Connection refused
enum ELOOP = 62; // Too many levels of symbolic links
enum ENAMETOOLONG = 63; // File name too long
enum EHOSTUNREACH = 65; // No route to host
enum ENOTEMPTY = 66; // Directory not empty
enum EPROCLIM = 67; // Too many processes
enum EUSERS = 68; // Too many users
enum EDQUOT = 69; // Disc quota exceeded
enum ESTALE = 70; // Stale NFS file handle
enum EREMOTE = 71; // Too many levels of remote in path
enum EBADRPC = 72; // RPC struct is bad
enum ERPCMISMATCH = 73; // RPC version wrong
enum EPROGUNAVAIL = 74; // RPC prog. not avail
enum EPROGMISMATCH = 75; // Program version wrong
enum EPROCUNAVAIL = 76; // Bad procedure for program
enum ENOLCK = 77; // No locks available
enum ENOSYS = 78; // Function not implemented
enum EFTYPE = 79; // Inappropriate file type or format
enum EAUTH = 80; // Authentication error
enum ENEEDAUTH = 81; // Need authenticator
enum EIDRM = 82; // Itendifier removed
enum ENOMSG = 83; // No message of desired type
enum EOVERFLOW = 84; // Value too large to be stored in data type
enum ECANCELED = 85; // Operation canceled
enum EILSEQ = 86; // Illegal byte sequence
enum ENOATTR = 87; // Attribute not found
enum EDOOFUS = 88; // Programming error
enum EBADMSG = 89; // Bad message
enum EMULTIHOP = 90; // Multihop attempted
enum ENOLINK = 91; // Link has been severed
enum EPROTO = 92; // Protocol error
enum ELAST = 92; // Must be equal largest errno
}

View File

@@ -0,0 +1,142 @@
/**
* D header file for C99.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: ISO/IEC 9899:1999 (E)
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.stdc.fenv;
extern (C):
version( Windows )
{
struct fenv_t
{
ushort status;
ushort control;
ushort round;
ushort[2] reserved;
}
alias int fexcept_t;
}
else version( linux )
{
struct fenv_t
{
ushort __control_word;
ushort __unused1;
ushort __status_word;
ushort __unused2;
ushort __tags;
ushort __unused3;
uint __eip;
ushort __cs_selector;
ushort __opcode;
uint __data_offset;
ushort __data_selector;
ushort __unused5;
}
alias int fexcept_t;
}
else version ( OSX )
{
version ( BigEndian )
{
alias uint fenv_t;
alias uint fexcept_t;
}
version ( LittleEndian )
{
struct fenv_t
{
ushort __control;
ushort __status;
uint __mxcsr;
byte[8] __reserved;
}
alias ushort fexcept_t;
}
}
else version ( freebsd )
{
struct fenv_t
{
ushort __control;
ushort __mxcsr_hi;
ushort __status;
ushort __mxcsr_lo;
uint __tag;
byte[16] __other;
}
alias ushort fexcept_t;
}
else
{
static assert( false );
}
enum
{
FE_INVALID = 1,
FE_DENORMAL = 2, // non-standard
FE_DIVBYZERO = 4,
FE_OVERFLOW = 8,
FE_UNDERFLOW = 0x10,
FE_INEXACT = 0x20,
FE_ALL_EXCEPT = 0x3F,
FE_TONEAREST = 0,
FE_UPWARD = 0x800,
FE_DOWNWARD = 0x400,
FE_TOWARDZERO = 0xC00,
}
version( Windows )
{
private extern fenv_t _FE_DFL_ENV;
fenv_t* FE_DFL_ENV = &_FE_DFL_ENV;
}
else version( linux )
{
fenv_t* FE_DFL_ENV = cast(fenv_t*)(-1);
}
else version( OSX )
{
private extern fenv_t _FE_DFL_ENV;
fenv_t* FE_DFL_ENV = &_FE_DFL_ENV;
}
else version( freebsd )
{
private extern fenv_t __fe_dfl_env;
fenv_t* FE_DFL_ENV = &__fe_dfl_env;
}
else
{
static assert( false );
}
void feraiseexcept(int excepts);
void feclearexcept(int excepts);
int fetestexcept(int excepts);
int feholdexcept(fenv_t* envp);
void fegetexceptflag(fexcept_t* flagp, int excepts);
void fesetexceptflag(in fexcept_t* flagp, int excepts);
int fegetround();
int fesetround(int round);
void fegetenv(fenv_t* envp);
void fesetenv(in fenv_t* envp);
void feupdateenv(in fenv_t* envp);

View File

@@ -0,0 +1,57 @@
/**
* D header file for C99.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: ISO/IEC 9899:1999 (E)
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.stdc.float_;
extern (C):
enum FLT_ROUNDS = 1;
enum FLT_EVAL_METHOD = 2;
enum FLT_RADIX = 2;
enum DECIMAL_DIG = real.dig;
enum FLT_DIG = float.dig;
enum DBL_DIG = double.dig;
enum LDBL_DIG = real.dig;
enum FLT_MANT_DIG = float.mant_dig;
enum DBL_MANT_DIG = double.mant_dig;
enum LDBL_MANT_DIG = real.mant_dig;
enum FLT_MIN = float.min;
enum DBL_MIN = double.min;
enum LDBL_MIN = real.min;
enum FLT_MAX = float.max;
enum DBL_MAX = double.max;
enum LDBL_MAX = real.max;
enum FLT_EPSILON = float.epsilon;
enum DBL_EPSILON = double.epsilon;
enum LDBL_EPSILON = real.epsilon;
enum FLT_MIN_EXP = float.min_exp;
enum DBL_MIN_EXP = double.min_exp;
enum LDBL_MIN_EXP = real.min_exp;
enum FLT_MAX_EXP = float.max_exp;
enum DBL_MAX_EXP = double.max_exp;
enum LDBL_MAX_EXP = real.max_exp;
enum FLT_MIN_10_EXP = float.min_10_exp;
enum DBL_MIN_10_EXP = double.min_10_exp;
enum LDBL_MIN_10_EXP = real.min_10_exp;
enum FLT_MAX_10_EXP = float.max_10_exp;
enum DBL_MAX_10_EXP = double.max_10_exp;
enum LDBL_MAX_10_EXP = real.max_10_exp;

View File

@@ -0,0 +1,256 @@
/**
* D header file for C99.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: ISO/IEC 9899:1999 (E)
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.stdc.inttypes;
public import core.stdc.stddef; // for wchar_t
public import core.stdc.stdint; // required by spec
extern (C):
struct imaxdiv_t
{
intmax_t quot,
rem;
}
private alias immutable(char)* _cstr;
enum _cstr PRId8 = "hhd";
enum _cstr PRId16 = "hd";
enum _cstr PRId32 = "ld";
enum _cstr PRId64 = "lld";
enum _cstr PRIdLEAST8 = "hhd";
enum _cstr PRIdLEAST16 = "hd";
enum _cstr PRIdLEAST32 = "ld";
enum _cstr PRIdLEAST64 = "lld";
enum _cstr PRIdFAST8 = "hhd";
enum _cstr PRIdFAST16 = "d";
enum _cstr PRIdFAST32 = "ld";
enum _cstr PRIdFAST64 = "lld";
enum _cstr PRIi8 = "hhi";
enum _cstr PRIi16 = "hi";
enum _cstr PRIi32 = "li";
enum _cstr PRIi64 = "lli";
enum _cstr PRIiLEAST8 = "hhi";
enum _cstr PRIiLEAST16 = "hi";
enum _cstr PRIiLEAST32 = "li";
enum _cstr PRIiLEAST64 = "lli";
enum _cstr PRIiFAST8 = "hhi";
enum _cstr PRIiFAST16 = "i";
enum _cstr PRIiFAST32 = "li";
enum _cstr PRIiFAST64 = "lli";
enum _cstr PRIo8 = "hho";
enum _cstr PRIo16 = "ho";
enum _cstr PRIo32 = "lo";
enum _cstr PRIo64 = "llo";
enum _cstr PRIoLEAST8 = "hho";
enum _cstr PRIoLEAST16 = "ho";
enum _cstr PRIoLEAST32 = "lo";
enum _cstr PRIoLEAST64 = "llo";
enum _cstr PRIoFAST8 = "hho";
enum _cstr PRIoFAST16 = "o";
enum _cstr PRIoFAST32 = "lo";
enum _cstr PRIoFAST64 = "llo";
enum _cstr PRIu8 = "hhu";
enum _cstr PRIu16 = "hu";
enum _cstr PRIu32 = "lu";
enum _cstr PRIu64 = "llu";
enum _cstr PRIuLEAST8 = "hhu";
enum _cstr PRIuLEAST16 = "hu";
enum _cstr PRIuLEAST32 = "lu";
enum _cstr PRIuLEAST64 = "llu";
enum _cstr PRIuFAST8 = "hhu";
enum _cstr PRIuFAST16 = "u";
enum _cstr PRIuFAST32 = "lu";
enum _cstr PRIuFAST64 = "llu";
enum _cstr PRIx8 = "hhx";
enum _cstr PRIx16 = "hx";
enum _cstr PRIx32 = "lx";
enum _cstr PRIx64 = "llx";
enum _cstr PRIxLEAST8 = "hhx";
enum _cstr PRIxLEAST16 = "hx";
enum _cstr PRIxLEAST32 = "lx";
enum _cstr PRIxLEAST64 = "llx";
enum _cstr PRIxFAST8 = "hhx";
enum _cstr PRIxFAST16 = "x";
enum _cstr PRIxFAST32 = "lx";
enum _cstr PRIxFAST64 = "llx";
enum _cstr PRIX8 = "hhX";
enum _cstr PRIX16 = "hX";
enum _cstr PRIX32 = "lX";
enum _cstr PRIX64 = "llX";
enum _cstr PRIXLEAST8 = "hhX";
enum _cstr PRIXLEAST16 = "hX";
enum _cstr PRIXLEAST32 = "lX";
enum _cstr PRIXLEAST64 = "llX";
enum _cstr PRIXFAST8 = "hhX";
enum _cstr PRIXFAST16 = "X";
enum _cstr PRIXFAST32 = "lX";
enum _cstr PRIXFAST64 = "llX";
enum _cstr SCNd8 = "hhd";
enum _cstr SCNd16 = "hd";
enum _cstr SCNd32 = "ld";
enum _cstr SCNd64 = "lld";
enum _cstr SCNdLEAST8 = "hhd";
enum _cstr SCNdLEAST16 = "hd";
enum _cstr SCNdLEAST32 = "ld";
enum _cstr SCNdLEAST64 = "lld";
enum _cstr SCNdFAST8 = "hhd";
enum _cstr SCNdFAST16 = "d";
enum _cstr SCNdFAST32 = "ld";
enum _cstr SCNdFAST64 = "lld";
enum _cstr SCNi8 = "hhd";
enum _cstr SCNi16 = "hi";
enum _cstr SCNi32 = "li";
enum _cstr SCNi64 = "lli";
enum _cstr SCNiLEAST8 = "hhd";
enum _cstr SCNiLEAST16 = "hi";
enum _cstr SCNiLEAST32 = "li";
enum _cstr SCNiLEAST64 = "lli";
enum _cstr SCNiFAST8 = "hhd";
enum _cstr SCNiFAST16 = "i";
enum _cstr SCNiFAST32 = "li";
enum _cstr SCNiFAST64 = "lli";
enum _cstr SCNo8 = "hhd";
enum _cstr SCNo16 = "ho";
enum _cstr SCNo32 = "lo";
enum _cstr SCNo64 = "llo";
enum _cstr SCNoLEAST8 = "hhd";
enum _cstr SCNoLEAST16 = "ho";
enum _cstr SCNoLEAST32 = "lo";
enum _cstr SCNoLEAST64 = "llo";
enum _cstr SCNoFAST8 = "hhd";
enum _cstr SCNoFAST16 = "o";
enum _cstr SCNoFAST32 = "lo";
enum _cstr SCNoFAST64 = "llo";
enum _cstr SCNu8 = "hhd";
enum _cstr SCNu16 = "hu";
enum _cstr SCNu32 = "lu";
enum _cstr SCNu64 = "llu";
enum _cstr SCNuLEAST8 = "hhd";
enum _cstr SCNuLEAST16 = "hu";
enum _cstr SCNuLEAST32 = "lu";
enum _cstr SCNuLEAST64 = "llu";
enum _cstr SCNuFAST8 = "hhd";
enum _cstr SCNuFAST16 = "u";
enum _cstr SCNuFAST32 = "lu";
enum _cstr SCNuFAST64 = "llu";
enum _cstr SCNx8 = "hhd";
enum _cstr SCNx16 = "hx";
enum _cstr SCNx32 = "lx";
enum _cstr SCNx64 = "llx";
enum _cstr SCNxLEAST8 = "hhd";
enum _cstr SCNxLEAST16 = "hx";
enum _cstr SCNxLEAST32 = "lx";
enum _cstr SCNxLEAST64 = "llx";
enum _cstr SCNxFAST8 = "hhd";
enum _cstr SCNxFAST16 = "x";
enum _cstr SCNxFAST32 = "lx";
enum _cstr SCNxFAST64 = "llx";
version( X86_64 )
{
enum _cstr PRIdMAX = PRId64;
enum _cstr PRIiMAX = PRIi64;
enum _cstr PRIoMAX = PRIo64;
enum _cstr PRIuMAX = PRIu64;
enum _cstr PRIxMAX = PRIx64;
enum _cstr PRIXMAX = PRIX64;
enum _cstr SCNdMAX = SCNd64;
enum _cstr SCNiMAX = SCNi64;
enum _cstr SCNoMAX = SCNo64;
enum _cstr SCNuMAX = SCNu64;
enum _cstr SCNxMAX = SCNx64;
enum _cstr PRIdPTR = PRId64;
enum _cstr PRIiPTR = PRIi64;
enum _cstr PRIoPTR = PRIo64;
enum _cstr PRIuPTR = PRIu64;
enum _cstr PRIxPTR = PRIx64;
enum _cstr PRIXPTR = PRIX64;
enum _cstr SCNdPTR = SCNd64;
enum _cstr SCNiPTR = SCNi64;
enum _cstr SCNoPTR = SCNo64;
enum _cstr SCNuPTR = SCNu64;
enum _cstr SCNxPTR = SCNx64;
}
else
{
enum _cstr PRIdMAX = PRId32;
enum _cstr PRIiMAX = PRIi32;
enum _cstr PRIoMAX = PRIo32;
enum _cstr PRIuMAX = PRIu32;
enum _cstr PRIxMAX = PRIx32;
enum _cstr PRIXMAX = PRIX32;
enum _cstr SCNdMAX = SCNd32;
enum _cstr SCNiMAX = SCNi32;
enum _cstr SCNoMAX = SCNo32;
enum _cstr SCNuMAX = SCNu32;
enum _cstr SCNxMAX = SCNx32;
enum _cstr PRIdPTR = PRId32;
enum _cstr PRIiPTR = PRIi32;
enum _cstr PRIoPTR = PRIo32;
enum _cstr PRIuPTR = PRIu32;
enum _cstr PRIxPTR = PRIx32;
enum _cstr PRIXPTR = PRIX32;
enum _cstr SCNdPTR = SCNd32;
enum _cstr SCNiPTR = SCNi32;
enum _cstr SCNoPTR = SCNo32;
enum _cstr SCNuPTR = SCNu32;
enum _cstr SCNxPTR = SCNx32;
}
intmax_t imaxabs(intmax_t j);
imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
intmax_t strtoimax(in char* nptr, char** endptr, int base);
uintmax_t strtoumax(in char* nptr, char** endptr, int base);
intmax_t wcstoimax(in wchar_t* nptr, wchar_t** endptr, int base);
uintmax_t wcstoumax(in wchar_t* nptr, wchar_t** endptr, int base);

View File

@@ -0,0 +1,38 @@
/**
* D header file for C99.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: ISO/IEC 9899:1999 (E)
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.stdc.limits;
private import core.stdc.config;
extern (C):
enum CHAR_BIT = 8;
enum SCHAR_MIN = byte.min;
enum SCHAR_MAX = byte.max;
enum UCHAR_MAX = ubyte.min;
enum CHAR_MIN = char.max;
enum CHAR_MAX = char.max;
enum MB_LEN_MAX = 2;
enum SHRT_MIN = short.min;
enum SHRT_MAX = short.max;
enum USHRT_MAX = ushort.max;
enum INT_MIN = int.min;
enum INT_MAX = int.max;
enum UINT_MAX = uint.max;
enum LONG_MIN = c_long.min;
enum LONG_MAX = c_long.max;
enum ULONG_MAX = c_ulong.max;
enum LLONG_MIN = long.min;
enum LLONG_MAX = long.max;
enum ULLONG_MAX = ulong.max;

View File

@@ -0,0 +1,60 @@
/**
* D header file for C99.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: ISO/IEC 9899:1999 (E)
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.stdc.locale;
extern (C):
struct lconv
{
char* decimal_point;
char* thousands_sep;
char* grouping;
char* int_curr_symbol;
char* currency_symbol;
char* mon_decimal_point;
char* mon_thousands_sep;
char* mon_grouping;
char* positive_sign;
char* negative_sign;
byte int_frac_digits;
byte frac_digits;
byte p_cs_precedes;
byte p_sep_by_space;
byte n_cs_precedes;
byte n_sep_by_space;
byte p_sign_posn;
byte n_sign_posn;
byte int_p_cs_precedes;
byte int_p_sep_by_space;
byte int_n_cs_precedes;
byte int_n_sep_by_space;
byte int_p_sign_posn;
byte int_n_sign_posn;
}
enum LC_CTYPE = 0;
enum LC_NUMERIC = 1;
enum LC_TIME = 2;
enum LC_COLLATE = 3;
enum LC_MONETARY = 4;
enum LC_ALL = 6;
enum LC_PAPER = 7; // non-standard
enum LC_NAME = 8; // non-standard
enum LC_ADDRESS = 9; // non-standard
enum LC_TELEPHONE = 10; // non-standard
enum LC_MEASUREMENT = 11; // non-standard
enum LC_IDENTIFICATION = 12; // non-standard
char* setlocale(int category, in char* locale);
lconv* localeconv();

View File

@@ -0,0 +1,933 @@
/**
* D header file for C99.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: ISO/IEC 9899:1999 (E)
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.stdc.math;
private import core.stdc.config;
extern (C):
alias float float_t;
alias double double_t;
enum double HUGE_VAL = double.infinity;
enum double HUGE_VALF = float.infinity;
enum double HUGE_VALL = real.infinity;
enum float INFINITY = float.infinity;
enum float NAN = float.nan;
enum int FP_ILOGB0 = int.min;
enum int FP_ILOGBNAN = int.min;
enum int MATH_ERRNO = 1;
enum int MATH_ERREXCEPT = 2;
enum int math_errhandling = MATH_ERRNO | MATH_ERREXCEPT;
version( none )
{
//
// these functions are all macros in C
//
//int fpclassify(real-floating x);
int fpclassify(float x);
int fpclassify(double x);
int fpclassify(real x);
//int isfinite(real-floating x);
int isfinite(float x);
int isfinite(double x);
int isfinite(real x);
//int isinf(real-floating x);
int isinf(float x);
int isinf(double x);
int isinf(real x);
//int isnan(real-floating x);
int isnan(float x);
int isnan(double x);
int isnan(real x);
//int isnormal(real-floating x);
int isnormal(float x);
int isnormal(double x);
int isnormal(real x);
//int signbit(real-floating x);
int signbit(float x);
int signbit(double x);
int signbit(real x);
//int isgreater(real-floating x, real-floating y);
int isgreater(float x, float y);
int isgreater(double x, double y);
int isgreater(real x, real y);
//int isgreaterequal(real-floating x, real-floating y);
int isgreaterequal(float x, float y);
int isgreaterequal(double x, double y);
int isgreaterequal(real x, real y);
//int isless(real-floating x, real-floating y);
int isless(float x, float y);
int isless(double x, double y);
int isless(real x, real y);
//int islessequal(real-floating x, real-floating y);
int islessequal(float x, float y);
int islessequal(double x, double y);
int islessequal(real x, real y);
//int islessgreater(real-floating x, real-floating y);
int islessgreater(float x, float y);
int islessgreater(double x, double y);
int islessgreater(real x, real y);
//int isunordered(real-floating x, real-floating y);
int isunordered(float x, float y);
int isunordered(double x, double y);
int isunordered(real x, real y);
}
version( DigitalMars ) version( Windows )
version = DigitalMarsWin32;
version( DigitalMarsWin32 )
{
enum
{
FP_NANS = 0,
FP_NANQ = 1,
FP_INFINITE = 2,
FP_NORMAL = 3,
FP_SUBNORMAL = 4,
FP_ZERO = 5,
FP_NAN = FP_NANQ,
FP_EMPTY = 6,
FP_UNSUPPORTED = 7,
}
enum
{
FP_FAST_FMA = 0,
FP_FAST_FMAF = 0,
FP_FAST_FMAL = 0,
}
uint __fpclassify_f(float x);
uint __fpclassify_d(double x);
uint __fpclassify_ld(real x);
extern (D)
{
//int fpclassify(real-floating x);
int fpclassify(float x) { return __fpclassify_f(x); }
int fpclassify(double x) { return __fpclassify_d(x); }
int fpclassify(real x)
{
return (real.sizeof == double.sizeof)
? __fpclassify_d(x)
: __fpclassify_ld(x);
}
//int isfinite(real-floating x);
int isfinite(float x) { return fpclassify(x) >= FP_NORMAL; }
int isfinite(double x) { return fpclassify(x) >= FP_NORMAL; }
int isfinite(real x) { return fpclassify(x) >= FP_NORMAL; }
//int isinf(real-floating x);
int isinf(float x) { return fpclassify(x) == FP_INFINITE; }
int isinf(double x) { return fpclassify(x) == FP_INFINITE; }
int isinf(real x) { return fpclassify(x) == FP_INFINITE; }
//int isnan(real-floating x);
int isnan(float x) { return fpclassify(x) <= FP_NANQ; }
int isnan(double x) { return fpclassify(x) <= FP_NANQ; }
int isnan(real x) { return fpclassify(x) <= FP_NANQ; }
//int isnormal(real-floating x);
int isnormal(float x) { return fpclassify(x) == FP_NORMAL; }
int isnormal(double x) { return fpclassify(x) == FP_NORMAL; }
int isnormal(real x) { return fpclassify(x) == FP_NORMAL; }
//int signbit(real-floating x);
int signbit(float x) { return (cast(short*)&(x))[1] & 0x8000; }
int signbit(double x) { return (cast(short*)&(x))[3] & 0x8000; }
int signbit(real x)
{
return (real.sizeof == double.sizeof)
? (cast(short*)&(x))[3] & 0x8000
: (cast(short*)&(x))[4] & 0x8000;
}
}
}
else version( linux )
{
enum
{
FP_NAN,
FP_INFINITE,
FP_ZERO,
FP_SUBNORMAL,
FP_NORMAL,
}
enum
{
FP_FAST_FMA = 0,
FP_FAST_FMAF = 0,
FP_FAST_FMAL = 0,
}
int __fpclassifyf(float x);
int __fpclassify(double x);
int __fpclassifyl(real x);
int __finitef(float x);
int __finite(double x);
int __finitel(real x);
int __isinff(float x);
int __isinf(double x);
int __isinfl(real x);
int __isnanf(float x);
int __isnan(double x);
int __isnanl(real x);
int __signbitf(float x);
int __signbit(double x);
int __signbitl(real x);
extern (D)
{
//int fpclassify(real-floating x);
int fpclassify(float x) { return __fpclassifyf(x); }
int fpclassify(double x) { return __fpclassify(x); }
int fpclassify(real x)
{
return (real.sizeof == double.sizeof)
? __fpclassify(x)
: __fpclassifyl(x);
}
//int isfinite(real-floating x);
int isfinite(float x) { return __finitef(x); }
int isfinite(double x) { return __finite(x); }
int isfinite(real x)
{
return (real.sizeof == double.sizeof)
? __finite(x)
: __finitel(x);
}
//int isinf(real-floating x);
int isinf(float x) { return __isinff(x); }
int isinf(double x) { return __isinf(x); }
int isinf(real x)
{
return (real.sizeof == double.sizeof)
? __isinf(x)
: __isinfl(x);
}
//int isnan(real-floating x);
int isnan(float x) { return __isnanf(x); }
int isnan(double x) { return __isnan(x); }
int isnan(real x)
{
return (real.sizeof == double.sizeof)
? __isnan(x)
: __isnanl(x);
}
//int isnormal(real-floating x);
int isnormal(float x) { return fpclassify(x) == FP_NORMAL; }
int isnormal(double x) { return fpclassify(x) == FP_NORMAL; }
int isnormal(real x) { return fpclassify(x) == FP_NORMAL; }
//int signbit(real-floating x);
int signbit(float x) { return __signbitf(x); }
int signbit(double x) { return __signbit(x); }
int signbit(real x)
{
return (real.sizeof == double.sizeof)
? __signbit(x)
: __signbitl(x);
}
}
}
else version( OSX )
{
enum
{
FP_NAN = 1,
FP_INFINITE = 2,
FP_ZERO = 3,
FP_NORMAL = 4,
FP_SUBNORMAL = 5,
FP_SUPERNORMAL = 6,
}
enum
{
FP_FAST_FMA = 0,
FP_FAST_FMAF = 0,
FP_FAST_FMAL = 0,
}
int __fpclassifyf(float x);
int __fpclassifyd(double x);
int __fpclassify(real x);
int __isfinitef(float x);
int __isfinited(double x);
int __isfinite(real x);
int __isinff(float x);
int __isinfd(double x);
int __isinf(real x);
int __isnanf(float x);
int __isnand(double x);
int __isnan(real x);
int __signbitf(float x);
int __signbitd(double x);
int __signbitl(real x);
extern (D)
{
//int fpclassify(real-floating x);
int fpclassify(float x) { return __fpclassifyf(x); }
int fpclassify(double x) { return __fpclassifyd(x); }
int fpclassify(real x)
{
return (real.sizeof == double.sizeof)
? __fpclassifyd(x)
: __fpclassify(x);
}
//int isfinite(real-floating x);
int isfinite(float x) { return __isfinitef(x); }
int isfinite(double x) { return __isfinited(x); }
int isfinite(real x)
{
return (real.sizeof == double.sizeof)
? __isfinited(x)
: __isfinite(x);
}
//int isinf(real-floating x);
int isinf(float x) { return __isinff(x); }
int isinf(double x) { return __isinfd(x); }
int isinf(real x)
{
return (real.sizeof == double.sizeof)
? __isinfd(x)
: __isinf(x);
}
//int isnan(real-floating x);
int isnan(float x) { return __isnanf(x); }
int isnan(double x) { return __isnand(x); }
int isnan(real x)
{
return (real.sizeof == double.sizeof)
? __isnand(x)
: __isnan(x);
}
//int isnormal(real-floating x);
int isnormal(float x) { return fpclassify(x) == FP_NORMAL; }
int isnormal(double x) { return fpclassify(x) == FP_NORMAL; }
int isnormal(real x) { return fpclassify(x) == FP_NORMAL; }
//int signbit(real-floating x);
int signbit(float x) { return __signbitf(x); }
int signbit(double x) { return __signbitd(x); }
int signbit(real x)
{
return (real.sizeof == double.sizeof)
? __signbitd(x)
: __signbitl(x);
}
}
}
else version( freebsd )
{
enum
{
FP_INFINITE = 0x01,
FP_NAN = 0x02,
FP_NORMAL = 0x04,
FP_SUBNORMAL = 0x08,
FP_ZERO = 0x10,
}
enum
{
FP_FAST_FMA = 0,
FP_FAST_FMAF = 0,
FP_FAST_FMAL = 0,
}
int __fpclassifyd(double);
int __fpclassifyf(float);
int __fpclassifyl(real);
int __isfinitef(float);
int __isfinite(double);
int __isfinitel(real);
int __isinff(float);
int __isinfl(real);
int __isnanl(real);
int __isnormalf(float);
int __isnormal(double);
int __isnormall(real);
int __signbit(double);
int __signbitf(float);
int __signbitl(real);
extern (D)
{
//int fpclassify(real-floating x);
int fpclassify(float x) { return __fpclassifyf(x); }
int fpclassify(double x) { return __fpclassifyd(x); }
int fpclassify(real x) { return __fpclassifyl(x); }
//int isfinite(real-floating x);
int isfinite(float x) { return __isfinitef(x); }
int isfinite(double x) { return __isfinite(x); }
int isfinite(real x) { return __isfinitel(x); }
//int isinf(real-floating x);
int isinf(float x) { return __isinff(x); }
int isinf(double x) { return __isinfl(x); }
int isinf(real x) { return __isinfl(x); }
//int isnan(real-floating x);
int isnan(float x) { return __isnanl(x); }
int isnan(double x) { return __isnanl(x); }
int isnan(real x) { return __isnanl(x); }
//int isnormal(real-floating x);
int isnormal(float x) { return __isnormalf(x); }
int isnormal(double x) { return __isnormal(x); }
int isnormal(real x) { return __isnormall(x); }
//int signbit(real-floating x);
int signbit(float x) { return __signbitf(x); }
int signbit(double x) { return __signbit(x); }
int signbit(real x) { return __signbit(x); }
}
}
extern (D)
{
//int isgreater(real-floating x, real-floating y);
int isgreater(float x, float y) { return !(x !> y); }
int isgreater(double x, double y) { return !(x !> y); }
int isgreater(real x, real y) { return !(x !> y); }
//int isgreaterequal(real-floating x, real-floating y);
int isgreaterequal(float x, float y) { return !(x !>= y); }
int isgreaterequal(double x, double y) { return !(x !>= y); }
int isgreaterequal(real x, real y) { return !(x !>= y); }
//int isless(real-floating x, real-floating y);
int isless(float x, float y) { return !(x !< y); }
int isless(double x, double y) { return !(x !< y); }
int isless(real x, real y) { return !(x !< y); }
//int islessequal(real-floating x, real-floating y);
int islessequal(float x, float y) { return !(x !<= y); }
int islessequal(double x, double y) { return !(x !<= y); }
int islessequal(real x, real y) { return !(x !<= y); }
//int islessgreater(real-floating x, real-floating y);
int islessgreater(float x, float y) { return !(x !<> y); }
int islessgreater(double x, double y) { return !(x !<> y); }
int islessgreater(real x, real y) { return !(x !<> y); }
//int isunordered(real-floating x, real-floating y);
int isunordered(float x, float y) { return (x !<>= y); }
int isunordered(double x, double y) { return (x !<>= y); }
int isunordered(real x, real y) { return (x !<>= y); }
}
// NOTE: freebsd < 8-CURRENT doesn't appear to support *l, but we can
// approximate.
version( freebsd )
{
double acos(double x);
float acosf(float x);
real acosl(real x) { return acos(x); }
double asin(double x);
float asinf(float x);
real asinl(real x) { return asin(x); }
double atan(double x);
float atanf(float x);
real atanl(real x) { return atan(x); }
double atan2(double y, double x);
float atan2f(float y, float x);
real atan2l(real y, real x) { return atan2(y, x); }
double cos(double x);
float cosf(float x);
real cosl(real x) { return cos(x); }
double sin(double x);
float sinf(float x);
real sinl(real x) { return sin(x); }
double tan(double x);
float tanf(float x);
real tanl(real x) { return tan(x); }
double acosh(double x);
float acoshf(float x);
real acoshl(real x) { return acosh(x); }
double asinh(double x);
float asinhf(float x);
real asinhl(real x) { return asinh(x); }
double atanh(double x);
float atanhf(float x);
real atanhl(real x) { return atanh(x); }
double cosh(double x);
float coshf(float x);
real coshl(real x) { return cosh(x); }
double sinh(double x);
float sinhf(float x);
real sinhl(real x) { return sinh(x); }
double tanh(double x);
float tanhf(float x);
real tanhl(real x) { return tanh(x); }
double exp(double x);
float expf(float x);
real expl(real x) { return exp(x); }
double exp2(double x);
float exp2f(float x);
real exp2l(real x) { return exp2(x); }
double expm1(double x);
float expm1f(float x);
real expm1l(real x) { return expm1(x); }
double frexp(double value, int* exp);
float frexpf(float value, int* exp);
real frexpl(real value, int* exp) { return frexp(value, exp); }
int ilogb(double x);
int ilogbf(float x);
int ilogbl(real x) { return ilogb(x); }
double ldexp(double x, int exp);
float ldexpf(float x, int exp);
real ldexpl(real x, int exp) { return ldexp(x, exp); }
double log(double x);
float logf(float x);
real logl(real x) { return log(x); }
double log10(double x);
float log10f(float x);
real log10l(real x) { return log10(x); }
double log1p(double x);
float log1pf(float x);
real log1pl(real x) { return log1p(x); }
private enum real ONE_LN2 = 1 / 0x1.62e42fefa39ef358p-1L;
double log2(double x) { return log(x) * ONE_LN2; }
float log2f(float x) { return logf(x) * ONE_LN2; }
real log2l(real x) { return logl(x) * ONE_LN2; }
double logb(double x);
float logbf(float x);
real logbl(real x) { return logb(x); }
double modf(double value, double* iptr);
float modff(float value, float* iptr);
//real modfl(real value, real *iptr); // nontrivial conversion
double scalbn(double x, int n);
float scalbnf(float x, int n);
real scalbnl(real x, int n) { return scalbn(x, n); }
double scalbln(double x, c_long n);
float scalblnf(float x, c_long n);
real scalblnl(real x, c_long n) { return scalbln(x, n); }
double cbrt(double x);
float cbrtf(float x);
real cbrtl(real x) { return cbrt(x); }
double fabs(double x);
float fabsf(float x);
real fabsl(real x) { return fabs(x); }
double hypot(double x, double y);
float hypotf(float x, float y);
real hypotl(real x, real y) { return hypot(x, y); }
double pow(double x, double y);
float powf(float x, float y);
real powl(real x, real y) { return pow(x, y); }
double sqrt(double x);
float sqrtf(float x);
real sqrtl(real x) { return sqrt(x); }
double erf(double x);
float erff(float x);
real erfl(real x) { return erf(x); }
double erfc(double x);
float erfcf(float x);
real erfcl(real x) { return erfc(x); }
double lgamma(double x);
float lgammaf(float x);
real lgammal(real x) { return lgamma(x); }
double tgamma(double x);
float tgammaf(float x);
real tgammal(real x) { return tgamma(x); }
double ceil(double x);
float ceilf(float x);
real ceill(real x) { return ceil(x); }
double floor(double x);
float floorf(float x);
real floorl(real x) { return floor(x); }
double nearbyint(double x);
float nearbyintf(float x);
real nearbyintl(real x) { return nearbyint(x); }
double rint(double x);
float rintf(float x);
real rintl(real x) { return rint(x); }
c_long lrint(double x);
c_long lrintf(float x);
c_long lrintl(real x) { return lrint(x); }
long llrint(double x);
long llrintf(float x);
long llrintl(real x) { return llrint(x); }
double round(double x);
float roundf(float x);
real roundl(real x) { return round(x); }
c_long lround(double x);
c_long lroundf(float x);
c_long lroundl(real x) { return lround(x); }
long llround(double x);
long llroundf(float x);
long llroundl(real x) { return llround(x); }
double trunc(double x);
float truncf(float x);
real truncl(real x) { return trunc(x); }
double fmod(double x, double y);
float fmodf(float x, float y);
real fmodl(real x, real y) { return fmod(x, y); }
double remainder(double x, double y);
float remainderf(float x, float y);
real remainderl(real x, real y) { return remainder(x, y); }
double remquo(double x, double y, int* quo);
float remquof(float x, float y, int* quo);
real remquol(real x, real y, int* quo) { return remquo(x, y, quo); }
double copysign(double x, double y);
float copysignf(float x, float y);
real copysignl(real x, real y) { return copysign(x, y); }
// double nan(char* tagp);
// float nanf(char* tagp);
// real nanl(char* tagp);
double nextafter(double x, double y);
float nextafterf(float x, float y);
real nextafterl(real x, real y) { return nextafter(x, y); }
double nexttoward(double x, real y);
float nexttowardf(float x, real y);
real nexttowardl(real x, real y) { return nexttoward(x, y); }
double fdim(double x, double y);
float fdimf(float x, float y);
real fdiml(real x, real y) { return fdim(x, y); }
double fmax(double x, double y);
float fmaxf(float x, float y);
real fmaxl(real x, real y) { return fmax(x, y); }
double fmin(double x, double y);
float fminf(float x, float y);
real fminl(real x, real y) { return fmin(x, y); }
double fma(double x, double y, double z);
float fmaf(float x, float y, float z);
real fmal(real x, real y, real z) { return fma(x, y, z); }
}
else
{
double acos(double x);
float acosf(float x);
real acosl(real x);
double asin(double x);
float asinf(float x);
real asinl(real x);
double atan(double x);
float atanf(float x);
real atanl(real x);
double atan2(double y, double x);
float atan2f(float y, float x);
real atan2l(real y, real x);
double cos(double x);
float cosf(float x);
real cosl(real x);
double sin(double x);
float sinf(float x);
real sinl(real x);
double tan(double x);
float tanf(float x);
real tanl(real x);
double acosh(double x);
float acoshf(float x);
real acoshl(real x);
double asinh(double x);
float asinhf(float x);
real asinhl(real x);
double atanh(double x);
float atanhf(float x);
real atanhl(real x);
double cosh(double x);
float coshf(float x);
real coshl(real x);
double sinh(double x);
float sinhf(float x);
real sinhl(real x);
double tanh(double x);
float tanhf(float x);
real tanhl(real x);
double exp(double x);
float expf(float x);
real expl(real x);
double exp2(double x);
float exp2f(float x);
real exp2l(real x);
double expm1(double x);
float expm1f(float x);
real expm1l(real x);
double frexp(double value, int* exp);
float frexpf(float value, int* exp);
real frexpl(real value, int* exp);
int ilogb(double x);
int ilogbf(float x);
int ilogbl(real x);
double ldexp(double x, int exp);
float ldexpf(float x, int exp);
real ldexpl(real x, int exp);
double log(double x);
float logf(float x);
real logl(real x);
double log10(double x);
float log10f(float x);
real log10l(real x);
double log1p(double x);
float log1pf(float x);
real log1pl(real x);
double log2(double x);
float log2f(float x);
real log2l(real x);
double logb(double x);
float logbf(float x);
real logbl(real x);
double modf(double value, double* iptr);
float modff(float value, float* iptr);
real modfl(real value, real *iptr);
double scalbn(double x, int n);
float scalbnf(float x, int n);
real scalbnl(real x, int n);
double scalbln(double x, c_long n);
float scalblnf(float x, c_long n);
real scalblnl(real x, c_long n);
double cbrt(double x);
float cbrtf(float x);
real cbrtl(real x);
double fabs(double x);
float fabsf(float x);
real fabsl(real x);
double hypot(double x, double y);
float hypotf(float x, float y);
real hypotl(real x, real y);
double pow(double x, double y);
float powf(float x, float y);
real powl(real x, real y);
double sqrt(double x);
float sqrtf(float x);
real sqrtl(real x);
double erf(double x);
float erff(float x);
real erfl(real x);
double erfc(double x);
float erfcf(float x);
real erfcl(real x);
double lgamma(double x);
float lgammaf(float x);
real lgammal(real x);
double tgamma(double x);
float tgammaf(float x);
real tgammal(real x);
double ceil(double x);
float ceilf(float x);
real ceill(real x);
double floor(double x);
float floorf(float x);
real floorl(real x);
double nearbyint(double x);
float nearbyintf(float x);
real nearbyintl(real x);
double rint(double x);
float rintf(float x);
real rintl(real x);
c_long lrint(double x);
c_long lrintf(float x);
c_long lrintl(real x);
long llrint(double x);
long llrintf(float x);
long llrintl(real x);
double round(double x);
float roundf(float x);
real roundl(real x);
c_long lround(double x);
c_long lroundf(float x);
c_long lroundl(real x);
long llround(double x);
long llroundf(float x);
long llroundl(real x);
double trunc(double x);
float truncf(float x);
real truncl(real x);
double fmod(double x, double y);
float fmodf(float x, float y);
real fmodl(real x, real y);
double remainder(double x, double y);
float remainderf(float x, float y);
real remainderl(real x, real y);
double remquo(double x, double y, int* quo);
float remquof(float x, float y, int* quo);
real remquol(real x, real y, int* quo);
double copysign(double x, double y);
float copysignf(float x, float y);
real copysignl(real x, real y);
double nan(char* tagp);
float nanf(char* tagp);
real nanl(char* tagp);
double nextafter(double x, double y);
float nextafterf(float x, float y);
real nextafterl(real x, real y);
double nexttoward(double x, real y);
float nexttowardf(float x, real y);
real nexttowardl(real x, real y);
double fdim(double x, double y);
float fdimf(float x, float y);
real fdiml(real x, real y);
double fmax(double x, double y);
float fmaxf(float x, float y);
real fmaxl(real x, real y);
double fmin(double x, double y);
float fminf(float x, float y);
real fminl(real x, real y);
double fma(double x, double y, double z);
float fmaf(float x, float y, float z);
real fmal(real x, real y, real z);
}

View File

@@ -0,0 +1,53 @@
/**
* D header file for C99.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: ISO/IEC 9899:1999 (E)
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.stdc.signal;
extern (C):
// this should be volatile
alias int sig_atomic_t;
private alias void function(int) sigfn_t;
version( Posix )
{
enum SIG_ERR = cast(sigfn_t) -1;
enum SIG_DFL = cast(sigfn_t) 0;
enum SIG_IGN = cast(sigfn_t) 1;
// standard C signals
enum SIGABRT = 6; // Abnormal termination
enum SIGFPE = 8; // Floating-point error
enum SIGILL = 4; // Illegal hardware instruction
enum SIGINT = 2; // Terminal interrupt character
enum SIGSEGV = 11; // Invalid memory reference
enum SIGTERM = 15; // Termination
}
else
{
enum SIG_ERR = cast(sigfn_t) -1;
enum SIG_DFL = cast(sigfn_t) 0;
enum SIG_IGN = cast(sigfn_t) 1;
// standard C signals
enum SIGABRT = 22; // Abnormal termination
enum SIGFPE = 8; // Floating-point error
enum SIGILL = 4; // Illegal hardware instruction
enum SIGINT = 2; // Terminal interrupt character
enum SIGSEGV = 11; // Invalid memory reference
enum SIGTERM = 15; // Termination
}
sigfn_t signal(int sig, sigfn_t func);
int raise(int sig);

View File

@@ -0,0 +1,45 @@
/**
* D header file for C99.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: ISO/IEC 9899:1999 (E)
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.stdc.stdarg;
alias void* va_list;
template va_start( T )
{
void va_start( out va_list ap, inout T parmn )
{
ap = cast(va_list) ( cast(void*) &parmn + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) );
}
}
template va_arg( T )
{
T va_arg( inout va_list ap )
{
T arg = *cast(T*) ap;
ap = cast(va_list) ( cast(void*) ap + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) );
return arg;
}
}
void va_end( va_list ap )
{
}
void va_copy( out va_list dest, va_list src )
{
dest = src;
}

View File

@@ -0,0 +1,28 @@
/**
* D header file for C99.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: ISO/IEC 9899:1999 (E)
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.stdc.stddef;
extern (C):
//alias typeof(int.sizeof) size_t;
//alias typeof(cast(void*)0 - cast(void*)0) ptrdiff_t;
version( Windows )
{
alias wchar wchar_t;
}
else
{
alias dchar wchar_t;
}

View File

@@ -0,0 +1,154 @@
/**
* D header file for C99.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: ISO/IEC 9899:1999 (E)
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.stdc.stdint;
private import core.stdc.stddef; // for ptrdiff_t, size_t, wchar_t
private import core.stdc.signal; // for sig_atomic_t
private import core.stdc.wchar_; // for wint_t
private
{
template typify(T)
{
T typify( T val ) { return val; }
}
}
extern (C):
alias byte int8_t;
alias short int16_t;
alias int int32_t;
alias long int64_t;
//alias cent int128_t;
alias ubyte uint8_t;
alias ushort uint16_t;
alias uint uint32_t;
alias ulong uint64_t;
//alias ucent uint128_t;
alias byte int_least8_t;
alias short int_least16_t;
alias int int_least32_t;
alias long int_least64_t;
alias ubyte uint_least8_t;
alias ushort uint_least16_t;
alias uint uint_least32_t;
alias ulong uint_least64_t;
alias byte int_fast8_t;
alias int int_fast16_t;
alias int int_fast32_t;
alias long int_fast64_t;
alias ubyte uint_fast8_t;
alias uint uint_fast16_t;
alias uint uint_fast32_t;
alias ulong uint_fast64_t;
version( X86_64 )
{
alias long intptr_t;
alias ulong uintptr_t;
}
else
{
alias int intptr_t;
alias uint uintptr_t;
}
alias long intmax_t;
alias ulong uintmax_t;
enum int8_t INT8_MIN = int8_t.min;
enum int8_t INT8_MAX = int8_t.max;
enum int16_t INT16_MIN = int16_t.min;
enum int16_t INT16_MAX = int16_t.max;
enum int32_t INT32_MIN = int32_t.min;
enum int32_t INT32_MAX = int32_t.max;
enum int64_t INT64_MIN = int64_t.min;
enum int64_t INT64_MAX = int64_t.max;
enum uint8_t UINT8_MAX = uint8_t.max;
enum uint16_t UINT16_MAX = uint16_t.max;
enum uint32_t UINT32_MAX = uint32_t.max;
enum uint64_t UINT64_MAX = uint64_t.max;
enum int_least8_t INT_LEAST8_MIN = int_least8_t.min;
enum int_least8_t INT_LEAST8_MAX = int_least8_t.max;
enum int_least16_t INT_LEAST16_MIN = int_least16_t.min;
enum int_least16_t INT_LEAST16_MAX = int_least16_t.max;
enum int_least32_t INT_LEAST32_MIN = int_least32_t.min;
enum int_least32_t INT_LEAST32_MAX = int_least32_t.max;
enum int_least64_t INT_LEAST64_MIN = int_least64_t.min;
enum int_least64_t INT_LEAST64_MAX = int_least64_t.max;
enum uint_least8_t UINT_LEAST8_MAX = uint_least8_t.max;
enum uint_least16_t UINT_LEAST16_MAX = uint_least16_t.max;
enum uint_least32_t UINT_LEAST32_MAX = uint_least32_t.max;
enum uint_least64_t UINT_LEAST64_MAX = uint_least64_t.max;
enum int_fast8_t INT_FAST8_MIN = int_fast8_t.min;
enum int_fast8_t INT_FAST8_MAX = int_fast8_t.max;
enum int_fast16_t INT_FAST16_MIN = int_fast16_t.min;
enum int_fast16_t INT_FAST16_MAX = int_fast16_t.max;
enum int_fast32_t INT_FAST32_MIN = int_fast32_t.min;
enum int_fast32_t INT_FAST32_MAX = int_fast32_t.max;
enum int_fast64_t INT_FAST64_MIN = int_fast64_t.min;
enum int_fast64_t INT_FAST64_MAX = int_fast64_t.max;
enum uint_fast8_t UINT_FAST8_MAX = uint_fast8_t.max;
enum uint_fast16_t UINT_FAST16_MAX = uint_fast16_t.max;
enum uint_fast32_t UINT_FAST32_MAX = uint_fast32_t.max;
enum uint_fast64_t UINT_FAST64_MAX = uint_fast64_t.max;
enum intptr_t INTPTR_MIN = intptr_t.min;
enum intptr_t INTPTR_MAX = intptr_t.max;
enum uintptr_t UINTPTR_MIN = uintptr_t.min;
enum uintptr_t UINTPTR_MAX = uintptr_t.max;
enum intmax_t INTMAX_MIN = intmax_t.min;
enum intmax_t INTMAX_MAX = intmax_t.max;
enum uintmax_t UINTMAX_MAX = uintmax_t.max;
enum ptrdiff_t PTRDIFF_MIN = ptrdiff_t.min;
enum ptrdiff_t PTRDIFF_MAX = ptrdiff_t.max;
enum sig_atomic_t SIG_ATOMIC_MIN = sig_atomic_t.min;
enum sig_atomic_t SIG_ATOMIC_MAX = sig_atomic_t.max;
enum size_t SIZE_MAX = size_t.max;
enum wchar_t WCHAR_MIN = wchar_t.min;
enum wchar_t WCHAR_MAX = wchar_t.max;
enum wint_t WINT_MIN = wint_t.min;
enum wint_t WINT_MAX = wint_t.max;
alias typify!(int8_t) INT8_C;
alias typify!(int16_t) INT16_C;
alias typify!(int32_t) INT32_C;
alias typify!(int64_t) INT64_C;
alias typify!(uint8_t) UINT8_C;
alias typify!(uint16_t) UINT16_C;
alias typify!(uint32_t) UINT32_C;
alias typify!(uint64_t) UINT64_C;
alias typify!(intmax_t) INTMAX_C;
alias typify!(uintmax_t) UINTMAX_C;

View File

@@ -0,0 +1,411 @@
/**
* D header file for C99.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: ISO/IEC 9899:1999 (E)
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.stdc.stdio;
private
{
import core.stdc.config;
import core.stdc.stddef; // for size_t
import core.stdc.stdarg; // for va_list
}
extern (C):
version( Windows )
{
enum
{
BUFSIZ = 0x4000,
EOF = -1,
FOPEN_MAX = 20,
FILENAME_MAX = 256, // 255 plus NULL
TMP_MAX = 32767,
SYS_OPEN = 20, // non-standard
}
enum int _NFILE = 60; // non-standard
enum string _P_tmpdir = "\\"; // non-standard
enum wstring _wP_tmpdir = "\\"; // non-standard
enum int L_tmpnam = _P_tmpdir.length + 12;
}
else version( linux )
{
enum
{
BUFSIZ = 8192,
EOF = -1,
FOPEN_MAX = 16,
FILENAME_MAX = 4095,
TMP_MAX = 238328,
L_tmpnam = 20
}
}
else version( OSX )
{
enum
{
BUFSIZ = 1024,
EOF = -1,
FOPEN_MAX = 20,
FILENAME_MAX = 1024,
TMP_MAX = 308915776,
L_tmpnam = 1024,
}
private
{
struct __sbuf
{
ubyte* _base;
int _size;
}
struct __sFILEX
{
}
}
}
else version ( FreeBSD )
{
enum
{
EOF = -1,
FOPEN_MAX = 20,
FILENAME_MAX = 1024,
TMP_MAX = 308915776,
L_tmpnam = 1024
}
private
{
struct __sbuf
{
ubyte *_base;
int _size;
}
struct __sFILEX
{
}
}
}
else
{
static assert( false );
}
enum
{
SEEK_SET,
SEEK_CUR,
SEEK_END
}
struct _iobuf
{
align (1):
version( Windows )
{
char* _ptr;
int _cnt;
char* _base;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
int __tmpnum;
}
else version( linux )
{
char* _read_ptr;
char* _read_end;
char* _read_base;
char* _write_base;
char* _write_ptr;
char* _write_end;
char* _buf_base;
char* _buf_end;
char* _save_base;
char* _backup_base;
char* _save_end;
void* _markers;
_iobuf* _chain;
int _fileno;
int _blksize;
int _old_offset;
ushort _cur_column;
byte _vtable_offset;
char[1] _shortbuf;
void* _lock;
}
else version( OSX )
{
ubyte* _p;
int _r;
int _w;
short _flags;
short _file;
__sbuf _bf;
int _lbfsize;
int* function(void*) _close;
int* function(void*, char*, int) _read;
fpos_t* function(void*, fpos_t, int) _seek;
int* function(void*, char *, int) _write;
__sbuf _ub;
__sFILEX* _extra;
int _ur;
ubyte[3] _ubuf;
ubyte[1] _nbuf;
__sbuf _lb;
int _blksize;
fpos_t _offset;
}
else version( FreeBSD )
{
ubyte* _p;
int _r;
int _w;
short _flags;
short _file;
__sbuf _bf;
int _lbfsize;
void* function() _cookie;
int* function(void*) _close;
int* function(void*, char*, int) _read;
fpos_t* function(void*, fpos_t, int) _seek;
int* function(void*, char *, int) _write;
__sbuf _ub;
__sFILEX* _extra;
int _ur;
ubyte[3] _ubuf;
ubyte[1] _nbuf;
__sbuf _lb;
int _blksize;
fpos_t _offset;
}
else
{
static assert( false );
}
}
alias shared(_iobuf) FILE;
enum
{
_F_RDWR = 0x0003, // non-standard
_F_READ = 0x0001, // non-standard
_F_WRIT = 0x0002, // non-standard
_F_BUF = 0x0004, // non-standard
_F_LBUF = 0x0008, // non-standard
_F_ERR = 0x0010, // non-standard
_F_EOF = 0x0020, // non-standard
_F_BIN = 0x0040, // non-standard
_F_IN = 0x0080, // non-standard
_F_OUT = 0x0100, // non-standard
_F_TERM = 0x0200, // non-standard
}
version( Windows )
{
enum
{
_IOFBF = 0,
_IOLBF = 0x40,
_IONBF = 4,
_IOREAD = 1, // non-standard
_IOWRT = 2, // non-standard
_IOMYBUF = 8, // non-standard
_IOEOF = 0x10, // non-standard
_IOERR = 0x20, // non-standard
_IOSTRG = 0x40, // non-standard
_IORW = 0x80, // non-standard
_IOTRAN = 0x100, // non-standard
_IOAPP = 0x200, // non-standard
}
extern shared void function() _fcloseallp;
private extern shared FILE[_NFILE] _iob;
shared stdin = &_iob[0];
shared stdout = &_iob[1];
shared stderr = &_iob[2];
shared stdaux = &_iob[3];
shared stdprn = &_iob[4];
}
else version( linux )
{
enum
{
_IOFBF = 0,
_IOLBF = 1,
_IONBF = 2,
}
extern shared FILE* stdin;
extern shared FILE* stdout;
extern shared FILE* stderr;
}
else version( OSX )
{
enum
{
_IOFBF = 0,
_IOLBF = 1,
_IONBF = 2,
}
private extern shared FILE* __stdinp;
private extern shared FILE* __stdoutp;
private extern shared FILE* __stderrp;
alias __stdinp stdin;
alias __stdoutp stdout;
alias __stderrp stderr;
}
else version( FreeBSD )
{
private extern shared FILE[3] __sF;
shared stdin = &__sF[0];
shared stdout = &__sF[1];
shared stderr = &__sF[2];
}
else
{
static assert( false );
}
alias int fpos_t;
int remove(in char* filename);
int rename(in char* from, in char* to);
FILE* tmpfile();
char* tmpnam(char* s);
int fclose(FILE* stream);
int fflush(FILE* stream);
FILE* fopen(in char* filename, in char* mode);
FILE* freopen(in char* filename, in char* mode, FILE* stream);
void setbuf(FILE* stream, char* buf);
int setvbuf(FILE* stream, char* buf, int mode, size_t size);
int fprintf(FILE* stream, in char* format, ...);
int fscanf(FILE* stream, in char* format, ...);
int sprintf(char* s, in char* format, ...);
int sscanf(in char* s, in char* format, ...);
int vfprintf(FILE* stream, in char* format, va_list arg);
int vfscanf(FILE* stream, in char* format, va_list arg);
int vsprintf(char* s, in char* format, va_list arg);
int vsscanf(in char* s, in char* format, va_list arg);
int vprintf(in char* format, va_list arg);
int vscanf(in char* format, va_list arg);
int printf(in char* format, ...);
int scanf(in char* format, ...);
int fgetc(FILE* stream);
int fputc(int c, FILE* stream);
char* fgets(char* s, int n, FILE* stream);
int fputs(in char* s, FILE* stream);
char* gets(char* s);
int puts(in char* s);
extern (D)
{
int getchar() { return getc(stdin); }
int putchar(int c) { return putc(c,stdout); }
int getc(FILE* stream) { return fgetc(stream); }
int putc(int c, FILE* stream) { return fputc(c,stream); }
}
int ungetc(int c, FILE* stream);
size_t fread(void* ptr, size_t size, size_t nmemb, FILE* stream);
size_t fwrite(in void* ptr, size_t size, size_t nmemb, FILE* stream);
int fgetpos(FILE* stream, fpos_t * pos);
int fsetpos(FILE* stream, in fpos_t* pos);
int fseek(FILE* stream, c_long offset, int whence);
c_long ftell(FILE* stream);
version( Windows )
{
extern (D)
{
void rewind(FILE* stream) { fseek(stream,0L,SEEK_SET); stream._flag&=~_IOERR; }
void clearerr(FILE* stream) { stream._flag &= ~(_IOERR|_IOEOF); }
int feof(FILE* stream) { return stream._flag&_IOEOF; }
int ferror(FILE* stream) { return stream._flag&_IOERR; }
}
int _snprintf(char* s, size_t n, in char* fmt, ...);
alias _snprintf snprintf;
int _vsnprintf(char* s, size_t n, in char* format, va_list arg);
alias _vsnprintf vsnprintf;
}
else version( linux )
{
void rewind(FILE* stream);
void clearerr(FILE* stream);
int feof(FILE* stream);
int ferror(FILE* stream);
int fileno(FILE *);
int snprintf(char* s, size_t n, in char* format, ...);
int vsnprintf(char* s, size_t n, in char* format, va_list arg);
}
else version( OSX )
{
void rewind(FILE*);
void clearerr(FILE*);
int feof(FILE*);
int ferror(FILE*);
int fileno(FILE*);
int snprintf(char* s, size_t n, in char* format, ...);
int vsnprintf(char* s, size_t n, in char* format, va_list arg);
}
else version( FreeBSD )
{
void rewind(FILE*);
void clearerr(FILE*);
int feof(FILE*);
int ferror(FILE*);
int fileno(FILE*);
int snprintf(char* s, size_t n, in char* format, ...);
int vsnprintf(char* s, size_t n, in char* format, va_list arg);
}
else
{
static assert( false );
}
void perror(in char* s);

View File

@@ -0,0 +1,93 @@
/**
* D header file for C99.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: ISO/IEC 9899:1999 (E)
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.stdc.stdlib;
private import core.stdc.config;
public import core.stdc.stddef; // for size_t, wchar_t
extern (C):
struct div_t
{
int quot,
rem;
}
struct ldiv_t
{
int quot,
rem;
}
struct lldiv_t
{
long quot,
rem;
}
enum EXIT_SUCCESS = 0;
enum EXIT_FAILURE = 1;
enum RAND_MAX = 32767;
enum MB_CUR_MAX = 1;
double atof(in char* nptr);
int atoi(in char* nptr);
c_long atol(in char* nptr);
long atoll(in char* nptr);
double strtod(in char* nptr, char** endptr);
float strtof(in char* nptr, char** endptr);
real strtold(in char* nptr, char** endptr);
c_long strtol(in char* nptr, char** endptr, int base);
long strtoll(in char* nptr, char** endptr, int base);
c_ulong strtoul(in char* nptr, char** endptr, int base);
ulong strtoull(in char* nptr, char** endptr, int base);
int rand();
void srand(uint seed);
void* malloc(size_t size);
void* calloc(size_t nmemb, size_t size);
void* realloc(void* ptr, size_t size);
void free(void* ptr);
void abort();
void exit(int status);
int atexit(void function() func);
void _Exit(int status);
char* getenv(in char* name);
int system(in char* string);
void* bsearch(in void* key, in void* base, size_t nmemb, size_t size, int function(in void*, in void*) compar);
void qsort(void* base, size_t nmemb, size_t size, int function(in void*, in void*) compar);
int abs(int j);
c_long labs(c_long j);
long llabs(long j);
div_t div(int numer, int denom);
ldiv_t ldiv(c_long numer, c_long denom);
lldiv_t lldiv(long numer, long denom);
int mblen(in char* s, size_t n);
int mbtowc(wchar_t* pwc, in char* s, size_t n);
int wctomb(char*s, wchar_t wc);
size_t mbstowcs(wchar_t* pwcs, in char* s, size_t n);
size_t wcstombs(char* s, in wchar_t* pwcs, size_t n);
version( DigitalMars )
{
void* alloca(size_t size); // non-standard
}

View File

@@ -0,0 +1,42 @@
/**
* D header file for C99.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: ISO/IEC 9899:1999 (E)
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.stdc.string;
private import core.stdc.stddef; // for size_t
extern (C):
void* memchr(in void* s, int c, size_t n);
int memcmp(in void* s1, in void* s2, size_t n);
void* memcpy(void* s1, in void* s2, size_t n);
void* memmove(void* s1, in void* s2, size_t n);
void* memset(void* s, int c, size_t n);
char* strcpy(char* s1, in char* s2);
char* strncpy(char* s1, in char* s2, size_t n);
char* strcat(char* s1, in char* s2);
char* strncat(char* s1, in char* s2, size_t n);
int strcmp(in char* s1, in char* s2);
int strcoll(in char* s1, in char* s2);
int strncmp(in char* s1, in char* s2, size_t n);
size_t strxfrm(char* s1, in char* s2, size_t n);
char* strchr(in char* s, int c);
size_t strcspn(in char* s1, in char* s2);
char* strpbrk(in char* s1, in char* s2);
char* strrchr(in char* s, int c);
size_t strspn(in char* s1, in char* s2);
char* strstr(in char* s1, in char* s2);
char* strtok(char* s1, in char* s2);
char* strerror(int errnum);
size_t strlen(in char* s);

View File

@@ -0,0 +1,657 @@
/**
* D header file for C99.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: ISO/IEC 9899:1999 (E)
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.stdc.tgmath;
private import core.stdc.config;
private static import core.stdc.math;
private static import core.stdc.complex;
extern (C):
version( freebsd )
{
alias core.stdc.math.acos acos;
alias core.stdc.math.acosf acos;
alias core.stdc.math.acosl acos;
alias core.stdc.complex.cacos acos;
alias core.stdc.complex.cacosf acos;
alias core.stdc.complex.cacosl acos;
alias core.stdc.math.asin asin;
alias core.stdc.math.asinf asin;
alias core.stdc.math.asinl asin;
alias core.stdc.complex.casin asin;
alias core.stdc.complex.casinf asin;
alias core.stdc.complex.casinl asin;
alias core.stdc.math.atan atan;
alias core.stdc.math.atanf atan;
alias core.stdc.math.atanl atan;
alias core.stdc.complex.catan atan;
alias core.stdc.complex.catanf atan;
alias core.stdc.complex.catanl atan;
alias core.stdc.math.atan2 atan2;
alias core.stdc.math.atan2f atan2;
alias core.stdc.math.atan2l atan2;
alias core.stdc.math.cos cos;
alias core.stdc.math.cosf cos;
alias core.stdc.math.cosl cos;
alias core.stdc.complex.ccos cos;
alias core.stdc.complex.ccosf cos;
alias core.stdc.complex.ccosl cos;
alias core.stdc.math.sin sin;
alias core.stdc.math.sinf sin;
alias core.stdc.math.sinl sin;
alias core.stdc.complex.csin csin;
alias core.stdc.complex.csinf csin;
alias core.stdc.complex.csinl csin;
alias core.stdc.math.tan tan;
alias core.stdc.math.tanf tan;
alias core.stdc.math.tanl tan;
alias core.stdc.complex.ctan tan;
alias core.stdc.complex.ctanf tan;
alias core.stdc.complex.ctanl tan;
alias core.stdc.math.acosh acosh;
alias core.stdc.math.acoshf acosh;
alias core.stdc.math.acoshl acosh;
alias core.stdc.complex.cacosh acosh;
alias core.stdc.complex.cacoshf acosh;
alias core.stdc.complex.cacoshl acosh;
alias core.stdc.math.asinh asinh;
alias core.stdc.math.asinhf asinh;
alias core.stdc.math.asinhl asinh;
alias core.stdc.complex.casinh asinh;
alias core.stdc.complex.casinhf asinh;
alias core.stdc.complex.casinhl asinh;
alias core.stdc.math.atanh atanh;
alias core.stdc.math.atanhf atanh;
alias core.stdc.math.atanhl atanh;
alias core.stdc.complex.catanh atanh;
alias core.stdc.complex.catanhf atanh;
alias core.stdc.complex.catanhl atanh;
alias core.stdc.math.cosh cosh;
alias core.stdc.math.coshf cosh;
alias core.stdc.math.coshl cosh;
alias core.stdc.complex.ccosh cosh;
alias core.stdc.complex.ccoshf cosh;
alias core.stdc.complex.ccoshl cosh;
alias core.stdc.math.sinh sinh;
alias core.stdc.math.sinhf sinh;
alias core.stdc.math.sinhl sinh;
alias core.stdc.complex.csinh sinh;
alias core.stdc.complex.csinhf sinh;
alias core.stdc.complex.csinhl sinh;
alias core.stdc.math.tanh tanh;
alias core.stdc.math.tanhf tanh;
alias core.stdc.math.tanhl tanh;
alias core.stdc.complex.ctanh tanh;
alias core.stdc.complex.ctanhf tanh;
alias core.stdc.complex.ctanhl tanh;
alias core.stdc.math.exp exp;
alias core.stdc.math.expf exp;
alias core.stdc.math.expl exp;
alias core.stdc.complex.cexp exp;
alias core.stdc.complex.cexpf exp;
alias core.stdc.complex.cexpl exp;
alias core.stdc.math.exp2 exp2;
alias core.stdc.math.exp2f exp2;
alias core.stdc.math.exp2l exp2;
alias core.stdc.math.expm1 expm1;
alias core.stdc.math.expm1f expm1;
alias core.stdc.math.expm1l expm1;
alias core.stdc.math.frexp frexp;
alias core.stdc.math.frexpf frexp;
alias core.stdc.math.frexpl frexp;
alias core.stdc.math.ilogb ilogb;
alias core.stdc.math.ilogbf ilogb;
alias core.stdc.math.ilogbl ilogb;
alias core.stdc.math.ldexp ldexp;
alias core.stdc.math.ldexpf ldexp;
alias core.stdc.math.ldexpl ldexp;
alias core.stdc.math.log log;
alias core.stdc.math.logf log;
alias core.stdc.math.logl log;
alias core.stdc.complex.clog log;
alias core.stdc.complex.clogf log;
alias core.stdc.complex.clogl log;
alias core.stdc.math.log10 log10;
alias core.stdc.math.log10f log10;
alias core.stdc.math.log10l log10;
alias core.stdc.math.log1p log1p;
alias core.stdc.math.log1pf log1p;
alias core.stdc.math.log1pl log1p;
alias core.stdc.math.log2 log1p;
alias core.stdc.math.log2f log1p;
alias core.stdc.math.log2l log1p;
alias core.stdc.math.logb log1p;
alias core.stdc.math.logbf log1p;
alias core.stdc.math.logbl log1p;
alias core.stdc.math.modf modf;
alias core.stdc.math.modff modf;
// alias core.stdc.math.modfl modf;
alias core.stdc.math.scalbn scalbn;
alias core.stdc.math.scalbnf scalbn;
alias core.stdc.math.scalbnl scalbn;
alias core.stdc.math.scalbln scalbln;
alias core.stdc.math.scalblnf scalbln;
alias core.stdc.math.scalblnl scalbln;
alias core.stdc.math.cbrt cbrt;
alias core.stdc.math.cbrtf cbrt;
alias core.stdc.math.cbrtl cbrt;
alias core.stdc.math.fabs fabs;
alias core.stdc.math.fabsf fabs;
alias core.stdc.math.fabsl fabs;
alias core.stdc.complex.cabs fabs;
alias core.stdc.complex.cabsf fabs;
alias core.stdc.complex.cabsl fabs;
alias core.stdc.math.hypot hypot;
alias core.stdc.math.hypotf hypot;
alias core.stdc.math.hypotl hypot;
alias core.stdc.math.pow pow;
alias core.stdc.math.powf pow;
alias core.stdc.math.powl pow;
alias core.stdc.complex.cpow pow;
alias core.stdc.complex.cpowf pow;
alias core.stdc.complex.cpowl pow;
alias core.stdc.math.sqrt sqrt;
alias core.stdc.math.sqrtf sqrt;
alias core.stdc.math.sqrtl sqrt;
alias core.stdc.complex.csqrt sqrt;
alias core.stdc.complex.csqrtf sqrt;
alias core.stdc.complex.csqrtl sqrt;
alias core.stdc.math.erf erf;
alias core.stdc.math.erff erf;
alias core.stdc.math.erfl erf;
alias core.stdc.math.erfc erfc;
alias core.stdc.math.erfcf erfc;
alias core.stdc.math.erfcl erfc;
alias core.stdc.math.lgamma lgamma;
alias core.stdc.math.lgammaf lgamma;
alias core.stdc.math.lgammal lgamma;
alias core.stdc.math.tgamma tgamma;
alias core.stdc.math.tgammaf tgamma;
alias core.stdc.math.tgammal tgamma;
alias core.stdc.math.ceil ceil;
alias core.stdc.math.ceilf ceil;
alias core.stdc.math.ceill ceil;
alias core.stdc.math.floor floor;
alias core.stdc.math.floorf floor;
alias core.stdc.math.floorl floor;
alias core.stdc.math.nearbyint nearbyint;
alias core.stdc.math.nearbyintf nearbyint;
alias core.stdc.math.nearbyintl nearbyint;
alias core.stdc.math.rint rint;
alias core.stdc.math.rintf rint;
alias core.stdc.math.rintl rint;
alias core.stdc.math.lrint lrint;
alias core.stdc.math.lrintf lrint;
alias core.stdc.math.lrintl lrint;
alias core.stdc.math.llrint llrint;
alias core.stdc.math.llrintf llrint;
alias core.stdc.math.llrintl llrint;
alias core.stdc.math.round round;
alias core.stdc.math.roundf round;
alias core.stdc.math.roundl round;
alias core.stdc.math.lround lround;
alias core.stdc.math.lroundf lround;
alias core.stdc.math.lroundl lround;
alias core.stdc.math.llround llround;
alias core.stdc.math.llroundf llround;
alias core.stdc.math.llroundl llround;
alias core.stdc.math.trunc trunc;
alias core.stdc.math.truncf trunc;
alias core.stdc.math.truncl trunc;
alias core.stdc.math.fmod fmod;
alias core.stdc.math.fmodf fmod;
alias core.stdc.math.fmodl fmod;
alias core.stdc.math.remainder remainder;
alias core.stdc.math.remainderf remainder;
alias core.stdc.math.remainderl remainder;
alias core.stdc.math.remquo remquo;
alias core.stdc.math.remquof remquo;
alias core.stdc.math.remquol remquo;
alias core.stdc.math.copysign copysign;
alias core.stdc.math.copysignf copysign;
alias core.stdc.math.copysignl copysign;
// alias core.stdc.math.nan nan;
// alias core.stdc.math.nanf nan;
// alias core.stdc.math.nanl nan;
alias core.stdc.math.nextafter nextafter;
alias core.stdc.math.nextafterf nextafter;
alias core.stdc.math.nextafterl nextafter;
alias core.stdc.math.nexttoward nexttoward;
alias core.stdc.math.nexttowardf nexttoward;
alias core.stdc.math.nexttowardl nexttoward;
alias core.stdc.math.fdim fdim;
alias core.stdc.math.fdimf fdim;
alias core.stdc.math.fdiml fdim;
alias core.stdc.math.fmax fmax;
alias core.stdc.math.fmaxf fmax;
alias core.stdc.math.fmaxl fmax;
alias core.stdc.math.fmin fmin;
alias core.stdc.math.fmin fmin;
alias core.stdc.math.fminl fmin;
alias core.stdc.math.fma fma;
alias core.stdc.math.fmaf fma;
alias core.stdc.math.fmal fma;
alias core.stdc.complex.carg carg;
alias core.stdc.complex.cargf carg;
alias core.stdc.complex.cargl carg;
alias core.stdc.complex.cimag cimag;
alias core.stdc.complex.cimagf cimag;
alias core.stdc.complex.cimagl cimag;
alias core.stdc.complex.conj conj;
alias core.stdc.complex.conjf conj;
alias core.stdc.complex.conjl conj;
alias core.stdc.complex.cproj cproj;
alias core.stdc.complex.cprojf cproj;
alias core.stdc.complex.cprojl cproj;
// alias core.stdc.complex.creal creal;
// alias core.stdc.complex.crealf creal;
// alias core.stdc.complex.creall creal;
}
else
{
alias core.stdc.math.acos acos;
alias core.stdc.math.acosf acos;
alias core.stdc.math.acosl acos;
alias core.stdc.complex.cacos acos;
alias core.stdc.complex.cacosf acos;
alias core.stdc.complex.cacosl acos;
alias core.stdc.math.asin asin;
alias core.stdc.math.asinf asin;
alias core.stdc.math.asinl asin;
alias core.stdc.complex.casin asin;
alias core.stdc.complex.casinf asin;
alias core.stdc.complex.casinl asin;
alias core.stdc.math.atan atan;
alias core.stdc.math.atanf atan;
alias core.stdc.math.atanl atan;
alias core.stdc.complex.catan atan;
alias core.stdc.complex.catanf atan;
alias core.stdc.complex.catanl atan;
alias core.stdc.math.atan2 atan2;
alias core.stdc.math.atan2f atan2;
alias core.stdc.math.atan2l atan2;
alias core.stdc.math.cos cos;
alias core.stdc.math.cosf cos;
alias core.stdc.math.cosl cos;
alias core.stdc.complex.ccos cos;
alias core.stdc.complex.ccosf cos;
alias core.stdc.complex.ccosl cos;
alias core.stdc.math.sin sin;
alias core.stdc.math.sinf sin;
alias core.stdc.math.sinl sin;
alias core.stdc.complex.csin csin;
alias core.stdc.complex.csinf csin;
alias core.stdc.complex.csinl csin;
alias core.stdc.math.tan tan;
alias core.stdc.math.tanf tan;
alias core.stdc.math.tanl tan;
alias core.stdc.complex.ctan tan;
alias core.stdc.complex.ctanf tan;
alias core.stdc.complex.ctanl tan;
alias core.stdc.math.acosh acosh;
alias core.stdc.math.acoshf acosh;
alias core.stdc.math.acoshl acosh;
alias core.stdc.complex.cacosh acosh;
alias core.stdc.complex.cacoshf acosh;
alias core.stdc.complex.cacoshl acosh;
alias core.stdc.math.asinh asinh;
alias core.stdc.math.asinhf asinh;
alias core.stdc.math.asinhl asinh;
alias core.stdc.complex.casinh asinh;
alias core.stdc.complex.casinhf asinh;
alias core.stdc.complex.casinhl asinh;
alias core.stdc.math.atanh atanh;
alias core.stdc.math.atanhf atanh;
alias core.stdc.math.atanhl atanh;
alias core.stdc.complex.catanh atanh;
alias core.stdc.complex.catanhf atanh;
alias core.stdc.complex.catanhl atanh;
alias core.stdc.math.cosh cosh;
alias core.stdc.math.coshf cosh;
alias core.stdc.math.coshl cosh;
alias core.stdc.complex.ccosh cosh;
alias core.stdc.complex.ccoshf cosh;
alias core.stdc.complex.ccoshl cosh;
alias core.stdc.math.sinh sinh;
alias core.stdc.math.sinhf sinh;
alias core.stdc.math.sinhl sinh;
alias core.stdc.complex.csinh sinh;
alias core.stdc.complex.csinhf sinh;
alias core.stdc.complex.csinhl sinh;
alias core.stdc.math.tanh tanh;
alias core.stdc.math.tanhf tanh;
alias core.stdc.math.tanhl tanh;
alias core.stdc.complex.ctanh tanh;
alias core.stdc.complex.ctanhf tanh;
alias core.stdc.complex.ctanhl tanh;
alias core.stdc.math.exp exp;
alias core.stdc.math.expf exp;
alias core.stdc.math.expl exp;
alias core.stdc.complex.cexp exp;
alias core.stdc.complex.cexpf exp;
alias core.stdc.complex.cexpl exp;
alias core.stdc.math.exp2 exp2;
alias core.stdc.math.exp2f exp2;
alias core.stdc.math.exp2l exp2;
alias core.stdc.math.expm1 expm1;
alias core.stdc.math.expm1f expm1;
alias core.stdc.math.expm1l expm1;
alias core.stdc.math.frexp frexp;
alias core.stdc.math.frexpf frexp;
alias core.stdc.math.frexpl frexp;
alias core.stdc.math.ilogb ilogb;
alias core.stdc.math.ilogbf ilogb;
alias core.stdc.math.ilogbl ilogb;
alias core.stdc.math.ldexp ldexp;
alias core.stdc.math.ldexpf ldexp;
alias core.stdc.math.ldexpl ldexp;
alias core.stdc.math.log log;
alias core.stdc.math.logf log;
alias core.stdc.math.logl log;
alias core.stdc.complex.clog log;
alias core.stdc.complex.clogf log;
alias core.stdc.complex.clogl log;
alias core.stdc.math.log10 log10;
alias core.stdc.math.log10f log10;
alias core.stdc.math.log10l log10;
alias core.stdc.math.log1p log1p;
alias core.stdc.math.log1pf log1p;
alias core.stdc.math.log1pl log1p;
alias core.stdc.math.log2 log1p;
alias core.stdc.math.log2f log1p;
alias core.stdc.math.log2l log1p;
alias core.stdc.math.logb log1p;
alias core.stdc.math.logbf log1p;
alias core.stdc.math.logbl log1p;
alias core.stdc.math.modf modf;
alias core.stdc.math.modff modf;
alias core.stdc.math.modfl modf;
alias core.stdc.math.scalbn scalbn;
alias core.stdc.math.scalbnf scalbn;
alias core.stdc.math.scalbnl scalbn;
alias core.stdc.math.scalbln scalbln;
alias core.stdc.math.scalblnf scalbln;
alias core.stdc.math.scalblnl scalbln;
alias core.stdc.math.cbrt cbrt;
alias core.stdc.math.cbrtf cbrt;
alias core.stdc.math.cbrtl cbrt;
alias core.stdc.math.fabs fabs;
alias core.stdc.math.fabsf fabs;
alias core.stdc.math.fabsl fabs;
alias core.stdc.complex.cabs fabs;
alias core.stdc.complex.cabsf fabs;
alias core.stdc.complex.cabsl fabs;
alias core.stdc.math.hypot hypot;
alias core.stdc.math.hypotf hypot;
alias core.stdc.math.hypotl hypot;
alias core.stdc.math.pow pow;
alias core.stdc.math.powf pow;
alias core.stdc.math.powl pow;
alias core.stdc.complex.cpow pow;
alias core.stdc.complex.cpowf pow;
alias core.stdc.complex.cpowl pow;
alias core.stdc.math.sqrt sqrt;
alias core.stdc.math.sqrtf sqrt;
alias core.stdc.math.sqrtl sqrt;
alias core.stdc.complex.csqrt sqrt;
alias core.stdc.complex.csqrtf sqrt;
alias core.stdc.complex.csqrtl sqrt;
alias core.stdc.math.erf erf;
alias core.stdc.math.erff erf;
alias core.stdc.math.erfl erf;
alias core.stdc.math.erfc erfc;
alias core.stdc.math.erfcf erfc;
alias core.stdc.math.erfcl erfc;
alias core.stdc.math.lgamma lgamma;
alias core.stdc.math.lgammaf lgamma;
alias core.stdc.math.lgammal lgamma;
alias core.stdc.math.tgamma tgamma;
alias core.stdc.math.tgammaf tgamma;
alias core.stdc.math.tgammal tgamma;
alias core.stdc.math.ceil ceil;
alias core.stdc.math.ceilf ceil;
alias core.stdc.math.ceill ceil;
alias core.stdc.math.floor floor;
alias core.stdc.math.floorf floor;
alias core.stdc.math.floorl floor;
alias core.stdc.math.nearbyint nearbyint;
alias core.stdc.math.nearbyintf nearbyint;
alias core.stdc.math.nearbyintl nearbyint;
alias core.stdc.math.rint rint;
alias core.stdc.math.rintf rint;
alias core.stdc.math.rintl rint;
alias core.stdc.math.lrint lrint;
alias core.stdc.math.lrintf lrint;
alias core.stdc.math.lrintl lrint;
alias core.stdc.math.llrint llrint;
alias core.stdc.math.llrintf llrint;
alias core.stdc.math.llrintl llrint;
alias core.stdc.math.round round;
alias core.stdc.math.roundf round;
alias core.stdc.math.roundl round;
alias core.stdc.math.lround lround;
alias core.stdc.math.lroundf lround;
alias core.stdc.math.lroundl lround;
alias core.stdc.math.llround llround;
alias core.stdc.math.llroundf llround;
alias core.stdc.math.llroundl llround;
alias core.stdc.math.trunc trunc;
alias core.stdc.math.truncf trunc;
alias core.stdc.math.truncl trunc;
alias core.stdc.math.fmod fmod;
alias core.stdc.math.fmodf fmod;
alias core.stdc.math.fmodl fmod;
alias core.stdc.math.remainder remainder;
alias core.stdc.math.remainderf remainder;
alias core.stdc.math.remainderl remainder;
alias core.stdc.math.remquo remquo;
alias core.stdc.math.remquof remquo;
alias core.stdc.math.remquol remquo;
alias core.stdc.math.copysign copysign;
alias core.stdc.math.copysignf copysign;
alias core.stdc.math.copysignl copysign;
alias core.stdc.math.nan nan;
alias core.stdc.math.nanf nan;
alias core.stdc.math.nanl nan;
alias core.stdc.math.nextafter nextafter;
alias core.stdc.math.nextafterf nextafter;
alias core.stdc.math.nextafterl nextafter;
alias core.stdc.math.nexttoward nexttoward;
alias core.stdc.math.nexttowardf nexttoward;
alias core.stdc.math.nexttowardl nexttoward;
alias core.stdc.math.fdim fdim;
alias core.stdc.math.fdimf fdim;
alias core.stdc.math.fdiml fdim;
alias core.stdc.math.fmax fmax;
alias core.stdc.math.fmaxf fmax;
alias core.stdc.math.fmaxl fmax;
alias core.stdc.math.fmin fmin;
alias core.stdc.math.fmin fmin;
alias core.stdc.math.fminl fmin;
alias core.stdc.math.fma fma;
alias core.stdc.math.fmaf fma;
alias core.stdc.math.fmal fma;
alias core.stdc.complex.carg carg;
alias core.stdc.complex.cargf carg;
alias core.stdc.complex.cargl carg;
alias core.stdc.complex.cimag cimag;
alias core.stdc.complex.cimagf cimag;
alias core.stdc.complex.cimagl cimag;
alias core.stdc.complex.conj conj;
alias core.stdc.complex.conjf conj;
alias core.stdc.complex.conjl conj;
alias core.stdc.complex.cproj cproj;
alias core.stdc.complex.cprojf cproj;
alias core.stdc.complex.cprojl cproj;
// alias core.stdc.complex.creal creal;
// alias core.stdc.complex.crealf creal;
// alias core.stdc.complex.creall creal;
}

View File

@@ -0,0 +1,98 @@
/**
* D header file for C99.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: ISO/IEC 9899:1999 (E)
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.stdc.time;
private import core.stdc.config;
private import core.stdc.stddef; // for size_t
extern (C):
version( Windows )
{
struct tm
{
int tm_sec; // seconds after the minute - [0, 60]
int tm_min; // minutes after the hour - [0, 59]
int tm_hour; // hours since midnight - [0, 23]
int tm_mday; // day of the month - [1, 31]
int tm_mon; // months since January - [0, 11]
int tm_year; // years since 1900
int tm_wday; // days since Sunday - [0, 6]
int tm_yday; // days since January 1 - [0, 365]
int tm_isdst; // Daylight Saving Time flag
}
}
else
{
struct tm
{
int tm_sec; // seconds after the minute [0-60]
int tm_min; // minutes after the hour [0-59]
int tm_hour; // hours since midnight [0-23]
int tm_mday; // day of the month [1-31]
int tm_mon; // months since January [0-11]
int tm_year; // years since 1900
int tm_wday; // days since Sunday [0-6]
int tm_yday; // days since January 1 [0-365]
int tm_isdst; // Daylight Savings Time flag
c_long tm_gmtoff; // offset from CUT in seconds
char* tm_zone; // timezone abbreviation
}
}
alias c_long time_t;
alias c_long clock_t;
version( Windows )
{
clock_t CLOCKS_PER_SEC = 1000;
}
else version( OSX )
{
clock_t CLOCKS_PER_SEC = 100;
}
else version( freebsd )
{
clock_t CLOCKS_PER_SEC = 128;
}
else
{
clock_t CLOCKS_PER_SEC = 1000000;
}
clock_t clock();
double difftime(time_t time1, time_t time0);
time_t mktime(tm* timeptr);
time_t time(time_t* timer);
char* asctime(in tm* timeptr);
char* ctime(in time_t* timer);
tm* gmtime(in time_t* timer);
tm* localtime(in time_t* timer);
size_t strftime(char* s, size_t maxsize, in char* format, in tm* timeptr);
version( Windows )
{
void tzset(); // non-standard
void _tzset(); // non-standard
char* _strdate(char* s); // non-standard
char* _strtime(char* s); // non-standard
}
else version( linux )
{
void tzset(); // non-standard
}
else version( freebsd )
{
void tzset(); // non-standard
}

View File

@@ -0,0 +1,108 @@
/**
* D header file for C99.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: ISO/IEC 9899:1999 (E)
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.stdc.wchar_;
private import core.stdc.config;
private import core.stdc.stdarg; // for va_list
private import core.stdc.stdio; // for FILE, not exposed per spec
public import core.stdc.stddef; // for size_t, wchar_t
public import core.stdc.time; // for tm
public import core.stdc.stdint; // for WCHAR_MIN, WCHAR_MAX
extern (C):
alias int mbstate_t;
alias wchar_t wint_t;
enum wchar_t WEOF = 0xFFFF;
int fwprintf(FILE* stream, in wchar_t* format, ...);
int fwscanf(FILE* stream, in wchar_t* format, ...);
int swprintf(wchar_t* s, size_t n, in wchar_t* format, ...);
int swscanf(in wchar_t* s, in wchar_t* format, ...);
int vfwprintf(FILE* stream, in wchar_t* format, va_list arg);
int vfwscanf(FILE* stream, in wchar_t* format, va_list arg);
int vswprintf(wchar_t* s, size_t n, in wchar_t* format, va_list arg);
int vswscanf(in wchar_t* s, in wchar_t* format, va_list arg);
int vwprintf(in wchar_t* format, va_list arg);
int vwscanf(in wchar_t* format, va_list arg);
int wprintf(in wchar_t* format, ...);
int wscanf(in wchar_t* format, ...);
wint_t fgetwc(FILE* stream);
wint_t fputwc(wchar_t c, FILE* stream);
wchar_t* fgetws(wchar_t* s, int n, FILE* stream);
int fputws(in wchar_t* s, FILE* stream);
extern (D)
{
wint_t getwchar() { return fgetwc(stdin); }
wint_t putwchar(wchar_t c) { return fputwc(c,stdout); }
wint_t getwc(FILE* stream) { return fgetwc(stream); }
wint_t putwc(wchar_t c, FILE* stream) { return fputwc(c, stream); }
}
wint_t ungetwc(wint_t c, FILE* stream);
int fwide(FILE* stream, int mode);
double wcstod(in wchar_t* nptr, wchar_t** endptr);
float wcstof(in wchar_t* nptr, wchar_t** endptr);
real wcstold(in wchar_t* nptr, wchar_t** endptr);
c_long wcstol(in wchar_t* nptr, wchar_t** endptr, int base);
long wcstoll(in wchar_t* nptr, wchar_t** endptr, int base);
c_ulong wcstoul(in wchar_t* nptr, wchar_t** endptr, int base);
ulong wcstoull(in wchar_t* nptr, wchar_t** endptr, int base);
wchar_t* wcscpy(wchar_t* s1, in wchar_t* s2);
wchar_t* wcsncpy(wchar_t* s1, in wchar_t* s2, size_t n);
wchar_t* wcscat(wchar_t* s1, in wchar_t* s2);
wchar_t* wcsncat(wchar_t* s1, in wchar_t* s2, size_t n);
int wcscmp(in wchar_t* s1, in wchar_t* s2);
int wcscoll(in wchar_t* s1, in wchar_t* s2);
int wcsncmp(in wchar_t* s1, in wchar_t* s2, size_t n);
size_t wcsxfrm(wchar_t* s1, in wchar_t* s2, size_t n);
wchar_t* wcschr(in wchar_t* s, wchar_t c);
size_t wcscspn(in wchar_t* s1, in wchar_t* s2);
wchar_t* wcspbrk(in wchar_t* s1, in wchar_t* s2);
wchar_t* wcsrchr(in wchar_t* s, wchar_t c);
size_t wcsspn(in wchar_t* s1, in wchar_t* s2);
wchar_t* wcsstr(in wchar_t* s1, in wchar_t* s2);
wchar_t* wcstok(wchar_t* s1, in wchar_t* s2, wchar_t** ptr);
size_t wcslen(wchar_t* s);
wchar_t* wmemchr(in wchar_t* s, wchar_t c, size_t n);
int wmemcmp(in wchar_t* s1, in wchar_t* s2, size_t n);
wchar_t* wmemcpy(wchar_t* s1, in wchar_t* s2, size_t n);
wchar_t* wmemmove(wchar_t*s1, in wchar_t* s2, size_t n);
wchar_t* wmemset(wchar_t* s, wchar_t c, size_t n);
size_t wcsftime(wchar_t* s, size_t maxsize, in wchar_t* format, in tm* timeptr);
version( Windows )
{
wchar_t* _wasctime(tm*); // non-standard
wchar_t* _wctime(time_t*); // non-standard
wchar_t* _wstrdate(wchar_t*); // non-standard
wchar_t* _wstrtime(wchar_t*); // non-standard
}
wint_t btowc(int c);
int wctob(wint_t c);
int mbsinit(in mbstate_t* ps);
size_t mbrlen(in char* s, size_t n, mbstate_t* ps);
size_t mbrtowc(wchar_t* pwc, in char* s, size_t n, mbstate_t* ps);
size_t wcrtomb(char* s, wchar_t wc, mbstate_t* ps);
size_t mbsrtowcs(wchar_t* dst, in char** src, size_t len, mbstate_t* ps);
size_t wcsrtombs(char* dst, in wchar_t** src, size_t len, mbstate_t* ps);

View File

@@ -0,0 +1,41 @@
/**
* D header file for C99.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: ISO/IEC 9899:1999 (E)
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.stdc.wctype;
public import core.stdc.wchar_; // for wint_t, WEOF
extern (C):
alias wchar_t wctrans_t;
alias wchar_t wctype_t;
int iswalnum(wint_t wc);
int iswalpha(wint_t wc);
int iswblank(wint_t wc);
int iswcntrl(wint_t wc);
int iswdigit(wint_t wc);
int iswgraph(wint_t wc);
int iswlower(wint_t wc);
int iswprint(wint_t wc);
int iswpunct(wint_t wc);
int iswspace(wint_t wc);
int iswupper(wint_t wc);
int iswxdigit(wint_t wc);
int iswctype(wint_t wc, wctype_t desc);
wctype_t wctype(in char* property);
wint_t towlower(wint_t wc);
wint_t towupper(wint_t wc);
wint_t towctrans(wint_t wc, wctrans_t desc);
wctrans_t wctrans(in char* property);

View File

@@ -0,0 +1,71 @@
/**
* D header file for OSX.
*
* Copyright: Copyright Sean Kelly 2008 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
*
* Copyright Sean Kelly 2008 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.osx.mach.kern_return;
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,
}

View File

@@ -0,0 +1,25 @@
/**
* D header file for OSX.
*
* Copyright: Copyright Sean Kelly 2008 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
*
* Copyright Sean Kelly 2008 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.osx.mach.port;
extern (C):
version( X86 )
version = i386;
version( X86_64 )
version = i386;
version( i386 )
{
alias uint natural_t;
alias natural_t mach_port_t;
}

View File

@@ -0,0 +1,54 @@
/**
* D header file for OSX.
*
* Copyright: Copyright Sean Kelly 2008 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
*
* Copyright Sean Kelly 2008 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.osx.mach.semaphore;
public import core.sys.osx.mach.kern_return;
public import core.sys.osx.mach.port;
extern (C):
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);

View File

@@ -0,0 +1,124 @@
/**
* D header file for OSX.
*
* Copyright: Copyright Sean Kelly 2008 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
*
* Copyright Sean Kelly 2008 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.osx.mach.thread_act;
public import core.sys.osx.mach.kern_return;
public import core.sys.osx.mach.port;
extern (C):
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*);
}

View File

@@ -0,0 +1,132 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.arpa.inet;
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
extern (C):
//
// Required
//
/*
in_port_t // from core.sys.posix.netinet.in_
in_addr_t // from core.sys.posix.netinet.in_
struct in_addr // from core.sys.posix.netinet.in_
INET_ADDRSTRLEN // from core.sys.posix.netinet.in_
uint32_t // from core.stdc.inttypes
uint16_t // from core.stdc.inttypes
uint32_t htonl(uint32_t);
uint16_t htons(uint16_t);
uint32_t ntohl(uint32_t);
uint16_t ntohs(uint16_t);
in_addr_t inet_addr(in char*);
char* inet_ntoa(in_addr);
// per spec: const char* inet_ntop(int, const void*, char*, socklen_t);
char* inet_ntop(int, in void*, char*, socklen_t);
int inet_pton(int, in char*, void*);
*/
version( linux )
{
alias uint16_t in_port_t;
alias uint32_t in_addr_t;
struct in_addr
{
in_addr_t s_addr;
}
enum INET_ADDRSTRLEN = 16;
uint32_t htonl(uint32_t);
uint16_t htons(uint16_t);
uint32_t ntohl(uint32_t);
uint16_t ntohs(uint16_t);
in_addr_t inet_addr(in char*);
char* inet_ntoa(in_addr);
char* inet_ntop(int, in void*, char*, socklen_t);
int inet_pton(int, in char*, void*);
}
else version( OSX )
{
alias uint16_t in_port_t; // TODO: verify
alias uint32_t in_addr_t; // TODO: verify
struct in_addr
{
in_addr_t s_addr;
}
enum INET_ADDRSTRLEN = 16;
uint32_t htonl(uint32_t);
uint16_t htons(uint16_t);
uint32_t ntohl(uint32_t);
uint16_t ntohs(uint16_t);
in_addr_t inet_addr(in char*);
char* inet_ntoa(in_addr);
char* inet_ntop(int, in void*, char*, socklen_t);
int inet_pton(int, in char*, void*);
}
else version( freebsd )
{
alias uint16_t in_port_t; // TODO: verify
alias uint32_t in_addr_t; // TODO: verify
struct in_addr
{
in_addr_t s_addr;
}
enum INET_ADDRSTRLEN = 16;
uint32_t htonl(uint32_t);
uint16_t htons(uint16_t);
uint32_t ntohl(uint32_t);
uint16_t ntohs(uint16_t);
in_addr_t inet_addr(in char*);
char* inet_ntoa(in_addr);
char* inet_ntop(int, in void*, char*, socklen_t);
int inet_pton(int, in char*, void*);
}
//
// IPV6 (IP6)
//
/*
INET6_ADDRSTRLEN // from core.sys.posix.netinet.in_
*/
version( linux )
{
enum INET6_ADDRSTRLEN = 46;
}
else version( OSX )
{
enum INET6_ADDRSTRLEN = 46;
}
else version( freebsd )
{
enum INET6_ADDRSTRLEN = 46;
}

View File

@@ -0,0 +1,32 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.config;
public import core.stdc.config;
extern (C):
version( linux )
{
version( X86_64 )
{
enum bool __USE_LARGEFILE64 = true;
}
else
{
enum bool __USE_LARGEFILE64 = false;
}
enum bool __USE_FILE_OFFSET64 = __USE_LARGEFILE64;
enum bool __REDIRECT = false;
}

View File

@@ -0,0 +1,203 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.dirent;
private import core.sys.posix.config;
public import core.sys.posix.sys.types; // for ino_t
extern (C):
//
// Required
//
/*
DIR
struct dirent
{
char[] d_name;
}
int closedir(DIR*);
DIR* opendir(in char*);
dirent* readdir(DIR*);
void rewinddir(DIR*);
*/
version( linux )
{
// NOTE: The following constants are non-standard Linux definitions
// for dirent.d_type.
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,
DT_WHT = 14
}
struct dirent
{
ino_t d_ino;
off_t d_off;
ushort d_reclen;
ubyte d_type;
char[256] d_name;
}
struct DIR
{
// Managed by OS
}
static if( __USE_LARGEFILE64 )
{
dirent* readdir64(DIR*);
alias readdir64 readdir;
}
else
{
dirent* readdir(DIR*);
}
}
else version( OSX )
{
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,
DT_WHT = 14
}
align(4)
struct dirent
{
ino_t d_ino;
ushort d_reclen;
ubyte d_type;
ubyte d_namlen;
char[256] d_name;
}
struct DIR
{
// Managed by OS
}
dirent* readdir(DIR*);
}
else version( freebsd )
{
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,
DT_WHT = 14
}
align(4)
struct dirent
{
uint d_fileno;
ushort d_reclen;
ubyte d_type;
ubyte d_namelen;
char[256] d_name;
}
struct _telldir;
struct DIR
{
int dd_fd;
c_long dd_loc;
c_long dd_size;
char* dd_buf;
int dd_len;
c_long dd_seek;
c_long dd_rewind;
int dd_flags;
void* dd_lock;
_telldir* dd_td;
}
dirent* readdir(DIR*);
}
else
{
dirent* readdir(DIR*);
}
int closedir(DIR*);
DIR* opendir(in char*);
//dirent* readdir(DIR*);
void rewinddir(DIR*);
//
// Thread-Safe Functions (TSF)
//
/*
int readdir_r(DIR*, dirent*, dirent**);
*/
version( linux )
{
static if( __USE_LARGEFILE64 )
{
int readdir64_r(DIR*, dirent*, dirent**);
alias readdir64_r readdir_r;
}
else
{
int readdir_r(DIR*, dirent*, dirent**);
}
}
else version( OSX )
{
int readdir_r(DIR*, dirent*, dirent**);
}
else version( freebsd )
{
int readdir_r(DIR*, dirent*, dirent**);
}
//
// XOpen (XSI)
//
/*
void seekdir(DIR*, c_long);
c_long telldir(DIR*);
*/
version( linux )
{
void seekdir(DIR*, c_long);
c_long telldir(DIR*);
}

View File

@@ -0,0 +1,70 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.dlfcn;
private import core.sys.posix.config;
extern (C):
//
// XOpen (XSI)
//
/*
RTLD_LAZY
RTLD_NOW
RTLD_GLOBAL
RTLD_LOCAL
int dlclose(void*);
char* dlerror();
void* dlopen(in char*, int);
void* dlsym(void*, in char*);
*/
version( linux )
{
enum RTLD_LAZY = 0x00001;
enum RTLD_NOW = 0x00002;
enum RTLD_GLOBAL = 0x00100;
enum RTLD_LOCAL = 0x00000;
int dlclose(void*);
char* dlerror();
void* dlopen(in char*, int);
void* dlsym(void*, in char*);
}
else version( OSX )
{
enum RTLD_LAZY = 0x00001;
enum RTLD_NOW = 0x00002;
enum RTLD_GLOBAL = 0x00100;
enum RTLD_LOCAL = 0x00000;
int dlclose(void*);
char* dlerror();
void* dlopen(in char*, int);
void* dlsym(void*, in char*);
}
else version( freebsd )
{
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*);
}

View File

@@ -0,0 +1,253 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.fcntl;
private import core.sys.posix.config;
private import core.stdc.stdint;
public import core.stdc.stddef; // for size_t
public import core.sys.posix.sys.types; // for off_t, mode_t
public import core.sys.posix.sys.stat; // for S_IFMT, etc.
extern (C):
//
// Required
//
/*
F_DUPFD
F_GETFD
F_SETFD
F_GETFL
F_SETFL
F_GETLK
F_SETLK
F_SETLKW
F_GETOWN
F_SETOWN
FD_CLOEXEC
F_RDLCK
F_UNLCK
F_WRLCK
O_CREAT
O_EXCL
O_NOCTTY
O_TRUNC
O_APPEND
O_DSYNC
O_NONBLOCK
O_RSYNC
O_SYNC
O_ACCMODE
O_RDONLY
O_RDWR
O_WRONLY
struct flock
{
short l_type;
short l_whence;
off_t l_start;
off_t l_len;
pid_t l_pid;
}
int creat(in char*, mode_t);
int fcntl(int, int, ...);
int open(in char*, int, ...);
*/
version( linux )
{
enum F_DUPFD = 0;
enum F_GETFD = 1;
enum F_SETFD = 2;
enum F_GETFL = 3;
enum F_SETFL = 4;
static if( __USE_FILE_OFFSET64 )
{
enum F_GETLK = 12;
enum F_SETLK = 13;
enum F_SETLKW = 14;
}
else
{
enum F_GETLK = 5;
enum F_SETLK = 6;
enum F_SETLKW = 7;
}
enum F_GETOWN = 9;
enum F_SETOWN = 8;
enum FD_CLOEXEC = 1;
enum F_RDLCK = 0;
enum F_UNLCK = 2;
enum F_WRLCK = 1;
enum O_CREAT = 0100;
enum O_EXCL = 0200;
enum O_NOCTTY = 0400;
enum O_TRUNC = 01000;
enum O_APPEND = 02000;
enum O_NONBLOCK = 04000;
enum O_SYNC = 010000;
enum O_DSYNC = O_SYNC;
enum O_RSYNC = O_SYNC;
enum O_ACCMODE = 0003;
enum O_RDONLY = 00;
enum O_WRONLY = 01;
enum O_RDWR = 02;
struct flock
{
short l_type;
short l_whence;
off_t l_start;
off_t l_len;
pid_t l_pid;
}
static if( __USE_LARGEFILE64 )
{
int creat64(in char*, mode_t);
alias creat64 creat;
int open64(in char*, int, ...);
alias open64 open;
}
else
{
int creat(in char*, mode_t);
int open(in char*, int, ...);
}
}
else version( OSX )
{
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 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 = 0;
enum O_TRUNC = 0x0400;
enum O_RDONLY = 0x0000;
enum O_WRONLY = 0x0001;
enum O_RDWR = 0x0002;
enum O_ACCMODE = 0x0003;
enum O_NONBLOCK = 0x0004;
enum O_APPEND = 0x0008;
enum O_SYNC = 0x0080;
//enum O_DSYNC
//enum O_RSYNC
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, ...);
}
else version( freebsd )
{
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 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 = 0;
enum O_TRUNC = 0x0400;
enum O_RDONLY = 0x0000;
enum O_WRONLY = 0x0001;
enum O_RDWR = 0x0002;
enum O_ACCMODE = 0x0003;
enum O_NONBLOCK = 0x0004;
enum O_APPEND = 0x0008;
enum O_SYNC = 0x0080;
//enum O_DSYNC
//enum O_RSYNC
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, ...);
}
//int creat(in char*, mode_t);
int fcntl(int, int, ...);
//int open(in char*, int, ...);
//
// Advisory Information (ADV)
//
/*
POSIX_FADV_NORMAL
POSIX_FADV_SEQUENTIAL
POSIX_FADV_RANDOM
POSIX_FADV_WILLNEED
POSIX_FADV_DONTNEED
POSIX_FADV_NOREUSE
int posix_fadvise(int, off_t, off_t, int);
int posix_fallocate(int, off_t, off_t);
*/

View File

@@ -0,0 +1,35 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.inttypes;
private import core.sys.posix.config;
public import core.stdc.inttypes;
//
// Required
//
/*
intmax_t imaxabs(intmax_t);
imaxdiv_t imaxdiv(intmax_t, intmax_t);
intmax_t strtoimax(in char*, char**, int);
uintmax_t strtoumax(in char *, char**, int);
intmax_t wcstoimax(in wchar_t*, wchar_t**, int);
uintmax_t wcstoumax(in wchar_t*, wchar_t**, int);
*/
intmax_t imaxabs(intmax_t);
imaxdiv_t imaxdiv(intmax_t, intmax_t);
intmax_t strtoimax(in char*, char**, int);
uintmax_t strtoumax(in char *, char**, int);
intmax_t wcstoimax(in wchar_t*, wchar_t**, int);
uintmax_t wcstoumax(in wchar_t*, wchar_t**, int);

View File

@@ -0,0 +1,82 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.net.if_;
private import core.sys.posix.config;
extern (C):
//
// Required
//
/*
struct if_nameindex // renamed to if_nameindex_t
{
uint if_index;
char* if_name;
}
IF_NAMESIZE
uint if_nametoindex(in char*);
char* if_indextoname(uint, char*);
if_nameindex_t* if_nameindex();
void if_freenameindex(if_nameindex_t*);
*/
version( linux )
{
struct if_nameindex_t
{
uint if_index;
char* if_name;
}
enum IF_NAMESIZE = 16;
uint if_nametoindex(in char*);
char* if_indextoname(uint, char*);
if_nameindex_t* if_nameindex();
void if_freenameindex(if_nameindex_t*);
}
else version( OSX )
{
struct if_nameindex_t
{
uint if_index;
char* if_name;
}
enum IF_NAMESIZE = 16;
uint if_nametoindex(in char*);
char* if_indextoname(uint, char*);
if_nameindex_t* if_nameindex();
void if_freenameindex(if_nameindex_t*);
}
else version( freebsd )
{
struct if_nameindex_t
{
uint if_index;
char* if_name;
}
enum IF_NAMESIZE = 16;
uint if_nametoindex(in char*);
char* if_indextoname(uint, char*);
if_nameindex_t* if_nameindex();
void if_freenameindex(if_nameindex_t*);
}

View File

@@ -0,0 +1,464 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.netinet.in_;
private import core.sys.posix.config;
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
extern (C):
//
// Required
//
/*
NOTE: The following must must be defined in core.sys.posix.arpa.inet to break
a circular import: in_port_t, in_addr_t, struct in_addr, INET_ADDRSTRLEN.
in_port_t
in_addr_t
sa_family_t // from core.sys.posix.sys.socket
uint8_t // from core.stdc.inttypes
uint32_t // from core.stdc.inttypes
struct in_addr
{
in_addr_t s_addr;
}
struct sockaddr_in
{
sa_family_t sin_family;
in_port_t sin_port;
in_addr sin_addr;
}
IPPROTO_IP
IPPROTO_ICMP
IPPROTO_TCP
IPPROTO_UDP
INADDR_ANY
INADDR_BROADCAST
INET_ADDRSTRLEN
htonl() // from core.sys.posix.arpa.inet
htons() // from core.sys.posix.arpa.inet
ntohl() // from core.sys.posix.arpa.inet
ntohs() // from core.sys.posix.arpa.inet
*/
version( linux )
{
private enum __SOCK_SIZE__ = 16;
struct sockaddr_in
{
sa_family_t sin_family;
in_port_t sin_port;
in_addr sin_addr;
/* Pad to size of `struct sockaddr'. */
ubyte[__SOCK_SIZE__ - sa_family_t.sizeof -
in_port_t.sizeof - in_addr.sizeof] __pad;
}
enum
{
IPPROTO_IP = 0,
IPPROTO_ICMP = 1,
IPPROTO_TCP = 6,
IPPROTO_UDP = 17
}
enum uint INADDR_ANY = 0x00000000;
enum uint INADDR_BROADCAST = 0xffffffff;
enum INET_ADDRSTRLEN = 16;
}
else version( OSX )
{
private enum __SOCK_SIZE__ = 16;
struct sockaddr_in
{
ubyte sin_len;
sa_family_t sin_family;
in_port_t sin_port;
in_addr sin_addr;
ubyte[8] sin_zero;
}
enum
{
IPPROTO_IP = 0,
IPPROTO_ICMP = 1,
IPPROTO_TCP = 6,
IPPROTO_UDP = 17
}
enum uint INADDR_ANY = 0x00000000;
enum uint INADDR_BROADCAST = 0xffffffff;
enum INET_ADDRSTRLEN = 16;
}
else version( freebsd )
{
private enum __SOCK_SIZE__ = 16;
struct sockaddr_in
{
ubyte sin_len;
sa_family_t sin_family;
in_port_t sin_port;
in_addr sin_addr;
ubyte[8] sin_zero;
}
enum
{
IPPROTO_IP = 0,
IPPROTO_ICMP = 1,
IPPROTO_TCP = 6,
IPPROTO_UDP = 17
}
enum uint INADDR_ANY = 0x00000000;
enum uint INADDR_BROADCAST = 0xffffffff;
}
//
// IPV6 (IP6)
//
/*
NOTE: The following must must be defined in core.sys.posix.arpa.inet to break
a circular import: INET6_ADDRSTRLEN.
struct in6_addr
{
uint8_t[16] s6_addr;
}
struct sockaddr_in6
{
sa_family_t sin6_family;
in_port_t sin6_port;
uint32_t sin6_flowinfo;
in6_addr sin6_addr;
uint32_t sin6_scope_id;
}
extern in6_addr in6addr_any;
extern in6_addr in6addr_loopback;
struct ipv6_mreq
{
in6_addr ipv6mr_multiaddr;
uint ipv6mr_interface;
}
IPPROTO_IPV6
INET6_ADDRSTRLEN
IPV6_JOIN_GROUP
IPV6_LEAVE_GROUP
IPV6_MULTICAST_HOPS
IPV6_MULTICAST_IF
IPV6_MULTICAST_LOOP
IPV6_UNICAST_HOPS
IPV6_V6ONLY
// macros
int IN6_IS_ADDR_UNSPECIFIED(in6_addr*)
int IN6_IS_ADDR_LOOPBACK(in6_addr*)
int IN6_IS_ADDR_MULTICAST(in6_addr*)
int IN6_IS_ADDR_LINKLOCAL(in6_addr*)
int IN6_IS_ADDR_SITELOCAL(in6_addr*)
int IN6_IS_ADDR_V4MAPPED(in6_addr*)
int IN6_IS_ADDR_V4COMPAT(in6_addr*)
int IN6_IS_ADDR_MC_NODELOCAL(in6_addr*)
int IN6_IS_ADDR_MC_LINKLOCAL(in6_addr*)
int IN6_IS_ADDR_MC_SITELOCAL(in6_addr*)
int IN6_IS_ADDR_MC_ORGLOCAL(in6_addr*)
int IN6_IS_ADDR_MC_GLOBAL(in6_addr*)
*/
version ( linux )
{
struct in6_addr
{
union
{
uint8_t[16] s6_addr;
uint16_t[8] s6_addr16;
uint32_t[4] s6_addr32;
}
}
struct sockaddr_in6
{
sa_family_t sin6_family;
in_port_t sin6_port;
uint32_t sin6_flowinfo;
in6_addr sin6_addr;
uint32_t sin6_scope_id;
}
extern in6_addr in6addr_any;
extern in6_addr in6addr_loopback;
struct ipv6_mreq
{
in6_addr ipv6mr_multiaddr;
uint ipv6mr_interface;
}
enum : uint
{
IPPROTO_IPV6 = 41,
INET6_ADDRSTRLEN = 46,
IPV6_JOIN_GROUP = 20,
IPV6_LEAVE_GROUP = 21,
IPV6_MULTICAST_HOPS = 18,
IPV6_MULTICAST_IF = 17,
IPV6_MULTICAST_LOOP = 19,
IPV6_UNICAST_HOPS = 16,
IPV6_V6ONLY = 26
}
// macros
extern (D) int IN6_IS_ADDR_UNSPECIFIED( in6_addr* addr )
{
return (cast(uint32_t*) addr)[0] == 0 &&
(cast(uint32_t*) addr)[1] == 0 &&
(cast(uint32_t*) addr)[2] == 0 &&
(cast(uint32_t*) addr)[3] == 0;
}
extern (D) int IN6_IS_ADDR_LOOPBACK( in6_addr* addr )
{
return (cast(uint32_t*) addr)[0] == 0 &&
(cast(uint32_t*) addr)[1] == 0 &&
(cast(uint32_t*) addr)[2] == 0 &&
(cast(uint32_t*) addr)[3] == htonl( 1 );
}
extern (D) int IN6_IS_ADDR_MULTICAST( in6_addr* addr )
{
return (cast(uint8_t*) addr)[0] == 0xff;
}
extern (D) int IN6_IS_ADDR_LINKLOCAL( in6_addr* addr )
{
return ((cast(uint32_t*) addr)[0] & htonl( 0xffc00000 )) == htonl( 0xfe800000 );
}
extern (D) int IN6_IS_ADDR_SITELOCAL( in6_addr* addr )
{
return ((cast(uint32_t*) addr)[0] & htonl( 0xffc00000 )) == htonl( 0xfec00000 );
}
extern (D) int IN6_IS_ADDR_V4MAPPED( in6_addr* addr )
{
return (cast(uint32_t*) addr)[0] == 0 &&
(cast(uint32_t*) addr)[1] == 0 &&
(cast(uint32_t*) addr)[2] == htonl( 0xffff );
}
extern (D) int IN6_IS_ADDR_V4COMPAT( in6_addr* addr )
{
return (cast(uint32_t*) addr)[0] == 0 &&
(cast(uint32_t*) addr)[1] == 0 &&
(cast(uint32_t*) addr)[2] == 0 &&
ntohl( (cast(uint32_t*) addr)[3] ) > 1;
}
extern (D) int IN6_IS_ADDR_MC_NODELOCAL( in6_addr* addr )
{
return IN6_IS_ADDR_MULTICAST( addr ) &&
((cast(uint8_t*) addr)[1] & 0xf) == 0x1;
}
extern (D) int IN6_IS_ADDR_MC_LINKLOCAL( in6_addr* addr )
{
return IN6_IS_ADDR_MULTICAST( addr ) &&
((cast(uint8_t*) addr)[1] & 0xf) == 0x2;
}
extern (D) int IN6_IS_ADDR_MC_SITELOCAL( in6_addr* addr )
{
return IN6_IS_ADDR_MULTICAST(addr) &&
((cast(uint8_t*) addr)[1] & 0xf) == 0x5;
}
extern (D) int IN6_IS_ADDR_MC_ORGLOCAL( in6_addr* addr )
{
return IN6_IS_ADDR_MULTICAST( addr) &&
((cast(uint8_t*) addr)[1] & 0xf) == 0x8;
}
extern (D) int IN6_IS_ADDR_MC_GLOBAL( in6_addr* addr )
{
return IN6_IS_ADDR_MULTICAST( addr ) &&
((cast(uint8_t*) addr)[1] & 0xf) == 0xe;
}
}
else version( OSX )
{
struct in6_addr
{
union
{
uint8_t[16] s6_addr;
uint16_t[8] s6_addr16;
uint32_t[4] s6_addr32;
}
}
struct sockaddr_in6
{
uint8_t sin6_len;
sa_family_t sin6_family;
in_port_t sin6_port;
uint32_t sin6_flowinfo;
in6_addr sin6_addr;
uint32_t sin6_scope_id;
}
extern in6_addr in6addr_any;
extern in6_addr in6addr_loopback;
struct ipv6_mreq
{
in6_addr ipv6mr_multiaddr;
uint ipv6mr_interface;
}
enum : uint
{
IPPROTO_IPV6 = 41,
INET6_ADDRSTRLEN = 46,
IPV6_JOIN_GROUP = 12,
IPV6_LEAVE_GROUP = 13,
IPV6_MULTICAST_HOPS = 10,
IPV6_MULTICAST_IF = 9,
IPV6_MULTICAST_LOOP = 11,
IPV6_UNICAST_HOPS = 4,
IPV6_V6ONLY = 27
}
// macros
extern (D) int IN6_IS_ADDR_UNSPECIFIED( in6_addr* addr )
{
return (cast(uint32_t*) addr)[0] == 0 &&
(cast(uint32_t*) addr)[1] == 0 &&
(cast(uint32_t*) addr)[2] == 0 &&
(cast(uint32_t*) addr)[3] == 0;
}
extern (D) int IN6_IS_ADDR_LOOPBACK( in6_addr* addr )
{
return (cast(uint32_t*) addr)[0] == 0 &&
(cast(uint32_t*) addr)[1] == 0 &&
(cast(uint32_t*) addr)[2] == 0 &&
(cast(uint32_t*) addr)[3] == ntohl( 1 );
}
extern (D) int IN6_IS_ADDR_MULTICAST( in6_addr* addr )
{
return addr.s6_addr[0] == 0xff;
}
extern (D) int IN6_IS_ADDR_LINKLOCAL( in6_addr* addr )
{
return addr.s6_addr[0] == 0xfe && (addr.s6_addr[1] & 0xc0) == 0x80;
}
extern (D) int IN6_IS_ADDR_SITELOCAL( in6_addr* addr )
{
return addr.s6_addr[0] == 0xfe && (addr.s6_addr[1] & 0xc0) == 0xc0;
}
extern (D) int IN6_IS_ADDR_V4MAPPED( in6_addr* addr )
{
return (cast(uint32_t*) addr)[0] == 0 &&
(cast(uint32_t*) addr)[1] == 0 &&
(cast(uint32_t*) addr)[2] == ntohl( 0x0000ffff );
}
extern (D) int IN6_IS_ADDR_V4COMPAT( in6_addr* addr )
{
return (cast(uint32_t*) addr)[0] == 0 &&
(cast(uint32_t*) addr)[1] == 0 &&
(cast(uint32_t*) addr)[2] == 0 &&
(cast(uint32_t*) addr)[3] != 0 &&
(cast(uint32_t*) addr)[3] != ntohl( 1 );
}
extern (D) int IN6_IS_ADDR_MC_NODELOCAL( in6_addr* addr )
{
return IN6_IS_ADDR_MULTICAST( addr ) &&
((cast(uint8_t*) addr)[1] & 0xf) == 0x1;
}
extern (D) int IN6_IS_ADDR_MC_LINKLOCAL( in6_addr* addr )
{
return IN6_IS_ADDR_MULTICAST( addr ) &&
((cast(uint8_t*) addr)[1] & 0xf) == 0x2;
}
extern (D) int IN6_IS_ADDR_MC_SITELOCAL( in6_addr* addr )
{
return IN6_IS_ADDR_MULTICAST(addr) &&
((cast(uint8_t*) addr)[1] & 0xf) == 0x5;
}
extern (D) int IN6_IS_ADDR_MC_ORGLOCAL( in6_addr* addr )
{
return IN6_IS_ADDR_MULTICAST( addr) &&
((cast(uint8_t*) addr)[1] & 0xf) == 0x8;
}
extern (D) int IN6_IS_ADDR_MC_GLOBAL( in6_addr* addr )
{
return IN6_IS_ADDR_MULTICAST( addr ) &&
((cast(uint8_t*) addr)[1] & 0xf) == 0xe;
}
}
//
// Raw Sockets (RS)
//
/*
IPPROTO_RAW
*/
version (linux )
{
enum uint IPPROTO_RAW = 255;
}
else version( OSX )
{
enum uint IPPROTO_RAW = 255;
}

View File

@@ -0,0 +1,38 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.netinet.tcp;
private import core.sys.posix.config;
extern (C):
//
// Required
//
/*
TCP_NODELAY
*/
version( linux )
{
enum TCP_NODELAY = 1;
}
else version( OSX )
{
enum TCP_NODELAY = 1;
}
else version( freebsd )
{
enum TCP_NODELAY = 1;
}

View File

@@ -0,0 +1,141 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.poll;
private import core.sys.posix.config;
extern (C):
//
// XOpen (XSI)
//
/*
struct pollfd
{
int fd;
short events;
short revents;
}
nfds_t
POLLIN
POLLRDNORM
POLLRDBAND
POLLPRI
POLLOUT
POLLWRNORM
POLLWRBAND
POLLERR
POLLHUP
POLLNVAL
int poll(pollfd[], nfds_t, int);
*/
version( linux )
{
struct pollfd
{
int fd;
short events;
short revents;
}
alias c_ulong nfds_t;
enum
{
POLLIN = 0x001,
POLLRDNORM = 0x040,
POLLRDBAND = 0x080,
POLLPRI = 0x002,
POLLOUT = 0x004,
POLLWRNORM = 0x100,
POLLWRBAND = 0x200,
POLLERR = 0x008,
POLLHUP = 0x010,
POLLNVAL = 0x020,
}
int poll(pollfd*, nfds_t, int);
}
else version( OSX )
{
struct pollfd
{
int fd;
short events;
short revents;
};
alias uint nfds_t;
enum
{
POLLIN = 0x0001,
POLLPRI = 0x0002,
POLLOUT = 0x0004,
POLLRDNORM = 0x0040,
POLLWRNORM = POLLOUT,
POLLRDBAND = 0x0080,
POLLWRBAND = 0x0100,
POLLEXTEND = 0x0200,
POLLATTRIB = 0x0400,
POLLNLINK = 0x0800,
POLLWRITE = 0x1000,
POLLERR = 0x0008,
POLLHUP = 0x0010,
POLLNVAL = 0x0020,
POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
}
int poll(pollfd*, nfds_t, int);
}
else version( freebsd )
{
struct pollfd
{
int fd;
short events;
short revents;
};
alias uint nfds_t;
enum
{
POLLIN = 0x0001,
POLLPRI = 0x0002,
POLLOUT = 0x0004,
POLLRDNORM = 0x0040,
POLLWRNORM = POLLOUT,
POLLRDBAND = 0x0080,
POLLWRBAND = 0x0100,
//POLLEXTEND = 0x0200,
//POLLATTRIB = 0x0400,
//POLLNLINK = 0x0800,
//POLLWRITE = 0x1000,
POLLERR = 0x0008,
POLLHUP = 0x0010,
POLLNVAL = 0x0020,
POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
}
int poll(pollfd*, nfds_t, int);
}

View File

@@ -0,0 +1,585 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.pthread;
private import core.sys.posix.config;
public import core.sys.posix.sys.types;
public import core.sys.posix.sched;
public import core.sys.posix.time;
extern (C):
//
// Required
//
/*
PTHREAD_CANCEL_ASYNCHRONOUS
PTHREAD_CANCEL_ENABLE
PTHREAD_CANCEL_DEFERRED
PTHREAD_CANCEL_DISABLE
PTHREAD_CANCELED
PTHREAD_COND_INITIALIZER
PTHREAD_CREATE_DETACHED
PTHREAD_CREATE_JOINABLE
PTHREAD_EXPLICIT_SCHED
PTHREAD_INHERIT_SCHED
PTHREAD_MUTEX_INITIALIZER
PTHREAD_ONCE_INIT
PTHREAD_PROCESS_SHARED
PTHREAD_PROCESS_PRIVATE
int pthread_atfork(void function(), void function(), void function());
int pthread_attr_destroy(pthread_attr_t*);
int pthread_attr_getdetachstate(in pthread_attr_t*, int*);
int pthread_attr_getschedparam(in pthread_attr_t*, sched_param*);
int pthread_attr_init(pthread_attr_t*);
int pthread_attr_setdetachstate(pthread_attr_t*, int);
int pthread_attr_setschedparam(in pthread_attr_t*, sched_param*);
int pthread_cancel(pthread_t);
void pthread_cleanup_push(void function(void*), void*);
void pthread_cleanup_pop(int);
int pthread_cond_broadcast(pthread_cond_t*);
int pthread_cond_destroy(pthread_cond_t*);
int pthread_cond_init(in pthread_cond_t*, pthread_condattr_t*);
int pthread_cond_signal(pthread_cond_t*);
int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, in timespec*);
int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*);
int pthread_condattr_destroy(pthread_condattr_t*);
int pthread_condattr_init(pthread_condattr_t*);
int pthread_create(pthread_t*, in pthread_attr_t*, void* function(void*), void*);
int pthread_detach(pthread_t);
int pthread_equal(pthread_t, pthread_t);
void pthread_exit(void*);
void* pthread_getspecific(pthread_key_t);
int pthread_join(pthread_t, void**);
int pthread_key_create(pthread_key_t*, void function(void*));
int pthread_key_delete(pthread_key_t);
int pthread_mutex_destroy(pthread_mutex_t*);
int pthread_mutex_init(pthread_mutex_t*, pthread_mutexattr_t*);
int pthread_mutex_lock(pthread_mutex_t*);
int pthread_mutex_trylock(pthread_mutex_t*);
int pthread_mutex_unlock(pthread_mutex_t*);
int pthread_mutexattr_destroy(pthread_mutexattr_t*);
int pthread_mutexattr_init(pthread_mutexattr_t*);
int pthread_once(pthread_once_t*, void function());
int pthread_rwlock_destroy(pthread_rwlock_t*);
int pthread_rwlock_init(in pthread_rwlock_t*, pthread_rwlockattr_t*);
int pthread_rwlock_rdlock(pthread_rwlock_t*);
int pthread_rwlock_tryrdlock(pthread_rwlock_t*);
int pthread_rwlock_trywrlock(pthread_rwlock_t*);
int pthread_rwlock_unlock(pthread_rwlock_t*);
int pthread_rwlock_wrlock(pthread_rwlock_t*);
int pthread_rwlockattr_destroy(pthread_rwlockattr_t*);
int pthread_rwlockattr_init(pthread_rwlockattr_t*);
pthread_t pthread_self();
int pthread_setcancelstate(int, int*);
int pthread_setcanceltype(int, int*);
int pthread_setspecific(pthread_key_t, in void*);
void pthread_testcancel();
*/
version( linux )
{
enum
{
PTHREAD_CANCEL_ENABLE,
PTHREAD_CANCEL_DISABLE
}
enum
{
PTHREAD_CANCEL_DEFERRED,
PTHREAD_CANCEL_ASYNCHRONOUS
}
enum PTHREAD_CANCELED = cast(void*) -1;
//enum pthread_mutex_t PTHREAD_COND_INITIALIZER = { __LOCK_ALT_INITIALIZER, 0, "", 0 };
enum
{
PTHREAD_CREATE_JOINABLE,
PTHREAD_CREATE_DETACHED
}
enum
{
PTHREAD_INHERIT_SCHED,
PTHREAD_EXPLICIT_SCHED
}
//enum pthread_mutex_t PTHREAD_MUTEX_INITIALIZER = { 0, 0, null, PTHREAD_MUTEX_NORMAL, { 0, 0 } };
enum PTHREAD_ONCE_INIT = 0;
enum
{
PTHREAD_PROCESS_PRIVATE,
PTHREAD_PROCESS_SHARED
}
}
else version( OSX )
{
enum
{
PTHREAD_CANCEL_ENABLE = 1,
PTHREAD_CANCEL_DISABLE = 0
}
enum
{
PTHREAD_CANCEL_DEFERRED = 2,
PTHREAD_CANCEL_ASYNCHRONOUS = 0
}
enum PTHREAD_CANCELED = cast(void*) -1;
//enum pthread_mutex_t PTHREAD_COND_INITIALIZER = { __LOCK_ALT_INITIALIZER, 0, "", 0 };
enum
{
PTHREAD_CREATE_JOINABLE = 1,
PTHREAD_CREATE_DETACHED = 2
}
enum
{
PTHREAD_INHERIT_SCHED = 1,
PTHREAD_EXPLICIT_SCHED = 2
}
//enum pthread_mutex_t PTHREAD_MUTEX_INITIALIZER = { 0, 0, null, PTHREAD_MUTEX_NORMAL, { 0, 0 } };
enum PTHREAD_ONCE_INIT = 0;
enum
{
PTHREAD_PROCESS_PRIVATE = 2,
PTHREAD_PROCESS_SHARED = 1
}
}
int pthread_atfork(void function(), void function(), void function());
int pthread_attr_destroy(pthread_attr_t*);
int pthread_attr_getdetachstate(in pthread_attr_t*, int*);
int pthread_attr_getschedparam(in pthread_attr_t*, sched_param*);
int pthread_attr_init(pthread_attr_t*);
int pthread_attr_setdetachstate(pthread_attr_t*, int);
int pthread_attr_setschedparam(in pthread_attr_t*, sched_param*);
int pthread_cancel(pthread_t);
version( linux )
{
alias void function(void*) _pthread_cleanup_routine;
struct _pthread_cleanup_buffer
{
_pthread_cleanup_routine __routine;
void* __arg;
int __canceltype;
_pthread_cleanup_buffer* __prev;
}
void _pthread_cleanup_push(_pthread_cleanup_buffer*, _pthread_cleanup_routine, void*);
void _pthread_cleanup_pop(_pthread_cleanup_buffer*, int);
struct pthread_cleanup
{
_pthread_cleanup_buffer buffer = void;
void push()( _pthread_cleanup_routine routine, void* arg )
{
_pthread_cleanup_push( &buffer, routine, arg );
}
void pop()( int execute )
{
_pthread_cleanup_pop( &buffer, execute );
}
}
}
else version( OSX )
{
alias void function(void*) _pthread_cleanup_routine;
struct _pthread_cleanup_buffer
{
_pthread_cleanup_routine __routine;
void* __arg;
_pthread_cleanup_buffer* __next;
}
struct pthread_cleanup
{
_pthread_cleanup_buffer buffer = void;
void push()( _pthread_cleanup_routine routine, void* arg )
{
pthread_t self = pthread_self();
buffer.__routine = routine;
buffer.__arg = arg;
buffer.__next = cast(_pthread_cleanup_buffer*) self.__cleanup_stack;
self.__cleanup_stack = cast(pthread_handler_rec*) &buffer;
}
void pop()( int execute )
{
pthread_t self = pthread_self();
self.__cleanup_stack = cast(pthread_handler_rec*) buffer.__next;
if( execute )
{
buffer.__routine( buffer.__arg );
}
}
}
}
else
{
void pthread_cleanup_push(void function(void*), void*);
void pthread_cleanup_pop(int);
}
int pthread_cond_broadcast(pthread_cond_t*);
int pthread_cond_destroy(pthread_cond_t*);
int pthread_cond_init(in pthread_cond_t*, pthread_condattr_t*);
int pthread_cond_signal(pthread_cond_t*);
int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, in timespec*);
int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*);
int pthread_condattr_destroy(pthread_condattr_t*);
int pthread_condattr_init(pthread_condattr_t*);
int pthread_create(pthread_t*, in pthread_attr_t*, void* function(void*), void*);
int pthread_detach(pthread_t);
int pthread_equal(pthread_t, pthread_t);
void pthread_exit(void*);
void* pthread_getspecific(pthread_key_t);
int pthread_join(pthread_t, void**);
int pthread_key_create(pthread_key_t*, void function(void*));
int pthread_key_delete(pthread_key_t);
int pthread_mutex_destroy(pthread_mutex_t*);
int pthread_mutex_init(pthread_mutex_t*, pthread_mutexattr_t*);
int pthread_mutex_lock(pthread_mutex_t*);
int pthread_mutex_trylock(pthread_mutex_t*);
int pthread_mutex_unlock(pthread_mutex_t*);
int pthread_mutexattr_destroy(pthread_mutexattr_t*);
int pthread_mutexattr_init(pthread_mutexattr_t*);
int pthread_once(pthread_once_t*, void function());
int pthread_rwlock_destroy(pthread_rwlock_t*);
int pthread_rwlock_init(in pthread_rwlock_t*, pthread_rwlockattr_t*);
int pthread_rwlock_rdlock(pthread_rwlock_t*);
int pthread_rwlock_tryrdlock(pthread_rwlock_t*);
int pthread_rwlock_trywrlock(pthread_rwlock_t*);
int pthread_rwlock_unlock(pthread_rwlock_t*);
int pthread_rwlock_wrlock(pthread_rwlock_t*);
int pthread_rwlockattr_destroy(pthread_rwlockattr_t*);
int pthread_rwlockattr_init(pthread_rwlockattr_t*);
pthread_t pthread_self();
int pthread_setcancelstate(int, int*);
int pthread_setcanceltype(int, int*);
int pthread_setspecific(pthread_key_t, in void*);
void pthread_testcancel();
//
// Barrier (BAR)
//
/*
PTHREAD_BARRIER_SERIAL_THREAD
int pthread_barrier_destroy(pthread_barrier_t*);
int pthread_barrier_init(pthread_barrier_t*, in pthread_barrierattr_t*, uint);
int pthread_barrier_wait(pthread_barrier_t*);
int pthread_barrierattr_destroy(pthread_barrierattr_t*);
int pthread_barrierattr_getpshared(in pthread_barrierattr_t*, int*); (BAR|TSH)
int pthread_barrierattr_init(pthread_barrierattr_t*);
int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int); (BAR|TSH)
*/
version( linux )
{
enum PTHREAD_BARRIER_SERIAL_THREAD = -1;
int pthread_barrier_destroy(pthread_barrier_t*);
int pthread_barrier_init(pthread_barrier_t*, in pthread_barrierattr_t*, uint);
int pthread_barrier_wait(pthread_barrier_t*);
int pthread_barrierattr_destroy(pthread_barrierattr_t*);
int pthread_barrierattr_getpshared(in pthread_barrierattr_t*, int*);
int pthread_barrierattr_init(pthread_barrierattr_t*);
int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
}
//
// Clock (CS)
//
/*
int pthread_condattr_getclock(in pthread_condattr_t*, clockid_t*);
int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
*/
//
// Spinlock (SPI)
//
/*
int pthread_spin_destroy(pthread_spinlock_t*);
int pthread_spin_init(pthread_spinlock_t*, int);
int pthread_spin_lock(pthread_spinlock_t*);
int pthread_spin_trylock(pthread_spinlock_t*);
int pthread_spin_unlock(pthread_spinlock_t*);
*/
version( linux )
{
int pthread_spin_destroy(pthread_spinlock_t*);
int pthread_spin_init(pthread_spinlock_t*, int);
int pthread_spin_lock(pthread_spinlock_t*);
int pthread_spin_trylock(pthread_spinlock_t*);
int pthread_spin_unlock(pthread_spinlock_t*);
}
//
// XOpen (XSI)
//
/*
PTHREAD_MUTEX_DEFAULT
PTHREAD_MUTEX_ERRORCHECK
PTHREAD_MUTEX_NORMAL
PTHREAD_MUTEX_RECURSIVE
int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
int pthread_attr_setguardsize(pthread_attr_t*, size_t);
int pthread_getconcurrency();
int pthread_mutexattr_gettype(in pthread_mutexattr_t*, int*);
int pthread_mutexattr_settype(pthread_mutexattr_t*, int);
int pthread_setconcurrency(int);
*/
version( linux )
{
enum PTHREAD_MUTEX_NORMAL = 0;
enum PTHREAD_MUTEX_RECURSIVE = 1;
enum PTHREAD_MUTEX_ERRORCHECK = 2;
enum PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL;
int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
int pthread_attr_setguardsize(pthread_attr_t*, size_t);
int pthread_getconcurrency();
int pthread_mutexattr_gettype(in pthread_mutexattr_t*, int*);
int pthread_mutexattr_settype(pthread_mutexattr_t*, int);
int pthread_setconcurrency(int);
}
else version( OSX )
{
enum PTHREAD_MUTEX_NORMAL = 0;
enum PTHREAD_MUTEX_ERRORCHECK = 1;
enum PTHREAD_MUTEX_RECURSIVE = 2;
enum PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL;
int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
int pthread_attr_setguardsize(pthread_attr_t*, size_t);
int pthread_getconcurrency();
int pthread_mutexattr_gettype(in pthread_mutexattr_t*, int*);
int pthread_mutexattr_settype(pthread_mutexattr_t*, int);
int pthread_setconcurrency(int);
}
else version( freebsd )
{
enum
{
PTHREAD_MUTEX_ERRORCHECK = 1,
PTHREAD_MUTEX_RECURSIVE = 2,
PTHREAD_MUTEX_NORMAL = 3,
PTHREAD_MUTEX_ADAPTIVE_NP = 4,
PTHREAD_MUTEX_TYPE_MAX
}
enum PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_ERRORCHECK;
int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
int pthread_attr_setguardsize(pthread_attr_t*, size_t);
int pthread_getconcurrency();
int pthread_mutexattr_gettype(pthread_mutexattr_t*, int*);
int pthread_mutexattr_settype(pthread_mutexattr_t*, int);
int pthread_setconcurrency(int);
}
//
// CPU Time (TCT)
//
/*
int pthread_getcpuclockid(pthread_t, clockid_t*);
*/
version( linux )
{
int pthread_getcpuclockid(pthread_t, clockid_t*);
}
//
// Timeouts (TMO)
//
/*
int pthread_mutex_timedlock(pthread_mutex_t*, timespec*);
int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
*/
version( linux )
{
int pthread_mutex_timedlock(pthread_mutex_t*, timespec*);
int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
}
else version( OSX )
{
int pthread_mutex_timedlock(pthread_mutex_t*, timespec*);
int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
}
//
// Priority (TPI|TPP)
//
/*
PTHREAD_PRIO_INHERIT (TPI)
PTHREAD_PRIO_NONE (TPP|TPI)
PTHREAD_PRIO_PROTECT (TPI)
int pthread_mutex_getprioceiling(in pthread_mutex_t*, int*); (TPP)
int pthread_mutex_setprioceiling(pthread_mutex_t*, int, int*); (TPP)
int pthread_mutexattr_getprioceiling(pthread_mutexattr_t*, int*); (TPP)
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)
*/
//
// Scheduling (TPS)
//
/*
PTHREAD_SCOPE_PROCESS
PTHREAD_SCOPE_SYSTEM
int pthread_attr_getinheritsched(in pthread_attr_t*, int*);
int pthread_attr_getschedpolicy(in pthread_attr_t*, int*);
int pthread_attr_getscope(in pthread_attr_t*, int*);
int pthread_attr_setinheritsched(pthread_attr_t*, int);
int pthread_attr_setschedpolicy(pthread_attr_t*, int);
int pthread_attr_setscope(pthread_attr_t*, int);
int pthread_getschedparam(pthread_t, int*, sched_param*);
int pthread_setschedparam(pthread_t, int, in sched_param*);
int pthread_setschedprio(pthread_t, int);
*/
version( linux )
{
enum
{
PTHREAD_SCOPE_SYSTEM,
PTHREAD_SCOPE_PROCESS
}
int pthread_attr_getinheritsched(in pthread_attr_t*, int*);
int pthread_attr_getschedpolicy(in pthread_attr_t*, int*);
int pthread_attr_getscope(in pthread_attr_t*, int*);
int pthread_attr_setinheritsched(pthread_attr_t*, int);
int pthread_attr_setschedpolicy(pthread_attr_t*, int);
int pthread_attr_setscope(pthread_attr_t*, int);
int pthread_getschedparam(pthread_t, int*, sched_param*);
int pthread_setschedparam(pthread_t, int, in sched_param*);
//int pthread_setschedprio(pthread_t, int);
}
else version( OSX )
{
enum
{
PTHREAD_SCOPE_SYSTEM = 1,
PTHREAD_SCOPE_PROCESS = 2
}
int pthread_attr_getinheritsched(in pthread_attr_t*, int*);
int pthread_attr_getschedpolicy(in pthread_attr_t*, int*);
int pthread_attr_getscope(in pthread_attr_t*, int*);
int pthread_attr_setinheritsched(pthread_attr_t*, int);
int pthread_attr_setschedpolicy(pthread_attr_t*, int);
int pthread_attr_setscope(pthread_attr_t*, int);
int pthread_getschedparam(pthread_t, int*, sched_param*);
int pthread_setschedparam(pthread_t, int, in sched_param*);
//int pthread_setschedprio(pthread_t, int);
}
else version( freebsd )
{
enum
{
PTHREAD_SCOPE_PROCESS = 0,
PTHREAD_SCOPE_SYSTEM = 0x2
}
int pthread_attr_getinheritsched(in pthread_attr_t*, int*);
int pthread_attr_getschedpolicy(in pthread_attr_t*, int*);
int pthread_attr_getscope(in pthread_attr_t*, int*);
int pthread_attr_setinheritsched(pthread_attr_t*, int);
int pthread_attr_setschedpolicy(pthread_attr_t*, int);
int pthread_attr_setscope(in pthread_attr_t*, int);
int pthread_getschedparam(pthread_t, int*, sched_param*);
int pthread_setschedparam(pthread_t, int, sched_param*);
//int pthread_setschedprio(pthread_t, int);
}
//
// Stack (TSA|TSS)
//
/*
int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*); (TSA|TSS)
int pthread_attr_getstackaddr(in pthread_attr_t*, void**); (TSA)
int pthread_attr_getstacksize(in pthread_attr_t*, size_t*); (TSS)
int pthread_attr_setstack(pthread_attr_t*, void*, size_t); (TSA|TSS)
int pthread_attr_setstackaddr(pthread_attr_t*, void*); (TSA)
int pthread_attr_setstacksize(pthread_attr_t*, size_t); (TSS)
*/
version( linux )
{
int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
int pthread_attr_getstackaddr(in pthread_attr_t*, void**);
int pthread_attr_getstacksize(in pthread_attr_t*, size_t*);
int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
int pthread_attr_setstackaddr(pthread_attr_t*, void*);
int pthread_attr_setstacksize(pthread_attr_t*, size_t);
}
else version( OSX )
{
int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
int pthread_attr_getstackaddr(in pthread_attr_t*, void**);
int pthread_attr_getstacksize(in pthread_attr_t*, size_t*);
int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
int pthread_attr_setstackaddr(pthread_attr_t*, void*);
int pthread_attr_setstacksize(pthread_attr_t*, size_t);
}
else version( freebsd )
{
int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
int pthread_attr_getstackaddr(in pthread_attr_t*, void**);
int pthread_attr_getstacksize(in pthread_attr_t*, size_t*);
int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
int pthread_attr_setstackaddr(pthread_attr_t*, void*);
int pthread_attr_setstacksize(pthread_attr_t*, size_t);
}
//
// Shared Synchronization (TSH)
//
/*
int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
int pthread_condattr_setpshared(pthread_condattr_t*, int);
int pthread_mutexattr_getpshared(in pthread_mutexattr_t*, int*);
int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
*/

View File

@@ -0,0 +1,137 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.pwd;
private import core.sys.posix.config;
public import core.sys.posix.sys.types; // for gid_t, uid_t
extern (C):
//
// Required
//
/*
struct passwd
{
char* pw_name;
uid_t pw_uid;
gid_t pw_gid;
char* pw_dir;
char* pw_shell;
}
passwd* getpwnam(in char*);
passwd* getpwuid(uid_t);
*/
version( linux )
{
struct passwd
{
char* pw_name;
char* pw_passwd;
uid_t pw_uid;
gid_t pw_gid;
char* pw_gecos;
char* pw_dir;
char* pw_shell;
}
}
else version( OSX )
{
struct passwd
{
char* pw_name;
char* pw_passwd;
uid_t pw_uid;
gid_t pw_gid;
time_t pw_change;
char* pw_class;
char* pw_gecos;
char* pw_dir;
char* pw_shell;
time_t pw_expire;
}
}
else version( freebsd )
{
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 */
int pw_fields; /* internal: fields filled in */
}
}
passwd* getpwnam(in char*);
passwd* getpwuid(uid_t);
//
// Thread-Safe Functions (TSF)
//
/*
int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
*/
version( linux )
{
int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
}
else version( OSX )
{
int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
}
else version( freebsd )
{
int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
}
//
// XOpen (XSI)
//
/*
void endpwent();
passwd* getpwent();
void setpwent();
*/
version( linux )
{
void endpwent();
passwd* getpwent();
void setpwent();
}
else version ( OSX )
{
void endpwent();
passwd* getpwent();
void setpwent();
}
else version ( freebsd )
{
void endpwent();
passwd* getpwent();
void setpwent();
}

View File

@@ -0,0 +1,137 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.sched;
private import core.sys.posix.config;
public import core.sys.posix.time;
public import core.sys.posix.sys.types;
extern (C):
//
// Required
//
/*
struct sched_param
{
int sched_priority (THR)
int sched_ss_low_priority (SS|TSP)
struct timespec sched_ss_repl_period (SS|TSP)
struct timespec sched_ss_init_budget (SS|TSP)
int sched_ss_max_repl (SS|TSP)
}
SCHED_FIFO
SCHED_RR
SCHED_SPORADIC (SS|TSP)
SCHED_OTHER
int sched_getparam(pid_t, sched_param*);
int sched_getscheduler(pid_t);
int sched_setparam(pid_t, in sched_param*);
int sched_setscheduler(pid_t, int, in sched_param*);
*/
version( linux )
{
struct sched_param
{
int sched_priority;
}
enum SCHED_OTHER = 0;
enum SCHED_FIFO = 1;
enum SCHED_RR = 2;
//SCHED_SPORADIC (SS|TSP)
}
else version( OSX )
{
enum SCHED_OTHER = 1;
enum SCHED_FIFO = 4;
enum SCHED_RR = 2;
//SCHED_SPORADIC (SS|TSP)
private enum __SCHED_PARAM_SIZE__ = 4;
struct sched_param
{
int sched_priority;
byte[__PTHREAD_MUTEX_SIZE__] __opaque;
}
}
else version( freebsd )
{
struct sched_param
{
int sched_priority;
}
enum SCHED_FIFO = 1;
enum SCHED_OTHER = 2;
enum SCHED_RR = 3;
//SCHED_SPORADIC (SS|TSP)
}
int sched_getparam(pid_t, sched_param*);
int sched_getscheduler(pid_t);
int sched_setparam(pid_t, in sched_param*);
int sched_setscheduler(pid_t, int, in sched_param*);
//
// Thread (THR)
//
/*
int sched_yield();
*/
version( linux )
{
int sched_yield();
}
else version( OSX )
{
int sched_yield();
}
else version( freebsd )
{
int sched_yield();
}
//
// Scheduling (TPS)
//
/*
int sched_get_priority_max(int);
int sched_get_priority_min(int);
int sched_rr_get_interval(pid_t, timespec*);
*/
version( linux )
{
int sched_get_priority_max(int);
int sched_get_priority_min(int);
int sched_rr_get_interval(pid_t, timespec*);
}
else version( OSX )
{
int sched_get_priority_min(int);
int sched_get_priority_max(int);
//int sched_rr_get_interval(pid_t, timespec*); // FIXME: unavailable?
}
else version( freebsd )
{
int sched_get_priority_min(int);
int sched_get_priority_max(int);
int sched_rr_get_interval(pid_t, timespec*);
}

View File

@@ -0,0 +1,102 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.semaphore;
private import core.sys.posix.config;
private import core.sys.posix.time;
extern (C):
//
// Required
//
/*
sem_t
SEM_FAILED
int sem_close(sem_t*);
int sem_destroy(sem_t*);
int sem_getvalue(sem_t*, int*);
int sem_init(sem_t*, int, uint);
sem_t* sem_open(in char*, int, ...);
int sem_post(sem_t*);
int sem_trywait(sem_t*);
int sem_unlink(in char*);
int sem_wait(sem_t*);
*/
version( linux )
{
private alias int __atomic_lock_t;
private struct _pthread_fastlock
{
c_long __status;
__atomic_lock_t __spinlock;
}
struct sem_t
{
_pthread_fastlock __sem_lock;
int __sem_value;
void* __sem_waiting;
}
enum SEM_FAILED = cast(sem_t*) null;
}
else version( OSX )
{
alias int sem_t;
enum SEM_FAILED = cast(sem_t*) null;
}
else version( freebsd )
{
enum SEM_MAGIC = 0x09fa4012;
enum SEM_USER = 0;
alias void* sem_t;
enum SEM_FAILED = cast(sem_t*) null;
}
int sem_close(sem_t*);
int sem_destroy(sem_t*);
int sem_getvalue(sem_t*, int*);
int sem_init(sem_t*, int, uint);
sem_t* sem_open(in char*, int, ...);
int sem_post(sem_t*);
int sem_trywait(sem_t*);
int sem_unlink(in char*);
int sem_wait(sem_t*);
//
// Timeouts (TMO)
//
/*
int sem_timedwait(sem_t*, in timespec*);
*/
version( linux )
{
int sem_timedwait(sem_t*, in timespec*);
}
else version( OSX )
{
int sem_timedwait(sem_t*, in timespec*);
}
else version( freebsd )
{
int sem_timedwait(sem_t*, in timespec*);
}

View File

@@ -0,0 +1,108 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.setjmp;
private import core.sys.posix.config;
private import core.sys.posix.signal; // for sigset_t
extern (C):
//
// Required
//
/*
jmp_buf
int setjmp(jmp_buf);
void longjmp(jmp_buf, int);
*/
version( linux )
{
version( X86_64 )
{
//enum JB_BX = 0;
//enum JB_BP = 1;
//enum JB_12 = 2;
//enum JB_13 = 3;
//enum JB_14 = 4;
//enum JB_15 = 5;
//enum JB_SP = 6;
//enum JB_PC = 7;
//enum JB_SIZE = 64;
alias long[8] __jmp_buf;
}
else version( X86 )
{
//enum JB_BX = 0;
//enum JB_SI = 1;
//enum JB_DI = 2;
//enum JB_BP = 3;
//enum JB_SP = 4;
//enum JB_PC = 5;
//enum JB_SIZE = 24;
alias int[6] __jmp_buf;
}
else version ( SPARC )
{
alias int[3] __jmp_buf;
}
struct __jmp_buf_tag
{
__jmp_buf __jmpbuf;
int __mask_was_saved;
sigset_t __saved_mask;
}
alias __jmp_buf_tag[1] jmp_buf;
alias _setjmp setjmp; // see XOpen block
void longjmp(jmp_buf, int);
}
//
// C Extension (CX)
//
/*
sigjmp_buf
int sigsetjmp(sigjmp_buf, int);
void siglongjmp(sigjmp_buf, int);
*/
version( linux )
{
alias jmp_buf sigjmp_buf;
int __sigsetjmp(sigjmp_buf, int);
alias __sigsetjmp sigsetjmp;
void siglongjmp(sigjmp_buf, int);
}
//
// XOpen (XSI)
//
/*
int _setjmp(jmp_buf);
void _longjmp(jmp_buf, int);
*/
version( linux )
{
int _setjmp(jmp_buf);
void _longjmp(jmp_buf, int);
}

View File

@@ -0,0 +1,843 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.signal;
private import core.sys.posix.config;
public import core.stdc.signal;
public import core.stdc.stddef; // for size_t
public import core.sys.posix.sys.types; // for pid_t
//public import core.sys.posix.time; // for timespec, now defined here
extern (C):
private alias void function(int) sigfn_t;
private alias void function(int, siginfo_t*, void*) sigactfn_t;
//
// Required
//
/*
SIG_DFL (defined in core.stdc.signal)
SIG_ERR (defined in core.stdc.signal)
SIG_IGN (defined in core.stdc.signal)
sig_atomic_t (defined in core.stdc.signal)
SIGEV_NONE
SIGEV_SIGNAL
SIGEV_THREAD
union sigval
{
int sival_int;
void* sival_ptr;
}
SIGRTMIN
SIGRTMAX
SIGABRT (defined in core.stdc.signal)
SIGALRM
SIGBUS
SIGCHLD
SIGCONT
SIGFPE (defined in core.stdc.signal)
SIGHUP
SIGILL (defined in core.stdc.signal)
SIGINT (defined in core.stdc.signal)
SIGKILL
SIGPIPE
SIGQUIT
SIGSEGV (defined in core.stdc.signal)
SIGSTOP
SIGTERM (defined in core.stdc.signal)
SIGTSTP
SIGTTIN
SIGTTOU
SIGUSR1
SIGUSR2
SIGURG
struct sigaction_t
{
sigfn_t sa_handler;
sigset_t sa_mask;
sigactfn_t sa_sigaction;
}
sigfn_t signal(int sig, sigfn_t func); (defined in core.stdc.signal)
int raise(int sig); (defined in core.stdc.signal)
*/
//SIG_DFL (defined in core.stdc.signal)
//SIG_ERR (defined in core.stdc.signal)
//SIG_IGN (defined in core.stdc.signal)
//sig_atomic_t (defined in core.stdc.signal)
enum
{
SIGEV_SIGNAL,
SIGEV_NONE,
SIGEV_THREAD
}
union sigval
{
int sival_int;
void* sival_ptr;
}
private extern (C) int __libc_current_sigrtmin();
private extern (C) int __libc_current_sigrtmax();
alias __libc_current_sigrtmin SIGRTMIN;
alias __libc_current_sigrtmax SIGRTMAX;
version( linux )
{
//SIGABRT (defined in core.stdc.signal)
enum SIGALRM = 14;
enum SIGBUS = 7;
enum SIGCHLD = 17;
enum SIGCONT = 18;
//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 = 19;
//SIGTERM (defined in core.stdc.signal)
enum SIGTSTP = 20;
enum SIGTTIN = 21;
enum SIGTTOU = 22;
enum SIGUSR1 = 10;
enum SIGUSR2 = 12;
enum SIGURG = 23;
}
else version( OSX )
{
//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( freebsd )
{
//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;
}
struct sigaction_t
{
static if( true /* __USE_POSIX199309 */ )
{
union
{
sigfn_t sa_handler;
sigactfn_t sa_sigaction;
}
}
else
{
sigfn_t sa_handler;
}
sigset_t sa_mask;
int sa_flags;
version( OSX ) {} else {
void function() sa_restorer;
}
}
//
// C Extension (CX)
//
/*
SIG_HOLD
sigset_t
pid_t (defined in core.sys.types)
SIGABRT (defined in core.stdc.signal)
SIGFPE (defined in core.stdc.signal)
SIGILL (defined in core.stdc.signal)
SIGINT (defined in core.stdc.signal)
SIGSEGV (defined in core.stdc.signal)
SIGTERM (defined in core.stdc.signal)
SA_NOCLDSTOP (CX|XSI)
SIG_BLOCK
SIG_UNBLOCK
SIG_SETMASK
struct siginfo_t
{
int si_signo;
int si_code;
version( XSI )
{
int si_errno;
pid_t si_pid;
uid_t si_uid;
void* si_addr;
int si_status;
c_long si_band;
}
version( RTS )
{
sigval si_value;
}
}
SI_USER
SI_QUEUE
SI_TIMER
SI_ASYNCIO
SI_MESGQ
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*);
*/
version( linux )
{
enum SIG_HOLD = cast(sigfn_t) 1;
private enum _SIGSET_NWORDS = 1024 / (8 * c_ulong.sizeof);
struct sigset_t
{
c_ulong[_SIGSET_NWORDS] __val;
}
// pid_t (defined in core.sys.types)
//SIGABRT (defined in core.stdc.signal)
//SIGFPE (defined in core.stdc.signal)
//SIGILL (defined in core.stdc.signal)
//SIGINT (defined in core.stdc.signal)
//SIGSEGV (defined in core.stdc.signal)
//SIGTERM (defined in core.stdc.signal)
enum SA_NOCLDSTOP = 1; // (CX|XSI)
enum SIG_BLOCK = 0;
enum SIG_UNBLOCK = 1;
enum SIG_SETMASK = 2;
private enum __SI_MAX_SIZE = 128;
static if( false /* __WORDSIZE == 64 */ )
{
private enum __SI_PAD_SIZE = ((__SI_MAX_SIZE / int.sizeof) - 4);
}
else
{
private enum __SI_PAD_SIZE = ((__SI_MAX_SIZE / int.sizeof) - 3);
}
struct siginfo_t
{
int si_signo; // Signal number
int si_errno; // If non-zero, an errno value associated with
// this signal, as defined in <errno.h>
int si_code; // Signal code
union _sifields_t
{
int _pad[__SI_PAD_SIZE];
// kill()
struct _kill_t
{
pid_t si_pid; // Sending process ID
uid_t si_uid; // Real user ID of sending process
} _kill_t _kill;
// POSIX.1b timers.
struct _timer_t
{
int si_tid; // Timer ID
int si_overrun; // Overrun count
sigval si_sigval; // Signal value
} _timer_t _timer;
// POSIX.1b signals
struct _rt_t
{
pid_t si_pid; // Sending process ID
uid_t si_uid; // Real user ID of sending process
sigval si_sigval; // Signal value
} _rt_t _rt;
// SIGCHLD
struct _sigchild_t
{
pid_t si_pid; // Which child
uid_t si_uid; // Real user ID of sending process
int si_status; // Exit value or signal
clock_t si_utime;
clock_t si_stime;
} _sigchild_t _sigchld;
// SIGILL, SIGFPE, SIGSEGV, SIGBUS
struct _sigfault_t
{
void* si_addr; // Faulting insn/memory ref
} _sigfault_t _sigfault;
// SIGPOLL
struct _sigpoll_t
{
c_long si_band; // Band event for SIGPOLL
int si_fd;
} _sigpoll_t _sigpoll;
} _sifields_t _sifields;
}
enum
{
SI_ASYNCNL = -60,
SI_TKILL = -6,
SI_SIGIO,
SI_ASYNCIO,
SI_MESGQ,
SI_TIMER,
SI_QUEUE,
SI_USER,
SI_KERNEL = 0x80
}
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( OSX )
{
//SIG_HOLD
alias uint sigset_t;
// pid_t (defined in core.sys.types)
//SIGABRT (defined in core.stdc.signal)
//SIGFPE (defined in core.stdc.signal)
//SIGILL (defined in core.stdc.signal)
//SIGINT (defined in core.stdc.signal)
//SIGSEGV (defined in core.stdc.signal)
//SIGTERM (defined in core.stdc.signal)
//SA_NOCLDSTOP (CX|XSI)
//SIG_BLOCK
//SIG_UNBLOCK
//SIG_SETMASK
struct siginfo_t
{
int si_signo;
int si_errno;
int si_code;
pid_t si_pid;
uid_t si_uid;
int si_status;
void* si_addr;
sigval si_value;
int si_band;
uint pad[7];
}
//SI_USER
//SI_QUEUE
//SI_TIMER
//SI_ASYNCIO
//SI_MESGQ
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( freebsd )
{
struct sigset_t
{
uint __bits[4];
}
struct siginfo_t
{
int si_signo;
int si_errno;
int si_code;
pid_t si_pid;
uid_t si_uid;
int si_status;
void* si_addr;
sigval si_value;
union __reason
{
struct __fault
{
int _trapno;
}
__fault _fault;
struct __timer
{
int _timerid;
int _overrun;
}
__timer _timer;
struct __mesgq
{
int _mqd;
}
__mesgq _mesgq;
struct __poll
{
c_long _band;
}
__poll _poll;
struct ___spare___
{
c_long __spare1__;
int[7] __spare2__;
}
___spare___ __spare__;
}
__reason _reason;
}
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*);
}
//
// XOpen (XSI)
//
/*
SIGPOLL
SIGPROF
SIGSYS
SIGTRAP
SIGVTALRM
SIGXCPU
SIGXFSZ
SA_ONSTACK
SA_RESETHAND
SA_RESTART
SA_SIGINFO
SA_NOCLDWAIT
SA_NODEFER
SS_ONSTACK
SS_DISABLE
MINSIGSTKSZ
SIGSTKSZ
ucontext_t // from ucontext
mcontext_t // from ucontext
struct stack_t
{
void* ss_sp;
size_t ss_size;
int ss_flags;
}
struct sigstack
{
int ss_onstack;
void* ss_sp;
}
ILL_ILLOPC
ILL_ILLOPN
ILL_ILLADR
ILL_ILLTRP
ILL_PRVOPC
ILL_PRVREG
ILL_COPROC
ILL_BADSTK
FPE_INTDIV
FPE_INTOVF
FPE_FLTDIV
FPE_FLTOVF
FPE_FLTUND
FPE_FLTRES
FPE_FLTINV
FPE_FLTSUB
SEGV_MAPERR
SEGV_ACCERR
BUS_ADRALN
BUS_ADRERR
BUS_OBJERR
TRAP_BRKPT
TRAP_TRACE
CLD_EXITED
CLD_KILLED
CLD_DUMPED
CLD_TRAPPED
CLD_STOPPED
CLD_CONTINUED
POLL_IN
POLL_OUT
POLL_MSG
POLL_ERR
POLL_PRI
POLL_HUP
sigfn_t bsd_signal(int sig, sigfn_t func);
sigfn_t sigset(int sig, sigfn_t func);
int killpg(pid_t, int);
int sigaltstack(in stack_t*, stack_t*);
int sighold(int);
int sigignore(int);
int siginterrupt(int, int);
int sigpause(int);
int sigrelse(int);
*/
version( linux )
{
enum SIGPOLL = 29;
enum SIGPROF = 27;
enum SIGSYS = 31;
enum SIGTRAP = 5;
enum SIGVTALRM = 26;
enum SIGXCPU = 24;
enum SIGXFSZ = 25;
enum SA_ONSTACK = 0x08000000;
enum SA_RESETHAND = 0x80000000;
enum SA_RESTART = 0x10000000;
enum SA_SIGINFO = 4;
enum SA_NOCLDWAIT = 2;
enum SA_NODEFER = 0x40000000;
enum SS_ONSTACK = 1;
enum SS_DISABLE = 2;
enum MINSIGSTKSZ = 2048;
enum SIGSTKSZ = 8192;
//ucontext_t (defined in core.sys.posix.ucontext)
//mcontext_t (defined in core.sys.posix.ucontext)
struct stack_t
{
void* ss_sp;
int ss_flags;
size_t ss_size;
}
struct sigstack
{
void* ss_sp;
int ss_onstack;
}
enum
{
ILL_ILLOPC = 1,
ILL_ILLOPN,
ILL_ILLADR,
ILL_ILLTRP,
ILL_PRVOPC,
ILL_PRVREG,
ILL_COPROC,
ILL_BADSTK
}
enum
{
FPE_INTDIV = 1,
FPE_INTOVF,
FPE_FLTDIV,
FPE_FLTOVF,
FPE_FLTUND,
FPE_FLTRES,
FPE_FLTINV,
FPE_FLTSUB
}
enum
{
SEGV_MAPERR = 1,
SEGV_ACCERR
}
enum
{
BUS_ADRALN = 1,
BUS_ADRERR,
BUS_OBJERR
}
enum
{
TRAP_BRKPT = 1,
TRAP_TRACE
}
enum
{
CLD_EXITED = 1,
CLD_KILLED,
CLD_DUMPED,
CLD_TRAPPED,
CLD_STOPPED,
CLD_CONTINUED
}
enum
{
POLL_IN = 1,
POLL_OUT,
POLL_MSG,
POLL_ERR,
POLL_PRI,
POLL_HUP
}
sigfn_t bsd_signal(int sig, sigfn_t func);
sigfn_t sigset(int sig, sigfn_t func);
int killpg(pid_t, int);
int sigaltstack(in stack_t*, stack_t*);
int sighold(int);
int sigignore(int);
int siginterrupt(int, int);
int sigpause(int);
int sigrelse(int);
}
//
// Timer (TMR)
//
/*
NOTE: This should actually be defined in core.sys.posix.time.
It is defined here instead to break a circular import.
struct timespec
{
time_t tv_sec;
int tv_nsec;
}
*/
version( linux )
{
struct timespec
{
time_t tv_sec;
c_long tv_nsec;
}
}
else version( OSX )
{
struct timespec
{
time_t tv_sec;
c_long tv_nsec;
}
}
else version( freebsd )
{
struct timespec
{
time_t tv_sec;
c_long tv_nsec;
}
}
//
// Realtime Signals (RTS)
//
/*
struct sigevent
{
int sigev_notify;
int sigev_signo;
sigval sigev_value;
void(*)(sigval) sigev_notify_function;
pthread_attr_t* sigev_notify_attributes;
}
int sigqueue(pid_t, int, in sigval);
int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
int sigwaitinfo(in sigset_t*, siginfo_t*);
*/
version( linux )
{
private enum __SIGEV_MAX_SIZE = 64;
static if( false /* __WORDSIZE == 64 */ )
{
private enum __SIGEV_PAD_SIZE = ((__SIGEV_MAX_SIZE / int.sizeof) - 4);
}
else
{
private enum __SIGEV_PAD_SIZE = ((__SIGEV_MAX_SIZE / int.sizeof) - 3);
}
struct sigevent
{
sigval sigev_value;
int sigev_signo;
int sigev_notify;
union _sigev_un_t
{
int[__SIGEV_PAD_SIZE] _pad;
pid_t _tid;
struct _sigev_thread_t
{
void function(sigval) _function;
void* _attribute;
} _sigev_thread_t _sigev_thread;
} _sigev_un_t _sigev_un;
}
int sigqueue(pid_t, int, in sigval);
int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
int sigwaitinfo(in sigset_t*, siginfo_t*);
}
else version( freebsd )
{
struct sigevent
{
int sigev_notify;
int sigev_signo;
sigval sigev_value;
union _sigev_un
{
lwpid_t _threadid;
struct _sigev_thread
{
void function(sigval) _function;
void* _attribute;
}
c_long[8] __spare__;
}
}
int sigqueue(pid_t, int, in sigval);
int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
int sigwaitinfo(in sigset_t*, siginfo_t*);
}
//
// Threads (THR)
//
/*
int pthread_kill(pthread_t, int);
int pthread_sigmask(int, in sigset_t*, sigset_t*);
*/
version( linux )
{
int pthread_kill(pthread_t, int);
int pthread_sigmask(int, in sigset_t*, sigset_t*);
}
else version( OSX )
{
int pthread_kill(pthread_t, int);
int pthread_sigmask(int, in sigset_t*, sigset_t*);
}
else version( freebsd )
{
int pthread_kill(pthread_t, int);
int pthread_sigmask(int, in sigset_t*, sigset_t*);
}

View File

@@ -0,0 +1,219 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.stdio;
private import core.sys.posix.config;
public import core.stdc.stdio;
public import core.sys.posix.sys.types; // for off_t
extern (C):
//
// Required (defined in core.stdc.stdio)
//
/*
BUFSIZ
_IOFBF
_IOLBF
_IONBF
L_tmpnam
SEEK_CUR
SEEK_END
SEEK_SET
FILENAME_MAX
FOPEN_MAX
TMP_MAX
EOF
NULL
stderr
stdin
stdout
FILE
fpos_t
size_t
void clearerr(FILE*);
int fclose(FILE*);
int feof(FILE*);
int ferror(FILE*);
int fflush(FILE*);
int fgetc(FILE*);
int fgetpos(FILE*, fpos_t *);
char* fgets(char*, int, FILE*);
FILE* fopen(in char*, in char*);
int fprintf(FILE*, in char*, ...);
int fputc(int, FILE*);
int fputs(in char*, FILE*);
size_t fread(void *, size_t, size_t, FILE*);
FILE* freopen(in char*, in char*, FILE*);
int fscanf(FILE*, in char*, ...);
int fseek(FILE*, c_long, int);
int fsetpos(FILE*, in fpos_t*);
c_long ftell(FILE*);
size_t fwrite(in void *, size_t, size_t, FILE*);
int getc(FILE*);
int getchar();
char* gets(char*);
void perror(in char*);
int printf(in char*, ...);
int putc(int, FILE*);
int putchar(int);
int puts(in char*);
int remove(in char*);
int rename(in char*, in char*);
void rewind(FILE*);
int scanf(in char*, ...);
void setbuf(FILE*, char*);
int setvbuf(FILE*, char*, int, size_t);
int snprintf(char*, size_t, in char*, ...);
int sprintf(char*, in char*, ...);
int sscanf(in char*, in char*, int ...);
FILE* tmpfile();
char* tmpnam(char*);
int ungetc(int, FILE*);
int vfprintf(FILE*, in char*, va_list);
int vfscanf(FILE*, in char*, va_list);
int vprintf(in char*, va_list);
int vscanf(in char*, va_list);
int vsnprintf(char*, size_t, in char*, va_list);
int vsprintf(char*, in char*, va_list);
int vsscanf(in char*, in char*, va_list arg);
*/
version( linux )
{
static if( __USE_LARGEFILE64 )
{
int fgetpos64(FILE*, fpos_t *);
alias fgetpos64 fgetpos;
FILE* fopen64(in char*, in char*);
alias fopen64 fopen;
FILE* freopen64(in char*, in char*, FILE*);
alias freopen64 freopen;
int fseek64(FILE*, c_long, int);
alias fseek64 fseek;
int fsetpos64(FILE*, in fpos_t*);
alias fsetpos64 fsetpos;
FILE* tmpfile64();
alias tmpfile64 tmpfile;
}
else
{
int fgetpos(FILE*, fpos_t *);
FILE* fopen(in char*, in char*);
FILE* freopen(in char*, in char*, FILE*);
int fseek(FILE*, c_long, int);
int fsetpos(FILE*, in fpos_t*);
FILE* tmpfile();
}
}
//
// C Extension (CX)
//
/*
L_ctermid
char* ctermid(char*);
FILE* fdopen(int, in char*);
int fileno(FILE*);
int fseeko(FILE*, off_t, int);
off_t ftello(FILE*);
char* gets(char*);
FILE* popen(in char*, in char*);
*/
version( linux )
{
enum L_ctermid = 9;
static if( __USE_FILE_OFFSET64 )
{
int fseeko64(FILE*, off_t, int);
alias fseeko64 fseeko;
}
else
{
int fseeko(FILE*, off_t, int);
}
static if( __USE_LARGEFILE64 )
{
off_t ftello64(FILE*);
alias ftello64 ftello;
}
else
{
off_t ftello(FILE*);
}
}
else
{
int fseeko(FILE*, off_t, int);
off_t ftello(FILE*);
}
char* ctermid(char*);
FILE* fdopen(int, in char*);
int fileno(FILE*);
//int fseeko(FILE*, off_t, int);
//off_t ftello(FILE*);
char* gets(char*);
FILE* popen(in char*, in char*);
//
// Thread-Safe Functions (TSF)
//
/*
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);
*/
version( linux )
{
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);
}
//
// XOpen (XSI)
//
/*
P_tmpdir
va_list (defined in core.stdc.stdarg)
char* tempnam(in char*, in char*);
*/
version( linux )
{
enum P_tmpdir = "/tmp";
char* tempnam(in char*, in char*);
}

View File

@@ -0,0 +1,310 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.stdlib;
private import core.sys.posix.config;
public import core.stdc.stdlib;
public import core.sys.posix.sys.wait;
extern (C):
//
// Required (defined in core.stdc.stdlib)
//
/*
EXIT_FAILURE
EXIT_SUCCESS
NULL
RAND_MAX
MB_CUR_MAX
div_t
ldiv_t
lldiv_t
size_t
wchar_t
void _Exit(int);
void abort();
int abs(int);
int atexit(void function());
double atof(in char*);
int atoi(in char*);
c_long atol(in char*);
long atoll(in char*);
void* bsearch(in void*, in void*, size_t, size_t, int function(in void*, in void*));
void* calloc(size_t, size_t);
div_t div(int, int);
void exit(int);
void free(void*);
char* getenv(in char*);
c_long labs(c_long);
ldiv_t ldiv(c_long, c_long);
long llabs(long);
lldiv_t lldiv(long, long);
void* malloc(size_t);
int mblen(in char*, size_t);
size_t mbstowcs(wchar_t*, in char*, size_t);
int mbtowc(wchar_t*, in char*, size_t);
void qsort(void*, size_t, size_t, int function(in void*, in void*));
int rand();
void* realloc(void*, size_t);
void srand(uint);
double strtod(in char*, char**);
float strtof(in char*, char**);
c_long strtol(in char*, char**, int);
real strtold(in char*, char**);
long strtoll(in char*, char**, int);
c_ulong strtoul(in char*, char**, int);
ulong strtoull(in char*, char**, int);
int system(in char*);
size_t wcstombs(char*, in wchar_t*, size_t);
int wctomb(char*, wchar_t);
*/
//
// Advisory Information (ADV)
//
/*
int posix_memalign(void**, size_t, size_t);
*/
version( linux )
{
int posix_memalign(void**, size_t, size_t);
}
//
// C Extension (CX)
//
/*
int setenv(in char*, in char*, int);
int unsetenv(in char*);
*/
version( linux )
{
int setenv(in char*, in char*, int);
int unsetenv(in char*);
void* valloc(size_t); // LEGACY non-standard
}
else version( OSX )
{
int setenv(in char*, in char*, int);
int unsetenv(in char*);
void* valloc(size_t); // LEGACY non-standard
}
else version( freebsd )
{
int setenv(in char*, in char*, int);
int unsetenv(in char*);
void* valloc(size_t); // LEGACY non-standard
}
//
// Thread-Safe Functions (TSF)
//
/*
int rand_r(uint*);
*/
version( linux )
{
int rand_r(uint*);
}
else version( OSX )
{
int rand_r(uint*);
}
else version( freebsd )
{
int rand_r(uint*);
}
//
// XOpen (XSI)
//
/*
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(ushort[3]);
char* fcvt(double, int, int *, int *); // LEGACY
char* gcvt(double, int, char*); // LEGACY
// per spec: int getsubopt(char** char* const*, char**);
int getsubopt(char**, in char**, char**);
int grantpt(int);
char* initstate(uint, char*, size_t);
c_long jrand48(ushort[3]);
char* l64a(c_long);
void lcong48(ushort[7]);
c_long lrand48();
char* mktemp(char*); // LEGACY
int mkstemp(char*);
c_long mrand48();
c_long nrand48(ushort[3]);
int posix_openpt(int);
char* ptsname(int);
int putenv(char*);
c_long random();
char* realpath(in char*, char*);
ushort seed48(ushort[3]);
void setkey(in char*);
char* setstate(in char*);
void srand48(c_long);
void srandom(uint);
int unlockpt(int);
*/
version( linux )
{
//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(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(ushort[3]);
char* l64a(c_long);
void lcong48(ushort[7]);
c_long lrand48();
char* mktemp(char*); // LEGACY
//int mkstemp(char*);
c_long mrand48();
c_long nrand48(ushort[3]);
int posix_openpt(int);
char* ptsname(int);
int putenv(char*);
c_long random();
char* realpath(in char*, char*);
ushort seed48(ushort[3]);
void setkey(in char*);
char* setstate(in char*);
void srand48(c_long);
void srandom(uint);
int unlockpt(int);
static if( __USE_LARGEFILE64 )
{
int mkstemp64(char*);
alias mkstemp64 mkstemp;
}
else
{
int mkstemp(char*);
}
}
else version( OSX )
{
//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(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(ushort[3]);
char* l64a(c_long);
void lcong48(ushort[7]);
c_long lrand48();
char* mktemp(char*); // LEGACY
int mkstemp(char*);
c_long mrand48();
c_long nrand48(ushort[3]);
int posix_openpt(int);
char* ptsname(int);
int putenv(char*);
c_long random();
char* realpath(in char*, char*);
ushort seed48(ushort[3]);
void setkey(in char*);
char* setstate(in char*);
void srand48(c_long);
void srandom(uint);
int unlockpt(int);
}
else version( freebsd )
{
//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(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(ushort[3]);
char* l64a(c_long);
void lcong48(ushort[7]);
c_long lrand48();
char* mktemp(char*); // LEGACY
int mkstemp(char*);
c_long mrand48();
c_long nrand48(ushort[3]);
int posix_openpt(int);
char* ptsname(int);
int putenv(char*);
c_long random();
char* realpath(in char*, char*);
ushort seed48(ushort[3]);
void setkey(in char*);
char* setstate(in char*);
void srand48(c_long);
void srandom(uint);
int unlockpt(int);
}

View File

@@ -0,0 +1,104 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
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
extern (C):
//
// XOpen (XSI)
//
/*
struct ipc_perm
{
uid_t uid;
gid_t gid;
uid_t cuid;
gid_t cgid;
mode_t mode;
}
IPC_CREAT
IPC_EXCL
IPC_NOWAIT
IPC_PRIVATE
IPC_RMID
IPC_SET
IPC_STAT
key_t ftok(in char*, int);
*/
version( linux )
{
struct ipc_perm
{
key_t __key;
uid_t uid;
gid_t gid;
uid_t cuid;
gid_t cgid;
ushort mode;
ushort __pad1;
ushort __seq;
ushort __pad2;
c_ulong __unused1;
c_ulong __unused2;
}
enum IPC_CREAT = 01000;
enum IPC_EXCL = 02000;
enum IPC_NOWAIT = 04000;
enum key_t IPC_PRIVATE = 0;
enum IPC_RMID = 0;
enum IPC_SET = 1;
enum IPC_STAT = 2;
key_t ftok(in char*, int);
}
else version( OSX )
{
}
else version( freebsd )
{
struct ipc_perm
{
ushort cuid;
ushort cguid;
ushort uid;
ushort gid;
ushort mode;
ushort seq;
key_t key;
}
enum IPC_CREAT = 01000;
enum IPC_EXCL = 02000;
enum IPC_NOWAIT = 04000;
enum key_t IPC_PRIVATE = 0;
enum IPC_RMID = 0;
enum IPC_SET = 1;
enum IPC_STAT = 2;
key_t ftok(in char*, int);
}

View File

@@ -0,0 +1,313 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.sys.mman;
private import core.sys.posix.config;
public import core.stdc.stddef; // for size_t
public import core.sys.posix.sys.types; // for off_t, mode_t
extern (C):
//
// Advisory Information (ADV)
//
/*
int posix_madvise(void*, size_t, int);
*/
//
// Advisory Information and either Memory Mapped Files or Shared Memory Objects (MC1)
//
/*
POSIX_MADV_NORMAL
POSIX_MADV_SEQUENTIAL
POSIX_MADV_RANDOM
POSIX_MADV_WILLNEED
POSIX_MADV_DONTNEED
*/
version( linux )
{
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;
}
else version( OSX )
{
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;
}
else version( freebsd )
{
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;
}
//
// Memory Mapped Files, Shared Memory Objects, or Memory Protection (MC2)
//
/*
PROT_READ
PROT_WRITE
PROT_EXEC
PROT_NONE
*/
version( linux )
{
enum PROT_NONE = 0x0;
enum PROT_READ = 0x1;
enum PROT_WRITE = 0x2;
enum PROT_EXEC = 0x4;
}
else version( OSX )
{
enum PROT_NONE = 0x00;
enum PROT_READ = 0x01;
enum PROT_WRITE = 0x02;
enum PROT_EXEC = 0x04;
}
else version( freebsd )
{
enum PROT_NONE = 0x00;
enum PROT_READ = 0x01;
enum PROT_WRITE = 0x02;
enum PROT_EXEC = 0x04;
}
//
// Memory Mapped Files, Shared Memory Objects, or Typed Memory Objects (MC3)
//
/*
void* mmap(void*, size_t, int, int, int, off_t);
int munmap(void*, size_t);
*/
version( linux )
{
//void* mmap(void*, size_t, int, int, int, off_t);
int munmap(void*, size_t);
static if( __USE_LARGEFILE64 )
{
void* mmap64(void*, size_t, int, int, int, off_t);
alias mmap64 mmap;
}
else
{
void* mmap(void*, size_t, int, int, int, off_t);
}
}
else version( OSX )
{
void* mmap(void*, size_t, int, int, int, off_t);
int munmap(void*, size_t);
}
else version( freebsd )
{
void* mmap(void*, size_t, int, int, int, off_t);
int munmap(void*, size_t);
}
//
// Memory Mapped Files (MF)
//
/*
MAP_SHARED (MF|SHM)
MAP_PRIVATE (MF|SHM)
MAP_FIXED (MF|SHM)
MAP_FAILED (MF|SHM)
MS_ASYNC (MF|SIO)
MS_SYNC (MF|SIO)
MS_INVALIDATE (MF|SIO)
int msync(void*, size_t, int); (MF|SIO)
*/
version( linux )
{
enum MAP_SHARED = 0x01;
enum MAP_PRIVATE = 0x02;
enum MAP_FIXED = 0x10;
enum MAP_ANON = 0x20; // non-standard
enum MAP_FAILED = cast(void*) -1;
enum
{
MS_ASYNC = 1,
MS_SYNC = 4,
MS_INVALIDATE = 2
}
int msync(void*, size_t, int);
}
else version( OSX )
{
enum MAP_SHARED = 0x0001;
enum MAP_PRIVATE = 0x0002;
enum MAP_FIXED = 0x0010;
enum MAP_ANON = 0x1000; // non-standard
enum MAP_FAILED = cast(void*)-1;
enum MS_ASYNC = 0x0001;
enum MS_INVALIDATE = 0x0002;
enum MS_SYNC = 0x0010;
int msync(void*, size_t, int);
}
else version( freebsd )
{
enum MAP_SHARED = 0x0001;
enum MAP_PRIVATE = 0x0002;
enum MAP_FIXED = 0x0010;
enum MAP_ANON = 0x1000; // non-standard
enum MAP_FAILED = cast(void*)-1;
enum MS_SYNC = 0x0000;
enum MS_ASYNC = 0x0001;
enum MS_INVALIDATE = 0x0002;
int msync(void*, size_t, int);
}
//
// Process Memory Locking (ML)
//
/*
MCL_CURRENT
MCL_FUTURE
int mlockall(int);
int munlockall();
*/
version( linux )
{
enum MCL_CURRENT = 1;
enum MCL_FUTURE = 2;
int mlockall(int);
int munlockall();
}
else version( OSX )
{
enum MCL_CURRENT = 0x0001;
enum MCL_FUTURE = 0x0002;
int mlockall(int);
int munlockall();
}
else version( freebsd )
{
enum MCL_CURRENT = 0x0001;
enum MCL_FUTURE = 0x0002;
int mlockall(int);
int munlockall();
}
//
// Range Memory Locking (MLR)
//
/*
int mlock(in void*, size_t);
int munlock(in void*, size_t);
*/
version( linux )
{
int mlock(in void*, size_t);
int munlock(in void*, size_t);
}
else version( OSX )
{
int mlock(in void*, size_t);
int munlock(in void*, size_t);
}
else version( freebsd )
{
int mlock(in void*, size_t);
int munlock(in void*, size_t);
}
//
// Memory Protection (MPR)
//
/*
int mprotect(void*, size_t, int);
*/
version( OSX )
{
int mprotect(void*, size_t, int);
}
else version( freebsd )
{
int mprotect(void*, size_t, int);
}
//
// Shared Memory Objects (SHM)
//
/*
int shm_open(in char*, int, mode_t);
int shm_unlink(in char*);
*/
version( linux )
{
int shm_open(in char*, int, mode_t);
int shm_unlink(in char*);
}
else version( OSX )
{
int shm_open(in char*, int, mode_t);
int shm_unlink(in char*);
}
else version( freebsd )
{
int shm_open(in char*, int, mode_t);
int shm_unlink(in char*);
}
//
// Typed Memory Objects (TYM)
//
/*
POSIX_TYPED_MEM_ALLOCATE
POSIX_TYPED_MEM_ALLOCATE_CONTIG
POSIX_TYPED_MEM_MAP_ALLOCATABLE
struct posix_typed_mem_info
{
size_t posix_tmi_length;
}
int posix_mem_offset(in void*, size_t, off_t *, size_t *, int *);
int posix_typed_mem_get_info(int, struct posix_typed_mem_info *);
int posix_typed_mem_open(in char*, int, int);
*/

View File

@@ -0,0 +1,180 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.sys.select;
private import core.sys.posix.config;
public import core.stdc.time; // for timespec
public import core.sys.posix.sys.time; // for timeval
public import core.sys.posix.sys.types; // for time_t
public import core.sys.posix.signal; // for sigset_t
extern (C):
//
// Required
//
/*
NOTE: This module requires timeval from core.sys.posix.sys.time, but timeval
is supposedly an XOpen extension. As a result, this header will not
compile on platforms that are not XSI-compliant. This must be resolved
on a per-platform basis.
fd_set
void FD_CLR(int fd, fd_set* fdset);
int FD_ISSET(int fd, fd_set* fdset);
void FD_SET(int fd, fd_set* fdset);
void FD_ZERO(fd_set* fdset);
FD_SETSIZE
int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
int select(int, fd_set*, fd_set*, fd_set*, timeval*);
*/
version( linux )
{
private
{
alias c_long __fd_mask;
enum __NFDBITS = 8 * __fd_mask.sizeof;
extern (D) int __FDELT( int d )
{
return d / __NFDBITS;
}
extern (D) int __FDMASK( int d )
{
return cast(__fd_mask) 1 << ( d % __NFDBITS );
}
}
enum FD_SETSIZE = 1024;
struct fd_set
{
__fd_mask[FD_SETSIZE / __NFDBITS] fds_bits;
}
extern (D) void FD_CLR( int fd, fd_set* fdset )
{
fdset.fds_bits[__FDELT( fd )] &= ~__FDMASK( fd );
}
extern (D) int FD_ISSET( int fd, fd_set* fdset )
{
return fdset.fds_bits[__FDELT( fd )] & __FDMASK( fd );
}
extern (D) void FD_SET( int fd, fd_set* fdset )
{
fdset.fds_bits[__FDELT( fd )] |= __FDMASK( fd );
}
extern (D) void FD_ZERO( fd_set* fdset )
{
fdset.fds_bits[0 .. $] = 0;
}
/+
+ GNU ASM Implementation
+
# define __FD_ZERO(fdsp) \
do { \
int __d0, __d1; \
__asm__ __volatile__ ("cld; rep; stosl" \
: "=c" (__d0), "=D" (__d1) \
: "a" (0), "0" (sizeof (fd_set) \
/ sizeof (__fd_mask)), \
"1" (&__FDS_BITS (fdsp)[0]) \
: "memory"); \
} while (0)
# define __FD_SET(fd, fdsp) \
__asm__ __volatile__ ("btsl %1,%0" \
: "=m" (__FDS_BITS (fdsp)[__FDELT (fd)]) \
: "r" (((int) (fd)) % __NFDBITS) \
: "cc","memory")
# define __FD_CLR(fd, fdsp) \
__asm__ __volatile__ ("btrl %1,%0" \
: "=m" (__FDS_BITS (fdsp)[__FDELT (fd)]) \
: "r" (((int) (fd)) % __NFDBITS) \
: "cc","memory")
# define __FD_ISSET(fd, fdsp) \
(__extension__ \
({register char __result; \
__asm__ __volatile__ ("btl %1,%2 ; setcb %b0" \
: "=q" (__result) \
: "r" (((int) (fd)) % __NFDBITS), \
"m" (__FDS_BITS (fdsp)[__FDELT (fd)]) \
: "cc"); \
__result; }))
+/
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 )
{
private
{
enum uint __DARWIN_NBBY = 8; /* bits in a byte */
enum uint __DARWIN_NFDBITS = (int.sizeof * __DARWIN_NBBY); /* bits per mask */
}
enum FD_SETSIZE = 1024;
struct fd_set
{
int[(FD_SETSIZE + (__DARWIN_NFDBITS - 1)) / __DARWIN_NFDBITS] fds_bits;
}
extern (D) void FD_CLR( int fd, fd_set* fdset )
{
fdset.fds_bits[fd / __DARWIN_NFDBITS] &= ~(1 << (fd % __DARWIN_NFDBITS));
}
extern (D) int FD_ISSET( int fd, fd_set* fdset )
{
return fdset.fds_bits[fd / __DARWIN_NFDBITS] & (1 << (fd % __DARWIN_NFDBITS));
}
extern (D) void FD_SET( int fd, fd_set* fdset )
{
fdset.fds_bits[fd / __DARWIN_NFDBITS] |= 1 << (fd % __DARWIN_NFDBITS);
}
extern (D) void FD_ZERO( fd_set* fdset )
{
fdset.fds_bits[0 .. $] = 0;
}
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( freebsd )
{
private
{
enum uint _NFDBITS = c_ulong.sizeof * 8;
}
enum uint FD_SETSIZE = 1024;
struct fd_set
{
c_ulong fds_bits[(FD_SETSIZE + (_NFDBITS - 1)) / _NFDBITS];
}
}

View File

@@ -0,0 +1,116 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.sys.shm;
private import core.sys.posix.config;
public import core.sys.posix.sys.types; // for pid_t, time_t, key_t, size_t
public import core.sys.posix.sys.ipc;
extern (C):
//
// XOpen (XSI)
//
/*
SHM_RDONLY
SHM_RND
SHMLBA
shmatt_t
struct shmid_ds
{
ipc_perm shm_perm;
size_t shm_segsz;
pid_t shm_lpid;
pid_t shm_cpid;
shmatt_t shm_nattch;
time_t shm_atime;
time_t shm_dtime;
time_t shm_ctime;
}
void* shmat(int, in void*, int);
int shmctl(int, int, shmid_ds*);
int shmdt(in void*);
int shmget(key_t, size_t, int);
*/
version( linux )
{
enum SHM_RDONLY = 010000;
enum SHM_RND = 020000;
int __getpagesize();
alias __getpagesize SHMLBA;
alias c_ulong shmatt_t;
struct shmid_ds
{
ipc_perm shm_perm;
size_t shm_segsz;
time_t shm_atime;
c_ulong __unused1;
time_t shm_dtime;
c_ulong __unused2;
time_t shm_ctime;
c_ulong __unused3;
pid_t shm_cpid;
pid_t shm_lpid;
shmatt_t shm_nattch;
c_ulong __unused4;
c_ulong __unused5;
}
void* shmat(int, in void*, int);
int shmctl(int, int, shmid_ds*);
int shmdt(in void*);
int shmget(key_t, size_t, int);
}
else version( freebsd )
{
enum SHM_RDONLY = 010000;
enum SHM_RND = 020000;
enum SHMLBA = 1 << 12; // PAGE_SIZE = (1<<PAGE_SHIFT)
alias c_ulong shmatt_t;
struct shmid_ds
{
ipc_perm shm_perm;
size_t shm_segsz;
time_t shm_atime;
c_ulong __unused1;
time_t shm_dtime;
c_ulong __unused2;
time_t shm_ctime;
c_ulong __unused3;
pid_t shm_cpid;
pid_t shm_lpid;
shmatt_t shm_nattch;
c_ulong __unused4;
c_ulong __unused5;
}
void* shmat(int, in void*, int);
int shmctl(int, int, shmid_ds*);
int shmdt(in void*);
int shmget(key_t, size_t, int);
}
else version( OSX )
{
}

View File

@@ -0,0 +1,647 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.sys.socket;
private import core.sys.posix.config;
public import core.sys.posix.sys.types; // for ssize_t, size_t
public import core.sys.posix.sys.uio; // for iovec
extern (C):
//
// Required
//
/*
socklen_t
sa_family_t
struct sockaddr
{
sa_family_t sa_family;
char sa_data[];
}
struct sockaddr_storage
{
sa_family_t ss_family;
}
struct msghdr
{
void* msg_name;
socklen_t msg_namelen;
struct iovec* msg_iov;
int msg_iovlen;
void* msg_control;
socklen_t msg_controllen;
int msg_flags;
}
struct iovec {} // from core.sys.posix.sys.uio
struct cmsghdr
{
socklen_t cmsg_len;
int cmsg_level;
int cmsg_type;
}
SCM_RIGHTS
CMSG_DATA(cmsg)
CMSG_NXTHDR(mhdr,cmsg)
CMSG_FIRSTHDR(mhdr)
struct linger
{
int l_onoff;
int l_linger;
}
SOCK_DGRAM
SOCK_SEQPACKET
SOCK_STREAM
SOL_SOCKET
SO_ACCEPTCONN
SO_BROADCAST
SO_DEBUG
SO_DONTROUTE
SO_ERROR
SO_KEEPALIVE
SO_LINGER
SO_OOBINLINE
SO_RCVBUF
SO_RCVLOWAT
SO_RCVTIMEO
SO_REUSEADDR
SO_SNDBUF
SO_SNDLOWAT
SO_SNDTIMEO
SO_TYPE
SOMAXCONN
MSG_CTRUNC
MSG_DONTROUTE
MSG_EOR
MSG_OOB
MSG_PEEK
MSG_TRUNC
MSG_WAITALL
AF_INET
AF_UNIX
AF_UNSPEC
SHUT_RD
SHUT_RDWR
SHUT_WR
int accept(int, sockaddr*, socklen_t*);
int bind(int, in sockaddr*, socklen_t);
int connect(int, in sockaddr*, socklen_t);
int getpeername(int, sockaddr*, socklen_t*);
int getsockname(int, sockaddr*, socklen_t*);
int getsockopt(int, int, int, void*, socklen_t*);
int listen(int, int);
ssize_t recv(int, void*, size_t, int);
ssize_t recvfrom(int, void*, size_t, int, sockaddr*, socklen_t*);
ssize_t recvmsg(int, msghdr*, int);
ssize_t send(int, in void*, size_t, int);
ssize_t sendmsg(int, in msghdr*, int);
ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
int setsockopt(int, int, int, in void*, socklen_t);
int shutdown(int, int);
int socket(int, int, int);
int sockatmark(int);
int socketpair(int, int, int, int[2]);
*/
version( linux )
{
alias uint socklen_t;
alias ushort sa_family_t;
struct sockaddr
{
sa_family_t sa_family;
byte[14] sa_data;
}
private enum : size_t
{
_SS_SIZE = 128,
_SS_PADSIZE = _SS_SIZE - (c_ulong.sizeof * 2)
}
struct sockaddr_storage
{
sa_family_t ss_family;
c_ulong __ss_align;
byte[_SS_PADSIZE] __ss_padding;
}
struct msghdr
{
void* msg_name;
socklen_t msg_namelen;
iovec* msg_iov;
size_t msg_iovlen;
void* msg_control;
size_t msg_controllen;
int msg_flags;
}
struct cmsghdr
{
size_t cmsg_len;
int cmsg_level;
int cmsg_type;
static if( false /* (!is( __STRICT_ANSI__ ) && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L */ )
{
ubyte[1] __cmsg_data;
}
}
enum : uint
{
SCM_RIGHTS = 0x01
}
static if( false /* (!is( __STRICT_ANSI__ ) && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L */ )
{
extern (D) ubyte[1] CMSG_DATA( cmsghdr* cmsg ) { return cmsg.__cmsg_data; }
}
else
{
extern (D) ubyte* CMSG_DATA( cmsghdr* cmsg ) { return cast(ubyte*)( cmsg + 1 ); }
}
private cmsghdr* __cmsg_nxthdr(msghdr*, cmsghdr*);
alias __cmsg_nxthdr CMSG_NXTHDR;
extern (D) size_t CMSG_FIRSTHDR( msghdr* mhdr )
{
return cast(size_t)( mhdr.msg_controllen >= cmsghdr.sizeof
? cast(cmsghdr*) mhdr.msg_control
: cast(cmsghdr*) null );
}
struct linger
{
int l_onoff;
int l_linger;
}
enum
{
SOCK_DGRAM = 2,
SOCK_SEQPACKET = 5,
SOCK_STREAM = 1
}
enum
{
SOL_SOCKET = 1
}
enum
{
SO_ACCEPTCONN = 30,
SO_BROADCAST = 6,
SO_DEBUG = 1,
SO_DONTROUTE = 5,
SO_ERROR = 4,
SO_KEEPALIVE = 9,
SO_LINGER = 13,
SO_OOBINLINE = 10,
SO_RCVBUF = 8,
SO_RCVLOWAT = 18,
SO_RCVTIMEO = 20,
SO_REUSEADDR = 2,
SO_SNDBUF = 7,
SO_SNDLOWAT = 19,
SO_SNDTIMEO = 21,
SO_TYPE = 3
}
enum
{
SOMAXCONN = 128
}
enum : uint
{
MSG_CTRUNC = 0x08,
MSG_DONTROUTE = 0x04,
MSG_EOR = 0x80,
MSG_OOB = 0x01,
MSG_PEEK = 0x02,
MSG_TRUNC = 0x20,
MSG_WAITALL = 0x100
}
enum
{
AF_INET = 2,
AF_UNIX = 1,
AF_UNSPEC = 0
}
enum
{
SHUT_RD,
SHUT_WR,
SHUT_RDWR
}
int accept(int, sockaddr*, socklen_t*);
int bind(int, in sockaddr*, socklen_t);
int connect(int, in sockaddr*, socklen_t);
int getpeername(int, sockaddr*, socklen_t*);
int getsockname(int, sockaddr*, socklen_t*);
int getsockopt(int, int, int, void*, socklen_t*);
int listen(int, int);
ssize_t recv(int, void*, size_t, int);
ssize_t recvfrom(int, void*, size_t, int, sockaddr*, socklen_t*);
ssize_t recvmsg(int, msghdr*, int);
ssize_t send(int, in void*, size_t, int);
ssize_t sendmsg(int, in msghdr*, int);
ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
int setsockopt(int, int, int, in void*, socklen_t);
int shutdown(int, int);
int socket(int, int, int);
int sockatmark(int);
int socketpair(int, int, int, int[2]);
}
else version( OSX )
{
alias uint socklen_t;
alias ubyte sa_family_t;
struct sockaddr
{
ubyte sa_len;
sa_family_t sa_family;
byte[14] sa_data;
}
private enum : size_t
{
_SS_PAD1 = long.sizeof - ubyte.sizeof - sa_family_t.sizeof,
_SS_PAD2 = 128 - ubyte.sizeof - sa_family_t.sizeof - _SS_PAD1 - long.sizeof
}
struct sockaddr_storage
{
ubyte ss_len;
sa_family_t ss_family;
byte[_SS_PAD1] __ss_pad1;
long __ss_align;
byte[_SS_PAD2] __ss_pad2;
}
struct msghdr
{
void* msg_name;
socklen_t msg_namelen;
iovec* msg_iov;
int msg_iovlen;
void* msg_control;
socklen_t msg_controllen;
int msg_flags;
}
struct cmsghdr
{
socklen_t cmsg_len;
int cmsg_level;
int cmsg_type;
}
enum : uint
{
SCM_RIGHTS = 0x01
}
/+
CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \
ALIGN(sizeof(struct cmsghdr)))
CMSG_NXTHDR(mhdr, cmsg) \
(((unsigned char *)(cmsg) + ALIGN((cmsg)->cmsg_len) + \
ALIGN(sizeof(struct cmsghdr)) > \
(unsigned char *)(mhdr)->msg_control +(mhdr)->msg_controllen) ? \
(struct cmsghdr *)0 /* NULL */ : \
(struct cmsghdr *)((unsigned char *)(cmsg) + ALIGN((cmsg)->cmsg_len)))
CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control)
+/
struct linger
{
int l_onoff;
int l_linger;
}
enum
{
SOCK_DGRAM = 2,
SOCK_SEQPACKET = 5,
SOCK_STREAM = 1
}
enum : uint
{
SOL_SOCKET = 0xffff
}
enum : uint
{
SO_ACCEPTCONN = 0x0002,
SO_BROADCAST = 0x0020,
SO_DEBUG = 0x0001,
SO_DONTROUTE = 0x0010,
SO_ERROR = 0x1007,
SO_KEEPALIVE = 0x0008,
SO_LINGER = 0x1080,
SO_OOBINLINE = 0x0100,
SO_RCVBUF = 0x1002,
SO_RCVLOWAT = 0x1004,
SO_RCVTIMEO = 0x1006,
SO_REUSEADDR = 0x0004,
SO_SNDBUF = 0x1001,
SO_SNDLOWAT = 0x1003,
SO_SNDTIMEO = 0x1005,
SO_TYPE = 0x1008
}
enum
{
SOMAXCONN = 128
}
enum : uint
{
MSG_CTRUNC = 0x20,
MSG_DONTROUTE = 0x4,
MSG_EOR = 0x8,
MSG_OOB = 0x1,
MSG_PEEK = 0x2,
MSG_TRUNC = 0x10,
MSG_WAITALL = 0x40
}
enum
{
AF_INET = 2,
AF_UNIX = 1,
AF_UNSPEC = 0
}
enum
{
SHUT_RD,
SHUT_WR,
SHUT_RDWR
}
int accept(int, sockaddr*, socklen_t*);
int bind(int, in sockaddr*, socklen_t);
int connect(int, in sockaddr*, socklen_t);
int getpeername(int, sockaddr*, socklen_t*);
int getsockname(int, sockaddr*, socklen_t*);
int getsockopt(int, int, int, void*, socklen_t*);
int listen(int, int);
ssize_t recv(int, void*, size_t, int);
ssize_t recvfrom(int, void*, size_t, int, sockaddr*, socklen_t*);
ssize_t recvmsg(int, msghdr*, int);
ssize_t send(int, in void*, size_t, int);
ssize_t sendmsg(int, in msghdr*, int);
ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
int setsockopt(int, int, int, in void*, socklen_t);
int shutdown(int, int);
int socket(int, int, int);
int sockatmark(int);
int socketpair(int, int, int, int[2]);
}
else version( freebsd )
{
alias uint socklen_t;
alias ubyte sa_family_t;
struct sockaddr
{
ubyte sa_len;
sa_family_t sa_family;
byte[14] sa_data;
}
private
{
enum _SS_ALIGNSIZE = long.sizeof;
enum _SS_MAXSIZE = 128;
enum _SS_PAD1SIZE = _SS_ALIGNSIZE - ubyte.sizeof - sa_family_t.sizeof;
enum _SS_PAD2SIZE = _SS_MAXSIZE - ubyte.sizeof - sa_family_t.sizeof - _SS_PAD1SIZE - _SS_ALIGNSIZE;
}
struct sockaddr_storage
{
ubyte ss_len;
sa_family_t ss_family;
byte[_SS_PAD1SIZE] __ss_pad1;
long __ss_align;
byte[_SS_PAD2SIZE] __ss_pad2;
}
struct msghdr
{
void* msg_name;
socklen_t msg_namelen;
iovec* msg_iov;
int msg_iovlen;
void* msg_control;
socklen_t msg_controllen;
int msg_flags;
}
struct cmsghdr
{
socklen_t cmsg_len;
int cmsg_level;
int cmsg_type;
}
enum : uint
{
SCM_RIGHTS = 0x01
}
/+
CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \
ALIGN(sizeof(struct cmsghdr)))
CMSG_NXTHDR(mhdr, cmsg) \
(((unsigned char *)(cmsg) + ALIGN((cmsg)->cmsg_len) + \
ALIGN(sizeof(struct cmsghdr)) > \
(unsigned char *)(mhdr)->msg_control +(mhdr)->msg_controllen) ? \
(struct cmsghdr *)0 /* NULL */ : \
(struct cmsghdr *)((unsigned char *)(cmsg) + ALIGN((cmsg)->cmsg_len)))
CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control)
+/
struct linger
{
int l_onoff;
int l_linger;
}
enum
{
SOCK_DGRAM = 2,
SOCK_SEQPACKET = 5,
SOCK_STREAM = 1
}
enum : uint
{
SOL_SOCKET = 0xffff
}
enum : uint
{
SO_ACCEPTCONN = 0x0002,
SO_BROADCAST = 0x0020,
SO_DEBUG = 0x0001,
SO_DONTROUTE = 0x0010,
SO_ERROR = 0x1007,
SO_KEEPALIVE = 0x0008,
SO_LINGER = 0x1080,
SO_OOBINLINE = 0x0100,
SO_RCVBUF = 0x1002,
SO_RCVLOWAT = 0x1004,
SO_RCVTIMEO = 0x1006,
SO_REUSEADDR = 0x0004,
SO_SNDBUF = 0x1001,
SO_SNDLOWAT = 0x1003,
SO_SNDTIMEO = 0x1005,
SO_TYPE = 0x1008
}
enum
{
SOMAXCONN = 128
}
enum : uint
{
MSG_CTRUNC = 0x20,
MSG_DONTROUTE = 0x4,
MSG_EOR = 0x8,
MSG_OOB = 0x1,
MSG_PEEK = 0x2,
MSG_TRUNC = 0x10,
MSG_WAITALL = 0x40
}
enum
{
AF_INET = 2,
AF_UNIX = 1,
AF_UNSPEC = 0
}
enum
{
SHUT_RD = 0,
SHUT_WR = 1,
SHUT_RDWR = 2
}
int accept(int, sockaddr*, socklen_t*);
int bind(int, in sockaddr*, socklen_t);
int connect(int, in sockaddr*, socklen_t);
int getpeername(int, sockaddr*, socklen_t*);
int getsockname(int, sockaddr*, socklen_t*);
int getsockopt(int, int, int, void*, socklen_t*);
int listen(int, int);
ssize_t recv(int, void*, size_t, int);
ssize_t recvfrom(int, void*, size_t, int, sockaddr*, socklen_t*);
ssize_t recvmsg(int, msghdr*, int);
ssize_t send(int, in void*, size_t, int);
ssize_t sendmsg(int, in msghdr*, int);
ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
int setsockopt(int, int, int, in void*, socklen_t);
int shutdown(int, int);
int socket(int, int, int);
int sockatmark(int);
int socketpair(int, int, int, int[2]);
}
//
// IPV6 (IP6)
//
/*
AF_INET6
*/
version( linux )
{
enum
{
AF_INET6 = 10
}
}
else version( OSX )
{
enum
{
AF_INET6 = 30
}
}
else version( freebsd )
{
enum
{
AF_INET6 = 28
}
}
//
// Raw Sockets (RS)
//
/*
SOCK_RAW
*/
version( linux )
{
enum
{
SOCK_RAW = 3
}
}
else version( OSX )
{
enum
{
SOCK_RAW = 3
}
}
else version( freebsd )
{
enum
{
SOCK_RAW = 3
}
}

View File

@@ -0,0 +1,425 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.sys.stat;
private import core.sys.posix.config;
private import core.stdc.stdint;
private import core.sys.posix.time; // for timespec
public import core.stdc.stddef; // for size_t
public import core.sys.posix.sys.types; // for off_t, mode_t
extern (C):
//
// Required
//
/*
struct stat
{
dev_t st_dev;
ino_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
off_t st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
}
S_IRWXU
S_IRUSR
S_IWUSR
S_IXUSR
S_IRWXG
S_IRGRP
S_IWGRP
S_IXGRP
S_IRWXO
S_IROTH
S_IWOTH
S_IXOTH
S_ISUID
S_ISGID
S_ISVTX
S_ISBLK(m)
S_ISCHR(m)
S_ISDIR(m)
S_ISFIFO(m)
S_ISREG(m)
S_ISLNK(m)
S_ISSOCK(m)
S_TYPEISMQ(buf)
S_TYPEISSEM(buf)
S_TYPEISSHM(buf)
int chmod(in char*, mode_t);
int fchmod(int, mode_t);
int fstat(int, stat*);
int lstat(in char*, stat*);
int mkdir(in char*, mode_t);
int mkfifo(in char*, mode_t);
int stat(in char*, stat*);
mode_t umask(mode_t);
*/
version( linux )
{
static if( __USE_LARGEFILE64 )
{
private alias uint _pad_t;
}
else
{
private alias ushort _pad_t;
}
struct stat_t
{
dev_t st_dev;
_pad_t __pad1;
static if( __USE_FILE_OFFSET64 )
{
ino_t __st_ino;
}
else
{
ino_t st_ino;
}
mode_t st_mode;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
dev_t st_rdev;
_pad_t __pad2;
off_t st_size;
blksize_t st_blksize;
blkcnt_t st_blocks;
static if( false /*__USE_MISC*/ ) // true if _BSD_SOURCE || _SVID_SOURCE
{
timespec st_atim;
timespec st_mtim;
timespec st_ctim;
alias st_atim.tv_sec st_atime;
alias st_mtim.tv_sec st_mtime;
alias st_ctim.tv_sec st_ctime;
}
else
{
time_t st_atime;
c_ulong st_atimensec;
time_t st_mtime;
c_ulong st_mtimensec;
time_t st_ctime;
c_ulong st_ctimensec;
}
static if( __USE_FILE_OFFSET64 )
{
ino_t st_ino;
}
else
{
c_ulong __unused4;
c_ulong __unused5;
}
}
enum S_IRUSR = 0400;
enum S_IWUSR = 0200;
enum S_IXUSR = 0100;
enum S_IRWXU = S_IRUSR | S_IWUSR | S_IXUSR;
enum S_IRGRP = S_IRUSR >> 3;
enum S_IWGRP = S_IWUSR >> 3;
enum S_IXGRP = S_IXUSR >> 3;
enum S_IRWXG = S_IRWXU >> 3;
enum S_IROTH = S_IRGRP >> 3;
enum S_IWOTH = S_IWGRP >> 3;
enum S_IXOTH = S_IXGRP >> 3;
enum S_IRWXO = S_IRWXG >> 3;
enum S_ISUID = 04000;
enum S_ISGID = 02000;
enum S_ISVTX = 01000;
private
{
extern (D) bool S_ISTYPE( mode_t mode, uint mask )
{
return ( mode & S_IFMT ) == mask;
}
}
extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); }
extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); }
extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); }
extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); }
extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); }
extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); }
extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
static if( true /*__USE_POSIX199309*/ )
{
extern bool S_TYPEISMQ( stat_t* buf ) { return false; }
extern bool S_TYPEISSEM( stat_t* buf ) { return false; }
extern bool S_TYPEISSHM( stat_t* buf ) { return false; }
}
}
else version( OSX )
{
struct stat_t
{
dev_t st_dev;
ino_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
dev_t st_rdev;
static if( false /*!_POSIX_C_SOURCE || _DARWIN_C_SOURCE*/ )
{
timespec st_atimespec;
timespec st_mtimespec;
timespec st_ctimespec;
}
else
{
time_t st_atime;
c_long st_atimensec;
time_t st_mtime;
c_long st_mtimensec;
time_t st_ctime;
c_long st_ctimensec;
}
off_t st_size;
blkcnt_t st_blocks;
blksize_t st_blksize;
uint st_flags;
uint st_gen;
int st_lspare;
long st_qspare[2];
}
enum S_IRUSR = 0400;
enum S_IWUSR = 0200;
enum S_IXUSR = 0100;
enum S_IRWXU = S_IRUSR | S_IWUSR | S_IXUSR;
enum S_IRGRP = S_IRUSR >> 3;
enum S_IWGRP = S_IWUSR >> 3;
enum S_IXGRP = S_IXUSR >> 3;
enum S_IRWXG = S_IRWXU >> 3;
enum S_IROTH = S_IRGRP >> 3;
enum S_IWOTH = S_IWGRP >> 3;
enum S_IXOTH = S_IXGRP >> 3;
enum S_IRWXO = S_IRWXG >> 3;
enum S_ISUID = 04000;
enum S_ISGID = 02000;
enum S_ISVTX = 01000;
private
{
extern (D) bool S_ISTYPE( mode_t mode, uint mask )
{
return ( mode & S_IFMT ) == mask;
}
}
extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); }
extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); }
extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); }
extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); }
extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); }
extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); }
extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
}
else version( freebsd )
{
struct stat_t
{
dev_t st_dev;
ino_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
dev_t st_rdev;
timespec st_atimespec;
timespec st_mtimespec;
timespec st_ctimespec;
time_t st_atime()
{
return st_atimespec.tv_sec;
}
time_t st_mtime()
{
return st_mtimespec.tv_sec;
}
time_t st_ctime()
{
return st_ctimespec.tv_sec;
}
off_t st_size;
blkcnt_t st_blocks;
blksize_t st_blksize;
fflags_t st_flags;
uint st_gen;
int st_lspare;
timespec st_birthtimespec;
byte[16 - timespec.sizeof] padding;
}
enum S_IRUSR = 0000400;
enum S_IWUSR = 0000200;
enum S_IXUSR = 0000100;
enum S_IRWXU = 0000700;
enum S_IRGRP = 0000040;
enum S_IWGRP = 0000020;
enum S_IXGRP = 0000010;
enum S_IRWXG = 0000070;
enum S_IROTH = 0000004;
enum S_IWOTH = 0000002;
enum S_IXOTH = 0000001;
enum S_IRWXO = 0000007;
enum S_ISUID = 0004000;
enum S_ISGID = 0002000;
enum S_ISVTX = 0001000;
private
{
extern (D) bool S_ISTYPE( mode_t mode, uint mask )
{
return ( mode & S_IFMT ) == mask;
}
}
extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); }
extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); }
extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); }
extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); }
extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); }
extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); }
extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
}
int chmod(in char*, mode_t);
int fchmod(int, mode_t);
//int fstat(int, stat_t*);
//int lstat(in char*, stat_t*);
int mkdir(in char*, mode_t);
int mkfifo(in char*, mode_t);
//int stat(in char*, stat_t*);
mode_t umask(mode_t);
version( linux )
{
static if( __USE_LARGEFILE64 )
{
int fstat64(int, stat_t*);
alias fstat64 fstat;
int lstat64(in char*, stat_t*);
alias lstat64 lstat;
int stat64(in char*, stat_t*);
alias stat64 stat;
}
else
{
int fstat(int, stat_t*);
int lstat(in char*, stat_t*);
int stat(in char*, stat_t*);
}
}
else
{
int fstat(int, stat_t*);
int lstat(in char*, stat_t*);
int stat(in char*, stat_t*);
}
//
// Typed Memory Objects (TYM)
//
/*
S_TYPEISTMO(buf)
*/
//
// XOpen (XSI)
//
/*
S_IFMT
S_IFBLK
S_IFCHR
S_IFIFO
S_IFREG
S_IFDIR
S_IFLNK
S_IFSOCK
int mknod(in 3char*, mode_t, dev_t);
*/
version( linux )
{
enum S_IFMT = 0170000;
enum S_IFBLK = 0060000;
enum S_IFCHR = 0020000;
enum S_IFIFO = 0010000;
enum S_IFREG = 0100000;
enum S_IFDIR = 0040000;
enum S_IFLNK = 0120000;
enum S_IFSOCK = 0140000;
int mknod(in char*, mode_t, dev_t);
}
else version( OSX )
{
enum S_IFMT = 0170000;
enum S_IFBLK = 0060000;
enum S_IFCHR = 0020000;
enum S_IFIFO = 0010000;
enum S_IFREG = 0100000;
enum S_IFDIR = 0040000;
enum S_IFLNK = 0120000;
enum S_IFSOCK = 0140000;
int mknod(in char*, mode_t, dev_t);
}
else version( freebsd )
{
enum S_IFMT = 0170000;
enum S_IFBLK = 0060000;
enum S_IFCHR = 0020000;
enum S_IFIFO = 0010000;
enum S_IFREG = 0100000;
enum S_IFDIR = 0040000;
enum S_IFLNK = 0120000;
enum S_IFSOCK = 0140000;
int mknod(in char*, mode_t, dev_t);
}

View File

@@ -0,0 +1,123 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.sys.time;
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()
extern (C):
//
// XOpen (XSI)
//
/*
struct timeval
{
time_t tv_sec;
suseconds_t tv_usec;
}
struct itimerval
{
timeval it_interval;
timeval it_value;
}
ITIMER_REAL
ITIMER_VIRTUAL
ITIMER_PROF
int getitimer(int, itimerval*);
int gettimeofday(timeval*, void*);
int select(int, fd_set*, fd_set*, fd_set*, timeval*); (defined in core.sys.posix.sys.signal)
int setitimer(int, in itimerval*, itimerval*);
int utimes(in char*, in timeval[2]); // LEGACY
*/
version( linux )
{
struct timeval
{
time_t tv_sec;
suseconds_t tv_usec;
}
struct itimerval
{
timeval it_interval;
timeval it_value;
}
enum ITIMER_REAL = 0;
enum ITIMER_VIRTUAL = 1;
enum ITIMER_PROF = 2;
int getitimer(int, itimerval*);
int gettimeofday(timeval*, void*);
int setitimer(int, in itimerval*, itimerval*);
int utimes(in char*, in timeval[2]); // LEGACY
}
else version( OSX )
{
struct timeval
{
time_t tv_sec;
suseconds_t tv_usec;
}
struct itimerval
{
timeval it_interval;
timeval it_value;
}
// non-standard
struct timezone_t
{
int tz_minuteswest;
int tz_dsttime;
}
int getitimer(int, itimerval*);
int gettimeofday(timeval*, timezone_t*); // timezone_t* is normally void*
int setitimer(int, in itimerval*, itimerval*);
int utimes(in char*, in timeval[2]);
}
else version( freebsd )
{
struct timeval
{
time_t tv_sec;
suseconds_t tv_usec;
}
struct itimerval
{
timeval it_interval;
timeval it_value;
}
// non-standard
struct timezone_t
{
int tz_minuteswest;
int tz_dsttime;
}
int getitimer(int, itimerval*);
int gettimeofday(timeval*, timezone_t*); // timezone_t* is normally void*
int setitimer(int, in itimerval*, itimerval*);
int utimes(in char*, in timeval[2]);
}

View File

@@ -0,0 +1,429 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.sys.types;
private import core.sys.posix.config;
private import core.stdc.stdint;
public import core.stdc.stddef; // for size_t
public import core.stdc.time; // for clock_t, time_t
extern (C):
//
// Required
//
/*
blkcnt_t
blksize_t
dev_t
gid_t
ino_t
mode_t
nlink_t
off_t
pid_t
size_t
ssize_t
time_t
uid_t
*/
version( linux )
{
static if( __USE_FILE_OFFSET64 )
{
alias long blkcnt_t;
alias ulong ino_t;
alias long off_t;
}
else
{
alias c_long blkcnt_t;
alias c_ulong ino_t;
alias c_long off_t;
}
alias c_long blksize_t;
alias ulong dev_t;
alias uint gid_t;
alias uint mode_t;
alias c_ulong nlink_t;
alias int pid_t;
//size_t (defined in core.stdc.stddef)
alias c_long ssize_t;
//time_t (defined in core.stdc.time)
alias uint uid_t;
}
else version( OSX )
{
alias long blkcnt_t;
alias int blksize_t;
alias int dev_t;
alias uint gid_t;
alias uint ino_t;
alias ushort mode_t;
alias ushort nlink_t;
alias long off_t;
alias int pid_t;
//size_t (defined in core.stdc.stddef)
alias size_t ssize_t;
//time_t (defined in core.stdc.time)
alias uint uid_t;
}
else version( freebsd )
{
alias long blkcnt_t;
alias uint blksize_t;
alias uint dev_t;
alias uint gid_t;
alias uint ino_t;
alias ushort mode_t;
alias ushort nlink_t;
alias long off_t;
alias int pid_t;
//size_t (defined in core.stdc.stddef)
alias size_t ssize_t;
//time_t (defined in core.stdc.time)
alias uint uid_t;
alias uint fflags_t;
}
//
// XOpen (XSI)
//
/*
clock_t
fsblkcnt_t
fsfilcnt_t
id_t
key_t
suseconds_t
useconds_t
*/
version( linux )
{
static if( __USE_FILE_OFFSET64 )
{
alias ulong fsblkcnt_t;
alias ulong fsfilcnt_t;
}
else
{
alias c_ulong fsblkcnt_t;
alias c_ulong fsfilcnt_t;
}
// clock_t (defined in core.stdc.time)
alias uint id_t;
alias int key_t;
alias c_long suseconds_t;
alias uint useconds_t;
}
else version( OSX )
{
//clock_t
alias uint fsblkcnt_t;
alias uint fsfilcnt_t;
alias uint id_t;
// key_t
alias int suseconds_t;
alias uint useconds_t;
}
else version( freebsd )
{
//clock_t
alias ulong fsblkcnt_t;
alias ulong fsfilcnt_t;
alias long id_t;
alias c_long key_t;
alias c_long suseconds_t;
alias uint useconds_t;
}
//
// Thread (THR)
//
/*
pthread_attr_t
pthread_cond_t
pthread_condattr_t
pthread_key_t
pthread_mutex_t
pthread_mutexattr_t
pthread_once_t
pthread_rwlock_t
pthread_rwlockattr_t
pthread_t
*/
version( linux )
{
private struct __sched_param
{
int __sched_priority;
}
struct pthread_attr_t
{
int __detachstate;
int __schedpolicy;
__sched_param __schedparam;
int __inheritsched;
int __scope;
size_t __guardsize;
int __stackaddr_set;
void* __stackaddr;
size_t __stacksize;
}
private alias int __atomic_lock_t;
private struct _pthread_fastlock
{
c_long __status;
__atomic_lock_t __spinlock;
}
private alias void* _pthread_descr;
private alias long __pthread_cond_align_t;
struct pthread_cond_t
{
_pthread_fastlock __c_lock;
_pthread_descr __c_waiting;
char[48 -
_pthread_fastlock.sizeof -
_pthread_descr.sizeof -
__pthread_cond_align_t.sizeof]
__padding;
__pthread_cond_align_t __align;
}
struct pthread_condattr_t
{
int __dummy;
}
alias uint pthread_key_t;
struct pthread_mutex_t
{
int __m_reserved;
int __m_count;
_pthread_descr __m_owner;
int __m_kind;
_pthread_fastlock __m_lock;
}
struct pthread_mutexattr_t
{
int __mutexkind;
}
alias int pthread_once_t;
struct pthread_rwlock_t
{
_pthread_fastlock __rw_lock;
int __rw_readers;
_pthread_descr __rw_writer;
_pthread_descr __rw_read_waiting;
_pthread_descr __rw_write_waiting;
int __rw_kind;
int __rw_pshared;
}
struct pthread_rwlockattr_t
{
int __lockkind;
int __pshared;
}
alias c_ulong pthread_t;
}
else version( OSX )
{
version( X86_64 )
{
enum __PTHREAD_SIZE__ = 1168;
enum __PTHREAD_ATTR_SIZE__ = 56;
enum __PTHREAD_MUTEXATTR_SIZE__ = 8;
enum __PTHREAD_MUTEX_SIZE__ = 56;
enum __PTHREAD_CONDATTR_SIZE__ = 8;
enum __PTHREAD_COND_SIZE__ = 40;
enum __PTHREAD_ONCE_SIZE__ = 8;
enum __PTHREAD_RWLOCK_SIZE__ = 192;
enum __PTHREAD_RWLOCKATTR_SIZE__ = 16;
}
else version( X86 )
{
enum __PTHREAD_SIZE__ = 596;
enum __PTHREAD_ATTR_SIZE__ = 36;
enum __PTHREAD_MUTEXATTR_SIZE__ = 8;
enum __PTHREAD_MUTEX_SIZE__ = 40;
enum __PTHREAD_CONDATTR_SIZE__ = 4;
enum __PTHREAD_COND_SIZE__ = 24;
enum __PTHREAD_ONCE_SIZE__ = 4;
enum __PTHREAD_RWLOCK_SIZE__ = 124;
enum __PTHREAD_RWLOCKATTR_SIZE__ = 12;
}
struct pthread_handler_rec
{
void function(void*) __routine;
void* __arg;
pthread_handler_rec* __next;
}
struct pthread_attr_t
{
c_long __sig;
byte[__PTHREAD_ATTR_SIZE__] __opaque;
}
struct pthread_cond_t
{
c_long __sig;
byte[__PTHREAD_COND_SIZE__] __opaque;
}
struct pthread_condattr_t
{
c_long __sig;
byte[__PTHREAD_CONDATTR_SIZE__] __opaque;
}
alias c_ulong pthread_key_t;
struct pthread_mutex_t
{
c_long __sig;
byte[__PTHREAD_MUTEX_SIZE__] __opaque;
}
struct pthread_mutexattr_t
{
c_long __sig;
byte[__PTHREAD_MUTEXATTR_SIZE__] __opaque;
}
struct pthread_once_t
{
c_long __sig;
byte[__PTHREAD_ONCE_SIZE__] __opaque;
}
struct pthread_rwlock_t
{
c_long __sig;
byte[__PTHREAD_RWLOCK_SIZE__] __opaque;
}
struct pthread_rwlockattr_t
{
c_long __sig;
byte[__PTHREAD_RWLOCKATTR_SIZE__] __opaque;
}
private struct _opaque_pthread_t
{
c_long __sig;
pthread_handler_rec* __cleanup_stack;
byte[__PTHREAD_SIZE__] __opaque;
}
alias _opaque_pthread_t* pthread_t;
}
else version( freebsd )
{
alias int lwpid_t;
alias void* pthread_attr_t;
alias void* pthread_cond_t;
alias void* pthread_condattr_t;
alias void* pthread_key_t;
alias void* pthread_mutex_t;
alias void* pthread_mutexattr_t;
alias void* pthread_once_t;
alias void* pthread_rwlock_t;
alias void* pthread_rwlockattr_t;
alias void* pthread_t;
}
//
// Barrier (BAR)
//
/*
pthread_barrier_t
pthread_barrierattr_t
*/
version( linux )
{
struct pthread_barrier_t
{
_pthread_fastlock __ba_lock;
int __ba_required;
int __ba_present;
_pthread_descr __ba_waiting;
}
struct pthread_barrierattr_t
{
int __pshared;
}
}
else version( freebsd )
{
alias void* pthread_barrier_t;
alias void* pthread_barrierattr_t;
}
//
// Spin (SPN)
//
/*
pthread_spinlock_t
*/
version( linux )
{
alias int pthread_spinlock_t; // volatile
}
else version( OSX )
{
//struct pthread_spinlock_t;
}
else version( freebsd )
{
alias void* pthread_spinlock_t;
}
//
// Timer (TMR)
//
/*
clockid_t
timer_t
*/
//
// Trace (TRC)
//
/*
trace_attr_t
trace_event_id_t
trace_event_set_t
trace_id_t
*/

View File

@@ -0,0 +1,70 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.sys.uio;
private import core.sys.posix.config;
public import core.sys.posix.sys.types; // for ssize_t, size_t
extern (C):
//
// Required
//
/*
struct iovec
{
void* iov_base;
size_t iov_len;
}
ssize_t // from core.sys.posix.sys.types
size_t // from core.sys.posix.sys.types
ssize_t readv(int, in iovec*, int);
ssize_t writev(int, in iovec*, int);
*/
version( linux )
{
struct iovec
{
void* iov_base;
size_t iov_len;
}
ssize_t readv(int, in iovec*, int);
ssize_t writev(int, in iovec*, int);
}
else version( OSX )
{
struct iovec
{
void* iov_base;
size_t iov_len;
}
ssize_t readv(int, in iovec*, int);
ssize_t writev(int, in iovec*, int);
}
else version( freebsd )
{
struct iovec
{
void* iov_base;
size_t iov_len;
}
ssize_t readv(int, in iovec*, int);
ssize_t writev(int, in iovec*, int);
}

View File

@@ -0,0 +1,141 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.sys.wait;
private import core.sys.posix.config;
public import core.sys.posix.sys.types; // for id_t, pid_t
public import core.sys.posix.signal; // for siginfo_t (XSI)
//public import core.sys.posix.resource; // for rusage (XSI)
extern (C):
//
// Required
//
/*
WNOHANG
WUNTRACED
WEXITSTATUS
WIFCONTINUED
WIFEXITED
WIFSIGNALED
WIFSTOPPED
WSTOPSIG
WTERMSIG
pid_t wait(int*);
pid_t waitpid(pid_t, int*, int);
*/
version( linux )
{
enum WNOHANG = 1;
enum WUNTRACED = 2;
private
{
enum __W_CONTINUED = 0xFFFF;
extern (D) int __WTERMSIG( int status ) { return status & 0x7F; }
}
//
// NOTE: These macros assume __USE_BSD is not defined in the relevant
// C headers as the parameter definition there is different and
// much more complicated.
//
extern (D) int WEXITSTATUS( int status ) { return ( status & 0xFF00 ) >> 8; }
extern (D) int WIFCONTINUED( int status ) { return status == __W_CONTINUED; }
extern (D) bool WIFEXITED( int status ) { return __WTERMSIG( status ) == 0; }
extern (D) bool WIFSIGNALED( int status )
{
return ( cast(byte) ( ( status & 0x7F ) + 1 ) >> 1 ) > 0;
}
extern (D) bool WIFSTOPPED( int status ) { return ( status & 0xFF ) == 0x7F; }
extern (D) int WSTOPSIG( int status ) { return WEXITSTATUS( status ); }
extern (D) int WTERMSIG( int status ) { return status & 0x7F; }
}
else version( OSX )
{
enum WNOHANG = 1;
enum WUNTRACED = 2;
private
{
enum _WSTOPPED = 0177;
}
extern (D) int _WSTATUS(int status) { return (status & 0177); }
extern (D) int WEXITSTATUS( int status ) { return (status >> 8); }
extern (D) int WIFCONTINUED( int status ) { return status == 0x13; }
extern (D) bool WIFEXITED( int status ) { return _WSTATUS(status) == 0; }
extern (D) bool WIFSIGNALED( int status )
{
return _WSTATUS( status ) != _WSTOPPED && _WSTATUS( status ) != 0;
}
extern (D) bool WIFSTOPPED( int status ) { return _WSTATUS( status ) == _WSTOPPED; }
extern (D) int WSTOPSIG( int status ) { return status >> 8; }
extern (D) int WTERMSIG( int status ) { return _WSTATUS( status ); }
}
else version( freebsd )
{
enum WNOHANG = 1;
enum WUNTRACED = 2;
enum WCONTINUED = 4;
private
{
enum _WSTOPPED = 0177;
}
extern (D) int _WSTATUS(int status) { return (status & 0177); }
extern (D) int WEXITSTATUS( int status ) { return (status >> 8); }
extern (D) int WIFCONTINUED( int status ) { return status == 0x13; }
extern (D) bool WIFEXITED( int status ) { return _WSTATUS(status) == 0; }
extern (D) bool WIFSIGNALED( int status )
{
return _WSTATUS( status ) != _WSTOPPED && _WSTATUS( status ) != 0;
}
extern (D) bool WIFSTOPPED( int status ) { return _WSTATUS( status ) == _WSTOPPED; }
extern (D) int WSTOPSIG( int status ) { return status >> 8; }
extern (D) int WTERMSIG( int status ) { return _WSTATUS( status ); }
}
else
{
static assert( false );
}
pid_t wait(int*);
pid_t waitpid(pid_t, int*, int);
//
// XOpen (XSI)
//
/*
WEXITED
WSTOPPED
WCONTINUED
WNOHANG
WNOWAIT
enum idtype_t
{
P_ALL,
P_PID,
P_PGID
}
int waitid(idtype_t, id_t, siginfo_t*, int);
*/

View File

@@ -0,0 +1,528 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.termios;
private import core.sys.posix.config;
public import core.sys.posix.sys.types; // for pid_t
extern (C):
//
// Required
//
/*
cc_t
speed_t
tcflag_t
NCCS
struct termios
{
tcflag_t c_iflag;
tcflag_t c_oflag;
tcflag_t c_cflag;
tcflag_t c_lflag;
cc_t[NCCS] c_cc;
}
VEOF
VEOL
VERASE
VINTR
VKILL
VMIN
VQUIT
VSTART
VSTOP
VSUSP
VTIME
BRKINT
ICRNL
IGNBRK
IGNCR
IGNPAR
INLCR
INPCK
ISTRIP
IXOFF
IXON
PARMRK
OPOST
B0
B50
B75
B110
B134
B150
B200
B300
B600
B1200
B1800
B2400
B4800
B9600
B19200
B38400
CSIZE
CS5
CS6
CS7
CS8
CSTOPB
CREAD
PARENB
PARODD
HUPCL
CLOCAL
ECHO
ECHOE
ECHOK
ECHONL
ICANON
IEXTEN
ISIG
NOFLSH
TOSTOP
TCSANOW
TCSADRAIN
TCSAFLUSH
TCIFLUSH
TCIOFLUSH
TCOFLUSH
TCIOFF
TCION
TCOOFF
TCOON
speed_t cfgetispeed(in termios*);
speed_t cfgetospeed(in termios*);
int cfsetispeed(termios*, speed_t);
int cfsetospeed(termios*, speed_t);
int tcdrain(int);
int tcflow(int, int);
int tcflush(int, int);
int tcgetattr(int, termios*);
int tcsendbreak(int, int);
int tcsetattr(int, int, in termios*);
*/
version( OSX )
{
alias ubyte cc_t;
alias uint speed_t;
alias uint tcflag_t;
enum NCCS = 20;
struct termios
{
tcflag_t c_iflag;
tcflag_t c_oflag;
tcflag_t c_cflag;
tcflag_t c_lflag;
cc_t[NCCS] c_cc;
speed_t c_ispeed;
speed_t c_ospeed;
}
enum VEOF = 0;
enum VEOL = 1;
enum VERASE = 3;
enum VINTR = 8;
enum VKILL = 5;
enum VMIN = 16;
enum VQUIT = 9;
enum VSTART = 12;
enum VSTOP = 13;
enum VSUSP = 10;
enum VTIME = 17;
enum BRKINT = 0x0000002;
enum ICRNL = 0x0000100;
enum IGNBRK = 0x0000001;
enum IGNCR = 0x0000080;
enum IGNPAR = 0x0000004;
enum INLCR = 0x0000040;
enum INPCK = 0x0000010;
enum ISTRIP = 0x0000020;
enum IXOFF = 0x0000400;
enum IXON = 0x0000200;
enum PARMRK = 0x0000008;
enum OPOST = 0x0000001;
enum B0 = 0;
enum B50 = 50;
enum B75 = 75;
enum B110 = 110;
enum B134 = 134;
enum B150 = 150;
enum B200 = 200;
enum B300 = 300;
enum B600 = 600;
enum B1200 = 1200;
enum B1800 = 1800;
enum B2400 = 2400;
enum B4800 = 4800;
enum B9600 = 9600;
enum B19200 = 19200;
enum B38400 = 38400;
enum CSIZE = 0x0000300;
enum CS5 = 0x0000000;
enum CS6 = 0x0000100;
enum CS7 = 0x0000200;
enum CS8 = 0x0000300;
enum CSTOPB = 0x0000400;
enum CREAD = 0x0000800;
enum PARENB = 0x0001000;
enum PARODD = 0x0002000;
enum HUPCL = 0x0004000;
enum CLOCAL = 0x0008000;
enum ECHO = 0x00000008;
enum ECHOE = 0x00000002;
enum ECHOK = 0x00000004;
enum ECHONL = 0x00000010;
enum ICANON = 0x00000100;
enum IEXTEN = 0x00000400;
enum ISIG = 0x00000080;
enum NOFLSH = 0x80000000;
enum TOSTOP = 0x00400000;
enum TCSANOW = 0;
enum TCSADRAIN = 1;
enum TCSAFLUSH = 2;
enum TCIFLUSH = 1;
enum TCOFLUSH = 2;
enum TCIOFLUSH = 3;
enum TCIOFF = 3;
enum TCION = 4;
enum TCOOFF = 1;
enum TCOON = 2;
speed_t cfgetispeed(in termios*);
speed_t cfgetospeed(in termios*);
int cfsetispeed(termios*, speed_t);
int cfsetospeed(termios*, speed_t);
int tcdrain(int);
int tcflow(int, int);
int tcflush(int, int);
int tcgetattr(int, termios*);
int tcsendbreak(int, int);
int tcsetattr(int, int, in termios*);
}
else version( linux )
{
alias ubyte cc_t;
alias uint speed_t;
alias uint tcflag_t;
enum NCCS = 32;
struct termios
{
tcflag_t c_iflag;
tcflag_t c_oflag;
tcflag_t c_cflag;
tcflag_t c_lflag;
cc_t c_line;
cc_t[NCCS] c_cc;
speed_t c_ispeed;
speed_t c_ospeed;
}
enum VEOF = 4;
enum VEOL = 11;
enum VERASE = 2;
enum VINTR = 0;
enum VKILL = 3;
enum VMIN = 6;
enum VQUIT = 1;
enum VSTART = 8;
enum VSTOP = 9;
enum VSUSP = 10;
enum VTIME = 5;
enum BRKINT = 0000002;
enum ICRNL = 0000400;
enum IGNBRK = 0000001;
enum IGNCR = 0000200;
enum IGNPAR = 0000004;
enum INLCR = 0000100;
enum INPCK = 0000020;
enum ISTRIP = 0000040;
enum IXOFF = 0010000;
enum IXON = 0002000;
enum PARMRK = 0000010;
enum OPOST = 0000001;
enum B0 = 0000000;
enum B50 = 0000001;
enum B75 = 0000002;
enum B110 = 0000003;
enum B134 = 0000004;
enum B150 = 0000005;
enum B200 = 0000006;
enum B300 = 0000007;
enum B600 = 0000010;
enum B1200 = 0000011;
enum B1800 = 0000012;
enum B2400 = 0000013;
enum B4800 = 0000014;
enum B9600 = 0000015;
enum B19200 = 0000016;
enum B38400 = 0000017;
enum CSIZE = 0000060;
enum CS5 = 0000000;
enum CS6 = 0000020;
enum CS7 = 0000040;
enum CS8 = 0000060;
enum CSTOPB = 0000100;
enum CREAD = 0000200;
enum PARENB = 0000400;
enum PARODD = 0001000;
enum HUPCL = 0002000;
enum CLOCAL = 0004000;
enum ECHO = 0000010;
enum ECHOE = 0000020;
enum ECHOK = 0000040;
enum ECHONL = 0000100;
enum ICANON = 0000002;
enum IEXTEN = 0100000;
enum ISIG = 0000001;
enum NOFLSH = 0000200;
enum TOSTOP = 0000400;
enum TCSANOW = 0;
enum TCSADRAIN = 1;
enum TCSAFLUSH = 2;
enum TCIFLUSH = 0;
enum TCOFLUSH = 1;
enum TCIOFLUSH = 2;
enum TCIOFF = 2;
enum TCION = 3;
enum TCOOFF = 0;
enum TCOON = 1;
speed_t cfgetispeed(in termios*);
speed_t cfgetospeed(in termios*);
int cfsetispeed(termios*, speed_t);
int cfsetospeed(termios*, speed_t);
int tcdrain(int);
int tcflow(int, int);
int tcflush(int, int);
int tcgetattr(int, termios*);
int tcsendbreak(int, int);
int tcsetattr(int, int, in termios*);
}
else version ( freebsd )
{
alias ubyte cc_t;
alias uint speed_t;
alias uint tcflag_t;
enum NCCS = 20;
struct termios
{
tcflag_t c_iflag;
tcflag_t c_oflag;
tcflag_t c_cflag;
tcflag_t c_lflag;
cc_t[NCCS] c_cc;
speed_t c_ispeed;
speed_t c_ospeed;
}
enum VEOF = 0;
enum VEOL = 1;
enum VERASE = 3;
enum VINTR = 8;
enum VKILL = 5;
enum VMIN = 16;
enum VQUIT = 9;
enum VSTART = 12;
enum VSTOP = 13;
enum VSUSP = 10;
enum VTIME = 17;
enum BRKINT = 0x0000002;
enum ICRNL = 0x0000100;
enum IGNBRK = 0x0000001;
enum IGNCR = 0x0000080;
enum IGNPAR = 0x0000004;
enum INLCR = 0x0000040;
enum INPCK = 0x0000010;
enum ISTRIP = 0x0000020;
enum IXOFF = 0x0000400;
enum IXON = 0x0000200;
enum PARMRK = 0x0000008;
enum OPOST = 0x0000001;
enum B0 = 0;
enum B50 = 50;
enum B75 = 75;
enum B110 = 110;
enum B134 = 134;
enum B150 = 150;
enum B200 = 200;
enum B300 = 300;
enum B600 = 600;
enum B1200 = 1200;
enum B1800 = 1800;
enum B2400 = 2400;
enum B4800 = 4800;
enum B9600 = 9600;
enum B19200 = 19200;
enum B38400 = 38400;
enum CSIZE = 0x0000300;
enum CS5 = 0x0000000;
enum CS6 = 0x0000100;
enum CS7 = 0x0000200;
enum CS8 = 0x0000300;
enum CSTOPB = 0x0000400;
enum CREAD = 0x0000800;
enum PARENB = 0x0001000;
enum PARODD = 0x0002000;
enum HUPCL = 0x0004000;
enum CLOCAL = 0x0008000;
enum ECHO = 0x00000008;
enum ECHOE = 0x00000002;
enum ECHOK = 0x00000004;
enum ECHONL = 0x00000010;
enum ICANON = 0x00000100;
enum IEXTEN = 0x00000400;
enum ISIG = 0x00000080;
enum NOFLSH = 0x80000000;
enum TOSTOP = 0x00400000;
enum TCSANOW = 0;
enum TCSADRAIN = 1;
enum TCSAFLUSH = 2;
enum TCIFLUSH = 1;
enum TCOFLUSH = 2;
enum TCIOFLUSH = 3;
enum TCIOFF = 3;
enum TCION = 4;
enum TCOOFF = 1;
enum TCOON = 2;
speed_t cfgetispeed(in termios*);
speed_t cfgetospeed(in termios*);
int cfsetispeed(termios*, speed_t);
int cfsetospeed(termios*, speed_t);
int tcdrain(int);
int tcflow(int, int);
int tcflush(int, int);
int tcgetattr(int, termios*);
int tcsendbreak(int, int);
int tcsetattr(int, int, in termios*);
}
//
// XOpen (XSI)
//
/*
IXANY
ONLCR
OCRNL
ONOCR
ONLRET
OFILL
NLDLY
NL0
NL1
CRDLY
CR0
CR1
CR2
CR3
TABDLY
TAB0
TAB1
TAB2
TAB3
BSDLY
BS0
BS1
VTDLY
VT0
VT1
FFDLY
FF0
FF1
pid_t tcgetsid(int);
*/
version( linux )
{
enum IXANY = 0004000;
enum ONLCR = 0000004;
enum OCRNL = 0000010;
enum ONOCR = 0000020;
enum ONLRET = 0000040;
enum OFILL = 0000100;
enum NLDLY = 0000400;
enum NL0 = 0000000;
enum NL1 = 0000400;
enum CRDLY = 0003000;
enum CR0 = 0000000;
enum CR1 = 0001000;
enum CR2 = 0002000;
enum CR3 = 0003000;
enum TABDLY = 0014000;
enum TAB0 = 0000000;
enum TAB1 = 0004000;
enum TAB2 = 0010000;
enum TAB3 = 0014000;
enum BSDLY = 0020000;
enum BS0 = 0000000;
enum BS1 = 0020000;
enum VTDLY = 0040000;
enum VT0 = 0000000;
enum VT1 = 0040000;
enum FFDLY = 0100000;
enum FF0 = 0000000;
enum FF1 = 0100000;
pid_t tcgetsid(int);
}

View File

@@ -0,0 +1,270 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.time;
private import core.sys.posix.config;
public import core.stdc.time;
public import core.sys.posix.sys.types;
public import core.sys.posix.signal; // for sigevent
extern (C):
//
// Required (defined in core.stdc.time)
//
/*
char* asctime(in tm*);
clock_t clock();
char* ctime(in time_t*);
double difftime(time_t, time_t);
tm* gmtime(in time_t*);
tm* localtime(in time_t*);
time_t mktime(tm*);
size_t strftime(char*, size_t, in char*, in tm*);
time_t time(time_t*);
*/
version( linux )
{
time_t timegm(tm*); // non-standard
}
else version( OSX )
{
time_t timegm(tm*); // non-standard
}
else version( freebsd )
{
time_t timegm(tm*); // non-standard
}
//
// C Extension (CX)
// (defined in core.stdc.time)
//
/*
char* tzname[];
void tzset();
*/
//
// Process CPU-Time Clocks (CPT)
//
/*
int clock_getcpuclockid(pid_t, clockid_t*);
*/
//
// Clock Selection (CS)
//
/*
int clock_nanosleep(clockid_t, int, in timespec*, timespec*);
*/
//
// Monotonic Clock (MON)
//
/*
CLOCK_MONOTONIC
*/
//
// Timer (TMR)
//
/*
CLOCK_PROCESS_CPUTIME_ID (TMR|CPT)
CLOCK_THREAD_CPUTIME_ID (TMR|TCT)
NOTE: timespec must be defined in core.sys.posix.signal to break
a circular import.
struct timespec
{
time_t tv_sec;
int tv_nsec;
}
struct itimerspec
{
timespec it_interval;
timespec it_value;
}
CLOCK_REALTIME
TIMER_ABSTIME
clockid_t
timer_t
int clock_getres(clockid_t, timespec*);
int clock_gettime(clockid_t, timespec*);
int clock_settime(clockid_t, in timespec*);
int nanosleep(in timespec*, timespec*);
int timer_create(clockid_t, sigevent*, timer_t*);
int timer_delete(timer_t);
int timer_gettime(timer_t, itimerspec*);
int timer_getoverrun(timer_t);
int timer_settime(timer_t, int, in itimerspec*, itimerspec*);
*/
version( linux )
{
enum CLOCK_PROCESS_CPUTIME_ID = 2; // (TMR|CPT)
enum CLOCK_THREAD_CPUTIME_ID = 3; // (TMR|TCT)
// NOTE: See above for why this is commented out.
//
//struct timespec
//{
// time_t tv_sec;
// c_long tv_nsec;
//}
struct itimerspec
{
timespec it_interval;
timespec it_value;
}
enum CLOCK_REALTIME = 0;
enum TIMER_ABSTIME = 0x01;
alias int clockid_t;
alias int timer_t;
int clock_getres(clockid_t, timespec*);
//int clock_gettime(clockid_t, timespec*);
//int clock_settime(clockid_t, in timespec*);
int nanosleep(in timespec*, timespec*);
int timer_create(clockid_t, sigevent*, timer_t*);
int timer_delete(timer_t);
int timer_gettime(timer_t, itimerspec*);
int timer_getoverrun(timer_t);
int timer_settime(timer_t, int, in itimerspec*, itimerspec*);
}
else version( OSX )
{
int nanosleep(in timespec*, timespec*);
}
else version( freebsd )
{
enum CLOCK_PROCESS_CPUTIME_ID = 2; // (TMR|CPT)
enum CLOCK_THREAD_CPUTIME_ID = 3; // (TMR|TCT)
// NOTE: See above for why this is commented out.
//
//struct timespec
//{
// time_t tv_sec;
// c_long tv_nsec;
//}
struct itimerspec
{
timespec it_interval;
timespec it_value;
}
enum CLOCK_REALTIME = 0;
enum TIMER_ABSTIME = 0x01;
//alias int clockid_t;
alias int timer_t;
int clock_getres(clockid_t, timespec*);
int clock_gettime(clockid_t, timespec*);
int clock_settime(clockid_t, in timespec*);
int nanosleep(in timespec*, timespec*);
int timer_create(clockid_t, sigevent*, timer_t*);
int timer_delete(timer_t);
int timer_gettime(timer_t, itimerspec*);
int timer_getoverrun(timer_t);
int timer_settime(timer_t, int, in itimerspec*, itimerspec*);
}
//
// Thread-Safe Functions (TSF)
//
/*
char* asctime_r(in tm*, char*);
char* ctime_r(in time_t*, char*);
tm* gmtime_r(in time_t*, tm*);
tm* localtime_r(in time_t*, tm*);
*/
version( linux )
{
char* asctime_r(in tm*, char*);
char* ctime_r(in time_t*, char*);
tm* gmtime_r(in time_t*, tm*);
tm* localtime_r(in time_t*, tm*);
}
else version( OSX )
{
char* asctime_r(in tm*, char*);
char* ctime_r(in time_t*, char*);
tm* gmtime_r(in time_t*, tm*);
tm* localtime_r(in time_t*, tm*);
}
else version( freebsd )
{
char* asctime_r(in tm*, char*);
char* ctime_r(in time_t*, char*);
tm* gmtime_r(in time_t*, tm*);
tm* localtime_r(in time_t*, tm*);
}
//
// XOpen (XSI)
//
/*
getdate_err
int daylight;
int timezone;
tm* getdate(in char*);
char* strptime(in char*, in char*, tm*);
*/
version( linux )
{
extern __gshared int daylight;
extern __gshared c_long timezone;
tm* getdate(in char*);
char* strptime(in char*, in char*, tm*);
}
else version( OSX )
{
extern __gshared c_long timezone;
tm* getdate(in char*);
char* strptime(in char*, in char*, tm*);
}
else version( FreeBSD )
{
extern __gshared c_long timezone;
//tm* getdate(in char*);
char* strptime(in char*, in char*, tm*);
}
else version( Solaris )
{
extern __gshared c_long timezone;
//tm* getdate(in char*);
char* strptime(in char*, in char*, tm*);
}

View File

@@ -0,0 +1,160 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.ucontext;
private import core.sys.posix.config;
public import core.sys.posix.signal; // for sigset_t, stack_t
extern (C):
//
// XOpen (XSI)
//
/*
mcontext_t
struct ucontext_t
{
ucontext_t* uc_link;
sigset_t uc_sigmask;
stack_t uc_stack;
mcontext_t uc_mcontext;
}
*/
version( linux )
{
version( X86_64 )
{
private
{
struct _libc_fpxreg
{
ushort[4] significand;
ushort exponent;
ushort[3] padding;
}
struct _libc_xmmreg
{
uint[4] element;
}
struct _libc_fpstate
{
ushort cwd;
ushort swd;
ushort ftw;
ushort fop;
ulong rip;
ulong rdp;
uint mxcsr;
uint mxcr_mask;
_libc_fpxreg[8] _st;
_libc_xmmreg[16] _xmm;
uint[24] padding;
}
enum NGREG = 23;
alias c_long greg_t;
alias greg_t[NGREG] gregset_t;
alias _libc_fpstate* fpregset_t;
}
struct mcontext_t
{
gregset_t gregs;
fpregset_t fpregs;
c_ulong[8] __reserved1;
}
struct ucontext_t
{
c_ulong uc_flags;
ucontext_t* uc_link;
stack_t uc_stack;
mcontext_t uc_mcontext;
sigset_t uc_sigmask;
_libc_fpstate __fpregs_mem;
}
}
else version( X86 )
{
private
{
struct _libc_fpreg
{
ushort[4] significand;
ushort exponent;
}
struct _libc_fpstate
{
c_ulong cw;
c_ulong sw;
c_ulong tag;
c_ulong ipoff;
c_ulong cssel;
c_ulong dataoff;
c_ulong datasel;
_libc_fpreg[8] _st;
c_ulong status;
}
enum NGREG = 19;
alias int greg_t;
alias greg_t[NGREG] gregset_t;
alias _libc_fpstate* fpregset_t;
}
struct mcontext_t
{
gregset_t gregs;
fpregset_t fpregs;
c_ulong oldmask;
c_ulong cr2;
}
struct ucontext_t
{
c_ulong uc_flags;
ucontext_t* uc_link;
stack_t uc_stack;
mcontext_t uc_mcontext;
sigset_t uc_sigmask;
_libc_fpstate __fpregs_mem;
}
}
}
//
// Obsolescent (OB)
//
/*
int getcontext(ucontext_t*);
void makecontext(ucontext_t*, void function(), int, ...);
int setcontext(in ucontext_t*);
int swapcontext(ucontext_t*, in ucontext_t*);
*/
static if( is( ucontext_t ) )
{
int getcontext(ucontext_t*);
void makecontext(ucontext_t*, void function(), int, ...);
int setcontext(in ucontext_t*);
int swapcontext(ucontext_t*, in ucontext_t*);
}

View File

@@ -0,0 +1,599 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.unistd;
private import core.sys.posix.config;
private import core.stdc.stddef;
public import core.sys.posix.inttypes; // for intptr_t
public import core.sys.posix.sys.types; // for size_t, ssize_t, uid_t, gid_t, off_t, pid_t, useconds_t
extern (C):
enum STDIN_FILENO = 0;
enum STDOUT_FILENO = 1;
enum STDERR_FILENO = 2;
char* optarg;
int optind;
int opterr;
int optopt;
int access(in char*, int);
uint alarm(uint);
int chdir(in char*);
int chown(in char*, uid_t, gid_t);
int close(int);
size_t confstr(int, char*, size_t);
int dup(int);
int dup2(int, int);
int execl(in char*, in char*, ...);
int execle(in char*, in char*, ...);
int execlp(in char*, in char*, ...);
int execv(in char*, in char**);
int execve(in char*, in char**, in char**);
int execvp(in char*, in char**);
void _exit(int);
int fchown(int, uid_t, gid_t);
pid_t fork();
c_long fpathconf(int, int);
//int ftruncate(int, off_t);
char* getcwd(char*, size_t);
gid_t getegid();
uid_t geteuid();
gid_t getgid();
int getgroups(int, gid_t *);
int gethostname(char*, size_t);
char* getlogin();
int getlogin_r(char*, size_t);
int getopt(int, in char**, in char*);
pid_t getpgrp();
pid_t getpid();
pid_t getppid();
uid_t getuid();
int isatty(int);
int link(in char*, in char*);
//off_t lseek(int, off_t, int);
c_long pathconf(in char*, int);
int pause();
int pipe(int[2]);
ssize_t read(int, void*, size_t);
ssize_t readlink(in char*, char*, size_t);
int rmdir(in char*);
int setegid(gid_t);
int seteuid(uid_t);
int setgid(gid_t);
int setpgid(pid_t, pid_t);
pid_t setsid();
int setuid(uid_t);
uint sleep(uint);
int symlink(in char*, in char*);
c_long sysconf(int);
pid_t tcgetpgrp(int);
int tcsetpgrp(int, pid_t);
char* ttyname(int);
int ttyname_r(int, char*, size_t);
int unlink(in char*);
ssize_t write(int, in void*, size_t);
version( linux )
{
static if( __USE_FILE_OFFSET64 )
{
off_t lseek64(int, off_t, int);
alias lseek64 lseek;
}
else
{
off_t lseek(int, off_t, int);
}
static if( __USE_LARGEFILE64 )
{
int ftruncate64(int, off_t);
alias ftruncate64 ftruncate;
}
else
{
int ftruncate(int, off_t);
}
}
else version( freebsd )
{
off_t lseek(int, off_t, int);
int ftruncate(int, off_t);
}
else
{
off_t lseek(int, off_t, int);
int ftruncate(int, off_t);
}
version( linux )
{
enum F_OK = 0;
enum R_OK = 4;
enum W_OK = 2;
enum X_OK = 1;
enum F_ULOCK = 0;
enum F_LOCK = 1;
enum F_TLOCK = 2;
enum F_TEST = 3;
enum
{
_CS_PATH,
_CS_V6_WIDTH_RESTRICTED_ENVS,
_CS_GNU_LIBC_VERSION,
_CS_GNU_LIBPTHREAD_VERSION,
_CS_LFS_CFLAGS = 1000,
_CS_LFS_LDFLAGS,
_CS_LFS_LIBS,
_CS_LFS_LINTFLAGS,
_CS_LFS64_CFLAGS,
_CS_LFS64_LDFLAGS,
_CS_LFS64_LIBS,
_CS_LFS64_LINTFLAGS,
_CS_XBS5_ILP32_OFF32_CFLAGS = 1100,
_CS_XBS5_ILP32_OFF32_LDFLAGS,
_CS_XBS5_ILP32_OFF32_LIBS,
_CS_XBS5_ILP32_OFF32_LINTFLAGS,
_CS_XBS5_ILP32_OFFBIG_CFLAGS,
_CS_XBS5_ILP32_OFFBIG_LDFLAGS,
_CS_XBS5_ILP32_OFFBIG_LIBS,
_CS_XBS5_ILP32_OFFBIG_LINTFLAGS,
_CS_XBS5_LP64_OFF64_CFLAGS,
_CS_XBS5_LP64_OFF64_LDFLAGS,
_CS_XBS5_LP64_OFF64_LIBS,
_CS_XBS5_LP64_OFF64_LINTFLAGS,
_CS_XBS5_LPBIG_OFFBIG_CFLAGS,
_CS_XBS5_LPBIG_OFFBIG_LDFLAGS,
_CS_XBS5_LPBIG_OFFBIG_LIBS,
_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS,
_CS_POSIX_V6_ILP32_OFF32_CFLAGS,
_CS_POSIX_V6_ILP32_OFF32_LDFLAGS,
_CS_POSIX_V6_ILP32_OFF32_LIBS,
_CS_POSIX_V6_ILP32_OFF32_LINTFLAGS,
_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS,
_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS,
_CS_POSIX_V6_ILP32_OFFBIG_LIBS,
_CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS,
_CS_POSIX_V6_LP64_OFF64_CFLAGS,
_CS_POSIX_V6_LP64_OFF64_LDFLAGS,
_CS_POSIX_V6_LP64_OFF64_LIBS,
_CS_POSIX_V6_LP64_OFF64_LINTFLAGS,
_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS,
_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS,
_CS_POSIX_V6_LPBIG_OFFBIG_LIBS,
_CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS
}
enum
{
_PC_LINK_MAX,
_PC_MAX_CANON,
_PC_MAX_INPUT,
_PC_NAME_MAX,
_PC_PATH_MAX,
_PC_PIPE_BUF,
_PC_CHOWN_RESTRICTED,
_PC_NO_TRUNC,
_PC_VDISABLE,
_PC_SYNC_IO,
_PC_ASYNC_IO,
_PC_PRIO_IO,
_PC_SOCK_MAXBUF,
_PC_FILESIZEBITS,
_PC_REC_INCR_XFER_SIZE,
_PC_REC_MAX_XFER_SIZE,
_PC_REC_MIN_XFER_SIZE,
_PC_REC_XFER_ALIGN,
_PC_ALLOC_SIZE_MIN,
_PC_SYMLINK_MAX,
_PC_2_SYMLINKS
}
enum
{
_SC_ARG_MAX,
_SC_CHILD_MAX,
_SC_CLK_TCK,
_SC_NGROUPS_MAX,
_SC_OPEN_MAX,
_SC_STREAM_MAX,
_SC_TZNAME_MAX,
_SC_JOB_CONTROL,
_SC_SAVED_IDS,
_SC_REALTIME_SIGNALS,
_SC_PRIORITY_SCHEDULING,
_SC_TIMERS,
_SC_ASYNCHRONOUS_IO,
_SC_PRIORITIZED_IO,
_SC_SYNCHRONIZED_IO,
_SC_FSYNC,
_SC_MAPPED_FILES,
_SC_MEMLOCK,
_SC_MEMLOCK_RANGE,
_SC_MEMORY_PROTECTION,
_SC_MESSAGE_PASSING,
_SC_SEMAPHORES,
_SC_SHARED_MEMORY_OBJECTS,
_SC_AIO_LISTIO_MAX,
_SC_AIO_MAX,
_SC_AIO_PRIO_DELTA_MAX,
_SC_DELAYTIMER_MAX,
_SC_MQ_OPEN_MAX,
_SC_MQ_PRIO_MAX,
_SC_VERSION,
_SC_PAGESIZE,
_SC_PAGE_SIZE = _SC_PAGESIZE,
_SC_RTSIG_MAX,
_SC_SEM_NSEMS_MAX,
_SC_SEM_VALUE_MAX,
_SC_SIGQUEUE_MAX,
_SC_TIMER_MAX,
_SC_BC_BASE_MAX,
_SC_BC_DIM_MAX,
_SC_BC_SCALE_MAX,
_SC_BC_STRING_MAX,
_SC_COLL_WEIGHTS_MAX,
_SC_EQUIV_CLASS_MAX,
_SC_EXPR_NEST_MAX,
_SC_LINE_MAX,
_SC_RE_DUP_MAX,
_SC_CHARCLASS_NAME_MAX,
_SC_2_VERSION,
_SC_2_C_BIND,
_SC_2_C_DEV,
_SC_2_FORT_DEV,
_SC_2_FORT_RUN,
_SC_2_SW_DEV,
_SC_2_LOCALEDEF,
_SC_PII,
_SC_PII_XTI,
_SC_PII_SOCKET,
_SC_PII_INTERNET,
_SC_PII_OSI,
_SC_POLL,
_SC_SELECT,
_SC_UIO_MAXIOV,
_SC_IOV_MAX = _SC_UIO_MAXIOV,
_SC_PII_INTERNET_STREAM,
_SC_PII_INTERNET_DGRAM,
_SC_PII_OSI_COTS,
_SC_PII_OSI_CLTS,
_SC_PII_OSI_M,
_SC_T_IOV_MAX,
_SC_THREADS,
_SC_THREAD_SAFE_FUNCTIONS,
_SC_GETGR_R_SIZE_MAX,
_SC_GETPW_R_SIZE_MAX,
_SC_LOGIN_NAME_MAX,
_SC_TTY_NAME_MAX,
_SC_THREAD_DESTRUCTOR_ITERATIONS,
_SC_THREAD_KEYS_MAX,
_SC_THREAD_STACK_MIN,
_SC_THREAD_THREADS_MAX,
_SC_THREAD_ATTR_STACKADDR,
_SC_THREAD_ATTR_STACKSIZE,
_SC_THREAD_PRIORITY_SCHEDULING,
_SC_THREAD_PRIO_INHERIT,
_SC_THREAD_PRIO_PROTECT,
_SC_THREAD_PROCESS_SHARED,
_SC_NPROCESSORS_CONF,
_SC_NPROCESSORS_ONLN,
_SC_PHYS_PAGES,
_SC_AVPHYS_PAGES,
_SC_ATEXIT_MAX,
_SC_PASS_MAX,
_SC_XOPEN_VERSION,
_SC_XOPEN_XCU_VERSION,
_SC_XOPEN_UNIX,
_SC_XOPEN_CRYPT,
_SC_XOPEN_ENH_I18N,
_SC_XOPEN_SHM,
_SC_2_CHAR_TERM,
_SC_2_C_VERSION,
_SC_2_UPE,
_SC_XOPEN_XPG2,
_SC_XOPEN_XPG3,
_SC_XOPEN_XPG4,
_SC_CHAR_BIT,
_SC_CHAR_MAX,
_SC_CHAR_MIN,
_SC_INT_MAX,
_SC_INT_MIN,
_SC_LONG_BIT,
_SC_WORD_BIT,
_SC_MB_LEN_MAX,
_SC_NZERO,
_SC_SSIZE_MAX,
_SC_SCHAR_MAX,
_SC_SCHAR_MIN,
_SC_SHRT_MAX,
_SC_SHRT_MIN,
_SC_UCHAR_MAX,
_SC_UINT_MAX,
_SC_ULONG_MAX,
_SC_USHRT_MAX,
_SC_NL_ARGMAX,
_SC_NL_LANGMAX,
_SC_NL_MSGMAX,
_SC_NL_NMAX,
_SC_NL_SETMAX,
_SC_NL_TEXTMAX,
_SC_XBS5_ILP32_OFF32,
_SC_XBS5_ILP32_OFFBIG,
_SC_XBS5_LP64_OFF64,
_SC_XBS5_LPBIG_OFFBIG,
_SC_XOPEN_LEGACY,
_SC_XOPEN_REALTIME,
_SC_XOPEN_REALTIME_THREADS,
_SC_ADVISORY_INFO,
_SC_BARRIERS,
_SC_BASE,
_SC_C_LANG_SUPPORT,
_SC_C_LANG_SUPPORT_R,
_SC_CLOCK_SELECTION,
_SC_CPUTIME,
_SC_THREAD_CPUTIME,
_SC_DEVICE_IO,
_SC_DEVICE_SPECIFIC,
_SC_DEVICE_SPECIFIC_R,
_SC_FD_MGMT,
_SC_FIFO,
_SC_PIPE,
_SC_FILE_ATTRIBUTES,
_SC_FILE_LOCKING,
_SC_FILE_SYSTEM,
_SC_MONOTONIC_CLOCK,
_SC_MULTI_PROCESS,
_SC_SINGLE_PROCESS,
_SC_NETWORKING,
_SC_READER_WRITER_LOCKS,
_SC_SPIN_LOCKS,
_SC_REGEXP,
_SC_REGEX_VERSION,
_SC_SHELL,
_SC_SIGNALS,
_SC_SPAWN,
_SC_SPORADIC_SERVER,
_SC_THREAD_SPORADIC_SERVER,
_SC_SYSTEM_DATABASE,
_SC_SYSTEM_DATABASE_R,
_SC_TIMEOUTS,
_SC_TYPED_MEMORY_OBJECTS,
_SC_USER_GROUPS,
_SC_USER_GROUPS_R,
_SC_2_PBS,
_SC_2_PBS_ACCOUNTING,
_SC_2_PBS_LOCATE,
_SC_2_PBS_MESSAGE,
_SC_2_PBS_TRACK,
_SC_SYMLOOP_MAX,
_SC_STREAMS,
_SC_2_PBS_CHECKPOINT,
_SC_V6_ILP32_OFF32,
_SC_V6_ILP32_OFFBIG,
_SC_V6_LP64_OFF64,
_SC_V6_LPBIG_OFFBIG,
_SC_HOST_NAME_MAX,
_SC_TRACE,
_SC_TRACE_EVENT_FILTER,
_SC_TRACE_INHERIT,
_SC_TRACE_LOG,
_SC_LEVEL1_ICACHE_SIZE,
_SC_LEVEL1_ICACHE_ASSOC,
_SC_LEVEL1_ICACHE_LINESIZE,
_SC_LEVEL1_DCACHE_SIZE,
_SC_LEVEL1_DCACHE_ASSOC,
_SC_LEVEL1_DCACHE_LINESIZE,
_SC_LEVEL2_CACHE_SIZE,
_SC_LEVEL2_CACHE_ASSOC,
_SC_LEVEL2_CACHE_LINESIZE,
_SC_LEVEL3_CACHE_SIZE,
_SC_LEVEL3_CACHE_ASSOC,
_SC_LEVEL3_CACHE_LINESIZE,
_SC_LEVEL4_CACHE_SIZE,
_SC_LEVEL4_CACHE_ASSOC,
_SC_LEVEL4_CACHE_LINESIZE,
_SC_IPV6 = _SC_LEVEL1_ICACHE_SIZE + 50,
_SC_RAW_SOCKETS
}
}
else version( OSX )
{
enum F_OK = 0;
enum R_OK = 4;
enum W_OK = 2;
enum X_OK = 1;
enum F_ULOCK = 0;
enum F_LOCK = 1;
enum F_TLOCK = 2;
enum F_TEST = 3;
}
else version( freebsd )
{
enum F_OK = 0;
enum R_OK = 0x04;
enum W_OK = 0x02;
enum X_OK = 0x01;
enum F_ULOCK = 0;
enum F_LOCK = 1;
enum F_TLOCK = 2;
enum F_TEST = 3;
}
//
// File Synchronization (FSC)
//
/*
int fsync(int);
*/
//
// Synchronized I/O (SIO)
//
/*
int fdatasync(int);
*/
//
// XOpen (XSI)
//
/*
char* crypt(in char*, in char*);
char* ctermid(char*);
void encrypt(char[64], int);
int fchdir(int);
c_long gethostid();
pid_t getpgid(pid_t);
pid_t getsid(pid_t);
char* getwd(char*); // LEGACY
int lchown(in char*, uid_t, gid_t);
int lockf(int, int, off_t);
int nice(int);
ssize_t pread(int, void*, size_t, off_t);
ssize_t pwrite(int, in void*, size_t, off_t);
pid_t setpgrp();
int setregid(gid_t, gid_t);
int setreuid(uid_t, uid_t);
void swab(in void*, void*, ssize_t);
void sync();
int truncate(in char*, off_t);
useconds_t ualarm(useconds_t, useconds_t);
int usleep(useconds_t);
pid_t vfork();
*/
version( linux )
{
char* crypt(in char*, in char*);
char* ctermid(char*);
void encrypt(char[64], int);
int fchdir(int);
c_long gethostid();
pid_t getpgid(pid_t);
pid_t getsid(pid_t);
char* getwd(char*); // LEGACY
int lchown(in char*, uid_t, gid_t);
//int lockf(int, int, off_t);
int nice(int);
//ssize_t pread(int, void*, size_t, off_t);
//ssize_t pwrite(int, in void*, size_t, off_t);
pid_t setpgrp();
int setregid(gid_t, gid_t);
int setreuid(uid_t, uid_t);
void swab(in void*, void*, ssize_t);
void sync();
//int truncate(in char*, off_t);
useconds_t ualarm(useconds_t, useconds_t);
int usleep(useconds_t);
pid_t vfork();
static if( __USE_LARGEFILE64 )
{
int lockf64(int, int, off_t);
alias lockf64 lockf;
ssize_t pread64(int, void*, size_t, off_t);
alias pread64 pread;
ssize_t pwrite64(int, in void*, size_t, off_t);
alias pwrite64 pwrite;
int truncate64(in char*, off_t);
alias truncate64 truncate;
}
else
{
int lockf(int, int, off_t);
ssize_t pread(int, void*, size_t, off_t);
ssize_t pwrite(int, in void*, size_t, off_t);
int truncate(in char*, off_t);
}
}
else version( OSX )
{
char* crypt(in char*, in char*);
char* ctermid(char*);
void encrypt(char[64], int);
int fchdir(int);
c_long gethostid();
pid_t getpgid(pid_t);
pid_t getsid(pid_t);
char* getwd(char*); // LEGACY
int lchown(in char*, uid_t, gid_t);
int lockf(int, int, off_t);
int nice(int);
ssize_t pread(int, void*, size_t, off_t);
ssize_t pwrite(int, in void*, size_t, off_t);
pid_t setpgrp();
int setregid(gid_t, gid_t);
int setreuid(uid_t, uid_t);
void swab(in void*, void*, ssize_t);
void sync();
int truncate(in char*, off_t);
useconds_t ualarm(useconds_t, useconds_t);
int usleep(useconds_t);
pid_t vfork();
}
else version (freebsd)
{
char* crypt(in char*, in char*);
//char* ctermid(char*);
void encrypt(char*, int);
int fchdir(int);
c_long gethostid();
int getpgid(pid_t);
int getsid(pid_t);
char* getwd(char*); // LEGACY
int lchown(in char*, uid_t, gid_t);
int lockf(int, int, off_t);
int nice(int);
ssize_t pread(int, void*, size_t, off_t);
ssize_t pwrite(int, in void*, size_t, off_t);
int setpgrp(pid_t, pid_t);
int setregid(gid_t, gid_t);
int setreuid(uid_t, uid_t);
void swab(in void*, void*, ssize_t);
void sync();
int truncate(in char*, off_t);
useconds_t ualarm(useconds_t, useconds_t);
int usleep(useconds_t);
pid_t vfork();
}

View File

@@ -0,0 +1,63 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Sean Kelly
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*
* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.posix.utime;
private import core.sys.posix.config;
public import core.sys.posix.sys.types; // for time_t
extern (C):
//
// Required
//
/*
struct utimbuf
{
time_t actime;
time_t modtime;
}
int utime(in char*, in utimbuf*);
*/
version( linux )
{
struct utimbuf
{
time_t actime;
time_t modtime;
}
int utime(in char*, in utimbuf*);
}
else version( OSX )
{
struct utimbuf
{
time_t actime;
time_t modtime;
}
int utime(in char*, in utimbuf*);
}
else version( freebsd )
{
struct utimbuf
{
time_t actime;
time_t modtime;
}
int utime(in char*, in utimbuf*);
}

File diff suppressed because it is too large Load Diff

268
druntime/import/object.di Normal file
View File

@@ -0,0 +1,268 @@
/**
* Contains all implicitly declared types and variables.
*
* Copyright: Copyright Digital Mars 2000 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
* Authors: Walter Bright, Sean Kelly
*
* Copyright Digital Mars 2000 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module object;
alias typeof(int.sizeof) size_t;
alias typeof(cast(void*)0 - cast(void*)0) ptrdiff_t;
alias size_t hash_t;
alias bool equals_t;
alias immutable(char)[] string;
alias immutable(wchar)[] wstring;
alias immutable(dchar)[] dstring;
class Object
{
string toString();
hash_t toHash();
int opCmp(Object o);
equals_t opEquals(Object o);
interface Monitor
{
void lock();
void unlock();
}
static Object factory(string classname);
}
struct Interface
{
ClassInfo classinfo;
void*[] vtbl;
ptrdiff_t offset; // offset to Interface 'this' from Object 'this'
}
class ClassInfo : Object
{
byte[] init; // class static initializer
string name; // class name
void*[] vtbl; // virtual function pointer table
Interface[] interfaces;
ClassInfo base;
void* destructor;
void(*classInvariant)(Object);
uint flags;
// 1: // is IUnknown or is derived from IUnknown
// 2: // has no possible pointers into GC memory
// 4: // has offTi[] member
// 8: // has constructors
// 16: // has xgetMembers member
// 32: // has typeinfo member
void* deallocator;
OffsetTypeInfo[] offTi;
void* defaultConstructor;
const(MemberInfo[]) function(string) xgetMembers;
TypeInfo typeinfo;
static ClassInfo find(in char[] classname);
Object create();
const(MemberInfo[]) getMembers(in char[] classname);
}
struct OffsetTypeInfo
{
size_t offset;
TypeInfo ti;
}
class TypeInfo
{
hash_t getHash(in void* p);
equals_t equals(in void* p1, in void* p2);
int compare(in void* p1, in void* p2);
size_t tsize();
void swap(void* p1, void* p2);
TypeInfo next();
void[] init();
uint flags();
// 1: // has possible pointers into GC memory
OffsetTypeInfo[] offTi();
void destroy(void* p);
void postblit(void* p);
}
class TypeInfo_Typedef : TypeInfo
{
TypeInfo base;
string name;
void[] m_init;
}
class TypeInfo_Enum : TypeInfo_Typedef
{
}
class TypeInfo_Pointer : TypeInfo
{
TypeInfo m_next;
}
class TypeInfo_Array : TypeInfo
{
TypeInfo value;
}
class TypeInfo_StaticArray : TypeInfo
{
TypeInfo value;
size_t len;
}
class TypeInfo_AssociativeArray : TypeInfo
{
TypeInfo value;
TypeInfo key;
}
class TypeInfo_Function : TypeInfo
{
TypeInfo next;
}
class TypeInfo_Delegate : TypeInfo
{
TypeInfo next;
}
class TypeInfo_Class : TypeInfo
{
ClassInfo info;
}
class TypeInfo_Interface : TypeInfo
{
ClassInfo info;
}
class TypeInfo_Struct : TypeInfo
{
string name;
void[] m_init;
uint function(in void*) xtoHash;
equals_t function(in void*, in void*) xopEquals;
int function(in void*, in void*) xopCmp;
string function(in void*) xtoString;
uint m_flags;
const(MemberInfo[]) function(in char[]) xgetMembers;
void function(void*) xdtor;
void function(void*) xpostblit;
}
class TypeInfo_Tuple : TypeInfo
{
TypeInfo[] elements;
}
class TypeInfo_Const : TypeInfo
{
TypeInfo next;
}
class TypeInfo_Invariant : TypeInfo_Const
{
}
class TypeInfo_Shared : TypeInfo_Const
{
}
abstract class MemberInfo
{
string name();
}
class MemberInfo_field : MemberInfo
{
this(string name, TypeInfo ti, size_t offset);
override string name();
TypeInfo typeInfo();
size_t offset();
}
class MemberInfo_function : MemberInfo
{
enum
{
Virtual = 1,
Member = 2,
Static = 4,
}
this(string name, TypeInfo ti, void* fp, uint flags);
override string name();
TypeInfo typeInfo();
void* fp();
uint flags();
}
class ModuleInfo
{
string name;
ModuleInfo[] importedModules;
ClassInfo[] localClasses;
uint flags;
void function() ctor;
void function() dtor;
void function() unitTest;
void* xgetMembers;
void function() ictor;
void*[4] reserved;
static int opApply(int delegate(inout ModuleInfo));
}
class Throwable : Object
{
interface TraceInfo
{
int opApply(int delegate(inout char[]));
string toString();
}
string msg;
string file;
size_t line;
TraceInfo info;
Throwable next;
this(string msg, Throwable next = null);
this(string msg, string file, size_t line, Throwable next = null);
override string toString();
}
class Exception : Throwable
{
this(string msg, Throwable next = null);
this(string msg, string file, size_t line, Throwable next = null);
}
class Error : Throwable
{
this(string msg, Throwable next = null);
this(string msg, string file, size_t line, Throwable next = null);
}

View File

@@ -0,0 +1,32 @@
/**
* These functions are built-in intrinsics to the compiler.
*
* Copyright: Public Domain
* License: Public Domain
* Authors: David Friedman
*/
module std.c.stdarg;
version( GNU )
{
private import gcc.builtins;
alias __builtin_va_list va_list;
alias __builtin_va_end va_end;
alias __builtin_va_copy va_copy;
}
template va_start(T)
{
void va_start( out va_list ap, inout T parmn )
{
}
}
template va_arg(T)
{
T va_arg( inout va_list ap )
{
return T.init;
}
}

View File

@@ -0,0 +1,176 @@
/**
* These functions are built-in intrinsics to the compiler.
*
* Intrinsic functions are functions built in to the compiler, usually to take
* advantage of specific CPU features that are inefficient to handle via
* external functions. The compiler's optimizer and code generator are fully
* integrated in with intrinsic functions, bringing to bear their full power on
* them. This can result in some surprising speedups.
*
* Copyright: Public Domain
* License: Public Domain
* Authors: Walter Bright
*/
module std.intrinsic;
/**
* Scans the bits in v starting with bit 0, looking
* for the first set bit.
* Returns:
* The bit number of the first bit set.
* The return value is undefined if v is zero.
*/
pure nothrow int bsf( uint v );
/**
* Scans the bits in v from the most significant bit
* to the least significant bit, looking
* for the first set bit.
* Returns:
* The bit number of the first bit set.
* The return value is undefined if v is zero.
* Example:
* ---
* import std.intrinsic;
*
* int main()
* {
* uint v;
* int x;
*
* v = 0x21;
* x = bsf(v);
* printf("bsf(x%x) = %d\n", v, x);
* x = bsr(v);
* printf("bsr(x%x) = %d\n", v, x);
* return 0;
* }
* ---
* Output:
* bsf(x21) = 0<br>
* bsr(x21) = 5
*/
pure nothrow int bsr( uint v );
/**
* Tests the bit.
*/
pure nothrow int bt( in uint* p, uint bitnum );
/**
* Tests and complements the bit.
*/
nothrow int btc( uint* p, uint bitnum );
/**
* Tests and resets (sets to 0) the bit.
*/
nothrow int btr( uint* p, uint bitnum );
/**
* Tests and sets the bit.
* Params:
* p = a non-NULL pointer to an array of uints.
* index = a bit number, starting with bit 0 of p[0],
* and progressing. It addresses bits like the expression:
---
p[index / (uint.sizeof*8)] & (1 << (index & ((uint.sizeof*8) - 1)))
---
* Returns:
* A non-zero value if the bit was set, and a zero
* if it was clear.
*
* Example:
* ---
import std.intrinsic;
int main()
{
uint array[2];
array[0] = 2;
array[1] = 0x100;
printf("btc(array, 35) = %d\n", <b>btc</b>(array, 35));
printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
printf("btc(array, 35) = %d\n", <b>btc</b>(array, 35));
printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
printf("bts(array, 35) = %d\n", <b>bts</b>(array, 35));
printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
printf("btr(array, 35) = %d\n", <b>btr</b>(array, 35));
printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
printf("bt(array, 1) = %d\n", <b>bt</b>(array, 1));
printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
return 0;
}
* ---
* Output:
<pre>
btc(array, 35) = 0
array = [0]:x2, [1]:x108
btc(array, 35) = -1
array = [0]:x2, [1]:x100
bts(array, 35) = 0
array = [0]:x2, [1]:x108
btr(array, 35) = -1
array = [0]:x2, [1]:x100
bt(array, 1) = -1
array = [0]:x2, [1]:x100
</pre>
*/
nothrow int bts( uint* p, uint bitnum );
/**
* Swaps bytes in a 4 byte uint end-to-end, i.e. byte 0 becomes
* byte 3, byte 1 becomes byte 2, byte 2 becomes byte 1, byte 3
* becomes byte 0.
*/
pure nothrow uint bswap( uint v );
/**
* Reads I/O port at port_address.
*/
nothrow ubyte inp( uint port_address );
/**
* ditto
*/
nothrow ushort inpw( uint port_address );
/**
* ditto
*/
nothrow uint inpl( uint port_address );
/**
* Writes and returns value to I/O port at port_address.
*/
nothrow ubyte outp( uint port_address, ubyte value );
/**
* ditto
*/
nothrow ushort outpw( uint port_address, ushort value );
/**
* ditto
*/
nothrow uint outpl( uint port_address, uint value );

View File

@@ -0,0 +1,32 @@
/**
* These functions are built-in intrinsics to the compiler.
*
* Copyright: Public Domain
* License: Public Domain
* Authors: David Friedman
*/
module std.stdarg;
version( GNU )
{
private import gcc.builtins;
alias __builtin_va_list va_list;
alias __builtin_va_end va_end;
alias __builtin_va_copy va_copy;
}
template va_start(T)
{
void va_start( out va_list ap, inout T parmn )
{
}
}
template va_arg(T)
{
T va_arg( inout va_list ap )
{
return T.init;
}
}