diff --git a/cstdlib/include/bits/errno.h b/cstdlib/include/bits/errno.h new file mode 100644 index 0000000..d2e1eee --- /dev/null +++ b/cstdlib/include/bits/errno.h @@ -0,0 +1,134 @@ +#define EPERM 1 +#define ENOENT 2 +#define ESRCH 3 +#define EINTR 4 +#define EIO 5 +#define ENXIO 6 +#define E2BIG 7 +#define ENOEXEC 8 +#define EBADF 9 +#define ECHILD 10 +#define EAGAIN 11 +#define ENOMEM 12 +#define EACCES 13 +#define EFAULT 14 +#define ENOTBLK 15 +#define EBUSY 16 +#define EEXIST 17 +#define EXDEV 18 +#define ENODEV 19 +#define ENOTDIR 20 +#define EISDIR 21 +#define EINVAL 22 +#define ENFILE 23 +#define EMFILE 24 +#define ENOTTY 25 +#define ETXTBSY 26 +#define EFBIG 27 +#define ENOSPC 28 +#define ESPIPE 29 +#define EROFS 30 +#define EMLINK 31 +#define EPIPE 32 +#define EDOM 33 +#define ERANGE 34 +#define EDEADLK 35 +#define ENAMETOOLONG 36 +#define ENOLCK 37 +#define ENOSYS 38 +#define ENOTEMPTY 39 +#define ELOOP 40 +#define EWOULDBLOCK EAGAIN +#define ENOMSG 42 +#define EIDRM 43 +#define ECHRNG 44 +#define EL2NSYNC 45 +#define EL3HLT 46 +#define EL3RST 47 +#define ELNRNG 48 +#define EUNATCH 49 +#define ENOCSI 50 +#define EL2HLT 51 +#define EBADE 52 +#define EBADR 53 +#define EXFULL 54 +#define ENOANO 55 +#define EBADRQC 56 +#define EBADSLT 57 +#define EDEADLOCK EDEADLK +#define EBFONT 59 +#define ENOSTR 60 +#define ENODATA 61 +#define ETIME 62 +#define ENOSR 63 +#define ENONET 64 +#define ENOPKG 65 +#define EREMOTE 66 +#define ENOLINK 67 +#define EADV 68 +#define ESRMNT 69 +#define ECOMM 70 +#define EPROTO 71 +#define EMULTIHOP 72 +#define EDOTDOT 73 +#define EBADMSG 74 +#define EOVERFLOW 75 +#define ENOTUNIQ 76 +#define EBADFD 77 +#define EREMCHG 78 +#define ELIBACC 79 +#define ELIBBAD 80 +#define ELIBSCN 81 +#define ELIBMAX 82 +#define ELIBEXEC 83 +#define EILSEQ 84 +#define ERESTART 85 +#define ESTRPIPE 86 +#define EUSERS 87 +#define ENOTSOCK 88 +#define EDESTADDRREQ 89 +#define EMSGSIZE 90 +#define EPROTOTYPE 91 +#define ENOPROTOOPT 92 +#define EPROTONOSUPPORT 93 +#define ESOCKTNOSUPPORT 94 +#define EOPNOTSUPP 95 +#define ENOTSUP EOPNOTSUPP +#define EPFNOSUPPORT 96 +#define EAFNOSUPPORT 97 +#define EADDRINUSE 98 +#define EADDRNOTAVAIL 99 +#define ENETDOWN 100 +#define ENETUNREACH 101 +#define ENETRESET 102 +#define ECONNABORTED 103 +#define ECONNRESET 104 +#define ENOBUFS 105 +#define EISCONN 106 +#define ENOTCONN 107 +#define ESHUTDOWN 108 +#define ETOOMANYREFS 109 +#define ETIMEDOUT 110 +#define ECONNREFUSED 111 +#define EHOSTDOWN 112 +#define EHOSTUNREACH 113 +#define EALREADY 114 +#define EINPROGRESS 115 +#define ESTALE 116 +#define EUCLEAN 117 +#define ENOTNAM 118 +#define ENAVAIL 119 +#define EISNAM 120 +#define EREMOTEIO 121 +#define EDQUOT 122 +#define ENOMEDIUM 123 +#define EMEDIUMTYPE 124 +#define ECANCELED 125 +#define ENOKEY 126 +#define EKEYEXPIRED 127 +#define EKEYREVOKED 128 +#define EKEYREJECTED 129 +#define EOWNERDEAD 130 +#define ENOTRECOVERABLE 131 +#define ERFKILL 132 +#define EHWPOISON 133 diff --git a/cstdlib/include/errno.h b/cstdlib/include/errno.h new file mode 100644 index 0000000..0361b33 --- /dev/null +++ b/cstdlib/include/errno.h @@ -0,0 +1,27 @@ +#ifndef _ERRNO_H +#define _ERRNO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include + +#ifdef __GNUC__ +__attribute__((const)) +#endif +int *__errno_location(void); +#define errno (*__errno_location()) + +#ifdef _GNU_SOURCE +extern char *program_invocation_short_name, *program_invocation_name; +#endif + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/cstdlib/include/stdio.h b/cstdlib/include/stdio.h index f344430..0ef60b4 100644 --- a/cstdlib/include/stdio.h +++ b/cstdlib/include/stdio.h @@ -1,5 +1,12 @@ struct _IO_FILE { char __x; }; typedef struct _IO_FILE FILE; -// TODO(orca) -// int fprintf(FILE *__restrict, const char *__restrict, ...); +extern FILE *const stdin; +extern FILE *const stdout; +extern FILE *const stderr; + +#define stdin (stdin) +#define stdout (stdout) +#define stderr (stderr) + +int fprintf(FILE *__restrict, const char *__restrict, ...); diff --git a/cstdlib/src/__errno_location.c b/cstdlib/src/__errno_location.c new file mode 100644 index 0000000..6d0f1c9 --- /dev/null +++ b/cstdlib/src/__errno_location.c @@ -0,0 +1,9 @@ +#include + +int errno; + +int *__errno_location(void) +{ + // NOTE(orca): We might need a better solution if we eventually support wasm threads. + return &errno; +} diff --git a/cstdlib/src/fprintf.c b/cstdlib/src/fprintf.c new file mode 100644 index 0000000..d6a9fc0 --- /dev/null +++ b/cstdlib/src/fprintf.c @@ -0,0 +1,16 @@ +#include +// #include +#include + +int fprintf(FILE *restrict f, const char *restrict fmt, ...) +{ + // TODO(orca) + abort(); + + // int ret; + // va_list ap; + // va_start(ap, fmt); + // ret = vfprintf(f, fmt, ap); + // va_end(ap); + // return ret; +} diff --git a/samples/pong/src/main.c b/samples/pong/src/main.c index 9c8dc7a..d60bcaf 100644 --- a/samples/pong/src/main.c +++ b/samples/pong/src/main.c @@ -184,6 +184,8 @@ ORCA_EXPORT void OnFrameRefresh(void) mg_rectangle_fill(paddle.x, paddle.y, paddle.w, paddle.h); mg_image_draw(image, ball); + // mg_set_color(ballColor); + // mg_circle_fill(ball.x+ball.w/2, ball.y + ball.w/2, ball.w/2.); mg_matrix_pop(); diff --git a/sdk/orca.c b/sdk/orca.c index 081f79a..d7517f0 100644 --- a/sdk/orca.c +++ b/sdk/orca.c @@ -6,6 +6,7 @@ * *****************************************************************/ +#include"platform/orca_malloc.c" #include"platform/orca_memory.c" #include"platform/orca_strings.c" #include"platform/orca_log.c"