diff --git a/src/include/stdlib.h b/src/include/stdlib.h index 9f34e11..4d99f82 100644 --- a/src/include/stdlib.h +++ b/src/include/stdlib.h @@ -12,4 +12,6 @@ void free(void *ptr); _Noreturn void exit(int status); +int abs(int j); + #endif diff --git a/src/stdlib.c b/src/stdlib.c index aae99d7..9c4a2ef 100644 --- a/src/stdlib.c +++ b/src/stdlib.c @@ -12,3 +12,7 @@ void free(void *ptr) { _Noreturn void exit(int status) { sys_exit(status); } + +int abs(int i) { + return i > 0 ? i : -i; +}