gcores ~/apps/Menu branch first commit

This commit is contained in:
cpi
2019-07-16 03:40:14 +00:00
parent 2d75a8d65d
commit 45737f787c
2136 changed files with 214 additions and 17128 deletions

View File

@@ -1,23 +0,0 @@
inline va_size(x& void) uint32 {
using size. uint32 = .x - 8;
func = .size;
}
inline va_start(x& void) void {
using size. uint32 = .x - 8;
func = .x - (.size + 8);
}
inline va_next<T>(ap& void) {
ap += ((sizeof(T) + (sizeof(word) - 1)) /
sizeof(word) * sizeof(word));
}
inline va_nexts<T>(ap& void, size& uint32) {
define {
x = ((sizeof(T) + (sizeof(word) - 1)) /
sizeof(word) * sizeof(word));
}
ap += x, size -= x;
}

View File

@@ -1,91 +0,0 @@
runtime call<T>(addr void) T = 1000;
runtime call1<T>(addr void, arg1 word) T = 1001;
runtime call2<T>(addr void, arg1 word, arg2 word) T = 1002;
runtime call3<T>(addr void, arg1 word, arg2 word, arg3 word) T = 1003;
runtime call4<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 word) T = 1004;
runtime call5<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 word, arg5 word) T = 1005;
runtime call6<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 word, arg5 word, arg6 word) T = 1006;
runtime call7<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 word, arg5 word, arg6 word, arg7 word) T = 1007;
runtime call8<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 word, arg5 word, arg6 word, arg7 word, arg8 word) T = 1008;
runtime call9<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 word, arg5 word, arg6 word, arg7 word, arg8 word, arg9 word) T = 1009;
runtime call10<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 word, arg5 word, arg6 word, arg7 word, arg8 word, arg9 word, arg10 word) T = 1010;
runtime call11<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 word, arg5 word, arg6 word, arg7 word, arg8 word, arg9 word, arg10 word, arg11 word) T = 1011;
runtime call12<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 word, arg5 word, arg6 word, arg7 word, arg8 word, arg9 word, arg10 word, arg11 word, arg12 word) T = 1012;
runtime call13<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 word, arg5 word, arg6 word, arg7 word, arg8 word, arg9 word, arg10 word, arg11 word, arg12 word, arg13 word) T = 1013;
runtime call14<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 word, arg5 word, arg6 word, arg7 word, arg8 word, arg9 word, arg10 word, arg11 word, arg12 word, arg13 word, arg14 word) T = 1014;
runtime call15<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 word, arg5 word, arg6 word, arg7 word, arg8 word, arg9 word, arg10 word, arg11 word, arg12 word, arg13 word, arg14 word, arg15 word) T = 1015;
runtime call16<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 word, arg5 word, arg6 word, arg7 word, arg8 word, arg9 word, arg10 word, arg11 word, arg12 word, arg13 word, arg14 word, arg15 word, arg16 word) T = 1016;
runtime call_64<T>(addr void) T = 1017;
runtime call_64_1<T>(addr void, arg1 word) T = 1018;
runtime call_64_2<T>(addr void, arg1 word, arg2 word) T = 1019;
runtime call_64_3<T>(addr void, arg1 word, arg2 word, arg3 word) T = 1020;
runtime call_64_4<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 word) T = 1021;
runtime call_64_5<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 word, arg5 word) T = 1022;
runtime call_64_6<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 word, arg5 word, arg6 word) T = 1023;
runtime call_64_7<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 word, arg5 word, arg6 word, arg7 word) T = 1024;
runtime call_64_8<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 word, arg5 word, arg6 word, arg7 word, arg8 word) T = 1025;
runtime callf<T>(addr void) T = 1026;
runtime callf_r<T>(addr void, arg1 word) T = 1027;
runtime callf_rr<T>(addr void, arg1 word, arg2 word) T = 1028;
runtime callf_rrr<T>(addr void, arg1 word, arg2 word, arg3 word) T = 1029;
runtime callf_rrrr<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 word) T = 1030;
runtime callf_f<T>(addr void, arg1 float) T = 1031;
runtime callf_ff<T>(addr void, arg1 float, arg2 float) T = 1032;
runtime callf_fff<T>(addr void, arg1 float, arg2 float, arg3 float) T = 1033;
runtime callf_fd<T>(addr void, arg1 float, arg2 double) T = 1034;
runtime callf_df<T>(addr void, arg1 double, arg2 float) T = 1035;
runtime callf_d<T>(addr void, arg1 double) T = 1036;
runtime callf_dd<T>(addr void, arg1 double, arg2 double) T = 1037;
runtime callf_ddd<T>(addr void, arg1 double, arg2 double, arg3 double) T = 1038;
runtime call_f<T>(addr void, arg1 float) T = 1039;
runtime call_ff<T>(addr void, arg1 float, arg2 float) T = 1040;
runtime call_fff<T>(addr void, arg1 float, arg2 float, arg3 float) T = 1041;
runtime call_ffff<T>(addr void, arg1 float, arg2 float, arg3 float, arg4 float) T = 1042;
runtime call_ffr<T>(addr void, arg1 float, arg2 float, arg3 word) T = 1043;
runtime call_rf<T>(addr void, arg1 word, arg2 float) T = 1044;
runtime call_rff<T>(addr void, arg1 word, arg2 float, arg3 float) T = 1045;
runtime call_rrf<T>(addr void, arg1 word, arg2 word, arg3 float) T = 1046;
runtime call_rrrf<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 float) T = 1047;
runtime call_rfff<T>(addr void, arg1 word, arg2 float, arg3 float, arg4 float) T = 1048;
runtime call_fffr<T>(addr void, arg1 float, arg2 float, arg3 float, arg4 word) T = 1049;
runtime call_rrff<T>(addr void, arg1 word, arg2 word, arg3 float, arg4 float) T = 1050;
runtime call_ffrr<T>(addr void, arg1 float, arg2 float, arg3 word, arg4 word) T = 1051;
runtime call_fr<T>(addr void, arg1 float, arg2 word) T = 1052;
runtime call_frr<T>(addr void, arg1 float, arg2 word, arg3 word) T = 1053;
runtime call_frrr<T>(addr void, arg1 float, arg2 word, arg3 word, arg4 word) T = 1054;
runtime call_d<T>(addr void, arg1 double) T = 1055;
runtime call_dd<T>(addr void, arg1 double, arg2 double) T = 1056;
runtime call_ddd<T>(addr void, arg1 double, arg2 double, arg3 double) T = 1057;
runtime call_dddd<T>(addr void, arg1 double, arg2 double, arg3 double, arg4 double) T = 1058;
runtime call_ddr<T>(addr void, arg1 double, arg2 double, arg3 word) T = 1059;
runtime call_rd<T>(addr void, arg1 word, arg2 double) T = 1060;
runtime call_rdd<T>(addr void, arg1 word, arg2 double, arg3 double) T = 1061;
runtime call_rrd<T>(addr void, arg1 word, arg2 word, arg3 double) T = 1062;
runtime call_rrrd<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 double) T = 1063;
runtime call_rddd<T>(addr void, arg1 word, arg2 double, arg3 double, arg4 double) T = 1064;
runtime call_dddr<T>(addr void, arg1 double, arg2 double, arg3 double, arg4 word) T = 1065;
runtime call_rrdd<T>(addr void, arg1 word, arg2 word, arg3 double, arg4 double) T = 1066;
runtime call_ddrr<T>(addr void, arg1 double, arg2 double, arg3 word, arg4 word) T = 1067;
runtime call_dr<T>(addr void, arg1 double, arg2 word) T = 1068;
runtime call_drr<T>(addr void, arg1 double, arg2 word, arg3 word) T = 1069;
runtime call_drrr<T>(addr void, arg1 double, arg2 word, arg3 word, arg4 word) T = 1070;
runtime call_df<T>(addr void, arg1 double, arg2 float) T = 1071;
runtime call_dff<T>(addr void, arg1 double, arg2 float, arg3 float) T = 1072;
runtime call_ddf<T>(addr void, arg1 double, arg2 double, arg3 float) T = 1073;
runtime call_dddf<T>(addr void, arg1 double, arg2 double, arg3 double, arg4 float) T = 1074;
runtime call_dfff<T>(addr void, arg1 double, arg2 float, arg3 float, arg4 float) T = 1075;
runtime call_fffd<T>(addr void, arg1 float, arg2 float, arg3 float, arg4 double) T = 1076;
runtime call_ddff<T>(addr void, arg1 double, arg2 double, arg3 float, arg4 float) T = 1077;
runtime call_ffdd<T>(addr void, arg1 float, arg2 float, arg3 double, arg4 double) T = 1078;
runtime call_ffd<T>(addr void, arg1 float, arg2 float, arg3 double) T = 1079;
runtime call_fd<T>(addr void, arg1 float, arg2 double) T = 1080;
runtime call_fdd<T>(addr void, arg1 float, arg2 double, arg3 double) T = 1081;
runtime call_fddd<T>(addr void, arg1 float, arg2 double, arg3 double, arg4 double) T = 1082;
runtime call_rrrrdrr<T>(addr void, arg1 word, arg2 word, arg3 word, arg4 word, arg5 double, arg6 word, arg7 word) T = 1083;

