From 17bfb0ef0a48330b1d54e61fe3c30d83528d2d90 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Wed, 25 Jan 2023 20:16:22 +0100 Subject: 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. --- src/user/lib/esemaphore.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/user/lib/esemaphore.c') diff --git a/src/user/lib/esemaphore.c b/src/user/lib/esemaphore.c index f58b510..3a3aa7f 100644 --- a/src/user/lib/esemaphore.c +++ b/src/user/lib/esemaphore.c @@ -5,27 +5,27 @@ #include void esem_signal(struct evil_sem *sem) { - _syscall_write(sem->signal, NULL, 0, 0, 0); + _sys_write(sem->signal, NULL, 0, 0, 0); } void esem_wait(struct evil_sem *sem) { - _syscall_read(sem->wait, NULL, 0, 0); + _sys_read(sem->wait, NULL, 0, 0); } struct evil_sem *esem_new(int value) { - handle_t ends_wait[2], ends_signal[2]; + hid_t ends_wait[2], ends_signal[2]; struct evil_sem *sem; if (value < 0) return NULL; - if (_syscall_pipe(ends_wait, 0) < 0) return NULL; - if (_syscall_pipe(ends_signal, 0) < 0) goto fail_signal; + if (_sys_pipe(ends_wait, 0) < 0) return NULL; + if (_sys_pipe(ends_signal, 0) < 0) goto fail_signal; if (!(sem = malloc(sizeof *sem))) goto fail_malloc; - if (!_syscall_fork(FORK_NOREAP, NULL)) { + if (!_sys_fork(FORK_NOREAP, NULL)) { close(ends_signal[1]); - while (_syscall_read(ends_signal[0], NULL, 0, 0) >= 0) { - if (!_syscall_fork(FORK_NOREAP, NULL)) { - _syscall_write(ends_wait[1], NULL, 0, 0, 0); + while (_sys_read(ends_signal[0], NULL, 0, 0) >= 0) { + if (!_sys_fork(FORK_NOREAP, NULL)) { + _sys_write(ends_wait[1], NULL, 0, 0, 0); exit(0); } } -- cgit v1.2.3