generalization of syscalls

This commit is contained in:
veclavtlica
2026-10-07 17:16:18 +03:00
parent e7abe1a1d2
commit 3db75378c4
9 changed files with 231 additions and 40 deletions
+13 -13
View File
@@ -10,21 +10,21 @@
#include <stddef.h>
#include <stdint.h>
#if COM_DEF_TARGET == COM_DEF_TARGET_LINUX
#include <sys/syscall.h>
static inline long com_std_syscall(long number, long arg1, long arg2,
long arg3) {
long ret;
__asm__ volatile("syscall"
: "=a"(ret)
: "a"(number), "D"(arg1), "S"(arg2), "d"(arg3)
: "rcx", "r11", "memory");
return ret;
}
#endif
/* Generic system interface, linux/bsd derived. */
typedef void *com_std_fd;
#define COM_STD_OPEN_READ (1 << 0)
#define COM_STD_OPEN_WRITE (1 << 1)
com_std_fd com_std_open(char *path, uint32_t flags);
bool com_std_write(com_std_fd fd, char const *data, uint32_t bytes);
int32_t com_std_read(com_std_fd fd, char *data, uint32_t upto);
bool com_std_sfwd(com_std_fd fd, uint32_t bytes);
com_std_fd com_std_socket(bool isnetwork);
bool com_std_connect(com_std_fd sock, bool isnetwork, char *address);
void com_std_exit(uint32_t status) __attribute__((noreturn));
void com_std_close(com_std_fd fd);
/* TODO: Remove, use buffer semantics instead. */
/* Instead have a mmap functions here. */
/* Note: Freeing is done by passing 0 size to pointer. */
void *com_std_alloc(void *ptr, size_t size);