summaryrefslogtreecommitdiff
path: root/libc/string/i386/strnlen.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-12-19 13:51:38 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-12-19 13:51:38 +0000
commit6c106c856412c027ff78a9661386b3a42a52cf36 (patch)
tree7ad4c7fbe228eca31768ba355ebf0d933a406cfe /libc/string/i386/strnlen.c
parent6232f9122d61ee11edca902d95e04144f9c5b3c1 (diff)
strncat: shorter version for i386, add small embedded test
memchr: add small embedded test strnlen: make small embedded test easier to use strncmp: reformat assembly to make it readable, no code changes (verified with objdump) text data bss dec hex filename - 46 0 0 46 2e libc/string/i386/strncat.os + 39 0 0 39 27 libc/string/i386/strncat.os
Diffstat (limited to 'libc/string/i386/strnlen.c')
-rw-r--r--libc/string/i386/strnlen.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/libc/string/i386/strnlen.c b/libc/string/i386/strnlen.c
index 066a11ef7..d9bce6485 100644
--- a/libc/string/i386/strnlen.c
+++ b/libc/string/i386/strnlen.c
@@ -34,6 +34,8 @@
#ifdef __USE_GNU
+#undef strnlen
+//#define strnlen TESTING
size_t strnlen(const char *s, size_t count)
{
int edx;
@@ -51,20 +53,22 @@ size_t strnlen(const char *s, size_t count)
);
return eax;
}
+#ifndef strnlen
libc_hidden_def(strnlen)
-
-#if 0
+#else
+/* Uncomment TESTING, gcc -D__USE_GNU -m32 -Os strnlen.c -o strnlen
+ * and run ./strnlen
+ */
int main()
{
- printf(strnlen2("abc\0def", -2) == 3 ? "ok\n" : "BAD!\n");
- printf(strnlen2("abc\0def", -1) == 3 ? "ok\n" : "BAD!\n");
- printf(strnlen2("abc\0def", 0) == 0 ? "ok\n" : "BAD!\n");
- printf(strnlen2("abc\0def", 1) == 1 ? "ok\n" : "BAD!\n");
- printf(strnlen2("abc\0def", 2) == 2 ? "ok\n" : "BAD!\n");
- printf(strnlen2("abc\0def", 3) == 3 ? "ok\n" : "BAD!\n");
- printf(strnlen2("abc\0def", 4) == 3 ? "ok\n" : "BAD!\n");
- printf(strnlen2("abc\0def", 5) == 3 ? "ok\n" : "BAD!\n");
- return 0;
+ printf(strnlen("abc\0def", -2) == 3 ? "ok\n" : "BAD!\n");
+ printf(strnlen("abc\0def", -1) == 3 ? "ok\n" : "BAD!\n");
+ printf(strnlen("abc\0def", 0) == 0 ? "ok\n" : "BAD!\n");
+ printf(strnlen("abc\0def", 1) == 1 ? "ok\n" : "BAD!\n");
+ printf(strnlen("abc\0def", 2) == 2 ? "ok\n" : "BAD!\n");
+ printf(strnlen("abc\0def", 3) == 3 ? "ok\n" : "BAD!\n");
+ printf(strnlen("abc\0def", 4) == 3 ? "ok\n" : "BAD!\n");
+ printf(strnlen("abc\0def", 5) == 3 ? "ok\n" : "BAD!\n");
}
#endif