File diff suppressed because it is too large Load Diff

View File

@@ -1,503 +0,0 @@
module rt+, c+ {
import libc;
// #include <stdlib.h>
// #include <string.h>
func malloc(size size_t) void {
runtime malloc(size size_t) void = 100;
if (func = malloc(size)) == null {
printf("malloc(0x%x): out of memory.\n", size);
exit(1);
}
}
func realloc(ptr void, size size_t) void {
runtime realloc(ptr void, size size_t) void = 101;
if (func = realloc(ptr, size)) == null {
printf("realloc(0x%x): out of memory.\n", size);
exit(1);
}
}
func calloc(nmemb size_t, size size_t) void {
runtime calloc(nmemb size_t, size size_t) void = 102;
if (func = calloc(nmemb, size)) == null {
printf("calloc(0x%x): out of memory.\n", size);
exit(1);
}
}
func strdup(s. char) .char {
runtime strdup(s. char) .char = 103;
if (func = strdup(s)) == null {
printf("strdup: out of memory.\n");
exit(1);
}
}
runtime free(ptr void) = 104;
inline malloc_t<T>() .T {
func = malloc(sizeof(T));
#if objectid(T).func.constructor;
func->constructor();
#endif
}
inline free_t<T>(block. T) {
#if objectid(T).func.destructor;
block->destructor();
#endif
free(block);
}
// #include <string.h>
runtime strcpy(dest. char, src. char) .char = 105;
runtime strncpy(dest. char, src. char, n size_t) .char = 106;
runtime strlen(s. char) size_t = 107;
runtime strcmp(s1. char, s2. char) int = 108;
runtime strncmp(s1. char, s2. char, n size_t) int = 109;
runtime strcasecmp(s1. char, s2. char) int = 110;
runtime strncasecmp(s1. char, s2. char, n size_t) int = 111;
runtime strstr(haystack. char, needle. char) .char = 112;
runtime strchr(s. char, c int) .char = 113;
runtime strrchr(s. char, c int) .char = 114;
// #include <string.h>
runtime memcpy(dest void, src void, n size_t) void = 115;
runtime memmove(dest void, src void, n size_t) void = 116;
runtime memcmp(s1 void, s2 void, n size_t) int = 117;
// runtime memmem(haystack void, haystacklen size_t, needle void, needlelen size_t) void = 118;
runtime memset(s void, c int, n size_t) void = 119;
/*-
* Copyright (c) 2005 Pascal Gloor <pascal.gloor@spale.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
func memchr(s void, c int, n size_t) void {
if n {
var p. unsigned char = s;
for ;; {
if .p == unsigned char(c);
return p;
p++;
if !(--n);
break;
}
}
return null;
}
func memmem(l void, l_len size_t, s void, s_len size_t) void {
if !l_len or !s_len or l_len < s_len;
return null;
var cl. char = l, cs. char = s;
if s_len == 1;
return memchr(cl, .cs, 1);
var cur. char = cl, last. char = cl + l_len - s_len;
for ; cur <= last; cur += 1 {
if .cur == .cs and !memcmp(cur, cs, s_len);
return cur;
}
return null;
}
// #include <ctype.h>
runtime tolower(c int) int = 120;
runtime toupper(c int) int = 121;
runtime isalnum(c int) int = 122;
runtime isalpha(c int) int = 123;
runtime isascii(c int) int = 124;
runtime isblank(c int) int = 125;
runtime iscntrl(c int) int = 126;
runtime isdigit(c int) int = 127;
runtime isgraph(c int) int = 128;
runtime islower(c int) int = 129;
runtime isprint(c int) int = 130;
runtime ispunct(c int) int = 131;
runtime isspace(c int) int = 132;
runtime isupper(c int) int = 133;
runtime isxdigit(c int) int = 134;
func strupper(str. char) {
while .str;
.str = toupper(.str), str += 1;
}
func strlower(str. char) {
while .str;
.str = tolower(.str), str += 1;
}
func isnumeric(str. char) bool {
if !(.str);
return false;
for ;; {
if !isdigit(.str);
return false;
if !(.(++str));
return true;
}
}
// #include <stdlib.h>
runtime atoi(nptr. char) int = 135;
runtime atol(nptr. char) long = 136;
runtime atoll(nptr. char) dlong = 137;
runtime atof(nptr. char) double = 138;
runtime strtod(nptr. char, endptr++ char) double = 139;
runtime strtof(nptr. char, endptr++ char) float = 140;
// #include <stdlib.h>
runtime srand(seed unsigned int) = 141;
runtime rand() int = 142;
inline randf() float {
return float(rand()) / RAND_MAX;
}
inline random<T>(value T) T {
return randf() * value;
}
inline random2<T>(min T, max T) T {
return T(randf() * float(max - min + 1)) + min;
}
func srand2(a uint, b uint, c uint) {
a=a-b;a=a-c;a=a^(c>>13);
b=b-c;b=b-a;b=b^(a<<8);
c=c-a;c=c-b;c=c^(b>>13);
a=a-b;a=a-c;a=a^(c>>12);
b=b-c;b=b-a;b=b^(a<<16);
c=c-a;c=c-b;c=c^(b>>5);
a=a-b;a=a-c;a=a^(c>>3);
b=b-c;b=b-a;b=b^(a<<10);
c=c-a;c=c-b;c=c^(b>>15);
srand(c);
}
// #include <stdio.h>
runtime get_stdin() +FILE = 143;
runtime get_stdout() +FILE = 144;
runtime get_stderr() +FILE = 145;
// #include <stdio.h>
runtime fopen(pathname. char, mode. char) +FILE = 146;
runtime fdopen(fd int, mode. char) +FILE = 147;
runtime freopen(pathname. char, mode. char, stream+ FILE) +FILE = 148;
runtime fclose(stream+ FILE) int = 149;
runtime fileno(stream+ FILE) int = 150;
runtime fwrite(ptr void, size size_t, nmemb size_t, stream+ FILE) size_t = 151;
runtime fread(ptr void, size size_t, nmemb size_t, stream+ FILE) size_t = 152;
runtime fputc(c int, stream+ FILE) int = 153;
runtime fputs(s. char, stream+ FILE) int = 154;
runtime fgetc(stream+ FILE) int = 155;
runtime fgets(s. char, size int, stream+ FILE) .char = 156;
runtime feof(stream+ FILE) int = 157;
runtime fseek(stream+ FILE, offset long, whence int) int = 158;
runtime ftell(stream+ FILE) long = 159;
runtime fgetpos(stream+ FILE, pos+ fpos_t) int = 160;
runtime fsetpos(stream+ FILE, pos+ fpos_t) int = 161;
runtime fflush(stream+ FILE) int = 162;
runtime ferror(stream+ FILE) int = 163;
runtime rewind(stream+ FILE) = 164;
runtime clearerr(stream+ FILE) = 165;
// #include <dirent.h>
runtime opendir(name. char) +DIR = 166;
runtime fdopendir(fd int) +DIR = 167;
runtime readdir(dirp+ DIR) .struct_dirent = 168;
runtime seekdir(dirp+ DIR, offset long) = 169;
runtime telldir(dirp+ DIR) long = 170;
runtime rewinddir(dirp+ DIR) = 171;
runtime closedir(dirp+ DIR) = 172;
// #include <sys/stat.h>
// #include <unistd.h>
runtime mkdir(pathname. char, mode mode_t) int = 173;
runtime rmdir(pathname. char) int = 174;
runtime mkfifo(pathname. char, mode mode_t) int = 175;
// #include <sys/stat.h>
// #include <fcntl.h>
// #include <unistd.h>
runtime open(pathname. char, flags int) int = 176;
runtime creat(pathname. char, flags int, mode mode_t) int = 177;
runtime close(fd int) int = 178;
runtime read(fd int, buf void, count size_t) ssize_t = 179;
runtime write(fd int, buf void, count size_t) ssize_t = 180;
// #include <stdio.h>
runtime rename(oldpath. char, newpath. char) int = 181;
runtime remove(pathname. char) int = 182;
// #include <unistd.h>
runtime link(oldpath. char, newpath. char) int = 183;
runtime unlink(pathname. char) int = 184;
runtime symlink(target. char, linkpath. char) int = 185;
// #include <unistd.h>
// #include <sys/stat.h>
runtime stat(path. char, buf. struct_stat) int = 186;
runtime fstat(fd int, buf. struct_stat) int = 187;
// #include <unistd.h>
runtime chown(pathname. char, owner uid_t, group gid_t) int = 188;
runtime fchown(fd int, owner uid_t, group gid_t) int = 189;
// #include <sys/stat.h>
runtime chmod(pathname. char, mode mode_t) int = 190;
runtime fchmod(fd int, mode mode_t) int = 191;
// #include <unistd.h>
runtime chdir(path. char) int = 192;
runtime fchdir(fd int) int = 193;
runtime truncate(path. char, length off_t) int = 194;
runtime ftruncate(fd int, length off_t) int = 195;
// #include <sys/mount.h>
runtime mount(source. char, target. char, filesystemtype. char, mountflags unsigned long, data void) int = 196;
// #include <time.h>
runtime time(t. time_t) time_t = 197;
runtime asctime(tm. struct_tm) .char = 198;
runtime ctime(timep. time_t) .char = 199;
runtime gmtime(timep. time_t) .struct_tm = 200;
runtime localtime(timep. time_t) .struct_tm = 201;
runtime difftime(time1 time_t, time2 time_t) double = 202;
runtime mktime(tm. struct_tm) time_t = 203;
runtime clock() clock_t = 204;
runtime clock_getres(clk_id clockid_t, res. struct_timespec) int = 205;
runtime clock_gettime(clk_id clockid_t, tp. struct_timespec) int = 206;
runtime clock_settime(clk_id clockid_t, tp. struct_timespec) = 207;
// #include <sys/stat.h>
runtime umask(mask mode_t) mode_t = 208;
// #include <stdlib.h>
runtime getenv(name. char) .char = 209;
runtime setenv(name. char, value. char, overwrite int) int = 210;
runtime unsetenv(name. char) int = 211;
runtime putenv(string. char) int = 212;
runtime clearenv() int = 213;
// #include <unistd.h>
runtime getpid() pid_t = 214;
runtime getppid() pid_t = 215;
// #include <stdlib.h>
runtime system(command. char) int = 216;
// #include <errno.h>
runtime get_errno() int = 217;
runtime set_errno(err int) = 218;
// #include <stdlib.h>
runtime exit(status int) = 219;
// #include <stdio.h>
runtime vprintf(format. char, ap+ va_list) int = 220;
runtime vsprintf(str. char, format. char, ap+ va_list) int = 221;
runtime vsnprintf(str. char, size size_t, format. char, ap+ va_list) int = 222;
runtime vscanf(format. char, ap+ va_list) int = 223;
runtime vsscanf(str. char, format. char, ap+ va_list) int = 224;
runtime vfprintf(stream+ FILE, format. char, ap+ va_list) int = 225;
runtime vfscanf(stream+ FILE, format. char, ap+ va_list) int = 226;
func printf(format. char, ...) int {
return vprintf(format, va_start(format));
}
func sprintf(str. char, format. char, ...) int {
return vsprintf(str, format, va_start(str));
}
func snprintf(str. char, size size_t, format. char, ...) int {
return vsnprintf(str, size, format, va_start(str));
}
func scanf(format. char, ...) int {
return vscanf(format, va_start(format));
}
func sscanf(str. char, format. char, ...) int {
return vsscanf(str, format, va_start(str));
}
func fprintf(stream+ FILE, format. char, ...) int {
return vfprintf(stream, format, va_start(stream));
}
func fscanf(stream+ FILE, format. char, ...) int {
return vfscanf(stream, format, va_start(stream));
}
inline vsprintfp(format. char, ap void) .char {
var len int = vsnprintf(null, 0, format, ap);
vsnprintf(func = malloc(++len), len, format, ap);
}
func sprintfp(format. char, ...) .char {
return vsprintfp(format, va_start(format));
}
// #include <fcntl.h>
runtime fcntl(fd int, cmd int, arg word) int = 227;
runtime fcntl2(fd int, cmd int, arg1 word, arg2 word) int = 228;
runtime fcntl3(fd int, cmd int, arg1 word, arg2 word, arg3 word) int = 229;
runtime fcntl4(fd int, cmd int, arg1 word, arg2 word, arg3 word, arg4 word) int = 230;
// #include <sys/ioctl.h>
runtime ioctl(fd int, request unsigned long, arg word) int = 231;
runtime ioctl2(fd int, request unsigned long, arg1 word, arg2 word) int = 232;
runtime ioctl3(fd int, request unsigned long, arg1 word, arg2 word, arg3 word) int = 233;
runtime ioctl4(fd int, request unsigned long, arg1 word, arg2 word, arg3 word, arg4 word) int = 234;
// #include <utime.h>
runtime utime(filename. char, times. struct_utimbuf) int = 235;
runtime utimes(filename. char, times. struct_timeval) int = 236;
// #include <sys/mount.h>
runtime umount(target. char) int = 237;
runtime umount2(target. char, flags int) int = 238;
// #include <unistd.h>
runtime getcwd(buf. char, size size_t) .char = 239;
runtime sysconf(name int) long = 240;
runtime sleep(seconds unsigned int) int = 241;
runtime usleep(usec useconds_t) int = 242;
// #include <locale.h>
runtime setlocale(category int, locale. char) .char = 243;
runtime localeconv() .struct_lconv = 244;
// #include <stdio.h>
runtime popen(command. char, type. char) +FILE = 245;
runtime pclose(stream+ FILE) int = 246;
// #include <signal.h>
runtime kill(pid pid_t, sig int) int = 247;
// #include <sys/select.h>
runtime select(nfds int, readfds. fd_set, writefds. fd_set, exceptfds. fd_set, timeout. struct_timeval) int = 248;
// #include <sys/select.h>
runtime FD_CLR(fd int, set. fd_set) = 249;
runtime FD_ISSET(fd int, set. fd_set) int = 250;
runtime FD_SET(fd int, set. fd_set) = 251;
runtime FD_ZERO(set. fd_set) = 252;
// #include <poll.h>
runtime poll(fds. struct_pollfd, nfds nfds_t, timeout int) = 253;
// #include <arpa/inet.h>
// #include <sys/socket.h>
runtime socket(domain int, type int, protocol int) int = 254;
runtime getsockopt(sockfd int, level int, optname int, optval void, optlen. socklen_t) int = 255;
runtime setsockopt(sockfd int, level int, optname int, optval void, optlen socklen_t) int = 256;
runtime connect(sockfd int, addr. struct_sockaddr, addrlen socklen_t) int = 257;
runtime accept(sockfd int, addr. struct_sockaddr, addrlen. socklen_t) int = 258;
runtime bind(sockfd int, addr. struct_sockaddr, addrlen socklen_t) int = 259;
runtime listen(sockfd int, backlog int) int = 260;
runtime send(sockfd int, buf void, len size_t, flags int) ssize_t = 261;
runtime sendto(sockfd int, buf void, len size_t, flags int, dest_addr. struct_sockaddr, addrlen socklen_t) ssize_t = 262;
runtime recv(sockfd int, buf void, len size_t, flags int) ssize_t = 263;
runtime recvfrom(sockfd int, buf void, len size_t, flags int, src_addr. struct_sockaddr, addrlen. socklen_t) ssize_t = 264;
runtime getsockname(sockfd int, addr. struct_sockaddr, addrlen. socklen_t) int = 265;
runtime getpeername(sockfd int, addr. struct_sockaddr, addrlen. socklen_t) int = 266;
runtime shutdown(sockfd int, how int) int = 267;
// #include <arpa/inet.h>
// #include <netinet/in.h>
// #include <sys/socket.h>
runtime inet_aton(cp. char, inp. struct_in_addr) int = 268;
runtime inet_addr(cp. char) in_addr_t = 269;
runtime inet_network(cp. char) in_addr_t = 270;
runtime inet_ntoa(in struct_in_addr) .char = 271;
runtime inet_makeaddr(net in_addr_t, host in_addr_t) struct_in_addr = 272;
runtime inet_lnaof(in struct_in_addr) in_addr_t = 273;
runtime inet_netof(in struct_in_addr) in_addr_t = 274;
runtime inet_ntop(af int, src void, dst. char, size socklen_t) .char = 275;
runtime inet_pton(af int, src. char, dst void) int = 276;
// #include <netdb.h>
runtime gethostbyname(name. char) .struct_hostent = 277;
runtime gethostbyaddr(addr void, len socklen_t, type int) .struct_hostent = 278;
runtime sethostent(stayopen int) = 279;
runtime endhostent() = 280;
runtime gethostent() .struct_hostent = 281;
// #include <netdb.h>
runtime getnetent() .struct_netent = 282;
runtime getnetbyname(name. char) .struct_netent = 283;
runtime getnetbyaddr(net uint32, type int) .struct_netent = 284;
runtime setnetent(stayopen int) = 285;
runtime endnetent() = 286;
// #include <netdb.h>
runtime getservent() .struct_servent = 287;
runtime getservbyname(name. char, proto. char) .struct_servent = 288;
runtime getservbyport(port int, proto. char) .struct_servent = 289;
runtime setservent(stayopen int) = 290;
runtime endservent() = 291;
// #include <sys/mman.h>
runtime mmap(addr void, length size_t, prot int, flags int, fd int, offset off_t) void = 292;
runtime munmap(addr void, length size_t) int = 293;
runtime mprotect(addr void, len size_t, prot int) int = 294;
// #include <stdio.h>
runtime perror(s. char) = 295;
// #include <unistd.h>
runtime execv(path. char, argv++ char) int = 296;
runtime execvp(file. char, argv++ char) int = 297;
runtime fork() pid_t = 298;
func execl(path. char, ...) int {
return execv(path, va_start(path));
}
func execlp(file. char, ...) int {
return execvp(file, va_start(file));
}
// #include <sys/wait.h>
runtime wait(status. int) pid_t = 299;
runtime waitpid(pid pid_t, status. int, options int) pid_t = 300;
// #include <unistd.h>
runtime pipe(pipefd[2] int) int = 301;
runtime dup(oldfd int) int = 302;
runtime dup2(oldfd int, newfd int) int = 303;
// #include <unistd.h>
runtime readlink(path. char, buf. char, bufsiz size_t) ssize_t = 304;
// #include <stdlib.h>
runtime realpath(path. char, resolved_path. char) .char = 305;
// event, epoll, ...
}

View File

@@ -1,42 +0,0 @@
module rt+, c+ {
import libc;
// #include <dlfcn.h>
func dlopen(filename. char, flag int) void {
runtime dlopen(filename. char, flag int) void = 1;
if (func = dlopen(filename, flag)) == null;
printf("dlopen: %s\n", filename);
}
runtime dlerror() .char = 2;
runtime dlsym(handle void, symbol. char) void = 3;
runtime dlclose(handle void) int = 4;
// util
func dlopens(flag int, ...) void {
forvar ap. char* = va_start(flag), size uint32 = va_size(flag); size; {
if (func = dlopen(.ap, flag)) ~= null;
return;
va_nexts<char*>(ap, size);
}
return null;
}
func dlsyms(handle void, funcs. char*, ...) bool {
if handle == null;
return false;
forvar ap. char* = va_start(handle), size uint32 = va_size(handle); size; funcs += sizeof(char*) {
if (.funcs = dlsym(handle, .ap)) == null {
printf("dlsyms: %s\n", .ap);
return false;
}
va_nexts<char*>(ap, size);
}
return true;
}
}

View File

@@ -1,16 +0,0 @@
module rt+, c+ {
import libc;
// #include <pthread.h>
runtime pthread_create(thread. pthread_t, attr. pthread_attr_t, start_addr void, arg void, stack_size uint32 = 0x10000) int = 5;
runtime pthread_join(thread pthread_t, retval+ void) int = 6;
runtime pthread_self() pthread_t = 7;
runtime pthread_detach(thread pthread_t) int = 8;
runtime pthread_attr_init(attr. pthread_attr_t) int = 9;
runtime pthread_attr_destroy(attr. pthread_attr_t) int = 10;
runtime pthread_attr_setdetachstate(attr. pthread_attr_t, detachstate int) int = 11;
runtime pthread_attr_getdetachstate(attr. pthread_attr_t, detachstate. int) int = 12;
}

View File

@@ -1,21 +0,0 @@
typedef uchar unsigned char;
typedef ushort unsigned short;
typedef uint unsigned int;
typedef ulong unsigned long;
typedef ull unsigned dlong;
typedef uint8 unsigned int8;
typedef uint16 unsigned int16;
typedef uint32 unsigned int32;
typedef uint64 unsigned int64;
typedef uintptr unsigned intptr;
typedef uword unsigned word;
typedef byte uchar;
typedef void uintptr;
typedef bool int;
define {
null = void(0);
false = bool(0);
true = bool(1);
}