diff options
author | Jukka Jylänki <jujjyl@gmail.com> | 2014-03-16 04:02:08 +0200 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2014-03-28 23:06:17 -0400 |
commit | c4363b595cb2529345e3248b1f374595e83953ff (patch) | |
tree | 6bb97280c031f57a87c886bef10cd691fe60cbc7 | |
parent | 4fc97c69d66a81e93849ebbff1f6eed8be7dd174 (diff) |
Migrate to using musl 0.9.13 strchr, strrchr, index and rindex for better asm.js performance.
-rw-r--r-- | src/library.js | 22 | ||||
-rw-r--r-- | system/lib/libc/musl/src/string/index.c | 7 | ||||
-rw-r--r-- | system/lib/libc/musl/src/string/rindex.c | 7 | ||||
-rw-r--r-- | system/lib/libc/musl/src/string/strchr.c | 9 | ||||
-rw-r--r-- | system/lib/libc/musl/src/string/strrchr.c | 8 | ||||
-rw-r--r-- | system/lib/libcextra.symbols | 4 | ||||
-rw-r--r-- | tools/system_libs.py | 4 |
7 files changed, 39 insertions, 22 deletions
diff --git a/src/library.js b/src/library.js index fbef0d15..601a5c06 100644 --- a/src/library.js +++ b/src/library.js @@ -3639,28 +3639,6 @@ LibraryManager.library = { return pdest|0; }, - strchr: function(ptr, chr) { - ptr--; - do { - ptr++; - var val = {{{ makeGetValue('ptr', 0, 'i8') }}}; - if (val == chr) return ptr; - } while (val); - return 0; - }, - index: 'strchr', - - strrchr__deps: ['strlen'], - strrchr: function(ptr, chr) { - var ptr2 = ptr + _strlen(ptr); - do { - if ({{{ makeGetValue('ptr2', 0, 'i8') }}} == chr) return ptr2; - ptr2--; - } while (ptr2 >= ptr); - return 0; - }, - rindex: 'strrchr', - strdup__deps: ['strlen', 'malloc'], strdup: function(ptr) { var len = _strlen(ptr); diff --git a/system/lib/libc/musl/src/string/index.c b/system/lib/libc/musl/src/string/index.c new file mode 100644 index 00000000..dd611251 --- /dev/null +++ b/system/lib/libc/musl/src/string/index.c @@ -0,0 +1,7 @@ +#include <string.h> +#include <strings.h> + +char *index(const char *s, int c) +{ + return strchr(s, c); +} diff --git a/system/lib/libc/musl/src/string/rindex.c b/system/lib/libc/musl/src/string/rindex.c new file mode 100644 index 00000000..17df2bf2 --- /dev/null +++ b/system/lib/libc/musl/src/string/rindex.c @@ -0,0 +1,7 @@ +#include <string.h> +#include <strings.h> + +char *rindex(const char *s, int c) +{ + return strrchr(s, c); +} diff --git a/system/lib/libc/musl/src/string/strchr.c b/system/lib/libc/musl/src/string/strchr.c new file mode 100644 index 00000000..bfae8f9f --- /dev/null +++ b/system/lib/libc/musl/src/string/strchr.c @@ -0,0 +1,9 @@ +#include <string.h> + +char *__strchrnul(const char *, int); + +char *strchr(const char *s, int c) +{ + char *r = __strchrnul(s, c); + return *(unsigned char *)r == (unsigned char)c ? r : 0; +} diff --git a/system/lib/libc/musl/src/string/strrchr.c b/system/lib/libc/musl/src/string/strrchr.c new file mode 100644 index 00000000..635fb3c1 --- /dev/null +++ b/system/lib/libc/musl/src/string/strrchr.c @@ -0,0 +1,8 @@ +#include <string.h> + +void *__memrchr(const void *, int, size_t); + +char *strrchr(const char *s, int c) +{ + return __memrchr(s, c, strlen(s) + 1); +} diff --git a/system/lib/libcextra.symbols b/system/lib/libcextra.symbols index bc69bb65..dedfcedd 100644 --- a/system/lib/libcextra.symbols +++ b/system/lib/libcextra.symbols @@ -45,6 +45,7 @@ T ilogb T ilogbf T ilogbl + T index T iswalnum T iswalnum_l T iswalpha @@ -107,12 +108,14 @@ T regerror T regexec T regfree + T rindex T scalbnf D signgam T stpcpy T strcasecmp_l T strcasestr W strchrnul + T strchr T strcspn T strfmon T strfmon_l @@ -121,6 +124,7 @@ T strncasecmp_l T strncat T strnlen + T strrchr T strsep T strspn T strstr diff --git a/tools/system_libs.py b/tools/system_libs.py index 5a30547f..f61e2f79 100644 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -236,19 +236,23 @@ def calculate(temp_files, in_temp, stdout, stderr): 'bcmp.c', 'bcopy.c', 'bzero.c', + 'index.c', 'memccpy.c', 'memmem.c', 'mempcpy.c', 'memchr.c', 'memrchr.c', + 'rindex.c', 'stpcpy.c', 'strcasestr.c', + 'strchr.c', 'strchrnul.c', 'strcspn.c', 'strlcat.c', 'strlcpy.c', 'strncat.c', 'strnlen.c', + 'strrchr.c', 'strsep.c', 'strspn.c', 'strstr.c', |