aboutsummaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-01-09 16:01:58 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-01-09 16:01:58 -0800
commitb41145cc84edf93c0b7ad77477a3b98753a2c6d7 (patch)
tree016eb3ee6097f9392d231c1bbb82ea2b16379b6c /system
parenta48941b07c88f2aee0be9adbdabd9b4b045f7b65 (diff)
use musl memcpy instead of out handwritten js one
Diffstat (limited to 'system')
-rw-r--r--system/lib/libc.symbols5
-rw-r--r--system/lib/libc/musl/COPYRIGHT92
-rw-r--r--system/lib/libc/musl/memcpy.c29
3 files changed, 126 insertions, 0 deletions
diff --git a/system/lib/libc.symbols b/system/lib/libc.symbols
index d41f4140..b98a79e4 100644
--- a/system/lib/libc.symbols
+++ b/system/lib/libc.symbols
@@ -48,3 +48,8 @@ _ZNSt20bad_array_new_lengthC2Ev
_ZNSt20bad_array_new_lengthD0Ev
_ZNSt20bad_array_new_lengthD1Ev
_ZNSt20bad_array_new_lengthD2Ev
+memcpy
+llvm.memcpy.i32
+llvm.memcpy.i64
+llvm.memcpy.p0i8.p0i8.i32
+llvm.memcpy.p0i8.p0i8.i64
diff --git a/system/lib/libc/musl/COPYRIGHT b/system/lib/libc/musl/COPYRIGHT
new file mode 100644
index 00000000..c0817619
--- /dev/null
+++ b/system/lib/libc/musl/COPYRIGHT
@@ -0,0 +1,92 @@
+musl as a whole is licensed under the following standard MIT license:
+
+Copyright © 2005-2012 Rich Felker
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+Portions of this software are contributed or derived from software
+authored by third parties. Complete details on the copyright status of
+all code included in musl follows below:
+
+
+The TRE regular expression implementation (src/regex/reg* and
+src/regex/tre*) is Copyright © 2001-2008 Ville Laurikari and licensed
+under a 2-clause BSD license (license text in the source files). The
+included version has been heavily modified by Rich Felker in 2012, in
+the interests of size, simplicity, and namespace cleanliness.
+
+Most of the math library code (src/math/* and src/complex/*) is
+Copyright © 1993,2004 Sun Microsystems or
+Copyright © 2003-2011 David Schultz or
+Copyright © 2003-2009 Steven G. Kargl or
+Copyright © 2003-2009 Bruce D. Evans or
+Copyright © 2008 Stephen L. Moshier
+and labelled as such. All have been licensed under extremely
+permissive terms. See the comments in the individual files for
+details.
+
+The implementation of DES for crypt (src/misc/crypt_des.c) is
+Copyright © 1994 David Burren. It is licensed under a BSD license.
+
+The implementation of blowfish crypt (src/misc/crypt_blowfish.c) was
+originally written by Solar Designer and placed into the public
+domain. The code also comes with a fallback permissive license for use
+in jurisdictions that may not recognize the public domain.
+
+The smoothsort implementation (src/stdlib/qsort.c) is Copyright © 2011
+Valentin Ochs and is licensed under an MIT-style license.
+
+The BSD PRNG implementation (src/prng/random.c) and XSI search API
+(src/search/*.c) functions are Copyright © 2011 Szabolcs Nagy and
+licensed under following terms: "Permission to use, copy, modify,
+and/or distribute this code for any purpose with or without fee is
+hereby granted. There is no warranty."
+
+The x86_64 port was written by Nicholas J. Kain. Several files (crt)
+were released into the public domain; others are licensed under the
+standard MIT license terms at the top of this file. See individual
+files for their copyright status.
+
+The mips and microblaze ports were originally written by Richard
+Pennington for use in the ellcc project. The original code was adapted
+by Rich Felker for build system and code conventions during upstream
+integration. It is licensed under the standard MIT terms.
+
+The powerpc port was also originally written by Richard Pennington,
+and later supplemented and integrated by John Spencer. It is licensed
+under the standard MIT terms.
+
+All other files which have no copyright comments are original works
+Copyright © 2005-2012 Rich Felker, the main author of this library.
+The decision to exclude such comments is intentional, as it should be
+possible to carry around the complete source code on tiny storage
+media. All public header files (include/*) should be treated as Public
+Domain as they intentionally contain no content which can be covered
+by copyright. Some source modules may fall in this category as well.
+If you believe that a file is so trivial that it should be in the
+Public Domain, please contact me and, if I agree, I will explicitly
+release it from copyright.
+
+The following files are trivial, in my opinion not copyrightable in
+the first place, and hereby explicitly released to the Public Domain:
+
+All public headers: include/*
+Startup files: crt/*
diff --git a/system/lib/libc/musl/memcpy.c b/system/lib/libc/musl/memcpy.c
new file mode 100644
index 00000000..8e98302f
--- /dev/null
+++ b/system/lib/libc/musl/memcpy.c
@@ -0,0 +1,29 @@
+#include <string.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+#define SS (sizeof(size_t))
+#define ALIGN (sizeof(size_t)-1)
+#define ONES ((size_t)-1/UCHAR_MAX)
+
+void *memcpy(void *restrict dest, const void *restrict src, size_t n)
+{
+ unsigned char *d = dest;
+ const unsigned char *s = src;
+
+ if (((uintptr_t)d & ALIGN) != ((uintptr_t)s & ALIGN))
+ goto misaligned;
+
+ for (; ((uintptr_t)d & ALIGN) && n; n--) *d++ = *s++;
+ if (n) {
+ size_t *wd = (void *)d;
+ const size_t *ws = (const void *)s;
+
+ for (; n>=SS; n-=SS) *wd++ = *ws++;
+ d = (void *)wd;
+ s = (const void *)ws;
+misaligned:
+ for (; n; n--) *d++ = *s++;
+ }
+ return dest;
+}