1,192 changes: 598 additions & 594 deletions src/core/stdc/errno.d

Large diffs are not rendered by default.

43 changes: 32 additions & 11 deletions src/core/stdc/fenv.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* D header file for C99.
*
* $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/fenv.h.html, fenv.h)
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: Distributed under the
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
Expand Down Expand Up @@ -216,75 +218,94 @@ else

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,
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( DMC_RUNTIME )
{
private extern __gshared fenv_t _FE_DFL_ENV;
///
enum fenv_t* FE_DFL_ENV = &_FE_DFL_ENV;
}
else version( Windows )
{
version( MinGW )
///
enum FE_DFL_ENV = cast(fenv_t*)(-1);
else
{
private immutable fenv_t _Fenv0 = {0, 0};
///
enum FE_DFL_ENV = &_Fenv0;
}
}
else version( linux )
{
///
enum FE_DFL_ENV = cast(fenv_t*)(-1);
}
else version( OSX )
{
private extern __gshared fenv_t _FE_DFL_ENV;
///
enum FE_DFL_ENV = &_FE_DFL_ENV;
}
else version( FreeBSD )
{
private extern const fenv_t __fe_dfl_env;
///
enum FE_DFL_ENV = &__fe_dfl_env;
}
else version( Android )
{
private extern const fenv_t __fe_dfl_env;
///
enum FE_DFL_ENV = &__fe_dfl_env;
}
else version( Solaris )
{
private extern const fenv_t __fenv_def_env;
///
enum FE_DFL_ENV = &__fenv_def_env;
}
else
{
static assert( false, "Unsupported platform" );
}

///
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);
33 changes: 33 additions & 0 deletions src/core/stdc/float_.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* D header file for C99.
*
* $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/float.h.html, float.h)
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: Distributed under the
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
Expand All @@ -17,43 +19,74 @@ extern (C):
nothrow:
@nogc:

///
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_normal;
///
enum DBL_MIN = double.min_normal;
///
enum LDBL_MIN = real.min_normal;

///
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;
185 changes: 185 additions & 0 deletions src/core/stdc/inttypes.d

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions src/core/stdc/limits.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* D header file for C99.
*
* $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html, limits.h)
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: Distributed under the
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
Expand All @@ -19,22 +21,41 @@ extern (C):
nothrow:
@nogc:

///
enum CHAR_BIT = 8;
///
enum SCHAR_MIN = byte.min;
///
enum SCHAR_MAX = byte.max;
///
enum UCHAR_MAX = ubyte.max;
///
enum CHAR_MIN = char.min;
///
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;
58 changes: 58 additions & 0 deletions src/core/stdc/locale.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* D header file for C99.
*
* $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/locale.h.html, locale.h)
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: Distributed under the
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
Expand All @@ -17,6 +19,7 @@ extern (C):
nothrow:
@nogc:

///
struct lconv
{
char* decimal_point;
Expand Down Expand Up @@ -47,82 +50,137 @@ struct lconv

version(linux)
{
///
enum LC_CTYPE = 0;
///
enum LC_NUMERIC = 1;
///
enum LC_TIME = 2;
///
enum LC_COLLATE = 3;
///
enum LC_MONETARY = 4;
///
enum LC_MESSAGES = 5;
///
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
}
else version(Windows)
{
///
enum LC_ALL = 0;
///
enum LC_COLLATE = 1;
///
enum LC_CTYPE = 2;
///
enum LC_MONETARY = 3;
///
enum LC_NUMERIC = 4;
///
enum LC_TIME = 5;
}
else version(OSX)
{
///
enum LC_ALL = 0;
///
enum LC_COLLATE = 1;
///
enum LC_CTYPE = 2;
///
enum LC_MONETARY = 3;
///
enum LC_NUMERIC = 4;
///
enum LC_TIME = 5;
///
enum LC_MESSAGES = 6;
}
else version(FreeBSD)
{
///
enum LC_ALL = 0;
///
enum LC_COLLATE = 1;
///
enum LC_CTYPE = 2;
///
enum LC_MONETARY = 3;
///
enum LC_NUMERIC = 4;
///
enum LC_TIME = 5;
///
enum LC_MESSAGES = 6;
}
else version(Android)
{
enum
{
///
LC_CTYPE = 0,
///
LC_NUMERIC = 1,
///
LC_TIME = 2,
///
LC_COLLATE = 3,
///
LC_MONETARY = 4,
///
LC_MESSAGES = 5,
///
LC_ALL = 6,
///
LC_PAPER = 7,
///
LC_NAME = 8,
///
LC_ADDRESS = 9,
///
LC_TELEPHONE = 10,
///
LC_MEASUREMENT = 11,
///
LC_IDENTIFICATION = 12,
}
}
else version(Solaris)
{
///
enum LC_CTYPE = 0;
///
enum LC_NUMERIC = 1;
///
enum LC_TIME = 2;
///
enum LC_COLLATE = 3;
///
enum LC_MONETARY = 4;
///
enum LC_MESSAGES = 5;
///
enum LC_ALL = 6;
}
else
{
static assert(false, "Unsupported platform");
}

///
@system char* setlocale(int category, in char* locale);
///
lconv* localeconv();
677 changes: 677 additions & 0 deletions src/core/stdc/math.d

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions src/core/stdc/signal.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* D header file for C99.
*
* $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/signal.h.html, signal.h)
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: Distributed under the
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
Expand All @@ -18,38 +20,59 @@ nothrow:
@nogc:

