feat: wi-fi - expand support and fix issues, add GUI components

This commit is contained in:
2026-08-07 10:36:53 +02:00
parent bbe1df62fd
commit 9eb21eb3e3
67 changed files with 4573 additions and 245 deletions
+3
View File
@@ -16,6 +16,9 @@ int islower(int c);
int isprint(int c);
int ispunct(int c);
int isxdigit(int c);
#define isascii(c) (((c) & ~0x7F) == 0)
#define toascii(c) ((c) & 0x7F)
int iscntrl(int c);
int isgraph(int c);
int toupper(int c);
+5
View File
@@ -9,8 +9,13 @@ extern "C" {
#define NAME_MAX 255
#define DT_UNKNOWN 0
#define DT_FIFO 1
#define DT_CHR 2
#define DT_DIR 4
#define DT_BLK 6
#define DT_REG 8
#define DT_LNK 10
#define DT_SOCK 12
struct dirent {
unsigned char d_type;
+82 -12
View File
@@ -9,18 +9,88 @@ extern "C" {
extern int errno;
#define ENOENT 2
#define EIO 5
#define ENOMEM 12
#define EACCES 13
#define EINVAL 22
#define ERANGE 34
#define ENOSYS 38
#define EISDIR 21
#define ENOTDIR 20
#define EEXIST 17
#define EBADF 9
#define EPERM 1
/* Linux errno numbering. */
#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 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 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 ETXTBSY 26
#define ENOMSG 42
#define EIDRM 43
#define ENOSTR 60
#define ENODATA 61
#define ETIME 62
#define ENOSR 63
#define ENOLINK 67
#define EPROTO 71
#define EMULTIHOP 72
#define EBADMSG 74
#define EOVERFLOW 75
#define EILSEQ 84
#define ENOTSOCK 88
#define EDESTADDRREQ 89
#define EMSGSIZE 90
#define EPROTOTYPE 91
#define ENOPROTOOPT 92
#define EPROTONOSUPPORT 93
#define EOPNOTSUPP 95 /* == ENOTSUP, Linux numbering */
#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 ETIMEDOUT 110
#define ECONNREFUSED 111
#define EHOSTUNREACH 113
#define EALREADY 114
#define EINPROGRESS 115
#define ESTALE 116
#define EDQUOT 122
#define ECANCELED 125
#define EOWNERDEAD 130
#define ENOTRECOVERABLE 131
#define ENOTSUP 95
#ifdef __cplusplus
}
+19 -5
View File
@@ -7,13 +7,27 @@
extern "C" {
#endif
#define O_RDONLY 0
#define O_WRONLY 1
#define O_RDWR 2
#define O_CREAT 0x40
#define O_TRUNC 0x200
#define O_RDONLY 0
#define O_WRONLY 1
#define O_RDWR 2
#define O_ACCMODE 3
#define O_CREAT 0x40
#define O_EXCL 0x80
#define O_TRUNC 0x200
#define O_APPEND 0x400
#define O_NONBLOCK 0x800
#define O_CLOEXEC 0x80000
#define F_DUPFD 0
#define F_GETFD 1
#define F_SETFD 2
#define F_GETFL 3
#define F_SETFL 4
#define FD_CLOEXEC 1
int open(const char *path, int flags, ...);
int fcntl(int fd, int cmd, ...);
#ifdef __cplusplus
}
+33
View File
@@ -23,5 +23,38 @@
#define PRIX16 "X"
#define PRIX32 "X"
#define PRIX64 "lX"
#define PRIo8 "o"
#define PRIo16 "o"
#define PRIo32 "o"
#define PRIo64 "lo"
#define PRIdPTR "ld"
#define PRIiPTR "li"
#define PRIuPTR "lu"
#define PRIxPTR "lx"
#define PRIXPTR "lX"
#define PRIdMAX "ld"
#define PRIuMAX "lu"
#define PRIxMAX "lx"
#define SCNd8 "d"
#define SCNd16 "d"
#define SCNd32 "d"
#define SCNd64 "ld"
#define SCNi8 "i"
#define SCNi16 "i"
#define SCNi32 "i"
#define SCNi64 "li"
#define SCNu8 "u"
#define SCNu16 "u"
#define SCNu32 "u"
#define SCNu64 "lu"
#define SCNx8 "x"
#define SCNx16 "x"
#define SCNx32 "x"
#define SCNx64 "lx"
#define SCNdPTR "ld"
#define SCNuPTR "lu"
#define SCNxPTR "lx"
#endif /* _LIBC_INTTYPES_H */
+39
View File
@@ -11,8 +11,47 @@ extern "C" {
#define INFINITY __builtin_inff()
#define NAN __builtin_nanf("")
/* C99 floating-point classification. */
#define FP_NAN 0
#define FP_INFINITE 1
#define FP_ZERO 2
#define FP_SUBNORMAL 3
#define FP_NORMAL 4
#define fpclassify(x) \
__builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, \
FP_ZERO, x)
#define isnan(x) __builtin_isnan(x)
#define isinf(x) __builtin_isinf(x)
#define isfinite(x) __builtin_isfinite(x)
#define isnormal(x) __builtin_isnormal(x)
#define signbit(x) __builtin_signbit(x)
double fabs(double x);
double frexp(double x, int *exp);
/* C89 modf and the C99 float variants assumed by hosted libstdc++
(--with-newlib crossconfig). The float forms wrap the double
implementations. */
double modf(double x, double *iptr);
float modff(float x, float *iptr);
double hypot(double x, double y);
float hypotf(float x, float y);
float acosf(float x);
float asinf(float x);
float atanf(float x);
float atan2f(float y, float x);
float coshf(float x);
float expf(float x);
float fmodf(float x, float y);
float frexpf(float x, int *exp);
float ldexpf(float x, int exp);
float logf(float x);
float log10f(float x);
float powf(float x, float y);
float sinhf(float x);
float tanf(float x);
float tanhf(float x);
double ldexp(double x, int n);
long double ldexpl(long double x, int n);
double floor(double x);
+9
View File
@@ -0,0 +1,9 @@
#ifndef _LIBC_MEMORY_H
#define _LIBC_MEMORY_H
#pragma once
/* Traditional alias for string.h. */
#include <string.h>
#endif /* _LIBC_MEMORY_H */
+175 -100
View File
@@ -19,106 +19,177 @@
extern "C" {
#endif
/* ====================================================================
Syscall numbers
==================================================================== */
#define MTK_SYS_EXIT 0
#define MTK_SYS_YIELD 1
#define MTK_SYS_SLEEP_MS 2
#define MTK_SYS_GETPID 3
#define MTK_SYS_PRINT 4
#define MTK_SYS_PUTCHAR 5
#define MTK_SYS_OPEN 6
#define MTK_SYS_READ 7
#define MTK_SYS_GETSIZE 8
#define MTK_SYS_CLOSE 9
#define MTK_SYS_READDIR 10
#define MTK_SYS_ALLOC 11
#define MTK_SYS_FREE 12
#define MTK_SYS_GETTICKS 13
#define MTK_SYS_GETMILLISECONDS 14
#define MTK_SYS_GETINFO 15
#define MTK_SYS_ISKEYAVAILABLE 16
#define MTK_SYS_GETKEY 17
#define MTK_SYS_GETCHAR 18
#define MTK_SYS_PING 19
#define MTK_SYS_SPAWN 20
#define MTK_SYS_WAITPID 23
#define MTK_SYS_TERMSIZE 24
#define MTK_SYS_GETARGS 25
#define MTK_SYS_RESET 26
#define MTK_SYS_SHUTDOWN 27
#define MTK_SYS_SETUNIXTIME 153
#define MTK_SYS_GETTIME 28
#define MTK_SYS_SOCKET 29
#define MTK_SYS_CONNECT 30
#define MTK_SYS_BIND 31
#define MTK_SYS_LISTEN 32
#define MTK_SYS_ACCEPT 33
#define MTK_SYS_SEND 34
#define MTK_SYS_RECV 35
#define MTK_SYS_CLOSESOCK 36
#define MTK_SYS_GETNETCFG 37
#define MTK_SYS_SETNETCFG 38
#define MTK_SYS_SENDTO 39
#define MTK_SYS_RECVFROM 40
#define MTK_SYS_FWRITE 41
#define MTK_SYS_FCREATE 42
#define MTK_SYS_TERMSCALE 43
#define MTK_SYS_RESOLVE 44
#define MTK_SYS_GETRANDOM 45
#define MTK_SYS_KLOG 46
#define MTK_SYS_MOUSESTATE 47
#define MTK_SYS_SETMOUSEBOUNDS 48
#define MTK_SYS_SPAWN_REDIR 49
#define MTK_SYS_CHILDIO_READ 50
#define MTK_SYS_CHILDIO_WRITE 51
#define MTK_SYS_WINCREATE 54
#define MTK_SYS_WINDESTROY 55
#define MTK_SYS_WINPRESENT 56
#define MTK_SYS_WINPOLL 57
#define MTK_SYS_WINENUM 58
#define MTK_SYS_WINMAP 59
#define MTK_SYS_WINUNMAP 97
#define MTK_SYS_WINSENDEVENT 60
#define MTK_SYS_PROCLIST 61
#define MTK_SYS_KILL 62
#define MTK_SYS_WINRESIZE 64
#define MTK_SYS_WINSETSCALE 65
#define MTK_SYS_WINGETSCALE 66
#define MTK_SYS_MEMSTATS 67
#define MTK_SYS_WINSETCURSOR 68
#define MTK_SYS_WINSETFLAGS 126
#define MTK_SYS_FDELETE 77
#define MTK_SYS_FMKDIR 78
#define MTK_SYS_FRENAME 94
#define MTK_SYS_DRIVELIST 79
#define MTK_SYS_DRIVELABEL 124
#define MTK_SYS_AUDIOOPEN 80
#define MTK_SYS_AUDIOCLOSE 81
#define MTK_SYS_AUDIOWRITE 82
#define MTK_SYS_AUDIOCTL 83
#define MTK_SYS_SETTZ 90
#define MTK_SYS_GETTZ 91
#define MTK_SYS_GETCWD 95
#define MTK_SYS_CHDIR 96
#define MTK_SYS_DUPHANDLE 98
#define MTK_SYS_WAIT_HANDLE 99
#define MTK_SYS_STREAM_CREATE 100
#define MTK_SYS_STREAM_READ 101
#define MTK_SYS_STREAM_WRITE 102
#define MTK_SYS_MAILBOX_CREATE 103
#define MTK_SYS_MAILBOX_SEND 104
#define MTK_SYS_MAILBOX_RECV 105
#define MTK_SYS_WAITSET_CREATE 106
#define MTK_SYS_WAITSET_ADD 107
#define MTK_SYS_WAITSET_REMOVE 108
#define MTK_SYS_WAITSET_WAIT 109
#define MTK_SYS_PROC_OPEN 110
#define MTK_SYS_SURFACE_CREATE 111
#define MTK_SYS_SURFACE_MAP 112
#define MTK_SYS_SURFACE_RESIZE 113
/* @SYSCALLS-BEGIN
Generated from Api/Syscall.hpp by scripts/montauk-syscalls.py.
Do not edit by hand; run 'make gen-syscalls' to refresh.
Wrapper functions below are hand-written. */
#define MTK_SYS_EXIT 0
#define MTK_SYS_YIELD 1
#define MTK_SYS_SLEEP_MS 2
#define MTK_SYS_GETPID 3
#define MTK_SYS_PRINT 4
#define MTK_SYS_PUTCHAR 5
#define MTK_SYS_OPEN 6
#define MTK_SYS_READ 7
#define MTK_SYS_GETSIZE 8
#define MTK_SYS_CLOSE 9
#define MTK_SYS_READDIR 10
#define MTK_SYS_ALLOC 11
#define MTK_SYS_FREE 12
#define MTK_SYS_GETTICKS 13
#define MTK_SYS_GETMILLISECONDS 14
#define MTK_SYS_GETINFO 15
#define MTK_SYS_ISKEYAVAILABLE 16
#define MTK_SYS_GETKEY 17
#define MTK_SYS_GETCHAR 18
#define MTK_SYS_PING 19
#define MTK_SYS_SPAWN 20
#define MTK_SYS_FBINFO 21
#define MTK_SYS_FBMAP 22
#define MTK_SYS_WAITPID 23
#define MTK_SYS_TERMSIZE 24
#define MTK_SYS_GETARGS 25
#define MTK_SYS_RESET 26
#define MTK_SYS_SHUTDOWN 27
#define MTK_SYS_GETTIME 28
#define MTK_SYS_SOCKET 29
#define MTK_SYS_CONNECT 30
#define MTK_SYS_BIND 31
#define MTK_SYS_LISTEN 32
#define MTK_SYS_ACCEPT 33
#define MTK_SYS_SEND 34
#define MTK_SYS_RECV 35
#define MTK_SYS_CLOSESOCK 36
#define MTK_SYS_GETNETCFG 37
#define MTK_SYS_SETNETCFG 38
#define MTK_SYS_SENDTO 39
#define MTK_SYS_RECVFROM 40
#define MTK_SYS_FWRITE 41
#define MTK_SYS_FCREATE 42
#define MTK_SYS_TERMSCALE 43
#define MTK_SYS_RESOLVE 44
#define MTK_SYS_GETRANDOM 45
#define MTK_SYS_KLOG 46
#define MTK_SYS_MOUSESTATE 47
#define MTK_SYS_SETMOUSEBOUNDS 48
#define MTK_SYS_SPAWN_REDIR 49
#define MTK_SYS_CHILDIO_READ 50
#define MTK_SYS_CHILDIO_WRITE 51
#define MTK_SYS_CHILDIO_WRITEKEY 52
#define MTK_SYS_CHILDIO_SETTERMSZ 53
#define MTK_SYS_WINCREATE 54
#define MTK_SYS_WINDESTROY 55
#define MTK_SYS_WINPRESENT 56
#define MTK_SYS_WINPOLL 57
#define MTK_SYS_WINENUM 58
#define MTK_SYS_WINMAP 59
#define MTK_SYS_WINSENDEVENT 60
#define MTK_SYS_PROCLIST 61
#define MTK_SYS_KILL 62
#define MTK_SYS_DEVLIST 63
#define MTK_SYS_WINRESIZE 64
#define MTK_SYS_WINSETSCALE 65
#define MTK_SYS_WINGETSCALE 66
#define MTK_SYS_MEMSTATS 67
#define MTK_SYS_WINSETCURSOR 68
#define MTK_SYS_DISKINFO 69
#define MTK_SYS_PARTLIST 70
#define MTK_SYS_DISKREAD 71
#define MTK_SYS_DISKWRITE 72
#define MTK_SYS_GPTINIT 73
#define MTK_SYS_GPTADD 74
#define MTK_SYS_FSMOUNT 75
#define MTK_SYS_FSFORMAT 76
#define MTK_SYS_FDELETE 77
#define MTK_SYS_FMKDIR 78
#define MTK_SYS_DRIVELIST 79
#define MTK_SYS_AUDIOOPEN 80
#define MTK_SYS_AUDIOCLOSE 81
#define MTK_SYS_AUDIOWRITE 82
#define MTK_SYS_AUDIOCTL 83
#define MTK_SYS_BTSCAN 84
#define MTK_SYS_BTCONNECT 85
#define MTK_SYS_BTDISCONNECT 86
#define MTK_SYS_BTLIST 87
#define MTK_SYS_BTINFO 88
#define MTK_SYS_SUSPEND 89
#define MTK_SYS_SETTZ 90
#define MTK_SYS_GETTZ 91
#define MTK_SYS_SETUSER 92
#define MTK_SYS_GETUSER 93
#define MTK_SYS_FRENAME 94
#define MTK_SYS_GETCWD 95
#define MTK_SYS_CHDIR 96
#define MTK_SYS_WINUNMAP 97
#define MTK_SYS_DUPHANDLE 98
#define MTK_SYS_WAIT_HANDLE 99
#define MTK_SYS_STREAM_CREATE 100
#define MTK_SYS_STREAM_READ 101
#define MTK_SYS_STREAM_WRITE 102
#define MTK_SYS_MAILBOX_CREATE 103
#define MTK_SYS_MAILBOX_SEND 104
#define MTK_SYS_MAILBOX_RECV 105
#define MTK_SYS_WAITSET_CREATE 106
#define MTK_SYS_WAITSET_ADD 107
#define MTK_SYS_WAITSET_REMOVE 108
#define MTK_SYS_WAITSET_WAIT 109
#define MTK_SYS_PROC_OPEN 110
#define MTK_SYS_SURFACE_CREATE 111
#define MTK_SYS_SURFACE_MAP 112
#define MTK_SYS_SURFACE_RESIZE 113
#define MTK_SYS_LOAD_LIB 114
#define MTK_SYS_UNLOAD_LIB 115
#define MTK_SYS_DLSYM 116
#define MTK_SYS_GETLIBBASE 117
#define MTK_SYS_CRASH_REPORT 118
#define MTK_SYS_CLIPBOARD_SET_TEXT 119
#define MTK_SYS_CLIPBOARD_GET_INFO 120
#define MTK_SYS_CLIPBOARD_GET_TEXT 121
#define MTK_SYS_CLIPBOARD_CLEAR 122
#define MTK_SYS_INPUT_WAIT 123
#define MTK_SYS_DRIVELABEL 124
#define MTK_SYS_NETSTATUS 125
#define MTK_SYS_WINSETFLAGS 126
#define MTK_SYS_DRIVEKIND 127
#define MTK_SYS_AUDIOLIST 128
#define MTK_SYS_AUDIOWAIT 129
#define MTK_SYS_THREAD_SPAWN 130
#define MTK_SYS_THREAD_EXIT 131
#define MTK_SYS_THREAD_JOIN 132
#define MTK_SYS_THREAD_SELF 133
#define MTK_SYS_FS_SYNC 134
#define MTK_SYS_POWER_REQUEST 135
#define MTK_SYS_READDIR_AT 136
#define MTK_SYS_BTSETADDR 137
#define MTK_SYS_BTBONDS 138
#define MTK_SYS_BTFORGET 139
#define MTK_SYS_SDR_COUNT 140
#define MTK_SYS_SDR_INFO 141
#define MTK_SYS_SDR_OPEN 142
#define MTK_SYS_SDR_CLOSE 143
#define MTK_SYS_SDR_START 144
#define MTK_SYS_SDR_STOP 145
#define MTK_SYS_SDR_READ 146
#define MTK_SYS_SDR_SETPARAM 147
#define MTK_SYS_SDR_GETPARAM 148
#define MTK_SYS_POWERINFO 149
#define MTK_SYS_FBFLIP 150
#define MTK_SYS_GETEXECPATH 151
#define MTK_SYS_STAT 152
#define MTK_SYS_SETUNIXTIME 153
#define MTK_SYS_DISPLAYINFO 154
#define MTK_SYS_DISPLAYMODES 155
#define MTK_SYS_DISPLAYSETMODE 156
#define MTK_SYS_DISPLAYBRIGHTNESS 157
#define MTK_SYS_WIFI_SCAN 158
#define MTK_SYS_WIFI_INFO 159
#define MTK_SYS_WIFI_CONNECT 160
#define MTK_SYS_WIFI_DISCONNECT 161
#define MTK_SYS_WIFI_SCAN_START 162
#define MTK_SYS_WIFI_RESULTS 163
#define MTK_SYS_WIFI_CONNECT_ASYNC 164
#define MTK_SYS_NETIFS 165
/* @SYSCALLS-END */
#define MTK_SOCK_TCP 1
#define MTK_SOCK_UDP 2
@@ -354,6 +425,10 @@ static inline int mtk_getargs(char *buf, unsigned long max_len) {
return (int)_mtk_syscall2(MTK_SYS_GETARGS, (long)buf, (long)max_len);
}
static inline int mtk_getexecpath(char *buf, unsigned long maxLen) {
return (int)mtk_syscall2(MTK_SYS_GETEXECPATH, (long)buf, (long)maxLen);
}
static inline int mtk_chdir(const char *path) {
return (int)_mtk_syscall1(MTK_SYS_CHDIR, (long)path);
}
+23 -1
View File
@@ -3,6 +3,8 @@
#pragma once
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
@@ -10,7 +12,26 @@ extern "C" {
typedef int sig_atomic_t;
typedef void (*sighandler_t)(int);
#define SIGINT 2
/* Linux signal numbering. Only SIGINT is ever delivered today; the
rest exist so hosted code can name them. */
#define SIGHUP 1
#define SIGINT 2
#define SIGQUIT 3
#define SIGILL 4
#define SIGTRAP 5
#define SIGABRT 6
#define SIGBUS 7
#define SIGFPE 8
#define SIGKILL 9
#define SIGUSR1 10
#define SIGSEGV 11
#define SIGUSR2 12
#define SIGPIPE 13
#define SIGALRM 14
#define SIGTERM 15
#define SIGCHLD 17
#define SIGCONT 18
#define SIGSTOP 19
#define SIG_DFL ((sighandler_t)0)
#define SIG_IGN ((sighandler_t)1)
@@ -18,6 +39,7 @@ typedef void (*sighandler_t)(int);
sighandler_t signal(int sig, sighandler_t handler);
int raise(int sig);
int kill(pid_t pid, int sig);
#ifdef __cplusplus
}
+60
View File
@@ -0,0 +1,60 @@
#ifndef _LIBC_SPAWN_H
#define _LIBC_SPAWN_H
#pragma once
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* posix_spawn for MontaukOS, layered on SYS_SPAWN.
*
* Limitations (kernel spawn model):
* - argv is joined into a single args string; arguments containing
* spaces are rejected with EINVAL (no quoting in the kernel).
* - envp is ignored (no environment transfer on spawn).
* - file actions must be empty: stdio redirection needs kernel
* support that does not exist yet, so any recorded action makes
* posix_spawn fail with ENOTSUP rather than misbehave silently.
*/
typedef struct {
short flags;
} posix_spawnattr_t;
typedef struct {
int action_count;
} posix_spawn_file_actions_t;
int posix_spawnattr_init(posix_spawnattr_t *attr);
int posix_spawnattr_destroy(posix_spawnattr_t *attr);
int posix_spawnattr_setflags(posix_spawnattr_t *attr, short flags);
int posix_spawnattr_getflags(const posix_spawnattr_t *attr, short *flags);
int posix_spawn_file_actions_init(posix_spawn_file_actions_t *actions);
int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *actions);
int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *actions,
int fd, int newfd);
int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *actions,
int fd);
int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *actions,
int fd, const char *path, int oflag,
mode_t mode);
int posix_spawn(pid_t *pid, const char *path,
const posix_spawn_file_actions_t *actions,
const posix_spawnattr_t *attr,
char *const argv[], char *const envp[]);
int posix_spawnp(pid_t *pid, const char *file,
const posix_spawn_file_actions_t *actions,
const posix_spawnattr_t *attr,
char *const argv[], char *const envp[]);
#ifdef __cplusplus
}
#endif
#endif /* _LIBC_SPAWN_H */
+21
View File
@@ -1,6 +1,12 @@
#ifndef _LIBC_STDIO_H
#define _LIBC_STDIO_H
/* Conventional guard marker: packages like GMP sniff the libc's stdio
include-guard name to detect that FILE is available. */
#ifndef _STDIO_H
#define _STDIO_H 1
#endif
#pragma once
#include <stdarg.h>
@@ -36,6 +42,21 @@ extern FILE *stdin;
extern FILE *stdout;
extern FILE *stderr;
int putc(int c, FILE *stream);
void rewind(FILE *stream);
int getchar(void);
typedef long fpos_t;
int fgetpos(FILE *stream, fpos_t *pos);
int fsetpos(FILE *stream, const fpos_t *pos);
void setbuf(FILE *stream, char *buf);
int fscanf(FILE *stream, const char *fmt, ...);
int scanf(const char *fmt, ...);
int vfscanf(FILE *stream, const char *fmt, va_list ap);
int fileno(FILE *stream);
FILE *fdopen(int fd, const char *mode);
int printf(const char *fmt, ...);
int fprintf(FILE *stream, const char *fmt, ...);
int sprintf(char *str, const char *fmt, ...);
+15 -1
View File
@@ -49,10 +49,24 @@ int unsetenv(const char *name);
int putenv(char *string);
void qsort(void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
int (*compar)(const void *, const void *));
void *bsearch(const void *key, const void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
long strtol(const char *nptr, char **endptr, int base);
unsigned long strtoul(const char *nptr, char **endptr, int base);
long long strtoll(const char *nptr, char **endptr, int base);
unsigned long long strtoull(const char *nptr, char **endptr, int base);
long long atoll(const char *nptr);
int mkstemp(char *template_);
char *mktemp(char *template_);
char *realpath(const char *path, char *resolved);
size_t mbstowcs(wchar_t *dst, const char *src, size_t n);
#define MB_CUR_MAX 1
int mblen(const char *s, size_t n);
int mbtowc(wchar_t *pwc, const char *s, size_t n);
int wctomb(char *s, wchar_t wc);
double strtod(const char *nptr, char **endptr);
float strtof(const char *nptr, char **endptr);
long double strtold(const char *nptr, char **endptr);
+3
View File
@@ -31,6 +31,9 @@ char *strpbrk(const char *s, const char *accept);
int strcasecmp(const char *s1, const char *s2);
int strncasecmp(const char *s1, const char *s2, size_t n);
int strcoll(const char *s1, const char *s2);
size_t strxfrm(char *dest, const char *src, size_t n);
char *strtok(char *str, const char *delim);
char *strtok_r(char *str, const char *delim, char **saveptr);
char *strstr(const char *haystack, const char *needle);
const char *strerror(int errnum);
+41
View File
@@ -0,0 +1,41 @@
#ifndef _LIBC_SYS_MMAN_H
#define _LIBC_SYS_MMAN_H
#pragma once
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Anonymous-memory mmap over SYS_ALLOC. SYS_ALLOC returns
* page-aligned process memory, which is exactly what callers like
* GCC's page allocator need. File-backed mappings are not
* supported and fail with ENODEV.
*/
#define PROT_NONE 0
#define PROT_READ 1
#define PROT_WRITE 2
#define PROT_EXEC 4
#define MAP_SHARED 0x01
#define MAP_PRIVATE 0x02
#define MAP_FIXED 0x10
#define MAP_ANONYMOUS 0x20
#define MAP_ANON MAP_ANONYMOUS
#define MAP_FAILED ((void *)-1)
void *mmap(void *addr, size_t length, int prot, int flags, int fd,
long offset);
int munmap(void *addr, size_t length);
int mprotect(void *addr, size_t length, int prot);
#ifdef __cplusplus
}
#endif
#endif /* _LIBC_SYS_MMAN_H */
+23
View File
@@ -0,0 +1,23 @@
#ifndef _LIBC_SYS_PARAM_H
#define _LIBC_SYS_PARAM_H
#pragma once
#include <limits.h>
#include <sys/types.h>
#ifndef MAXPATHLEN
#define MAXPATHLEN 4096
#endif
#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#endif
#define howmany(x, y) (((x) + ((y) - 1)) / (y))
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
#endif /* _LIBC_SYS_PARAM_H */
+44 -8
View File
@@ -12,19 +12,55 @@ extern "C" {
#define S_IFMT 0170000
#define S_IFDIR 0040000
#define S_IFREG 0100000
#define S_IFCHR 0020000
#define S_IFLNK 0120000
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
#define S_ISFIFO(mode) (0)
#define S_ISSOCK(mode) (0)
#define S_ISBLK(mode) (0)
/* stat() reports real permission bits: ext2 stores them natively, the
ramdisk takes them from the USTAR header, and FAT32 synthesizes them from
its read-only attribute. Changing them (chmod) is still not supported. */
#define S_IRWXU 0700
#define S_IRUSR 0400
#define S_IWUSR 0200
#define S_IXUSR 0100
#define S_IRWXG 0070
#define S_IRGRP 0040
#define S_IWGRP 0020
#define S_IXGRP 0010
#define S_IRWXO 0007
#define S_IROTH 0004
#define S_IWOTH 0002
#define S_IXOTH 0001
struct stat {
mode_t st_mode;
unsigned long st_size;
time_t st_mtime;
dev_t st_dev;
ino_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
off_t st_size;
blksize_t st_blksize;
blkcnt_t st_blocks;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
};
int mkdir(const char *path, unsigned int mode);
int stat(const char *path, struct stat *buf);
int fstat(int fd, struct stat *buf);
int mkdir(const char *path, unsigned int mode);
int stat(const char *path, struct stat *buf);
int fstat(int fd, struct stat *buf);
int lstat(const char *path, struct stat *buf);
int chmod(const char *path, mode_t mode);
int fchmod(int fd, mode_t mode);
mode_t umask(mode_t mask);
#ifdef __cplusplus
}
+13
View File
@@ -3,6 +3,12 @@
#pragma once
/* Fixed-width and pointer-sized integer types. Freestanding builds get
this from the kernel freestanding headers; the cross toolchain from
the GCC-provided stdint.h. Hosted code (e.g. libgcov) expects
intptr_t to be visible via the stdio/stdlib include chain. */
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
@@ -15,6 +21,13 @@ typedef unsigned int mode_t;
typedef unsigned int uid_t;
typedef unsigned int gid_t;
typedef long time_t;
typedef unsigned long ino_t;
typedef unsigned long dev_t;
typedef unsigned long nlink_t;
typedef long blkcnt_t;
typedef long blksize_t;
typedef long suseconds_t;
typedef int clockid_t;
#ifdef __cplusplus
}
+31
View File
@@ -0,0 +1,31 @@
#ifndef _LIBC_SYS_WAIT_H
#define _LIBC_SYS_WAIT_H
#pragma once
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/* POSIX status decoding. waitpid() encodes a normal exit as code<<8
and a killed/crashed child as the signal number in the low bits. */
#define WIFEXITED(s) (((s) & 0x7F) == 0)
#define WEXITSTATUS(s) (((s) >> 8) & 0xFF)
#define WIFSIGNALED(s) (((s) & 0x7F) != 0)
#define WTERMSIG(s) ((s) & 0x7F)
#define WIFSTOPPED(s) (0)
#define WSTOPSIG(s) (0)
#define WNOHANG 1
#define WUNTRACED 2
pid_t wait(int *status);
pid_t waitpid(pid_t pid, int *status, int options);
#ifdef __cplusplus
}
#endif
#endif /* _LIBC_SYS_WAIT_H */
+3
View File
@@ -34,6 +34,9 @@ struct tm *localtime(const time_t *timer);
time_t mktime(struct tm *tm);
size_t strftime(char *s, size_t max, const char *format, const struct tm *tm);
char *asctime(const struct tm *tm);
char *ctime(const time_t *timep);
#ifdef __cplusplus
}
#endif
+35
View File
@@ -4,11 +4,16 @@
#pragma once
#include <stddef.h>
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
#define F_OK 0
#define X_OK 1
#define W_OK 2
@@ -22,6 +27,36 @@ int chdir(const char *path);
char *getcwd(char *buf, size_t size);
int access(const char *path, int mode);
int isatty(int fd);
int unlink(const char *path);
int rmdir(const char *path);
int dup(int fd);
int dup2(int oldfd, int newfd);
pid_t getpid(void);
void _exit(int status) __attribute__((noreturn));
pid_t fork(void);
int execv(const char *path, char *const argv[]);
int execve(const char *path, char *const argv[], char *const envp[]);
int execvp(const char *file, char *const argv[]);
int pipe(int fds[2]);
long pathconf(const char *path, int name);
int getpagesize(void);
long sysconf(int name);
/* sysconf() names (Linux numbering). */
#define _SC_OPEN_MAX 4
#define _SC_PAGESIZE 30
#define _SC_PAGE_SIZE 30
#define _SC_NPROCESSORS_ONLN 84
/* pathconf() names (Linux numbering). */
#define _PC_LINK_MAX 0
#define _PC_MAX_CANON 1
#define _PC_MAX_INPUT 2
#define _PC_NAME_MAX 3
#define _PC_PATH_MAX 4
#define _PC_PIPE_BUF 5
extern char **environ;
unsigned int sleep(unsigned int seconds);
+25
View File
@@ -0,0 +1,25 @@
#ifndef _LIBC_UTIME_H
#define _LIBC_UTIME_H
#pragma once
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
struct utimbuf {
time_t actime;
time_t modtime;
};
/* Accepted for POSIX compatibility; the Montauk VFS does not support
setting file times. */
int utime(const char *path, const struct utimbuf *times);
#ifdef __cplusplus
}
#endif
#endif /* _LIBC_UTIME_H */
+29
View File
@@ -0,0 +1,29 @@
#ifndef _LIBC_WCHAR_H
#define _LIBC_WCHAR_H
#pragma once
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned int wint_t;
/* Opaque shift state for the (byte-oriented) C locale. */
typedef struct {
unsigned long __opaque;
} mbstate_t;
#define WEOF ((wint_t)-1)
/* Byte-oriented C locale only: one byte, one character. */
size_t mbstowcs(wchar_t *dst, const char *src, size_t n);
int mblen(const char *s, size_t n);
#ifdef __cplusplus
}
#endif
#endif /* _LIBC_WCHAR_H */