[Tinyx-devel] [PATCH] libc: add the strcmp on libc.
Status: Planning
Brought to you by:
davidcohen
From: David C. <da...@gm...> - 2007-12-11 23:09:25
|
Signed-off-by: David Cohen <da...@gm...> --- Makefile | 2 +- include/tinyx/libc/string.h | 6 ++++++ lib/Makefile | 1 + lib/libc/Makefile | 1 + lib/libc/string.c | 13 +++++++++++++ 5 files changed, 22 insertions(+), 1 deletions(-) create mode 100644 include/tinyx/libc/string.h create mode 100644 lib/Makefile create mode 100644 lib/libc/Makefile create mode 100644 lib/libc/string.c diff --git a/Makefile b/Makefile index bae3b3f..0ca9772 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ all-sources = $(shell git-ls-files) export ARCH AS LD CC AR NM STRIP OBJCOPY OBJDUMP AWK CFLAGS PYTHON INCLUDES -tinyx.dirs = arch/ kernel/ +tinyx.dirs = lib/ arch/ kernel/ tinyx.objs = $(patsubst %/, %/tyx_part.o, $(tinyx.dirs)) diff --git a/include/tinyx/libc/string.h b/include/tinyx/libc/string.h new file mode 100644 index 0000000..2455bcc --- /dev/null +++ b/include/tinyx/libc/string.h @@ -0,0 +1,6 @@ +#ifndef __TINYX_LIBC_STRING_H +#define __TINYX_LIBC_STRING_H + +int strcmp(const char *str1, const char *str2); + +#endif /* __TINYX_LIBC_STRING_H */ diff --git a/lib/Makefile b/lib/Makefile new file mode 100644 index 0000000..3231475 --- /dev/null +++ b/lib/Makefile @@ -0,0 +1 @@ +obj-y = libc/ diff --git a/lib/libc/Makefile b/lib/libc/Makefile new file mode 100644 index 0000000..f6fde72 --- /dev/null +++ b/lib/libc/Makefile @@ -0,0 +1 @@ +obj-y += string.o diff --git a/lib/libc/string.c b/lib/libc/string.c new file mode 100644 index 0000000..bc9bfb3 --- /dev/null +++ b/lib/libc/string.c @@ -0,0 +1,13 @@ +#include <tinyx/libc/string.h> + +int strcmp(const char *str1, const char *str2) +{ + while ((*str1) == (*str2)) { + if (!*str1++) + return 0; + str2++; + } + while ((*str1++) && (*str2++)); + + return (*str1) ? 1 : -1; +} -- 1.5.3.5 |