// 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);
10 changes: 10 additions & 0 deletions src/core/stdc/stdarg.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* D header file for C99.
*
* $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/stdarg.h.html, stdarg.h)
*
* Copyright: Copyright Digital Mars 2000 - 2009.
* License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Walter Bright, Hauke Duden
Expand Down Expand Up @@ -73,6 +75,7 @@ version( X86 )
{
}

///
void va_copy(out va_list dest, va_list src)
{
dest = src;
Expand Down Expand Up @@ -147,6 +150,7 @@ else version (Windows) // Win64
{
}

///
void va_copy(out va_list dest, va_list src)
{
dest = src;
Expand Down Expand Up @@ -188,17 +192,20 @@ else version (X86_64)
*/
alias va_list = __va_list*;

///
void va_start(T)(out va_list ap, ref T parmn)
{
ap = &parmn.va;
}

///
T va_arg(T)(va_list ap)
{ T a;
va_arg(ap, a);
return a;
}

///
void va_arg(T)(va_list apx, ref T parmn)
{
__va_list* ap = cast(__va_list*)apx;
Expand Down Expand Up @@ -340,6 +347,7 @@ else version (X86_64)
}
}

///
void va_arg()(va_list apx, TypeInfo ti, void* parmn)
{
__va_list* ap = cast(__va_list*)apx;
Expand Down Expand Up @@ -452,10 +460,12 @@ else version (X86_64)
}
}

///
void va_end(va_list ap)
{
}

///
void va_copy(out va_list dest, va_list src)
{
dest = src;
Expand Down
4 changes: 4 additions & 0 deletions src/core/stdc/stddef.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* D header file for C99.
*
* $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/stddef.h.html, stddef.h)
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: Distributed under the
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
Expand All @@ -21,9 +23,11 @@ nothrow:

version( Windows )
{
///
alias wchar wchar_t;
}
else
{
///
alias dchar wchar_t;
}
94 changes: 94 additions & 0 deletions src/core/stdc/stdint.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* D header file for C99.
*
* $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/stdint.h.html, stdint.h)
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: Distributed under the
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
Expand All @@ -25,128 +27,220 @@ extern (C):
nothrow:
@nogc:

///
alias int8_t = byte ;
///
alias int16_t = short;
///
alias int32_t = int ;
///
alias int64_t = long ;
//alias int128_t = cent;

///
alias uint8_t = ubyte ;
///
alias uint16_t = ushort;
///
alias uint32_t = uint ;
///
alias uint64_t = ulong ;
//alias uint128_t = ucent;

///
alias int_least8_t = byte ;
///
alias int_least16_t = short;
///
alias int_least32_t = int ;
///
alias int_least64_t = long ;

///
alias uint_least8_t = ubyte ;
///
alias uint_least16_t = ushort;
///
alias uint_least32_t = uint ;
///
alias uint_least64_t = ulong ;

///
alias int_fast8_t = byte;
///
alias int_fast16_t = int ;
///
alias int_fast32_t = int ;
///
alias int_fast64_t = long;

///
alias uint_fast8_t = ubyte;
///
alias uint_fast16_t = uint ;
///
alias uint_fast32_t = uint ;
///
alias uint_fast64_t = ulong;

version( D_LP64 )
{
///
alias intptr_t = long ;
///
alias uintptr_t = ulong;
}
else
{
///
alias intptr_t = int ;
///
alias uintptr_t = uint;
}

///
alias intmax_t = long ;
///
alias uintmax_t = ulong;

///
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 INT8_C = _typify!int8_t ;
///
alias INT16_C = _typify!int16_t;
///
alias INT32_C = _typify!int32_t;
///
alias INT64_C = _typify!int64_t;

