505 changes: 505 additions & 0 deletions src/core/stdc/math.d

Large diffs are not rendered by default.

184 changes: 184 additions & 0 deletions src/core/stdc/stdio.d
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ private
{
import core.sys.posix.sys.types;
}
else version (OpenBSD)
{
import core.sys.posix.sys.types;
}
}

extern (C):
Expand Down Expand Up @@ -175,6 +179,36 @@ else version ( FreeBSD )
long _mbstateL;
}
}
else version ( OpenBSD )
{
enum
{
///
BUFSIZ = 1024,
///
EOF = -1,
///
FOPEN_MAX = 20,
///
FILENAME_MAX = 1024,
///
TMP_MAX = 0x7fffffff,
///
L_tmpnam = 1024
}

struct __sbuf
{
ubyte *_base;
int _size;
}

union __mbstate_t // <sys/_types.h>
{
char[128] __mbstate8;
long __mbstateL;
}
}
else version (Solaris)
{
enum
Expand Down Expand Up @@ -401,6 +435,44 @@ else version( FreeBSD )
///
alias shared(__sFILE) FILE;
}
else version( OpenBSD )
{
///
alias fpos_t = off_t;

///
struct __sFILE
{
ubyte* _p;
int _r;
int _w;
short _flags;
short _file;
__sbuf _bf;
int _lbfsize;

void* _cookie;
int function(void*) _close;
int function(void*, char*, int) _read;
fpos_t function(void*, fpos_t, int) _seek;
int function(void*, in char*, int) _write;

__sbuf _ext;
ubyte* _up;
int _ur;

ubyte[3] _ubuf;
ubyte[1] _nbuf;

__sbuf _lb;

int _blksize;
fpos_t _offset;
}

///
alias shared(__sFILE) FILE;
}
else version (Solaris)
{
import core.stdc.wchar_ : __mbstate_t;
Expand Down Expand Up @@ -669,6 +741,27 @@ else version( FreeBSD )
///
alias __stderrp stderr;
}
else version( OpenBSD )
{
enum
{
///
_IOFBF = 0,
///
_IOLBF = 1,
///
_IONBF = 2,
}

private extern shared FILE[] __sF;

///
shared stdin = &__sF[0];
///
shared stdout = &__sF[1];
///
shared stderr = &__sF[2];
}
else version (Solaris)
{
enum
Expand Down Expand Up @@ -1065,6 +1158,97 @@ else version( FreeBSD )
///
int vsnprintf(char* s, size_t n, in char* format, va_list arg);
}
else version( OpenBSD )
{
// No unsafe pointer manipulation.
@trusted
{
///
void rewind(FILE*);
}
@trusted private
{
///
pure void clearerr(FILE*);
alias __clearerr = clearerr;
///
pure int feof(FILE*);
alias __feof = feof;
///
pure int ferror(FILE*);
alias __ferror = ferror;
///
int fileno(FILE*);
alias __fileno = fileno;
}

enum __SLBF = 0x0001;
enum __SNBF = 0x0002;
enum __SRD = 0x0004;
enum __SWR = 0x0008;
enum __SRW = 0x0010;
enum __SEOF = 0x0020;
enum __SERR = 0x0040;
enum __SMBF = 0x0080;
enum __SAPP = 0x0100;
enum __SSTR = 0x0200;
enum __SOPT = 0x0400;
enum __SNPT = 0x0800;
enum __SOFF = 0x1000;
enum __SMOD = 0x2000;
enum __SALC = 0x4000;
enum __SIGN = 0x8000;

extern int __isthreaded;

extern (D)
{
void __sclearerr(FILE* p)
{
p._flags &= ~(__SERR|__SEOF);
}

int __sfeof(FILE* p)
{
return (p._flags & __SEOF) != 0;
}

int __sferror(FILE* p)
{
return (p._flags & __SERR) != 0;
}

int __sfileno(FILE* p)
{
return p._file;
}

int clearerr(FILE* file)
{
return !__isthreaded ? __sclearerr(file) : __clearerr(file);
}

int feof(FILE* file)
{
return !__isthreaded ? __sfeof(file) : __feof(file);
}

int ferror(FILE* file)
{
return !__isthreaded ? __sferror(file) : __ferror(file);
}

int fileno(FILE* file)
{
return !__isthreaded ? __sfileno(file) : __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 (Solaris)
{
// No unsafe pointer manipulation.
Expand Down
1 change: 1 addition & 0 deletions src/core/stdc/stdlib.d
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ version(Windows) enum RAND_MAX = 0x7fff;
else version(CRuntime_Glibc) enum RAND_MAX = 0x7fffffff;
else version(Darwin) enum RAND_MAX = 0x7fffffff;
else version(FreeBSD) enum RAND_MAX = 0x7fffffff;
else version(OpenBSD) enum RAND_MAX = 0x7fffffff;
else version(Solaris) enum RAND_MAX = 0x7fff;
else version(CRuntime_Bionic) enum RAND_MAX = 0x7fffffff;
else static assert( false, "Unsupported platform" );
Expand Down
4 changes: 4 additions & 0 deletions src/core/stdc/string.d
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ else version (FreeBSD)
{
int strerror_r(int errnum, char* buf, size_t buflen);
}
else version (OpenBSD)
{
int strerror_r(int errnum, char* buf, size_t buflen);
}
else version (Solaris)
{
int strerror_r(int errnum, char* buf, size_t buflen);
Expand Down
538 changes: 538 additions & 0 deletions src/core/stdc/tgmath.d

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions src/core/stdc/time.d
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ else version( FreeBSD )
{
enum clock_t CLOCKS_PER_SEC = 128;
}
else version( OpenBSD )
{
enum clock_t CLOCKS_PER_SEC = 100;
}
else version (CRuntime_Glibc)
{
enum clock_t CLOCKS_PER_SEC = 1_000_000;
Expand Down Expand Up @@ -158,6 +162,13 @@ else version( FreeBSD )
///
extern __gshared const(char)*[2] tzname; // non-standard
}
else version( OpenBSD )
{
///
void tzset(); // non-standard
///
extern __gshared const(char)*[2] tzname; // non-standard
}
else version (Solaris)
{
///
Expand Down
9 changes: 9 additions & 0 deletions src/core/stdc/wchar_.d
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ version( CRuntime_Glibc )
___value __value;
}
}
else version (OpenBSD)
{
union __mbstate_t
{
char[128] __mbstate8;
int64_t __mbstateL;
}
alias mbstate_t = __mbstate_t;
}
else version (Solaris)
{
///
Expand Down