diff --git a/libs/libc/include/stdlib.h b/libs/libc/include/stdlib.h index cb49672d..25bab5b1 100644 --- a/libs/libc/include/stdlib.h +++ b/libs/libc/include/stdlib.h @@ -65,6 +65,15 @@ extern "C" /* Seeds the random number generator with the specified seed. */ void srand(unsigned int seed); + /* Returns the absolute value of an integer. */ + int abs(int val); + + /* Returns the absolute value of an integer. */ + long labs(long val); + + /* Returns the absolute value of an integer. */ + long long llabs(long long val); + #ifdef __cplusplus } #endif diff --git a/libs/libc/src/stdlib.cpp b/libs/libc/src/stdlib.cpp index 9bb532cc..addc8fd9 100644 --- a/libs/libc/src/stdlib.cpp +++ b/libs/libc/src/stdlib.cpp @@ -63,4 +63,19 @@ extern "C" syscall(SYS_exit, status); __lc_unreachable(); } + + int abs(int val) + { + return __builtin_abs(val); + } + + long labs(long val) + { + return __builtin_labs(val); + } + + long long llabs(long long val) + { + return __builtin_llabs(val); + } } \ No newline at end of file