aboutsummaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
authorJukka Jylänki <jujjyl@gmail.com>2014-03-15 18:41:36 +0200
committerJukka Jylänki <jujjyl@gmail.com>2014-03-28 23:06:16 -0400
commit58f9620df20ab6a9bf35c7c91075ecd81597b411 (patch)
treec3a97f61a720386d90fab1fe90e3ba2320684b5c /system
parentcde38c81c2330c139fa5d7d12a9e3688c5059f9c (diff)
Migrate to using musl 0.9.13 libc bsearch to take advantage of compiled asm.js performance in the algorithm.
Diffstat (limited to 'system')
-rw-r--r--system/lib/libc/musl/src/stdlib/bsearch.c20
-rw-r--r--system/lib/libcextra.symbols1
2 files changed, 21 insertions, 0 deletions
diff --git a/system/lib/libc/musl/src/stdlib/bsearch.c b/system/lib/libc/musl/src/stdlib/bsearch.c
new file mode 100644
index 00000000..61d89367
--- /dev/null
+++ b/system/lib/libc/musl/src/stdlib/bsearch.c
@@ -0,0 +1,20 @@
+#include <stdlib.h>
+
+void *bsearch(const void *key, const void *base, size_t nel, size_t width, int (*cmp)(const void *, const void *))
+{
+ void *try;
+ int sign;
+ while (nel > 0) {
+ try = (char *)base + width*(nel/2);
+ sign = cmp(key, try);
+ if (!sign) return try;
+ else if (nel == 1) break;
+ else if (sign < 0)
+ nel /= 2;
+ else {
+ base = try;
+ nel -= nel/2;
+ }
+ }
+ return NULL;
+}
diff --git a/system/lib/libcextra.symbols b/system/lib/libcextra.symbols
index 54176b1d..096b261d 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 bsearch
T btowc
T ecvt
T err