| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #ifndef ARK_SYS_LIBC_H
- #define ARK_SYS_LIBC_H
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <stdint.h>
- #include <stdbool.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <sys/ioctl.h>
- #include <sys/mman.h>
- #include <sys/socket.h>
- #include <sys/un.h>
- #include <errno.h>
- #include <time.h>
- #include <signal.h>
- #include <spawn.h>
- #include <sys/wait.h>
- #include <sys/mount.h>
- #include <dirent.h>
- #include <pthread.h>
- #include <poll.h>
- #include <sys/epoll.h>
- #include <math.h>
- // linux/input.h is not available in the musl static SDK.
- // Define the input_event struct and constants we need directly.
- struct ark_input_event {
- unsigned long sec;
- unsigned long usec;
- unsigned short type;
- unsigned short code;
- int value;
- };
- #define ABS_X 0x00
- #define ABS_Y 0x01
- // ── Wrappers for variadic/macro C symbols unavailable in Swift's static musl SDK ──
- /// Non-variadic wrapper for open(path, flags, mode).
- static inline int ark_open(const char *path, int flags, mode_t mode) {
- return open(path, flags, mode);
- }
- /// Two-arg open wrapper (no mode).
- static inline int ark_open2(const char *path, int flags) {
- return open(path, flags);
- }
- /// Non-variadic wrapper for fcntl(fd, cmd).
- static inline int ark_fcntl(int fd, int cmd) {
- return fcntl(fd, cmd);
- }
- /// Non-variadic wrapper for fcntl(fd, cmd, arg).
- static inline int ark_fcntl_arg(int fd, int cmd, int arg) {
- return fcntl(fd, cmd, arg);
- }
- /// Wrapper to access errno (a macro in musl, invisible to Swift).
- static inline int ark_errno(void) {
- return errno;
- }
- /// Wrapper to set errno.
- static inline void ark_set_errno(int val) {
- errno = val;
- }
- /// Wrapper for read.
- static inline ssize_t ark_read(int fd, void *buf, size_t count) {
- return read(fd, buf, count);
- }
- /// Wrapper for write.
- static inline ssize_t ark_write(int fd, const void *buf, size_t count) {
- return write(fd, buf, count);
- }
- /// Wrapper for ioctl.
- static inline int ark_ioctl(int fd, unsigned long request, void *arg) {
- return ioctl(fd, (int)request, arg);
- }
- #endif // ARK_SYS_LIBC_H
|