diff --git a/src/core/stdc/errno.d b/src/core/stdc/errno.d index b3bb2139cdd..f123e29c099 100644 --- a/src/core/stdc/errno.d +++ b/src/core/stdc/errno.d @@ -504,6 +504,138 @@ else version (Solaris) enum EINPROGRESS = 150 /* operation now in progress */; enum ESTALE = 151 /* Stale NFS file handle */; } +else version( Android ) +{ + 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 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 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 { static assert(false, "Unsupported platform"); diff --git a/src/core/stdc/fenv.d b/src/core/stdc/fenv.d index 52c4f70ee65..37db25904e3 100644 --- a/src/core/stdc/fenv.d +++ b/src/core/stdc/fenv.d @@ -114,6 +114,20 @@ else version ( FreeBSD ) alias ushort fexcept_t; } +else version( Android ) +{ + 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, "Unsupported platform" ); @@ -153,6 +167,11 @@ else version( FreeBSD ) private extern const fenv_t __fe_dfl_env; const fenv_t* FE_DFL_ENV = &__fe_dfl_env; } +else version( Android ) +{ + private extern const fenv_t __fe_dfl_env; + const fenv_t* FE_DFL_ENV = &__fe_dfl_env; +} else { static assert( false, "Unsupported platform" ); diff --git a/src/core/stdc/locale.d b/src/core/stdc/locale.d index 80fa97ccc3a..6c96ff8c71b 100644 --- a/src/core/stdc/locale.d +++ b/src/core/stdc/locale.d @@ -91,6 +91,24 @@ else version(FreeBSD) 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 { static assert(false); diff --git a/src/core/stdc/math.d b/src/core/stdc/math.d index 505ad2bd43a..c7b5193eb4d 100644 --- a/src/core/stdc/math.d +++ b/src/core/stdc/math.d @@ -544,6 +544,75 @@ else version( FreeBSD ) int signbit(real x) { return __signbit(x); } } } +else version( Android ) +{ + enum + { + FP_INFINITE = 0x01, + FP_NAN = 0x02, + FP_NORMAL = 0x04, + FP_SUBNORMAL = 0x08, + FP_ZERO = 0x10, + } + + enum FP_FAST_FMAF; + + int __fpclassifyd(double); + int __fpclassifyf(float); + int __fpclassifyl(real); + + int __isfinitef(float); + int __isfinite(double); + int __isfinitel(real); + + int __isinff(float); + int __isinf(double); + int __isinfl(real); + + int isnanf(float); + int isnan(double); + 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 __isinf(x); } + int isinf(real x) { return __isinfl(x); } + + //int isnan(real-floating x); + int isnan(float x) { return isnanf(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 __signbitl(x); } + } +} extern (D) { diff --git a/src/core/stdc/stdio.d b/src/core/stdc/stdio.d index 4eb1435066f..4489b793c5c 100644 --- a/src/core/stdc/stdio.d +++ b/src/core/stdc/stdio.d @@ -146,6 +146,24 @@ else version (Solaris) else enum int _NFILE = 20; } +else version( Android ) +{ + enum + { + BUFSIZ = 1024, + EOF = -1, + FOPEN_MAX = 20, + FILENAME_MAX = 1024, + TMP_MAX = 308915776, + L_tmpnam = 1024 + } + + struct __sbuf + { + ubyte* _base; + int _size; + } +} else { static assert( false, "Unsupported platform" ); @@ -299,6 +317,37 @@ else version (Solaris) // __filler:10 } } +else version( Android ) +{ + align(1) struct _iobuf + { + 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; + } +} else { static assert( false, "Unsupported platform" ); @@ -446,6 +495,21 @@ else version (Solaris) shared stdout = &__iob[1]; shared stderr = &__iob[2]; } +else version( Android ) +{ + enum + { + _IOFBF = 0, + _IOLBF = 1, + _IONBF = 2, + } + + private extern shared FILE[3] __sF; + + shared stdin = &__sF[0]; + shared stdout = &__sF[1]; + shared stderr = &__sF[2]; +} else { static assert( false, "Unsupported platform" ); @@ -704,6 +768,21 @@ else version (Solaris) 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( Android ) +{ + // No unsafe pointer manipulation. + @trusted + { + void rewind(FILE*); + pure void clearerr(FILE*); + pure int feof(FILE*); + pure 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, "Unsupported platform" ); diff --git a/src/core/stdc/stdlib.d b/src/core/stdc/stdlib.d index a88c0b41122..a22278b2e4f 100644 --- a/src/core/stdc/stdlib.d +++ b/src/core/stdc/stdlib.d @@ -46,6 +46,7 @@ else version(linux) enum RAND_MAX = 0x7fffffff; else version(OSX) enum RAND_MAX = 0x7fffffff; else version(FreeBSD) enum RAND_MAX = 0x7fffffff; 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); diff --git a/src/core/stdc/time.d b/src/core/stdc/time.d index 4eac80f06ea..97f3ef6e936 100644 --- a/src/core/stdc/time.d +++ b/src/core/stdc/time.d @@ -79,7 +79,11 @@ else version( FreeBSD ) } else version (linux) { - enum clock_t CLOCKS_PER_SEC = 1000000; + enum clock_t CLOCKS_PER_SEC = 1_000_000; +} +else version (Android) +{ + enum clock_t CLOCKS_PER_SEC = 1_000_000; } clock_t clock(); @@ -121,6 +125,11 @@ else version (Solaris) void tzset(); extern __gshared const(char)*[2] tzname; } +else version( Android ) +{ + void tzset(); // non-standard + extern __gshared const(char)*[2] tzname; // non-standard +} else { static assert(false, "Unsupported platform");