///
alias UINT8_C = _typify!uint8_t ;
///
alias UINT16_C = _typify!uint16_t;
///
alias UINT32_C = _typify!uint32_t;
///
alias UINT64_C = _typify!uint64_t;

///
alias INTMAX_C = _typify!intmax_t ;
///
alias UINTMAX_C = _typify!uintmax_t;
319 changes: 319 additions & 0 deletions src/core/stdc/stdio.d

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions src/core/stdc/stdlib.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* D header file for C99.
*
* $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/stdlib.h.html, stdlib.h)
*
* Copyright: Copyright Sean Kelly 2005 - 2014.
* License: Distributed under the
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
Expand All @@ -20,36 +22,46 @@ extern (C):

/* Placed outside @nogc in order to not constrain what the callback does.
*/
///
alias int function(in void*, in void*) _compare_fp_t;
///
void* bsearch(in void* key, in void* base, size_t nmemb, size_t size, _compare_fp_t compar);
///
void qsort(void* base, size_t nmemb, size_t size, _compare_fp_t compar);


nothrow:
@nogc:

///
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 MB_CUR_MAX = 1;

///
version(Windows) enum RAND_MAX = 0x7fff;
else version(linux) enum RAND_MAX = 0x7fffffff;
else version(OSX) enum RAND_MAX = 0x7fffffff;
Expand All @@ -58,40 +70,55 @@ else version(Solaris) enum RAND_MAX = 0x7fff;
else version(Android) enum RAND_MAX = 0x7fffffff;
else static assert( false, "Unsupported platform" );

///
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);
///
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);

version (CRuntime_Microsoft)
{
// strtold exists starting from VS2013, so we make this a template to avoid link errors
///
real strtold()(in char* nptr, char** endptr)
{ // Fake it 'till we make it
return strtod(nptr, endptr);
}
}
else version (MinGW)
{
///
real __mingw_strtold(in char* nptr, char** endptr);
///
alias __mingw_strtold strtold;
}
else version (Android)
{
///
real strtold(in char* nptr, char** endptr)
{ // Fake it again till we make it
return strtod(nptr, endptr);
}
}
else
{
///
real strtold(in char* nptr, char** endptr);
}

Expand All @@ -101,12 +128,16 @@ else
version(Android)
{
import core.sys.posix.stdlib: lrand48, srand48;
///
alias core.sys.posix.stdlib.lrand48 rand;
///
alias core.sys.posix.stdlib.srand48 srand;
}
else
{
///
int rand();
///
void srand(uint seed);
}
}
Expand All @@ -115,37 +146,59 @@ else
// to do a pointer cast to do anything sensible with the result. Thus,
// functions using these already have to be @trusted, allowing them to
// call @system stuff anyway.
///
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);

// These only operate on integer values.
@trusted
{
///
pure int abs(int j);
///
pure c_long labs(c_long j);
///
pure 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 )
{
// See malloc comment about @trusted.
Expand All @@ -158,10 +211,14 @@ else version( GNU )

version( CRuntime_Microsoft )
{
///
ulong _strtoui64(in char *,char **,int);
///
ulong _wcstoui64(in wchar *,wchar **,int);

///
long _strtoi64(in char *,char **,int);
///
long _wcstoi64(in wchar *,wchar **,int);
}

28 changes: 28 additions & 0 deletions src/core/stdc/string.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* D header file for C99.
*
* $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/string.h.html, string.h)
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: Distributed under the
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
Expand All @@ -19,39 +21,65 @@ extern (C):
nothrow:
@nogc:

///
pure void* memchr(in void* s, int c, size_t n);
///
pure int memcmp(in void* s1, in void* s2, size_t n);
///
pure void* memcpy(void* s1, in void* s2, size_t n);
version (Windows)
{
///
int memicmp(in char* s1, in char* s2, size_t n);
}
///
pure void* memmove(void* s1, in void* s2, size_t n);
///
pure void* memset(void* s, int c, size_t n);

