From 37b3b43b3e4837bf91852c48f8a186a9b0d9df21 Mon Sep 17 00:00:00 2001 From: g1n Date: Wed, 27 Jul 2022 17:57:48 +0300 Subject: [PATCH] Add abs function to --- src/include/stdlib.h | 2 ++ src/stdlib.c | 4 ++++ 2 files changed, 6 insertions(+) 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; +}