mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
lib: move strlen()
Allow the function to be individually linkable, discardable, and overridable. Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Julien Grall <jgrall@amazon.com>
This commit is contained in:
1 parent
47cb18e069
commit
9d0c024c2f
3 files changed
+29
-15
No files matched your search
@@ -184,21 +184,6 @@ char *(strrchr)(const char *s, int c)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __HAVE_ARCH_STRLEN
|
||||
/**
|
||||
* strlen - Find the length of a string
|
||||
* @s: The string to be sized
|
||||
*/
|
||||
size_t (strlen)(const char * s)
|
||||
{
|
||||
const char *sc;
|
||||
|
||||
for (sc = s; *sc != '\0'; ++sc)
|
||||
/* nothing */;
|
||||
return sc - s;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __HAVE_ARCH_STRNLEN
|
||||
/**
|
||||
* strnlen - Find the length of a length-limited string
|
||||
|
||||
@@ -14,6 +14,7 @@ lib-y += muldiv64.o
|
||||
lib-y += parse-size.o
|
||||
lib-y += rbtree.o
|
||||
lib-y += sort.o
|
||||
lib-y += strlen.o
|
||||
lib-$(CONFIG_X86) += xxhash32.o
|
||||
lib-$(CONFIG_X86) += xxhash64.o
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 1991, 1992 Linus Torvalds
|
||||
*/
|
||||
|
||||
#include <xen/string.h>
|
||||
|
||||
/**
|
||||
* strlen - Find the length of a string
|
||||
* @s: The string to be sized
|
||||
*/
|
||||
size_t (strlen)(const char * s)
|
||||
{
|
||||
const char *sc;
|
||||
|
||||
for (sc = s; *sc != '\0'; ++sc)
|
||||
/* nothing */;
|
||||
return sc - s;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: C
|
||||
* c-file-style: "BSD"
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||