summaryrefslogtreecommitdiff
path: root/src/user/app/tests/libc/esemaphore.c
diff options
context:
space:
mode:
authordzwdz2023-01-25 20:16:22 +0100
committerdzwdz2023-01-25 20:16:22 +0100
commit17bfb0ef0a48330b1d54e61fe3c30d83528d2d90 (patch)
treeb3d4aed1f408edcb17fe5c86fccaeacaa2a5a48a /src/user/app/tests/libc/esemaphore.c
parent2ad6ee8ed15d1bf898645a16dbc06991a3c1425e (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/user/app/tests/libc/esemaphore.c')
-rw-r--r--src/user/app/tests/libc/esemaphore.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/user/app/tests/libc/esemaphore.c b/src/user/app/tests/libc/esemaphore.c
index f1856ff..2f1d4bc 100644
--- a/src/user/app/tests/libc/esemaphore.c
+++ b/src/user/app/tests/libc/esemaphore.c
@@ -6,37 +6,37 @@
#include <unistd.h>
#include <user/lib/esemaphore.h>
-static void odd(handle_t out, struct evil_sem *sem1, struct evil_sem *sem2) {
- _syscall_write(out, "1", 1, -1, 0);
+static void odd(hid_t out, struct evil_sem *sem1, struct evil_sem *sem2) {
+ _sys_write(out, "1", 1, -1, 0);
esem_signal(sem1);
esem_wait(sem2);
- _syscall_write(out, "3", 1, -1, 0);
+ _sys_write(out, "3", 1, -1, 0);
esem_signal(sem1);
esem_wait(sem2);
- _syscall_write(out, "5", 1, -1, 0);
+ _sys_write(out, "5", 1, -1, 0);
esem_signal(sem1);
}
-static void even(handle_t out, struct evil_sem *sem1, struct evil_sem *sem2) {
+static void even(hid_t out, struct evil_sem *sem1, struct evil_sem *sem2) {
esem_wait(sem1);
- _syscall_write(out, "2", 1, -1, 0);
+ _sys_write(out, "2", 1, -1, 0);
esem_signal(sem2);
esem_wait(sem1);
- _syscall_write(out, "4", 1, -1, 0);
+ _sys_write(out, "4", 1, -1, 0);
esem_signal(sem2);
esem_wait(sem1);
- _syscall_write(out, "6", 1, -1, 0);
+ _sys_write(out, "6", 1, -1, 0);
esem_signal(sem2);
}
static void test_semaphore(void) {
struct evil_sem *sem1, *sem2;
- handle_t pipe[2];
- test(_syscall_pipe(pipe, 0) >= 0);
+ hid_t pipe[2];
+ test(_sys_pipe(pipe, 0) >= 0);
if (!fork()) {
sem1 = esem_new(0);
@@ -47,12 +47,12 @@ static void test_semaphore(void) {
exit(69);
} else {
even(pipe[1], sem1, sem2);
- test(_syscall_await() == 69);
+ test(_sys_await() == 69);
}
esem_free(sem1);
esem_free(sem2);
- _syscall_write(pipe[1], "|", 1, -1, 0);
+ _sys_write(pipe[1], "|", 1, -1, 0);
sem1 = esem_new(0);
sem2 = esem_new(0);
@@ -62,13 +62,13 @@ static void test_semaphore(void) {
exit(69);
} else {
odd(pipe[1], sem1, sem2);
- test(_syscall_await() == 69);
- _syscall_await();
+ test(_sys_await() == 69);
+ _sys_await();
}
esem_free(sem1);
esem_free(sem2);
- _syscall_filicide();
+ _sys_filicide();
exit(0);
} else {
close(pipe[1]);
@@ -76,7 +76,7 @@ static void test_semaphore(void) {
char buf[16];
size_t pos = 0;
for (;;) {
- int ret = _syscall_read(pipe[0], buf + pos, sizeof(buf) - pos, 0);
+ int ret = _sys_read(pipe[0], buf + pos, sizeof(buf) - pos, 0);
if (ret < 0) break;
pos += ret;
}
@@ -86,7 +86,7 @@ static void test_semaphore(void) {
test_fail();
}
- _syscall_await();
+ _sys_await();
}
}