diff --git a/ChangeLog b/ChangeLog index 8d8d37a1cf351a07ed8a363b1b254de1848a9c4c..6fb13b04a0b799d3af00313349e3127e7b76e6a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1297,6 +1297,8 @@ for the AT91 UC3A/B family of AVR32 MCUs. * confgs/avr32dev1 - Add support for the Atmel AVR32DEV1 board featuring the AT91UC3B0256 MCU. This board is produced by www.mcuzone.com. - * include/stdlib.h, lib/Makefile and lib/lib_abs.c - Add abs(). + * include/stdlib.h, lib/Makefile, lib/lib_abs.c, lib/lib_labs.c, + lib_labs.c, lib_llabs.c, lib_imaxabs.c - Add abs(), labs(), llabs(), and + imaxabs(). diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html index 9f1fd03aaed2b91f9305f4a2ff9f37ec7ac9acfa..99d372ebbe2bb9b9b8a8b8e011ef193d6b4cb2b1 100644 --- a/Documentation/NuttX.html +++ b/Documentation/NuttX.html @@ -1914,8 +1914,9 @@ nuttx-5.12 2010-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> for the AT91 UC3A/B family of AVR32 MCUs. * confgs/avr32dev1 - Add support for the Atmel AVR32DEV1 board featuring the AT91UC3B0256 MCU. This board is produced by www.mcuzone.com. - * include/stdlib.h, lib/Makefile and lib/lib_abs.c - Add abs(). - + * include/stdlib.h, lib/Makefile, lib/lib_abs.c, lib/lib_labs.c, + lib_labs.c, lib_llabs.c, lib_imaxabs.c - Add abs(), labs(), llabs(), and + imaxabs(). pascal-2.1 2010-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> diff --git a/include/stdlib.h b/include/stdlib.h index c30d07ee39230214bb0793b941a3aa145afeb167..7509768a19f7c3a23cb95646673db3c7bea6148a 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -41,7 +41,9 @@ ****************************************************************************/ #include <nuttx/config.h> +#include <nuttx/compiler.h> #include <sys/types.h> +#include <stdint.h> /**************************************************************************** * Definitions @@ -146,7 +148,12 @@ EXTERN FAR void *calloc(size_t, size_t); /* Misc */ -EXTERN int abs(int i); +EXTERN int abs(int j); +EXTERN long int labs(long int j); +#ifdef CONFIG_HAVE_LONG_LONG +EXTERN long long int llabs(long long int j); +#endif +EXTERN intmax_t imaxabs(intmax_t j); /* Sorting */ diff --git a/lib/Makefile b/lib/Makefile index b8897d842f5d03859b156db73eaf3b35e9cb98c2..a08e721562c6da199df78d4a977139c6cfff6578 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -75,7 +75,7 @@ ifeq ($(CONFIG_LIBC_FLOATINGPOINT),y) STDIO_SRCS += lib_dtoa.c endif -STDLIB_SRCS = lib_abs.c lib_rand.c lib_qsort.c +STDLIB_SRCS = lib_abs.c lib_imaxabs.c lib_labs.c lib_llabs.c lib_rand.c lib_qsort.c MATH_SRCS = lib_rint.c lib_fixedmath.c lib_b16sin.c lib_b16cos.c diff --git a/lib/lib_abs.c b/lib/lib_abs.c index 8ef131b875971ec12c1f19526be7c00429ee6d2f..39339b86cdcf13105ba745e69b094899c2bb4f4d 100644 --- a/lib/lib_abs.c +++ b/lib/lib_abs.c @@ -44,11 +44,11 @@ * Global Functions ************************************************************************/ -int abs(int i) +int abs(int j) { - if (i < 0) + if (j < 0) { - i = -i; + j = -j; } - return i; + return j; }