[liba] Add abs function for int

Change-Id: Ic133ff2f34c7ff24ecbec69d5f31e447a72ae4fe
This commit is contained in:
Hugo Saint-Vignes
2020-08-04 18:16:44 +02:00
committed by Émilie Feral
parent 0a92499dd7
commit 53e204db3a
4 changed files with 9 additions and 0 deletions

View File

@@ -33,6 +33,7 @@ ion_device_usb_src += $(addprefix ion/src/device/shared/usb/stack/descriptor/, \
# DFU code
ion_device_dfu_src += liba/src/abs.c
ion_device_dfu_src += liba/src/assert.c
ion_device_dfu_src += liba/src/strlen.c
ion_device_dfu_src += liba/src/strlcpy.c

View File

@@ -3,6 +3,7 @@ SFLAGS += -Iliba/include
liba_src += $(addprefix liba/src/, \
armv7m/setjmp.s \
armv7m/longjmp.s \
abs.c \
assert.c \
bzero.c \
ctype.c \

View File

@@ -13,6 +13,8 @@ void * calloc(size_t count, size_t size);
void abort(void) __attribute__((noreturn));
int abs(int n);
LIBA_END_DECLS
#endif

5
liba/src/abs.c Normal file
View File

@@ -0,0 +1,5 @@
#include <stdlib.h>
int abs(int n) {
return n < 0 ? -n : n;
}