diff options
author | dzwdz | 2023-01-25 20:16:22 +0100 |
---|---|---|
committer | dzwdz | 2023-01-25 20:16:22 +0100 |
commit | 17bfb0ef0a48330b1d54e61fe3c30d83528d2d90 (patch) | |
tree | b3d4aed1f408edcb17fe5c86fccaeacaa2a5a48a /src/shared | |
parent | 2ad6ee8ed15d1bf898645a16dbc06991a3c1425e (diff) |
style: typedef structs, shorter namespaces
I've wanted to do this for a while, and since I've just had a relatively
large refactor commit (pcpy), this is as good of a time as any.
Typedefing structs was mostly inspired by Plan 9's coding style. It makes
some lines of code much shorter at basically no expense.
Everything related to userland kept old-style struct definitions, so as not
to force that style onto other people.
I also considered changing SCREAMING_ENUM_FIELDS to NicerLookingCamelcase,
but I didn't, just in case that'd be confusing.
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/include/camellia/syscalls.h | 86 | ||||
-rw-r--r-- | src/shared/include/camellia/types.h | 6 |
2 files changed, 46 insertions, 46 deletions
diff --git a/src/shared/include/camellia/syscalls.h b/src/shared/include/camellia/syscalls.h index 1de5368..5d63223 100644 --- a/src/shared/include/camellia/syscalls.h +++ b/src/shared/include/camellia/syscalls.h @@ -1,27 +1,27 @@ #pragma once -#define _SYSCALL_EXIT 0 -#define _SYSCALL_AWAIT 1 -#define _SYSCALL_FORK 2 -#define _SYSCALL_OPEN 3 -#define _SYSCALL_MOUNT 4 -#define _SYSCALL_DUP 5 -#define _SYSCALL_READ 6 -#define _SYSCALL_WRITE 7 -#define _SYSCALL_GETSIZE 8 -#define _SYSCALL_REMOVE 9 -#define _SYSCALL_CLOSE 10 -#define _SYSCALL_FS_WAIT 11 -#define _SYSCALL_FS_RESPOND 12 -#define _SYSCALL_MEMFLAG 13 -#define _SYSCALL_PIPE 14 -#define _SYSCALL_SLEEP 15 -#define _SYSCALL_FILICIDE 16 -#define _SYSCALL_INTR 17 -#define _SYSCALL_INTR_SET 18 - -#define _SYSCALL_EXECBUF 100 -#define _SYSCALL_DEBUG_KLOG 101 +#define _SYS_EXIT 0 +#define _SYS_AWAIT 1 +#define _SYS_FORK 2 +#define _SYS_OPEN 3 +#define _SYS_MOUNT 4 +#define _SYS_DUP 5 +#define _SYS_READ 6 +#define _SYS_WRITE 7 +#define _SYS_GETSIZE 8 +#define _SYS_REMOVE 9 +#define _SYS_CLOSE 10 +#define _SYS_FS_WAIT 11 +#define _SYS_FS_RESPOND 12 +#define _SYS_MEMFLAG 13 +#define _SYS_PIPE 14 +#define _SYS_SLEEP 15 +#define _SYS_FILICIDE 16 +#define _SYS_INTR 17 +#define _SYS_INTR_SET 18 + +#define _SYS_EXECBUF 100 +#define _SYS_DEBUG_KLOG 101 #ifndef ASM_FILE #include <camellia/types.h> @@ -31,12 +31,12 @@ long _syscall(long, long, long, long, long, long); /** Kills the current process. */ -_Noreturn void _syscall_exit(long ret); +_Noreturn void _sys_exit(long ret); /** Waits for a child to exit. * @return the value the child passed to exit() */ -long _syscall_await(void); +long _sys_await(void); /** Creates a copy of the current process, and executes it. * All user memory pages get copied too. @@ -46,20 +46,20 @@ long _syscall_await(void); * * @return 0 in the child, the CID in the parent. */ -long _syscall_fork(int flags, handle_t __user *fs_front); +long _sys_fork(int flags, hid_t __user *fs_front); -handle_t _syscall_open(const char __user *path, long len, int flags); -long _syscall_mount(handle_t h, const char __user *path, long len); -handle_t _syscall_dup(handle_t from, handle_t to, int flags); +hid_t _sys_open(const char __user *path, long len, int flags); +long _sys_mount(hid_t h, const char __user *path, long len); +hid_t _sys_dup(hid_t from, hid_t to, int flags); -long _syscall_read(handle_t h, void __user *buf, size_t len, long offset); -long _syscall_write(handle_t h, const void __user *buf, size_t len, long offset, int flags); -long _syscall_getsize(handle_t h); -long _syscall_remove(handle_t h); -long _syscall_close(handle_t h); +long _sys_read(hid_t h, void __user *buf, size_t len, long offset); +long _sys_write(hid_t h, const void __user *buf, size_t len, long offset, int flags); +long _sys_getsize(hid_t h); +long _sys_remove(hid_t h); +long _sys_close(hid_t h); -handle_t _syscall_fs_wait(char __user *buf, long max_len, struct ufs_request __user *res); -long _syscall_fs_respond(handle_t hid, const void __user *buf, long ret, int flags); +hid_t _sys_fs_wait(char __user *buf, long max_len, struct ufs_request __user *res); +long _sys_fs_respond(hid_t hid, const void __user *buf, long ret, int flags); /** Modifies the virtual address space. * @@ -70,18 +70,18 @@ long _syscall_fs_respond(handle_t hid, const void __user *buf, long ret, int fla * * @return address of the first affected page (usually == addr) */ -void __user *_syscall_memflag(void __user *addr, size_t len, int flags); -long _syscall_pipe(handle_t __user user_ends[2], int flags); +void __user *_sys_memflag(void __user *addr, size_t len, int flags); +long _sys_pipe(hid_t __user user_ends[2], int flags); -void _syscall_sleep(long ms); +void _sys_sleep(long ms); -void _syscall_filicide(void); -void _syscall_intr(void); -void _syscall_intr_set(void __user *ip); +void _sys_filicide(void); +void _sys_intr(void); +void _sys_intr_set(void __user *ip); /* see shared/execbuf.h */ -long _syscall_execbuf(void __user *buf, size_t len); +long _sys_execbuf(void __user *buf, size_t len); -void _syscall_debug_klog(const void __user *buf, size_t len); +void _sys_debug_klog(const void __user *buf, size_t len); #endif diff --git a/src/shared/include/camellia/types.h b/src/shared/include/camellia/types.h index bd17e51..3b9cfb4 100644 --- a/src/shared/include/camellia/types.h +++ b/src/shared/include/camellia/types.h @@ -11,9 +11,9 @@ #endif typedef void __user * userptr_t; -typedef int handle_t; +typedef int hid_t; -enum vfs_operation { +enum vfs_op { VFSOP_OPEN, VFSOP_READ, VFSOP_WRITE, @@ -23,7 +23,7 @@ enum vfs_operation { }; struct ufs_request { - enum vfs_operation op; + enum vfs_op op; size_t len; // how much was put in *buf size_t capacity; // how much output can be accepted by the caller void __user *id; // file id (returned by the open handler, passed to other calls) |