diff options
author | Jukka Jylänki <jujjyl@gmail.com> | 2014-03-15 18:49:12 +0200 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2014-03-28 23:06:16 -0400 |
commit | 3a501858147d9d31573f24d1b352fbeb52d7c3f2 (patch) | |
tree | d2bf0bfceab21c829aa1bc188964e5e0666aaeec /system | |
parent | 58f9620df20ab6a9bf35c7c91075ecd81597b411 (diff) |
Migrate to using musl 0.9.13 libc atoi, atol and atoll for better asm.js performance.
Diffstat (limited to 'system')
-rw-r--r-- | system/lib/libc.symbols | 2 | ||||
-rw-r--r-- | system/lib/libc/musl/src/stdlib/atoi.c | 16 | ||||
-rw-r--r-- | system/lib/libc/musl/src/stdlib/atol.c | 17 | ||||
-rw-r--r-- | system/lib/libc/musl/src/stdlib/atoll.c | 17 | ||||
-rw-r--r-- | system/lib/libcextra.symbols | 1 |
5 files changed, 53 insertions, 0 deletions
diff --git a/system/lib/libc.symbols b/system/lib/libc.symbols index 53a27082..eb2053ce 100644 --- a/system/lib/libc.symbols +++ b/system/lib/libc.symbols @@ -50,6 +50,8 @@ T __towrite T __uflow T atof + T atoi + T atol W bulk_free W calloc W free diff --git a/system/lib/libc/musl/src/stdlib/atoi.c b/system/lib/libc/musl/src/stdlib/atoi.c new file mode 100644 index 00000000..9baca7b8 --- /dev/null +++ b/system/lib/libc/musl/src/stdlib/atoi.c @@ -0,0 +1,16 @@ +#include <stdlib.h> +#include <ctype.h> + +int atoi(const char *s) +{ + int n=0, neg=0; + while (isspace(*s)) s++; + switch (*s) { + case '-': neg=1; + case '+': s++; + } + /* Compute n as a negative number to avoid overflow on INT_MIN */ + while (isdigit(*s)) + n = 10*n - (*s++ - '0'); + return neg ? n : -n; +} diff --git a/system/lib/libc/musl/src/stdlib/atol.c b/system/lib/libc/musl/src/stdlib/atol.c new file mode 100644 index 00000000..140ea3ea --- /dev/null +++ b/system/lib/libc/musl/src/stdlib/atol.c @@ -0,0 +1,17 @@ +#include <stdlib.h> +#include <ctype.h> + +long atol(const char *s) +{ + long n=0; + int neg=0; + while (isspace(*s)) s++; + switch (*s) { + case '-': neg=1; + case '+': s++; + } + /* Compute n as a negative number to avoid overflow on LONG_MIN */ + while (isdigit(*s)) + n = 10*n - (*s++ - '0'); + return neg ? n : -n; +} diff --git a/system/lib/libc/musl/src/stdlib/atoll.c b/system/lib/libc/musl/src/stdlib/atoll.c new file mode 100644 index 00000000..b6930489 --- /dev/null +++ b/system/lib/libc/musl/src/stdlib/atoll.c @@ -0,0 +1,17 @@ +#include <stdlib.h> +#include <ctype.h> + +long long atoll(const char *s) +{ + long long n=0; + int neg=0; + while (isspace(*s)) s++; + switch (*s) { + case '-': neg=1; + case '+': s++; + } + /* Compute n as a negative number to avoid overflow on LLONG_MIN */ + while (isdigit(*s)) + n = 10*n - (*s++ - '0'); + return neg ? n : -n; +} diff --git a/system/lib/libcextra.symbols b/system/lib/libcextra.symbols index 096b261d..4018b3e2 100644 --- a/system/lib/libcextra.symbols +++ b/system/lib/libcextra.symbols @@ -22,6 +22,7 @@ T __wcscoll_l T __wcsxfrm_l W __wctype_l + T atoll T bsearch T btowc T ecvt |