/* LRL version of ANSI C header http://flash-gordon.me.uk/ansi.c.txt */ linkname ""; // 4.10 GENERAL UTILITIES typedef size_t = count; typedef wchar_t = uint32; // UCS-4 typedef div_t = (var int quot, var int rem); typedef ldiv_t = (var long quot, var long rem); // Use none instead of NULL, which is a typed NULL alias int EXIT_FAILURE = 1; alias int EXIT_SUCCESS = 0; // Value from GNU libc alias int RAND_MAX = 2147483647; // TODO MB_CUR_MAX ? // 4.10.1 String conversion functions cdouble atof(byte+> nptr); int atoi(byte+> nptr); long atol(byte+> nptr); cdouble strtod(byte+> nptr, byte+>? var^ endptr); long strtol(byte+> nptr, byte+>? var^ endptr, int base); ulong strtoul(byte+> nptr, byte+>? var^ endptr, int base); // 4.10.2 Pseudo-random sequence generation functions int rand(); () srand(uint seed); // 4.10.3 Memory management functions // TODO size constraints (size == sizeof(T)) T own^? calloc[T](count nmemb, count size); () free[T](T own^? ptr); T own^? malloc[T](count size); U own^? realloc[T,U](T own^? ptr, count size); // kind of unsafe. type mismatches can not be detected with e.g. Valgrind // 4.10.4 Communication with the environment () abort(); int atexit(()()^ func); () exit(int status); shared byte+>? getenv(byte+> name); int system(byte ^string); // 4.10.5 Searching and sorting utilities // TODO size constraints (size == sizeof(T)) T^? bsearch[T](T^ key, T#[nmemb]^ base, count nmemb, count size, int(T^, T^)^ compar); () qsort[T](var T#[nmemb]^, count nmemb, count size, int(T^, T^)^ compar); // 4.10.6 Integer arithmetic functions int abs(int j); div_t div(int number, int denom); long labs(long j); ldiv_t ldiv(long number, long denom); // 4.10.7 Multibyte character functions int mblen(byte+> s, count n); int mbtowc(var wchar_t^? pwc, byte+>? s, count n); int wctomb(var byte+>? s, wchar_t wchar); // 4.10.8 Multibyte string functions count mbstowcs(var wchar_t^? pwcs, byte+> s, count n); count wcstombs(var byte+>? s, wchar_t^ pwcs, count n);