Skip to content

Commit b3a4062

Browse files
authored
Merge pull request #18 from weiso131/main
Move abs function from memory.c to new math.c
2 parents ceee53c + c44932f commit b3a4062

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ KERNEL_OBJS := timer.o mqueue.o pipe.o semaphore.o mutex.o error.o syscall.o tas
2121
KERNEL_OBJS := $(addprefix $(BUILD_KERNEL_DIR)/,$(KERNEL_OBJS))
2222
deps += $(KERNEL_OBJS:%.o=%.o.d)
2323

24-
LIB_OBJS := ctype.o malloc.o memory.o random.o stdio.o string.o queue.o
24+
LIB_OBJS := ctype.o malloc.o math.o memory.o random.o stdio.o string.o queue.o
2525
LIB_OBJS := $(addprefix $(BUILD_LIB_DIR)/,$(LIB_OBJS))
2626
deps += $(LIB_OBJS:%.o=%.o.d)
2727

lib/math.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* libc: Math function. */
2+
3+
#include <lib/libc.h>
4+
5+
/* Returns the absolute value of an integer. */
6+
int32_t abs(int32_t n)
7+
{
8+
return n >= 0 ? n : -n;
9+
}

lib/memory.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,3 @@ int32_t memcmp(const void *cs, const void *ct, uint32_t n)
122122
*/
123123
return (n == 0) ? 0 : ((*r1 < *r2) ? -1 : 1);
124124
}
125-
126-
/* Returns the absolute value of an integer. */
127-
int32_t abs(int32_t n)
128-
{
129-
return n >= 0 ? n : -n;
130-
}

0 commit comments

Comments
 (0)