///
pure char* strcpy(char* s1, in char* s2);
///
pure char* strncpy(char* s1, in char* s2, size_t n);
///
pure char* strcat(char* s1, in char* s2);
///
pure char* strncat(char* s1, in char* s2, size_t n);
///
pure int strcmp(in char* s1, in char* s2);
///
int strcoll(in char* s1, in char* s2);
///
pure int strncmp(in char* s1, in char* s2, size_t n);
///
size_t strxfrm(char* s1, in char* s2, size_t n);
///
pure char* strchr(in char* s, int c);
///
pure size_t strcspn(in char* s1, in char* s2);
///
pure char* strpbrk(in char* s1, in char* s2);
///
pure char* strrchr(in char* s, int c);
///
pure size_t strspn(in char* s1, in char* s2);
///
pure char* strstr(in char* s1, in char* s2);
///
char* strtok(char* s1, in char* s2);
///
char* strerror(int errnum);
version (linux)
{
///
const(char)* strerror_r(int errnum, char* buf, size_t buflen);
}
else version (Posix)
{
///
int strerror_r(int errnum, char* buf, size_t buflen);
}
///
pure size_t strlen(in char* s);
///
char* strdup(in char *s);
466 changes: 466 additions & 0 deletions src/core/stdc/tgmath.d

Large diffs are not rendered by default.

71 changes: 51 additions & 20 deletions src/core/stdc/time.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* D header file for C99.
*
* $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/time.h.html, time.h)
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: Distributed under the
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
Expand All @@ -23,34 +25,36 @@ nothrow:

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

Expand All @@ -60,10 +64,13 @@ version ( Posix )
}
else
{
///
alias c_long time_t;
///
alias c_long clock_t;
}

///
version( Windows )
{
enum clock_t CLOCKS_PER_SEC = 1000;
Expand All @@ -85,48 +92,72 @@ else version (Android)
enum clock_t CLOCKS_PER_SEC = 1_000_000;
}

///
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);
///
@system size_t strftime(char* s, size_t maxsize, in char* format, in tm* timeptr);

version( Windows )
{
///
void tzset(); // non-standard
///
void _tzset(); // non-standard
///
@system char* _strdate(char* s); // non-standard
///
@system char* _strtime(char* s); // non-standard

///
extern __gshared const(char)*[2] tzname; // non-standard
}
else version( OSX )
{
///
void tzset(); // non-standard
///
extern __gshared const(char)*[2] tzname; // non-standard
}
else version( linux )
{
///
void tzset(); // non-standard
///
extern __gshared const(char)*[2] tzname; // non-standard
}
else version( FreeBSD )
{
///
void tzset(); // non-standard
///
extern __gshared const(char)*[2] tzname; // non-standard
}
else version (Solaris)
{
///
void tzset();
///
extern __gshared const(char)*[2] tzname;
}
else version( Android )
{
///
void tzset();
///
extern __gshared const(char)*[2] tzname;
}
else
Expand Down
68 changes: 68 additions & 0 deletions src/core/stdc/wchar_.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* D header file for C99.
*
* $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/wchar.h.html, wchar.h)
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: Distributed under the
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
Expand All @@ -24,47 +26,72 @@ extern (C):
nothrow:
@nogc:

///
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, ...);

// No unsafe pointer manipulation.
@trusted
{
///
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);

// No unsafe pointer manipulation.
extern (D) @trusted
{
///
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); }
}

// No unsafe pointer manipulation.
@trusted
{
///
wint_t ungetwc(wint_t c, FILE* stream);
///
version( CRuntime_Microsoft )
{
// MSVC defines this as an inline function.
Expand All @@ -76,57 +103,98 @@ extern (D) @trusted
}
}

///
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(in 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
}

// No unsafe pointer manipulation.
@trusted
{
///
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);
22 changes: 22 additions & 0 deletions src/core/stdc/wctype.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* D header file for C99.
*
* $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/wctype.h.html, wctype.h)
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: Distributed under the
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
Expand All @@ -19,25 +21,45 @@ extern (C):
nothrow:
@nogc:

///
alias wchar_t wctrans_t;
///
alias wchar_t wctype_t;

///
pure int iswalnum(wint_t wc);
///
pure int iswalpha(wint_t wc);
///
pure int iswblank(wint_t wc);
///
pure int iswcntrl(wint_t wc);
///
pure int iswdigit(wint_t wc);
///
pure int iswgraph(wint_t wc);
///
pure int iswlower(wint_t wc);
///
pure int iswprint(wint_t wc);
///
pure int iswpunct(wint_t wc);
///
pure int iswspace(wint_t wc);
///
pure int iswupper(wint_t wc);
///
pure int iswxdigit(wint_t wc);

///
int iswctype(wint_t wc, wctype_t desc);
///
@system wctype_t wctype(in char* property);
///
pure wint_t towlower(wint_t wc);
///
pure wint_t towupper(wint_t wc);
///
wint_t towctrans(wint_t wc, wctrans_t desc);
///
@system wctrans_t wctrans(in char* property);