am 7915b22e: am a4b20d71: am b8e1033c: (-s ours) am e5412a9a: (-s ours) Reconcile with jb-mr1-release - do not merge

* commit '7915b22e8f70b80a9fc2c41f9734194c58b546fc':
diff --git a/ABI-bugs.txt b/ABI-bugs.txt
new file mode 100644
index 0000000..83ee952
--- /dev/null
+++ b/ABI-bugs.txt
@@ -0,0 +1,15 @@
+KNOWN ABI BUGS
+--------------
+
+  time_t is 32-bit. http://b/5819737
+
+  off_t is 32-bit. There is off64_t, but no _FILE_OFFSET_BITS support.
+
+  sigset_t is too small on ARM and x86 (but correct on MIPS), so support
+  for real-time signals is broken. http://b/5828899
+
+  Too few TLS slots mean we can't allocate 128 pthread_key_t instances,
+  which POSIX says should be the minimum.
+
+  atexit(3) handlers registered by a shared library aren't called on
+  dlclose(3); this only affects ARM. http://b/4998315
diff --git a/libc/Android.mk b/libc/Android.mk
index 6a77deb..b033790 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -8,68 +8,12 @@
 	$(syscall_src) \
 	unistd/abort.c \
 	unistd/alarm.c \
-	unistd/brk.c \
-	unistd/daemon.c \
-	unistd/eventfd.c \
 	unistd/exec.c \
-	unistd/fcntl.c \
 	unistd/fnmatch.c \
-	unistd/fstatfs.c \
-	unistd/ftime.c \
-	unistd/ftok.c \
-	unistd/getdtablesize.c \
-	unistd/gethostname.c \
 	unistd/getopt_long.c \
-	unistd/getpgrp.c \
-	unistd/getpriority.c \
-	unistd/getpt.c \
-	unistd/initgroups.c \
-	unistd/isatty.c \
-	unistd/issetugid.c \
-	unistd/killpg.c \
-	unistd/lseek64.c \
-	unistd/mmap.c \
-	unistd/open.c \
-	unistd/openat.c \
-	unistd/opendir.c \
-	unistd/pathconf.c \
-	unistd/perror.c \
-	unistd/popen.c \
-	unistd/pread.c \
-	unistd/pselect.c \
-	unistd/ptsname.c \
-	unistd/ptsname_r.c \
-	unistd/pwrite.c \
-	unistd/raise.c \
-	unistd/reboot.c \
-	unistd/recv.c \
-	unistd/sbrk.c \
-	unistd/send.c \
-	unistd/setegid.c \
-	unistd/setuid.c \
-	unistd/seteuid.c \
-	unistd/setreuid.c \
-	unistd/setresuid.c \
-	unistd/setpgrp.c \
-	unistd/sigblock.c \
-	unistd/siginterrupt.c \
-	unistd/siglist.c \
-	unistd/signal.c \
-	unistd/signame.c \
-	unistd/sigsetmask.c \
-	unistd/sigsuspend.c \
-	unistd/sigwait.c \
-	unistd/sleep.c \
-	unistd/statfs.c \
 	unistd/syslog.c \
 	unistd/system.c \
-	unistd/tcgetpgrp.c \
-	unistd/tcsetpgrp.c \
 	unistd/time.c \
-	unistd/umount.c \
-	unistd/unlockpt.c \
-	unistd/usleep.c \
-	unistd/wait.c \
 	stdio/asprintf.c \
 	stdio/clrerr.c \
 	stdio/fclose.c \
@@ -84,7 +28,6 @@
 	stdio/fileno.c \
 	stdio/findfp.c \
 	stdio/flags.c \
-	stdio/flockfile.c \
 	stdio/fopen.c \
 	stdio/fprintf.c \
 	stdio/fpurge.c \
@@ -123,7 +66,6 @@
 	stdio/sscanf.c \
 	stdio/stdio.c \
 	stdio/tempnam.c \
-	stdio/tmpfile.c \
 	stdio/tmpnam.c \
 	stdio/ungetc.c \
 	stdio/vasprintf.c \
@@ -136,37 +78,13 @@
 	stdio/vsscanf.c \
 	stdio/wbuf.c \
 	stdio/wsetup.c \
-	stdio/__fgets_chk.c \
-	stdio/__snprintf_chk.c \
-	stdio/__sprintf_chk.c \
-	stdio/__vsnprintf_chk.c \
-	stdio/__vsprintf_chk.c \
-	stdlib/_rand48.c \
-	stdlib/assert.c \
 	stdlib/atexit.c \
-	stdlib/atoi.c \
-	stdlib/atol.c \
-	stdlib/atoll.c \
-	stdlib/bsearch.c \
 	stdlib/ctype_.c \
-	stdlib/div.c \
 	stdlib/exit.c \
 	stdlib/getenv.c \
-	stdlib/jrand48.c \
-	stdlib/ldiv.c \
-	stdlib/lldiv.c \
-	stdlib/locale.c \
-	stdlib/lrand48.c \
-	stdlib/mrand48.c \
-	stdlib/nrand48.c \
 	stdlib/putenv.c \
 	stdlib/qsort.c \
-	stdlib/seed48.c \
 	stdlib/setenv.c \
-	stdlib/setjmperr.c \
-	stdlib/srand48.c \
-	stdlib/strntoimax.c \
-	stdlib/strntoumax.c \
 	stdlib/strtod.c \
 	stdlib/strtoimax.c \
 	stdlib/strtol.c \
@@ -176,131 +94,119 @@
 	stdlib/strtoumax.c \
 	stdlib/tolower_.c \
 	stdlib/toupper_.c \
-	stdlib/wchar.c \
 	string/index.c \
-	string/memccpy.c \
-	string/memchr.c \
-	string/memmem.c \
-	string/memrchr.c \
-	string/memswap.c \
 	string/strcasecmp.c \
-	string/strcasestr.c \
 	string/strcat.c \
 	string/strchr.c \
-	string/strcoll.c \
 	string/strcspn.c \
 	string/strdup.c \
 	string/strlcat.c \
 	string/strlcpy.c \
 	string/strncat.c \
 	string/strncpy.c \
-	string/strndup.c \
-	string/strnlen.c \
 	string/strpbrk.c \
 	string/strrchr.c \
 	string/strsep.c \
 	string/strspn.c \
 	string/strstr.c \
 	string/strtok.c \
-	string/strtotimeval.c \
-	string/__memcpy_chk.c \
-	string/__memmove_chk.c \
-	string/__memset_chk.c \
-	string/__strcat_chk.c \
-	string/__strcpy_chk.c \
-	string/__strlcat_chk.c \
-	string/__strlcpy_chk.c \
-	string/__strlen_chk.c \
-	string/__strncat_chk.c \
-	string/__strncpy_chk.c \
-	wchar/wcpcpy.c \
-	wchar/wcpncpy.c \
-	wchar/wcscasecmp.c \
-	wchar/wcscat.c \
-	wchar/wcschr.c \
-	wchar/wcscmp.c \
-	wchar/wcscoll.c \
-	wchar/wcscpy.c \
-	wchar/wcscspn.c \
-	wchar/wcsdup.c \
-	wchar/wcslcat.c \
-	wchar/wcslcpy.c \
-	wchar/wcslen.c \
-	wchar/wcsncasecmp.c \
-	wchar/wcsncat.c \
-	wchar/wcsncmp.c \
-	wchar/wcsncpy.c \
-	wchar/wcsnlen.c \
-	wchar/wcspbrk.c \
-	wchar/wcsrchr.c \
-	wchar/wcsspn.c \
-	wchar/wcsstr.c \
-	wchar/wcstok.c \
 	wchar/wcswidth.c \
 	wchar/wcsxfrm.c \
-	wchar/wmemchr.c \
-	wchar/wmemcmp.c \
-	wchar/wmemcpy.c \
-	wchar/wmemmove.c \
-	wchar/wmemset.c \
-	inet/bindresvport.c \
-	inet/inet_addr.c \
-	inet/inet_aton.c \
-	inet/inet_ntoa.c \
-	inet/inet_ntop.c \
-	inet/inet_pton.c \
-	inet/ether_aton.c \
-	inet/ether_ntoa.c \
 	tzcode/asctime.c \
 	tzcode/difftime.c \
 	tzcode/localtime.c \
 	tzcode/strftime.c \
 	tzcode/strptime.c \
-	bionic/__set_errno.c \
-	bionic/bionic_clone.c \
-	bionic/cpuacct.c \
 	bionic/arc4random.c \
-	bionic/basename.c \
-	bionic/basename_r.c \
+	bionic/atoi.c \
+	bionic/atol.c \
+	bionic/atoll.c \
+	bionic/bindresvport.c \
+	bionic/bionic_clone.c \
 	bionic/clearenv.c \
-	bionic/dirname.c \
-	bionic/dirname_r.c \
-	bionic/drand48.c \
-	bionic/erand48.c \
+	bionic/cpuacct.c \
+	bionic/daemon.c \
 	bionic/err.c \
+	bionic/ether_aton.c \
+	bionic/ether_ntoa.c \
+	bionic/fcntl.c \
 	bionic/fdprintf.c \
+	bionic/flockfile.c \
 	bionic/fork.c \
+	bionic/fstatfs.c \
+	bionic/ftime.c \
+	bionic/ftok.c \
 	bionic/fts.c \
-	bionic/getcwd.cpp \
-	bionic/if_nametoindex.c \
+	bionic/getdtablesize.c \
+	bionic/gethostname.c \
+	bionic/getpgrp.c \
+	bionic/getpriority.c \
+	bionic/getpt.c \
 	bionic/if_indextoname.c \
+	bionic/if_nametoindex.c \
+	bionic/initgroups.c \
 	bionic/ioctl.c \
+	bionic/isatty.c \
+	bionic/issetugid.c \
 	bionic/ldexp.c \
-	bionic/libc_init_common.c \
 	bionic/logd_write.c \
+	bionic/lseek64.c \
 	bionic/md5.c \
-	bionic/memmove_words.c \
+	bionic/memchr.c \
+	bionic/memmem.c \
+	bionic/memrchr.c \
+	bionic/memswap.c \
+	bionic/mmap.c \
+	bionic/openat.c \
+	bionic/open.c \
+	bionic/pathconf.c \
+	bionic/perror.c \
+	bionic/pread.c \
+	bionic/pselect.c \
+	bionic/ptsname.c \
+	bionic/ptsname_r.c \
 	bionic/pututline.c \
-	bionic/realpath.c \
-	bionic/sched_getaffinity.c \
-	bionic/sched_getcpu.c \
+	bionic/pwrite.c \
+	bionic/reboot.c \
+	bionic/recv.c \
 	bionic/sched_cpualloc.c \
 	bionic/sched_cpucount.c \
+	bionic/sched_getaffinity.c \
+	bionic/sched_getcpu.c \
 	bionic/semaphore.c \
-	bionic/sha1.c \
-	bionic/strerror.cpp \
-	bionic/strerror_r.cpp \
-	bionic/strsignal.cpp \
-	bionic/stubs.cpp \
+	bionic/send.c \
+	bionic/setegid.c \
+	bionic/seteuid.c \
+	bionic/setpgrp.c \
+	bionic/setresuid.c \
+	bionic/setreuid.c \
+	bionic/setuid.c \
+	bionic/sigblock.c \
+	bionic/siginterrupt.c \
+	bionic/siglist.c \
+	bionic/signal.c \
+	bionic/signame.c \
+	bionic/sigsetmask.c \
+	bionic/sigsuspend.c \
+	bionic/sleep.c \
+	bionic/statfs.c \
+	bionic/strndup.c \
+	bionic/strnlen.c \
+	bionic/strntoimax.c \
+	bionic/strntoumax.c \
+	bionic/strtotimeval.c \
 	bionic/system_properties.c \
-	bionic/tdestroy.c \
-	bionic/time64.c \
+	bionic/tcgetpgrp.c \
+	bionic/tcsetpgrp.c \
 	bionic/thread_atexit.c \
-	bionic/utime.c \
+	bionic/time64.c \
+	bionic/umount.c \
+	bionic/unlockpt.c \
+	bionic/usleep.c \
 	bionic/utmp.c \
+	bionic/wait.c \
+	bionic/wcscoll.c \
 	netbsd/gethnamaddr.c \
-	netbsd/isc/ev_timers.c \
-	netbsd/isc/ev_streams.c \
 	netbsd/inet/nsap_addr.c \
 	netbsd/resolv/__dn_comp.c \
 	netbsd/resolv/__res_close.c \
@@ -329,69 +235,164 @@
 	netbsd/nameser/ns_print.c \
 	netbsd/nameser/ns_samedomain.c \
 
-libc_upstream_netbsd_src_files := \
-	upstream-netbsd/libc/compat-43/creat.c \
-	upstream-netbsd/libc/gen/ftw.c \
-	upstream-netbsd/libc/gen/nftw.c \
-	upstream-netbsd/libc/gen/nice.c \
-	upstream-netbsd/libc/gen/psignal.c \
-	upstream-netbsd/libc/regex/regcomp.c \
-	upstream-netbsd/libc/regex/regerror.c \
-	upstream-netbsd/libc/regex/regexec.c \
-	upstream-netbsd/libc/regex/regfree.c \
-	upstream-netbsd/libc/stdlib/tdelete.c \
-	upstream-netbsd/libc/stdlib/tfind.c \
-	upstream-netbsd/libc/stdlib/tsearch.c \
-	upstream-netbsd/libc/string/strxfrm.c \
+libc_bionic_src_files := \
+    bionic/assert.cpp \
+    bionic/brk.cpp \
+    bionic/debug_format.cpp \
+    bionic/dirent.cpp \
+    bionic/__errno.c \
+    bionic/eventfd.cpp \
+    bionic/__fgets_chk.cpp \
+    bionic/getauxval.cpp \
+    bionic/getcwd.cpp \
+    bionic/libc_init_common.cpp \
+    bionic/libgen.cpp \
+    bionic/__memcpy_chk.cpp \
+    bionic/__memmove_chk.cpp \
+    bionic/__memset_chk.cpp \
+    bionic/pthread_attr.cpp \
+    bionic/pthread_detach.cpp \
+    bionic/pthread_equal.cpp \
+    bionic/pthread_getcpuclockid.cpp \
+    bionic/pthread_getschedparam.cpp \
+    bionic/pthread_internals.cpp \
+    bionic/pthread_join.cpp \
+    bionic/pthread_kill.cpp \
+    bionic/pthread_self.cpp \
+    bionic/pthread_setname_np.cpp \
+    bionic/pthread_setschedparam.cpp \
+    bionic/pthread_sigmask.cpp \
+    bionic/raise.cpp \
+    bionic/sbrk.cpp \
+    bionic/scandir.cpp \
+    bionic/__set_errno.cpp \
+    bionic/setlocale.cpp \
+    bionic/signalfd.cpp \
+    bionic/sigwait.cpp \
+    bionic/__strcat_chk.cpp \
+    bionic/__strcpy_chk.cpp \
+    bionic/strerror.cpp \
+    bionic/strerror_r.cpp \
+    bionic/__strlcat_chk.cpp \
+    bionic/__strlcpy_chk.cpp \
+    bionic/__strlen_chk.cpp \
+    bionic/__strncat_chk.cpp \
+    bionic/__strncpy_chk.cpp \
+    bionic/strsignal.cpp \
+    bionic/stubs.cpp \
+    bionic/sysconf.cpp \
+    bionic/tdestroy.cpp \
+    bionic/tmpfile.cpp \
+    bionic/__umask_chk.cpp \
+    bionic/__vsnprintf_chk.cpp \
+    bionic/__vsprintf_chk.cpp \
+    bionic/wchar.cpp \
 
-# The following files are common, but must be compiled
-# with different C flags when building a static C library.
-#
-# The reason for this is the implementation of __get_tls()
-# that will differ between the shared and static versions
-# of the library.
-#
-# See comments in private/bionic_tls.h for more details.
-#
-# NOTE: bionic/pthread.c is added later to this list
-#       because it needs special handling on ARM, see
-#       below.
-#
-libc_static_common_src_files := \
-        unistd/sysconf.c \
-        bionic/__errno.c \
+libc_upstream_freebsd_src_files := \
+    upstream-freebsd/lib/libc/stdlib/realpath.c \
+    upstream-freebsd/lib/libc/string/wcpcpy.c \
+    upstream-freebsd/lib/libc/string/wcpncpy.c \
+    upstream-freebsd/lib/libc/string/wcscasecmp.c \
+    upstream-freebsd/lib/libc/string/wcscat.c \
+    upstream-freebsd/lib/libc/string/wcschr.c \
+    upstream-freebsd/lib/libc/string/wcscmp.c \
+    upstream-freebsd/lib/libc/string/wcscpy.c \
+    upstream-freebsd/lib/libc/string/wcscspn.c \
+    upstream-freebsd/lib/libc/string/wcsdup.c \
+    upstream-freebsd/lib/libc/string/wcslcat.c \
+    upstream-freebsd/lib/libc/string/wcslcpy.c \
+    upstream-freebsd/lib/libc/string/wcslen.c \
+    upstream-freebsd/lib/libc/string/wcsncasecmp.c \
+    upstream-freebsd/lib/libc/string/wcsncat.c \
+    upstream-freebsd/lib/libc/string/wcsncmp.c \
+    upstream-freebsd/lib/libc/string/wcsncpy.c \
+    upstream-freebsd/lib/libc/string/wcsnlen.c \
+    upstream-freebsd/lib/libc/string/wcspbrk.c \
+    upstream-freebsd/lib/libc/string/wcsrchr.c \
+    upstream-freebsd/lib/libc/string/wcsspn.c \
+    upstream-freebsd/lib/libc/string/wcsstr.c \
+    upstream-freebsd/lib/libc/string/wcstok.c \
+    upstream-freebsd/lib/libc/string/wmemchr.c \
+    upstream-freebsd/lib/libc/string/wmemcmp.c \
+    upstream-freebsd/lib/libc/string/wmemcpy.c \
+    upstream-freebsd/lib/libc/string/wmemmove.c \
+    upstream-freebsd/lib/libc/string/wmemset.c \
+
+libc_upstream_netbsd_src_files := \
+    upstream-netbsd/common/lib/libc/hash/sha1/sha1.c \
+    upstream-netbsd/common/lib/libc/inet/inet_addr.c \
+    upstream-netbsd/libc/compat-43/creat.c \
+    upstream-netbsd/libc/gen/ftw.c \
+    upstream-netbsd/libc/gen/nftw.c \
+    upstream-netbsd/libc/gen/nice.c \
+    upstream-netbsd/libc/gen/popen.c \
+    upstream-netbsd/libc/gen/psignal.c \
+    upstream-netbsd/libc/gen/setjmperr.c \
+    upstream-netbsd/libc/gen/utime.c \
+    upstream-netbsd/libc/inet/inet_ntoa.c \
+    upstream-netbsd/libc/inet/inet_ntop.c \
+    upstream-netbsd/libc/inet/inet_pton.c \
+    upstream-netbsd/libc/isc/ev_streams.c \
+    upstream-netbsd/libc/isc/ev_timers.c \
+    upstream-netbsd/libc/regex/regcomp.c \
+    upstream-netbsd/libc/regex/regerror.c \
+    upstream-netbsd/libc/regex/regexec.c \
+    upstream-netbsd/libc/regex/regfree.c \
+    upstream-netbsd/libc/stdio/getdelim.c \
+    upstream-netbsd/libc/stdio/getline.c \
+    upstream-netbsd/libc/stdlib/bsearch.c \
+    upstream-netbsd/libc/stdlib/div.c \
+    upstream-netbsd/libc/stdlib/drand48.c \
+    upstream-netbsd/libc/stdlib/erand48.c \
+    upstream-netbsd/libc/stdlib/jrand48.c \
+    upstream-netbsd/libc/stdlib/ldiv.c \
+    upstream-netbsd/libc/stdlib/lldiv.c \
+    upstream-netbsd/libc/stdlib/lrand48.c \
+    upstream-netbsd/libc/stdlib/mrand48.c \
+    upstream-netbsd/libc/stdlib/nrand48.c \
+    upstream-netbsd/libc/stdlib/_rand48.c \
+    upstream-netbsd/libc/stdlib/seed48.c \
+    upstream-netbsd/libc/stdlib/srand48.c \
+    upstream-netbsd/libc/stdlib/tdelete.c \
+    upstream-netbsd/libc/stdlib/tfind.c \
+    upstream-netbsd/libc/stdlib/tsearch.c \
+    upstream-netbsd/libc/string/memccpy.c \
+    upstream-netbsd/libc/string/strcasestr.c \
+    upstream-netbsd/libc/string/strcoll.c \
+    upstream-netbsd/libc/string/strxfrm.c \
+    upstream-netbsd/libc/unistd/killpg.c \
 
 # Architecture specific source files go here
 # =========================================================
 ifeq ($(TARGET_ARCH),arm)
 libc_common_src_files += \
-	arch-arm/bionic/__get_sp.S \
-	arch-arm/bionic/_exit_with_stack_teardown.S \
-	arch-arm/bionic/_setjmp.S \
 	arch-arm/bionic/abort_arm.S \
 	arch-arm/bionic/atomics_arm.c \
 	arch-arm/bionic/clone.S \
 	arch-arm/bionic/eabi.c \
+	arch-arm/bionic/_exit_with_stack_teardown.S \
 	arch-arm/bionic/ffs.S \
 	arch-arm/bionic/futex_arm.S \
+	arch-arm/bionic/__get_sp.S \
 	arch-arm/bionic/kill.S \
 	arch-arm/bionic/libgcc_compat.c \
-	arch-arm/bionic/tkill.S \
-	arch-arm/bionic/tgkill.S \
-	arch-arm/bionic/memcmp.S \
 	arch-arm/bionic/memcmp16.S \
+	arch-arm/bionic/memcmp.S \
 	arch-arm/bionic/memcpy.S \
 	arch-arm/bionic/memset.S \
+	arch-arm/bionic/_setjmp.S \
 	arch-arm/bionic/setjmp.S \
 	arch-arm/bionic/sigsetjmp.S \
-	arch-arm/bionic/strlen.c.arm \
-	arch-arm/bionic/strcpy.S \
 	arch-arm/bionic/strcmp.S \
+	arch-arm/bionic/strcpy.S \
+	arch-arm/bionic/strlen.c.arm \
 	arch-arm/bionic/syscall.S \
-	string/memmove.c.arm \
+	arch-arm/bionic/tgkill.S \
+	arch-arm/bionic/tkill.S \
+	bionic/memmove.c.arm \
+	bionic/socketcalls.c \
 	string/bcopy.c \
 	string/strncmp.c \
-	unistd/socketcalls.c
 
 # These files need to be arm so that gdbserver
 # can set breakpoints in them without messing
@@ -403,7 +404,9 @@
 	bionic/ptrace.c.arm
 
 libc_static_common_src_files += \
-        bionic/pthread.c.arm \
+    bionic/pthread.c.arm \
+    bionic/pthread_create.cpp.arm \
+    bionic/pthread_key.cpp.arm \
 
 # these are used by the static and dynamic versions of the libc
 # respectively
@@ -416,34 +419,37 @@
 
 ifeq ($(TARGET_ARCH),x86)
 libc_common_src_files += \
-	arch-x86/bionic/__get_sp.S \
-	arch-x86/bionic/__get_tls.c \
-	arch-x86/bionic/__set_tls.c \
-	arch-x86/bionic/clone.S \
-	arch-x86/bionic/_exit_with_stack_teardown.S \
-	arch-x86/bionic/futex_x86.S \
-	arch-x86/bionic/setjmp.S \
-	arch-x86/bionic/_setjmp.S \
-	arch-x86/bionic/sigsetjmp.S \
-	arch-x86/bionic/vfork.S \
-	arch-x86/bionic/syscall.S \
-	arch-x86/string/bcopy_wrapper.S \
-	arch-x86/string/memcpy_wrapper.S \
-	arch-x86/string/memmove_wrapper.S \
-	arch-x86/string/bzero_wrapper.S \
-	arch-x86/string/memcmp_wrapper.S \
-	arch-x86/string/memset_wrapper.S \
-	arch-x86/string/strcmp_wrapper.S \
-	arch-x86/string/strncmp_wrapper.S \
-	arch-x86/string/strlen_wrapper.S \
-	string/strcpy.c \
-	bionic/pthread-atfork.c \
-	bionic/pthread-rwlocks.c \
-	bionic/pthread-timers.c \
-	bionic/ptrace.c
+    arch-x86/bionic/clone.S \
+    arch-x86/bionic/_exit_with_stack_teardown.S \
+    arch-x86/bionic/futex_x86.S \
+    arch-x86/bionic/__get_sp.S \
+    arch-x86/bionic/__get_tls.c \
+    arch-x86/bionic/_setjmp.S \
+    arch-x86/bionic/setjmp.S \
+    arch-x86/bionic/__set_tls.c \
+    arch-x86/bionic/sigsetjmp.S \
+    arch-x86/bionic/syscall.S \
+    arch-x86/bionic/vfork.S \
+    arch-x86/string/bcopy_wrapper.S \
+    arch-x86/string/bzero_wrapper.S \
+    arch-x86/string/ffs.S \
+    arch-x86/string/memcmp_wrapper.S \
+    arch-x86/string/memcpy_wrapper.S \
+    arch-x86/string/memmove_wrapper.S \
+    arch-x86/string/memset_wrapper.S \
+    arch-x86/string/strcmp_wrapper.S \
+    arch-x86/string/strlen_wrapper.S \
+    arch-x86/string/strncmp_wrapper.S \
+    bionic/pthread-atfork.c \
+    bionic/pthread-rwlocks.c \
+    bionic/pthread-timers.c \
+    bionic/ptrace.c \
+    string/strcpy.c \
 
 libc_static_common_src_files += \
-        bionic/pthread.c \
+    bionic/pthread.c \
+    bionic/pthread_create.cpp \
+    bionic/pthread_key.cpp \
 
 libc_arch_static_src_files := \
 	bionic/dl_iterate_phdr_static.c
@@ -476,8 +482,8 @@
 	arch-mips/string/mips_strlen.c
 
 libc_common_src_files += \
+	bionic/memcmp.c \
 	string/bcopy.c \
-	string/memcmp.c \
 	string/strcmp.c \
 	string/strcpy.c \
 	string/strncmp.c
@@ -489,7 +495,9 @@
 	bionic/ptrace.c
 
 libc_static_common_src_files += \
-	bionic/pthread.c
+    bionic/pthread.c \
+    bionic/pthread_create.cpp \
+    bionic/pthread_key.cpp \
 
 libc_arch_static_src_files := \
 	bionic/dl_iterate_phdr_static.c
@@ -508,7 +516,6 @@
     -I$(LOCAL_PATH)/private \
     -DPOSIX_MISTAKE \
     -DLOG_ON_HEAP_ERROR \
-    -std=gnu99 \
     -Wall -Wextra
 
 # these macro definitions are required to implement the
@@ -535,18 +542,8 @@
   libc_common_cflags += -fstrict-aliasing
   libc_crt_target_cflags := -mthumb-interwork
   #
-  # Define HAVE_ARM_TLS_REGISTER macro to indicate to the C library
-  # that it should access the hardware TLS register directly in
-  # private/bionic_tls.h
-  #
-  # The value must match your kernel configuration
-  #
-  ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true)
-    libc_common_cflags += -DHAVE_ARM_TLS_REGISTER
-  endif
-  #
-  # Define HAVE_32_BYTE_CACHE_LINES to indicate to C
-  # library it should use to 32-byte version of memcpy, and not
+  # Define HAVE_32_BYTE_CACHE_LINES to indicate to the C library
+  # that it should use the 32-byte version of memcpy, not
   # the 64-byte version.
   #
   ifeq ($(ARCH_ARM_HAVE_32_BYTE_CACHE_LINES),true)
@@ -625,7 +622,7 @@
     libc_crt_target_so_cflags := -fPIC
 endif
 ifeq ($(TARGET_ARCH),x86)
-    libc_crtbegin_extension := S
+    libc_crtbegin_extension := c
     libc_crt_target_so_cflags := -fPIC
 endif
 ifeq ($(libc_crtbegin_extension),)
@@ -739,8 +736,8 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES := bionic/ssp.c
-LOCAL_CFLAGS := $(libc_common_cflags) -fno-stack-protector
+LOCAL_SRC_FILES := bionic/__stack_chk_fail.cpp
+LOCAL_CFLAGS := $(libc_common_cflags) -fno-stack-protector -Werror
 LOCAL_C_INCLUDES := $(libc_common_c_includes)
 LOCAL_MODULE := libbionic_ssp
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
@@ -750,6 +747,29 @@
 
 
 # ========================================================
+# libc_freebsd.a - upstream FreeBSD C library code
+# ========================================================
+#
+# These files are built with the freebsd-compat.h header file
+# automatically included.
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(libc_upstream_freebsd_src_files)
+LOCAL_CFLAGS := \
+    $(libc_common_cflags) \
+    -I$(LOCAL_PATH)/upstream-freebsd \
+    -I$(LOCAL_PATH)/upstream-freebsd/libc/include \
+    -include upstream-freebsd/freebsd-compat.h
+LOCAL_C_INCLUDES := $(libc_common_c_includes)
+LOCAL_MODULE := libc_freebsd
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+LOCAL_SYSTEM_SHARED_LIBRARIES :=
+
+include $(BUILD_STATIC_LIBRARY)
+
+
+# ========================================================
 # libc_netbsd.a - upstream NetBSD C library code
 # ========================================================
 #
@@ -762,6 +782,7 @@
 LOCAL_CFLAGS := \
     $(libc_common_cflags) \
     -I$(LOCAL_PATH)/upstream-netbsd \
+    -I$(LOCAL_PATH)/upstream-netbsd/libc/include \
     -include upstream-netbsd/netbsd-compat.h
 LOCAL_C_INCLUDES := $(libc_common_c_includes)
 LOCAL_MODULE := libc_netbsd
@@ -772,17 +793,35 @@
 
 
 # ========================================================
+# libc_bionic.a - home-grown C library code
+# ========================================================
+#
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(libc_bionic_src_files)
+LOCAL_CFLAGS := $(libc_common_cflags) -Werror
+LOCAL_C_INCLUDES := $(libc_common_c_includes)
+LOCAL_MODULE := libc_bionic
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+LOCAL_SYSTEM_SHARED_LIBRARIES :=
+
+include $(BUILD_STATIC_LIBRARY)
+
+
+# ========================================================
 # libc_common.a
 # ========================================================
 
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := $(libc_common_src_files)
-LOCAL_CFLAGS := $(libc_common_cflags)
+LOCAL_CFLAGS := $(libc_common_cflags) \
+    -std=gnu99 \
+    -I$(LOCAL_PATH)/upstream-netbsd/libc/include # for netbsd private headers
 LOCAL_C_INCLUDES := $(libc_common_c_includes)
 LOCAL_MODULE := libc_common
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_WHOLE_STATIC_LIBRARIES := libbionic_ssp libc_netbsd
+LOCAL_WHOLE_STATIC_LIBRARIES := libbionic_ssp libc_bionic libc_freebsd libc_netbsd
 LOCAL_SYSTEM_SHARED_LIBRARIES :=
 
 include $(BUILD_STATIC_LIBRARY)
@@ -793,21 +832,22 @@
 # ========================================================
 #
 # This is a version of the static C library that does not
-# include malloc. It's useful in situations when calling
-# the user wants to provide their own malloc implementation,
-# or wants to explicitly disallow the use of the use of malloc,
-# like the dynamic loader.
+# include malloc. It's useful in situations when the user wants
+# to provide their own malloc implementation, or wants to
+# explicitly disallow the use of the use of malloc,
+# such as in the dynamic loader.
 
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
 	$(libc_arch_static_src_files) \
 	$(libc_static_common_src_files) \
-	bionic/libc_init_static.c
+	bionic/libc_init_static.cpp
 
 LOCAL_C_INCLUDES := $(libc_common_c_includes)
 LOCAL_CFLAGS := $(libc_common_cflags) \
-                -DLIBC_STATIC
+                -DLIBC_STATIC \
+                -std=gnu99
 
 LOCAL_MODULE := libc_nomalloc
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
@@ -827,10 +867,11 @@
 	$(libc_static_common_src_files) \
 	bionic/dlmalloc.c \
 	bionic/malloc_debug_common.cpp \
-	bionic/libc_init_static.c
+	bionic/libc_init_static.cpp
 
 LOCAL_CFLAGS := $(libc_common_cflags) \
-                -DLIBC_STATIC
+                -DLIBC_STATIC \
+                -std=gnu99
 LOCAL_C_INCLUDES := $(libc_common_c_includes)
 LOCAL_MODULE := libc
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
@@ -851,7 +892,7 @@
 # Since this code is experimental it is disabled by default.
 # see libc/bionic/pthread_debug.c for details
 
-LOCAL_CFLAGS := $(libc_common_cflags) -DPTHREAD_DEBUG -DPTHREAD_DEBUG_ENABLED=0
+LOCAL_CFLAGS := $(libc_common_cflags) -std=gnu99 -DPTHREAD_DEBUG -DPTHREAD_DEBUG_ENABLED=0
 LOCAL_C_INCLUDES := $(libc_common_c_includes)
 
 LOCAL_SRC_FILES := \
@@ -859,8 +900,8 @@
 	$(libc_static_common_src_files) \
 	bionic/dlmalloc.c \
 	bionic/malloc_debug_common.cpp \
-	bionic/pthread_debug.c \
-	bionic/libc_init_dynamic.c
+	bionic/pthread_debug.cpp \
+	bionic/libc_init_dynamic.cpp
 
 ifeq ($(TARGET_ARCH),arm)
 	LOCAL_NO_CRT := true
@@ -875,6 +916,7 @@
 
 LOCAL_MODULE:= libc
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+LOCAL_REQUIRED_MODULES := tzdata
 
 # WARNING: The only library libc.so should depend on is libdl.so!  If you add other libraries,
 # make sure to add -Wl,--exclude-libs=libgcc.a to the LOCAL_LDFLAGS for those libraries.  This
@@ -911,10 +953,10 @@
 LOCAL_C_INCLUDES := $(libc_common_c_includes)
 
 LOCAL_SRC_FILES := \
+	bionic/debug_mapinfo.cpp \
+	bionic/debug_stacktrace.cpp \
 	bionic/malloc_debug_leak.cpp \
 	bionic/malloc_debug_check.cpp \
-	bionic/malloc_debug_check_mapinfo.cpp \
-	bionic/malloc_debug_stacktrace.cpp
 
 LOCAL_MODULE:= libc_malloc_debug_leak
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
diff --git a/libc/NOTICE b/libc/NOTICE
index 299f672..730fa46 100644
--- a/libc/NOTICE
+++ b/libc/NOTICE
@@ -37,6 +37,40 @@
 
 -------------------------------------------------------------------
 
+Copyright (C) 2004, 2005, 2008  Internet Systems Consortium, Inc. ("ISC")
+Copyright (C) 1995-1999, 2001, 2003  Internet Software Consortium.
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+
+-------------------------------------------------------------------
+
+Copyright (C) 2004, 2005, 2008  Internet Systems Consortium, Inc. ("ISC")
+Copyright (C) 1997-2001  Internet Software Consortium.
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+
+-------------------------------------------------------------------
+
 Copyright (C) 2006 The Android Open Source Project
 All rights reserved.
 
@@ -65,22 +99,6 @@
 
 -------------------------------------------------------------------
 
-Copyright (C) 2007 The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-     http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
--------------------------------------------------------------------
-
 Copyright (C) 2008 The Android Open Source Project
 All rights reserved.
 
@@ -328,6 +346,50 @@
 
 -------------------------------------------------------------------
 
+Copyright (C) 2013 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-------------------------------------------------------------------
+
+Copyright (C) 2013 The Android Open Source Project
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in
+   the documentation and/or other materials provided with the
+   distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
 Copyright (c) 1980, 1983, 1988, 1993
    The Regents of the University of California.  All rights reserved.
 
@@ -438,6 +500,40 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 1982, 1986, 1993
+   The Regents of the University of California.  All rights reserved.
+(c) UNIX System Laboratories, Inc.
+All or some portions of this file are derived from material licensed
+to the University of California by American Telephone and Telegraph
+Co. or Unix System Laboratories, Inc. and are reproduced herein with
+the permission of UNIX System Laboratories, Inc.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. Neither the name of the University nor the names of its contributors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
 Copyright (c) 1983, 1987, 1989
    The Regents of the University of California.  All rights reserved.
 
@@ -569,7 +665,11 @@
 2. Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in the
    documentation and/or other materials provided with the distribution.
-3. Neither the name of the University nor the names of its contributors
+3. All advertising materials mentioning features or use of this software
+   must display the following acknowledgement:
+    This product includes software developed by the University of
+    California, Berkeley and its contributors.
+4. Neither the name of the University nor the names of its contributors
    may be used to endorse or promote products derived from this software
    without specific prior written permission.
 
@@ -585,24 +685,6 @@
 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 SUCH DAMAGE.
 
-Portions Copyright (c) 1993 by Digital Equipment Corporation.
-
-Permission to use, copy, modify, and distribute this software for any
-purpose with or without fee is hereby granted, provided that the above
-copyright notice and this permission notice appear in all copies, and that
-the name of Digital Equipment Corporation not be used in advertising or
-publicity pertaining to distribution of the document or software without
-specific, written prior permission.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
-WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
-CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
-PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
-ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
 -------------------------------------------------------------------
 
 Copyright (c) 1983, 1993
@@ -1406,38 +1488,6 @@
 
 -------------------------------------------------------------------
 
-Copyright (c) 1990 Regents of the University of California.
-All rights reserved.
-
-This code is derived from software contributed to Berkeley by
-Chris Torek.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. Neither the name of the University nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
 Copyright (c) 1990 The Regents of the University of California.
 All rights reserved.
 
@@ -1594,35 +1644,6 @@
 Copyright (c) 1990, 1993
    The Regents of the University of California.  All rights reserved.
 
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-4. Neither the name of the University nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 1990, 1993
-   The Regents of the University of California.  All rights reserved.
-
 This code is derived from software contributed to Berkeley by
 Chris Torek.
 
@@ -2376,6 +2397,35 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 1994 The NetBSD Foundation, Inc.
+All rights reserved.
+
+This code is derived from software contributed to The NetBSD Foundation
+by Christos Zoulas.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
 Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan
 (Royal Institute of Technology, Stockholm, Sweden).
 All rights reserved.
@@ -2463,32 +2513,6 @@
 
 -------------------------------------------------------------------
 
-Copyright (c) 1995, 1996 Erik Theisen.  All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. The name of the author may not be used to endorse or promote products
-   derived from this software without specific prior written permission
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
--------------------------------------------------------------------
-
 Copyright (c) 1996 by Internet Software Consortium.
 
 Permission to use, copy, modify, and distribute this software for any
@@ -3597,23 +3621,6 @@
 -------------------------------------------------------------------
 
 Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
-Copyright (c) 1997-1999 by Internet Software Consortium.
-
-Permission to use, copy, modify, and distribute this software for any
-purpose with or without fee is hereby granted, provided that the above
-copyright notice and this permission notice appear in all copies.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
-WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
-ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
-OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
 Copyright (c) 1999 by Internet Software Consortium.
 
 Permission to use, copy, modify, and distribute this software for any
@@ -3673,6 +3680,23 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 2005 by Internet Systems Consortium, Inc. ("ISC")
+Copyright (c) 1995-1999 by Internet Software Consortium
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+-------------------------------------------------------------------
+
 Copyright (c) 2007-2008  Michael G Schwern
 
 This software originally derived from Paul Sheer's pivotal_gmtime_r.c.
@@ -3833,6 +3857,33 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 2009 The NetBSD Foundation, Inc.
+
+This code is derived from software contributed to The NetBSD Foundation
+by Roy Marples.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
 Copyright (c) 2010 MIPS Technologies, Inc.
 
 All rights reserved.
@@ -3979,6 +4030,34 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 2013 ARM Ltd
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. The name of the company may not be used to endorse or promote
+   products derived from this software without specific prior written
+   permission.
+
+THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
 Copyright (c)1999 Citrus Project,
 All rights reserved.
 
diff --git a/libc/README b/libc/README
deleted file mode 100644
index d92d85d..0000000
--- a/libc/README
+++ /dev/null
@@ -1,54 +0,0 @@
-Welcome to Bionic, Android's small and custom C library for the Android
-platform.
-
-Bionic is mainly a port of the BSD C library to our Linux kernel with the
-following additions/changes:
-
-- no support for locales
-- no support for wide chars (i.e. multi-byte characters)
-- its own smallish implementation of pthreads based on Linux futexes
-- support for x86, ARM and ARM thumb CPU instruction sets and kernel interfaces
-
-Bionic is released under the standard 3-clause BSD License
-
-Bionic doesn't want to implement all features of a traditional C library, we only
-add features to it as we need them, and we try to keep things as simple and small
-as possible. Our goal is not to support scaling to thousands of concurrent threads
-on multi-processors machines; we're running this on cell-phones, damnit !!
-
-Note that Bionic doesn't provide a libthread_db or a libm implementation.
-
-
-Adding new syscalls:
-====================
-
-Bionic provides the gensyscalls.py Python script to automatically generate syscall
-stubs from the list defined in the file SYSCALLS.TXT. You can thus add a new syscall
-by doing the following:
-
-- edit SYSCALLS.TXT
-- add a new line describing your syscall, it should look like:
-
-   return_type  syscall_name(parameters)    syscall_number
-
-- in the event where you want to differentiate the syscall function from its entry name,
-  use the alternate:
-
-   return_type  funcname:syscall_name(parameters)  syscall_number
-
-- additionally, if the syscall number is different between ARM and x86, use:
-
-   return_type  funcname[:syscall_name](parameters)   arm_number,x86_number
-
-- a syscall number can be -1 to indicate that the syscall is not implemented on
-  a given platform, for example:
-
-   void   __set_tls(void*)   arm_number,-1
-
-
-the comments in SYSCALLS.TXT contain more information about the line format
-
-You can also use the 'checksyscalls.py' script to check that all the syscall
-numbers you entered are correct. It does so by looking at the values defined in
-your Linux kernel headers. The script indicates where the values are incorrect
-and what is expected instead.
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index d79e6f3..2a25618 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -25,7 +25,10 @@
 #      - additionally, if the syscall number is different amoung ARM, and x86, MIPS use:
 #        return_type funcname[:syscall_name](parameters) arm_number,x86_number,mips_number
 #
-# the file is processed by a python script named gensyscalls.py
+# This file is processed by a python script named gensyscalls.py.
+#
+# The checksyscalls.py script can check that the syscall numbers here are
+# correct by comparing them to the numbers in the Linux kernel headers.
 #
 
 # process management
@@ -62,7 +65,7 @@
 int     getgroups:getgroups(int, gid_t *)      -1,-1,80
 pid_t   getpgid(pid_t)             132
 pid_t   getppid()                  64
-pid_t   getsid(pid_t)              147
+pid_t   getsid(pid_t)              147,147,151
 pid_t   setsid()                   66
 int     setgid:setgid32(gid_t)     214,214,-1
 int     setgid:setgid(gid_t)       -1,-1,46
@@ -225,6 +228,7 @@
 int     __rt_sigprocmask:rt_sigprocmask (int  how, const sigset_t *set, sigset_t *oset, size_t sigsetsize)  175,175,195
 int     __rt_sigtimedwait:rt_sigtimedwait(const sigset_t *set, struct siginfo_t  *info, struct timespec_t  *timeout, size_t  sigset_size)  177,177,197
 int     sigpending(sigset_t *)  73
+int     signalfd4(int fd, const sigset_t *mask, size_t sizemask, int flags)  355,327,324
 
 # sockets
 int           socket(int, int, int)              281,-1,183
@@ -288,7 +292,7 @@
 int     klogctl:syslog(int, char *, int)   103
 int     sysinfo(struct sysinfo *)  116
 int     personality(unsigned long)  136
-long    perf_event_open(struct perf_event_attr *attr_uptr, pid_t pid, int cpu, int group_fd, unsigned long flags) 364
+long    perf_event_open(struct perf_event_attr *attr_uptr, pid_t pid, int cpu, int group_fd, unsigned long flags) 364,336,333
 
 # futex
 int	futex(void *, int, int, void *, void *, int) 240,240,238
diff --git a/libc/arch-arm/bionic/__get_sp.S b/libc/arch-arm/bionic/__get_sp.S
index 0a313a3..2a7e7b7 100644
--- a/libc/arch-arm/bionic/__get_sp.S
+++ b/libc/arch-arm/bionic/__get_sp.S
@@ -25,10 +25,10 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-.global __get_sp
-.type __get_sp, %function
 
-__get_sp:
-	mov r0, sp
-	bx lr
+#include <machine/asm.h>
 
+ENTRY(__get_sp)
+  mov r0, sp
+  bx lr
+END(__get_sp)
diff --git a/libc/arch-arm/bionic/_exit_with_stack_teardown.S b/libc/arch-arm/bionic/_exit_with_stack_teardown.S
index c2d7758..b00ea28 100644
--- a/libc/arch-arm/bionic/_exit_with_stack_teardown.S
+++ b/libc/arch-arm/bionic/_exit_with_stack_teardown.S
@@ -25,27 +25,20 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#include <asm/unistd.h>
+
 #include <machine/asm.h>
+#include <sys/linux-syscalls.h>
 
-@ void _exit_with_stack_teardown(void * stackBase, int stackSize, int retCode)
+// void _exit_with_stack_teardown(void* stackBase, int stackSize, int retCode)
 ENTRY(_exit_with_stack_teardown)
-
-#if __ARM_EABI__
     mov     lr, r2
     ldr     r7, =__NR_munmap
-    swi     #0              @ the stack is destroyed by this call
+    swi     #0              // the stack is destroyed by this call
     mov     r0, lr
     ldr     r7, =__NR_exit
     swi     #0
-#else
-    mov     lr, r2
-    swi     # __NR_munmap   @ the stack is destroyed by this call
-    mov     r0, lr
-    swi     # __NR_exit
-#endif
 
-    @ exit() should never return, cause a crash if it does
-    mov		r0, #0
-    ldr		r0, [r0]
+    // exit() should never return, cause a crash if it does
+    mov     r0, #0
+    ldr     r0, [r0]
 END(_exit_with_stack_teardown)
diff --git a/libc/arch-arm/bionic/atexit_legacy.c b/libc/arch-arm/bionic/atexit_legacy.c
index 4abe839..6e299ac 100644
--- a/libc/arch-arm/bionic/atexit_legacy.c
+++ b/libc/arch-arm/bionic/atexit_legacy.c
@@ -50,10 +50,9 @@
      * calling library may have been dlclose()'d, causing the program to
      * crash.
      */
-    static char const warning[] =
-        "WARNING: generic atexit() called from legacy shared library\n";
+    static char const warning[] = "WARNING: generic atexit() called from legacy shared library\n";
 
-    __libc_android_log_print(ANDROID_LOG_WARN, "libc", warning);
+    __libc_android_log_write(ANDROID_LOG_WARN, "libc", warning);
     fprintf(stderr, warning);
 
     return (__cxa_atexit((void (*)(void *))func, NULL, NULL));
diff --git a/libc/arch-arm/bionic/clone.S b/libc/arch-arm/bionic/clone.S
index 7ff3d0d..13bc7d7 100644
--- a/libc/arch-arm/bionic/clone.S
+++ b/libc/arch-arm/bionic/clone.S
@@ -25,47 +25,39 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#include <sys/linux-syscalls.h>
+
 #include <machine/asm.h>
+#include <sys/linux-syscalls.h>
 
+// int  __pthread_clone(void* (*fn)(void*), void* child_stack, int flags, void* arg);
 ENTRY(__pthread_clone)
-    @ insert the args onto the new stack
-    stmdb r1!, {r0, r3}
+    # Copy the args onto the new stack.
+    stmdb   r1!, {r0, r3}
 
-    @ do the system call
-    @ get flags
-
+    # The sys_clone system call only takes two arguments: 'flags' and 'child_stack'.
+    # 'child_stack' is already in r1, but we need to move 'flags' into position.
     mov     r0, r2
-
-    @ new sp is already in r1
-
-#if __ARM_EABI__
     stmfd   sp!, {r4, r7}
+
+    # System call.
     ldr     r7, =__NR_clone
     swi     #0
-#else
-    swi     #__NR_clone
-#endif
-
     movs    r0, r0
-#if __ARM_EABI__
-    ldmnefd sp!, {r4, r7}
-#endif
-    blt     __error
-    bxne    lr
+    beq     1f
 
+    # In parent, reload saved registers then either exit or set errno.
+    ldmfd   sp!, {r4, r7}
+    bxpl    lr
+    b       __set_syscall_errno
 
-    @ pick the function arg and call address off the stack and jump
-    @ to the C __thread_entry function which does some setup and then
-    @ calls the thread's start function
-
+1:  # The child.
+    # pick the function arg and call address off the stack and jump
+    # to the C __thread_entry function which does some setup and then
+    # calls the thread's start function
     pop     {r0, r1}
-    mov     r2, sp			@ __thread_entry needs the TLS pointer
+    # __thread_entry needs the TLS pointer
+    mov     r2, sp
     b       __thread_entry
-
-__error:
-    mov     r0, #-1
-    bx      lr
 END(__pthread_clone)
 
 
@@ -76,8 +68,8 @@
     #                          pid_t *pid, void *tls, pid_t *ctid,
     #                          int  (*fn)(void *), void* arg );
     #
-    # NOTE: This is not the same signature than the GLibc
-    #       __clone function here !! Placing 'fn' and 'arg'
+    # NOTE: This is not the same signature as the glibc
+    #       __clone function. Placing 'fn' and 'arg'
     #       at the end of the parameter list makes the
     #       implementation much simpler.
     #
@@ -96,20 +88,18 @@
     str     r5, [r1, #-4]
     str     r6, [r1, #-8]
 
-    # system call
+    # System call
     ldr     r7, =__NR_clone
     swi     #0
     movs    r0, r0
     beq     1f
 
-    # in parent, reload saved registers
-    # then either exit or error
-    #
+    # In the parent, reload saved registers then either exit or set errno.
     ldmfd   sp!, {r4, r5, r6, r7}
-    bxne    lr
+    bxpl    lr
     b       __set_syscall_errno
 
-1:  # in the child - pick arguments
+1:  # The child.
     ldr    r0, [sp, #-4]
     ldr    r1, [sp, #-8]
     b      __bionic_clone_entry
diff --git a/libc/arch-arm/bionic/crtbegin.c b/libc/arch-arm/bionic/crtbegin.c
index 0e2d31e..1bcb335 100644
--- a/libc/arch-arm/bionic/crtbegin.c
+++ b/libc/arch-arm/bionic/crtbegin.c
@@ -26,21 +26,9 @@
  * SUCH DAMAGE.
  */
 
-typedef struct
-{
-    void (**preinit_array)(void);
-    void (**init_array)(void);
-    void (**fini_array)(void);
-} structors_array_t;
-
-extern int main(int argc, char **argv, char **env);
-
-extern void __libc_init(
-  unsigned int *elfdata,
-  void (*onexit)(void),
-  int (*slingshot)(int, char**, char**),
-  structors_array_t const * const structors
-);
+#include "../../bionic/libc_init_common.h"
+#include <stddef.h>
+#include <stdint.h>
 
 __attribute__ ((section (".preinit_array")))
 void (*__PREINIT_ARRAY__)(void) = (void (*)(void)) -1;
@@ -51,17 +39,14 @@
 __attribute__ ((section (".fini_array")))
 void (*__FINI_ARRAY__)(void) = (void (*)(void)) -1;
 
-__attribute__((visibility("hidden")))
-void _start() {
+__LIBC_HIDDEN__ void _start() {
   structors_array_t array;
-  void *elfdata;
-
   array.preinit_array = &__PREINIT_ARRAY__;
-  array.init_array =    &__INIT_ARRAY__;
-  array.fini_array =    &__FINI_ARRAY__;
+  array.init_array = &__INIT_ARRAY__;
+  array.fini_array = &__FINI_ARRAY__;
 
-  elfdata = __builtin_frame_address(0) + sizeof(void *);
-  __libc_init(elfdata, (void *) 0, &main, &array);
+  void* raw_args = (void*) ((uintptr_t) __builtin_frame_address(0) + sizeof(void*));
+  __libc_init(raw_args, NULL, &main, &array);
 }
 
 #include "__dso_handle.h"
diff --git a/libc/arch-arm/bionic/ffs.S b/libc/arch-arm/bionic/ffs.S
index c59091f..701af8c 100644
--- a/libc/arch-arm/bionic/ffs.S
+++ b/libc/arch-arm/bionic/ffs.S
@@ -31,55 +31,11 @@
 #include <machine/asm.h>
 #include <machine/cpu-features.h>
 
-/*
- * ffs - find first set bit, this algorithm isolates the first set
- * bit, then multiplies the number by 0x0450fbaf which leaves the top
- * 6 bits as an index into the table.  This algorithm should be a win
- * over the checking each bit in turn as per the C compiled version.
- *
- * Some newer ARM architectures have an instruction named
- * CLZ (count leading Zero's) that is used
- *
- * This is the ffs algorithm devised by d.seal and posted to comp.sys.arm on
- * 16 Feb 1994.
- */
-
 ENTRY(ffs)
 	/* Standard trick to isolate bottom bit in r0 or 0 if r0 = 0 on entry */
  	rsb     r1, r0, #0
  	ands    r0, r0, r1
-#ifndef __ARM_HAVE_CLZ
-	/*
-	 * now r0 has at most one set bit, call this X
-	 * if X = 0, all further instructions are skipped
-	 */
-	adrne   r2, .L_ffs_table
-	orrne   r0, r0, r0, lsl #4  /* r0 = X * 0x11 */ 
-	orrne   r0, r0, r0, lsl #6  /* r0 = X * 0x451 */
-	rsbne   r0, r0, r0, lsl #16 /* r0 = X * 0x0450fbaf */
-              
-	/* now lookup in table indexed on top 6 bits of r0 */
-	ldrneb  r0, [ r2, r0, lsr #26 ]
-
-	bx		lr
-END(ffs)
-
-.text;
-.type .L_ffs_table, _ASM_TYPE_OBJECT;
-.L_ffs_table:
-/*               0   1   2   3   4   5   6   7           */
-	.byte	 0,  1,  2, 13,  3,  7,  0, 14  /*  0- 7 */
-	.byte	 4,  0,  8,  0,  0,  0,  0, 15  /*  8-15 */
-	.byte	11,  5,  0,  0,  9,  0,  0, 26  /* 16-23 */
-	.byte	 0,  0,  0,  0,  0, 22, 28, 16  /* 24-31 */
-	.byte	32, 12,  6,  0,  0,  0,  0,  0	/* 32-39 */
-	.byte	10,  0,  0, 25,  0,  0, 21, 27  /* 40-47 */
-	.byte	31,  0,  0,  0,  0, 24,  0, 20  /* 48-55 */
-	.byte   30,  0, 23, 19, 29, 18, 17,  0  /* 56-63 */
-#else /* !defined(__ARM_HAVE_CLZ) */
 	clzne	r0, r0
 	rsbne	r0, r0, #32
 	bx		lr
 END(ffs)
-#endif /* !defined(__ARM_HAVE_CLZ) */
-
diff --git a/libc/arch-arm/bionic/futex_arm.S b/libc/arch-arm/bionic/futex_arm.S
index 7041663..bbd0629 100644
--- a/libc/arch-arm/bionic/futex_arm.S
+++ b/libc/arch-arm/bionic/futex_arm.S
@@ -25,32 +25,14 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #include <sys/linux-syscalls.h>
 #include <machine/asm.h>
-#include <machine/cpu-features.h>
 
 #define FUTEX_WAIT 0
 #define FUTEX_WAKE 1
 
-/* __futex_wait(*ftx, val, *timespec) */
-/* __futex_wake(*ftx, counter) */
-/* __futex_syscall3(*ftx, op, val) */
-/* __futex_syscall4(*ftx, op, val, *timespec) */
-
-.global __futex_wait
-.type __futex_wait, %function
-
-.global __futex_wake
-.type __futex_wake, %function
-
-.global __futex_syscall3
-.type __futex_syscall3, %function
-
-.global __futex_syscall4
-.type __futex_syscall4, %function
-
-#if __ARM_EABI__
-
+// __futex_syscall3(*ftx, op, val)
 ENTRY(__futex_syscall3)
     stmdb   sp!, {r4, r7}
     .save   {r4, r7}
@@ -60,53 +42,32 @@
     bx      lr
 END(__futex_syscall3)
 
-ENTRY(__futex_wait)
-    stmdb   sp!, {r4, r7}
-    .save   {r4, r7}
-    mov     r3, r2
-    mov     r2, r1
-    mov     r1, #FUTEX_WAIT
-    ldr     r7, =__NR_futex
-    swi     #0
-    ldmia   sp!, {r4, r7}
-    bx      lr
-END(__futex_wait)
-
-ENTRY(__futex_wake)
-    .save   {r4, r7}
-    stmdb   sp!, {r4, r7}
-    mov     r2, r1
-    mov     r1, #FUTEX_WAKE
-    ldr     r7, =__NR_futex
-    swi     #0
-    ldmia   sp!, {r4, r7}
-    bx      lr
-END(__futex_wake)
-
-#else
-
-ENTRY(__futex_syscall3)
-    swi     #__NR_futex
-    bx      lr
-END(__futex_syscall3)
-
-ENTRY(__futex_wait)
-    mov     r3, r2
-    mov     r2, r1
-    mov     r1, #FUTEX_WAIT
-    swi     #__NR_futex
-    bx      lr
-END(__futex_wait)
-
-ENTRY(__futex_wake)
-    mov     r2, r1
-    mov     r1, #FUTEX_WAKE
-    swi     #__NR_futex
-    bx      lr
-END(__futex_wake)
-
-#endif
-
+// __futex_syscall4(*ftx, op, val, *timespec)
 ENTRY(__futex_syscall4)
     b __futex_syscall3
 END(__futex_syscall4)
+
+// __futex_wait(*ftx, val, *timespec)
+ENTRY(__futex_wait)
+    stmdb   sp!, {r4, r7}
+    .save   {r4, r7}
+    mov     r3, r2
+    mov     r2, r1
+    mov     r1, #FUTEX_WAIT
+    ldr     r7, =__NR_futex
+    swi     #0
+    ldmia   sp!, {r4, r7}
+    bx      lr
+END(__futex_wait)
+
+// __futex_wake(*ftx, counter)
+ENTRY(__futex_wake)
+    .save   {r4, r7}
+    stmdb   sp!, {r4, r7}
+    mov     r2, r1
+    mov     r1, #FUTEX_WAKE
+    ldr     r7, =__NR_futex
+    swi     #0
+    ldmia   sp!, {r4, r7}
+    bx      lr
+END(__futex_wake)
diff --git a/libc/arch-arm/bionic/libgcc_compat.c b/libc/arch-arm/bionic/libgcc_compat.c
index a5cb219..e4473f3 100644
--- a/libc/arch-arm/bionic/libgcc_compat.c
+++ b/libc/arch-arm/bionic/libgcc_compat.c
@@ -110,6 +110,7 @@
     XX(__aeabi_fsub)         \
     XX(__aeabi_i2d)          \
     XX(__aeabi_i2f)          \
+    XX(__aeabi_idiv)         \
     XX(__aeabi_l2d)          \
     XX(__aeabi_l2f)          \
     XX(__aeabi_lmul)         \
diff --git a/libc/arch-arm/bionic/memcmp.S b/libc/arch-arm/bionic/memcmp.S
index c872a51..7fb4283 100644
--- a/libc/arch-arm/bionic/memcmp.S
+++ b/libc/arch-arm/bionic/memcmp.S
@@ -29,44 +29,93 @@
 #include <machine/cpu-features.h>
 #include <machine/asm.h>
 
+
+#ifdef HAVE_32_BYTE_CACHE_LINE
+#define CACHE_LINE_SIZE     32
+#else
+#define CACHE_LINE_SIZE     64
+#endif
+
 /*
- * Optimized memcmp() for ARM9.
- * This would not be optimal on XScale or ARM11, where more prefetching
- * and use of PLD will be needed.
- * The 2 major optimzations here are
- * (1) The main loop compares 16 bytes at a time
- * (2) The loads are scheduled in a way they won't stall
+ * Optimized memcmp() for Cortex-A9.
  */
 
 ENTRY(memcmp)
-        PLD         (r0, #0)
-        PLD         (r1, #0)
+        pld         [r0, #(CACHE_LINE_SIZE * 0)]
+        pld         [r0, #(CACHE_LINE_SIZE * 1)]
 
         /* take of the case where length is 0 or the buffers are the same */
         cmp         r0, r1
-        cmpne       r2, #0
         moveq       r0, #0
         bxeq        lr
 
+        pld         [r1, #(CACHE_LINE_SIZE * 0)]
+        pld         [r1, #(CACHE_LINE_SIZE * 1)]
+
+        /* make sure we have at least 8+4 bytes, this simplify things below
+         * and avoid some overhead for small blocks
+         */
+        cmp        r2, #(8+4)
+        bmi        10f
+/*
+ * Neon optimization
+ * Comparing 32 bytes at a time
+ */
+#if defined(__ARM_NEON__) && defined(NEON_UNALIGNED_ACCESS)
+        subs        r2, r2, #32
+        blo         3f
+
+        /* preload all the cache lines we need. */
+        pld         [r0, #(CACHE_LINE_SIZE * 2)]
+        pld         [r1, #(CACHE_LINE_SIZE * 2)]
+
+1:      /* The main loop compares 32 bytes at a time */
+        vld1.8      {d0 - d3}, [r0]!
+        pld         [r0, #(CACHE_LINE_SIZE * 2)]
+        vld1.8      {d4 - d7}, [r1]!
+        pld         [r1, #(CACHE_LINE_SIZE * 2)]
+
+        /* Start subtracting the values and merge results */
+        vsub.i8     q0, q2
+        vsub.i8     q1, q3
+        vorr        q2, q0, q1
+        vorr        d4, d5
+        vmov        r3, ip, d4
+        /* Check if there are any differences among the 32 bytes */
+        orrs        r3, ip
+        bne         2f
+        subs        r2, r2, #32
+        bhs         1b
+        b           3f
+2:
+        /* Check if the difference was in the first or last 16 bytes */
+        sub         r0, #32
+        vorr        d0, d1
+        sub         r1, #32
+        vmov        r3, ip, d0
+        orrs        r3, ip
+        /* if the first 16 bytes are equal, we only have to rewind 16 bytes */
+        ittt        eq
+        subeq       r2, #16
+        addeq       r0, #16
+        addeq       r1, #16
+
+3:      /* fix-up the remaining count */
+        add         r2, r2, #32
+
+        cmp        r2, #(8+4)
+        bmi        10f
+#endif
+
         .save {r4, lr}
         /* save registers */
         stmfd       sp!, {r4, lr}
-        
-        PLD         (r0, #32)
-        PLD         (r1, #32)
 
         /* since r0 hold the result, move the first source
          * pointer somewhere else
          */
-         
          mov        r4, r0
-         
-         /* make sure we have at least 8+4 bytes, this simplify things below
-          * and avoid some overhead for small blocks
-          */
-         cmp        r2, #(8+4)
-         bmi        8f
-        
+
         /* align first pointer to word boundary
          * offset = -src & 3
          */
@@ -102,9 +151,9 @@
         ldr         ip, [r1]
         subs        r2, r2, #(32 + 4)
         bmi         1f
-        
-0:      PLD         (r4, #64)
-        PLD         (r1, #64)
+
+0:      pld         [r4, #(CACHE_LINE_SIZE * 2)]
+        pld         [r1, #(CACHE_LINE_SIZE * 2)]
         ldr         r0, [r4], #4
         ldr         lr, [r1, #4]!
         eors        r0, r0, ip
@@ -129,14 +178,14 @@
         ldreq       r0, [r4], #4
         ldreq       ip, [r1, #4]!
         eoreqs      r0, r0, lr
-        bne         2f        
+        bne         2f
         subs        r2, r2, #32
         bhs         0b
 
         /* do we have at least 4 bytes left? */
 1:      adds        r2, r2, #(32 - 4 + 4)
         bmi         4f
-        
+
         /* finish off 4 bytes at a time */
 3:      ldr         r0, [r4], #4
         ldr         ip, [r1], #4
@@ -170,19 +219,28 @@
 9:      /* restore registers and return */
         ldmfd       sp!, {r4, lr}
         bx          lr
-END(memcmp)
 
-
-
-
+10:     /* process less than 12 bytes */
+        cmp         r2, #0
+        moveq       r0, #0
+        bxeq        lr
+        mov         r3, r0
+11:
+        ldrb        r0, [r3], #1
+        ldrb        ip, [r1], #1
+        subs        r0, ip
+        bxne        lr
+        subs        r2, r2, #1
+        bne         11b
+        bx          lr
 
 5:      /*************** non-congruent case ***************/
-        and         r0, r1, #3      
+        and         r0, r1, #3
         cmp         r0, #2
         bne         4f
 
         /* here, offset is 2 (16-bits aligned, special cased) */
-        
+
         /* make sure we have at least 16 bytes to process */
         subs        r2, r2, #16
         addmi       r2, r2, #16
@@ -192,8 +250,8 @@
         bic         r1, r1, #3
         ldr         lr, [r1], #4
 
-6:      PLD         (r1, #64)
-        PLD         (r4, #64)
+6:      pld         [r1, #(CACHE_LINE_SIZE * 2)]
+        pld         [r4, #(CACHE_LINE_SIZE * 2)]
         mov         ip, lr, lsr #16
         ldr         lr, [r1], #4
         ldr         r0, [r4], #4
@@ -280,3 +338,4 @@
         mov         r2, #4
 		ldmfd		sp!, {r5, r6, r7}
         b           8b
+END(memcmp)
diff --git a/libc/arch-arm/bionic/memcpy.S b/libc/arch-arm/bionic/memcpy.S
index 8453cc0..0dc86d5 100644
--- a/libc/arch-arm/bionic/memcpy.S
+++ b/libc/arch-arm/bionic/memcpy.S
@@ -37,28 +37,35 @@
 #ifdef HAVE_32_BYTE_CACHE_LINE
 /* a prefetch distance of 2 cache-lines */
 #define CACHE_LINE_SIZE     32
-#define PREFETCH_DISTANCE   (CACHE_LINE_SIZE*2)
 #else
 /* a prefetch distance of 4 cache-lines works best experimentally */
 #define CACHE_LINE_SIZE     64
-#define PREFETCH_DISTANCE   (CACHE_LINE_SIZE*4)
 #endif
 
 ENTRY(memcpy)
         .save       {r0, lr}
         /* start preloading as early as possible */
-        pld         [r1, #(CACHE_LINE_SIZE*0)]
+        pld         [r1, #(CACHE_LINE_SIZE * 0)]
         stmfd       sp!, {r0, lr}
-        pld         [r1, #(CACHE_LINE_SIZE*1)]
+        pld         [r1, #(CACHE_LINE_SIZE * 1)]
 
+/* If Neon supports unaligned access then remove the align code,
+ * unless a size limit has been specified.
+ */
+#ifndef NEON_UNALIGNED_ACCESS
         /* do we have at least 16-bytes to copy (needed for alignment below) */
         cmp         r2, #16
         blo         5f
 
+        /* check if buffers are aligned. If so, run arm-only version */
+        eor         r3, r0, r1
+        ands        r3, r3, #0x3
+        beq         11f
+
         /* align destination to cache-line for the write-buffer */
         rsb         r3, r0, #0
         ands        r3, r3, #0xF
-        beq         0f
+        beq         2f
 
         /* copy up to 15-bytes (count in r3) */
         sub         r2, r2, r3
@@ -79,10 +86,9 @@
         vld1.8      {d0}, [r1]!
         vst1.8      {d0}, [r0, :64]!
 2:
-
-0:      /* preload immediately the next cache line, which we may need */
-        pld         [r1, #(CACHE_LINE_SIZE*0)]
-        pld         [r1, #(CACHE_LINE_SIZE*1)]
+        /* preload immediately the next cache line, which we may need */
+        pld         [r1, #(CACHE_LINE_SIZE * 0)]
+        pld         [r1, #(CACHE_LINE_SIZE * 1)]
 
 #ifdef HAVE_32_BYTE_CACHE_LINE
         /* make sure we have at least 32 bytes to copy */
@@ -108,23 +114,22 @@
         subs        r2, r2, #64
         blo         2f
 
-        /* preload all the cache lines we need.
-         * NOTE: the number of pld below depends on PREFETCH_DISTANCE,
-         * ideally would would increase the distance in the main loop to
-         * avoid the goofy code below. In practice this doesn't seem to make
-         * a big difference.
-         */
-        pld         [r1, #(CACHE_LINE_SIZE*2)]
-        pld         [r1, #(CACHE_LINE_SIZE*3)]
-        pld         [r1, #(PREFETCH_DISTANCE)]
+        /* preload all the cache lines we need. */
+        pld         [r1, #(CACHE_LINE_SIZE * 2)]
+        pld         [r1, #(CACHE_LINE_SIZE * 3)]
 
 1:      /* The main loop copies 64 bytes at a time */
-        vld1.8      {d0  - d3},   [r1]!
-        vld1.8      {d4  - d7},   [r1]!
-        pld         [r1, #(PREFETCH_DISTANCE)]
+        vld1.8      {d0 - d3}, [r1]!
+        vld1.8      {d4 - d7}, [r1]!
+#ifdef  HAVE_32_BYTE_CACHE_LINE
+        pld         [r1, #(CACHE_LINE_SIZE * 2)]
+        pld         [r1, #(CACHE_LINE_SIZE * 3)]
+#else
+        pld         [r1, #(CACHE_LINE_SIZE * 3)]
+#endif
         subs        r2, r2, #64
-        vst1.8      {d0  - d3},   [r0, :128]!
-        vst1.8      {d4  - d7},   [r0, :128]!
+        vst1.8      {d0 - d3}, [r0, :128]!
+        vst1.8      {d4 - d7}, [r0, :128]!
         bhs         1b
 
 2:      /* fix-up the remaining count and make sure we have >= 32 bytes left */
@@ -133,9 +138,9 @@
         blo         4f
 
 3:      /* 32 bytes at a time. These cache lines were already preloaded */
-        vld1.8      {d0 - d3},  [r1]!
+        vld1.8      {d0 - d3}, [r1]!
         subs        r2, r2, #32
-        vst1.8      {d0 - d3},  [r0, :128]!
+        vst1.8      {d0 - d3}, [r0, :128]!
         bhs         3b
 #endif
 4:      /* less than 32 left */
@@ -145,7 +150,6 @@
         // copies 16 bytes, 128-bits aligned
         vld1.8      {d0, d1}, [r1]!
         vst1.8      {d0, d1}, [r0, :128]!
-
 5:      /* copy up to 15-bytes (count in r2) */
         movs        ip, r2, lsl #29
         bcc         1f
@@ -164,6 +168,164 @@
 
         ldmfd       sp!, {r0, lr}
         bx          lr
+
+#else   /* NEON_UNALIGNED_ACCESS */
+
+        // Check so divider is at least 16 bytes, needed for alignment code.
+        cmp         r2, #16
+        blo         5f
+
+#ifdef NEON_MEMCPY_ALIGNMENT_DIVIDER
+        /* Check the upper size limit for Neon unaligned memory access in memcpy */
+#if NEON_MEMCPY_ALIGNMENT_DIVIDER >= 16
+        cmp         r2, #NEON_MEMCPY_ALIGNMENT_DIVIDER
+        blo         3f
+#endif
+        /* check if buffers are aligned. If so, run arm-only version */
+        eor         r3, r0, r1
+        ands        r3, r3, #0x3
+        beq         11f
+
+        /* align destination to 16 bytes for the write-buffer */
+        rsb         r3, r0, #0
+        ands        r3, r3, #0xF
+        beq         3f
+
+        /* copy up to 15-bytes (count in r3) */
+        sub         r2, r2, r3
+        movs        ip, r3, lsl #31
+        ldrmib      lr, [r1], #1
+        strmib      lr, [r0], #1
+        ldrcsb      ip, [r1], #1
+        ldrcsb      lr, [r1], #1
+        strcsb      ip, [r0], #1
+        strcsb      lr, [r0], #1
+        movs        ip, r3, lsl #29
+        bge         1f
+        // copies 4 bytes, destination 32-bits aligned
+        vld1.32     {d0[0]}, [r1]!
+        vst1.32     {d0[0]}, [r0, :32]!
+1:      bcc         2f
+        // copies 8 bytes, destination 64-bits aligned
+        vld1.8      {d0}, [r1]!
+        vst1.8      {d0}, [r0, :64]!
+2:
+        /* preload immediately the next cache line, which we may need */
+        pld         [r1, #(CACHE_LINE_SIZE * 0)]
+        pld         [r1, #(CACHE_LINE_SIZE * 1)]
+3:
+#endif
+        /* make sure we have at least 64 bytes to copy */
+        subs        r2, r2, #64
+        blo         2f
+
+        /* preload all the cache lines we need */
+        pld         [r1, #(CACHE_LINE_SIZE * 2)]
+        pld         [r1, #(CACHE_LINE_SIZE * 3)]
+
+1:      /* The main loop copies 64 bytes at a time */
+        vld1.8      {d0 - d3}, [r1]!
+        vld1.8      {d4 - d7}, [r1]!
+#ifdef  HAVE_32_BYTE_CACHE_LINE
+        pld         [r1, #(CACHE_LINE_SIZE * 2)]
+        pld         [r1, #(CACHE_LINE_SIZE * 3)]
+#else
+        pld         [r1, #(CACHE_LINE_SIZE * 3)]
+#endif
+        subs        r2, r2, #64
+        vst1.8      {d0 - d3}, [r0]!
+        vst1.8      {d4 - d7}, [r0]!
+        bhs         1b
+
+2:      /* fix-up the remaining count and make sure we have >= 32 bytes left */
+        add         r2, r2, #64
+        subs        r2, r2, #32
+        blo         4f
+
+3:      /* 32 bytes at a time. These cache lines were already preloaded */
+        vld1.8      {d0 - d3}, [r1]!
+        subs        r2, r2, #32
+        vst1.8      {d0 - d3}, [r0]!
+        bhs         3b
+
+4:      /* less than 32 left */
+        add         r2, r2, #32
+        tst         r2, #0x10
+        beq         5f
+        // copies 16 bytes, 128-bits aligned
+        vld1.8      {d0, d1}, [r1]!
+        vst1.8      {d0, d1}, [r0]!
+5:      /* copy up to 15-bytes (count in r2) */
+        movs        ip, r2, lsl #29
+        bcc         1f
+        vld1.8      {d0}, [r1]!
+        vst1.8      {d0}, [r0]!
+1:      bge         2f
+        vld1.32     {d0[0]}, [r1]!
+        vst1.32     {d0[0]}, [r0]!
+2:      movs        ip, r2, lsl #31
+        ldrmib      r3, [r1], #1
+        ldrcsb      ip, [r1], #1
+        ldrcsb      lr, [r1], #1
+        strmib      r3, [r0], #1
+        strcsb      ip, [r0], #1
+        strcsb      lr, [r0], #1
+
+        ldmfd       sp!, {r0, lr}
+        bx          lr
+#endif  /* NEON_UNALIGNED_ACCESS */
+11:
+        /* Simple arm-only copy loop to handle aligned copy operations */
+        stmfd       sp!, {r4, r5, r6, r7, r8}
+        pld         [r1, #(CACHE_LINE_SIZE * 2)]
+
+        /* Check alignment */
+        rsb         r3, r1, #0
+        ands        r3, #3
+        beq         2f
+
+        /* align source to 32 bits. We need to insert 2 instructions between
+         * a ldr[b|h] and str[b|h] because byte and half-word instructions
+         * stall 2 cycles.
+         */
+        movs        r12, r3, lsl #31
+        sub         r2, r2, r3      /* we know that r3 <= r2 because r2 >= 4 */
+        ldrmib      r3, [r1], #1
+        ldrcsb      r4, [r1], #1
+        ldrcsb      r5, [r1], #1
+        strmib      r3, [r0], #1
+        strcsb      r4, [r0], #1
+        strcsb      r5, [r0], #1
+2:
+        subs        r2, #32
+        blt         5f
+        pld         [r1, #(CACHE_LINE_SIZE * 3)]
+3:      /* Main copy loop, copying 32 bytes at a time */
+        pld         [r1, #(CACHE_LINE_SIZE * 4)]
+        ldmia       r1!, {r3, r4, r5, r6, r7, r8, r12, lr}
+        subs        r2, r2, #32
+        stmia       r0!, {r3, r4, r5, r6, r7, r8, r12, lr}
+        bge         3b
+5:      /* Handle any remaining bytes */
+        adds        r2, #32
+        beq         6f
+
+        movs        r12, r2, lsl #28
+        ldmcsia     r1!, {r3, r4, r5, r6}   /* 16 bytes */
+        ldmmiia     r1!, {r7, r8}           /*  8 bytes */
+        stmcsia     r0!, {r3, r4, r5, r6}
+        stmmiia     r0!, {r7, r8}
+        movs        r12, r2, lsl #30
+        ldrcs       r3, [r1], #4            /*  4 bytes */
+        ldrmih      r4, [r1], #2            /*  2 bytes */
+        strcs       r3, [r0], #4
+        strmih      r4, [r0], #2
+        tst         r2, #0x1
+        ldrneb      r3, [r1]                /*  last byte  */
+        strneb      r3, [r0]
+6:
+        ldmfd       sp!, {r4, r5, r6, r7, r8}
+        ldmfd       sp!, {r0, pc}
 END(memcpy)
 
 
diff --git a/libc/arch-arm/bionic/memcpy.a15.S b/libc/arch-arm/bionic/memcpy.a15.S
new file mode 100644
index 0000000..516e20c
--- /dev/null
+++ b/libc/arch-arm/bionic/memcpy.a15.S
@@ -0,0 +1,406 @@
+/*
+ * Copyright (c) 2013 ARM Ltd
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the company may not be used to endorse or promote
+ *    products derived from this software without specific prior written
+ *    permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+    /* Prototype: void *memcpy (void *dst, const void *src, size_t count).  */
+
+        /* Use the version of memcpy implemented using LDRD and STRD.
+           This version is tuned for Cortex-A15.
+           This might not be the best for other ARMv7-A CPUs,
+           but there is no predefine to distinguish between
+           different CPUs in the same architecture,
+           and this version is better than the plain memcpy provided in newlib.
+
+           Therefore, we use this version for all ARMv7-A CPUS.  */
+
+        /* To make the same code compile for both ARM and Thumb instruction
+       sets, switch to unified syntax at the beginning of this function.
+           However, by using the same code, we may be missing optimization
+       opportunities.  For instance, in LDRD/STRD instructions, the first
+       destination register must be even and the second consecutive in
+       ARM state, but not in Thumb state.  */
+
+#include <machine/cpu-features.h>
+#include <machine/asm.h>
+
+        .syntax         unified
+
+ENTRY(memcpy)
+
+       /* Assumes that n >= 0, and dst, src are valid pointers.
+          If there is at least 8 bytes to copy, use LDRD/STRD.
+          If src and dst are misaligned with different offsets,
+          first copy byte by byte until dst is aligned,
+          and then copy using LDRD/STRD and shift if needed.
+          When less than 8 left, copy a word and then byte by byte.  */
+
+       /* Save registers (r0 holds the return value):
+          optimized push {r0, r4, r5, r6, r7, lr}.
+          To try and improve performance, stack layout changed,
+          i.e., not keeping the stack looking like users expect
+          (highest numbered register at highest address).  */
+        .save   {r0, lr}
+        push    {r0, lr}
+        .save   {r4, r5}
+        strd    r4, r5, [sp, #-8]!
+        .save   {r6, r7}
+        strd    r6, r7, [sp, #-8]!
+
+       /* TODO: Add debug frame directives.
+          We don't need exception unwind directives, because the code below
+      does not throw any exceptions and does not call any other functions.
+          Generally, newlib functions like this lack debug information for
+      assembler source.  */
+
+        /* Get copying of tiny blocks out of the way first.  */
+        /* Is there at least 4 bytes to copy?  */
+        subs    r2, r2, #4
+        blt     copy_less_than_4                 /* If n < 4.  */
+
+        /* Check word alignment.  */
+        ands    ip, r0, #3                       /* ip = last 2 bits of dst.  */
+        bne     dst_not_word_aligned             /* If dst is not word-aligned.  */
+
+        /* Get here if dst is word-aligned.  */
+        ands    ip, r1, #3                      /* ip = last 2 bits of src.  */
+        bne     src_not_word_aligned            /* If src is not word-aligned.  */
+word_aligned:
+        /* Get here if source and dst both are word-aligned.
+           The number of bytes remaining to copy is r2+4.  */
+
+        /* Is there is at least 64 bytes to copy?  */
+        subs    r2, r2, #60
+        blt     copy_less_than_64                /* If r2 + 4 < 64.  */
+
+        /* First, align the destination buffer to 8-bytes,
+           to make sure double loads and stores don't cross cache line boundary,
+           as they are then more expensive even if the data is in the cache
+           (require two load/store issue cycles instead of one).
+           If only one of the buffers is not 8-bytes aligned,
+           then it's more important to align dst than src,
+           because there is more penalty for stores
+           than loads that cross cacheline boundary.
+           This check and realignment are only worth doing
+           if there is a lot to copy.  */
+
+        /* Get here if dst is word aligned,
+           i.e., the 2 least significant bits are 0.
+           If dst is not 2w aligned (i.e., the 3rd bit is not set in dst),
+           then copy 1 word (4 bytes).  */
+        ands    r3, r0, #4
+        beq     11f                  /* If dst already two-word aligned.  */
+        ldr     r3, [r1], #4
+        str     r3, [r0], #4
+        subs    r2, r2, #4
+        blt     copy_less_than_64
+
+11:
+        /* TODO: Align to cacheline (useful for PLD optimization).  */
+
+        /* Every loop iteration copies 64 bytes.  */
+1:
+        .irp    offset, #0, #8, #16, #24, #32, #40, #48, #56
+        ldrd    r4, r5, [r1, \offset]
+        strd    r4, r5, [r0, \offset]
+        .endr
+
+        add     r0, r0, #64
+        add     r1, r1, #64
+        subs    r2, r2, #64
+        bge     1b                            /* If there is more to copy.  */
+
+copy_less_than_64:
+
+        /* Get here if less than 64 bytes to copy, -64 <= r2 < 0.
+           Restore the count if there is more than 7 bytes to copy.  */
+        adds    r2, r2, #56
+        blt     copy_less_than_8
+
+        /* Copy 8 bytes at a time.  */
+2:
+        ldrd    r4, r5, [r1], #8
+        strd    r4, r5, [r0], #8
+        subs    r2, r2, #8
+        bge     2b                            /* If there is more to copy.  */
+
+copy_less_than_8:
+
+        /* Get here if less than 8 bytes to copy, -8 <= r2 < 0.
+           Check if there is more to copy.  */
+        cmn     r2, #8
+        beq     return                          /* If r2 + 8 == 0.  */
+
+        /* Restore the count if there is more than 3 bytes to copy.  */
+        adds    r2, r2, #4
+        blt     copy_less_than_4
+
+        /* Copy 4 bytes.  */
+        ldr     r3, [r1], #4
+        str     r3, [r0], #4
+
+copy_less_than_4:
+        /* Get here if less than 4 bytes to copy, -4 <= r2 < 0.  */
+
+        /* Restore the count, check if there is more to copy.  */
+        adds    r2, r2, #4
+        beq     return                          /* If r2 == 0.  */
+
+        /* Get here with r2 is in {1,2,3}={01,10,11}.  */
+        /* Logical shift left r2, insert 0s, update flags.  */
+        lsls    r2, r2, #31
+
+        /* Copy byte by byte.
+           Condition ne means the last bit of r2 is 0.
+           Condition cs means the second to last bit of r2 is set,
+           i.e., r2 is 1 or 3.  */
+        itt     ne
+        ldrbne  r3, [r1], #1
+        strbne  r3, [r0], #1
+
+        itttt   cs
+        ldrbcs  r4, [r1], #1
+        ldrbcs  r5, [r1]
+        strbcs  r4, [r0], #1
+        strbcs  r5, [r0]
+
+return:
+        /* Restore registers: optimized pop {r0, r4, r5, r6, r7, pc}   */
+        /* This is the only return point of memcpy.  */
+        ldrd r6, r7, [sp], #8
+        ldrd r4, r5, [sp], #8
+        pop {r0, pc}
+
+#ifndef __ARM_FEATURE_UNALIGNED
+
+       /* The following assembly macro implements misaligned copy in software.
+          Assumes that dst is word aligned, src is at offset "pull" bits from
+      word, push = 32 - pull, and the number of bytes that remain to copy
+      is r2 + 4, r2 >= 0.  */
+
+       /* In the code below, r2 is the number of bytes that remain to be
+      written.  The number of bytes read is always larger, because we have
+      partial words in the shift queue.  */
+
+        .macro  miscopy pull push shiftleft shiftright
+
+        /* Align src to the previous word boundary.  */
+        bic     r1, r1, #3
+
+        /* Initialize the shift queue.  */
+        ldr     r5, [r1], #4                   /* Load a word from source.  */
+
+        subs    r2, r2, #4
+        blt     6f          /* Go to misaligned copy of less than 8 bytes.  */
+
+       /* Get here if there is more than 8 bytes to copy.
+          The number of bytes to copy is r2+8, r2 >= 0.  */
+
+       subs     r2, r2, #56
+       blt      4f         /* Go to misaligned copy of less than 64 bytes.  */
+
+3:
+       /* Get here if there is more than 64 bytes to copy.
+          The number of bytes to copy is r2+64, r2 >= 0.  */
+
+       /* Copy 64 bytes in every iteration.
+          Use a partial word from the shift queue.  */
+        .irp    offset, #0, #8, #16, #24, #32, #40, #48, #56
+        mov     r6, r5, \shiftleft #\pull
+        ldrd    r4, r5, [r1, \offset]
+        orr     r6, r6, r4, \shiftright #\push
+        mov     r7, r4, \shiftleft #\pull
+        orr     r7, r7, r5, \shiftright #\push
+        strd    r6, r7, [r0, \offset]
+        .endr
+
+        add     r1, r1, #64
+        add     r0, r0, #64
+        subs    r2, r2, #64
+        bge     3b
+
+4:
+       /* Get here if there is less than 64 bytes to copy (-64 <= r2 < 0)
+      and they are misaligned.  */
+
+       /* Restore the count if there is more than 7 bytes to copy.  */
+        adds    r2, r2, #56
+
+        blt     6f          /* Go to misaligned copy of less than 8 bytes.  */
+
+5:
+        /* Copy 8 bytes at a time.
+           Use a partial word from the shift queue.  */
+        mov     r6, r5, \shiftleft #\pull
+        ldrd    r4, r5, [r1], #8
+        orr     r6, r6, r4, \shiftright #\push
+        mov     r7, r4, \shiftleft #\pull
+        orr     r7, r7, r5, \shiftright #\push
+        strd    r6, r7, [r0], #8
+
+        subs    r2, r2, #8
+        bge     5b                        /* If there is more to copy.  */
+
+6:
+        /* Get here if there less than 8 bytes to copy (-8 <= r2 < 0)
+           and they are misaligned.  */
+
+        /* Check if there is more to copy.  */
+        cmn     r2, #8
+        beq     return
+
+        /* Check if there is less than 4 bytes to copy.  */
+        cmn     r2, #4
+
+        itt     lt
+        /* Restore src offset from word-align.  */
+        sublt   r1, r1, #(\push / 8)
+        blt     copy_less_than_4
+
+        /* Use a partial word from the shift queue.  */
+        mov     r3, r5, \shiftleft #\pull
+        /* Load a word from src, but without writeback
+           (this word is not fully written to dst).  */
+        ldr     r5, [r1]
+
+        /* Restore src offset from word-align.  */
+        add     r1, r1, #(\pull / 8)
+
+        /* Shift bytes to create one dst word and store it.  */
+        orr     r3, r3, r5, \shiftright #\push
+        str     r3, [r0], #4
+
+        /* Use single byte copying of the remaining bytes.  */
+        b       copy_less_than_4
+
+        .endm
+
+#endif /* not __ARM_FEATURE_UNALIGNED  */
+
+dst_not_word_aligned:
+
+       /* Get here when dst is not aligned and ip has the last 2 bits of dst,
+          i.e., ip is the offset of dst from word.
+          The number of bytes that remains to copy is r2 + 4,
+          i.e., there are at least 4 bytes to copy.
+          Write a partial word (0 to 3 bytes), such that dst becomes
+      word-aligned.  */
+
+       /* If dst is at ip bytes offset from a word (with 0 < ip < 4),
+          then there are (4 - ip) bytes to fill up to align dst to the next
+      word.  */
+        rsb     ip, ip, #4                        /* ip = #4 - ip.  */
+        cmp     ip, #2
+
+       /* Copy byte by byte with conditionals.  */
+        itt     gt
+        ldrbgt  r3, [r1], #1
+        strbgt  r3, [r0], #1
+
+        itt     ge
+        ldrbge  r4, [r1], #1
+        strbge  r4, [r0], #1
+
+        ldrb    lr, [r1], #1
+        strb    lr, [r0], #1
+
+       /* Update the count.
+          ip holds the number of bytes we have just copied.  */
+        subs    r2, r2, ip                        /* r2 = r2 - ip.  */
+        blt     copy_less_than_4                  /* If r2 < ip.  */
+
+       /* Get here if there are more than 4 bytes to copy.
+          Check if src is aligned.  If beforehand src and dst were not word
+      aligned but congruent (same offset), then now they are both
+      word-aligned, and we can copy the rest efficiently (without
+      shifting).  */
+        ands    ip, r1, #3                    /* ip = last 2 bits of src.  */
+        beq     word_aligned                  /* If r1 is word-aligned.  */
+
+src_not_word_aligned:
+       /* Get here when src is not word-aligned, but dst is word-aligned.
+          The number of bytes that remains to copy is r2+4.  */
+
+#ifdef __ARM_FEATURE_UNALIGNED
+       /* Copy word by word using LDR when alignment can be done in hardware,
+          i.e., SCTLR.A is set, supporting unaligned access in LDR and STR.  */
+        subs    r2, r2, #60
+        blt     8f
+
+7:
+        /* Copy 64 bytes in every loop iteration.  */
+        .irp    offset, #0, #4, #8, #12, #16, #20, #24, #28, #32, #36, #40, #44, #48, #52, #56, #60
+        ldr     r3, [r1, \offset]
+        str     r3, [r0, \offset]
+        .endr
+
+        add     r0, r0, #64
+        add     r1, r1, #64
+        subs    r2, r2, #64
+        bge     7b
+
+8:
+        /* Get here if less than 64 bytes to copy, -64 <= r2 < 0.
+           Check if there is more than 3 bytes to copy.  */
+        adds    r2, r2, #60
+        blt     copy_less_than_4
+
+9:
+       /* Get here if there is less than 64 but at least 4 bytes to copy,
+          where the number of bytes to copy is r2+4.  */
+        ldr     r3, [r1], #4
+        str     r3, [r0], #4
+        subs    r2, r2, #4
+        bge     9b
+
+        b       copy_less_than_4
+
+#else /* not __ARM_FEATURE_UNALIGNED  */
+
+       /* ip has last 2 bits of src,
+          i.e., ip is the offset of src from word, and ip > 0.
+          Compute shifts needed to copy from src to dst.  */
+        cmp     ip, #2
+        beq     miscopy_16_16             /* If ip == 2.  */
+        bge     miscopy_24_8              /* If ip == 3.  */
+
+        /* Get here if ip == 1.  */
+
+        /* Endian independent macros for shifting bytes within registers.  */
+
+#ifndef __ARMEB__
+miscopy_8_24:   miscopy pull=8 push=24 shiftleft=lsr shiftright=lsl
+miscopy_16_16:  miscopy pull=16 push=16 shiftleft=lsr shiftright=lsl
+miscopy_24_8:   miscopy pull=24 push=8 shiftleft=lsr shiftright=lsl
+#else  /* not __ARMEB__ */
+miscopy_8_24:   miscopy pull=8 push=24 shiftleft=lsl shiftright=lsr
+miscopy_16_16:  miscopy pull=16 push=16 shiftleft=lsl shiftright=lsr
+miscopy_24_8:   miscopy pull=24 push=8 shiftleft=lsl shiftright=lsr
+#endif  /* not __ARMEB__ */
+
+#endif  /* not __ARM_FEATURE_UNALIGNED  */
+
+END(memcpy)
diff --git a/libc/arch-arm/bionic/memset.S b/libc/arch-arm/bionic/memset.S
index 273b9e3..102d541 100644
--- a/libc/arch-arm/bionic/memset.S
+++ b/libc/arch-arm/bionic/memset.S
@@ -26,23 +26,114 @@
  * SUCH DAMAGE.
  */
 
+#include <machine/cpu-features.h>
 #include <machine/asm.h>
-	
+
 		/*
 		 * Optimized memset() for ARM.
          *
          * memset() returns its first argument.
 		 */
-	
+
+#if defined(__ARM_NEON__)
+    .fpu    neon
+#endif
+
 ENTRY(bzero)
         mov     r2, r1
         mov     r1, #0
+        // Fall through to memset...
 END(bzero)
 
 ENTRY(memset)
+#if defined(__ARM_NEON__)
+
+#ifdef  NEON_MEMSET_DIVIDER
+        cmp         r2, #NEON_MEMSET_DIVIDER
+        bhi         11f
+#endif
+        .save       {r0}
+        stmfd       sp!, {r0}
+
+        vdup.8      q0, r1
+
+#ifndef NEON_UNALIGNED_ACCESS
+        /* do we have at least 16-bytes to write (needed for alignment below) */
+        cmp         r2, #16
+        blo         3f
+
+        /* align destination to 16 bytes for the write-buffer */
+        rsb         r3, r0, #0
+        ands        r3, r3, #0xF
+        beq         2f
+
+        /* write up to 15-bytes (count in r3) */
+        sub         r2, r2, r3
+        movs        ip, r3, lsl #31
+        strmib      r1, [r0], #1
+        strcsb      r1, [r0], #1
+        strcsb      r1, [r0], #1
+        movs        ip, r3, lsl #29
+        bge         1f
+
+        // writes 4 bytes, 32-bits aligned
+        vst1.32     {d0[0]}, [r0, :32]!
+1:      bcc         2f
+
+        // writes 8 bytes, 64-bits aligned
+        vst1.8      {d0}, [r0, :64]!
+2:
+#endif
+        /* make sure we have at least 32 bytes to write */
+        subs        r2, r2, #32
+        blo         2f
+        vmov        q1, q0
+
+1:      /* The main loop writes 32 bytes at a time */
+        subs        r2, r2, #32
+#ifndef NEON_UNALIGNED_ACCESS
+        vst1.8      {d0 - d3}, [r0, :128]!
+#else
+        vst1.8      {d0 - d3}, [r0]!
+#endif
+        bhs         1b
+
+2:      /* less than 32 left */
+        add         r2, r2, #32
+        tst         r2, #0x10
+        beq         3f
+
+        // writes 16 bytes, 128-bits aligned
+#ifndef NEON_UNALIGNED_ACCESS
+        vst1.8      {d0, d1}, [r0, :128]!
+#else
+        vst1.8      {d0, d1}, [r0]!
+#endif
+3:      /* write up to 15-bytes (count in r2) */
+        movs        ip, r2, lsl #29
+        bcc         1f
+        vst1.8      {d0}, [r0]!
+1:      bge         2f
+        vst1.32     {d0[0]}, [r0]!
+2:      movs        ip, r2, lsl #31
+        strmib      r1, [r0], #1
+        strcsb      r1, [r0], #1
+        strcsb      r1, [r0], #1
+        ldmfd       sp!, {r0}
+        bx          lr
+11:
+#endif
+
+        /*
+         * Optimized memset() for ARM.
+         *
+         * memset() returns its first argument.
+         */
+
 		/* compute the offset to align the destination
 		 * offset = (4-(src&3))&3 = -src & 3
 		 */
+
         .save       {r0, r4-r7, lr}
 		stmfd		sp!, {r0, r4-r7, lr}
 		rsb			r3, r0, #0
@@ -70,7 +161,7 @@
         mov         r5, r1
         mov         r6, r1
         mov         r7, r1
-        
+
 		rsb         r3, r0, #0
 		ands		r3, r3, #0x1C
 		beq         3f
@@ -78,7 +169,7 @@
 		andhi		r3, r2, #0x1C
 		sub         r2, r2, r3
 
-		/* conditionnaly writes 0 to 7 words (length in r3) */
+		/* conditionally writes 0 to 7 words (length in r3) */
 		movs		r3, r3, lsl #28
 		stmcsia		r0!, {r1, lr}
 		stmcsia		r0!, {r1, lr}
@@ -95,7 +186,7 @@
         bhs         1b
 2:      add         r2, r2, #32
 
-		/* conditionnaly stores 0 to 31 bytes */
+		/* conditionally stores 0 to 31 bytes */
 		movs		r2, r2, lsl #28
 		stmcsia		r0!, {r1,r3,r12,lr}
 		stmmiia		r0!, {r1, lr}
diff --git a/libc/arch-arm/bionic/strcmp.a15.S b/libc/arch-arm/bionic/strcmp.a15.S
new file mode 100644
index 0000000..b726a6e
--- /dev/null
+++ b/libc/arch-arm/bionic/strcmp.a15.S
@@ -0,0 +1,787 @@
+/*
+ * Copyright (c) 2013 ARM Ltd
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the company may not be used to endorse or promote
+ *    products derived from this software without specific prior written
+ *    permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "arm_asm.h"
+
+#ifdef __ARMEB__
+#define S2LOMEM lsl
+#define S2LOMEMEQ lsleq
+#define S2HIMEM lsr
+#define MSB 0x000000ff
+#define LSB 0xff000000
+#define BYTE0_OFFSET 24
+#define BYTE1_OFFSET 16
+#define BYTE2_OFFSET 8
+#define BYTE3_OFFSET 0
+#else /* not  __ARMEB__ */
+#define S2LOMEM lsr
+#define S2LOMEMEQ lsreq
+#define S2HIMEM lsl
+#define BYTE0_OFFSET 0
+#define BYTE1_OFFSET 8
+#define BYTE2_OFFSET 16
+#define BYTE3_OFFSET 24
+#define MSB 0xff000000
+#define LSB 0x000000ff
+#endif /* not  __ARMEB__ */
+
+.syntax         unified
+
+#if defined (__thumb__)
+        .thumb
+        .thumb_func
+#endif
+        .global strcmp
+        .type   strcmp, %function
+strcmp:
+
+#if (defined (__thumb__) && !defined (__thumb2__))
+1:
+        ldrb    r2, [r0]
+        ldrb    r3, [r1]
+        adds    r0, r0, #1
+        adds    r1, r1, #1
+        cmp     r2, #0
+        beq     2f
+        cmp     r2, r3
+        beq     1b
+2:
+        subs    r0, r2, r3
+        bx      lr
+#elif (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED))
+1:
+        ldrb    r2, [r0], #1
+        ldrb    r3, [r1], #1
+        cmp     r2, #1
+        it      cs
+        cmpcs   r2, r3
+        beq     1b
+        subs    r0, r2, r3
+        RETURN
+
+
+#elif (defined (_ISA_THUMB_2) || defined (_ISA_ARM_6))
+      /* Use LDRD whenever possible.  */
+
+/* The main thing to look out for when comparing large blocks is that
+   the loads do not cross a page boundary when loading past the index
+   of the byte with the first difference or the first string-terminator.
+
+   For example, if the strings are identical and the string-terminator
+   is at index k, byte by byte comparison will not load beyond address
+   s1+k and s2+k; word by word comparison may load up to 3 bytes beyond
+   k; double word - up to 7 bytes.  If the load of these bytes crosses
+   a page boundary, it might cause a memory fault (if the page is not mapped)
+   that would not have happened in byte by byte comparison.
+
+   If an address is (double) word aligned, then a load of a (double) word
+   from that address will not cross a page boundary.
+   Therefore, the algorithm below considers word and double-word alignment
+   of strings separately.  */
+
+/* High-level description of the algorithm.
+
+   * The fast path: if both strings are double-word aligned,
+     use LDRD to load two words from each string in every loop iteration.
+   * If the strings have the same offset from a word boundary,
+     use LDRB to load and compare byte by byte until
+     the first string is aligned to a word boundary (at most 3 bytes).
+     This is optimized for quick return on short unaligned strings.
+   * If the strings have the same offset from a double-word boundary,
+     use LDRD to load two words from each string in every loop iteration, as in the fast path.
+   * If the strings do not have the same offset from a double-word boundary,
+     load a word from the second string before the loop to initialize the queue.
+     Use LDRD to load two words from every string in every loop iteration.
+     Inside the loop, load the second word from the second string only after comparing
+     the first word, using the queued value, to guarantee safety across page boundaries.
+   * If the strings do not have the same offset from a word boundary,
+     use LDR and a shift queue. Order of loads and comparisons matters,
+     similarly to the previous case.
+
+   * Use UADD8 and SEL to compare words, and use REV and CLZ to compute the return value.
+   * The only difference between ARM and Thumb modes is the use of CBZ instruction.
+   * The only difference between big and little endian is the use of REV in little endian
+     to compute the return value, instead of MOV.
+   * No preload. [TODO.]
+*/
+
+        .macro m_cbz reg label
+#ifdef __thumb2__
+        cbz     \reg, \label
+#else   /* not defined __thumb2__ */
+        cmp     \reg, #0
+        beq     \label
+#endif /* not defined __thumb2__ */
+        .endm /* m_cbz */
+
+        .macro m_cbnz reg label
+#ifdef __thumb2__
+        cbnz    \reg, \label
+#else   /* not defined __thumb2__ */
+        cmp     \reg, #0
+        bne     \label
+#endif /* not defined __thumb2__ */
+        .endm /* m_cbnz */
+
+        .macro  init
+        /* Macro to save temporary registers and prepare magic values.  */
+        subs    sp, sp, #16
+        strd    r4, r5, [sp, #8]
+        strd    r6, r7, [sp]
+        mvn     r6, #0  /* all F */
+        mov     r7, #0  /* all 0 */
+        .endm   /* init */
+
+        .macro  magic_compare_and_branch w1 w2 label
+        /* Macro to compare registers w1 and w2 and conditionally branch to label.  */
+        cmp     \w1, \w2        /* Are w1 and w2 the same?  */
+        magic_find_zero_bytes \w1
+        it      eq
+        cmpeq   ip, #0          /* Is there a zero byte in w1?  */
+        bne     \label
+        .endm /* magic_compare_and_branch */
+
+        .macro  magic_find_zero_bytes w1
+        /* Macro to find all-zero bytes in w1, result is in ip.  */
+#if (defined (__ARM_FEATURE_DSP))
+        uadd8   ip, \w1, r6
+        sel     ip, r7, r6
+#else /* not defined (__ARM_FEATURE_DSP) */
+        /* __ARM_FEATURE_DSP is not defined for some Cortex-M processors.
+        Coincidently, these processors only have Thumb-2 mode, where we can use the
+        the (large) magic constant available directly as an immediate in instructions.
+        Note that we cannot use the magic constant in ARM mode, where we need
+        to create the constant in a register.  */
+        sub     ip, \w1, #0x01010101
+        bic     ip, ip, \w1
+        and     ip, ip, #0x80808080
+#endif /* not defined (__ARM_FEATURE_DSP) */
+        .endm /* magic_find_zero_bytes */
+
+        .macro  setup_return w1 w2
+#ifdef __ARMEB__
+        mov     r1, \w1
+        mov     r2, \w2
+#else /* not  __ARMEB__ */
+        rev     r1, \w1
+        rev     r2, \w2
+#endif /* not  __ARMEB__ */
+        .endm /* setup_return */
+
+        /*
+        optpld r0, #0
+        optpld r1, #0
+        */
+
+        /* Are both strings double-word aligned?  */
+        orr     ip, r0, r1
+        tst     ip, #7
+        bne     do_align
+
+        /* Fast path.  */
+        init
+
+doubleword_aligned:
+
+        /* Get here when the strings to compare are double-word aligned.  */
+        /* Compare two words in every iteration.  */
+        .p2align        2
+2:
+        /*
+        optpld r0, #16
+        optpld r1, #16
+        */
+
+        /* Load the next double-word from each string.  */
+        ldrd    r2, r3, [r0], #8
+        ldrd    r4, r5, [r1], #8
+
+        magic_compare_and_branch w1=r2, w2=r4, label=return_24
+        magic_compare_and_branch w1=r3, w2=r5, label=return_35
+        b       2b
+
+do_align:
+        /* Is the first string word-aligned?  */
+        ands    ip, r0, #3
+        beq     word_aligned_r0
+
+        /* Fast compare byte by byte until the first string is word-aligned.  */
+        /* The offset of r0 from a word boundary is in ip. Thus, the number of bytes
+        to read until the next word boudnary is 4-ip.  */
+        bic     r0, r0, #3
+        ldr     r2, [r0], #4
+        lsls    ip, ip, #31
+        beq     byte2
+        bcs     byte3
+
+byte1:
+        ldrb    ip, [r1], #1
+        uxtb    r3, r2, ror #BYTE1_OFFSET
+        subs    ip, r3, ip
+        bne     fast_return
+        m_cbz   reg=r3, label=fast_return
+
+byte2:
+        ldrb    ip, [r1], #1
+        uxtb    r3, r2, ror #BYTE2_OFFSET
+        subs    ip, r3, ip
+        bne     fast_return
+        m_cbz   reg=r3, label=fast_return
+
+byte3:
+        ldrb    ip, [r1], #1
+        uxtb    r3, r2, ror #BYTE3_OFFSET
+        subs    ip, r3, ip
+        bne     fast_return
+        m_cbnz  reg=r3, label=word_aligned_r0
+
+fast_return:
+        mov     r0, ip
+        bx      lr
+
+word_aligned_r0:
+        init
+        /* The first string is word-aligned.  */
+        /* Is the second string word-aligned?  */
+        ands    ip, r1, #3
+        bne     strcmp_unaligned
+
+word_aligned:
+        /* The strings are word-aligned. */
+        /* Is the first string double-word aligned?  */
+        tst     r0, #4
+        beq     doubleword_aligned_r0
+
+        /* If r0 is not double-word aligned yet, align it by loading
+        and comparing the next word from each string.  */
+        ldr     r2, [r0], #4
+        ldr     r4, [r1], #4
+        magic_compare_and_branch w1=r2 w2=r4 label=return_24
+
+doubleword_aligned_r0:
+        /* Get here when r0 is double-word aligned.  */
+        /* Is r1 doubleword_aligned?  */
+        tst     r1, #4
+        beq     doubleword_aligned
+
+        /* Get here when the strings to compare are word-aligned,
+        r0 is double-word aligned, but r1 is not double-word aligned.  */
+
+        /* Initialize the queue.  */
+        ldr     r5, [r1], #4
+
+        /* Compare two words in every iteration.  */
+        .p2align        2
+3:
+        /*
+        optpld r0, #16
+        optpld r1, #16
+        */
+
+        /* Load the next double-word from each string and compare.  */
+        ldrd    r2, r3, [r0], #8
+        magic_compare_and_branch w1=r2 w2=r5 label=return_25
+        ldrd    r4, r5, [r1], #8
+        magic_compare_and_branch w1=r3 w2=r4 label=return_34
+        b       3b
+
+        .macro miscmp_word offsetlo offsethi
+        /* Macro to compare misaligned strings.  */
+        /* r0, r1 are word-aligned, and at least one of the strings
+        is not double-word aligned.  */
+        /* Compare one word in every loop iteration.  */
+        /* OFFSETLO is the original bit-offset of r1 from a word-boundary,
+        OFFSETHI is 32 - OFFSETLO (i.e., offset from the next word).  */
+
+        /* Initialize the shift queue.  */
+        ldr     r5, [r1], #4
+
+        /* Compare one word from each string in every loop iteration.  */
+        .p2align        2
+7:
+        ldr     r3, [r0], #4
+        S2LOMEM r5, r5, #\offsetlo
+        magic_find_zero_bytes w1=r3
+        cmp     r7, ip, S2HIMEM #\offsetlo
+        and     r2, r3, r6, S2LOMEM #\offsetlo
+        it      eq
+        cmpeq   r2, r5
+        bne     return_25
+        ldr     r5, [r1], #4
+        cmp     ip, #0
+        eor r3, r2, r3
+        S2HIMEM r2, r5, #\offsethi
+        it      eq
+        cmpeq   r3, r2
+        bne     return_32
+        b       7b
+        .endm /* miscmp_word */
+
+strcmp_unaligned:
+        /* r0 is word-aligned, r1 is at offset ip from a word.  */
+        /* Align r1 to the (previous) word-boundary.  */
+        bic     r1, r1, #3
+
+        /* Unaligned comparison word by word using LDRs. */
+        cmp     ip, #2
+        beq     miscmp_word_16                    /* If ip == 2.  */
+        bge     miscmp_word_24                    /* If ip == 3.  */
+        miscmp_word offsetlo=8 offsethi=24        /* If ip == 1.  */
+miscmp_word_16:  miscmp_word offsetlo=16 offsethi=16
+miscmp_word_24:  miscmp_word offsetlo=24 offsethi=8
+
+
+return_32:
+        setup_return w1=r3, w2=r2
+        b       do_return
+return_34:
+        setup_return w1=r3, w2=r4
+        b       do_return
+return_25:
+        setup_return w1=r2, w2=r5
+        b       do_return
+return_35:
+        setup_return w1=r3, w2=r5
+        b       do_return
+return_24:
+        setup_return w1=r2, w2=r4
+
+do_return:
+
+#ifdef __ARMEB__
+        mov     r0, ip
+#else /* not  __ARMEB__ */
+        rev     r0, ip
+#endif /* not  __ARMEB__ */
+
+        /* Restore temporaries early, before computing the return value.  */
+        ldrd    r6, r7, [sp]
+        ldrd    r4, r5, [sp, #8]
+        adds    sp, sp, #16
+
+        /* There is a zero or a different byte between r1 and r2.  */
+        /* r0 contains a mask of all-zero bytes in r1.  */
+        /* Using r0 and not ip here because cbz requires low register.  */
+        m_cbz   reg=r0, label=compute_return_value
+        clz     r0, r0
+        /* r0 contains the number of bits on the left of the first all-zero byte in r1.  */
+        rsb     r0, r0, #24
+        /* Here, r0 contains the number of bits on the right of the first all-zero byte in r1.  */
+        lsr     r1, r1, r0
+        lsr     r2, r2, r0
+
+compute_return_value:
+        movs    r0, #1
+        cmp     r1, r2
+        /* The return value is computed as follows.
+        If r1>r2 then (C==1 and Z==0) and LS doesn't hold and r0 is #1 at return.
+        If r1<r2 then (C==0 and Z==0) and we execute SBC with carry_in=0,
+        which means r0:=r0-r0-1 and r0 is #-1 at return.
+        If r1=r2 then (C==1 and Z==1) and we execute SBC with carry_in=1,
+        which means r0:=r0-r0 and r0 is #0 at return.
+        (C==0 and Z==1) cannot happen because the carry bit is "not borrow".  */
+        it      ls
+        sbcls   r0, r0, r0
+        bx      lr
+
+
+#else   /* !(defined (_ISA_THUMB_2) || defined (_ISA_ARM_6)
+             defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED) ||
+             (defined (__thumb__) && !defined (__thumb2__))) */
+
+        /* Use LDR whenever possible. */
+
+#ifdef __thumb2__
+#define magic1(REG) 0x01010101
+#define magic2(REG) 0x80808080
+#else
+#define magic1(REG) REG
+#define magic2(REG) REG, lsl #7
+#endif
+
+        optpld  r0
+        optpld  r1
+        eor     r2, r0, r1
+        tst     r2, #3
+        /* Strings not at same byte offset from a word boundary.  */
+        bne     strcmp_unaligned
+        ands    r2, r0, #3
+        bic     r0, r0, #3
+        bic     r1, r1, #3
+        ldr     ip, [r0], #4
+        it      eq
+        ldreq   r3, [r1], #4
+        beq     1f
+        /* Although s1 and s2 have identical initial alignment, they are
+        not currently word aligned.  Rather than comparing bytes,
+    make sure that any bytes fetched from before the addressed
+    bytes are forced to 0xff.  Then they will always compare
+    equal.  */
+        eor     r2, r2, #3
+        lsl     r2, r2, #3
+        mvn     r3, MSB
+        S2LOMEM        r2, r3, r2
+        ldr     r3, [r1], #4
+        orr     ip, ip, r2
+        orr     r3, r3, r2
+1:
+#ifndef __thumb2__
+              /* Load the 'magic' constant 0x01010101.  */
+        str     r4, [sp, #-4]!
+        mov     r4, #1
+        orr     r4, r4, r4, lsl #8
+        orr     r4, r4, r4, lsl #16
+#endif
+        .p2align        2
+4:
+        optpld  r0, #8
+        optpld  r1, #8
+        sub     r2, ip, magic1(r4)
+        cmp     ip, r3
+        itttt   eq
+        /* check for any zero bytes in first word */
+        biceq   r2, r2, ip
+        tsteq   r2, magic2(r4)
+        ldreq   ip, [r0], #4
+        ldreq   r3, [r1], #4
+        beq     4b
+2:
+        /* There's a zero or a different byte in the word */
+        S2HIMEM  r0, ip, #24
+        S2LOMEM  ip, ip, #8
+        cmp     r0, #1
+        it      cs
+        cmpcs   r0, r3, S2HIMEM #24
+        it      eq
+        S2LOMEMEQ r3, r3, #8
+        beq     2b
+        /* On a big-endian machine, r0 contains the desired byte in bits
+        0-7; on a little-endian machine they are in bits 24-31.  In
+        both cases the other bits in r0 are all zero.  For r3 the
+        interesting byte is at the other end of the word, but the
+        other bits are not necessarily zero.  We need a signed result
+        representing the differnece in the unsigned bytes, so for the
+        little-endian case we can't just shift the interesting bits
+        up.  */
+#ifdef __ARMEB__
+        sub     r0, r0, r3, lsr #24
+#else
+        and     r3, r3, #255
+#ifdef __thumb2__
+        /* No RSB instruction in Thumb2 */
+        lsr     r0, r0, #24
+        sub     r0, r0, r3
+#else
+        rsb     r0, r3, r0, lsr #24
+#endif
+#endif
+#ifndef __thumb2__
+        ldr     r4, [sp], #4
+#endif
+        RETURN
+
+
+strcmp_unaligned:
+
+#if 0
+        /* The assembly code below is based on the following alogrithm.  */
+#ifdef __ARMEB__
+#define RSHIFT <<
+#define LSHIFT >>
+#else
+#define RSHIFT >>
+#define LSHIFT <<
+#endif
+
+#define body(shift)                         \
+  mask = 0xffffffffU RSHIFT shift;                  \
+  w1 = *wp1++;                              \
+  w2 = *wp2++;                              \
+  do                                    \
+    {                                   \
+      t1 = w1 & mask;                           \
+      if (__builtin_expect(t1 != w2 RSHIFT shift, 0))           \
+    {                               \
+      w2 RSHIFT= shift;                     \
+      break;                            \
+    }                               \
+      if (__builtin_expect(((w1 - b1) & ~w1) & (b1 << 7), 0))       \
+    {                               \
+      /* See comment in assembler below re syndrome on big-endian */\
+      if ((((w1 - b1) & ~w1) & (b1 << 7)) & mask)           \
+        w2 RSHIFT= shift;                       \
+      else                              \
+        {                               \
+          w2 = *wp2;                        \
+          t1 = w1 RSHIFT (32 - shift);              \
+          w2 = (w2 LSHIFT (32 - shift)) RSHIFT (32 - shift);    \
+        }                               \
+      break;                            \
+    }                               \
+      w2 = *wp2++;                          \
+      t1 ^= w1;                             \
+      if (__builtin_expect(t1 != w2 LSHIFT (32 - shift), 0))        \
+    {                               \
+      t1 = w1 >> (32 - shift);                  \
+      w2 = (w2 << (32 - shift)) RSHIFT (32 - shift);        \
+      break;                            \
+    }                               \
+      w1 = *wp1++;                          \
+    } while (1)
+
+  const unsigned* wp1;
+  const unsigned* wp2;
+  unsigned w1, w2;
+  unsigned mask;
+  unsigned shift;
+  unsigned b1 = 0x01010101;
+  char c1, c2;
+  unsigned t1;
+
+  while (((unsigned) s1) & 3)
+    {
+      c1 = *s1++;
+      c2 = *s2++;
+      if (c1 == 0 || c1 != c2)
+    return c1 - (int)c2;
+    }
+  wp1 = (unsigned*) (((unsigned)s1) & ~3);
+  wp2 = (unsigned*) (((unsigned)s2) & ~3);
+  t1 = ((unsigned) s2) & 3;
+  if (t1 == 1)
+    {
+      body(8);
+    }
+  else if (t1 == 2)
+    {
+      body(16);
+    }
+  else
+    {
+      body (24);
+    }
+
+  do
+    {
+#ifdef __ARMEB__
+      c1 = (char) t1 >> 24;
+      c2 = (char) w2 >> 24;
+#else /* not  __ARMEB__ */
+      c1 = (char) t1;
+      c2 = (char) w2;
+#endif /* not  __ARMEB__ */
+      t1 RSHIFT= 8;
+      w2 RSHIFT= 8;
+    } while (c1 != 0 && c1 == c2);
+  return c1 - c2;
+#endif /* 0 */
+
+
+        wp1 .req r0
+        wp2 .req r1
+        b1  .req r2
+        w1  .req r4
+        w2  .req r5
+        t1  .req ip
+        @ r3 is scratch
+
+        /* First of all, compare bytes until wp1(sp1) is word-aligned. */
+1:
+        tst     wp1, #3
+        beq     2f
+        ldrb    r2, [wp1], #1
+        ldrb    r3, [wp2], #1
+        cmp     r2, #1
+        it      cs
+        cmpcs   r2, r3
+        beq     1b
+        sub     r0, r2, r3
+        RETURN
+
+2:
+        str     r5, [sp, #-4]!
+        str     r4, [sp, #-4]!
+        //stmfd   sp!, {r4, r5}
+        mov     b1, #1
+        orr     b1, b1, b1, lsl #8
+        orr     b1, b1, b1, lsl #16
+
+        and     t1, wp2, #3
+        bic     wp2, wp2, #3
+        ldr     w1, [wp1], #4
+        ldr     w2, [wp2], #4
+        cmp     t1, #2
+        beq     2f
+        bhi     3f
+
+        /* Critical inner Loop: Block with 3 bytes initial overlap */
+        .p2align        2
+1:
+        bic     t1, w1, MSB
+        cmp     t1, w2, S2LOMEM #8
+        sub     r3, w1, b1
+        bic     r3, r3, w1
+        bne     4f
+        ands    r3, r3, b1, lsl #7
+        it      eq
+        ldreq   w2, [wp2], #4
+        bne     5f
+        eor     t1, t1, w1
+        cmp     t1, w2, S2HIMEM #24
+        bne     6f
+        ldr     w1, [wp1], #4
+        b       1b
+4:
+        S2LOMEM        w2, w2, #8
+        b       8f
+
+5:
+#ifdef __ARMEB__
+        /* The syndrome value may contain false ones if the string ends
+        with the bytes 0x01 0x00 */
+        tst     w1, #0xff000000
+        itt     ne
+        tstne   w1, #0x00ff0000
+        tstne   w1, #0x0000ff00
+        beq     7f
+#else
+        bics    r3, r3, #0xff000000
+        bne     7f
+#endif
+        ldrb    w2, [wp2]
+        S2LOMEM  t1, w1, #24
+#ifdef __ARMEB__
+        lsl     w2, w2, #24
+#endif
+        b       8f
+
+6:
+        S2LOMEM  t1, w1, #24
+        and     w2, w2, LSB
+        b       8f
+
+        /* Critical inner Loop: Block with 2 bytes initial overlap */
+        .p2align        2
+2:
+        S2HIMEM  t1, w1, #16
+        sub     r3, w1, b1
+        S2LOMEM  t1, t1, #16
+        bic     r3, r3, w1
+        cmp     t1, w2, S2LOMEM #16
+        bne     4f
+        ands    r3, r3, b1, lsl #7
+        it      eq
+        ldreq   w2, [wp2], #4
+        bne     5f
+        eor     t1, t1, w1
+        cmp     t1, w2, S2HIMEM #16
+        bne     6f
+        ldr     w1, [wp1], #4
+        b       2b
+
+5:
+#ifdef __ARMEB__
+        /* The syndrome value may contain false ones if the string ends
+        with the bytes 0x01 0x00 */
+        tst     w1, #0xff000000
+        it      ne
+        tstne   w1, #0x00ff0000
+        beq     7f
+#else
+        lsls    r3, r3, #16
+        bne     7f
+#endif
+        ldrh    w2, [wp2]
+        S2LOMEM  t1, w1, #16
+#ifdef __ARMEB__
+        lsl     w2, w2, #16
+#endif
+        b       8f
+
+6:
+        S2HIMEM  w2, w2, #16
+        S2LOMEM  t1, w1, #16
+4:
+        S2LOMEM  w2, w2, #16
+        b       8f
+
+        /* Critical inner Loop: Block with 1 byte initial overlap */
+        .p2align        2
+3:
+        and     t1, w1, LSB
+        cmp     t1, w2, S2LOMEM #24
+        sub     r3, w1, b1
+        bic     r3, r3, w1
+        bne     4f
+        ands    r3, r3, b1, lsl #7
+        it      eq
+        ldreq   w2, [wp2], #4
+        bne     5f
+        eor     t1, t1, w1
+        cmp     t1, w2, S2HIMEM #8
+        bne     6f
+        ldr     w1, [wp1], #4
+        b       3b
+4:
+        S2LOMEM  w2, w2, #24
+        b       8f
+5:
+        /* The syndrome value may contain false ones if the string ends
+        with the bytes 0x01 0x00 */
+        tst     w1, LSB
+        beq     7f
+        ldr     w2, [wp2], #4
+6:
+        S2LOMEM  t1, w1, #8
+        bic     w2, w2, MSB
+        b       8f
+7:
+        mov     r0, #0
+        //ldmfd   sp!, {r4, r5}
+        ldr     r4, [sp], #4
+        ldr     r5, [sp], #4
+        RETURN
+8:
+        and     r2, t1, LSB
+        and     r0, w2, LSB
+        cmp     r0, #1
+        it      cs
+        cmpcs   r0, r2
+        itt     eq
+        S2LOMEMEQ        t1, t1, #8
+        S2LOMEMEQ        w2, w2, #8
+        beq     8b
+        sub     r0, r2, r0
+        //ldmfd   sp!, {r4, r5}
+        ldr     r4, [sp], #4
+        ldr     r5, [sp], #4
+        RETURN
+
+#endif /* !(defined (_ISA_THUMB_2) || defined (_ISA_ARM_6)
+            defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED) ||
+            (defined (__thumb__) && !defined (__thumb2__))) */
diff --git a/libc/arch-arm/bionic/syscall.S b/libc/arch-arm/bionic/syscall.S
index ada12a6..69f3bec 100644
--- a/libc/arch-arm/bionic/syscall.S
+++ b/libc/arch-arm/bionic/syscall.S
@@ -25,47 +25,21 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-
-	.text
-	.align 4
-	.type syscall,#function
-	.globl syscall
- 
-	.text
-	.align
-
-#if __ARM_EABI__
-
-syscall:
+ENTRY(syscall)
     mov     ip, sp
-    stmfd	sp!, {r4, r5, r6, r7}
+    stmfd   sp!, {r4, r5, r6, r7}
     mov     r7, r0
     mov     r0, r1
     mov     r1, r2
     mov     r2, r3
-    ldmfd	ip, {r3, r4, r5, r6}
+    ldmfd   ip, {r3, r4, r5, r6}
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-
-#else
-
-#ifndef __NR_syscall
-#define __NR_syscall    113
-#endif
-
-syscall:
-    stmfd   sp!, {r4, r5, lr}
-    ldr     r4, [sp, #12]
-    ldr     r5, [sp, #16]
-    swi     __NR_syscall
-    ldmfd   sp!, {r4, r5, lr}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
-
-#endif
+END(syscall)
diff --git a/libc/arch-arm/include/endian.h b/libc/arch-arm/include/endian.h
deleted file mode 100644
index 6de0889..0000000
--- a/libc/arch-arm/include/endian.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*	$OpenBSD: endian.h,v 1.3 2005/12/13 00:35:23 millert Exp $	*/
-
-/*
- * Copyright (C) 2010 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _ARM_ENDIAN_H_
-#define _ARM_ENDIAN_H_
-
-#ifdef __GNUC__
-
-/*
- * REV and REV16 weren't available on ARM5 or ARM4.
- * We don't include <machine/cpu-features.h> because it pollutes the
- * namespace with macros like PLD.
- */
-#if !defined __ARM_ARCH_5__ && !defined __ARM_ARCH_5T__ && \
-    !defined __ARM_ARCH_5TE__ && !defined __ARM_ARCH_5TEJ__ && \
-    !defined __ARM_ARCH_4T__ && !defined __ARM_ARCH_4__
-
-/* According to RealView Assembler User's Guide, REV and REV16 are available
- * in Thumb code and 16-bit instructions when used in Thumb-2 code.
- *
- * REV Rd, Rm
- *   Rd and Rm must both be Lo registers.
- *
- * REV16 Rd, Rm
- *   Rd and Rm must both be Lo registers.
- *
- * The +l constraint takes care of this without constraining us in ARM mode.
- */
-#define __swap16md(x) ({                                        \
-    register u_int16_t _x = (x);                                \
-    __asm volatile ("rev16 %0, %0" : "+l" (_x));                \
-    _x;                                                         \
-})
-
-#define __swap32md(x) ({                                        \
-    register u_int32_t _x = (x);                                \
-    __asm volatile ("rev %0, %0" : "+l" (_x));                  \
-    _x;                                                         \
-})
-
-#define __swap64md(x) ({                                        \
-    u_int64_t _swap64md_x = (x);                                \
-    (u_int64_t) __swap32md(_swap64md_x >> 32) |                 \
-        (u_int64_t) __swap32md(_swap64md_x & 0xffffffff) << 32; \
-})
-
-/* Tell sys/endian.h we have MD variants of the swap macros.  */
-#define MD_SWAP
-
-#endif  /* __ARM_ARCH__ */
-#endif  /* __GNUC__ */
-
-#ifdef __ARMEB__
-#define _BYTE_ORDER _BIG_ENDIAN
-#else
-#define _BYTE_ORDER _LITTLE_ENDIAN
-#endif
-#define __STRICT_ALIGNMENT
-#include <sys/types.h>
-#include <sys/endian.h>
-
-#endif  /* !_ARM_ENDIAN_H_ */
diff --git a/libc/arch-arm/include/machine/_types.h b/libc/arch-arm/include/machine/_types.h
index 3e779ca..0a8b610 100644
--- a/libc/arch-arm/include/machine/_types.h
+++ b/libc/arch-arm/include/machine/_types.h
@@ -35,17 +35,6 @@
 #ifndef _ARM__TYPES_H_
 #define _ARM__TYPES_H_
 
-
-#if !defined(__ARM_EABI__)
-/* the kernel defines size_t as unsigned int, but g++ wants it to be unsigned long */
-#define _SIZE_T
-#define _SSIZE_T
-#define _PTRDIFF_T
-typedef unsigned long  size_t;
-typedef long           ssize_t;
-typedef long           ptrdiff_t;
-#endif
-
 /* 7.18.1.1 Exact-width integer types */
 typedef	__signed char		__int8_t;
 typedef	unsigned char		__uint8_t;
@@ -98,6 +87,8 @@
 /* Standard system types */
 typedef int			__clock_t;
 typedef int			__clockid_t;
+typedef double			__double_t;
+typedef float			__float_t;
 typedef long			__ptrdiff_t;
 typedef	int			__time_t;
 typedef int			__timer_t;
@@ -116,10 +107,4 @@
 typedef	void *			__wctrans_t;
 typedef	void *			__wctype_t;
 
-#ifdef __ARMEB__
-#define _BYTE_ORDER _BIG_ENDIAN
-#else
-#define _BYTE_ORDER _LITTLE_ENDIAN
-#endif
-
 #endif	/* _ARM__TYPES_H_ */
diff --git a/libc/arch-arm/include/machine/elf_machdep.h b/libc/arch-arm/include/machine/elf_machdep.h
new file mode 100644
index 0000000..97d8434
--- /dev/null
+++ b/libc/arch-arm/include/machine/elf_machdep.h
@@ -0,0 +1,138 @@
+/*	$NetBSD: elf_machdep.h,v 1.10 2012/08/05 04:12:46 matt Exp $	*/
+
+#ifndef _ARM_ELF_MACHDEP_H_
+#define _ARM_ELF_MACHDEP_H_
+
+#if defined(__ARMEB__)
+#define ELF32_MACHDEP_ENDIANNESS	ELFDATA2MSB
+#else
+#define ELF32_MACHDEP_ENDIANNESS	ELFDATA2LSB
+#endif
+
+#define ELF64_MACHDEP_ENDIANNESS	XXX	/* break compilation */
+#define ELF64_MACHDEP_ID_CASES                                          \
+		/* no 64-bit ELF machine types supported */
+
+/* Processor specific flags for the ELF header e_flags field.  */
+#define EF_ARM_RELEXEC		0x00000001
+#define EF_ARM_HASENTRY		0x00000002
+#define EF_ARM_INTERWORK	0x00000004 /* GNU binutils 000413 */
+#define EF_ARM_SYMSARESORTED	0x00000004 /* ARM ELF A08 */
+#define EF_ARM_APCS_26		0x00000008 /* GNU binutils 000413 */
+#define EF_ARM_DYNSYMSUSESEGIDX	0x00000008 /* ARM ELF B01 */
+#define EF_ARM_APCS_FLOAT	0x00000010 /* GNU binutils 000413 */
+#define EF_ARM_MAPSYMSFIRST	0x00000010 /* ARM ELF B01 */
+#define EF_ARM_PIC		0x00000020
+#define EF_ARM_ALIGN8		0x00000040 /* 8-bit structure alignment.  */
+#define EF_ARM_NEW_ABI		0x00000080
+#define EF_ARM_OLD_ABI		0x00000100
+#define EF_ARM_SOFT_FLOAT	0x00000200
+#define EF_ARM_EABIMASK		0xff000000
+#define	EF_ARM_EABI_VER1	0x01000000
+#define	EF_ARM_EABI_VER2	0x02000000
+#define	EF_ARM_EABI_VER3	0x03000000
+#define	EF_ARM_EABI_VER4	0x04000000
+#define	EF_ARM_EABI_VER5	0x05000000
+
+#define	ELF32_MACHDEP_ID_CASES						\
+		case EM_ARM:						\
+			break;
+
+#define	ELF32_MACHDEP_ID	EM_ARM
+
+#define ARCH_ELFSIZE		32	/* MD native binary size */
+
+/* Processor specific relocation types */
+
+#define R_ARM_NONE		0
+#define R_ARM_PC24		1
+#define R_ARM_ABS32		2
+#define R_ARM_REL32		3
+#define R_ARM_PC13		4
+#define R_ARM_ABS16		5
+#define R_ARM_ABS12		6
+#define R_ARM_THM_ABS5		7
+#define R_ARM_ABS8		8
+#define R_ARM_SBREL32		9
+#define R_ARM_THM_PC22		10
+#define R_ARM_THM_PC8		11
+#define R_ARM_AMP_VCALL9	12
+#define R_ARM_SWI24		13
+#define R_ARM_THM_SWI8		14
+#define R_ARM_XPC25		15
+#define R_ARM_THM_XPC22		16
+
+/* TLS relocations */
+#define R_ARM_TLS_DTPMOD32	17	/* ID of module containing symbol */
+#define R_ARM_TLS_DTPOFF32	18	/* Offset in TLS block */
+#define R_ARM_TLS_TPOFF32	19	/* Offset in static TLS block */
+
+/* 20-31 are reserved for ARM Linux. */
+#define R_ARM_COPY		20
+#define R_ARM_GLOB_DAT		21
+#define	R_ARM_JUMP_SLOT		22
+#define R_ARM_RELATIVE		23
+#define	R_ARM_GOTOFF		24
+#define R_ARM_GOTPC		25
+#define R_ARM_GOT32		26
+#define R_ARM_PLT32		27
+
+#define R_ARM_ALU_PCREL_7_0	32
+#define R_ARM_ALU_PCREL_15_8	33
+#define R_ARM_ALU_PCREL_23_15	34
+#define R_ARM_ALU_SBREL_11_0	35
+#define R_ARM_ALU_SBREL_19_12	36
+#define R_ARM_ALU_SBREL_27_20	37
+
+/* 96-111 are reserved to G++. */
+#define R_ARM_GNU_VTENTRY	100
+#define R_ARM_GNU_VTINHERIT	101
+#define R_ARM_THM_PC11		102
+#define R_ARM_THM_PC9		103
+
+/* More TLS relocations */
+#define R_ARM_TLS_GD32		104	/* PC-rel 32 bit for global dynamic */
+#define R_ARM_TLS_LDM32		105	/* PC-rel 32 bit for local dynamic */
+#define R_ARM_TLS_LDO32		106	/* 32 bit offset relative to TLS */
+#define R_ARM_TLS_IE32		107	/* PC-rel 32 bit for GOT entry of */
+#define R_ARM_TLS_LE32		108
+#define R_ARM_TLS_LDO12		109
+#define R_ARM_TLS_LE12		110
+#define R_ARM_TLS_IE12GP	111
+
+/* 112-127 are reserved for private experiments. */
+
+#define R_ARM_RXPC25		249
+#define R_ARM_RSBREL32		250
+#define R_ARM_THM_RPC22		251
+#define R_ARM_RREL32		252
+#define R_ARM_RABS32		253
+#define R_ARM_RPC24		254
+#define R_ARM_RBASE		255
+
+#define R_TYPE(name)		__CONCAT(R_ARM_,name)
+
+/* Processor specific program header flags */
+#define PF_ARM_SB		0x10000000
+#define PF_ARM_PI		0x20000000
+#define PF_ARM_ENTRY		0x80000000
+
+/* Processor specific section header flags */
+#define SHF_ENTRYSECT		0x10000000
+#define SHF_COMDEF		0x80000000
+
+/* Processor specific symbol types */
+#define STT_ARM_TFUNC		STT_LOPROC
+
+#ifdef _KERNEL
+#ifdef ELFSIZE
+#define	ELF_MD_PROBE_FUNC	ELFNAME2(arm_netbsd,probe)
+#endif
+
+struct exec_package;
+
+int arm_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *,
+	vaddr_t *);
+#endif
+
+#endif /* _ARM_ELF_MACHDEP_H_ */
diff --git a/libc/arch-arm/include/machine/endian.h b/libc/arch-arm/include/machine/endian.h
new file mode 100644
index 0000000..7cba3b9
--- /dev/null
+++ b/libc/arch-arm/include/machine/endian.h
@@ -0,0 +1,89 @@
+/*	$OpenBSD: endian.h,v 1.3 2005/12/13 00:35:23 millert Exp $	*/
+
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARM_ENDIAN_H_
+#define _ARM_ENDIAN_H_
+
+#ifdef __GNUC__
+
+/*
+ * REV and REV16 weren't available on ARM5 or ARM4.
+ * We don't include <machine/cpu-features.h> because it pollutes the
+ * namespace with macros like PLD.
+ */
+#if !defined __ARM_ARCH_5__ && !defined __ARM_ARCH_5T__ && \
+    !defined __ARM_ARCH_5TE__ && !defined __ARM_ARCH_5TEJ__ && \
+    !defined __ARM_ARCH_4T__ && !defined __ARM_ARCH_4__
+
+/* According to RealView Assembler User's Guide, REV and REV16 are available
+ * in Thumb code and 16-bit instructions when used in Thumb-2 code.
+ *
+ * REV Rd, Rm
+ *   Rd and Rm must both be Lo registers.
+ *
+ * REV16 Rd, Rm
+ *   Rd and Rm must both be Lo registers.
+ *
+ * The +l constraint takes care of this without constraining us in ARM mode.
+ */
+#define __swap16md(x) ({                                        \
+    register u_int16_t _x = (x);                                \
+    __asm volatile ("rev16 %0, %0" : "+l" (_x));                \
+    _x;                                                         \
+})
+
+#define __swap32md(x) ({                                        \
+    register u_int32_t _x = (x);                                \
+    __asm volatile ("rev %0, %0" : "+l" (_x));                  \
+    _x;                                                         \
+})
+
+#define __swap64md(x) ({                                        \
+    u_int64_t _swap64md_x = (x);                                \
+    (u_int64_t) __swap32md(_swap64md_x >> 32) |                 \
+        (u_int64_t) __swap32md(_swap64md_x & 0xffffffff) << 32; \
+})
+
+/* Tell sys/endian.h we have MD variants of the swap macros.  */
+#define MD_SWAP
+
+#endif  /* __ARM_ARCH__ */
+#endif  /* __GNUC__ */
+
+#if defined(__ARMEB__)
+#define _BYTE_ORDER _BIG_ENDIAN
+#else
+#define _BYTE_ORDER _LITTLE_ENDIAN
+#endif
+#define __STRICT_ALIGNMENT
+#include <sys/types.h>
+#include <sys/endian.h>
+
+#endif  /* !_ARM_ENDIAN_H_ */
diff --git a/libc/arch-arm/syscalls.mk b/libc/arch-arm/syscalls.mk
index 62eda87..5cb46b5 100644
--- a/libc/arch-arm/syscalls.mk
+++ b/libc/arch-arm/syscalls.mk
@@ -150,6 +150,7 @@
 syscall_src += arch-arm/syscalls/__rt_sigprocmask.S
 syscall_src += arch-arm/syscalls/__rt_sigtimedwait.S
 syscall_src += arch-arm/syscalls/sigpending.S
+syscall_src += arch-arm/syscalls/signalfd4.S
 syscall_src += arch-arm/syscalls/socket.S
 syscall_src += arch-arm/syscalls/socketpair.S
 syscall_src += arch-arm/syscalls/bind.S
diff --git a/libc/arch-arm/syscalls/__brk.S b/libc/arch-arm/syscalls/__brk.S
index a0854a0..e4fcab0 100644
--- a/libc/arch-arm/syscalls/__brk.S
+++ b/libc/arch-arm/syscalls/__brk.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__brk)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_brk
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__fcntl.S b/libc/arch-arm/syscalls/__fcntl.S
index 067ee9a..ee82ef1 100644
--- a/libc/arch-arm/syscalls/__fcntl.S
+++ b/libc/arch-arm/syscalls/__fcntl.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__fcntl)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_fcntl
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__fcntl64.S b/libc/arch-arm/syscalls/__fcntl64.S
index 3d39567..96cc16b 100644
--- a/libc/arch-arm/syscalls/__fcntl64.S
+++ b/libc/arch-arm/syscalls/__fcntl64.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__fcntl64)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_fcntl64
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__fork.S b/libc/arch-arm/syscalls/__fork.S
index 6cf08ad..9df9702 100644
--- a/libc/arch-arm/syscalls/__fork.S
+++ b/libc/arch-arm/syscalls/__fork.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__fork)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_fork
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__fstatfs64.S b/libc/arch-arm/syscalls/__fstatfs64.S
index e8aa2f4..6e90214 100644
--- a/libc/arch-arm/syscalls/__fstatfs64.S
+++ b/libc/arch-arm/syscalls/__fstatfs64.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__fstatfs64)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_fstatfs64
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__getcpu.S b/libc/arch-arm/syscalls/__getcpu.S
index 78271eb..7976b06 100644
--- a/libc/arch-arm/syscalls/__getcpu.S
+++ b/libc/arch-arm/syscalls/__getcpu.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__getcpu)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_getcpu
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__getcwd.S b/libc/arch-arm/syscalls/__getcwd.S
index e09a484..6fc2d64 100644
--- a/libc/arch-arm/syscalls/__getcwd.S
+++ b/libc/arch-arm/syscalls/__getcwd.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__getcwd)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_getcwd
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__getpriority.S b/libc/arch-arm/syscalls/__getpriority.S
index 30e335c..6fb2a43 100644
--- a/libc/arch-arm/syscalls/__getpriority.S
+++ b/libc/arch-arm/syscalls/__getpriority.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__getpriority)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_getpriority
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__ioctl.S b/libc/arch-arm/syscalls/__ioctl.S
index 554809f..56fd607 100644
--- a/libc/arch-arm/syscalls/__ioctl.S
+++ b/libc/arch-arm/syscalls/__ioctl.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__ioctl)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_ioctl
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__open.S b/libc/arch-arm/syscalls/__open.S
index be2f4bf..589d5ad 100644
--- a/libc/arch-arm/syscalls/__open.S
+++ b/libc/arch-arm/syscalls/__open.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__open)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_open
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__openat.S b/libc/arch-arm/syscalls/__openat.S
index 4d91780..10c30d3 100644
--- a/libc/arch-arm/syscalls/__openat.S
+++ b/libc/arch-arm/syscalls/__openat.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__openat)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_openat
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__ptrace.S b/libc/arch-arm/syscalls/__ptrace.S
index 04e0a30..72acd70 100644
--- a/libc/arch-arm/syscalls/__ptrace.S
+++ b/libc/arch-arm/syscalls/__ptrace.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__ptrace)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_ptrace
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__reboot.S b/libc/arch-arm/syscalls/__reboot.S
index e75df45..07898a0 100644
--- a/libc/arch-arm/syscalls/__reboot.S
+++ b/libc/arch-arm/syscalls/__reboot.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__reboot)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_reboot
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__rt_sigaction.S b/libc/arch-arm/syscalls/__rt_sigaction.S
index 57a3149..31d4c1e 100644
--- a/libc/arch-arm/syscalls/__rt_sigaction.S
+++ b/libc/arch-arm/syscalls/__rt_sigaction.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__rt_sigaction)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_rt_sigaction
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__rt_sigprocmask.S b/libc/arch-arm/syscalls/__rt_sigprocmask.S
index 8220825..640a7ee 100644
--- a/libc/arch-arm/syscalls/__rt_sigprocmask.S
+++ b/libc/arch-arm/syscalls/__rt_sigprocmask.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__rt_sigprocmask)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_rt_sigprocmask
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__rt_sigtimedwait.S b/libc/arch-arm/syscalls/__rt_sigtimedwait.S
index bce63ed..ad725af 100644
--- a/libc/arch-arm/syscalls/__rt_sigtimedwait.S
+++ b/libc/arch-arm/syscalls/__rt_sigtimedwait.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__rt_sigtimedwait)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_rt_sigtimedwait
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__sched_getaffinity.S b/libc/arch-arm/syscalls/__sched_getaffinity.S
index bdd4517..bee1674 100644
--- a/libc/arch-arm/syscalls/__sched_getaffinity.S
+++ b/libc/arch-arm/syscalls/__sched_getaffinity.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__sched_getaffinity)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_sched_getaffinity
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__set_tls.S b/libc/arch-arm/syscalls/__set_tls.S
index cf5d6b6..3039b35 100644
--- a/libc/arch-arm/syscalls/__set_tls.S
+++ b/libc/arch-arm/syscalls/__set_tls.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__set_tls)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_ARM_set_tls
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__setresuid.S b/libc/arch-arm/syscalls/__setresuid.S
index d5053ba..1877bbf 100644
--- a/libc/arch-arm/syscalls/__setresuid.S
+++ b/libc/arch-arm/syscalls/__setresuid.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__setresuid)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_setresuid32
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__setreuid.S b/libc/arch-arm/syscalls/__setreuid.S
index 9cd51f6..2129cb2 100644
--- a/libc/arch-arm/syscalls/__setreuid.S
+++ b/libc/arch-arm/syscalls/__setreuid.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__setreuid)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_setreuid32
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__setuid.S b/libc/arch-arm/syscalls/__setuid.S
index 88dc58e..9df2f89 100644
--- a/libc/arch-arm/syscalls/__setuid.S
+++ b/libc/arch-arm/syscalls/__setuid.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__setuid)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_setuid32
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__sigsuspend.S b/libc/arch-arm/syscalls/__sigsuspend.S
index 1ececb7..8f1ff55 100644
--- a/libc/arch-arm/syscalls/__sigsuspend.S
+++ b/libc/arch-arm/syscalls/__sigsuspend.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__sigsuspend)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_sigsuspend
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__statfs64.S b/libc/arch-arm/syscalls/__statfs64.S
index 4afef71..f8d63a3 100644
--- a/libc/arch-arm/syscalls/__statfs64.S
+++ b/libc/arch-arm/syscalls/__statfs64.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__statfs64)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_statfs64
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__syslog.S b/libc/arch-arm/syscalls/__syslog.S
index 6dbe745..8ad0271 100644
--- a/libc/arch-arm/syscalls/__syslog.S
+++ b/libc/arch-arm/syscalls/__syslog.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__syslog)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_syslog
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__timer_create.S b/libc/arch-arm/syscalls/__timer_create.S
index c547137..fcb4e3f 100644
--- a/libc/arch-arm/syscalls/__timer_create.S
+++ b/libc/arch-arm/syscalls/__timer_create.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__timer_create)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_timer_create
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__timer_delete.S b/libc/arch-arm/syscalls/__timer_delete.S
index ca2e0a3..de303fc 100644
--- a/libc/arch-arm/syscalls/__timer_delete.S
+++ b/libc/arch-arm/syscalls/__timer_delete.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__timer_delete)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_timer_delete
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__timer_getoverrun.S b/libc/arch-arm/syscalls/__timer_getoverrun.S
index b0f18e7..a96b047 100644
--- a/libc/arch-arm/syscalls/__timer_getoverrun.S
+++ b/libc/arch-arm/syscalls/__timer_getoverrun.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__timer_getoverrun)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_timer_getoverrun
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__timer_gettime.S b/libc/arch-arm/syscalls/__timer_gettime.S
index c172602..6e6bbf5 100644
--- a/libc/arch-arm/syscalls/__timer_gettime.S
+++ b/libc/arch-arm/syscalls/__timer_gettime.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__timer_gettime)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_timer_gettime
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__timer_settime.S b/libc/arch-arm/syscalls/__timer_settime.S
index 8220440..bcbe298 100644
--- a/libc/arch-arm/syscalls/__timer_settime.S
+++ b/libc/arch-arm/syscalls/__timer_settime.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__timer_settime)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_timer_settime
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/__wait4.S b/libc/arch-arm/syscalls/__wait4.S
index fa34502..2a0e5c4 100644
--- a/libc/arch-arm/syscalls/__wait4.S
+++ b/libc/arch-arm/syscalls/__wait4.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(__wait4)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_wait4
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/_exit.S b/libc/arch-arm/syscalls/_exit.S
index 77487b5..ab444ce 100644
--- a/libc/arch-arm/syscalls/_exit.S
+++ b/libc/arch-arm/syscalls/_exit.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(_exit)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_exit_group
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/_exit_thread.S b/libc/arch-arm/syscalls/_exit_thread.S
index bd16ff1..53a21fb 100644
--- a/libc/arch-arm/syscalls/_exit_thread.S
+++ b/libc/arch-arm/syscalls/_exit_thread.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(_exit_thread)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_exit
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/accept.S b/libc/arch-arm/syscalls/accept.S
index 0dcfb0c..b1a2d72 100644
--- a/libc/arch-arm/syscalls/accept.S
+++ b/libc/arch-arm/syscalls/accept.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(accept)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_accept
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/access.S b/libc/arch-arm/syscalls/access.S
index cf585a3..c0b0333 100644
--- a/libc/arch-arm/syscalls/access.S
+++ b/libc/arch-arm/syscalls/access.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(access)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_access
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/acct.S b/libc/arch-arm/syscalls/acct.S
index 85346e4..5485be1 100644
--- a/libc/arch-arm/syscalls/acct.S
+++ b/libc/arch-arm/syscalls/acct.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(acct)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_acct
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/bind.S b/libc/arch-arm/syscalls/bind.S
index 85d0471..1bb5843 100644
--- a/libc/arch-arm/syscalls/bind.S
+++ b/libc/arch-arm/syscalls/bind.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(bind)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_bind
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/cacheflush.S b/libc/arch-arm/syscalls/cacheflush.S
index 05b2411..fd7f68d 100644
--- a/libc/arch-arm/syscalls/cacheflush.S
+++ b/libc/arch-arm/syscalls/cacheflush.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(cacheflush)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_ARM_cacheflush
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/capget.S b/libc/arch-arm/syscalls/capget.S
index 0f3ba31..1f425a0 100644
--- a/libc/arch-arm/syscalls/capget.S
+++ b/libc/arch-arm/syscalls/capget.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(capget)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_capget
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/capset.S b/libc/arch-arm/syscalls/capset.S
index 2254db2..13ebd5a 100644
--- a/libc/arch-arm/syscalls/capset.S
+++ b/libc/arch-arm/syscalls/capset.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(capset)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_capset
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/chdir.S b/libc/arch-arm/syscalls/chdir.S
index 57d6b13..4965495 100644
--- a/libc/arch-arm/syscalls/chdir.S
+++ b/libc/arch-arm/syscalls/chdir.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(chdir)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_chdir
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/chmod.S b/libc/arch-arm/syscalls/chmod.S
index 8909c6f..ed9d52f 100644
--- a/libc/arch-arm/syscalls/chmod.S
+++ b/libc/arch-arm/syscalls/chmod.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(chmod)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_chmod
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/chown.S b/libc/arch-arm/syscalls/chown.S
index cbbd8a8..ff1cec2 100644
--- a/libc/arch-arm/syscalls/chown.S
+++ b/libc/arch-arm/syscalls/chown.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(chown)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_chown32
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/chroot.S b/libc/arch-arm/syscalls/chroot.S
index a679172..bc8e3fe 100644
--- a/libc/arch-arm/syscalls/chroot.S
+++ b/libc/arch-arm/syscalls/chroot.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(chroot)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_chroot
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/clock_getres.S b/libc/arch-arm/syscalls/clock_getres.S
index 705f296..66cf9ec 100644
--- a/libc/arch-arm/syscalls/clock_getres.S
+++ b/libc/arch-arm/syscalls/clock_getres.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(clock_getres)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_clock_getres
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/clock_gettime.S b/libc/arch-arm/syscalls/clock_gettime.S
index a9ab41f..4e42c82 100644
--- a/libc/arch-arm/syscalls/clock_gettime.S
+++ b/libc/arch-arm/syscalls/clock_gettime.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(clock_gettime)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_clock_gettime
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/clock_nanosleep.S b/libc/arch-arm/syscalls/clock_nanosleep.S
index f8e7f73..6d530a2 100644
--- a/libc/arch-arm/syscalls/clock_nanosleep.S
+++ b/libc/arch-arm/syscalls/clock_nanosleep.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(clock_nanosleep)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_clock_nanosleep
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/clock_settime.S b/libc/arch-arm/syscalls/clock_settime.S
index a996441..e9374b5 100644
--- a/libc/arch-arm/syscalls/clock_settime.S
+++ b/libc/arch-arm/syscalls/clock_settime.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(clock_settime)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_clock_settime
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/close.S b/libc/arch-arm/syscalls/close.S
index 36d78a4..eb4cb62 100644
--- a/libc/arch-arm/syscalls/close.S
+++ b/libc/arch-arm/syscalls/close.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(close)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_close
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/connect.S b/libc/arch-arm/syscalls/connect.S
index ea14c17..b97b4fe 100644
--- a/libc/arch-arm/syscalls/connect.S
+++ b/libc/arch-arm/syscalls/connect.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(connect)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_connect
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/delete_module.S b/libc/arch-arm/syscalls/delete_module.S
index df8aae0..0994994 100644
--- a/libc/arch-arm/syscalls/delete_module.S
+++ b/libc/arch-arm/syscalls/delete_module.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(delete_module)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_delete_module
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/dup.S b/libc/arch-arm/syscalls/dup.S
index b0c1cda..8854342 100644
--- a/libc/arch-arm/syscalls/dup.S
+++ b/libc/arch-arm/syscalls/dup.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(dup)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_dup
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/dup2.S b/libc/arch-arm/syscalls/dup2.S
index ed346d9..0dcc57f 100644
--- a/libc/arch-arm/syscalls/dup2.S
+++ b/libc/arch-arm/syscalls/dup2.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(dup2)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_dup2
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/epoll_create.S b/libc/arch-arm/syscalls/epoll_create.S
index 1aab606..92a2781 100644
--- a/libc/arch-arm/syscalls/epoll_create.S
+++ b/libc/arch-arm/syscalls/epoll_create.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(epoll_create)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_epoll_create
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/epoll_ctl.S b/libc/arch-arm/syscalls/epoll_ctl.S
index c0ecf06..b3c630f 100644
--- a/libc/arch-arm/syscalls/epoll_ctl.S
+++ b/libc/arch-arm/syscalls/epoll_ctl.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(epoll_ctl)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_epoll_ctl
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/epoll_wait.S b/libc/arch-arm/syscalls/epoll_wait.S
index 3535001..3ccac91 100644
--- a/libc/arch-arm/syscalls/epoll_wait.S
+++ b/libc/arch-arm/syscalls/epoll_wait.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(epoll_wait)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_epoll_wait
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/eventfd.S b/libc/arch-arm/syscalls/eventfd.S
index 857b6c0..754f019 100644
--- a/libc/arch-arm/syscalls/eventfd.S
+++ b/libc/arch-arm/syscalls/eventfd.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(eventfd)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_eventfd2
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/execve.S b/libc/arch-arm/syscalls/execve.S
index 1a66167..49e5b13 100644
--- a/libc/arch-arm/syscalls/execve.S
+++ b/libc/arch-arm/syscalls/execve.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(execve)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_execve
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/faccessat.S b/libc/arch-arm/syscalls/faccessat.S
index a2f176f..5ade517 100644
--- a/libc/arch-arm/syscalls/faccessat.S
+++ b/libc/arch-arm/syscalls/faccessat.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(faccessat)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_faccessat
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/fchdir.S b/libc/arch-arm/syscalls/fchdir.S
index 7d80cf0..96a047d 100644
--- a/libc/arch-arm/syscalls/fchdir.S
+++ b/libc/arch-arm/syscalls/fchdir.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(fchdir)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_fchdir
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/fchmod.S b/libc/arch-arm/syscalls/fchmod.S
index bc8e643..b096a8c 100644
--- a/libc/arch-arm/syscalls/fchmod.S
+++ b/libc/arch-arm/syscalls/fchmod.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(fchmod)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_fchmod
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/fchmodat.S b/libc/arch-arm/syscalls/fchmodat.S
index ac782e5..8c87598 100644
--- a/libc/arch-arm/syscalls/fchmodat.S
+++ b/libc/arch-arm/syscalls/fchmodat.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(fchmodat)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_fchmodat
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/fchown.S b/libc/arch-arm/syscalls/fchown.S
index 22d7fd2..2f7e92b 100644
--- a/libc/arch-arm/syscalls/fchown.S
+++ b/libc/arch-arm/syscalls/fchown.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(fchown)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_fchown32
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/fdatasync.S b/libc/arch-arm/syscalls/fdatasync.S
index d41e823..31818c8 100644
--- a/libc/arch-arm/syscalls/fdatasync.S
+++ b/libc/arch-arm/syscalls/fdatasync.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(fdatasync)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_fdatasync
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/fgetxattr.S b/libc/arch-arm/syscalls/fgetxattr.S
index 32b8ef8..6f3eb3d 100644
--- a/libc/arch-arm/syscalls/fgetxattr.S
+++ b/libc/arch-arm/syscalls/fgetxattr.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(fgetxattr)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_fgetxattr
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/flistxattr.S b/libc/arch-arm/syscalls/flistxattr.S
index 0785e77..38e856d 100644
--- a/libc/arch-arm/syscalls/flistxattr.S
+++ b/libc/arch-arm/syscalls/flistxattr.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(flistxattr)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_flistxattr
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/flock.S b/libc/arch-arm/syscalls/flock.S
index c0d2844..3732bfe 100644
--- a/libc/arch-arm/syscalls/flock.S
+++ b/libc/arch-arm/syscalls/flock.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(flock)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_flock
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/fremovexattr.S b/libc/arch-arm/syscalls/fremovexattr.S
index ae97d13..45cf803 100644
--- a/libc/arch-arm/syscalls/fremovexattr.S
+++ b/libc/arch-arm/syscalls/fremovexattr.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(fremovexattr)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_fremovexattr
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/fstat.S b/libc/arch-arm/syscalls/fstat.S
index e75649f..d314213 100644
--- a/libc/arch-arm/syscalls/fstat.S
+++ b/libc/arch-arm/syscalls/fstat.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(fstat)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_fstat64
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/fstatat.S b/libc/arch-arm/syscalls/fstatat.S
index 065ef9f..8cf1a57 100644
--- a/libc/arch-arm/syscalls/fstatat.S
+++ b/libc/arch-arm/syscalls/fstatat.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(fstatat)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_fstatat64
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/fsync.S b/libc/arch-arm/syscalls/fsync.S
index f0de9ca..52cfa53 100644
--- a/libc/arch-arm/syscalls/fsync.S
+++ b/libc/arch-arm/syscalls/fsync.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(fsync)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_fsync
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/ftruncate.S b/libc/arch-arm/syscalls/ftruncate.S
index 2e4a308..14cd87d 100644
--- a/libc/arch-arm/syscalls/ftruncate.S
+++ b/libc/arch-arm/syscalls/ftruncate.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(ftruncate)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_ftruncate
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/ftruncate64.S b/libc/arch-arm/syscalls/ftruncate64.S
index 7c7b80b..0e1b42b 100644
--- a/libc/arch-arm/syscalls/ftruncate64.S
+++ b/libc/arch-arm/syscalls/ftruncate64.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(ftruncate64)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_ftruncate64
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/getdents.S b/libc/arch-arm/syscalls/getdents.S
index 82b6e4c..e6c3028 100644
--- a/libc/arch-arm/syscalls/getdents.S
+++ b/libc/arch-arm/syscalls/getdents.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(getdents)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_getdents64
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/getegid.S b/libc/arch-arm/syscalls/getegid.S
index 27ea272..22794d1 100644
--- a/libc/arch-arm/syscalls/getegid.S
+++ b/libc/arch-arm/syscalls/getegid.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(getegid)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_getegid32
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/geteuid.S b/libc/arch-arm/syscalls/geteuid.S
index d4c9cd1..cfb318f 100644
--- a/libc/arch-arm/syscalls/geteuid.S
+++ b/libc/arch-arm/syscalls/geteuid.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(geteuid)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_geteuid32
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/getgid.S b/libc/arch-arm/syscalls/getgid.S
index 9a40fe6..085061e 100644
--- a/libc/arch-arm/syscalls/getgid.S
+++ b/libc/arch-arm/syscalls/getgid.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(getgid)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_getgid32
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/getgroups.S b/libc/arch-arm/syscalls/getgroups.S
index 2995cc8..c426d87 100644
--- a/libc/arch-arm/syscalls/getgroups.S
+++ b/libc/arch-arm/syscalls/getgroups.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(getgroups)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_getgroups32
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/getitimer.S b/libc/arch-arm/syscalls/getitimer.S
index a3f1423..5d832d9 100644
--- a/libc/arch-arm/syscalls/getitimer.S
+++ b/libc/arch-arm/syscalls/getitimer.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(getitimer)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_getitimer
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/getpeername.S b/libc/arch-arm/syscalls/getpeername.S
index f90c344..ced69f7 100644
--- a/libc/arch-arm/syscalls/getpeername.S
+++ b/libc/arch-arm/syscalls/getpeername.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(getpeername)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_getpeername
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/getpgid.S b/libc/arch-arm/syscalls/getpgid.S
index 0fc57a4..d599f1e 100644
--- a/libc/arch-arm/syscalls/getpgid.S
+++ b/libc/arch-arm/syscalls/getpgid.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(getpgid)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_getpgid
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/getpid.S b/libc/arch-arm/syscalls/getpid.S
index 440ae9b..ef19d25 100644
--- a/libc/arch-arm/syscalls/getpid.S
+++ b/libc/arch-arm/syscalls/getpid.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(getpid)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_getpid
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/getppid.S b/libc/arch-arm/syscalls/getppid.S
index 3eb1b86..1fe30d4 100644
--- a/libc/arch-arm/syscalls/getppid.S
+++ b/libc/arch-arm/syscalls/getppid.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(getppid)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_getppid
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/getresgid.S b/libc/arch-arm/syscalls/getresgid.S
index a022341..e8d2129 100644
--- a/libc/arch-arm/syscalls/getresgid.S
+++ b/libc/arch-arm/syscalls/getresgid.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(getresgid)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_getresgid32
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/getresuid.S b/libc/arch-arm/syscalls/getresuid.S
index 23112a6..cdfe0f7 100644
--- a/libc/arch-arm/syscalls/getresuid.S
+++ b/libc/arch-arm/syscalls/getresuid.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(getresuid)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_getresuid32
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/getrlimit.S b/libc/arch-arm/syscalls/getrlimit.S
index 8b1c089..3acbf95 100644
--- a/libc/arch-arm/syscalls/getrlimit.S
+++ b/libc/arch-arm/syscalls/getrlimit.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(getrlimit)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_ugetrlimit
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/getrusage.S b/libc/arch-arm/syscalls/getrusage.S
index 74fa20b..e17fc4a 100644
--- a/libc/arch-arm/syscalls/getrusage.S
+++ b/libc/arch-arm/syscalls/getrusage.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(getrusage)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_getrusage
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/getsid.S b/libc/arch-arm/syscalls/getsid.S
index 856d41a..06e6d67 100644
--- a/libc/arch-arm/syscalls/getsid.S
+++ b/libc/arch-arm/syscalls/getsid.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(getsid)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_getsid
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/getsockname.S b/libc/arch-arm/syscalls/getsockname.S
index 99470e2..458814f 100644
--- a/libc/arch-arm/syscalls/getsockname.S
+++ b/libc/arch-arm/syscalls/getsockname.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(getsockname)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_getsockname
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/gettid.S b/libc/arch-arm/syscalls/gettid.S
index f5b15be..f35c7ea 100644
--- a/libc/arch-arm/syscalls/gettid.S
+++ b/libc/arch-arm/syscalls/gettid.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(gettid)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_gettid
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/gettimeofday.S b/libc/arch-arm/syscalls/gettimeofday.S
index 9b47daf..113413e 100644
--- a/libc/arch-arm/syscalls/gettimeofday.S
+++ b/libc/arch-arm/syscalls/gettimeofday.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(gettimeofday)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_gettimeofday
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/getuid.S b/libc/arch-arm/syscalls/getuid.S
index 053dc31..20ed7f9 100644
--- a/libc/arch-arm/syscalls/getuid.S
+++ b/libc/arch-arm/syscalls/getuid.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(getuid)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_getuid32
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/getxattr.S b/libc/arch-arm/syscalls/getxattr.S
index 18532ce..0a7cbef 100644
--- a/libc/arch-arm/syscalls/getxattr.S
+++ b/libc/arch-arm/syscalls/getxattr.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(getxattr)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_getxattr
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/init_module.S b/libc/arch-arm/syscalls/init_module.S
index 73beb46..de41a7e 100644
--- a/libc/arch-arm/syscalls/init_module.S
+++ b/libc/arch-arm/syscalls/init_module.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(init_module)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_init_module
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/inotify_add_watch.S b/libc/arch-arm/syscalls/inotify_add_watch.S
index da4a296..aa8fcb7 100644
--- a/libc/arch-arm/syscalls/inotify_add_watch.S
+++ b/libc/arch-arm/syscalls/inotify_add_watch.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(inotify_add_watch)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_inotify_add_watch
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/inotify_init.S b/libc/arch-arm/syscalls/inotify_init.S
index bac124c..56d4b93 100644
--- a/libc/arch-arm/syscalls/inotify_init.S
+++ b/libc/arch-arm/syscalls/inotify_init.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(inotify_init)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_inotify_init
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/inotify_rm_watch.S b/libc/arch-arm/syscalls/inotify_rm_watch.S
index f576480..4315061 100644
--- a/libc/arch-arm/syscalls/inotify_rm_watch.S
+++ b/libc/arch-arm/syscalls/inotify_rm_watch.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(inotify_rm_watch)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_inotify_rm_watch
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/ioprio_get.S b/libc/arch-arm/syscalls/ioprio_get.S
index 13739dc..d3bd796 100644
--- a/libc/arch-arm/syscalls/ioprio_get.S
+++ b/libc/arch-arm/syscalls/ioprio_get.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(ioprio_get)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_ioprio_get
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/ioprio_set.S b/libc/arch-arm/syscalls/ioprio_set.S
index 7e40ee5..c42d305 100644
--- a/libc/arch-arm/syscalls/ioprio_set.S
+++ b/libc/arch-arm/syscalls/ioprio_set.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(ioprio_set)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_ioprio_set
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/klogctl.S b/libc/arch-arm/syscalls/klogctl.S
index 5434b30..1356815 100644
--- a/libc/arch-arm/syscalls/klogctl.S
+++ b/libc/arch-arm/syscalls/klogctl.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(klogctl)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_syslog
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/lchown.S b/libc/arch-arm/syscalls/lchown.S
index 789e5af..56902a3 100644
--- a/libc/arch-arm/syscalls/lchown.S
+++ b/libc/arch-arm/syscalls/lchown.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(lchown)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_lchown32
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/lgetxattr.S b/libc/arch-arm/syscalls/lgetxattr.S
index 61fc098..cc30d63 100644
--- a/libc/arch-arm/syscalls/lgetxattr.S
+++ b/libc/arch-arm/syscalls/lgetxattr.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(lgetxattr)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_lgetxattr
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/link.S b/libc/arch-arm/syscalls/link.S
index ccf0a1d..dab8fa6 100644
--- a/libc/arch-arm/syscalls/link.S
+++ b/libc/arch-arm/syscalls/link.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(link)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_link
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/listen.S b/libc/arch-arm/syscalls/listen.S
index bb7f7a4..fac3702 100644
--- a/libc/arch-arm/syscalls/listen.S
+++ b/libc/arch-arm/syscalls/listen.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(listen)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_listen
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/listxattr.S b/libc/arch-arm/syscalls/listxattr.S
index 6bbdb6a..8c7fc9b 100644
--- a/libc/arch-arm/syscalls/listxattr.S
+++ b/libc/arch-arm/syscalls/listxattr.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(listxattr)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_listxattr
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/llistxattr.S b/libc/arch-arm/syscalls/llistxattr.S
index 89682df..9cade18 100644
--- a/libc/arch-arm/syscalls/llistxattr.S
+++ b/libc/arch-arm/syscalls/llistxattr.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(llistxattr)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_llistxattr
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/lremovexattr.S b/libc/arch-arm/syscalls/lremovexattr.S
index 62f6722..d4a7b82 100644
--- a/libc/arch-arm/syscalls/lremovexattr.S
+++ b/libc/arch-arm/syscalls/lremovexattr.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(lremovexattr)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_lremovexattr
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/lseek.S b/libc/arch-arm/syscalls/lseek.S
index 2cd0853..a452856 100644
--- a/libc/arch-arm/syscalls/lseek.S
+++ b/libc/arch-arm/syscalls/lseek.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(lseek)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_lseek
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/lstat.S b/libc/arch-arm/syscalls/lstat.S
index dbecefe..69f2146 100644
--- a/libc/arch-arm/syscalls/lstat.S
+++ b/libc/arch-arm/syscalls/lstat.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(lstat)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_lstat64
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/madvise.S b/libc/arch-arm/syscalls/madvise.S
index 024476f..02944a2 100644
--- a/libc/arch-arm/syscalls/madvise.S
+++ b/libc/arch-arm/syscalls/madvise.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(madvise)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_madvise
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/mincore.S b/libc/arch-arm/syscalls/mincore.S
index 7a2a378..5ffdc11 100644
--- a/libc/arch-arm/syscalls/mincore.S
+++ b/libc/arch-arm/syscalls/mincore.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(mincore)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_mincore
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/mkdir.S b/libc/arch-arm/syscalls/mkdir.S
index e51beab..c2aa080 100644
--- a/libc/arch-arm/syscalls/mkdir.S
+++ b/libc/arch-arm/syscalls/mkdir.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(mkdir)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_mkdir
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/mkdirat.S b/libc/arch-arm/syscalls/mkdirat.S
index 52f0be3..421c70a 100644
--- a/libc/arch-arm/syscalls/mkdirat.S
+++ b/libc/arch-arm/syscalls/mkdirat.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(mkdirat)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_mkdirat
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/mknod.S b/libc/arch-arm/syscalls/mknod.S
index ac6d976..4aca2c5 100644
--- a/libc/arch-arm/syscalls/mknod.S
+++ b/libc/arch-arm/syscalls/mknod.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(mknod)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_mknod
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/mlock.S b/libc/arch-arm/syscalls/mlock.S
index ad140d1..5c8e74d 100644
--- a/libc/arch-arm/syscalls/mlock.S
+++ b/libc/arch-arm/syscalls/mlock.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(mlock)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_mlock
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/mlockall.S b/libc/arch-arm/syscalls/mlockall.S
index 45c782e..a89545a 100644
--- a/libc/arch-arm/syscalls/mlockall.S
+++ b/libc/arch-arm/syscalls/mlockall.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(mlockall)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_mlockall
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/mprotect.S b/libc/arch-arm/syscalls/mprotect.S
index 39ae353..06238bf 100644
--- a/libc/arch-arm/syscalls/mprotect.S
+++ b/libc/arch-arm/syscalls/mprotect.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(mprotect)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_mprotect
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/mremap.S b/libc/arch-arm/syscalls/mremap.S
index 918f3b7..29b308b 100644
--- a/libc/arch-arm/syscalls/mremap.S
+++ b/libc/arch-arm/syscalls/mremap.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(mremap)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_mremap
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/msync.S b/libc/arch-arm/syscalls/msync.S
index 2a5922c..af8fc0c 100644
--- a/libc/arch-arm/syscalls/msync.S
+++ b/libc/arch-arm/syscalls/msync.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(msync)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_msync
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/munlock.S b/libc/arch-arm/syscalls/munlock.S
index 5a02aaf..42df37e 100644
--- a/libc/arch-arm/syscalls/munlock.S
+++ b/libc/arch-arm/syscalls/munlock.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(munlock)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_munlock
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/munlockall.S b/libc/arch-arm/syscalls/munlockall.S
index 8106965..c0fca33 100644
--- a/libc/arch-arm/syscalls/munlockall.S
+++ b/libc/arch-arm/syscalls/munlockall.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(munlockall)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_munlockall
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/munmap.S b/libc/arch-arm/syscalls/munmap.S
index 6bb8dd8..9d7b60f 100644
--- a/libc/arch-arm/syscalls/munmap.S
+++ b/libc/arch-arm/syscalls/munmap.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(munmap)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_munmap
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/nanosleep.S b/libc/arch-arm/syscalls/nanosleep.S
index af36ced..7f4cda6 100644
--- a/libc/arch-arm/syscalls/nanosleep.S
+++ b/libc/arch-arm/syscalls/nanosleep.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(nanosleep)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_nanosleep
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/pause.S b/libc/arch-arm/syscalls/pause.S
index e64f4f3..1238f4b 100644
--- a/libc/arch-arm/syscalls/pause.S
+++ b/libc/arch-arm/syscalls/pause.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(pause)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_pause
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/personality.S b/libc/arch-arm/syscalls/personality.S
index 17ac686..f338d71 100644
--- a/libc/arch-arm/syscalls/personality.S
+++ b/libc/arch-arm/syscalls/personality.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(personality)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_personality
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/pipe.S b/libc/arch-arm/syscalls/pipe.S
index 3968703..ec0efb1 100644
--- a/libc/arch-arm/syscalls/pipe.S
+++ b/libc/arch-arm/syscalls/pipe.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(pipe)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_pipe
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/pipe2.S b/libc/arch-arm/syscalls/pipe2.S
index da2ecba..f79c8f5 100644
--- a/libc/arch-arm/syscalls/pipe2.S
+++ b/libc/arch-arm/syscalls/pipe2.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(pipe2)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_pipe2
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/poll.S b/libc/arch-arm/syscalls/poll.S
index 4d345ea..d9831ab 100644
--- a/libc/arch-arm/syscalls/poll.S
+++ b/libc/arch-arm/syscalls/poll.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(poll)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_poll
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/read.S b/libc/arch-arm/syscalls/read.S
index c062388..ab0583a 100644
--- a/libc/arch-arm/syscalls/read.S
+++ b/libc/arch-arm/syscalls/read.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(read)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_read
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/readlink.S b/libc/arch-arm/syscalls/readlink.S
index 7602e61..90b0ea6 100644
--- a/libc/arch-arm/syscalls/readlink.S
+++ b/libc/arch-arm/syscalls/readlink.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(readlink)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_readlink
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/readv.S b/libc/arch-arm/syscalls/readv.S
index e717e61..9f8b8db 100644
--- a/libc/arch-arm/syscalls/readv.S
+++ b/libc/arch-arm/syscalls/readv.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(readv)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_readv
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/recvmsg.S b/libc/arch-arm/syscalls/recvmsg.S
index 5c168dc..00746a1 100644
--- a/libc/arch-arm/syscalls/recvmsg.S
+++ b/libc/arch-arm/syscalls/recvmsg.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(recvmsg)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_recvmsg
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/removexattr.S b/libc/arch-arm/syscalls/removexattr.S
index 1a44caf..82fb9e0 100644
--- a/libc/arch-arm/syscalls/removexattr.S
+++ b/libc/arch-arm/syscalls/removexattr.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(removexattr)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_removexattr
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/rename.S b/libc/arch-arm/syscalls/rename.S
index 930ddb6..dfe0b0e 100644
--- a/libc/arch-arm/syscalls/rename.S
+++ b/libc/arch-arm/syscalls/rename.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(rename)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_rename
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/renameat.S b/libc/arch-arm/syscalls/renameat.S
index a13c4ee..aa42b78 100644
--- a/libc/arch-arm/syscalls/renameat.S
+++ b/libc/arch-arm/syscalls/renameat.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(renameat)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_renameat
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/rmdir.S b/libc/arch-arm/syscalls/rmdir.S
index 09a956f..c2d5c5a 100644
--- a/libc/arch-arm/syscalls/rmdir.S
+++ b/libc/arch-arm/syscalls/rmdir.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(rmdir)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_rmdir
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/sched_get_priority_max.S b/libc/arch-arm/syscalls/sched_get_priority_max.S
index 2dea3b7..703ddeb 100644
--- a/libc/arch-arm/syscalls/sched_get_priority_max.S
+++ b/libc/arch-arm/syscalls/sched_get_priority_max.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(sched_get_priority_max)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_sched_get_priority_max
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/sched_get_priority_min.S b/libc/arch-arm/syscalls/sched_get_priority_min.S
index de8b878..deea8ae 100644
--- a/libc/arch-arm/syscalls/sched_get_priority_min.S
+++ b/libc/arch-arm/syscalls/sched_get_priority_min.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(sched_get_priority_min)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_sched_get_priority_min
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/sched_getparam.S b/libc/arch-arm/syscalls/sched_getparam.S
index 6434217..194d4a2 100644
--- a/libc/arch-arm/syscalls/sched_getparam.S
+++ b/libc/arch-arm/syscalls/sched_getparam.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(sched_getparam)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_sched_getparam
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/sched_getscheduler.S b/libc/arch-arm/syscalls/sched_getscheduler.S
index 8e45ce6..fd3cec5 100644
--- a/libc/arch-arm/syscalls/sched_getscheduler.S
+++ b/libc/arch-arm/syscalls/sched_getscheduler.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(sched_getscheduler)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_sched_getscheduler
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/sched_rr_get_interval.S b/libc/arch-arm/syscalls/sched_rr_get_interval.S
index e88d26e..21a5788 100644
--- a/libc/arch-arm/syscalls/sched_rr_get_interval.S
+++ b/libc/arch-arm/syscalls/sched_rr_get_interval.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(sched_rr_get_interval)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_sched_rr_get_interval
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/sched_setaffinity.S b/libc/arch-arm/syscalls/sched_setaffinity.S
index b9dd299..c980ed0 100644
--- a/libc/arch-arm/syscalls/sched_setaffinity.S
+++ b/libc/arch-arm/syscalls/sched_setaffinity.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(sched_setaffinity)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_sched_setaffinity
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/sched_setparam.S b/libc/arch-arm/syscalls/sched_setparam.S
index 73d6ab6..993078d 100644
--- a/libc/arch-arm/syscalls/sched_setparam.S
+++ b/libc/arch-arm/syscalls/sched_setparam.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(sched_setparam)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_sched_setparam
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/sched_setscheduler.S b/libc/arch-arm/syscalls/sched_setscheduler.S
index 33c28ab..d0ac1de 100644
--- a/libc/arch-arm/syscalls/sched_setscheduler.S
+++ b/libc/arch-arm/syscalls/sched_setscheduler.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(sched_setscheduler)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_sched_setscheduler
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/sched_yield.S b/libc/arch-arm/syscalls/sched_yield.S
index 71628b3..00bdfbd 100644
--- a/libc/arch-arm/syscalls/sched_yield.S
+++ b/libc/arch-arm/syscalls/sched_yield.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(sched_yield)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_sched_yield
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/sendfile.S b/libc/arch-arm/syscalls/sendfile.S
index 2790b4b..9e4c70c 100644
--- a/libc/arch-arm/syscalls/sendfile.S
+++ b/libc/arch-arm/syscalls/sendfile.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(sendfile)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_sendfile
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/sendmsg.S b/libc/arch-arm/syscalls/sendmsg.S
index 99b5479..1b54aee 100644
--- a/libc/arch-arm/syscalls/sendmsg.S
+++ b/libc/arch-arm/syscalls/sendmsg.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(sendmsg)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_sendmsg
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/setgid.S b/libc/arch-arm/syscalls/setgid.S
index f28687d..09045ad 100644
--- a/libc/arch-arm/syscalls/setgid.S
+++ b/libc/arch-arm/syscalls/setgid.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(setgid)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_setgid32
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/setgroups.S b/libc/arch-arm/syscalls/setgroups.S
index d2c932f..e4c36b5 100644
--- a/libc/arch-arm/syscalls/setgroups.S
+++ b/libc/arch-arm/syscalls/setgroups.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(setgroups)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_setgroups32
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/setitimer.S b/libc/arch-arm/syscalls/setitimer.S
index c6b5064..dfb7a46 100644
--- a/libc/arch-arm/syscalls/setitimer.S
+++ b/libc/arch-arm/syscalls/setitimer.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(setitimer)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_setitimer
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/setpgid.S b/libc/arch-arm/syscalls/setpgid.S
index 39e1e03..c558063 100644
--- a/libc/arch-arm/syscalls/setpgid.S
+++ b/libc/arch-arm/syscalls/setpgid.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(setpgid)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_setpgid
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/setpriority.S b/libc/arch-arm/syscalls/setpriority.S
index 5cb84a8..683da34 100644
--- a/libc/arch-arm/syscalls/setpriority.S
+++ b/libc/arch-arm/syscalls/setpriority.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(setpriority)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_setpriority
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/setregid.S b/libc/arch-arm/syscalls/setregid.S
index bc79e9e..2062d05 100644
--- a/libc/arch-arm/syscalls/setregid.S
+++ b/libc/arch-arm/syscalls/setregid.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(setregid)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_setregid32
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/setresgid.S b/libc/arch-arm/syscalls/setresgid.S
index 711626e..089c7a7 100644
--- a/libc/arch-arm/syscalls/setresgid.S
+++ b/libc/arch-arm/syscalls/setresgid.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(setresgid)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_setresgid32
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/setrlimit.S b/libc/arch-arm/syscalls/setrlimit.S
index 0fe2467..02b8db4 100644
--- a/libc/arch-arm/syscalls/setrlimit.S
+++ b/libc/arch-arm/syscalls/setrlimit.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(setrlimit)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_setrlimit
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/setsid.S b/libc/arch-arm/syscalls/setsid.S
index f11b6fb..d82c347 100644
--- a/libc/arch-arm/syscalls/setsid.S
+++ b/libc/arch-arm/syscalls/setsid.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(setsid)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_setsid
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/settimeofday.S b/libc/arch-arm/syscalls/settimeofday.S
index 2741e05..44f5e66 100644
--- a/libc/arch-arm/syscalls/settimeofday.S
+++ b/libc/arch-arm/syscalls/settimeofday.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(settimeofday)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_settimeofday
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/shutdown.S b/libc/arch-arm/syscalls/shutdown.S
index 0802631..cc96f56 100644
--- a/libc/arch-arm/syscalls/shutdown.S
+++ b/libc/arch-arm/syscalls/shutdown.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(shutdown)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_shutdown
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/sigaction.S b/libc/arch-arm/syscalls/sigaction.S
index 04a8b94..699f55d 100644
--- a/libc/arch-arm/syscalls/sigaction.S
+++ b/libc/arch-arm/syscalls/sigaction.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(sigaction)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_sigaction
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/sigaltstack.S b/libc/arch-arm/syscalls/sigaltstack.S
index b541a87..0f34eab 100644
--- a/libc/arch-arm/syscalls/sigaltstack.S
+++ b/libc/arch-arm/syscalls/sigaltstack.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(sigaltstack)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_sigaltstack
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/signalfd4.S b/libc/arch-arm/syscalls/signalfd4.S
new file mode 100644
index 0000000..6f07fbe
--- /dev/null
+++ b/libc/arch-arm/syscalls/signalfd4.S
@@ -0,0 +1,13 @@
+/* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
+#include <sys/linux-syscalls.h>
+
+ENTRY(signalfd4)
+    mov     ip, r7
+    ldr     r7, =__NR_signalfd4
+    swi     #0
+    mov     r7, ip
+    movs    r0, r0
+    bxpl    lr
+    b       __set_syscall_errno
+END(signalfd4)
diff --git a/libc/arch-arm/syscalls/sigpending.S b/libc/arch-arm/syscalls/sigpending.S
index 4c7d919..b541288 100644
--- a/libc/arch-arm/syscalls/sigpending.S
+++ b/libc/arch-arm/syscalls/sigpending.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(sigpending)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_sigpending
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/sigprocmask.S b/libc/arch-arm/syscalls/sigprocmask.S
index 7c59a6b..d169474 100644
--- a/libc/arch-arm/syscalls/sigprocmask.S
+++ b/libc/arch-arm/syscalls/sigprocmask.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(sigprocmask)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_sigprocmask
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/socket.S b/libc/arch-arm/syscalls/socket.S
index e28d252..1003bd4 100644
--- a/libc/arch-arm/syscalls/socket.S
+++ b/libc/arch-arm/syscalls/socket.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(socket)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_socket
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/socketpair.S b/libc/arch-arm/syscalls/socketpair.S
index e699000..65bef68 100644
--- a/libc/arch-arm/syscalls/socketpair.S
+++ b/libc/arch-arm/syscalls/socketpair.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(socketpair)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_socketpair
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/stat.S b/libc/arch-arm/syscalls/stat.S
index a4669a6..17b63cc 100644
--- a/libc/arch-arm/syscalls/stat.S
+++ b/libc/arch-arm/syscalls/stat.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(stat)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_stat64
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/symlink.S b/libc/arch-arm/syscalls/symlink.S
index 14a753f..ac569af 100644
--- a/libc/arch-arm/syscalls/symlink.S
+++ b/libc/arch-arm/syscalls/symlink.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(symlink)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_symlink
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/sync.S b/libc/arch-arm/syscalls/sync.S
index 68c0c0f..ef6cb16 100644
--- a/libc/arch-arm/syscalls/sync.S
+++ b/libc/arch-arm/syscalls/sync.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(sync)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_sync
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/sysinfo.S b/libc/arch-arm/syscalls/sysinfo.S
index 2a2fb59..a891735 100644
--- a/libc/arch-arm/syscalls/sysinfo.S
+++ b/libc/arch-arm/syscalls/sysinfo.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(sysinfo)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_sysinfo
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/times.S b/libc/arch-arm/syscalls/times.S
index aacb4ca..051f34d 100644
--- a/libc/arch-arm/syscalls/times.S
+++ b/libc/arch-arm/syscalls/times.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(times)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_times
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/truncate.S b/libc/arch-arm/syscalls/truncate.S
index 8c0b24f..3bb68cd 100644
--- a/libc/arch-arm/syscalls/truncate.S
+++ b/libc/arch-arm/syscalls/truncate.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(truncate)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_truncate
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/umask.S b/libc/arch-arm/syscalls/umask.S
index a7bc20b..78e43e0 100644
--- a/libc/arch-arm/syscalls/umask.S
+++ b/libc/arch-arm/syscalls/umask.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(umask)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_umask
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/umount2.S b/libc/arch-arm/syscalls/umount2.S
index 04b28f4..605359e 100644
--- a/libc/arch-arm/syscalls/umount2.S
+++ b/libc/arch-arm/syscalls/umount2.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(umount2)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_umount2
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/uname.S b/libc/arch-arm/syscalls/uname.S
index 4a6f0f4..db0860b 100644
--- a/libc/arch-arm/syscalls/uname.S
+++ b/libc/arch-arm/syscalls/uname.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(uname)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_uname
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/unlink.S b/libc/arch-arm/syscalls/unlink.S
index 87fa79e..8ef33df 100644
--- a/libc/arch-arm/syscalls/unlink.S
+++ b/libc/arch-arm/syscalls/unlink.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(unlink)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_unlink
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/unlinkat.S b/libc/arch-arm/syscalls/unlinkat.S
index 3beae6c..eb822e4 100644
--- a/libc/arch-arm/syscalls/unlinkat.S
+++ b/libc/arch-arm/syscalls/unlinkat.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(unlinkat)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_unlinkat
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/unshare.S b/libc/arch-arm/syscalls/unshare.S
index 0a92b21..ec77f3a 100644
--- a/libc/arch-arm/syscalls/unshare.S
+++ b/libc/arch-arm/syscalls/unshare.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(unshare)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_unshare
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/utimensat.S b/libc/arch-arm/syscalls/utimensat.S
index ceae7fa..976a667 100644
--- a/libc/arch-arm/syscalls/utimensat.S
+++ b/libc/arch-arm/syscalls/utimensat.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(utimensat)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_utimensat
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/utimes.S b/libc/arch-arm/syscalls/utimes.S
index a2d58a3..8966626 100644
--- a/libc/arch-arm/syscalls/utimes.S
+++ b/libc/arch-arm/syscalls/utimes.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(utimes)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_utimes
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/vfork.S b/libc/arch-arm/syscalls/vfork.S
index 3bd2668..89cbda2 100644
--- a/libc/arch-arm/syscalls/vfork.S
+++ b/libc/arch-arm/syscalls/vfork.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(vfork)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_vfork
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/write.S b/libc/arch-arm/syscalls/write.S
index 826e82c..c257915 100644
--- a/libc/arch-arm/syscalls/write.S
+++ b/libc/arch-arm/syscalls/write.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(write)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_write
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-arm/syscalls/writev.S b/libc/arch-arm/syscalls/writev.S
index 16a6df9..521e10c 100644
--- a/libc/arch-arm/syscalls/writev.S
+++ b/libc/arch-arm/syscalls/writev.S
@@ -3,11 +3,10 @@
 #include <sys/linux-syscalls.h>
 
 ENTRY(writev)
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =__NR_writev
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
diff --git a/libc/arch-mips/bionic/cacheflush.c b/libc/arch-mips/bionic/cacheflush.c
index 05085b6..1911687 100644
--- a/libc/arch-mips/bionic/cacheflush.c
+++ b/libc/arch-mips/bionic/cacheflush.c
@@ -29,9 +29,9 @@
 #include <sys/cachectl.h>
 
 #ifdef DEBUG
-#include <logd.h>
-#define  XLOG(...)   \
-	__libc_android_log_print(ANDROID_LOG_DEBUG,"libc-cacheflush",__VA_ARGS__)
+#include <private/logd.h>
+#include <private/debug_format.h>
+#define  XLOG(...) __libc_format_log(ANDROID_LOG_DEBUG,"libc-cacheflush",__VA_ARGS__)
 #endif
 
 /*
diff --git a/libc/arch-mips/bionic/clone.S b/libc/arch-mips/bionic/clone.S
index 30fef8d..007e909 100644
--- a/libc/arch-mips/bionic/clone.S
+++ b/libc/arch-mips/bionic/clone.S
@@ -28,15 +28,15 @@
 #include <linux/sched.h>
 #include <sys/linux-syscalls.h>
 #include <linux/errno.h>
-        
+
 	.text
 	.type __pthread_clone, @function
 	.global __pthread_clone
 	.align 4
         .ent __pthread_clone
-        
+
 /*
- * int __pthread_clone(int (*fn)(void*), void *child_stack,
+ * int __pthread_clone(void* (*fn)(void*), void *child_stack,
  *			 int flags, void *arg);
  */
 
@@ -69,7 +69,7 @@
         bnez	$a3,.L__error
 
         beqz	$v0,.L__thread_start
-        
+
         j $ra
 
 .L__thread_start:
@@ -77,7 +77,7 @@
         lw	$a1,4($sp)	#  arg
         addu	$a2,$sp,16	#  tls
 
-	# void __thread_entry(int (*func)(void*), void *arg, void *tls)
+	# void __thread_entry(void* (*func)(void*), void *arg, void *tls)
         la	$t9, __thread_entry
         j	$t9
 
@@ -125,7 +125,7 @@
         bnez	$a3,.L__error_bc
 
         beqz	$v0,.L__thread_start_bc
-        
+
         j $ra
 
 .L__thread_start_bc:
@@ -142,4 +142,3 @@
 	j	$t9
 
         .end __bionic_clone
-	
diff --git a/libc/arch-mips/include/endian.h b/libc/arch-mips/include/endian.h
deleted file mode 100644
index 6d4ca4e..0000000
--- a/libc/arch-mips/include/endian.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*	$OpenBSD: endian.h,v 1.5 2006/02/27 23:35:59 miod Exp $ */
-
-/*
- * Copyright (c) 2001-2002 Opsycon AB  (www.opsycon.se / www.opsycon.com)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#ifndef _MIPS64_ENDIAN_H_
-#define _MIPS64_ENDIAN_H_
-
-#if defined(__MIPSEL__)
-#define _BYTE_ORDER _LITTLE_ENDIAN
-#endif
-#if defined(__MIPSEB__)
-#define _BYTE_ORDER _BIG_ENDIAN
-#endif
-
-#if !defined(_BYTE_ORDER) && !defined(lint)
-#error "__MIPSEL__ or __MIPSEB__ must be defined to define BYTE_ORDER!!!"
-#endif
-
-#ifdef __GNUC__
-
-#if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
-#define __swap16md(x) ({					\
-    register uint16_t _x = (x);					\
-    register uint16_t _r;					\
-    __asm volatile ("wsbh %0, %1" : "=r" (_r) : "r" (_x));	\
-    _r;								\
-})
-
-#define __swap32md(x) ({					\
-    register uint32_t _x = (x);					\
-    register uint32_t _r;					\
-    __asm volatile ("wsbh %0, %1; rotr %0, %0, 16" : "=r" (_r) : "r" (_x)); \
-    _r;								\
-})
-
-#define __swap64md(x) ({					\
-    uint64_t _swap64md_x = (x);					\
-    (uint64_t) __swap32md(_swap64md_x >> 32) |			\
-        (uint64_t) __swap32md(_swap64md_x & 0xffffffff) << 32;	\
-})
-
-/* Tell sys/endian.h we have MD variants of the swap macros.  */
-#define MD_SWAP
-
-#endif  /* __mips32r2__ */
-#endif  /* __GNUC__ */
-
-
-#include <sys/endian.h>
-
-#define	__STRICT_ALIGNMENT
-
-#endif /* _MIPS64_ENDIAN_H_ */
diff --git a/libc/arch-mips/include/machine/_types.h b/libc/arch-mips/include/machine/_types.h
index 1cc6c21..05f79ef 100644
--- a/libc/arch-mips/include/machine/_types.h
+++ b/libc/arch-mips/include/machine/_types.h
@@ -105,8 +105,6 @@
 typedef float			__float_t;
 typedef long long		__off_t;
 typedef long			__ptrdiff_t;
-/*typedef	unsigned long		__size_t;*/
-typedef	long			__ssize_t;
 typedef	int			__time_t;
 typedef int			__timer_t;
 #if defined(__GNUC__) && __GNUC__ >= 3
@@ -124,12 +122,6 @@
 typedef	void *			__wctrans_t;
 typedef	void *			__wctype_t;
 
-#ifdef __MIPSEB__
-#define _BYTE_ORDER _BIG_ENDIAN
-#else
-#define _BYTE_ORDER _LITTLE_ENDIAN
-#endif
-
 #if defined(_KERNEL)
 typedef struct label_t {
 	__register_t val[14];
diff --git a/libc/arch-mips/include/machine/elf_machdep.h b/libc/arch-mips/include/machine/elf_machdep.h
new file mode 100644
index 0000000..d27d431
--- /dev/null
+++ b/libc/arch-mips/include/machine/elf_machdep.h
@@ -0,0 +1,196 @@
+/*	$NetBSD: elf_machdep.h,v 1.15 2011/03/15 07:39:22 matt Exp $	*/
+
+#ifndef _MIPS_ELF_MACHDEP_H_
+#define  _MIPS_ELF_MACHDEP_H_
+
+#ifdef _LP64
+#define ARCH_ELFSIZE		64	/* MD native binary size */
+#else
+#define ARCH_ELFSIZE		32	/* MD native binary size */
+#endif
+
+#if ELFSIZE == 32
+#define	ELF32_MACHDEP_ID_CASES						\
+		case EM_MIPS:						\
+			break;
+
+#define	ELF32_MACHDEP_ID	EM_MIPS
+#elif ELFSIZE == 64
+#define	ELF64_MACHDEP_ID_CASES						\
+		case EM_MIPS:						\
+			break;
+
+#define	ELF64_MACHDEP_ID	EM_MIPS
+#endif
+
+/* mips relocs.  */
+
+#define R_MIPS_NONE		0
+#define R_MIPS_16		1
+#define R_MIPS_32		2
+#define R_MIPS_REL32		3
+#define R_MIPS_REL		R_MIPS_REL32
+#define R_MIPS_26		4
+#define R_MIPS_HI16		5	/* high 16 bits of symbol value */
+#define R_MIPS_LO16		6	/* low 16 bits of symbol value */
+#define R_MIPS_GPREL16		7  	/* GP-relative reference  */
+#define R_MIPS_LITERAL		8 	/* Reference to literal section  */
+#define R_MIPS_GOT16		9	/* Reference to global offset table */
+#define R_MIPS_GOT		R_MIPS_GOT16
+#define R_MIPS_PC16		10  	/* 16 bit PC relative reference */
+#define R_MIPS_CALL16 		11  	/* 16 bit call thru glbl offset tbl */
+#define R_MIPS_CALL		R_MIPS_CALL16
+#define R_MIPS_GPREL32		12
+
+/* 13, 14, 15 are not defined at this point. */
+#define R_MIPS_UNUSED1		13
+#define R_MIPS_UNUSED2		14
+#define R_MIPS_UNUSED3		15
+
+/*
+ * The remaining relocs are apparently part of the 64-bit Irix ELF ABI.
+ */
+#define R_MIPS_SHIFT5		16
+#define R_MIPS_SHIFT6		17
+
+#define R_MIPS_64		18
+#define R_MIPS_GOT_DISP		19
+#define R_MIPS_GOT_PAGE		20
+#define R_MIPS_GOT_OFST		21
+#define R_MIPS_GOT_HI16		22
+#define R_MIPS_GOT_LO16		23
+#define R_MIPS_SUB 		24
+#define R_MIPS_INSERT_A		25
+#define R_MIPS_INSERT_B		26
+#define R_MIPS_DELETE		27
+#define R_MIPS_HIGHER		28
+#define R_MIPS_HIGHEST		29
+#define R_MIPS_CALL_HI16	30
+#define R_MIPS_CALL_LO16	31
+#define R_MIPS_SCN_DISP		32
+#define R_MIPS_REL16		33
+#define R_MIPS_ADD_IMMEDIATE	34
+#define R_MIPS_PJUMP		35
+#define R_MIPS_RELGOT		36
+#define	R_MIPS_JALR		37
+/* TLS relocations */
+
+#define R_MIPS_TLS_DTPMOD32	38	/* Module number 32 bit */
+#define R_MIPS_TLS_DTPREL32	39	/* Module-relative offset 32 bit */
+#define R_MIPS_TLS_DTPMOD64	40	/* Module number 64 bit */
+#define R_MIPS_TLS_DTPREL64	41	/* Module-relative offset 64 bit */
+#define R_MIPS_TLS_GD		42	/* 16 bit GOT offset for GD */
+#define R_MIPS_TLS_LDM		43	/* 16 bit GOT offset for LDM */
+#define R_MIPS_TLS_DTPREL_HI16	44	/* Module-relative offset, high 16 bits */
+#define R_MIPS_TLS_DTPREL_LO16	45	/* Module-relative offset, low 16 bits */
+#define R_MIPS_TLS_GOTTPREL	46	/* 16 bit GOT offset for IE */
+#define R_MIPS_TLS_TPREL32	47	/* TP-relative offset, 32 bit */
+#define R_MIPS_TLS_TPREL64	48	/* TP-relative offset, 64 bit */
+#define R_MIPS_TLS_TPREL_HI16	49	/* TP-relative offset, high 16 bits */
+#define R_MIPS_TLS_TPREL_LO16	50	/* TP-relative offset, low 16 bits */
+
+#define R_MIPS_max		51
+
+#define R_TYPE(name)		__CONCAT(R_MIPS_,name)
+
+#define	R_MIPS16_min		100
+#define	R_MIPS16_26		100
+#define	R_MIPS16_GPREL		101
+#define	R_MIPS16_GOT16		102
+#define	R_MIPS16_CALL16		103
+#define	R_MIPS16_HI16		104
+#define	R_MIPS16_LO16		105
+#define	R_MIPS16_max		106
+
+
+/* mips dynamic tags */
+
+#define DT_MIPS_RLD_VERSION	0x70000001
+#define DT_MIPS_TIME_STAMP	0x70000002
+#define DT_MIPS_ICHECKSUM	0x70000003
+#define DT_MIPS_IVERSION	0x70000004
+#define DT_MIPS_FLAGS		0x70000005
+#define DT_MIPS_BASE_ADDRESS	0x70000006
+#define DT_MIPS_CONFLICT	0x70000008
+#define DT_MIPS_LIBLIST		0x70000009
+#define DT_MIPS_CONFLICTNO	0x7000000b
+#define	DT_MIPS_LOCAL_GOTNO	0x7000000a	/* number of local got ents */
+#define DT_MIPS_LIBLISTNO	0x70000010
+#define	DT_MIPS_SYMTABNO	0x70000011	/* number of .dynsym entries */
+#define DT_MIPS_UNREFEXTNO	0x70000012
+#define	DT_MIPS_GOTSYM		0x70000013	/* first dynamic sym in got */
+#define DT_MIPS_HIPAGENO	0x70000014
+#define	DT_MIPS_RLD_MAP		0x70000016	/* address of loader map */
+
+/*
+ * ELF Flags
+ */
+#define	EF_MIPS_PIC		0x00000002	/* Contains PIC code */
+#define	EF_MIPS_CPIC		0x00000004	/* STD PIC calling sequence */
+#define	EF_MIPS_ABI2		0x00000020	/* N32 */
+
+#define	EF_MIPS_ARCH_ASE	0x0f000000	/* Architectural extensions */
+#define	EF_MIPS_ARCH_MDMX	0x08000000	/* MDMX multimedia extension */
+#define	EF_MIPS_ARCH_M16	0x04000000	/* MIPS-16 ISA extensions */
+
+#define	EF_MIPS_ARCH		0xf0000000	/* Architecture field */
+#define	EF_MIPS_ARCH_1		0x00000000	/* -mips1 code */
+#define	EF_MIPS_ARCH_2		0x10000000	/* -mips2 code */
+#define	EF_MIPS_ARCH_3		0x20000000	/* -mips3 code */
+#define	EF_MIPS_ARCH_4		0x30000000	/* -mips4 code */
+#define	EF_MIPS_ARCH_5		0x40000000	/* -mips5 code */
+#define	EF_MIPS_ARCH_32		0x50000000	/* -mips32 code */
+#define	EF_MIPS_ARCH_64		0x60000000	/* -mips64 code */
+#define	EF_MIPS_ARCH_32R2	0x70000000	/* -mips32r2 code */
+#define	EF_MIPS_ARCH_64R2	0x80000000	/* -mips64r2 code */
+
+#define	EF_MIPS_ABI		0x0000f000
+#define	EF_MIPS_ABI_O32		0x00001000
+#define	EF_MIPS_ABI_O64		0x00002000
+#define	EF_MIPS_ABI_EABI32	0x00003000
+#define	EF_MIPS_ABI_EABI64	0x00004000
+
+#if defined(__MIPSEB__)
+#define	ELF32_MACHDEP_ENDIANNESS	ELFDATA2MSB
+#define	ELF64_MACHDEP_ENDIANNESS	ELFDATA2MSB
+#elif defined(__MIPSEL__)
+#define	ELF32_MACHDEP_ENDIANNESS	ELFDATA2LSB
+#define	ELF64_MACHDEP_ENDIANNESS	ELFDATA2LSB
+#elif !defined(HAVE_NBTOOL_CONFIG_H)
+#error neither __MIPSEL__ nor __MIPSEB__ are defined.
+#endif
+
+#ifdef _KERNEL
+#ifdef _KERNEL_OPT
+#include "opt_compat_netbsd.h"
+#endif
+#ifdef COMPAT_16
+/*
+ * Up to 1.6, the ELF dynamic loader (ld.elf_so) was not relocatable.
+ * Tell the kernel ELF exec code not to try relocating the interpreter
+ * for dynamically-linked ELF binaries.
+ */
+#define ELF_INTERP_NON_RELOCATABLE
+#endif /* COMPAT_16 */
+
+/*
+ * We need to be able to include the ELF header so we can pick out the
+ * ABI being used.
+ */
+#ifdef ELFSIZE
+#define	ELF_MD_PROBE_FUNC	ELFNAME2(mips_netbsd,probe)
+#define	ELF_MD_COREDUMP_SETUP	ELFNAME2(coredump,setup)
+#endif
+
+struct exec_package;
+
+int mips_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *,
+	vaddr_t *);
+void coredump_elf32_setup(struct lwp *, void *);
+
+int mips_netbsd_elf64_probe(struct lwp *, struct exec_package *, void *, char *,
+	vaddr_t *);
+void coredump_elf64_setup(struct lwp *, void *);
+#endif /* _KERNEL */
+
+#endif /* _MIPS_ELF_MACHDEP_H_ */
diff --git a/libc/arch-mips/include/machine/endian.h b/libc/arch-mips/include/machine/endian.h
new file mode 100644
index 0000000..41a9004
--- /dev/null
+++ b/libc/arch-mips/include/machine/endian.h
@@ -0,0 +1,70 @@
+/*	$OpenBSD: endian.h,v 1.5 2006/02/27 23:35:59 miod Exp $ */
+
+/*
+ * Copyright (c) 2001-2002 Opsycon AB  (www.opsycon.se / www.opsycon.com)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#ifndef _MIPS64_ENDIAN_H_
+#define _MIPS64_ENDIAN_H_
+
+#ifdef __GNUC__
+
+#if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
+#define __swap16md(x) ({					\
+    register uint16_t _x = (x);					\
+    register uint16_t _r;					\
+    __asm volatile ("wsbh %0, %1" : "=r" (_r) : "r" (_x));	\
+    _r;								\
+})
+
+#define __swap32md(x) ({					\
+    register uint32_t _x = (x);					\
+    register uint32_t _r;					\
+    __asm volatile ("wsbh %0, %1; rotr %0, %0, 16" : "=r" (_r) : "r" (_x)); \
+    _r;								\
+})
+
+#define __swap64md(x) ({					\
+    uint64_t _swap64md_x = (x);					\
+    (uint64_t) __swap32md(_swap64md_x >> 32) |			\
+        (uint64_t) __swap32md(_swap64md_x & 0xffffffff) << 32;	\
+})
+
+/* Tell sys/endian.h we have MD variants of the swap macros.  */
+#define MD_SWAP
+
+#endif  /* __mips32r2__ */
+#endif  /* __GNUC__ */
+
+#if defined(__MIPSEB__)
+#define _BYTE_ORDER _BIG_ENDIAN
+#else
+#define _BYTE_ORDER _LITTLE_ENDIAN
+#endif
+#define __STRICT_ALIGNMENT
+#include <sys/types.h>
+#include <sys/endian.h>
+
+#endif /* _MIPS64_ENDIAN_H_ */
diff --git a/libc/arch-mips/syscalls.mk b/libc/arch-mips/syscalls.mk
index 263f307..7e40c2e 100644
--- a/libc/arch-mips/syscalls.mk
+++ b/libc/arch-mips/syscalls.mk
@@ -153,6 +153,7 @@
 syscall_src += arch-mips/syscalls/__rt_sigprocmask.S
 syscall_src += arch-mips/syscalls/__rt_sigtimedwait.S
 syscall_src += arch-mips/syscalls/sigpending.S
+syscall_src += arch-mips/syscalls/signalfd4.S
 syscall_src += arch-mips/syscalls/socket.S
 syscall_src += arch-mips/syscalls/socketpair.S
 syscall_src += arch-mips/syscalls/bind.S
diff --git a/libc/arch-mips/syscalls/signalfd4.S b/libc/arch-mips/syscalls/signalfd4.S
new file mode 100644
index 0000000..7e4082c
--- /dev/null
+++ b/libc/arch-mips/syscalls/signalfd4.S
@@ -0,0 +1,22 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+    .text
+    .globl signalfd4
+    .align 4
+    .ent signalfd4
+
+signalfd4:
+    .set noreorder
+    .cpload $t9
+    li $v0, __NR_signalfd4
+    syscall
+    bnez $a3, 1f
+    move $a0, $v0
+    j $ra
+    nop
+1:
+    la $t9,__set_errno
+    j $t9
+    nop
+    .set reorder
+    .end signalfd4
diff --git a/libc/arch-x86/bionic/__dso_handle.S b/libc/arch-x86/bionic/__dso_handle.S
deleted file mode 100644
index 3e80128..0000000
--- a/libc/arch-x86/bionic/__dso_handle.S
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-# The __dso_handle global variable is used by static
-# C++ constructors and destructors in the binary.
-# See http://www.codesourcery.com/public/cxx-abi/abi.html#dso-dtor
-#
-        .section .bss
-        .align 4
-
-#ifndef CRT_LEGACY_WORKAROUND
-	.hidden __dso_handle
-#endif
-
-        .globl __dso_handle
-__dso_handle:
-        .long 0
diff --git a/libc/arch-x86/bionic/__dso_handle_so.S b/libc/arch-x86/bionic/__dso_handle_so.S
deleted file mode 100644
index 77a5d7f..0000000
--- a/libc/arch-x86/bionic/__dso_handle_so.S
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-# The __dso_handle global variable is used by static
-# C++ constructors and destructors in the binary.
-# See http://www.codesourcery.com/public/cxx-abi/abi.html#dso-dtor
-#
-	.data
-        .align 4
-	.hidden __dso_handle
-        .globl __dso_handle
-__dso_handle:
-        .long __dso_handle
diff --git a/libc/arch-x86/bionic/__get_sp.S b/libc/arch-x86/bionic/__get_sp.S
index aeaaa66..0739d79 100644
--- a/libc/arch-x86/bionic/__get_sp.S
+++ b/libc/arch-x86/bionic/__get_sp.S
@@ -25,11 +25,10 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-    .text
-    .type __get_sp, @function
-    .global __get_sp
-    .align 4
 
-__get_sp:
-    mov  %esp, %eax
-    ret
+#include <machine/asm.h>
+
+ENTRY(__get_sp)
+  mov  %esp, %eax
+  ret
+END(__get_sp)
diff --git a/libc/arch-x86/bionic/__stack_chk_fail_local.S b/libc/arch-x86/bionic/__stack_chk_fail_local.S
deleted file mode 100644
index 59fe86e..0000000
--- a/libc/arch-x86/bionic/__stack_chk_fail_local.S
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-/*
- * Contributed by: Intel Corporation
- */
-
-	.text
-	.p2align 4,,15
-	.globl	__stack_chk_fail_local
-	.hidden	__stack_chk_fail_local
-	.type	__stack_chk_fail_local, @function
-
-__stack_chk_fail_local:
-#ifdef __PIC__
-	pushl	%ebx
-	call	__x86.get_pc_thunk.bx
-	addl	$_GLOBAL_OFFSET_TABLE_, %ebx
-	call	__stack_chk_fail@PLT
-#else /* PIC */
-	jmp   __stack_chk_fail
-#endif /* not PIC */
-
-	.size	__stack_chk_fail_local, .-__stack_chk_fail_local
diff --git a/libc/arch-x86/bionic/__stack_chk_fail_local.h b/libc/arch-x86/bionic/__stack_chk_fail_local.h
new file mode 100755
index 0000000..4f3699a
--- /dev/null
+++ b/libc/arch-x86/bionic/__stack_chk_fail_local.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+/*
+   __stack_chk_fail routine is runtime part of stack protector compiler
+   feature. It's implemented in libc and represents die routine when stack
+   corruption is detected.
+
+   Calls are generated by compiler and injected into user functions when
+   -fstack-protector* options are used.
+
+   __stack_chk_fail_local is wrapper for __stack_chk_fail. Compiler generates
+   wrapper calls instead for PIC code only and only on IA32 for optimization
+   purpose (see gcc/config/i386/i386.c). Wrapper body is always included into
+   executable or library. This is the idea of optimization.
+
+   Glibc is doing this via libc_nonshared.a which is linked automatically
+   everytime with libc.so. In bionic we have to bring it within crtfiles
+   because libc.so is real library and not a link script like libc.so at glibc.
+
+   For x86_64 or non-PIC code compiler always generates __stack_chk_fail calls.
+*/
+
+#ifdef __i386__
+#ifdef __PIC__
+extern void __stack_chk_fail();
+
+__attribute__ ((visibility ("hidden")))
+void __stack_chk_fail_local()
+{
+  __stack_chk_fail();
+}
+#endif
+#endif
diff --git a/libc/arch-x86/bionic/_exit_with_stack_teardown.S b/libc/arch-x86/bionic/_exit_with_stack_teardown.S
index 83a504d..e2bb6ad 100644
--- a/libc/arch-x86/bionic/_exit_with_stack_teardown.S
+++ b/libc/arch-x86/bionic/_exit_with_stack_teardown.S
@@ -1,15 +1,8 @@
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-.text
-.type _exit_with_stack_teardown, @function
-.globl _exit_with_stack_teardown
-.align 4
-
-/*
- * void _exit_with_stack_teardown(void *stackBase, int stackSize, int *retCode) 
- */
-
-_exit_with_stack_teardown:
+// void _exit_with_stack_teardown(void *stackBase, int stackSize, int *retCode)
+ENTRY(_exit_with_stack_teardown)
     /* we can trash %ebx here since this call should never return. */
     /* We can also take advantage of the fact that the linux syscall trap
      * handler saves all the registers, so we don't need a stack to keep
@@ -32,3 +25,4 @@
      * that presently, 'hlt' will cause the program to segfault.. but this
      * should never happen :) */
     hlt
+END(_exit_with_stack_teardown)
diff --git a/libc/arch-x86/bionic/_setjmp.S b/libc/arch-x86/bionic/_setjmp.S
index ac62635..9221138 100644
--- a/libc/arch-x86/bionic/_setjmp.S
+++ b/libc/arch-x86/bionic/_setjmp.S
@@ -54,6 +54,7 @@
 	movl	%edi,20(%eax)
 	xorl	%eax,%eax
 	ret
+END(_setjmp)
 
 ENTRY(_longjmp)
 	movl	4(%esp),%edx
@@ -69,3 +70,4 @@
 	incl	%eax
 1:	movl	%ecx,0(%esp)
 	ret
+END(_longjmp)
diff --git a/libc/arch-x86/bionic/atexit.S b/libc/arch-x86/bionic/atexit.S
deleted file mode 100644
index b28f40b..0000000
--- a/libc/arch-x86/bionic/atexit.S
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-	.text
-	.p2align 4,,15
-	.globl	atexit
-	.hidden	atexit
-	.type	atexit, @function
-atexit:
-	pushl	%ebp
-	movl	%esp, %ebp
-	pushl	%ebx
-	call	__x86.get_pc_thunk.bx
-	addl	$_GLOBAL_OFFSET_TABLE_, %ebx
-	subl	$20, %esp
-	movl	$0, 4(%esp)
-	movl	__dso_handle@GOTOFF(%ebx), %eax
-	movl	%eax, 8(%esp)
-	movl	8(%ebp), %eax
-	movl	%eax, (%esp)
-	call	__cxa_atexit@PLT
-	addl	$20, %esp
-	popl	%ebx
-	popl	%ebp
-	ret
-	.size	atexit, .-atexit
-
-	.section	.text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
-	.globl	__x86.get_pc_thunk.bx
-	.hidden	__x86.get_pc_thunk.bx
-	.type	__x86.get_pc_thunk.bx, @function
-__x86.get_pc_thunk.bx:
-	nop
-	nop
-	nop
-	nop
-	nop
-	nop
-	nop
-	nop
-	movl	(%esp), %ebx
-	ret
diff --git a/libc/arch-x86/bionic/atexit.h b/libc/arch-x86/bionic/atexit.h
new file mode 100644
index 0000000..bc776a8
--- /dev/null
+++ b/libc/arch-x86/bionic/atexit.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+extern void *__dso_handle;
+
+__attribute__ ((visibility ("hidden")))
+int atexit(void (*func)(void))
+{
+  return (__cxa_atexit((void (*)(void *))func, (void *)0, &__dso_handle));
+}
diff --git a/libc/arch-x86/bionic/clone.S b/libc/arch-x86/bionic/clone.S
index 54b6ef2..80e3c75 100644
--- a/libc/arch-x86/bionic/clone.S
+++ b/libc/arch-x86/bionic/clone.S
@@ -1,15 +1,8 @@
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-.text
-
-/*
- * int  __pthread_clone(int (*fn)(void*), void *tls, int flags,
- *                      void *arg);
- */
-.globl __pthread_clone
-.type __pthread_clone, @function
-.align 4
-__pthread_clone:
+// int  __pthread_clone(void* (*fn)(void*), void* tls, int flags, void* arg);
+ENTRY(__pthread_clone)
         pushl   %ebx
         pushl   %ecx
         movl    16(%esp), %ecx
@@ -28,30 +21,37 @@
 
         subl    $16, %ecx
         movl    20(%esp), %ebx
+
+        # make system call
         movl    $__NR_clone, %eax
         int     $0x80
-        test    %eax, %eax
-        jns     1f
+
+        cmpl    $0, %eax
+        je      pc_child
+        jg      pc_parent
 
         # an error occurred, set errno and return -1
         negl    %eax
+        pushl   %eax
         call    __set_errno
+        addl    $4, %esp
         orl     $-1, %eax
-        jmp     2f
+        jmp     pc_return
 
-1:
-        jnz     2f
-
+pc_child:
         # we're in the child thread now, call __thread_entry
         # with the appropriate arguments on the child stack
         # we already placed most of them
         call    __thread_entry
         hlt
 
-2:
+pc_parent:
+        # we're the parent; nothing to do.
+pc_return:
         popl    %ecx
         popl    %ebx
         ret
+END(__pthread_clone)
 
 
 /*
@@ -63,11 +63,7 @@
  *                     int           (*fn)(void *),
  *                     void          *arg);
  */
-.text
-.globl __bionic_clone
-.type __bionic_clone, @function
-.align 4
-__bionic_clone:
+ENTRY(__bionic_clone)
         pushl   %ebx
         pushl   %esi
         pushl   %edi
@@ -85,28 +81,35 @@
         movl    24(%esp), %edx
         movl    32(%esp), %esi
         movl    28(%esp), %edi
+
+        # make system call
         movl    $__NR_clone, %eax
         int     $0x80
-        test    %eax, %eax
-        jns     1f
+
+        cmpl    $0, %eax
+        je      bc_child
+        jg      bc_parent
 
         # an error occurred, set errno and return -1
         negl    %eax
+        pushl   %eax
         call    __set_errno
+        addl    $4, %esp
         orl     $-1, %eax
-        jmp     2f
+        jmp     bc_return
 
-1:
-        jnz     2f
-
+bc_child:
         # we're in the child now, call __bionic_clone_entry
         # with the appropriate arguments on the child stack
         # we already placed most of them
         call    __bionic_clone_entry
         hlt
 
-2:
+bc_parent:
+        # we're the parent; nothing to do.
+bc_return:
         popl    %edi
         popl    %esi
         popl    %ebx
         ret
+END(__bionic_clone)
diff --git a/libc/arch-x86/bionic/crtbegin.S b/libc/arch-x86/bionic/crtbegin.S
deleted file mode 100644
index 39b6af0..0000000
--- a/libc/arch-x86/bionic/crtbegin.S
+++ /dev/null
@@ -1,138 +0,0 @@
-# bionic/arch-x86/bionic/crtbegin_dynamic.S
-#
-# Copyright 2006, The Android Open Source Project
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#     * Redistributions of source code must retain the above copyright
-#       notice, this list of conditions and the following disclaimer.
-#     * Redistributions in binary form must reproduce the above copyright
-#       notice, this list of conditions and the following disclaimer in the
-#       documentation and/or other materials provided with the distribution.
-#     * Neither the name of Google Inc. nor the names of its contributors may
-#       be used to endorse or promote products derived from this software
-#       without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY Google Inc. ``AS IS'' AND ANY EXPRESS OR 
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 
-# EVENT SHALL Google Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
-# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
-# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
-# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-	.text
-	.align 4
-	.type _start, @function
-	.globl _start
-
-# this is the small startup code that is first run when
-# any executable that is linked with Bionic runs.
-#
-# it's purpose is to call __libc_init with appropriate
-# arguments, which are:
-#
-#    - the address of the raw data block setup by the Linux
-#      kernel ELF loader
-#
-#    - address of an "onexit" function, not used on any
-#      platform supported by Bionic
-#
-#    - address of the "main" function of the program. We
-#      can't hard-code it in the adr pseudo instruction
-#      so we use a tiny trampoline that will get relocated
-#      by the dynamic linker before this code runs
-#
-#    - address of the constructor list
-#
-_start:	
-        mov     %esp, %eax
-        # before push arguments, align the stack to a 16 byte boundary
-        andl    $~15, %esp
-        mov     $1f, %edx
-        pushl   %edx
-        mov     $0f, %edx
-        pushl   %edx
-        mov     $0, %edx
-        pushl   %edx
-        pushl   %eax
-        call     __libc_init
-
-0:
-        jmp   main
-
-1:  .long   __PREINIT_ARRAY__
-    .long   __INIT_ARRAY__
-    .long   __FINI_ARRAY__
-
-	.section .preinit_array, "aw"
-	.globl __PREINIT_ARRAY__
-__PREINIT_ARRAY__:
-	.long -1
-
-	.section .init_array, "aw"
-	.globl __INIT_ARRAY__
-__INIT_ARRAY__:
-	.long -1
-	.long	frame_dummy
-
-	.section .fini_array, "aw"
-	.globl __FINI_ARRAY__
-__FINI_ARRAY__:
-	.long -1
-	.long	__do_global_dtors_aux
-
-	.section	.eh_frame,"a",@progbits
-	.align 4
-	.type	__EH_FRAME_BEGIN__, @object
-__EH_FRAME_BEGIN__:
-	.text
-	.p2align 4,,15
-	.type	__do_global_dtors_aux, @function
-__do_global_dtors_aux:
-	pushl	%ebp
-	movl	%esp, %ebp
-	subl	$24, %esp
-	cmpb	$0, completed.4454
-	jne	.L4
-	movl	$__deregister_frame_info_bases, %eax
-	testl	%eax, %eax
-	je	.L3
-	movl	$__EH_FRAME_BEGIN__, (%esp)
-	call	__deregister_frame_info_bases
-.L3:
-	movb	$1, completed.4454
-.L4:
-	leave
-	ret
-	.text
-	.p2align 4,,15
-	.type	frame_dummy, @function
-frame_dummy:
-	pushl	%ebp
-	movl	$__register_frame_info_bases, %eax
-	movl	%esp, %ebp
-	subl	$24, %esp
-	testl	%eax, %eax
-	je	.L7
-	movl	%ebx, 12(%esp)
-	movl	$0, 8(%esp)
-	movl	$object.4466, 4(%esp)
-	movl	$__EH_FRAME_BEGIN__, (%esp)
-	call	__register_frame_info_bases
-.L7:
-	leave
-	ret
-	.local	completed.4454
-	.comm	completed.4454,1,1
-	.local	object.4466
-	.comm	object.4466,24,4
-	.weak	__register_frame_info_bases
-	.weak	__deregister_frame_info_bases
-
-#include "__dso_handle.S"
-#include "atexit.S"
-#include "__stack_chk_fail_local.S"
diff --git a/libc/arch-x86/bionic/crtbegin.c b/libc/arch-x86/bionic/crtbegin.c
new file mode 100755
index 0000000..43e9306
--- /dev/null
+++ b/libc/arch-x86/bionic/crtbegin.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "../../bionic/libc_init_common.h"
+#include <stddef.h>
+#include <stdint.h>
+
+__attribute__ ((section (".preinit_array")))
+void (*__PREINIT_ARRAY__)(void) = (void (*)(void)) -1;
+
+__attribute__ ((section (".init_array")))
+void (*__INIT_ARRAY__)(void) = (void (*)(void)) -1;
+
+__attribute__ ((section (".fini_array")))
+void (*__FINI_ARRAY__)(void) = (void (*)(void)) -1;
+
+__LIBC_HIDDEN__
+__attribute__((force_align_arg_pointer))
+void _start() {
+  structors_array_t array;
+  array.preinit_array = &__PREINIT_ARRAY__;
+  array.init_array = &__INIT_ARRAY__;
+  array.fini_array = &__FINI_ARRAY__;
+
+  void* raw_args = (void*) ((uintptr_t) __builtin_frame_address(0) + sizeof(void*));
+  __libc_init(raw_args, NULL, &main, &array);
+}
+
+#include "__dso_handle.h"
+#include "atexit.h"
+#include "__stack_chk_fail_local.h"
diff --git a/libc/arch-x86/bionic/crtbegin_so.S b/libc/arch-x86/bionic/crtbegin_so.S
deleted file mode 100644
index 99662fe..0000000
--- a/libc/arch-x86/bionic/crtbegin_so.S
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-.section .init_array, "aw"
-.align 4
-.type __INIT_ARRAY__, @object
-.globl __INIT_ARRAY__
-__INIT_ARRAY__:
-    .long -1
-    .long frame_dummy
-
-.section .fini_array, "aw"
-.align 4
-.type __FINI_ARRAY__, @object
-.globl __FINI_ARRAY__
-__FINI_ARRAY__:
-    .long -1
-    .long __do_global_dtors_aux
-
-	.section	.eh_frame,"a",@progbits
-	.align 4
-	.type	__EH_FRAME_BEGIN__, @object
-__EH_FRAME_BEGIN__:
-	.text
-	.p2align 4,,15
-	.type	__do_global_dtors_aux, @function
-__do_global_dtors_aux:
-	pushl	%ebp
-	movl	%esp, %ebp
-	pushl	%ebx
-	call	__x86.get_pc_thunk.bx
-	addl	$_GLOBAL_OFFSET_TABLE_, %ebx
-	subl	$20, %esp
-	cmpb	$0, completed.4454@GOTOFF(%ebx)
-	jne	.L5
-	movl	__dso_handle@GOTOFF(%ebx), %eax
-	movl	%eax, (%esp)
-	call	__cxa_finalize@PLT
-	movl	__deregister_frame_info_bases@GOT(%ebx), %eax
-	testl	%eax, %eax
-	je	.L4
-	leal	__EH_FRAME_BEGIN__@GOTOFF(%ebx), %eax
-	movl	%eax, (%esp)
-	call	__deregister_frame_info_bases@PLT
-.L4:
-	movb	$1, completed.4454@GOTOFF(%ebx)
-.L5:
-	addl	$20, %esp
-	popl	%ebx
-	popl	%ebp
-	ret
-	.text
-	.p2align 4,,15
-	.type	frame_dummy, @function
-frame_dummy:
-	pushl	%ebp
-	movl	%esp, %ebp
-	pushl	%ebx
-	call	__x86.get_pc_thunk.bx
-	addl	$_GLOBAL_OFFSET_TABLE_, %ebx
-	subl	$20, %esp
-	movl	__register_frame_info_bases@GOT(%ebx), %eax
-	testl	%eax, %eax
-	je	.L8
-	leal	object.4469@GOTOFF(%ebx), %eax
-	movl	%eax, 4(%esp)
-	leal	__EH_FRAME_BEGIN__@GOTOFF(%ebx), %eax
-	movl	%ebx, 12(%esp)
-	movl	$0, 8(%esp)
-	movl	%eax, (%esp)
-	call	__register_frame_info_bases@PLT
-.L8:
-	addl	$20, %esp
-	popl	%ebx
-	popl	%ebp
-	ret
-	.local	completed.4454
-	.comm	completed.4454,1,1
-	.local	object.4469
-	.comm	object.4469,24,4
-	.weak	__register_frame_info_bases
-	.weak	__deregister_frame_info_bases
-
-#include "__dso_handle_so.S"
-#include "atexit.S"
-#include "__stack_chk_fail_local.S"
diff --git a/libc/arch-x86/bionic/crtbegin_so.c b/libc/arch-x86/bionic/crtbegin_so.c
new file mode 100755
index 0000000..30de6af
--- /dev/null
+++ b/libc/arch-x86/bionic/crtbegin_so.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+extern void __cxa_finalize(void *);
+extern void *__dso_handle;
+
+__attribute__((visibility("hidden"),destructor))
+void __on_dlclose() {
+  __cxa_finalize(&__dso_handle);
+}
+
+/* CRT_LEGACY_WORKAROUND should only be defined when building
+ * this file as part of the platform's C library.
+ *
+ * The C library already defines a function named 'atexit()'
+ * for backwards compatibility with older NDK-generated binaries.
+ *
+ * For newer ones, 'atexit' is actually embedded in the C
+ * runtime objects that are linked into the final ELF
+ * binary (shared library or executable), and will call
+ * __cxa_atexit() in order to un-register any atexit()
+ * handler when a library is unloaded.
+ *
+ * This function must be global *and* hidden. Only the
+ * code inside the same ELF binary should be able to access it.
+ */
+
+#ifdef CRT_LEGACY_WORKAROUND
+#include "__dso_handle.h"
+#else
+#include "__dso_handle_so.h"
+#include "atexit.h"
+#include "__stack_chk_fail_local.h"
+#endif
diff --git a/libc/arch-x86/bionic/futex_x86.S b/libc/arch-x86/bionic/futex_x86.S
index e98a391..36a28e8 100644
--- a/libc/arch-x86/bionic/futex_x86.S
+++ b/libc/arch-x86/bionic/futex_x86.S
@@ -1,17 +1,11 @@
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
 #define FUTEX_WAIT 0
 #define FUTEX_WAKE 1
 
-
-/*
- * int __futex_wait(volatile void *ftx, int val, const struct timespec *timeout)
- */
-.text
-.globl __futex_wait
-.type __futex_wait, @function
-.align 4
-__futex_wait:
+// int __futex_wait(volatile void *ftx, int val, const struct timespec *timeout)
+ENTRY(__futex_wait)
     pushl   %ebx
     pushl   %esi
     mov     12(%esp), %ebx           /* ftx */
@@ -23,15 +17,10 @@
     popl    %esi
     popl    %ebx
     ret
+END(__futex_wait)
 
-
-/* int __futex_wake(volatile void *ftx, int count) */
-
-.text
-.globl __futex_wake
-.type __futex_wake, @function
-.align 4
-__futex_wake:
+// int __futex_wake(volatile void *ftx, int count)
+ENTRY(__futex_wake)
     pushl   %ebx
     mov     8(%esp), %ebx            /* ftx */
     movl    $FUTEX_WAKE, %ecx
@@ -40,13 +29,10 @@
     int     $0x80
     popl    %ebx
     ret
+END(__futex_wake)
 
-/* int __futex_syscall3(volatile void *ftx, int op, int count) */
-.text
-.globl __futex_syscall3
-.type __futex_syscall3, @function
-.align 4
-__futex_syscall3:
+// int __futex_syscall3(volatile void *ftx, int op, int count)
+ENTRY(__futex_syscall3)
     pushl   %ebx
     movl    8(%esp), %ebx      /* ftx */
     movl    12(%esp), %ecx      /* op */
@@ -55,13 +41,10 @@
     int     $0x80
     popl    %ebx
     ret
+END(__futex_syscall3)
 
-/* int __futex_syscall4(volatile void *ftx, int op, int val, const struct timespec *timeout) */
-.text
-.globl __futex_syscall4
-.type __futex_syscall4, @function
-.align 4
-__futex_syscall4:
+// int __futex_syscall4(volatile void *ftx, int op, int val, const struct timespec *timeout)
+ENTRY(__futex_syscall4)
     pushl   %ebx
     pushl   %esi
     movl    12(%esp), %ebx      /* ftx */
@@ -73,3 +56,4 @@
     popl    %esi
     popl    %ebx
     ret
+END(__futex_syscall4)
diff --git a/libc/arch-x86/bionic/setjmp.S b/libc/arch-x86/bionic/setjmp.S
index bcb5f9d..c0df647 100644
--- a/libc/arch-x86/bionic/setjmp.S
+++ b/libc/arch-x86/bionic/setjmp.S
@@ -52,7 +52,7 @@
 	call	_C_LABEL(sigblock)
 #endif
 	addl	$4,%esp
-	PIC_EPILOGUE 
+	PIC_EPILOGUE
 
 	movl	4(%esp),%ecx
 	movl	0(%esp),%edx
@@ -65,6 +65,7 @@
 	movl	%eax,24(%ecx)
 	xorl	%eax,%eax
 	ret
+END(setjmp)
 
 ENTRY(longjmp)
 	movl	4(%esp),%edx
@@ -76,7 +77,7 @@
 	call	_C_LABEL(sigsetmask)
 #endif
 	addl	$4,%esp
-	PIC_EPILOGUE 
+	PIC_EPILOGUE
 
 	movl	4(%esp),%edx
 	movl	8(%esp),%eax
@@ -91,3 +92,4 @@
 	incl	%eax
 1:	movl	%ecx,0(%esp)
 	ret
+END(longjmp)
diff --git a/libc/arch-x86/bionic/sigsetjmp.S b/libc/arch-x86/bionic/sigsetjmp.S
index c990a05..70cc6db 100644
--- a/libc/arch-x86/bionic/sigsetjmp.S
+++ b/libc/arch-x86/bionic/sigsetjmp.S
@@ -61,6 +61,7 @@
 	movl	%edi,20(%ecx)
 	xorl	%eax,%eax
 	ret
+END(sigsetjmp)
 
 ENTRY(siglongjmp)
 	movl	4(%esp),%edx
@@ -90,3 +91,4 @@
 	incl	%eax
 2:	movl	%ecx,0(%esp)
 	ret
+END(siglongjmp)
diff --git a/libc/arch-x86/bionic/syscall.S b/libc/arch-x86/bionic/syscall.S
index 49d6f8d..ef816b6 100644
--- a/libc/arch-x86/bionic/syscall.S
+++ b/libc/arch-x86/bionic/syscall.S
@@ -10,14 +10,10 @@
  *	%ebp: arg5                -   callee save
  */
 
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type syscall, @function
-    .globl syscall
-    .align 4
-
-syscall:
+ENTRY(syscall)
     # Push the callee save registers.
     push    %ebx
     push    %esi
@@ -53,3 +49,4 @@
     pop    %esi
     pop    %ebx
     ret
+END(syscall)
diff --git a/libc/arch-x86/bionic/vfork.S b/libc/arch-x86/bionic/vfork.S
index 53910ab..235be0c 100644
--- a/libc/arch-x86/bionic/vfork.S
+++ b/libc/arch-x86/bionic/vfork.S
@@ -1,3 +1,4 @@
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
 #ifndef __NR_vfork
@@ -5,17 +6,12 @@
 #endif
 
 
-    .text
-    .type vfork, @function
-    .globl vfork
-    .align 4
-
 /* Get rid of the stack modifications (popl/ret) after vfork() success.
  * vfork is VERY sneaky. One has to be very careful about what can be done
  * between a successful vfork and a a subsequent execve()
  */
 
-vfork:
+ENTRY(vfork)
     /* grab the return address */
     popl    %ecx
     movl    $__NR_vfork, %eax
@@ -28,3 +24,4 @@
     orl     $-1, %eax
 1:
     jmp     *%ecx
+END(vfork)
diff --git a/libc/arch-x86/include/endian.h b/libc/arch-x86/include/endian.h
deleted file mode 100644
index 4a70536..0000000
--- a/libc/arch-x86/include/endian.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*	$OpenBSD: endian.h,v 1.14 2005/12/13 00:35:23 millert Exp $	*/
-
-/*-
- * Copyright (c) 1997 Niklas Hallqvist.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _I386_ENDIAN_H_
-#define _I386_ENDIAN_H_
-
-#ifdef __GNUC__
-
-#if defined(_KERNEL) && !defined(I386_CPU)
-#define	__swap32md(x) ({						\
-	uint32_t __swap32md_x = (x);					\
-									\
-	__asm ("bswap %1" : "+r" (__swap32md_x));			\
-	__swap32md_x;							\
-})
-#else
-#define	__swap32md(x) ({						\
-	uint32_t __swap32md_x = (x);					\
-									\
-	__asm ("rorw $8, %w1; rorl $16, %1; rorw $8, %w1" :		\
-	    "+r" (__swap32md_x));					\
-	__swap32md_x;							\
-})
-#endif	/* _KERNEL && !I386_CPU */
-
-#define	__swap64md(x) ({						\
-	uint64_t __swap64md_x = (x);					\
-									\
-	(uint64_t)__swap32md(__swap64md_x >> 32) |			\
-	    (uint64_t)__swap32md(__swap64md_x & 0xffffffff) << 32;	\
-})
-#define	__swap16md(x) ({						\
-	uint16_t __swap16md_x = (x);					\
-									\
-	__asm ("rorw $8, %w1" : "+r" (__swap16md_x));			\
-	__swap16md_x;							\
-})
-
-/* Tell sys/endian.h we have MD variants of the swap macros.  */
-#define MD_SWAP
-
-#endif	/* __GNUC__ */
-
-#define _BYTE_ORDER _LITTLE_ENDIAN
-#include <sys/endian.h>
-
-#endif /* _I386_ENDIAN_H_ */
diff --git a/libc/arch-x86/include/machine/_types.h b/libc/arch-x86/include/machine/_types.h
index d3d9eeb..3806f78 100644
--- a/libc/arch-x86/include/machine/_types.h
+++ b/libc/arch-x86/include/machine/_types.h
@@ -35,29 +35,6 @@
 #ifndef _I386__TYPES_H_
 #define _I386__TYPES_H_
 
-/* the kernel defines size_t as unsigned int, but g++ wants it to be unsigned long */
-#ifndef _SIZE_T_DEFINED_
-#  define _SIZE_T_DEFINED_
-#  ifdef __ANDROID__
-     typedef unsigned int  size_t;
-#  else
-     typedef unsigned long  size_t;
-#  endif
-#endif
-#if !defined(_SSIZE_T) && !defined(_SSIZE_T_DEFINED_)
-#define _SSIZE_T
-#define _SSIZE_T_DEFINED_
-typedef long int       ssize_t;
-#endif
-#ifndef _PTRDIFF_T
-#define _PTRDIFF_T
-#  ifdef __ANDROID__
-     typedef int            ptrdiff_t;
-#  else
-     typedef long           ptrdiff_t;
-#  endif
-#endif
-
 /* 7.18.1.1 Exact-width integer types */
 typedef	__signed char		__int8_t;
 typedef	unsigned char		__uint8_t;
@@ -110,6 +87,8 @@
 /* Standard system types */
 typedef int			__clock_t;
 typedef int			__clockid_t;
+typedef double			__double_t;
+typedef float			__float_t;
 typedef long			__ptrdiff_t;
 typedef	int			__time_t;
 typedef int			__timer_t;
diff --git a/libc/arch-x86/include/machine/asm.h b/libc/arch-x86/include/machine/asm.h
index 49d3ea8..2e8d298 100644
--- a/libc/arch-x86/include/machine/asm.h
+++ b/libc/arch-x86/include/machine/asm.h
@@ -1,5 +1,4 @@
-/*	$OpenBSD: asm.h,v 1.8 2004/06/13 21:49:16 niklas Exp $	*/
-/*	$NetBSD: asm.h,v 1.7 1994/10/27 04:15:56 cgd Exp $	*/
+/*	$NetBSD: asm.h,v 1.40 2011/06/16 13:16:20 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -38,24 +37,17 @@
 #ifndef _I386_ASM_H_
 #define _I386_ASM_H_
 
-/* This is borrowed from FreeBSD /src/sys/i386/include/asmacros.h v1.27 */
-/*
- * CNAME and HIDENAME manage the relationship between symbol names in C
- * and the equivalent assembly language names.  CNAME is given a name as
- * it would be used in a C program.  It expands to the equivalent assembly
- * language name.  HIDENAME is given an assembly-language name, and expands
- * to a possibly-modified form that will be invisible to C programs.
- */
-#define CNAME(csym)             csym
-#define HIDENAME(asmsym)        .asmsym
+#ifdef _KERNEL_OPT
+#include "opt_multiprocessor.h"
+#endif
 
 #ifdef PIC
 #define PIC_PROLOGUE	\
 	pushl	%ebx;	\
-	call	666f;	\
-666:			\
+	call	1f;	\
+1:			\
 	popl	%ebx;	\
-	addl	$_C_LABEL(_GLOBAL_OFFSET_TABLE_)+[.-666b], %ebx
+	addl	$_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
 #define PIC_EPILOGUE	\
 	popl	%ebx
 #define PIC_PLT(x)	x@PLT
@@ -69,10 +61,18 @@
 #define PIC_GOTOFF(x)	x
 #endif
 
-#define _C_LABEL(name)	name
+#ifdef __ELF__
+# define _C_LABEL(x)	x
+#else
+# ifdef __STDC__
+#  define _C_LABEL(x)	_ ## x
+# else
+#  define _C_LABEL(x)	_/**/x
+# endif
+#endif
 #define	_ASM_LABEL(x)	x
 
-#define CVAROFF(x, y)	_C_LABEL(x) + y
+#define CVAROFF(x, y)		_C_LABEL(x) + y
 
 #ifdef __STDC__
 # define __CONCAT(x,y)	x ## y
@@ -82,53 +82,137 @@
 # define __STRING(x)	"x"
 #endif
 
-/*
- * WEAK ALIAS: create a weak alias
- */
-#define WEAK_ALIAS(alias,sym) \
-	.weak alias; \
-	alias = sym
-
-/*
- * WARN_REFERENCES: create a warning if the specified symbol is referenced
- */
-#define WARN_REFERENCES(_sym,_msg)	\
-	.section .gnu.warning. ## _sym ; .ascii _msg ; .text
-
 /* let kernels and others override entrypoint alignment */
-#ifndef _ALIGN_TEXT
-# define _ALIGN_TEXT .align 2, 0x90
+#if !defined(_ALIGN_TEXT) && !defined(_KERNEL)
+# ifdef _STANDALONE
+#  define _ALIGN_TEXT .align 1
+# elif defined __ELF__
+#  define _ALIGN_TEXT .align 16
+# else
+#  define _ALIGN_TEXT .align 4
+# endif
 #endif
 
 #define _ENTRY(x) \
 	.text; _ALIGN_TEXT; .globl x; .type x,@function; x:
+#define _LABEL(x) \
+	.globl x; x:
 
-#define _ASM_SIZE(x)    .size x, .-x;
+#ifdef _KERNEL
 
-#define _END(x) \
-	.fnend; \
-	_ASM_SIZE(x)
+#define CPUVAR(off) %fs:__CONCAT(CPU_INFO_,off)
+
+/* XXX Can't use __CONCAT() here, as it would be evaluated incorrectly. */
+#ifdef __ELF__
+#ifdef __STDC__
+#define	IDTVEC(name) \
+	ALIGN_TEXT; .globl X ## name; .type X ## name,@function; X ## name:
+#define	IDTVEC_END(name) \
+	.size X ## name, . - X ## name
+#else 
+#define	IDTVEC(name) \
+	ALIGN_TEXT; .globl X/**/name; .type X/**/name,@function; X/**/name:
+#define	IDTVEC_END(name) \
+	.size X/**/name, . - X/**/name
+#endif /* __STDC__ */ 
+#else 
+#ifdef __STDC__
+#define	IDTVEC(name) \
+	ALIGN_TEXT; .globl _X ## name; .type _X ## name,@function; _X ## name: 
+#define	IDTVEC_END(name) \
+	.size _X ## name, . - _X ## name
+#else
+#define	IDTVEC(name) \
+	ALIGN_TEXT; .globl _X/**/name; .type _X/**/name,@function; _X/**/name:
+#define	IDTVEC_END(name) \
+	.size _X/**/name, . - _X/**/name
+#endif /* __STDC__ */
+#endif /* __ELF__ */
+
+#ifdef _STANDALONE
+#define ALIGN_DATA	.align	4
+#define ALIGN_TEXT	.align	4	/* 4-byte boundaries */
+#define SUPERALIGN_TEXT	.align	16	/* 15-byte boundaries */
+#elif defined __ELF__
+#define ALIGN_DATA	.align	4
+#define ALIGN_TEXT	.align	16	/* 16-byte boundaries */
+#define SUPERALIGN_TEXT	.align	16	/* 16-byte boundaries */
+#else
+#define ALIGN_DATA	.align	2
+#define ALIGN_TEXT	.align	4	/* 16-byte boundaries */
+#define SUPERALIGN_TEXT	.align	4	/* 16-byte boundaries */
+#endif /* __ELF__ */
+
+#define _ALIGN_TEXT ALIGN_TEXT
 
 #ifdef GPROF
-# define _PROF_PROLOGUE	\
+#ifdef __ELF__
+#define	MCOUNT_ASM	call	_C_LABEL(__mcount)
+#else /* __ELF__ */
+#define	MCOUNT_ASM	call	_C_LABEL(mcount)
+#endif /* __ELF__ */
+#else /* GPROF */
+#define	MCOUNT_ASM	/* nothing */
+#endif /* GPROF */
+
+#endif /* _KERNEL */
+
+
+
+#ifdef GPROF
+# ifdef __ELF__
+#  define _PROF_PROLOGUE	\
+	pushl %ebp; movl %esp,%ebp; call PIC_PLT(__mcount); popl %ebp
+# else 
+#  define _PROF_PROLOGUE	\
 	pushl %ebp; movl %esp,%ebp; call PIC_PLT(mcount); popl %ebp
+# endif
 #else
 # define _PROF_PROLOGUE
 #endif
 
 #define	ENTRY(y)	_ENTRY(_C_LABEL(y)); _PROF_PROLOGUE
 #define	NENTRY(y)	_ENTRY(_C_LABEL(y))
-#define	END(y)		_END(_C_LABEL(y))
 #define	ASENTRY(y)	_ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE
-
-#define ENTRY_PRIVATE(y)  ENTRY(y); .hidden _C_LABEL(y)
-
-
-#define	ALTENTRY(name)	.globl _C_LABEL(name); _C_LABEL(name):
+#define	LABEL(y)	_LABEL(_C_LABEL(y))
+#define	END(y)		.size y, . - y
 
 #define	ASMSTR		.asciz
 
+#ifdef __ELF__
+#define RCSID(x)	.pushsection ".ident"; .asciz x; .popsection
+#else
 #define RCSID(x)	.text; .asciz x
-#define __FBSDID(x)     RCSID(x)
+#endif
+
+#ifdef NO_KERNEL_RCSIDS
+#define	__KERNEL_RCSID(_n, _s)	/* nothing */
+#else
+#define	__KERNEL_RCSID(_n, _s)	RCSID(_s)
+#endif
+
+#ifdef __ELF__
+#define	WEAK_ALIAS(alias,sym)						\
+	.weak alias;							\
+	alias = sym
+#endif
+/*
+ * STRONG_ALIAS: create a strong alias.
+ */
+#define STRONG_ALIAS(alias,sym)						\
+	.globl alias;							\
+	alias = sym
+
+#ifdef __STDC__
+#define	WARN_REFERENCES(sym,msg)					\
+	.pushsection .gnu.warning. ## sym;				\
+	.ascii msg;							\
+	.popsection
+#else
+#define	WARN_REFERENCES(sym,msg)					\
+	.pushsection .gnu.warning./**/sym;				\
+	.ascii msg;							\
+	.popsection
+#endif /* __STDC__ */
 
 #endif /* !_I386_ASM_H_ */
diff --git a/libc/arch-x86/include/machine/elf_machdep.h b/libc/arch-x86/include/machine/elf_machdep.h
new file mode 100644
index 0000000..442c561
--- /dev/null
+++ b/libc/arch-x86/include/machine/elf_machdep.h
@@ -0,0 +1,63 @@
+/*	$NetBSD: elf_machdep.h,v 1.10 2009/05/30 05:56:52 skrll Exp $	*/
+
+#define	ELF32_MACHDEP_ENDIANNESS	ELFDATA2LSB
+#define	ELF32_MACHDEP_ID_CASES						\
+		case EM_386:						\
+		case EM_486:						\
+			break;
+
+#define	ELF64_MACHDEP_ENDIANNESS	XXX	/* break compilation */
+#define	ELF64_MACHDEP_ID_CASES						\
+		/* no 64-bit ELF machine types supported */
+
+#define	ELF32_MACHDEP_ID		EM_386
+
+#define ARCH_ELFSIZE		32	/* MD native binary size */
+
+/* i386 relocations */
+#define	R_386_NONE	0
+#define	R_386_32	1
+#define	R_386_PC32	2
+#define	R_386_GOT32	3
+#define	R_386_PLT32	4
+#define	R_386_COPY	5
+#define	R_386_GLOB_DAT	6
+#define	R_386_JMP_SLOT	7
+#define	R_386_RELATIVE	8
+#define	R_386_GOTOFF	9
+#define	R_386_GOTPC	10
+
+/* TLS relocations */
+#define	R_386_TLS_TPOFF	14
+#define	R_386_TLS_IE	15
+#define	R_386_TLS_GOTIE	16
+#define	R_386_TLS_LE	17
+#define	R_386_TLS_GD	18
+#define	R_386_TLS_LDM	19
+
+/* The following relocations are GNU extensions. */
+#define	R_386_16	20
+#define	R_386_PC16	21
+#define	R_386_8		22
+#define	R_386_PC8	23
+
+/* More TLS relocations */
+#define	R_386_TLS_GD_32		24
+#define	R_386_TLS_GD_PUSH	25
+#define	R_386_TLS_GD_CALL	26
+#define	R_386_TLS_GD_POP	27
+#define	R_386_TLS_LDM_32	28
+#define	R_386_TLS_LDM_PUSH	29
+#define	R_386_TLS_LDM_CALL	30
+#define	R_386_TLS_LDM_POP	31
+#define	R_386_TLS_LDO_32	32
+#define	R_386_TLS_IE_32		33
+#define	R_386_TLS_LE_32		34
+#define	R_386_TLS_DTPMOD32	35
+#define	R_386_TLS_DTPOFF32	36
+#define	R_386_TLS_TPOFF32	37
+#define	R_386_TLS_GOTDESC	39
+#define	R_386_TLS_DESC_CALL	40
+#define	R_386_TLS_DESC		41
+
+#define	R_TYPE(name)	__CONCAT(R_386_,name)
diff --git a/libc/arch-x86/include/machine/endian.h b/libc/arch-x86/include/machine/endian.h
new file mode 100644
index 0000000..e7ad257
--- /dev/null
+++ b/libc/arch-x86/include/machine/endian.h
@@ -0,0 +1,71 @@
+/*	$OpenBSD: endian.h,v 1.14 2005/12/13 00:35:23 millert Exp $	*/
+
+/*-
+ * Copyright (c) 1997 Niklas Hallqvist.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _I386_ENDIAN_H_
+#define _I386_ENDIAN_H_
+
+#ifdef __GNUC__
+
+#if defined(_KERNEL) && !defined(I386_CPU)
+#define	__swap32md(x) ({						\
+	uint32_t __swap32md_x = (x);					\
+									\
+	__asm ("bswap %1" : "+r" (__swap32md_x));			\
+	__swap32md_x;							\
+})
+#else
+#define	__swap32md(x) ({						\
+	uint32_t __swap32md_x = (x);					\
+									\
+	__asm ("rorw $8, %w1; rorl $16, %1; rorw $8, %w1" :		\
+	    "+r" (__swap32md_x));					\
+	__swap32md_x;							\
+})
+#endif	/* _KERNEL && !I386_CPU */
+
+#define	__swap64md(x) ({						\
+	uint64_t __swap64md_x = (x);					\
+									\
+	(uint64_t)__swap32md(__swap64md_x >> 32) |			\
+	    (uint64_t)__swap32md(__swap64md_x & 0xffffffff) << 32;	\
+})
+#define	__swap16md(x) ({						\
+	uint16_t __swap16md_x = (x);					\
+									\
+	__asm ("rorw $8, %w1" : "+r" (__swap16md_x));			\
+	__swap16md_x;							\
+})
+
+/* Tell sys/endian.h we have MD variants of the swap macros.  */
+#define MD_SWAP
+
+#endif	/* __GNUC__ */
+
+#define _BYTE_ORDER _LITTLE_ENDIAN
+#include <sys/types.h>
+#include <sys/endian.h>
+
+#endif /* _I386_ENDIAN_H_ */
diff --git a/libc/arch-x86/string/bcmp.S b/libc/arch-x86/string/bcmp.S
deleted file mode 100644
index a5b46ae..0000000
--- a/libc/arch-x86/string/bcmp.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/*	$OpenBSD: bcmp.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */
-/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-
-ENTRY(bcmp)
-	pushl	%edi
-	pushl	%esi
-	movl	12(%esp),%edi
-	movl	16(%esp),%esi
-	xorl	%eax,%eax		/* clear return value */
-	cld				/* set compare direction forward */
-
-	movl	20(%esp),%ecx		/* compare by words */
-	shrl	$2,%ecx
-	repe
-	cmpsl
-	jne	L1
-
-	movl	20(%esp),%ecx		/* compare remainder by bytes */
-	andl	$3,%ecx
-	repe
-	cmpsb
-	je	L2
-
-L1:	incl	%eax
-L2:	popl	%esi
-	popl	%edi
-	ret
diff --git a/libc/arch-x86/string/bzero.S b/libc/arch-x86/string/bzero.S
index 2ec9c7d..c73a351 100644
--- a/libc/arch-x86/string/bzero.S
+++ b/libc/arch-x86/string/bzero.S
@@ -41,3 +41,4 @@
 
 	popl	%edi
 	ret
+END(bzero)
diff --git a/libc/arch-x86/string/ffs.S b/libc/arch-x86/string/ffs.S
new file mode 100644
index 0000000..d819306
--- /dev/null
+++ b/libc/arch-x86/string/ffs.S
@@ -0,0 +1,18 @@
+/*	$OpenBSD: ffs.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+ENTRY(ffs)
+	bsfl	4(%esp),%eax
+	jz	L1	 		/* ZF is set if all bits are 0 */
+	incl	%eax			/* bits numbered from 1, not 0 */
+	ret
+
+	.align 2
+L1:	xorl	%eax,%eax		/* clear result */
+	ret
+END(ffs)
diff --git a/libc/arch-x86/string/fss.S b/libc/arch-x86/string/fss.S
deleted file mode 100644
index 96affab..0000000
--- a/libc/arch-x86/string/fss.S
+++ /dev/null
@@ -1,17 +0,0 @@
-/*	$OpenBSD: ffs.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */
-/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-
-ENTRY(ffs)
-	bsfl	4(%esp),%eax
-	jz	L1	 		/* ZF is set if all bits are 0 */
-	incl	%eax			/* bits numbered from 1, not 0 */
-	ret
-
-	.align 2
-L1:	xorl	%eax,%eax		/* clear result */
-	ret
diff --git a/libc/arch-x86/string/memchr.S b/libc/arch-x86/string/memchr.S
index d6bcbe6..367c7b4 100644
--- a/libc/arch-x86/string/memchr.S
+++ b/libc/arch-x86/string/memchr.S
@@ -24,3 +24,4 @@
 L1:	xorl	%eax,%eax
 	popl	%edi
 	ret
+END(memchr)
diff --git a/libc/arch-x86/string/memcmp.S b/libc/arch-x86/string/memcmp.S
index 1be189a..3b50530 100644
--- a/libc/arch-x86/string/memcmp.S
+++ b/libc/arch-x86/string/memcmp.S
@@ -41,3 +41,4 @@
 	popl	%esi
 	popl	%edi
 	ret
+END(memcmp)
diff --git a/libc/arch-x86/string/memset.S b/libc/arch-x86/string/memset.S
index 1059ccc..62e6a17 100644
--- a/libc/arch-x86/string/memset.S
+++ b/libc/arch-x86/string/memset.S
@@ -53,3 +53,4 @@
 	popl	%ebx
 	popl	%edi
 	ret
+END(memset)
diff --git a/libc/arch-x86/string/rindex.S b/libc/arch-x86/string/rindex.S
deleted file mode 100644
index 0260d38..0000000
--- a/libc/arch-x86/string/rindex.S
+++ /dev/null
@@ -1,29 +0,0 @@
-/*	$OpenBSD: rindex.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */
-/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-
-#ifdef STRRCHR
-ENTRY(strrchr)
-#else
-ENTRY(rindex)
-#endif
-	pushl	%ebx
-	movl	8(%esp),%edx
-	movb	12(%esp),%cl
-	xorl	%eax,%eax		/* init pointer to null */
-	.align 2,0x90
-L1:
-	movb	(%edx),%bl
-	cmpb	%bl,%cl
-	jne	L2
-	movl	%edx,%eax
-L2:
-	incl	%edx
-	testb	%bl,%bl			/* null terminator??? */
-	jnz	L1
-	popl	%ebx
-	ret
diff --git a/libc/arch-x86/string/strcat.S b/libc/arch-x86/string/strcat.S
index 60fdd55..c75f38a 100644
--- a/libc/arch-x86/string/strcat.S
+++ b/libc/arch-x86/string/strcat.S
@@ -71,3 +71,4 @@
 L2:	popl	%eax			/* pop destination address */
 	popl	%edi			/* restore edi */
 	ret
+END(strcat)
diff --git a/libc/arch-x86/string/strcmp.S b/libc/arch-x86/string/strcmp.S
index 22ba546..5d3f4fc 100644
--- a/libc/arch-x86/string/strcmp.S
+++ b/libc/arch-x86/string/strcmp.S
@@ -79,3 +79,4 @@
 	movzbl	(%edx),%edx
 	subl	%edx,%eax
 	ret
+END(strcmp)
diff --git a/libc/arch-x86/string/strcpy.S b/libc/arch-x86/string/strcpy.S
index 341eb6c..7d9b87e 100644
--- a/libc/arch-x86/string/strcpy.S
+++ b/libc/arch-x86/string/strcpy.S
@@ -61,3 +61,4 @@
 	jnz	L1
 L2:	popl	%eax			/* pop dst address */
 	ret
+END(strcpy)
diff --git a/libc/arch-x86/string/strlen.S b/libc/arch-x86/string/strlen.S
index 4f04ffc..527e36a 100644
--- a/libc/arch-x86/string/strlen.S
+++ b/libc/arch-x86/string/strlen.S
@@ -18,3 +18,4 @@
 	leal	-1(%ecx),%eax		/* and subtracting one */
 	popl	%edi
 	ret
+END(strlen)
diff --git a/libc/arch-x86/string/strncmp.S b/libc/arch-x86/string/strncmp.S
index 5aa88d7..6649473 100644
--- a/libc/arch-x86/string/strncmp.S
+++ b/libc/arch-x86/string/strncmp.S
@@ -111,3 +111,4 @@
 L4:	xorl	%eax,%eax
 	popl	%ebx
 	ret
+END(strncmp)
diff --git a/libc/arch-x86/string/strrchr.S b/libc/arch-x86/string/strrchr.S
deleted file mode 100644
index 4ee153f..0000000
--- a/libc/arch-x86/string/strrchr.S
+++ /dev/null
@@ -1,3 +0,0 @@
-/*	$OpenBSD: strrchr.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */
-#define STRRCHR
-#include "rindex.S"
diff --git a/libc/arch-x86/string/swab.S b/libc/arch-x86/string/swab.S
index 3055860..2f6cfb2 100644
--- a/libc/arch-x86/string/swab.S
+++ b/libc/arch-x86/string/swab.S
@@ -65,3 +65,4 @@
 L4:	popl	%edi
 	popl	%esi
 	ret
+END(swab)
diff --git a/libc/arch-x86/syscalls.mk b/libc/arch-x86/syscalls.mk
index 2517ebf..e196c02 100644
--- a/libc/arch-x86/syscalls.mk
+++ b/libc/arch-x86/syscalls.mk
@@ -154,6 +154,7 @@
 syscall_src += arch-x86/syscalls/__rt_sigprocmask.S
 syscall_src += arch-x86/syscalls/__rt_sigtimedwait.S
 syscall_src += arch-x86/syscalls/sigpending.S
+syscall_src += arch-x86/syscalls/signalfd4.S
 syscall_src += arch-x86/syscalls/socket.S
 syscall_src += arch-x86/syscalls/bind.S
 syscall_src += arch-x86/syscalls/connect.S
diff --git a/libc/arch-x86/syscalls/__brk.S b/libc/arch-x86/syscalls/__brk.S
index 235cc4f..f7a81ff 100644
--- a/libc/arch-x86/syscalls/__brk.S
+++ b/libc/arch-x86/syscalls/__brk.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __brk, @function
-    .globl __brk
-    .align 4
-
-__brk:
+ENTRY(__brk)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_brk, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(__brk)
diff --git a/libc/arch-x86/syscalls/__fcntl.S b/libc/arch-x86/syscalls/__fcntl.S
index 377f08e..9f74d86 100644
--- a/libc/arch-x86/syscalls/__fcntl.S
+++ b/libc/arch-x86/syscalls/__fcntl.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __fcntl, @function
-    .globl __fcntl
-    .align 4
-
-__fcntl:
+ENTRY(__fcntl)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__fcntl)
diff --git a/libc/arch-x86/syscalls/__fcntl64.S b/libc/arch-x86/syscalls/__fcntl64.S
index 2ed47fe..c59f490 100644
--- a/libc/arch-x86/syscalls/__fcntl64.S
+++ b/libc/arch-x86/syscalls/__fcntl64.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __fcntl64, @function
-    .globl __fcntl64
-    .align 4
-
-__fcntl64:
+ENTRY(__fcntl64)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__fcntl64)
diff --git a/libc/arch-x86/syscalls/__fork.S b/libc/arch-x86/syscalls/__fork.S
index 4b5d1c6..557714d 100644
--- a/libc/arch-x86/syscalls/__fork.S
+++ b/libc/arch-x86/syscalls/__fork.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __fork, @function
-    .globl __fork
-    .align 4
-
-__fork:
+ENTRY(__fork)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_fork, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(__fork)
diff --git a/libc/arch-x86/syscalls/__fstatfs64.S b/libc/arch-x86/syscalls/__fstatfs64.S
index f755244..9943362 100644
--- a/libc/arch-x86/syscalls/__fstatfs64.S
+++ b/libc/arch-x86/syscalls/__fstatfs64.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __fstatfs64, @function
-    .globl __fstatfs64
-    .align 4
-
-__fstatfs64:
+ENTRY(__fstatfs64)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__fstatfs64)
diff --git a/libc/arch-x86/syscalls/__getcpu.S b/libc/arch-x86/syscalls/__getcpu.S
index 0381799..152f5c8 100644
--- a/libc/arch-x86/syscalls/__getcpu.S
+++ b/libc/arch-x86/syscalls/__getcpu.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __getcpu, @function
-    .globl __getcpu
-    .align 4
-
-__getcpu:
+ENTRY(__getcpu)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__getcpu)
diff --git a/libc/arch-x86/syscalls/__getcwd.S b/libc/arch-x86/syscalls/__getcwd.S
index f2bd520..2e30d9b 100644
--- a/libc/arch-x86/syscalls/__getcwd.S
+++ b/libc/arch-x86/syscalls/__getcwd.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __getcwd, @function
-    .globl __getcwd
-    .align 4
-
-__getcwd:
+ENTRY(__getcwd)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__getcwd)
diff --git a/libc/arch-x86/syscalls/__getpriority.S b/libc/arch-x86/syscalls/__getpriority.S
index 08503d8..a015127 100644
--- a/libc/arch-x86/syscalls/__getpriority.S
+++ b/libc/arch-x86/syscalls/__getpriority.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __getpriority, @function
-    .globl __getpriority
-    .align 4
-
-__getpriority:
+ENTRY(__getpriority)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__getpriority)
diff --git a/libc/arch-x86/syscalls/__ioctl.S b/libc/arch-x86/syscalls/__ioctl.S
index cdde9ab..db85a19 100644
--- a/libc/arch-x86/syscalls/__ioctl.S
+++ b/libc/arch-x86/syscalls/__ioctl.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __ioctl, @function
-    .globl __ioctl
-    .align 4
-
-__ioctl:
+ENTRY(__ioctl)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__ioctl)
diff --git a/libc/arch-x86/syscalls/__llseek.S b/libc/arch-x86/syscalls/__llseek.S
index df49a94..7811f6b 100644
--- a/libc/arch-x86/syscalls/__llseek.S
+++ b/libc/arch-x86/syscalls/__llseek.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __llseek, @function
-    .globl __llseek
-    .align 4
-
-__llseek:
+ENTRY(__llseek)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -33,3 +29,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__llseek)
diff --git a/libc/arch-x86/syscalls/__mmap2.S b/libc/arch-x86/syscalls/__mmap2.S
index fea571f..535a891 100644
--- a/libc/arch-x86/syscalls/__mmap2.S
+++ b/libc/arch-x86/syscalls/__mmap2.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __mmap2, @function
-    .globl __mmap2
-    .align 4
-
-__mmap2:
+ENTRY(__mmap2)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -36,3 +32,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__mmap2)
diff --git a/libc/arch-x86/syscalls/__open.S b/libc/arch-x86/syscalls/__open.S
index df6fd93..b878231 100644
--- a/libc/arch-x86/syscalls/__open.S
+++ b/libc/arch-x86/syscalls/__open.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __open, @function
-    .globl __open
-    .align 4
-
-__open:
+ENTRY(__open)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__open)
diff --git a/libc/arch-x86/syscalls/__openat.S b/libc/arch-x86/syscalls/__openat.S
index aa14927..faf8013 100644
--- a/libc/arch-x86/syscalls/__openat.S
+++ b/libc/arch-x86/syscalls/__openat.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __openat, @function
-    .globl __openat
-    .align 4
-
-__openat:
+ENTRY(__openat)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__openat)
diff --git a/libc/arch-x86/syscalls/__ptrace.S b/libc/arch-x86/syscalls/__ptrace.S
index bec952b..f574cf0 100644
--- a/libc/arch-x86/syscalls/__ptrace.S
+++ b/libc/arch-x86/syscalls/__ptrace.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __ptrace, @function
-    .globl __ptrace
-    .align 4
-
-__ptrace:
+ENTRY(__ptrace)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__ptrace)
diff --git a/libc/arch-x86/syscalls/__reboot.S b/libc/arch-x86/syscalls/__reboot.S
index 6cb74e2..626a955 100644
--- a/libc/arch-x86/syscalls/__reboot.S
+++ b/libc/arch-x86/syscalls/__reboot.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __reboot, @function
-    .globl __reboot
-    .align 4
-
-__reboot:
+ENTRY(__reboot)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__reboot)
diff --git a/libc/arch-x86/syscalls/__rt_sigaction.S b/libc/arch-x86/syscalls/__rt_sigaction.S
index c57f580..ef9893b 100644
--- a/libc/arch-x86/syscalls/__rt_sigaction.S
+++ b/libc/arch-x86/syscalls/__rt_sigaction.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __rt_sigaction, @function
-    .globl __rt_sigaction
-    .align 4
-
-__rt_sigaction:
+ENTRY(__rt_sigaction)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__rt_sigaction)
diff --git a/libc/arch-x86/syscalls/__rt_sigprocmask.S b/libc/arch-x86/syscalls/__rt_sigprocmask.S
index 623331b..930c9b2 100644
--- a/libc/arch-x86/syscalls/__rt_sigprocmask.S
+++ b/libc/arch-x86/syscalls/__rt_sigprocmask.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __rt_sigprocmask, @function
-    .globl __rt_sigprocmask
-    .align 4
-
-__rt_sigprocmask:
+ENTRY(__rt_sigprocmask)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__rt_sigprocmask)
diff --git a/libc/arch-x86/syscalls/__rt_sigtimedwait.S b/libc/arch-x86/syscalls/__rt_sigtimedwait.S
index 8e14a89..ba867f5 100644
--- a/libc/arch-x86/syscalls/__rt_sigtimedwait.S
+++ b/libc/arch-x86/syscalls/__rt_sigtimedwait.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __rt_sigtimedwait, @function
-    .globl __rt_sigtimedwait
-    .align 4
-
-__rt_sigtimedwait:
+ENTRY(__rt_sigtimedwait)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__rt_sigtimedwait)
diff --git a/libc/arch-x86/syscalls/__sched_getaffinity.S b/libc/arch-x86/syscalls/__sched_getaffinity.S
index 43bfa50..2a40b65 100644
--- a/libc/arch-x86/syscalls/__sched_getaffinity.S
+++ b/libc/arch-x86/syscalls/__sched_getaffinity.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __sched_getaffinity, @function
-    .globl __sched_getaffinity
-    .align 4
-
-__sched_getaffinity:
+ENTRY(__sched_getaffinity)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__sched_getaffinity)
diff --git a/libc/arch-x86/syscalls/__set_thread_area.S b/libc/arch-x86/syscalls/__set_thread_area.S
index cd22040..dc4a561 100644
--- a/libc/arch-x86/syscalls/__set_thread_area.S
+++ b/libc/arch-x86/syscalls/__set_thread_area.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __set_thread_area, @function
-    .globl __set_thread_area
-    .align 4
-
-__set_thread_area:
+ENTRY(__set_thread_area)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_set_thread_area, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(__set_thread_area)
diff --git a/libc/arch-x86/syscalls/__setresuid.S b/libc/arch-x86/syscalls/__setresuid.S
index c492dfb..c604984 100644
--- a/libc/arch-x86/syscalls/__setresuid.S
+++ b/libc/arch-x86/syscalls/__setresuid.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __setresuid, @function
-    .globl __setresuid
-    .align 4
-
-__setresuid:
+ENTRY(__setresuid)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__setresuid)
diff --git a/libc/arch-x86/syscalls/__setreuid.S b/libc/arch-x86/syscalls/__setreuid.S
index 111e999..5818739 100644
--- a/libc/arch-x86/syscalls/__setreuid.S
+++ b/libc/arch-x86/syscalls/__setreuid.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __setreuid, @function
-    .globl __setreuid
-    .align 4
-
-__setreuid:
+ENTRY(__setreuid)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__setreuid)
diff --git a/libc/arch-x86/syscalls/__setuid.S b/libc/arch-x86/syscalls/__setuid.S
index 1e5f285..df578b8 100644
--- a/libc/arch-x86/syscalls/__setuid.S
+++ b/libc/arch-x86/syscalls/__setuid.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __setuid, @function
-    .globl __setuid
-    .align 4
-
-__setuid:
+ENTRY(__setuid)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_setuid32, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(__setuid)
diff --git a/libc/arch-x86/syscalls/__sigsuspend.S b/libc/arch-x86/syscalls/__sigsuspend.S
index 64de756..b09f872 100644
--- a/libc/arch-x86/syscalls/__sigsuspend.S
+++ b/libc/arch-x86/syscalls/__sigsuspend.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __sigsuspend, @function
-    .globl __sigsuspend
-    .align 4
-
-__sigsuspend:
+ENTRY(__sigsuspend)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__sigsuspend)
diff --git a/libc/arch-x86/syscalls/__statfs64.S b/libc/arch-x86/syscalls/__statfs64.S
index a0685b7..4f46bd7 100644
--- a/libc/arch-x86/syscalls/__statfs64.S
+++ b/libc/arch-x86/syscalls/__statfs64.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __statfs64, @function
-    .globl __statfs64
-    .align 4
-
-__statfs64:
+ENTRY(__statfs64)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__statfs64)
diff --git a/libc/arch-x86/syscalls/__sys_clone.S b/libc/arch-x86/syscalls/__sys_clone.S
index 172d6af..a5ce170 100644
--- a/libc/arch-x86/syscalls/__sys_clone.S
+++ b/libc/arch-x86/syscalls/__sys_clone.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __sys_clone, @function
-    .globl __sys_clone
-    .align 4
-
-__sys_clone:
+ENTRY(__sys_clone)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -33,3 +29,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__sys_clone)
diff --git a/libc/arch-x86/syscalls/__syslog.S b/libc/arch-x86/syscalls/__syslog.S
index 3982db4..9d36779 100644
--- a/libc/arch-x86/syscalls/__syslog.S
+++ b/libc/arch-x86/syscalls/__syslog.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __syslog, @function
-    .globl __syslog
-    .align 4
-
-__syslog:
+ENTRY(__syslog)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__syslog)
diff --git a/libc/arch-x86/syscalls/__timer_create.S b/libc/arch-x86/syscalls/__timer_create.S
index 66b0cea..b319f1b 100644
--- a/libc/arch-x86/syscalls/__timer_create.S
+++ b/libc/arch-x86/syscalls/__timer_create.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __timer_create, @function
-    .globl __timer_create
-    .align 4
-
-__timer_create:
+ENTRY(__timer_create)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__timer_create)
diff --git a/libc/arch-x86/syscalls/__timer_delete.S b/libc/arch-x86/syscalls/__timer_delete.S
index 4344d08..7fb5930 100644
--- a/libc/arch-x86/syscalls/__timer_delete.S
+++ b/libc/arch-x86/syscalls/__timer_delete.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __timer_delete, @function
-    .globl __timer_delete
-    .align 4
-
-__timer_delete:
+ENTRY(__timer_delete)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_timer_delete, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(__timer_delete)
diff --git a/libc/arch-x86/syscalls/__timer_getoverrun.S b/libc/arch-x86/syscalls/__timer_getoverrun.S
index 4371415..477a3d8 100644
--- a/libc/arch-x86/syscalls/__timer_getoverrun.S
+++ b/libc/arch-x86/syscalls/__timer_getoverrun.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __timer_getoverrun, @function
-    .globl __timer_getoverrun
-    .align 4
-
-__timer_getoverrun:
+ENTRY(__timer_getoverrun)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_timer_getoverrun, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(__timer_getoverrun)
diff --git a/libc/arch-x86/syscalls/__timer_gettime.S b/libc/arch-x86/syscalls/__timer_gettime.S
index 3923b0a..ee5604d 100644
--- a/libc/arch-x86/syscalls/__timer_gettime.S
+++ b/libc/arch-x86/syscalls/__timer_gettime.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __timer_gettime, @function
-    .globl __timer_gettime
-    .align 4
-
-__timer_gettime:
+ENTRY(__timer_gettime)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__timer_gettime)
diff --git a/libc/arch-x86/syscalls/__timer_settime.S b/libc/arch-x86/syscalls/__timer_settime.S
index cabb7df..9758f61 100644
--- a/libc/arch-x86/syscalls/__timer_settime.S
+++ b/libc/arch-x86/syscalls/__timer_settime.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __timer_settime, @function
-    .globl __timer_settime
-    .align 4
-
-__timer_settime:
+ENTRY(__timer_settime)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__timer_settime)
diff --git a/libc/arch-x86/syscalls/__wait4.S b/libc/arch-x86/syscalls/__wait4.S
index 75ffb95..23165a3 100644
--- a/libc/arch-x86/syscalls/__wait4.S
+++ b/libc/arch-x86/syscalls/__wait4.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __wait4, @function
-    .globl __wait4
-    .align 4
-
-__wait4:
+ENTRY(__wait4)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__wait4)
diff --git a/libc/arch-x86/syscalls/__waitid.S b/libc/arch-x86/syscalls/__waitid.S
index 4dd8c11..12f1ac8 100644
--- a/libc/arch-x86/syscalls/__waitid.S
+++ b/libc/arch-x86/syscalls/__waitid.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __waitid, @function
-    .globl __waitid
-    .align 4
-
-__waitid:
+ENTRY(__waitid)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -33,3 +29,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(__waitid)
diff --git a/libc/arch-x86/syscalls/_exit.S b/libc/arch-x86/syscalls/_exit.S
index 21aa49f..e17f925 100644
--- a/libc/arch-x86/syscalls/_exit.S
+++ b/libc/arch-x86/syscalls/_exit.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type _exit, @function
-    .globl _exit
-    .align 4
-
-_exit:
+ENTRY(_exit)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_exit_group, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(_exit)
diff --git a/libc/arch-x86/syscalls/_exit_thread.S b/libc/arch-x86/syscalls/_exit_thread.S
index 16aaa5b..a371350 100644
--- a/libc/arch-x86/syscalls/_exit_thread.S
+++ b/libc/arch-x86/syscalls/_exit_thread.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type _exit_thread, @function
-    .globl _exit_thread
-    .align 4
-
-_exit_thread:
+ENTRY(_exit_thread)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_exit, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(_exit_thread)
diff --git a/libc/arch-x86/syscalls/_waitpid.S b/libc/arch-x86/syscalls/_waitpid.S
index 7e76496..59bf20e 100644
--- a/libc/arch-x86/syscalls/_waitpid.S
+++ b/libc/arch-x86/syscalls/_waitpid.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type _waitpid, @function
-    .globl _waitpid
-    .align 4
-
-_waitpid:
+ENTRY(_waitpid)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(_waitpid)
diff --git a/libc/arch-x86/syscalls/accept.S b/libc/arch-x86/syscalls/accept.S
index ccd56e7..f5fcb5d 100644
--- a/libc/arch-x86/syscalls/accept.S
+++ b/libc/arch-x86/syscalls/accept.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type accept, @function
-    .globl accept
-    .align 4
-
-accept:
+ENTRY(accept)
     pushl   %ebx
     pushl   %ecx
     mov     $5, %ebx
@@ -25,3 +21,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(accept)
diff --git a/libc/arch-x86/syscalls/access.S b/libc/arch-x86/syscalls/access.S
index fff26a9..0f68574 100644
--- a/libc/arch-x86/syscalls/access.S
+++ b/libc/arch-x86/syscalls/access.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type access, @function
-    .globl access
-    .align 4
-
-access:
+ENTRY(access)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(access)
diff --git a/libc/arch-x86/syscalls/acct.S b/libc/arch-x86/syscalls/acct.S
index 711b6fc..bf991d6 100644
--- a/libc/arch-x86/syscalls/acct.S
+++ b/libc/arch-x86/syscalls/acct.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type acct, @function
-    .globl acct
-    .align 4
-
-acct:
+ENTRY(acct)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_acct, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(acct)
diff --git a/libc/arch-x86/syscalls/bind.S b/libc/arch-x86/syscalls/bind.S
index 2172cfb..ff6ae9f 100644
--- a/libc/arch-x86/syscalls/bind.S
+++ b/libc/arch-x86/syscalls/bind.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type bind, @function
-    .globl bind
-    .align 4
-
-bind:
+ENTRY(bind)
     pushl   %ebx
     pushl   %ecx
     mov     $2, %ebx
@@ -25,3 +21,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(bind)
diff --git a/libc/arch-x86/syscalls/capget.S b/libc/arch-x86/syscalls/capget.S
index e287cb2..55960f1 100644
--- a/libc/arch-x86/syscalls/capget.S
+++ b/libc/arch-x86/syscalls/capget.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type capget, @function
-    .globl capget
-    .align 4
-
-capget:
+ENTRY(capget)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(capget)
diff --git a/libc/arch-x86/syscalls/capset.S b/libc/arch-x86/syscalls/capset.S
index ce71f6e..c8703c7 100644
--- a/libc/arch-x86/syscalls/capset.S
+++ b/libc/arch-x86/syscalls/capset.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type capset, @function
-    .globl capset
-    .align 4
-
-capset:
+ENTRY(capset)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(capset)
diff --git a/libc/arch-x86/syscalls/chdir.S b/libc/arch-x86/syscalls/chdir.S
index be88847..d40d099 100644
--- a/libc/arch-x86/syscalls/chdir.S
+++ b/libc/arch-x86/syscalls/chdir.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type chdir, @function
-    .globl chdir
-    .align 4
-
-chdir:
+ENTRY(chdir)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_chdir, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(chdir)
diff --git a/libc/arch-x86/syscalls/chmod.S b/libc/arch-x86/syscalls/chmod.S
index d023a7d..307e196 100644
--- a/libc/arch-x86/syscalls/chmod.S
+++ b/libc/arch-x86/syscalls/chmod.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type chmod, @function
-    .globl chmod
-    .align 4
-
-chmod:
+ENTRY(chmod)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(chmod)
diff --git a/libc/arch-x86/syscalls/chown.S b/libc/arch-x86/syscalls/chown.S
index 5646088..800bf04 100644
--- a/libc/arch-x86/syscalls/chown.S
+++ b/libc/arch-x86/syscalls/chown.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type chown, @function
-    .globl chown
-    .align 4
-
-chown:
+ENTRY(chown)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(chown)
diff --git a/libc/arch-x86/syscalls/chroot.S b/libc/arch-x86/syscalls/chroot.S
index 461087c..24d2d10 100644
--- a/libc/arch-x86/syscalls/chroot.S
+++ b/libc/arch-x86/syscalls/chroot.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type chroot, @function
-    .globl chroot
-    .align 4
-
-chroot:
+ENTRY(chroot)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_chroot, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(chroot)
diff --git a/libc/arch-x86/syscalls/clock_getres.S b/libc/arch-x86/syscalls/clock_getres.S
index 07742ae..da332aa 100644
--- a/libc/arch-x86/syscalls/clock_getres.S
+++ b/libc/arch-x86/syscalls/clock_getres.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type clock_getres, @function
-    .globl clock_getres
-    .align 4
-
-clock_getres:
+ENTRY(clock_getres)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(clock_getres)
diff --git a/libc/arch-x86/syscalls/clock_gettime.S b/libc/arch-x86/syscalls/clock_gettime.S
index bfe14a4..41ac5e2 100644
--- a/libc/arch-x86/syscalls/clock_gettime.S
+++ b/libc/arch-x86/syscalls/clock_gettime.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type clock_gettime, @function
-    .globl clock_gettime
-    .align 4
-
-clock_gettime:
+ENTRY(clock_gettime)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(clock_gettime)
diff --git a/libc/arch-x86/syscalls/clock_nanosleep.S b/libc/arch-x86/syscalls/clock_nanosleep.S
index 23e1e6f..cd163df 100644
--- a/libc/arch-x86/syscalls/clock_nanosleep.S
+++ b/libc/arch-x86/syscalls/clock_nanosleep.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type clock_nanosleep, @function
-    .globl clock_nanosleep
-    .align 4
-
-clock_nanosleep:
+ENTRY(clock_nanosleep)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(clock_nanosleep)
diff --git a/libc/arch-x86/syscalls/clock_settime.S b/libc/arch-x86/syscalls/clock_settime.S
index 58495ba..18237c4 100644
--- a/libc/arch-x86/syscalls/clock_settime.S
+++ b/libc/arch-x86/syscalls/clock_settime.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type clock_settime, @function
-    .globl clock_settime
-    .align 4
-
-clock_settime:
+ENTRY(clock_settime)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(clock_settime)
diff --git a/libc/arch-x86/syscalls/close.S b/libc/arch-x86/syscalls/close.S
index 1944a83..76175c7 100644
--- a/libc/arch-x86/syscalls/close.S
+++ b/libc/arch-x86/syscalls/close.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type close, @function
-    .globl close
-    .align 4
-
-close:
+ENTRY(close)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_close, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(close)
diff --git a/libc/arch-x86/syscalls/connect.S b/libc/arch-x86/syscalls/connect.S
index 8b8ce4e..e87b123 100644
--- a/libc/arch-x86/syscalls/connect.S
+++ b/libc/arch-x86/syscalls/connect.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type connect, @function
-    .globl connect
-    .align 4
-
-connect:
+ENTRY(connect)
     pushl   %ebx
     pushl   %ecx
     mov     $3, %ebx
@@ -25,3 +21,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(connect)
diff --git a/libc/arch-x86/syscalls/delete_module.S b/libc/arch-x86/syscalls/delete_module.S
index 6865d6a..10a06a3 100644
--- a/libc/arch-x86/syscalls/delete_module.S
+++ b/libc/arch-x86/syscalls/delete_module.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type delete_module, @function
-    .globl delete_module
-    .align 4
-
-delete_module:
+ENTRY(delete_module)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(delete_module)
diff --git a/libc/arch-x86/syscalls/dup.S b/libc/arch-x86/syscalls/dup.S
index 155de79..80259fe 100644
--- a/libc/arch-x86/syscalls/dup.S
+++ b/libc/arch-x86/syscalls/dup.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type dup, @function
-    .globl dup
-    .align 4
-
-dup:
+ENTRY(dup)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_dup, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(dup)
diff --git a/libc/arch-x86/syscalls/dup2.S b/libc/arch-x86/syscalls/dup2.S
index 59f8329..43def66 100644
--- a/libc/arch-x86/syscalls/dup2.S
+++ b/libc/arch-x86/syscalls/dup2.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type dup2, @function
-    .globl dup2
-    .align 4
-
-dup2:
+ENTRY(dup2)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(dup2)
diff --git a/libc/arch-x86/syscalls/epoll_create.S b/libc/arch-x86/syscalls/epoll_create.S
index 8106c58..0bdc885 100644
--- a/libc/arch-x86/syscalls/epoll_create.S
+++ b/libc/arch-x86/syscalls/epoll_create.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type epoll_create, @function
-    .globl epoll_create
-    .align 4
-
-epoll_create:
+ENTRY(epoll_create)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_epoll_create, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(epoll_create)
diff --git a/libc/arch-x86/syscalls/epoll_ctl.S b/libc/arch-x86/syscalls/epoll_ctl.S
index ff2c112..43175d2 100644
--- a/libc/arch-x86/syscalls/epoll_ctl.S
+++ b/libc/arch-x86/syscalls/epoll_ctl.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type epoll_ctl, @function
-    .globl epoll_ctl
-    .align 4
-
-epoll_ctl:
+ENTRY(epoll_ctl)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(epoll_ctl)
diff --git a/libc/arch-x86/syscalls/epoll_wait.S b/libc/arch-x86/syscalls/epoll_wait.S
index 3d81a14..e2d61c0 100644
--- a/libc/arch-x86/syscalls/epoll_wait.S
+++ b/libc/arch-x86/syscalls/epoll_wait.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type epoll_wait, @function
-    .globl epoll_wait
-    .align 4
-
-epoll_wait:
+ENTRY(epoll_wait)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(epoll_wait)
diff --git a/libc/arch-x86/syscalls/eventfd.S b/libc/arch-x86/syscalls/eventfd.S
index 104c842..338696f 100644
--- a/libc/arch-x86/syscalls/eventfd.S
+++ b/libc/arch-x86/syscalls/eventfd.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type eventfd, @function
-    .globl eventfd
-    .align 4
-
-eventfd:
+ENTRY(eventfd)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(eventfd)
diff --git a/libc/arch-x86/syscalls/execve.S b/libc/arch-x86/syscalls/execve.S
index 0ab1d75..c7e3ca5 100644
--- a/libc/arch-x86/syscalls/execve.S
+++ b/libc/arch-x86/syscalls/execve.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type execve, @function
-    .globl execve
-    .align 4
-
-execve:
+ENTRY(execve)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(execve)
diff --git a/libc/arch-x86/syscalls/faccessat.S b/libc/arch-x86/syscalls/faccessat.S
index 2010e57..6733029 100644
--- a/libc/arch-x86/syscalls/faccessat.S
+++ b/libc/arch-x86/syscalls/faccessat.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type faccessat, @function
-    .globl faccessat
-    .align 4
-
-faccessat:
+ENTRY(faccessat)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(faccessat)
diff --git a/libc/arch-x86/syscalls/fchdir.S b/libc/arch-x86/syscalls/fchdir.S
index 4e681be..23aa6e2 100644
--- a/libc/arch-x86/syscalls/fchdir.S
+++ b/libc/arch-x86/syscalls/fchdir.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type fchdir, @function
-    .globl fchdir
-    .align 4
-
-fchdir:
+ENTRY(fchdir)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_fchdir, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(fchdir)
diff --git a/libc/arch-x86/syscalls/fchmod.S b/libc/arch-x86/syscalls/fchmod.S
index 58f8a94..019eb07 100644
--- a/libc/arch-x86/syscalls/fchmod.S
+++ b/libc/arch-x86/syscalls/fchmod.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type fchmod, @function
-    .globl fchmod
-    .align 4
-
-fchmod:
+ENTRY(fchmod)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(fchmod)
diff --git a/libc/arch-x86/syscalls/fchmodat.S b/libc/arch-x86/syscalls/fchmodat.S
index b5b9c6d..f7292f9 100644
--- a/libc/arch-x86/syscalls/fchmodat.S
+++ b/libc/arch-x86/syscalls/fchmodat.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type fchmodat, @function
-    .globl fchmodat
-    .align 4
-
-fchmodat:
+ENTRY(fchmodat)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(fchmodat)
diff --git a/libc/arch-x86/syscalls/fchown.S b/libc/arch-x86/syscalls/fchown.S
index c648d7f..f17c0d6 100644
--- a/libc/arch-x86/syscalls/fchown.S
+++ b/libc/arch-x86/syscalls/fchown.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type fchown, @function
-    .globl fchown
-    .align 4
-
-fchown:
+ENTRY(fchown)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(fchown)
diff --git a/libc/arch-x86/syscalls/fchownat.S b/libc/arch-x86/syscalls/fchownat.S
index 3bec843..7648d79 100644
--- a/libc/arch-x86/syscalls/fchownat.S
+++ b/libc/arch-x86/syscalls/fchownat.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type fchownat, @function
-    .globl fchownat
-    .align 4
-
-fchownat:
+ENTRY(fchownat)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -33,3 +29,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(fchownat)
diff --git a/libc/arch-x86/syscalls/fdatasync.S b/libc/arch-x86/syscalls/fdatasync.S
index b86c0f8..2808e0f 100644
--- a/libc/arch-x86/syscalls/fdatasync.S
+++ b/libc/arch-x86/syscalls/fdatasync.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type fdatasync, @function
-    .globl fdatasync
-    .align 4
-
-fdatasync:
+ENTRY(fdatasync)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_fdatasync, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(fdatasync)
diff --git a/libc/arch-x86/syscalls/fgetxattr.S b/libc/arch-x86/syscalls/fgetxattr.S
index d9f582f..beaab09 100644
--- a/libc/arch-x86/syscalls/fgetxattr.S
+++ b/libc/arch-x86/syscalls/fgetxattr.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type fgetxattr, @function
-    .globl fgetxattr
-    .align 4
-
-fgetxattr:
+ENTRY(fgetxattr)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(fgetxattr)
diff --git a/libc/arch-x86/syscalls/flistxattr.S b/libc/arch-x86/syscalls/flistxattr.S
index 43ff73d..95935c0 100644
--- a/libc/arch-x86/syscalls/flistxattr.S
+++ b/libc/arch-x86/syscalls/flistxattr.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type flistxattr, @function
-    .globl flistxattr
-    .align 4
-
-flistxattr:
+ENTRY(flistxattr)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(flistxattr)
diff --git a/libc/arch-x86/syscalls/flock.S b/libc/arch-x86/syscalls/flock.S
index 1ca09a5..156844c 100644
--- a/libc/arch-x86/syscalls/flock.S
+++ b/libc/arch-x86/syscalls/flock.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type flock, @function
-    .globl flock
-    .align 4
-
-flock:
+ENTRY(flock)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(flock)
diff --git a/libc/arch-x86/syscalls/fremovexattr.S b/libc/arch-x86/syscalls/fremovexattr.S
index eeed57f..32d0bdc 100644
--- a/libc/arch-x86/syscalls/fremovexattr.S
+++ b/libc/arch-x86/syscalls/fremovexattr.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type fremovexattr, @function
-    .globl fremovexattr
-    .align 4
-
-fremovexattr:
+ENTRY(fremovexattr)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(fremovexattr)
diff --git a/libc/arch-x86/syscalls/fsetxattr.S b/libc/arch-x86/syscalls/fsetxattr.S
index a70ca4f..c3d588e 100644
--- a/libc/arch-x86/syscalls/fsetxattr.S
+++ b/libc/arch-x86/syscalls/fsetxattr.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type fsetxattr, @function
-    .globl fsetxattr
-    .align 4
-
-fsetxattr:
+ENTRY(fsetxattr)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -33,3 +29,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(fsetxattr)
diff --git a/libc/arch-x86/syscalls/fstat.S b/libc/arch-x86/syscalls/fstat.S
index 8f58316..95301d9 100644
--- a/libc/arch-x86/syscalls/fstat.S
+++ b/libc/arch-x86/syscalls/fstat.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type fstat, @function
-    .globl fstat
-    .align 4
-
-fstat:
+ENTRY(fstat)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(fstat)
diff --git a/libc/arch-x86/syscalls/fstatat.S b/libc/arch-x86/syscalls/fstatat.S
index 4926e99..947f4da 100644
--- a/libc/arch-x86/syscalls/fstatat.S
+++ b/libc/arch-x86/syscalls/fstatat.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type fstatat, @function
-    .globl fstatat
-    .align 4
-
-fstatat:
+ENTRY(fstatat)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(fstatat)
diff --git a/libc/arch-x86/syscalls/fsync.S b/libc/arch-x86/syscalls/fsync.S
index d9fd225..363b334 100644
--- a/libc/arch-x86/syscalls/fsync.S
+++ b/libc/arch-x86/syscalls/fsync.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type fsync, @function
-    .globl fsync
-    .align 4
-
-fsync:
+ENTRY(fsync)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_fsync, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(fsync)
diff --git a/libc/arch-x86/syscalls/ftruncate.S b/libc/arch-x86/syscalls/ftruncate.S
index 25b7df5..1ed3f96 100644
--- a/libc/arch-x86/syscalls/ftruncate.S
+++ b/libc/arch-x86/syscalls/ftruncate.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type ftruncate, @function
-    .globl ftruncate
-    .align 4
-
-ftruncate:
+ENTRY(ftruncate)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(ftruncate)
diff --git a/libc/arch-x86/syscalls/ftruncate64.S b/libc/arch-x86/syscalls/ftruncate64.S
index 66835ab..fa6dbef 100644
--- a/libc/arch-x86/syscalls/ftruncate64.S
+++ b/libc/arch-x86/syscalls/ftruncate64.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type ftruncate64, @function
-    .globl ftruncate64
-    .align 4
-
-ftruncate64:
+ENTRY(ftruncate64)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(ftruncate64)
diff --git a/libc/arch-x86/syscalls/futex.S b/libc/arch-x86/syscalls/futex.S
index ac51316..f72be1b 100644
--- a/libc/arch-x86/syscalls/futex.S
+++ b/libc/arch-x86/syscalls/futex.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type futex, @function
-    .globl futex
-    .align 4
-
-futex:
+ENTRY(futex)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -36,3 +32,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(futex)
diff --git a/libc/arch-x86/syscalls/getdents.S b/libc/arch-x86/syscalls/getdents.S
index b8c527f..c5d2721 100644
--- a/libc/arch-x86/syscalls/getdents.S
+++ b/libc/arch-x86/syscalls/getdents.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getdents, @function
-    .globl getdents
-    .align 4
-
-getdents:
+ENTRY(getdents)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(getdents)
diff --git a/libc/arch-x86/syscalls/getegid.S b/libc/arch-x86/syscalls/getegid.S
index e34a147..c26ebc2 100644
--- a/libc/arch-x86/syscalls/getegid.S
+++ b/libc/arch-x86/syscalls/getegid.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getegid, @function
-    .globl getegid
-    .align 4
-
-getegid:
+ENTRY(getegid)
     movl    $__NR_getegid32, %eax
     int     $0x80
     cmpl    $-129, %eax
@@ -18,3 +14,4 @@
     orl     $-1, %eax
 1:
     ret
+END(getegid)
diff --git a/libc/arch-x86/syscalls/geteuid.S b/libc/arch-x86/syscalls/geteuid.S
index 8ec7297..a7761e8 100644
--- a/libc/arch-x86/syscalls/geteuid.S
+++ b/libc/arch-x86/syscalls/geteuid.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type geteuid, @function
-    .globl geteuid
-    .align 4
-
-geteuid:
+ENTRY(geteuid)
     movl    $__NR_geteuid32, %eax
     int     $0x80
     cmpl    $-129, %eax
@@ -18,3 +14,4 @@
     orl     $-1, %eax
 1:
     ret
+END(geteuid)
diff --git a/libc/arch-x86/syscalls/getgid.S b/libc/arch-x86/syscalls/getgid.S
index d69d722..7a51200 100644
--- a/libc/arch-x86/syscalls/getgid.S
+++ b/libc/arch-x86/syscalls/getgid.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getgid, @function
-    .globl getgid
-    .align 4
-
-getgid:
+ENTRY(getgid)
     movl    $__NR_getgid32, %eax
     int     $0x80
     cmpl    $-129, %eax
@@ -18,3 +14,4 @@
     orl     $-1, %eax
 1:
     ret
+END(getgid)
diff --git a/libc/arch-x86/syscalls/getgroups.S b/libc/arch-x86/syscalls/getgroups.S
index f6a9912..35bc3f5 100644
--- a/libc/arch-x86/syscalls/getgroups.S
+++ b/libc/arch-x86/syscalls/getgroups.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getgroups, @function
-    .globl getgroups
-    .align 4
-
-getgroups:
+ENTRY(getgroups)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(getgroups)
diff --git a/libc/arch-x86/syscalls/getitimer.S b/libc/arch-x86/syscalls/getitimer.S
index f170ebf..79957da 100644
--- a/libc/arch-x86/syscalls/getitimer.S
+++ b/libc/arch-x86/syscalls/getitimer.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getitimer, @function
-    .globl getitimer
-    .align 4
-
-getitimer:
+ENTRY(getitimer)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(getitimer)
diff --git a/libc/arch-x86/syscalls/getpeername.S b/libc/arch-x86/syscalls/getpeername.S
index b6f8eb8..3831990 100644
--- a/libc/arch-x86/syscalls/getpeername.S
+++ b/libc/arch-x86/syscalls/getpeername.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getpeername, @function
-    .globl getpeername
-    .align 4
-
-getpeername:
+ENTRY(getpeername)
     pushl   %ebx
     pushl   %ecx
     mov     $7, %ebx
@@ -25,3 +21,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(getpeername)
diff --git a/libc/arch-x86/syscalls/getpgid.S b/libc/arch-x86/syscalls/getpgid.S
index ca1e659..f49abbf 100644
--- a/libc/arch-x86/syscalls/getpgid.S
+++ b/libc/arch-x86/syscalls/getpgid.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getpgid, @function
-    .globl getpgid
-    .align 4
-
-getpgid:
+ENTRY(getpgid)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_getpgid, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(getpgid)
diff --git a/libc/arch-x86/syscalls/getpid.S b/libc/arch-x86/syscalls/getpid.S
index df43b88..29703e8 100644
--- a/libc/arch-x86/syscalls/getpid.S
+++ b/libc/arch-x86/syscalls/getpid.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getpid, @function
-    .globl getpid
-    .align 4
-
-getpid:
+ENTRY(getpid)
     movl    $__NR_getpid, %eax
     int     $0x80
     cmpl    $-129, %eax
@@ -18,3 +14,4 @@
     orl     $-1, %eax
 1:
     ret
+END(getpid)
diff --git a/libc/arch-x86/syscalls/getppid.S b/libc/arch-x86/syscalls/getppid.S
index 9a882bd..dc89d6e 100644
--- a/libc/arch-x86/syscalls/getppid.S
+++ b/libc/arch-x86/syscalls/getppid.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getppid, @function
-    .globl getppid
-    .align 4
-
-getppid:
+ENTRY(getppid)
     movl    $__NR_getppid, %eax
     int     $0x80
     cmpl    $-129, %eax
@@ -18,3 +14,4 @@
     orl     $-1, %eax
 1:
     ret
+END(getppid)
diff --git a/libc/arch-x86/syscalls/getresgid.S b/libc/arch-x86/syscalls/getresgid.S
index d43aec4..08a37e7 100644
--- a/libc/arch-x86/syscalls/getresgid.S
+++ b/libc/arch-x86/syscalls/getresgid.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getresgid, @function
-    .globl getresgid
-    .align 4
-
-getresgid:
+ENTRY(getresgid)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(getresgid)
diff --git a/libc/arch-x86/syscalls/getresuid.S b/libc/arch-x86/syscalls/getresuid.S
index f489d40..435a901 100644
--- a/libc/arch-x86/syscalls/getresuid.S
+++ b/libc/arch-x86/syscalls/getresuid.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getresuid, @function
-    .globl getresuid
-    .align 4
-
-getresuid:
+ENTRY(getresuid)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(getresuid)
diff --git a/libc/arch-x86/syscalls/getrlimit.S b/libc/arch-x86/syscalls/getrlimit.S
index f4c334f..8f6edd6 100644
--- a/libc/arch-x86/syscalls/getrlimit.S
+++ b/libc/arch-x86/syscalls/getrlimit.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getrlimit, @function
-    .globl getrlimit
-    .align 4
-
-getrlimit:
+ENTRY(getrlimit)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(getrlimit)
diff --git a/libc/arch-x86/syscalls/getrusage.S b/libc/arch-x86/syscalls/getrusage.S
index 750ab5b..ee47f3d 100644
--- a/libc/arch-x86/syscalls/getrusage.S
+++ b/libc/arch-x86/syscalls/getrusage.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getrusage, @function
-    .globl getrusage
-    .align 4
-
-getrusage:
+ENTRY(getrusage)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(getrusage)
diff --git a/libc/arch-x86/syscalls/getsid.S b/libc/arch-x86/syscalls/getsid.S
index 7046b9a..876bf6a 100644
--- a/libc/arch-x86/syscalls/getsid.S
+++ b/libc/arch-x86/syscalls/getsid.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getsid, @function
-    .globl getsid
-    .align 4
-
-getsid:
+ENTRY(getsid)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_getsid, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(getsid)
diff --git a/libc/arch-x86/syscalls/getsockname.S b/libc/arch-x86/syscalls/getsockname.S
index 884acd9..b28ecb8 100644
--- a/libc/arch-x86/syscalls/getsockname.S
+++ b/libc/arch-x86/syscalls/getsockname.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getsockname, @function
-    .globl getsockname
-    .align 4
-
-getsockname:
+ENTRY(getsockname)
     pushl   %ebx
     pushl   %ecx
     mov     $6, %ebx
@@ -25,3 +21,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(getsockname)
diff --git a/libc/arch-x86/syscalls/getsockopt.S b/libc/arch-x86/syscalls/getsockopt.S
index a606532..190b6f2 100644
--- a/libc/arch-x86/syscalls/getsockopt.S
+++ b/libc/arch-x86/syscalls/getsockopt.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getsockopt, @function
-    .globl getsockopt
-    .align 4
-
-getsockopt:
+ENTRY(getsockopt)
     pushl   %ebx
     pushl   %ecx
     mov     $15, %ebx
@@ -25,3 +21,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(getsockopt)
diff --git a/libc/arch-x86/syscalls/gettid.S b/libc/arch-x86/syscalls/gettid.S
index 2e8cb59..c1e6ba0 100644
--- a/libc/arch-x86/syscalls/gettid.S
+++ b/libc/arch-x86/syscalls/gettid.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type gettid, @function
-    .globl gettid
-    .align 4
-
-gettid:
+ENTRY(gettid)
     movl    $__NR_gettid, %eax
     int     $0x80
     cmpl    $-129, %eax
@@ -18,3 +14,4 @@
     orl     $-1, %eax
 1:
     ret
+END(gettid)
diff --git a/libc/arch-x86/syscalls/gettimeofday.S b/libc/arch-x86/syscalls/gettimeofday.S
index feffe92..34b9982 100644
--- a/libc/arch-x86/syscalls/gettimeofday.S
+++ b/libc/arch-x86/syscalls/gettimeofday.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type gettimeofday, @function
-    .globl gettimeofday
-    .align 4
-
-gettimeofday:
+ENTRY(gettimeofday)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(gettimeofday)
diff --git a/libc/arch-x86/syscalls/getuid.S b/libc/arch-x86/syscalls/getuid.S
index 635105e..e82b8b0 100644
--- a/libc/arch-x86/syscalls/getuid.S
+++ b/libc/arch-x86/syscalls/getuid.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getuid, @function
-    .globl getuid
-    .align 4
-
-getuid:
+ENTRY(getuid)
     movl    $__NR_getuid32, %eax
     int     $0x80
     cmpl    $-129, %eax
@@ -18,3 +14,4 @@
     orl     $-1, %eax
 1:
     ret
+END(getuid)
diff --git a/libc/arch-x86/syscalls/getxattr.S b/libc/arch-x86/syscalls/getxattr.S
index 80d2fc4..92f7c30 100644
--- a/libc/arch-x86/syscalls/getxattr.S
+++ b/libc/arch-x86/syscalls/getxattr.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getxattr, @function
-    .globl getxattr
-    .align 4
-
-getxattr:
+ENTRY(getxattr)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(getxattr)
diff --git a/libc/arch-x86/syscalls/init_module.S b/libc/arch-x86/syscalls/init_module.S
index 2e2b088..3ef9b36 100644
--- a/libc/arch-x86/syscalls/init_module.S
+++ b/libc/arch-x86/syscalls/init_module.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type init_module, @function
-    .globl init_module
-    .align 4
-
-init_module:
+ENTRY(init_module)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(init_module)
diff --git a/libc/arch-x86/syscalls/inotify_add_watch.S b/libc/arch-x86/syscalls/inotify_add_watch.S
index 12a12e4..7b57f3c 100644
--- a/libc/arch-x86/syscalls/inotify_add_watch.S
+++ b/libc/arch-x86/syscalls/inotify_add_watch.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type inotify_add_watch, @function
-    .globl inotify_add_watch
-    .align 4
-
-inotify_add_watch:
+ENTRY(inotify_add_watch)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(inotify_add_watch)
diff --git a/libc/arch-x86/syscalls/inotify_init.S b/libc/arch-x86/syscalls/inotify_init.S
index 2d186c4..c19174b 100644
--- a/libc/arch-x86/syscalls/inotify_init.S
+++ b/libc/arch-x86/syscalls/inotify_init.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type inotify_init, @function
-    .globl inotify_init
-    .align 4
-
-inotify_init:
+ENTRY(inotify_init)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_inotify_init, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(inotify_init)
diff --git a/libc/arch-x86/syscalls/inotify_rm_watch.S b/libc/arch-x86/syscalls/inotify_rm_watch.S
index f931833..351bdc2 100644
--- a/libc/arch-x86/syscalls/inotify_rm_watch.S
+++ b/libc/arch-x86/syscalls/inotify_rm_watch.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type inotify_rm_watch, @function
-    .globl inotify_rm_watch
-    .align 4
-
-inotify_rm_watch:
+ENTRY(inotify_rm_watch)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(inotify_rm_watch)
diff --git a/libc/arch-x86/syscalls/ioprio_get.S b/libc/arch-x86/syscalls/ioprio_get.S
index 3620271..b64662f 100644
--- a/libc/arch-x86/syscalls/ioprio_get.S
+++ b/libc/arch-x86/syscalls/ioprio_get.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type ioprio_get, @function
-    .globl ioprio_get
-    .align 4
-
-ioprio_get:
+ENTRY(ioprio_get)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(ioprio_get)
diff --git a/libc/arch-x86/syscalls/ioprio_set.S b/libc/arch-x86/syscalls/ioprio_set.S
index 174d923..6f2a4f3 100644
--- a/libc/arch-x86/syscalls/ioprio_set.S
+++ b/libc/arch-x86/syscalls/ioprio_set.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type ioprio_set, @function
-    .globl ioprio_set
-    .align 4
-
-ioprio_set:
+ENTRY(ioprio_set)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(ioprio_set)
diff --git a/libc/arch-x86/syscalls/kill.S b/libc/arch-x86/syscalls/kill.S
index e495c54..99fe9a9 100644
--- a/libc/arch-x86/syscalls/kill.S
+++ b/libc/arch-x86/syscalls/kill.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type kill, @function
-    .globl kill
-    .align 4
-
-kill:
+ENTRY(kill)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(kill)
diff --git a/libc/arch-x86/syscalls/klogctl.S b/libc/arch-x86/syscalls/klogctl.S
index e46c8ae..e9f8b79 100644
--- a/libc/arch-x86/syscalls/klogctl.S
+++ b/libc/arch-x86/syscalls/klogctl.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type klogctl, @function
-    .globl klogctl
-    .align 4
-
-klogctl:
+ENTRY(klogctl)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(klogctl)
diff --git a/libc/arch-x86/syscalls/lchown.S b/libc/arch-x86/syscalls/lchown.S
index f584a32..779f703 100644
--- a/libc/arch-x86/syscalls/lchown.S
+++ b/libc/arch-x86/syscalls/lchown.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type lchown, @function
-    .globl lchown
-    .align 4
-
-lchown:
+ENTRY(lchown)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(lchown)
diff --git a/libc/arch-x86/syscalls/lgetxattr.S b/libc/arch-x86/syscalls/lgetxattr.S
index 3f5b63e..3781bff 100644
--- a/libc/arch-x86/syscalls/lgetxattr.S
+++ b/libc/arch-x86/syscalls/lgetxattr.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type lgetxattr, @function
-    .globl lgetxattr
-    .align 4
-
-lgetxattr:
+ENTRY(lgetxattr)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(lgetxattr)
diff --git a/libc/arch-x86/syscalls/link.S b/libc/arch-x86/syscalls/link.S
index 3946dbf..dac7d0e 100644
--- a/libc/arch-x86/syscalls/link.S
+++ b/libc/arch-x86/syscalls/link.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type link, @function
-    .globl link
-    .align 4
-
-link:
+ENTRY(link)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(link)
diff --git a/libc/arch-x86/syscalls/listen.S b/libc/arch-x86/syscalls/listen.S
index de310cf..8f63945 100644
--- a/libc/arch-x86/syscalls/listen.S
+++ b/libc/arch-x86/syscalls/listen.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type listen, @function
-    .globl listen
-    .align 4
-
-listen:
+ENTRY(listen)
     pushl   %ebx
     pushl   %ecx
     mov     $4, %ebx
@@ -25,3 +21,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(listen)
diff --git a/libc/arch-x86/syscalls/listxattr.S b/libc/arch-x86/syscalls/listxattr.S
index 88109bb..853c47b 100644
--- a/libc/arch-x86/syscalls/listxattr.S
+++ b/libc/arch-x86/syscalls/listxattr.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type listxattr, @function
-    .globl listxattr
-    .align 4
-
-listxattr:
+ENTRY(listxattr)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(listxattr)
diff --git a/libc/arch-x86/syscalls/llistxattr.S b/libc/arch-x86/syscalls/llistxattr.S
index fa8505c..cd7038b 100644
--- a/libc/arch-x86/syscalls/llistxattr.S
+++ b/libc/arch-x86/syscalls/llistxattr.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type llistxattr, @function
-    .globl llistxattr
-    .align 4
-
-llistxattr:
+ENTRY(llistxattr)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(llistxattr)
diff --git a/libc/arch-x86/syscalls/lremovexattr.S b/libc/arch-x86/syscalls/lremovexattr.S
index f6c7afe..93973d6 100644
--- a/libc/arch-x86/syscalls/lremovexattr.S
+++ b/libc/arch-x86/syscalls/lremovexattr.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type lremovexattr, @function
-    .globl lremovexattr
-    .align 4
-
-lremovexattr:
+ENTRY(lremovexattr)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(lremovexattr)
diff --git a/libc/arch-x86/syscalls/lseek.S b/libc/arch-x86/syscalls/lseek.S
index 0b2c57c..f6250e6 100644
--- a/libc/arch-x86/syscalls/lseek.S
+++ b/libc/arch-x86/syscalls/lseek.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type lseek, @function
-    .globl lseek
-    .align 4
-
-lseek:
+ENTRY(lseek)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(lseek)
diff --git a/libc/arch-x86/syscalls/lsetxattr.S b/libc/arch-x86/syscalls/lsetxattr.S
index 56c8cf8..c5dbc30 100644
--- a/libc/arch-x86/syscalls/lsetxattr.S
+++ b/libc/arch-x86/syscalls/lsetxattr.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type lsetxattr, @function
-    .globl lsetxattr
-    .align 4
-
-lsetxattr:
+ENTRY(lsetxattr)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -33,3 +29,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(lsetxattr)
diff --git a/libc/arch-x86/syscalls/lstat.S b/libc/arch-x86/syscalls/lstat.S
index 4739f32..4e25fae 100644
--- a/libc/arch-x86/syscalls/lstat.S
+++ b/libc/arch-x86/syscalls/lstat.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type lstat, @function
-    .globl lstat
-    .align 4
-
-lstat:
+ENTRY(lstat)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(lstat)
diff --git a/libc/arch-x86/syscalls/madvise.S b/libc/arch-x86/syscalls/madvise.S
index 2423cc2..bf3e5dc 100644
--- a/libc/arch-x86/syscalls/madvise.S
+++ b/libc/arch-x86/syscalls/madvise.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type madvise, @function
-    .globl madvise
-    .align 4
-
-madvise:
+ENTRY(madvise)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(madvise)
diff --git a/libc/arch-x86/syscalls/mincore.S b/libc/arch-x86/syscalls/mincore.S
index 1e02ac2..37df639 100644
--- a/libc/arch-x86/syscalls/mincore.S
+++ b/libc/arch-x86/syscalls/mincore.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type mincore, @function
-    .globl mincore
-    .align 4
-
-mincore:
+ENTRY(mincore)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(mincore)
diff --git a/libc/arch-x86/syscalls/mkdir.S b/libc/arch-x86/syscalls/mkdir.S
index 4f1d157..16a5c03 100644
--- a/libc/arch-x86/syscalls/mkdir.S
+++ b/libc/arch-x86/syscalls/mkdir.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type mkdir, @function
-    .globl mkdir
-    .align 4
-
-mkdir:
+ENTRY(mkdir)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(mkdir)
diff --git a/libc/arch-x86/syscalls/mkdirat.S b/libc/arch-x86/syscalls/mkdirat.S
index 10406d3..ece2c27 100644
--- a/libc/arch-x86/syscalls/mkdirat.S
+++ b/libc/arch-x86/syscalls/mkdirat.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type mkdirat, @function
-    .globl mkdirat
-    .align 4
-
-mkdirat:
+ENTRY(mkdirat)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(mkdirat)
diff --git a/libc/arch-x86/syscalls/mknod.S b/libc/arch-x86/syscalls/mknod.S
index 8df1013..22fc390 100644
--- a/libc/arch-x86/syscalls/mknod.S
+++ b/libc/arch-x86/syscalls/mknod.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type mknod, @function
-    .globl mknod
-    .align 4
-
-mknod:
+ENTRY(mknod)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(mknod)
diff --git a/libc/arch-x86/syscalls/mlock.S b/libc/arch-x86/syscalls/mlock.S
index 85323d2..5010e00 100644
--- a/libc/arch-x86/syscalls/mlock.S
+++ b/libc/arch-x86/syscalls/mlock.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type mlock, @function
-    .globl mlock
-    .align 4
-
-mlock:
+ENTRY(mlock)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(mlock)
diff --git a/libc/arch-x86/syscalls/mlockall.S b/libc/arch-x86/syscalls/mlockall.S
index ad24213..849b44f 100644
--- a/libc/arch-x86/syscalls/mlockall.S
+++ b/libc/arch-x86/syscalls/mlockall.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type mlockall, @function
-    .globl mlockall
-    .align 4
-
-mlockall:
+ENTRY(mlockall)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_mlockall, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(mlockall)
diff --git a/libc/arch-x86/syscalls/mount.S b/libc/arch-x86/syscalls/mount.S
index 46237d3..9ceeab9 100644
--- a/libc/arch-x86/syscalls/mount.S
+++ b/libc/arch-x86/syscalls/mount.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type mount, @function
-    .globl mount
-    .align 4
-
-mount:
+ENTRY(mount)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -33,3 +29,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(mount)
diff --git a/libc/arch-x86/syscalls/mprotect.S b/libc/arch-x86/syscalls/mprotect.S
index f44d564..4438bfe 100644
--- a/libc/arch-x86/syscalls/mprotect.S
+++ b/libc/arch-x86/syscalls/mprotect.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type mprotect, @function
-    .globl mprotect
-    .align 4
-
-mprotect:
+ENTRY(mprotect)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(mprotect)
diff --git a/libc/arch-x86/syscalls/mremap.S b/libc/arch-x86/syscalls/mremap.S
index 891261c..d33a8dc 100644
--- a/libc/arch-x86/syscalls/mremap.S
+++ b/libc/arch-x86/syscalls/mremap.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type mremap, @function
-    .globl mremap
-    .align 4
-
-mremap:
+ENTRY(mremap)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(mremap)
diff --git a/libc/arch-x86/syscalls/msync.S b/libc/arch-x86/syscalls/msync.S
index b83ce01..2da5bc7 100644
--- a/libc/arch-x86/syscalls/msync.S
+++ b/libc/arch-x86/syscalls/msync.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type msync, @function
-    .globl msync
-    .align 4
-
-msync:
+ENTRY(msync)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(msync)
diff --git a/libc/arch-x86/syscalls/munlock.S b/libc/arch-x86/syscalls/munlock.S
index 75ee75e..574d17b 100644
--- a/libc/arch-x86/syscalls/munlock.S
+++ b/libc/arch-x86/syscalls/munlock.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type munlock, @function
-    .globl munlock
-    .align 4
-
-munlock:
+ENTRY(munlock)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(munlock)
diff --git a/libc/arch-x86/syscalls/munlockall.S b/libc/arch-x86/syscalls/munlockall.S
index c43e162..f69316a 100644
--- a/libc/arch-x86/syscalls/munlockall.S
+++ b/libc/arch-x86/syscalls/munlockall.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type munlockall, @function
-    .globl munlockall
-    .align 4
-
-munlockall:
+ENTRY(munlockall)
     movl    $__NR_munlockall, %eax
     int     $0x80
     cmpl    $-129, %eax
@@ -18,3 +14,4 @@
     orl     $-1, %eax
 1:
     ret
+END(munlockall)
diff --git a/libc/arch-x86/syscalls/munmap.S b/libc/arch-x86/syscalls/munmap.S
index b251844..91c73c1 100644
--- a/libc/arch-x86/syscalls/munmap.S
+++ b/libc/arch-x86/syscalls/munmap.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type munmap, @function
-    .globl munmap
-    .align 4
-
-munmap:
+ENTRY(munmap)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(munmap)
diff --git a/libc/arch-x86/syscalls/nanosleep.S b/libc/arch-x86/syscalls/nanosleep.S
index c274d4f..6d2df08 100644
--- a/libc/arch-x86/syscalls/nanosleep.S
+++ b/libc/arch-x86/syscalls/nanosleep.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type nanosleep, @function
-    .globl nanosleep
-    .align 4
-
-nanosleep:
+ENTRY(nanosleep)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(nanosleep)
diff --git a/libc/arch-x86/syscalls/pause.S b/libc/arch-x86/syscalls/pause.S
index 3fe1546..70be691 100644
--- a/libc/arch-x86/syscalls/pause.S
+++ b/libc/arch-x86/syscalls/pause.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type pause, @function
-    .globl pause
-    .align 4
-
-pause:
+ENTRY(pause)
     movl    $__NR_pause, %eax
     int     $0x80
     cmpl    $-129, %eax
@@ -18,3 +14,4 @@
     orl     $-1, %eax
 1:
     ret
+END(pause)
diff --git a/libc/arch-x86/syscalls/perf_event_open.S b/libc/arch-x86/syscalls/perf_event_open.S
index 5c15c5f..6466b45 100644
--- a/libc/arch-x86/syscalls/perf_event_open.S
+++ b/libc/arch-x86/syscalls/perf_event_open.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type perf_event_open, @function
-    .globl perf_event_open
-    .align 4
-
-perf_event_open:
+ENTRY(perf_event_open)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -33,3 +29,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(perf_event_open)
diff --git a/libc/arch-x86/syscalls/personality.S b/libc/arch-x86/syscalls/personality.S
index af4f912..b23b592 100644
--- a/libc/arch-x86/syscalls/personality.S
+++ b/libc/arch-x86/syscalls/personality.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type personality, @function
-    .globl personality
-    .align 4
-
-personality:
+ENTRY(personality)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_personality, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(personality)
diff --git a/libc/arch-x86/syscalls/pipe.S b/libc/arch-x86/syscalls/pipe.S
index d130909..1560bad 100644
--- a/libc/arch-x86/syscalls/pipe.S
+++ b/libc/arch-x86/syscalls/pipe.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type pipe, @function
-    .globl pipe
-    .align 4
-
-pipe:
+ENTRY(pipe)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_pipe, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(pipe)
diff --git a/libc/arch-x86/syscalls/pipe2.S b/libc/arch-x86/syscalls/pipe2.S
index c3354a7..55fe08f 100644
--- a/libc/arch-x86/syscalls/pipe2.S
+++ b/libc/arch-x86/syscalls/pipe2.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type pipe2, @function
-    .globl pipe2
-    .align 4
-
-pipe2:
+ENTRY(pipe2)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(pipe2)
diff --git a/libc/arch-x86/syscalls/poll.S b/libc/arch-x86/syscalls/poll.S
index b732af6..541d657 100644
--- a/libc/arch-x86/syscalls/poll.S
+++ b/libc/arch-x86/syscalls/poll.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type poll, @function
-    .globl poll
-    .align 4
-
-poll:
+ENTRY(poll)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(poll)
diff --git a/libc/arch-x86/syscalls/prctl.S b/libc/arch-x86/syscalls/prctl.S
index 4ce5d89..56720fe 100644
--- a/libc/arch-x86/syscalls/prctl.S
+++ b/libc/arch-x86/syscalls/prctl.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type prctl, @function
-    .globl prctl
-    .align 4
-
-prctl:
+ENTRY(prctl)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -33,3 +29,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(prctl)
diff --git a/libc/arch-x86/syscalls/pread64.S b/libc/arch-x86/syscalls/pread64.S
index eb004a9..987e9b8 100644
--- a/libc/arch-x86/syscalls/pread64.S
+++ b/libc/arch-x86/syscalls/pread64.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type pread64, @function
-    .globl pread64
-    .align 4
-
-pread64:
+ENTRY(pread64)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -33,3 +29,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(pread64)
diff --git a/libc/arch-x86/syscalls/pwrite64.S b/libc/arch-x86/syscalls/pwrite64.S
index 01389f8..8773a20 100644
--- a/libc/arch-x86/syscalls/pwrite64.S
+++ b/libc/arch-x86/syscalls/pwrite64.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type pwrite64, @function
-    .globl pwrite64
-    .align 4
-
-pwrite64:
+ENTRY(pwrite64)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -33,3 +29,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(pwrite64)
diff --git a/libc/arch-x86/syscalls/read.S b/libc/arch-x86/syscalls/read.S
index 63549dc..98b7c12 100644
--- a/libc/arch-x86/syscalls/read.S
+++ b/libc/arch-x86/syscalls/read.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type read, @function
-    .globl read
-    .align 4
-
-read:
+ENTRY(read)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(read)
diff --git a/libc/arch-x86/syscalls/readahead.S b/libc/arch-x86/syscalls/readahead.S
index b89314f..b0c0018 100644
--- a/libc/arch-x86/syscalls/readahead.S
+++ b/libc/arch-x86/syscalls/readahead.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type readahead, @function
-    .globl readahead
-    .align 4
-
-readahead:
+ENTRY(readahead)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(readahead)
diff --git a/libc/arch-x86/syscalls/readlink.S b/libc/arch-x86/syscalls/readlink.S
index 53c7632..393b5d4 100644
--- a/libc/arch-x86/syscalls/readlink.S
+++ b/libc/arch-x86/syscalls/readlink.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type readlink, @function
-    .globl readlink
-    .align 4
-
-readlink:
+ENTRY(readlink)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(readlink)
diff --git a/libc/arch-x86/syscalls/readv.S b/libc/arch-x86/syscalls/readv.S
index ed352d2..d626068 100644
--- a/libc/arch-x86/syscalls/readv.S
+++ b/libc/arch-x86/syscalls/readv.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type readv, @function
-    .globl readv
-    .align 4
-
-readv:
+ENTRY(readv)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(readv)
diff --git a/libc/arch-x86/syscalls/recvfrom.S b/libc/arch-x86/syscalls/recvfrom.S
index 3a38518..98558e1 100644
--- a/libc/arch-x86/syscalls/recvfrom.S
+++ b/libc/arch-x86/syscalls/recvfrom.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type recvfrom, @function
-    .globl recvfrom
-    .align 4
-
-recvfrom:
+ENTRY(recvfrom)
     pushl   %ebx
     pushl   %ecx
     mov     $12, %ebx
@@ -25,3 +21,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(recvfrom)
diff --git a/libc/arch-x86/syscalls/recvmsg.S b/libc/arch-x86/syscalls/recvmsg.S
index aee69d6..8b3c7bd 100644
--- a/libc/arch-x86/syscalls/recvmsg.S
+++ b/libc/arch-x86/syscalls/recvmsg.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type recvmsg, @function
-    .globl recvmsg
-    .align 4
-
-recvmsg:
+ENTRY(recvmsg)
     pushl   %ebx
     pushl   %ecx
     mov     $17, %ebx
@@ -25,3 +21,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(recvmsg)
diff --git a/libc/arch-x86/syscalls/removexattr.S b/libc/arch-x86/syscalls/removexattr.S
index 2350865..e2211e8 100644
--- a/libc/arch-x86/syscalls/removexattr.S
+++ b/libc/arch-x86/syscalls/removexattr.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type removexattr, @function
-    .globl removexattr
-    .align 4
-
-removexattr:
+ENTRY(removexattr)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(removexattr)
diff --git a/libc/arch-x86/syscalls/rename.S b/libc/arch-x86/syscalls/rename.S
index 79ae119..43be210 100644
--- a/libc/arch-x86/syscalls/rename.S
+++ b/libc/arch-x86/syscalls/rename.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type rename, @function
-    .globl rename
-    .align 4
-
-rename:
+ENTRY(rename)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(rename)
diff --git a/libc/arch-x86/syscalls/renameat.S b/libc/arch-x86/syscalls/renameat.S
index 30ba210..8084045 100644
--- a/libc/arch-x86/syscalls/renameat.S
+++ b/libc/arch-x86/syscalls/renameat.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type renameat, @function
-    .globl renameat
-    .align 4
-
-renameat:
+ENTRY(renameat)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(renameat)
diff --git a/libc/arch-x86/syscalls/rmdir.S b/libc/arch-x86/syscalls/rmdir.S
index 124c10d..b16375c 100644
--- a/libc/arch-x86/syscalls/rmdir.S
+++ b/libc/arch-x86/syscalls/rmdir.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type rmdir, @function
-    .globl rmdir
-    .align 4
-
-rmdir:
+ENTRY(rmdir)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_rmdir, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(rmdir)
diff --git a/libc/arch-x86/syscalls/sched_get_priority_max.S b/libc/arch-x86/syscalls/sched_get_priority_max.S
index e2d09a6..713b02d 100644
--- a/libc/arch-x86/syscalls/sched_get_priority_max.S
+++ b/libc/arch-x86/syscalls/sched_get_priority_max.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sched_get_priority_max, @function
-    .globl sched_get_priority_max
-    .align 4
-
-sched_get_priority_max:
+ENTRY(sched_get_priority_max)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_sched_get_priority_max, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(sched_get_priority_max)
diff --git a/libc/arch-x86/syscalls/sched_get_priority_min.S b/libc/arch-x86/syscalls/sched_get_priority_min.S
index 0f66eee..de6768f 100644
--- a/libc/arch-x86/syscalls/sched_get_priority_min.S
+++ b/libc/arch-x86/syscalls/sched_get_priority_min.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sched_get_priority_min, @function
-    .globl sched_get_priority_min
-    .align 4
-
-sched_get_priority_min:
+ENTRY(sched_get_priority_min)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_sched_get_priority_min, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(sched_get_priority_min)
diff --git a/libc/arch-x86/syscalls/sched_getparam.S b/libc/arch-x86/syscalls/sched_getparam.S
index 2a8bd0e..eabc562 100644
--- a/libc/arch-x86/syscalls/sched_getparam.S
+++ b/libc/arch-x86/syscalls/sched_getparam.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sched_getparam, @function
-    .globl sched_getparam
-    .align 4
-
-sched_getparam:
+ENTRY(sched_getparam)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(sched_getparam)
diff --git a/libc/arch-x86/syscalls/sched_getscheduler.S b/libc/arch-x86/syscalls/sched_getscheduler.S
index aaa5f8c..2a6c8f7 100644
--- a/libc/arch-x86/syscalls/sched_getscheduler.S
+++ b/libc/arch-x86/syscalls/sched_getscheduler.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sched_getscheduler, @function
-    .globl sched_getscheduler
-    .align 4
-
-sched_getscheduler:
+ENTRY(sched_getscheduler)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_sched_getscheduler, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(sched_getscheduler)
diff --git a/libc/arch-x86/syscalls/sched_rr_get_interval.S b/libc/arch-x86/syscalls/sched_rr_get_interval.S
index 58ccddd..3f032d5 100644
--- a/libc/arch-x86/syscalls/sched_rr_get_interval.S
+++ b/libc/arch-x86/syscalls/sched_rr_get_interval.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sched_rr_get_interval, @function
-    .globl sched_rr_get_interval
-    .align 4
-
-sched_rr_get_interval:
+ENTRY(sched_rr_get_interval)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(sched_rr_get_interval)
diff --git a/libc/arch-x86/syscalls/sched_setaffinity.S b/libc/arch-x86/syscalls/sched_setaffinity.S
index 5fa51ef..988f6b4 100644
--- a/libc/arch-x86/syscalls/sched_setaffinity.S
+++ b/libc/arch-x86/syscalls/sched_setaffinity.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sched_setaffinity, @function
-    .globl sched_setaffinity
-    .align 4
-
-sched_setaffinity:
+ENTRY(sched_setaffinity)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(sched_setaffinity)
diff --git a/libc/arch-x86/syscalls/sched_setparam.S b/libc/arch-x86/syscalls/sched_setparam.S
index 4b869bf..a250783 100644
--- a/libc/arch-x86/syscalls/sched_setparam.S
+++ b/libc/arch-x86/syscalls/sched_setparam.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sched_setparam, @function
-    .globl sched_setparam
-    .align 4
-
-sched_setparam:
+ENTRY(sched_setparam)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(sched_setparam)
diff --git a/libc/arch-x86/syscalls/sched_setscheduler.S b/libc/arch-x86/syscalls/sched_setscheduler.S
index 099a6d1..c6851ba 100644
--- a/libc/arch-x86/syscalls/sched_setscheduler.S
+++ b/libc/arch-x86/syscalls/sched_setscheduler.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sched_setscheduler, @function
-    .globl sched_setscheduler
-    .align 4
-
-sched_setscheduler:
+ENTRY(sched_setscheduler)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(sched_setscheduler)
diff --git a/libc/arch-x86/syscalls/sched_yield.S b/libc/arch-x86/syscalls/sched_yield.S
index fcd7281..3dcc7fc 100644
--- a/libc/arch-x86/syscalls/sched_yield.S
+++ b/libc/arch-x86/syscalls/sched_yield.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sched_yield, @function
-    .globl sched_yield
-    .align 4
-
-sched_yield:
+ENTRY(sched_yield)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_sched_yield, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(sched_yield)
diff --git a/libc/arch-x86/syscalls/select.S b/libc/arch-x86/syscalls/select.S
index 27359a9..b665281 100644
--- a/libc/arch-x86/syscalls/select.S
+++ b/libc/arch-x86/syscalls/select.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type select, @function
-    .globl select
-    .align 4
-
-select:
+ENTRY(select)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -33,3 +29,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(select)
diff --git a/libc/arch-x86/syscalls/sendfile.S b/libc/arch-x86/syscalls/sendfile.S
index 2752eec..b36fa1f 100644
--- a/libc/arch-x86/syscalls/sendfile.S
+++ b/libc/arch-x86/syscalls/sendfile.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sendfile, @function
-    .globl sendfile
-    .align 4
-
-sendfile:
+ENTRY(sendfile)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(sendfile)
diff --git a/libc/arch-x86/syscalls/sendmsg.S b/libc/arch-x86/syscalls/sendmsg.S
index 5f26623..119d632 100644
--- a/libc/arch-x86/syscalls/sendmsg.S
+++ b/libc/arch-x86/syscalls/sendmsg.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sendmsg, @function
-    .globl sendmsg
-    .align 4
-
-sendmsg:
+ENTRY(sendmsg)
     pushl   %ebx
     pushl   %ecx
     mov     $16, %ebx
@@ -25,3 +21,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(sendmsg)
diff --git a/libc/arch-x86/syscalls/sendto.S b/libc/arch-x86/syscalls/sendto.S
index d79a2ba..82208fe 100644
--- a/libc/arch-x86/syscalls/sendto.S
+++ b/libc/arch-x86/syscalls/sendto.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sendto, @function
-    .globl sendto
-    .align 4
-
-sendto:
+ENTRY(sendto)
     pushl   %ebx
     pushl   %ecx
     mov     $11, %ebx
@@ -25,3 +21,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(sendto)
diff --git a/libc/arch-x86/syscalls/setgid.S b/libc/arch-x86/syscalls/setgid.S
index 67fd02e..37f5ffe 100644
--- a/libc/arch-x86/syscalls/setgid.S
+++ b/libc/arch-x86/syscalls/setgid.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type setgid, @function
-    .globl setgid
-    .align 4
-
-setgid:
+ENTRY(setgid)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_setgid32, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(setgid)
diff --git a/libc/arch-x86/syscalls/setgroups.S b/libc/arch-x86/syscalls/setgroups.S
index b6bab11..20266e0 100644
--- a/libc/arch-x86/syscalls/setgroups.S
+++ b/libc/arch-x86/syscalls/setgroups.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type setgroups, @function
-    .globl setgroups
-    .align 4
-
-setgroups:
+ENTRY(setgroups)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(setgroups)
diff --git a/libc/arch-x86/syscalls/setitimer.S b/libc/arch-x86/syscalls/setitimer.S
index 29d4bc6..97ee7c6 100644
--- a/libc/arch-x86/syscalls/setitimer.S
+++ b/libc/arch-x86/syscalls/setitimer.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type setitimer, @function
-    .globl setitimer
-    .align 4
-
-setitimer:
+ENTRY(setitimer)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(setitimer)
diff --git a/libc/arch-x86/syscalls/setpgid.S b/libc/arch-x86/syscalls/setpgid.S
index df72382..8ff9273 100644
--- a/libc/arch-x86/syscalls/setpgid.S
+++ b/libc/arch-x86/syscalls/setpgid.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type setpgid, @function
-    .globl setpgid
-    .align 4
-
-setpgid:
+ENTRY(setpgid)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(setpgid)
diff --git a/libc/arch-x86/syscalls/setpriority.S b/libc/arch-x86/syscalls/setpriority.S
index 39d7a18..7358a89 100644
--- a/libc/arch-x86/syscalls/setpriority.S
+++ b/libc/arch-x86/syscalls/setpriority.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type setpriority, @function
-    .globl setpriority
-    .align 4
-
-setpriority:
+ENTRY(setpriority)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(setpriority)
diff --git a/libc/arch-x86/syscalls/setregid.S b/libc/arch-x86/syscalls/setregid.S
index c3112de..bbe092f 100644
--- a/libc/arch-x86/syscalls/setregid.S
+++ b/libc/arch-x86/syscalls/setregid.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type setregid, @function
-    .globl setregid
-    .align 4
-
-setregid:
+ENTRY(setregid)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(setregid)
diff --git a/libc/arch-x86/syscalls/setresgid.S b/libc/arch-x86/syscalls/setresgid.S
index 8e6c8c9..c235837 100644
--- a/libc/arch-x86/syscalls/setresgid.S
+++ b/libc/arch-x86/syscalls/setresgid.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type setresgid, @function
-    .globl setresgid
-    .align 4
-
-setresgid:
+ENTRY(setresgid)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(setresgid)
diff --git a/libc/arch-x86/syscalls/setrlimit.S b/libc/arch-x86/syscalls/setrlimit.S
index 31613c5..d7f5072 100644
--- a/libc/arch-x86/syscalls/setrlimit.S
+++ b/libc/arch-x86/syscalls/setrlimit.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type setrlimit, @function
-    .globl setrlimit
-    .align 4
-
-setrlimit:
+ENTRY(setrlimit)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(setrlimit)
diff --git a/libc/arch-x86/syscalls/setsid.S b/libc/arch-x86/syscalls/setsid.S
index db31380..684b304 100644
--- a/libc/arch-x86/syscalls/setsid.S
+++ b/libc/arch-x86/syscalls/setsid.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type setsid, @function
-    .globl setsid
-    .align 4
-
-setsid:
+ENTRY(setsid)
     movl    $__NR_setsid, %eax
     int     $0x80
     cmpl    $-129, %eax
@@ -18,3 +14,4 @@
     orl     $-1, %eax
 1:
     ret
+END(setsid)
diff --git a/libc/arch-x86/syscalls/setsockopt.S b/libc/arch-x86/syscalls/setsockopt.S
index d1c986a..9c70116 100644
--- a/libc/arch-x86/syscalls/setsockopt.S
+++ b/libc/arch-x86/syscalls/setsockopt.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type setsockopt, @function
-    .globl setsockopt
-    .align 4
-
-setsockopt:
+ENTRY(setsockopt)
     pushl   %ebx
     pushl   %ecx
     mov     $14, %ebx
@@ -25,3 +21,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(setsockopt)
diff --git a/libc/arch-x86/syscalls/settimeofday.S b/libc/arch-x86/syscalls/settimeofday.S
index e77fa1e..bc95fec 100644
--- a/libc/arch-x86/syscalls/settimeofday.S
+++ b/libc/arch-x86/syscalls/settimeofday.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type settimeofday, @function
-    .globl settimeofday
-    .align 4
-
-settimeofday:
+ENTRY(settimeofday)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(settimeofday)
diff --git a/libc/arch-x86/syscalls/setxattr.S b/libc/arch-x86/syscalls/setxattr.S
index 38be736..9dc87e3 100644
--- a/libc/arch-x86/syscalls/setxattr.S
+++ b/libc/arch-x86/syscalls/setxattr.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type setxattr, @function
-    .globl setxattr
-    .align 4
-
-setxattr:
+ENTRY(setxattr)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -33,3 +29,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(setxattr)
diff --git a/libc/arch-x86/syscalls/shutdown.S b/libc/arch-x86/syscalls/shutdown.S
index 45f0664..7fa36a1 100644
--- a/libc/arch-x86/syscalls/shutdown.S
+++ b/libc/arch-x86/syscalls/shutdown.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type shutdown, @function
-    .globl shutdown
-    .align 4
-
-shutdown:
+ENTRY(shutdown)
     pushl   %ebx
     pushl   %ecx
     mov     $13, %ebx
@@ -25,3 +21,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(shutdown)
diff --git a/libc/arch-x86/syscalls/sigaction.S b/libc/arch-x86/syscalls/sigaction.S
index b16e3aa..4fd5993 100644
--- a/libc/arch-x86/syscalls/sigaction.S
+++ b/libc/arch-x86/syscalls/sigaction.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sigaction, @function
-    .globl sigaction
-    .align 4
-
-sigaction:
+ENTRY(sigaction)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(sigaction)
diff --git a/libc/arch-x86/syscalls/sigaltstack.S b/libc/arch-x86/syscalls/sigaltstack.S
index d39419d..830c99f 100644
--- a/libc/arch-x86/syscalls/sigaltstack.S
+++ b/libc/arch-x86/syscalls/sigaltstack.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sigaltstack, @function
-    .globl sigaltstack
-    .align 4
-
-sigaltstack:
+ENTRY(sigaltstack)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(sigaltstack)
diff --git a/libc/arch-x86/syscalls/signalfd4.S b/libc/arch-x86/syscalls/signalfd4.S
new file mode 100644
index 0000000..57e0233
--- /dev/null
+++ b/libc/arch-x86/syscalls/signalfd4.S
@@ -0,0 +1,29 @@
+/* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
+#include <sys/linux-syscalls.h>
+
+ENTRY(signalfd4)
+    pushl   %ebx
+    pushl   %ecx
+    pushl   %edx
+    pushl   %esi
+    mov     20(%esp), %ebx
+    mov     24(%esp), %ecx
+    mov     28(%esp), %edx
+    mov     32(%esp), %esi
+    movl    $__NR_signalfd4, %eax
+    int     $0x80
+    cmpl    $-129, %eax
+    jb      1f
+    negl    %eax
+    pushl   %eax
+    call    __set_errno
+    addl    $4, %esp
+    orl     $-1, %eax
+1:
+    popl    %esi
+    popl    %edx
+    popl    %ecx
+    popl    %ebx
+    ret
+END(signalfd4)
diff --git a/libc/arch-x86/syscalls/sigpending.S b/libc/arch-x86/syscalls/sigpending.S
index 2280886..2f009b2 100644
--- a/libc/arch-x86/syscalls/sigpending.S
+++ b/libc/arch-x86/syscalls/sigpending.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sigpending, @function
-    .globl sigpending
-    .align 4
-
-sigpending:
+ENTRY(sigpending)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_sigpending, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(sigpending)
diff --git a/libc/arch-x86/syscalls/sigprocmask.S b/libc/arch-x86/syscalls/sigprocmask.S
index 42fcf92..81cdfa2 100644
--- a/libc/arch-x86/syscalls/sigprocmask.S
+++ b/libc/arch-x86/syscalls/sigprocmask.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sigprocmask, @function
-    .globl sigprocmask
-    .align 4
-
-sigprocmask:
+ENTRY(sigprocmask)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(sigprocmask)
diff --git a/libc/arch-x86/syscalls/socket.S b/libc/arch-x86/syscalls/socket.S
index 89a8358..8cc93bd 100644
--- a/libc/arch-x86/syscalls/socket.S
+++ b/libc/arch-x86/syscalls/socket.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type socket, @function
-    .globl socket
-    .align 4
-
-socket:
+ENTRY(socket)
     pushl   %ebx
     pushl   %ecx
     mov     $1, %ebx
@@ -25,3 +21,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(socket)
diff --git a/libc/arch-x86/syscalls/socketpair.S b/libc/arch-x86/syscalls/socketpair.S
index 0222989..ccfc847 100644
--- a/libc/arch-x86/syscalls/socketpair.S
+++ b/libc/arch-x86/syscalls/socketpair.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type socketpair, @function
-    .globl socketpair
-    .align 4
-
-socketpair:
+ENTRY(socketpair)
     pushl   %ebx
     pushl   %ecx
     mov     $8, %ebx
@@ -25,3 +21,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(socketpair)
diff --git a/libc/arch-x86/syscalls/stat.S b/libc/arch-x86/syscalls/stat.S
index c9984f1..83d1af8 100644
--- a/libc/arch-x86/syscalls/stat.S
+++ b/libc/arch-x86/syscalls/stat.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type stat, @function
-    .globl stat
-    .align 4
-
-stat:
+ENTRY(stat)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(stat)
diff --git a/libc/arch-x86/syscalls/symlink.S b/libc/arch-x86/syscalls/symlink.S
index 04c4298..dbc5490 100644
--- a/libc/arch-x86/syscalls/symlink.S
+++ b/libc/arch-x86/syscalls/symlink.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type symlink, @function
-    .globl symlink
-    .align 4
-
-symlink:
+ENTRY(symlink)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(symlink)
diff --git a/libc/arch-x86/syscalls/sync.S b/libc/arch-x86/syscalls/sync.S
index 5a6a727..f337c2c 100644
--- a/libc/arch-x86/syscalls/sync.S
+++ b/libc/arch-x86/syscalls/sync.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sync, @function
-    .globl sync
-    .align 4
-
-sync:
+ENTRY(sync)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_sync, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(sync)
diff --git a/libc/arch-x86/syscalls/sysinfo.S b/libc/arch-x86/syscalls/sysinfo.S
index c60c37b..ef9fcb0 100644
--- a/libc/arch-x86/syscalls/sysinfo.S
+++ b/libc/arch-x86/syscalls/sysinfo.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sysinfo, @function
-    .globl sysinfo
-    .align 4
-
-sysinfo:
+ENTRY(sysinfo)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_sysinfo, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(sysinfo)
diff --git a/libc/arch-x86/syscalls/tgkill.S b/libc/arch-x86/syscalls/tgkill.S
index 99af740..6d5dc88 100644
--- a/libc/arch-x86/syscalls/tgkill.S
+++ b/libc/arch-x86/syscalls/tgkill.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type tgkill, @function
-    .globl tgkill
-    .align 4
-
-tgkill:
+ENTRY(tgkill)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(tgkill)
diff --git a/libc/arch-x86/syscalls/times.S b/libc/arch-x86/syscalls/times.S
index 543f2be..04991a8 100644
--- a/libc/arch-x86/syscalls/times.S
+++ b/libc/arch-x86/syscalls/times.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type times, @function
-    .globl times
-    .align 4
-
-times:
+ENTRY(times)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_times, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(times)
diff --git a/libc/arch-x86/syscalls/tkill.S b/libc/arch-x86/syscalls/tkill.S
index f1f174b..51eb1c8 100644
--- a/libc/arch-x86/syscalls/tkill.S
+++ b/libc/arch-x86/syscalls/tkill.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type tkill, @function
-    .globl tkill
-    .align 4
-
-tkill:
+ENTRY(tkill)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(tkill)
diff --git a/libc/arch-x86/syscalls/truncate.S b/libc/arch-x86/syscalls/truncate.S
index 8c6646d..9e9b08d 100644
--- a/libc/arch-x86/syscalls/truncate.S
+++ b/libc/arch-x86/syscalls/truncate.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type truncate, @function
-    .globl truncate
-    .align 4
-
-truncate:
+ENTRY(truncate)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(truncate)
diff --git a/libc/arch-x86/syscalls/umask.S b/libc/arch-x86/syscalls/umask.S
index fe3d8cd..f2bf7b0 100644
--- a/libc/arch-x86/syscalls/umask.S
+++ b/libc/arch-x86/syscalls/umask.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type umask, @function
-    .globl umask
-    .align 4
-
-umask:
+ENTRY(umask)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_umask, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(umask)
diff --git a/libc/arch-x86/syscalls/umount2.S b/libc/arch-x86/syscalls/umount2.S
index fdb5354..1949489 100644
--- a/libc/arch-x86/syscalls/umount2.S
+++ b/libc/arch-x86/syscalls/umount2.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type umount2, @function
-    .globl umount2
-    .align 4
-
-umount2:
+ENTRY(umount2)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(umount2)
diff --git a/libc/arch-x86/syscalls/uname.S b/libc/arch-x86/syscalls/uname.S
index b5e8bfa..9b2c746 100644
--- a/libc/arch-x86/syscalls/uname.S
+++ b/libc/arch-x86/syscalls/uname.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type uname, @function
-    .globl uname
-    .align 4
-
-uname:
+ENTRY(uname)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_uname, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(uname)
diff --git a/libc/arch-x86/syscalls/unlink.S b/libc/arch-x86/syscalls/unlink.S
index 0fe52bf..0d9ce84 100644
--- a/libc/arch-x86/syscalls/unlink.S
+++ b/libc/arch-x86/syscalls/unlink.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type unlink, @function
-    .globl unlink
-    .align 4
-
-unlink:
+ENTRY(unlink)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_unlink, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(unlink)
diff --git a/libc/arch-x86/syscalls/unlinkat.S b/libc/arch-x86/syscalls/unlinkat.S
index f6f8c17..d05b488 100644
--- a/libc/arch-x86/syscalls/unlinkat.S
+++ b/libc/arch-x86/syscalls/unlinkat.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type unlinkat, @function
-    .globl unlinkat
-    .align 4
-
-unlinkat:
+ENTRY(unlinkat)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(unlinkat)
diff --git a/libc/arch-x86/syscalls/unshare.S b/libc/arch-x86/syscalls/unshare.S
index ef31a35..da0f563 100644
--- a/libc/arch-x86/syscalls/unshare.S
+++ b/libc/arch-x86/syscalls/unshare.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type unshare, @function
-    .globl unshare
-    .align 4
-
-unshare:
+ENTRY(unshare)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_unshare, %eax
@@ -21,3 +17,4 @@
 1:
     popl    %ebx
     ret
+END(unshare)
diff --git a/libc/arch-x86/syscalls/utimensat.S b/libc/arch-x86/syscalls/utimensat.S
index e2032b5..fb1d630 100644
--- a/libc/arch-x86/syscalls/utimensat.S
+++ b/libc/arch-x86/syscalls/utimensat.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type utimensat, @function
-    .globl utimensat
-    .align 4
-
-utimensat:
+ENTRY(utimensat)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -30,3 +26,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(utimensat)
diff --git a/libc/arch-x86/syscalls/utimes.S b/libc/arch-x86/syscalls/utimes.S
index 1a1b51d..189f6b9 100644
--- a/libc/arch-x86/syscalls/utimes.S
+++ b/libc/arch-x86/syscalls/utimes.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type utimes, @function
-    .globl utimes
-    .align 4
-
-utimes:
+ENTRY(utimes)
     pushl   %ebx
     pushl   %ecx
     mov     12(%esp), %ebx
@@ -24,3 +20,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(utimes)
diff --git a/libc/arch-x86/syscalls/write.S b/libc/arch-x86/syscalls/write.S
index caa450f..7f0b030 100644
--- a/libc/arch-x86/syscalls/write.S
+++ b/libc/arch-x86/syscalls/write.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type write, @function
-    .globl write
-    .align 4
-
-write:
+ENTRY(write)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(write)
diff --git a/libc/arch-x86/syscalls/writev.S b/libc/arch-x86/syscalls/writev.S
index 53d3731..0757a44 100644
--- a/libc/arch-x86/syscalls/writev.S
+++ b/libc/arch-x86/syscalls/writev.S
@@ -1,12 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type writev, @function
-    .globl writev
-    .align 4
-
-writev:
+ENTRY(writev)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -27,3 +23,4 @@
     popl    %ecx
     popl    %ebx
     ret
+END(writev)
diff --git a/libc/bionic/ThreadLocalBuffer.h b/libc/bionic/ThreadLocalBuffer.h
deleted file mode 100644
index 99acdba..0000000
--- a/libc/bionic/ThreadLocalBuffer.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _BIONIC_THREAD_LOCAL_BUFFER_H_included
-#define _BIONIC_THREAD_LOCAL_BUFFER_H_included
-
-#include <malloc.h>
-#include <pthread.h>
-
-// libstdc++ currently contains __cxa_guard_acquire and __cxa_guard_release,
-// so we make do with macros instead of a C++ class.
-// TODO: move __cxa_guard_acquire and __cxa_guard_release into libc.
-
-#define GLOBAL_INIT_THREAD_LOCAL_BUFFER(name) \
-  static pthread_once_t name ## _once; \
-  static pthread_key_t name ## _key; \
-  static void name ## _key_destroy(void* buffer) { \
-    free(buffer); \
-  } \
-  static void name ## _key_init() { \
-    pthread_key_create(&name ## _key, name ## _key_destroy); \
-  }
-
-// Leaves "name_buffer" and "name_byte_count" defined and initialized.
-#define LOCAL_INIT_THREAD_LOCAL_BUFFER(type, name, byte_count) \
-  pthread_once(&name ## _once, name ## _key_init); \
-  type name ## _buffer = reinterpret_cast<type>(pthread_getspecific(name ## _key)); \
-  if (name ## _buffer == NULL) { \
-    name ## _buffer = reinterpret_cast<type>(malloc(byte_count)); \
-    pthread_setspecific(name ## _key, name ## _buffer); \
-  } \
-  const size_t name ## _buffer_size = byte_count
-
-#endif // _BIONIC_THREAD_LOCAL_BUFFER_H_included
diff --git a/libc/bionic/__fgets_chk.cpp b/libc/bionic/__fgets_chk.cpp
new file mode 100644
index 0000000..6ae97cc
--- /dev/null
+++ b/libc/bionic/__fgets_chk.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <private/logd.h>
+
+/*
+ * __fgets_chk. Called in place of fgets() when we know the
+ * size of the buffer we're writing into.
+ *
+ * See
+ *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
+ * for details.
+ *
+ * This fgets check is called if _FORTIFY_SOURCE is defined and
+ * greater than 0.
+ */
+extern "C" char *__fgets_chk(char *dest, int supplied_size,
+                  FILE *stream, size_t dest_len_from_compiler)
+{
+    if (supplied_size < 0) {
+        __fortify_chk_fail("fgets buffer size less than 0", 0);
+    }
+
+    if (((size_t) supplied_size) > dest_len_from_compiler) {
+        __fortify_chk_fail("fgets buffer overflow", 0);
+    }
+
+    return fgets(dest, supplied_size, stream);
+}
diff --git a/libc/bionic/__memcpy_chk.cpp b/libc/bionic/__memcpy_chk.cpp
new file mode 100644
index 0000000..7a98cb7
--- /dev/null
+++ b/libc/bionic/__memcpy_chk.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#undef _FORTIFY_SOURCE
+#include <string.h>
+#include <stdlib.h>
+#include <private/logd.h>
+
+/*
+ * Runtime implementation of __memcpy_chk.
+ *
+ * See
+ *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
+ *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
+ * for details.
+ *
+ * This memcpy check is called if _FORTIFY_SOURCE is defined and
+ * greater than 0.
+ */
+extern "C" void *__memcpy_chk(void *dest, const void *src,
+              size_t copy_amount, size_t dest_len)
+{
+    if (__builtin_expect(copy_amount > dest_len, 0)) {
+        __fortify_chk_fail("memcpy buffer overflow",
+                             BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW);
+    }
+
+    return memcpy(dest, src, copy_amount);
+}
diff --git a/libc/bionic/__memmove_chk.cpp b/libc/bionic/__memmove_chk.cpp
new file mode 100644
index 0000000..51f2e1c
--- /dev/null
+++ b/libc/bionic/__memmove_chk.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <private/logd.h>
+
+/*
+ * Runtime implementation of __builtin____memmove_chk.
+ *
+ * See
+ *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
+ *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
+ * for details.
+ *
+ * This memmove check is called if _FORTIFY_SOURCE is defined and
+ * greater than 0.
+ */
+extern "C" void *__memmove_chk (void *dest, const void *src,
+              size_t len, size_t dest_len)
+{
+    if (len > dest_len) {
+        __fortify_chk_fail("memmove buffer overflow",
+                             BIONIC_EVENT_MEMMOVE_BUFFER_OVERFLOW);
+    }
+
+    return memmove(dest, src, len);
+}
diff --git a/libc/bionic/__memset_chk.cpp b/libc/bionic/__memset_chk.cpp
new file mode 100644
index 0000000..99a12ad
--- /dev/null
+++ b/libc/bionic/__memset_chk.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <private/logd.h>
+
+/*
+ * Runtime implementation of __builtin____memset_chk.
+ *
+ * See
+ *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
+ *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
+ * for details.
+ *
+ * This memset check is called if _FORTIFY_SOURCE is defined and
+ * greater than 0.
+ */
+extern "C" void *__memset_chk (void *dest, int c, size_t n, size_t dest_len) {
+    if (n > dest_len) {
+        __fortify_chk_fail("memset buffer overflow",
+                             BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW);
+    }
+
+    return memset(dest, c, n);
+}
diff --git a/libc/bionic/__set_errno.c b/libc/bionic/__set_errno.c
deleted file mode 100644
index 163d404..0000000
--- a/libc/bionic/__set_errno.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <errno.h>
-
-
-int __set_errno(int n)
-{
-    errno = n;
-    return -1;
-}
-
-/*
- * this function is called from syscall stubs,
- * (tail-called in the case of 0-4 arg versions)
- */
-
-__LIBC_HIDDEN__
-int __set_syscall_errno(int n)
-{
-        /* some syscalls, mmap() for example, have valid return
-        ** values that are "negative".  Since errno values are not
-        ** greater than 131 on Linux, we will just consider 
-        ** anything significantly out of range as not-an-error
-        */
-    if(n > -256) {
-        return __set_errno(-n);
-    } else {
-        return n;
-    }
-}
diff --git a/libc/bionic/__set_errno.cpp b/libc/bionic/__set_errno.cpp
new file mode 100644
index 0000000..5b249c8
--- /dev/null
+++ b/libc/bionic/__set_errno.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+
+// These functions are called from our assembler syscall stubs.
+// C/C++ code should just assign 'errno' instead.
+
+// TODO: should be __LIBC_HIDDEN__, but already exported by NDK :-(
+// TODO: this isn't used on ARM.
+extern "C" int __set_errno(int n) {
+  errno = n;
+  return -1;
+}
+
+// TODO: this is only used on ARM, but is exported by NDK on all platforms :-(
+extern "C" __LIBC_HIDDEN__ int __set_syscall_errno(int n) {
+  // Some syscalls, mmap() for example, have valid return
+  // values that are "negative".  Since errno values are not
+  // greater than 131 on Linux, we will just consider
+  // anything significantly out of range as not-an-error.
+  if(n > -256) {
+    return __set_errno(-n);
+  } else {
+    return n;
+  }
+}
diff --git a/libc/bionic/__stack_chk_fail.cpp b/libc/bionic/__stack_chk_fail.cpp
new file mode 100644
index 0000000..cae66b1
--- /dev/null
+++ b/libc/bionic/__stack_chk_fail.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+
+#include "bionic_ssp.h"
+#include "debug_format.h"
+#include "logd.h"
+
+void __stack_chk_fail() {
+  __libc_format_log(ANDROID_LOG_FATAL, "libc", "stack corruption detected");
+  abort();
+}
diff --git a/libc/bionic/__strcat_chk.cpp b/libc/bionic/__strcat_chk.cpp
new file mode 100644
index 0000000..2450da6
--- /dev/null
+++ b/libc/bionic/__strcat_chk.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <private/logd.h>
+#include <safe_iop.h>
+
+/*
+ * Runtime implementation of __builtin____strcat_chk.
+ *
+ * See
+ *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
+ *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
+ * for details.
+ *
+ * This strcat check is called if _FORTIFY_SOURCE is defined and
+ * greater than 0.
+ */
+extern "C" char *__strcat_chk (char *dest, const char *src, size_t dest_buf_size) {
+    // TODO: optimize so we don't scan src/dest twice.
+    size_t src_len  = strlen(src);
+    size_t dest_len = strlen(dest);
+    size_t sum;
+
+    // sum = src_len + dest_len + 1 (with overflow protection)
+    if (!safe_add3(&sum, src_len, dest_len, 1U)) {
+        __fortify_chk_fail("strcat integer overflow",
+                             BIONIC_EVENT_STRCAT_INTEGER_OVERFLOW);
+    }
+
+    if (sum > dest_buf_size) {
+        __fortify_chk_fail("strcat buffer overflow",
+                             BIONIC_EVENT_STRCAT_BUFFER_OVERFLOW);
+    }
+
+    return strcat(dest, src);
+}
diff --git a/libc/bionic/__strcpy_chk.cpp b/libc/bionic/__strcpy_chk.cpp
new file mode 100644
index 0000000..74ceda1
--- /dev/null
+++ b/libc/bionic/__strcpy_chk.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <private/logd.h>
+
+/*
+ * Runtime implementation of __builtin____strcpy_chk.
+ *
+ * See
+ *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
+ *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
+ * for details.
+ *
+ * This strcpy check is called if _FORTIFY_SOURCE is defined and
+ * greater than 0.
+ */
+extern "C" char *__strcpy_chk (char *dest, const char *src, size_t dest_len) {
+    // TODO: optimize so we don't scan src twice.
+    size_t src_len = strlen(src) + 1;
+    if (src_len > dest_len) {
+        __fortify_chk_fail("strcpy buffer overflow",
+                             BIONIC_EVENT_STRCPY_BUFFER_OVERFLOW);
+    }
+
+    return strcpy(dest, src);
+}
diff --git a/libc/bionic/__strlcat_chk.cpp b/libc/bionic/__strlcat_chk.cpp
new file mode 100644
index 0000000..12676f4
--- /dev/null
+++ b/libc/bionic/__strlcat_chk.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <private/logd.h>
+
+/*
+ * __strlcat_chk. Called in place of strlcat() when we know the
+ * size of the buffer we're writing into.
+ *
+ * See
+ *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
+ *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
+ * for details.
+ *
+ * This strlcat check is called if _FORTIFY_SOURCE is defined and
+ * greater than 0.
+ */
+extern "C" size_t __strlcat_chk(char *dest, const char *src,
+              size_t supplied_size, size_t dest_len_from_compiler)
+{
+    if (supplied_size > dest_len_from_compiler) {
+        __fortify_chk_fail("strlcat buffer overflow", 0);
+    }
+
+    return strlcat(dest, src, supplied_size);
+}
diff --git a/libc/bionic/__strlcpy_chk.cpp b/libc/bionic/__strlcpy_chk.cpp
new file mode 100644
index 0000000..62fa14b
--- /dev/null
+++ b/libc/bionic/__strlcpy_chk.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <private/logd.h>
+
+/*
+ * __strlcpy_chk. Called in place of strlcpy() when we know the
+ * size of the buffer we're writing into.
+ *
+ * See
+ *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
+ *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
+ * for details.
+ *
+ * This strlcpy check is called if _FORTIFY_SOURCE is defined and
+ * greater than 0.
+ */
+extern "C" size_t __strlcpy_chk(char *dest, const char *src,
+              size_t supplied_size, size_t dest_len_from_compiler)
+{
+    if (supplied_size > dest_len_from_compiler) {
+        __fortify_chk_fail("strlcpy buffer overflow", 0);
+    }
+
+    return strlcpy(dest, src, supplied_size);
+}
diff --git a/libc/bionic/__strlen_chk.cpp b/libc/bionic/__strlen_chk.cpp
new file mode 100644
index 0000000..5cc052e
--- /dev/null
+++ b/libc/bionic/__strlen_chk.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <private/logd.h>
+
+/*
+ * Runtime implementation of __strlen_chk.
+ *
+ * See
+ *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
+ *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
+ * for details.
+ *
+ * This strlen check is called if _FORTIFY_SOURCE is defined and
+ * greater than 0.
+ *
+ * This test is designed to detect code such as:
+ *
+ * int main() {
+ *   char buf[10];
+ *   memcpy(buf, "1234567890", sizeof(buf));
+ *   size_t len = strlen(buf); // segfault here with _FORTIFY_SOURCE
+ *   printf("%d\n", len);
+ *   return 0;
+ * }
+ *
+ * or anytime strlen reads beyond an object boundary.
+ */
+extern "C" size_t __strlen_chk(const char *s, size_t s_len) {
+    size_t ret = strlen(s);
+
+    if (__builtin_expect(ret >= s_len, 0)) {
+        __fortify_chk_fail("strlen read overflow", 0);
+    }
+
+    return ret;
+}
diff --git a/libc/bionic/__strncat_chk.cpp b/libc/bionic/__strncat_chk.cpp
new file mode 100644
index 0000000..32a3962
--- /dev/null
+++ b/libc/bionic/__strncat_chk.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <private/logd.h>
+#include <safe_iop.h>
+
+/*
+ * Runtime implementation of __builtin____strncat_chk.
+ *
+ * See
+ *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
+ *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
+ * for details.
+ *
+ * This strncat check is called if _FORTIFY_SOURCE is defined and
+ * greater than 0.
+ */
+extern "C" char *__strncat_chk (char *dest, const char *src,
+              size_t len, size_t dest_buf_size)
+{
+    // TODO: optimize so we don't scan src/dest twice.
+    size_t dest_len = strlen(dest);
+    size_t src_len = strlen(src);
+    if (src_len > len) {
+        src_len = len;
+    }
+
+    size_t sum;
+    // sum = src_len + dest_len + 1 (with overflow protection)
+    if (!safe_add3(&sum, src_len, dest_len, 1U)) {
+        __fortify_chk_fail("strncat integer overflow",
+                             BIONIC_EVENT_STRNCAT_INTEGER_OVERFLOW);
+    }
+
+    if (sum > dest_buf_size) {
+        __fortify_chk_fail("strncat buffer overflow",
+                             BIONIC_EVENT_STRNCAT_BUFFER_OVERFLOW);
+    }
+
+    return strncat(dest, src, len);
+}
diff --git a/libc/bionic/__strncpy_chk.cpp b/libc/bionic/__strncpy_chk.cpp
new file mode 100644
index 0000000..c9676ed
--- /dev/null
+++ b/libc/bionic/__strncpy_chk.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <private/logd.h>
+
+/*
+ * Runtime implementation of __builtin____strncpy_chk.
+ *
+ * See
+ *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
+ *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
+ * for details.
+ *
+ * This strncpy check is called if _FORTIFY_SOURCE is defined and
+ * greater than 0.
+ */
+extern "C" char *__strncpy_chk (char *dest, const char *src,
+              size_t len, size_t dest_len)
+{
+    if (len > dest_len) {
+        __fortify_chk_fail("strncpy buffer overflow",
+                             BIONIC_EVENT_STRNCPY_BUFFER_OVERFLOW);
+    }
+
+    return strncpy(dest, src, len);
+}
diff --git a/libc/bionic/__umask_chk.cpp b/libc/bionic/__umask_chk.cpp
new file mode 100644
index 0000000..e1bc96d
--- /dev/null
+++ b/libc/bionic/__umask_chk.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#undef _FORTIFY_SOURCE
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <private/logd.h>
+#include <stdlib.h>
+
+/*
+ * Runtime implementation of __umask_chk.
+ *
+ * Validate that umask is called with sane mode.
+ *
+ * This umask check is called if _FORTIFY_SOURCE is defined and
+ * greater than 0.
+ */
+extern "C" mode_t __umask_chk(mode_t mode) {
+    if ((mode & 0777) != mode) {
+        __fortify_chk_fail("umask called with invalid mask", 0);
+    }
+
+    return umask(mode);
+}
diff --git a/libc/bionic/__vsnprintf_chk.cpp b/libc/bionic/__vsnprintf_chk.cpp
new file mode 100644
index 0000000..95d4915
--- /dev/null
+++ b/libc/bionic/__vsnprintf_chk.cpp
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <private/logd.h>
+
+/*
+ * Runtime implementation of __builtin____vsnprintf_chk.
+ *
+ * See
+ *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
+ *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
+ * for details.
+ *
+ * This vsnprintf check is called if _FORTIFY_SOURCE is defined and
+ * greater than 0.
+ */
+extern "C" int __vsnprintf_chk(
+        char *dest,
+        size_t supplied_size,
+        int /*flags*/,
+        size_t dest_len_from_compiler,
+        const char *format,
+        va_list va)
+{
+    if (supplied_size > dest_len_from_compiler) {
+        __fortify_chk_fail("vsnprintf buffer overflow", 0);
+    }
+
+    return vsnprintf(dest, supplied_size, format, va);
+}
+
+/*
+ * Runtime implementation of __builtin____snprintf_chk.
+ *
+ * See
+ *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
+ *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
+ * for details.
+ *
+ * This snprintf check is called if _FORTIFY_SOURCE is defined and
+ * greater than 0.
+ */
+extern "C" int __snprintf_chk(
+        char *dest,
+        size_t supplied_size,
+        int flags,
+        size_t dest_len_from_compiler,
+        const char *format, ...)
+{
+    va_list va;
+    int retval;
+
+    va_start(va, format);
+    retval = __vsnprintf_chk(dest, supplied_size, flags,
+                             dest_len_from_compiler, format, va);
+    va_end(va);
+
+    return retval;
+}
diff --git a/libc/bionic/__vsprintf_chk.cpp b/libc/bionic/__vsprintf_chk.cpp
new file mode 100644
index 0000000..e1d10f5
--- /dev/null
+++ b/libc/bionic/__vsprintf_chk.cpp
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <private/logd.h>
+
+/*
+ * Runtime implementation of __builtin____vsprintf_chk.
+ *
+ * See
+ *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
+ *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
+ * for details.
+ *
+ * This vsprintf check is called if _FORTIFY_SOURCE is defined and
+ * greater than 0.
+ */
+extern "C" int __vsprintf_chk(
+        char *dest,
+        int /*flags*/,
+        size_t dest_len_from_compiler,
+        const char *format,
+        va_list va)
+{
+    int ret = vsnprintf(dest, dest_len_from_compiler, format, va);
+
+    if ((size_t) ret >= dest_len_from_compiler) {
+        __fortify_chk_fail("vsprintf buffer overflow", 0);
+    }
+
+    return ret;
+}
+
+/*
+ * Runtime implementation of __builtin____sprintf_chk.
+ *
+ * See
+ *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
+ *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
+ * for details.
+ *
+ * This sprintf check is called if _FORTIFY_SOURCE is defined and
+ * greater than 0.
+ */
+extern "C" int __sprintf_chk(
+        char *dest,
+        int flags,
+        size_t dest_len_from_compiler,
+        const char *format, ...)
+{
+    va_list va;
+    int retval;
+
+    va_start(va, format);
+    retval = __vsprintf_chk(dest, flags,
+                             dest_len_from_compiler, format, va);
+    va_end(va);
+
+    return retval;
+}
diff --git a/libc/bionic/assert.cpp b/libc/bionic/assert.cpp
new file mode 100644
index 0000000..e38c16d
--- /dev/null
+++ b/libc/bionic/assert.cpp
@@ -0,0 +1,55 @@
+/*	$OpenBSD: assert.c,v 1.8 2005/08/08 08:05:33 espie Exp $ */
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <private/debug_format.h>
+#include <private/logd.h>
+
+// We log to stderr for the benefit of "adb shell" users, and the log for the benefit
+// of regular app developers who want to see their asserts.
+
+void __assert(const char* file, int line, const char* failed_expression) {
+  const char* fmt = "%s:%d: assertion \"%s\" failed\n";
+  __libc_format_log(ANDROID_LOG_FATAL, "libc", fmt, file, line, failed_expression);
+  fprintf(stderr, fmt, file, line, failed_expression);
+  abort();
+  /* NOTREACHED */
+}
+
+void __assert2(const char* file, int line, const char* function, const char* failed_expression) {
+  const char* fmt = "%s:%d: %s: assertion \"%s\" failed\n";
+  __libc_format_log(ANDROID_LOG_FATAL, "libc", fmt, file, line, function, failed_expression);
+  fprintf(stderr, fmt, file, line, function, failed_expression);
+  abort();
+  /* NOTREACHED */
+}
diff --git a/libc/stdlib/atoi.c b/libc/bionic/atoi.c
similarity index 100%
rename from libc/stdlib/atoi.c
rename to libc/bionic/atoi.c
diff --git a/libc/stdlib/atol.c b/libc/bionic/atol.c
similarity index 100%
rename from libc/stdlib/atol.c
rename to libc/bionic/atol.c
diff --git a/libc/stdlib/atoll.c b/libc/bionic/atoll.c
similarity index 100%
rename from libc/stdlib/atoll.c
rename to libc/bionic/atoll.c
diff --git a/libc/bionic/basename.c b/libc/bionic/basename.c
deleted file mode 100644
index 8aaae53..0000000
--- a/libc/bionic/basename.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <sys/cdefs.h>
-
-#include <errno.h>
-#include <libgen.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/param.h>
-
-char*
-basename(const char*  path)
-{
-    static char*  bname = NULL;
-    int           ret;
-
-    if (bname == NULL) {
-        bname = (char *)malloc(MAXPATHLEN);
-        if (bname == NULL)
-            return(NULL);
-    }
-    ret = basename_r(path, bname, MAXPATHLEN);
-    return (ret < 0) ? NULL : bname;
-}
diff --git a/libc/bionic/basename_r.c b/libc/bionic/basename_r.c
deleted file mode 100644
index e9080f0..0000000
--- a/libc/bionic/basename_r.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <libgen.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/param.h>
-
-int
-basename_r(const char* path, char*  buffer, size_t  bufflen)
-{
-    const char *endp, *startp;
-    int         len, result;
-    char        temp[2];
-
-    /* Empty or NULL string gets treated as "." */
-    if (path == NULL || *path == '\0') {
-        startp  = ".";
-        len     = 1;
-        goto Exit;
-    }
-
-    /* Strip trailing slashes */
-    endp = path + strlen(path) - 1;
-    while (endp > path && *endp == '/')
-        endp--;
-
-    /* All slashes becomes "/" */
-    if (endp == path && *endp == '/') {
-        startp = "/";
-        len    = 1;
-        goto Exit;
-    }
-
-    /* Find the start of the base */
-    startp = endp;
-    while (startp > path && *(startp - 1) != '/')
-        startp--;
-
-    len = endp - startp +1;
-
-Exit:
-    result = len;
-    if (buffer == NULL) {
-        return result;
-    }
-    if (len > (int)bufflen-1) {
-        len    = (int)bufflen-1;
-        result = -1;
-        errno  = ERANGE;
-    }
-
-    if (len >= 0) {
-        memcpy( buffer, startp, len );
-        buffer[len] = 0;
-    }
-    return result;
-}
diff --git a/libc/inet/bindresvport.c b/libc/bionic/bindresvport.c
similarity index 100%
rename from libc/inet/bindresvport.c
rename to libc/bionic/bindresvport.c
diff --git a/libc/bionic/bionic_clone.c b/libc/bionic/bionic_clone.c
index 187b60d..8412057 100644
--- a/libc/bionic/bionic_clone.c
+++ b/libc/bionic/bionic_clone.c
@@ -58,9 +58,8 @@
     int     *parent_tidptr = NULL;
     void    *new_tls = NULL;
     int     *child_tidptr = NULL;
-    int     ret;
 
-    /* extract optional parameters - they are cummulative */
+    /* extract optional parameters - they are cumulative. */
     va_start(args, arg);
     if (flags & (CLONE_PARENT_SETTID|CLONE_SETTLS|CLONE_CHILD_SETTID)) {
         parent_tidptr = va_arg(args, int*);
@@ -73,6 +72,5 @@
     }
     va_end(args);
 
-    ret = __bionic_clone(flags, child_stack, parent_tidptr, new_tls, child_tidptr, fn, arg);
-    return ret;
+    return __bionic_clone(flags, child_stack, parent_tidptr, new_tls, child_tidptr, fn, arg);
 }
diff --git a/libc/bionic/brk.cpp b/libc/bionic/brk.cpp
new file mode 100644
index 0000000..633b914
--- /dev/null
+++ b/libc/bionic/brk.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+
+/* Shared with sbrk.c. */
+extern "C" void* __bionic_brk; // TODO: should be __LIBC_HIDDEN__ but accidentally exported by NDK :-(
+
+int brk(void* end_data) {
+  void* new_brk = __brk(end_data);
+  if (new_brk != end_data) {
+    return -1;
+  }
+  __bionic_brk = new_brk;
+  return 0;
+}
diff --git a/libc/unistd/daemon.c b/libc/bionic/daemon.c
similarity index 100%
rename from libc/unistd/daemon.c
rename to libc/bionic/daemon.c
diff --git a/libc/bionic/debug_format.cpp b/libc/bionic/debug_format.cpp
new file mode 100644
index 0000000..793f8b1
--- /dev/null
+++ b/libc/bionic/debug_format.cpp
@@ -0,0 +1,518 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <../private/debug_format.h> // Relative path so we can #include this for testing.
+
+#include <assert.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+
+/*** Generic output sink
+ ***/
+
+struct Out {
+  void *opaque;
+  void (*send)(void *opaque, const char *data, int len);
+};
+
+static void out_send(Out *o, const char *data, size_t len) {
+    o->send(o->opaque, data, (int)len);
+}
+
+static void
+out_send_repeat(Out *o, char ch, int count)
+{
+    char pad[8];
+    const int padSize = (int)sizeof(pad);
+
+    memset(pad, ch, sizeof(pad));
+    while (count > 0) {
+        int avail = count;
+        if (avail > padSize) {
+            avail = padSize;
+        }
+        o->send(o->opaque, pad, avail);
+        count -= avail;
+    }
+}
+
+/* forward declaration */
+static void out_vformat(Out* o, const char* format, va_list args);
+
+/*** Bounded buffer output
+ ***/
+
+struct BufOut {
+  Out out[1];
+  char *buffer;
+  char *pos;
+  char *end;
+  int total;
+};
+
+static void buf_out_send(void *opaque, const char *data, int len) {
+    BufOut *bo = reinterpret_cast<BufOut*>(opaque);
+
+    if (len < 0) {
+        len = strlen(data);
+    }
+
+    bo->total += len;
+
+    while (len > 0) {
+        int avail = bo->end - bo->pos;
+        if (avail == 0)
+            break;
+        if (avail > len)
+            avail = len;
+        memcpy(bo->pos, data, avail);
+        bo->pos += avail;
+        bo->pos[0] = '\0';
+        len -= avail;
+    }
+}
+
+static Out*
+buf_out_init(BufOut *bo, char *buffer, size_t size)
+{
+    if (size == 0)
+        return NULL;
+
+    bo->out->opaque = bo;
+    bo->out->send   = buf_out_send;
+    bo->buffer      = buffer;
+    bo->end         = buffer + size - 1;
+    bo->pos         = bo->buffer;
+    bo->pos[0]      = '\0';
+    bo->total       = 0;
+
+    return bo->out;
+}
+
+static int
+buf_out_length(BufOut *bo)
+{
+    return bo->total;
+}
+
+static int
+vformat_buffer(char *buff, size_t buf_size, const char *format, va_list args)
+{
+    BufOut bo;
+    Out *out;
+
+    out = buf_out_init(&bo, buff, buf_size);
+    if (out == NULL)
+        return 0;
+
+    out_vformat(out, format, args);
+
+    return buf_out_length(&bo);
+}
+
+int __libc_format_buffer(char* buffer, size_t buffer_size, const char* format, ...) {
+  va_list args;
+  va_start(args, format);
+  int result = vformat_buffer(buffer, buffer_size, format, args);
+  va_end(args);
+  return result;
+}
+
+
+/*** File descriptor output
+ ***/
+
+struct FdOut {
+  Out out[1];
+  int fd;
+  int total;
+};
+
+static void
+fd_out_send(void *opaque, const char *data, int len)
+{
+    FdOut *fdo = reinterpret_cast<FdOut*>(opaque);
+
+    if (len < 0)
+        len = strlen(data);
+
+    while (len > 0) {
+        int ret = write(fdo->fd, data, len);
+        if (ret < 0) {
+            if (errno == EINTR)
+                continue;
+            break;
+        }
+        data += ret;
+        len -= ret;
+        fdo->total += ret;
+    }
+}
+
+static Out*
+fd_out_init(FdOut *fdo, int  fd)
+{
+    fdo->out->opaque = fdo;
+    fdo->out->send = fd_out_send;
+    fdo->fd = fd;
+    fdo->total = 0;
+
+    return fdo->out;
+}
+
+static int
+fd_out_length(FdOut *fdo)
+{
+    return fdo->total;
+}
+
+
+int __libc_format_fd(int fd, const char* format, ...) {
+  FdOut fdo;
+  Out* out = fd_out_init(&fdo, fd);
+  if (out == NULL) {
+    return 0;
+  }
+
+  va_list args;
+  va_start(args, format);
+  out_vformat(out, format, args);
+  va_end(args);
+
+  return fd_out_length(&fdo);
+}
+
+/*** Log output
+ ***/
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/uio.h>
+
+int __libc_format_log_va_list(int priority, const char* tag, const char* fmt, va_list args) {
+  char buf[1024];
+  int result = vformat_buffer(buf, sizeof buf, fmt, args);
+
+  static int log_fd = -1;
+  if (log_fd == -1) {
+    log_fd = open("/dev/log/main", O_WRONLY);
+    if (log_fd == -1) {
+      return result;
+    }
+  }
+
+  struct iovec vec[3];
+  vec[0].iov_base = (unsigned char *) &priority;
+  vec[0].iov_len = 1;
+  vec[1].iov_base = (void *) tag;
+  vec[1].iov_len = strlen(tag) + 1;
+  vec[2].iov_base = (void *) buf;
+  vec[2].iov_len = strlen(buf) + 1;
+
+  TEMP_FAILURE_RETRY(writev(log_fd, vec, 3));
+
+  return result;
+}
+
+int __libc_format_log(int priority, const char* tag, const char* format, ...) {
+  va_list args;
+  va_start(args, format);
+  int result = __libc_format_log_va_list(priority, tag, format, args);
+  va_end(args);
+  return result;
+}
+
+/*** formatted output implementation
+ ***/
+
+/* Parse a decimal string from 'format + *ppos',
+ * return the value, and writes the new position past
+ * the decimal string in '*ppos' on exit.
+ *
+ * NOTE: Does *not* handle a sign prefix.
+ */
+static unsigned
+parse_decimal(const char *format, int *ppos)
+{
+    const char* p = format + *ppos;
+    unsigned result = 0;
+
+    for (;;) {
+        int ch = *p;
+        unsigned d = (unsigned)(ch - '0');
+
+        if (d >= 10U)
+            break;
+
+        result = result*10 + d;
+        p++;
+    }
+    *ppos = p - format;
+    return result;
+}
+
+// Writes number 'value' in base 'base' into buffer 'buf' of size 'buf_size' bytes.
+// Assumes that buf_size > 0.
+static void format_unsigned(char* buf, size_t buf_size, uint64_t value, int base, bool caps) {
+  char* p = buf;
+  char* end = buf + buf_size - 1;
+
+  // Generate digit string in reverse order.
+  while (value) {
+    unsigned d = value % base;
+    value /= base;
+    if (p != end) {
+      char ch;
+      if (d < 10) {
+        ch = '0' + d;
+      } else {
+        ch = (caps ? 'A' : 'a') + (d - 10);
+      }
+      *p++ = ch;
+    }
+  }
+
+  // Special case for 0.
+  if (p == buf) {
+    if (p != end) {
+      *p++ = '0';
+    }
+  }
+  *p = '\0';
+
+  // Reverse digit string in-place.
+  size_t length = p - buf;
+  for (size_t i = 0, j = length - 1; i < j; ++i, --j) {
+    char ch = buf[i];
+    buf[i] = buf[j];
+    buf[j] = ch;
+  }
+}
+
+static void format_integer(char* buf, size_t buf_size, uint64_t value, char conversion) {
+  // Decode the conversion specifier.
+  int is_signed = (conversion == 'd' || conversion == 'i' || conversion == 'o');
+  int base = 10;
+  if (conversion == 'x' || conversion == 'X') {
+    base = 16;
+  } else if (conversion == 'o') {
+    base = 8;
+  }
+  bool caps = (conversion == 'X');
+
+  if (is_signed && static_cast<int64_t>(value) < 0) {
+    buf[0] = '-';
+    buf += 1;
+    buf_size -= 1;
+    value = static_cast<uint64_t>(-static_cast<int64_t>(value));
+  }
+  format_unsigned(buf, buf_size, value, base, caps);
+}
+
+/* Perform formatted output to an output target 'o' */
+static void
+out_vformat(Out *o, const char *format, va_list args)
+{
+    int nn = 0;
+
+    for (;;) {
+        int mm;
+        int padZero = 0;
+        int padLeft = 0;
+        char sign = '\0';
+        int width = -1;
+        int prec  = -1;
+        size_t bytelen = sizeof(int);
+        int slen;
+        char buffer[32];  /* temporary buffer used to format numbers */
+
+        char  c;
+
+        /* first, find all characters that are not 0 or '%' */
+        /* then send them to the output directly */
+        mm = nn;
+        do {
+            c = format[mm];
+            if (c == '\0' || c == '%')
+                break;
+            mm++;
+        } while (1);
+
+        if (mm > nn) {
+            out_send(o, format+nn, mm-nn);
+            nn = mm;
+        }
+
+        /* is this it ? then exit */
+        if (c == '\0')
+            break;
+
+        /* nope, we are at a '%' modifier */
+        nn++;  // skip it
+
+        /* parse flags */
+        for (;;) {
+            c = format[nn++];
+            if (c == '\0') {  /* single trailing '%' ? */
+                c = '%';
+                out_send(o, &c, 1);
+                return;
+            }
+            else if (c == '0') {
+                padZero = 1;
+                continue;
+            }
+            else if (c == '-') {
+                padLeft = 1;
+                continue;
+            }
+            else if (c == ' ' || c == '+') {
+                sign = c;
+                continue;
+            }
+            break;
+        }
+
+        /* parse field width */
+        if ((c >= '0' && c <= '9')) {
+            nn --;
+            width = (int)parse_decimal(format, &nn);
+            c = format[nn++];
+        }
+
+        /* parse precision */
+        if (c == '.') {
+            prec = (int)parse_decimal(format, &nn);
+            c = format[nn++];
+        }
+
+        /* length modifier */
+        switch (c) {
+        case 'h':
+            bytelen = sizeof(short);
+            if (format[nn] == 'h') {
+                bytelen = sizeof(char);
+                nn += 1;
+            }
+            c = format[nn++];
+            break;
+        case 'l':
+            bytelen = sizeof(long);
+            if (format[nn] == 'l') {
+                bytelen = sizeof(long long);
+                nn += 1;
+            }
+            c = format[nn++];
+            break;
+        case 'z':
+            bytelen = sizeof(size_t);
+            c = format[nn++];
+            break;
+        case 't':
+            bytelen = sizeof(ptrdiff_t);
+            c = format[nn++];
+            break;
+        default:
+            ;
+        }
+
+        /* conversion specifier */
+        const char* str = buffer;
+        if (c == 's') {
+            /* string */
+            str = va_arg(args, const char*);
+            if (str == NULL) {
+                str = "(null)";
+            }
+        } else if (c == 'c') {
+            /* character */
+            /* NOTE: char is promoted to int when passed through the stack */
+            buffer[0] = (char) va_arg(args, int);
+            buffer[1] = '\0';
+        } else if (c == 'p') {
+            uint64_t  value = (uintptr_t) va_arg(args, void*);
+            buffer[0] = '0';
+            buffer[1] = 'x';
+            format_integer(buffer + 2, sizeof(buffer) - 2, value, 'x');
+        } else if (c == 'd' || c == 'i' || c == 'o' || c == 'x' || c == 'X') {
+            /* integers - first read value from stack */
+            uint64_t value;
+            int is_signed = (c == 'd' || c == 'i' || c == 'o');
+
+            /* NOTE: int8_t and int16_t are promoted to int when passed
+             *       through the stack
+             */
+            switch (bytelen) {
+            case 1: value = (uint8_t)  va_arg(args, int); break;
+            case 2: value = (uint16_t) va_arg(args, int); break;
+            case 4: value = va_arg(args, uint32_t); break;
+            case 8: value = va_arg(args, uint64_t); break;
+            default: return;  /* should not happen */
+            }
+
+            /* sign extension, if needed */
+            if (is_signed) {
+                int shift = 64 - 8*bytelen;
+                value = (uint64_t)(((int64_t)(value << shift)) >> shift);
+            }
+
+            /* format the number properly into our buffer */
+            format_integer(buffer, sizeof(buffer), value, c);
+        } else if (c == '%') {
+            buffer[0] = '%';
+            buffer[1] = '\0';
+        } else {
+            __assert(__FILE__, __LINE__, "conversion specifier unsupported");
+        }
+
+        /* if we are here, 'str' points to the content that must be
+         * outputted. handle padding and alignment now */
+
+        slen = strlen(str);
+
+        if (sign != '\0' || prec != -1) {
+            __assert(__FILE__, __LINE__, "sign/precision unsupported");
+        }
+
+        if (slen < width && !padLeft) {
+            char padChar = padZero ? '0' : ' ';
+            out_send_repeat(o, padChar, width - slen);
+        }
+
+        out_send(o, str, slen);
+
+        if (slen < width && padLeft) {
+            char padChar = padZero ? '0' : ' ';
+            out_send_repeat(o, padChar, width - slen);
+        }
+    }
+}
diff --git a/libc/bionic/debug_mapinfo.cpp b/libc/bionic/debug_mapinfo.cpp
new file mode 100644
index 0000000..c5b9aa7
--- /dev/null
+++ b/libc/bionic/debug_mapinfo.cpp
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "dlmalloc.h"
+#include "debug_mapinfo.h"
+
+// 6f000000-6f01e000 rwxp 00000000 00:0c 16389419   /system/lib/libcomposer.so
+// 012345678901234567890123456789012345678901234567890123456789
+// 0         1         2         3         4         5
+
+static mapinfo_t* parse_maps_line(char* line) {
+  int len = strlen(line);
+
+  if (len < 1) return 0;
+  line[--len] = 0;
+
+  if (len < 50) return 0;
+  if (line[20] != 'x') return 0;
+
+  mapinfo_t* mi = static_cast<mapinfo_t*>(dlmalloc(sizeof(mapinfo_t) + (len - 47)));
+  if (mi == 0) return 0;
+
+  mi->start = strtoul(line, 0, 16);
+  mi->end = strtoul(line + 9, 0, 16);
+  mi->next = 0;
+  strcpy(mi->name, line + 49);
+
+  return mi;
+}
+
+__LIBC_HIDDEN__ mapinfo_t* mapinfo_create(pid_t pid) {
+  struct mapinfo_t* milist = NULL;
+  char data[1024]; // Used to read lines as well as to construct the filename.
+  snprintf(data, sizeof(data), "/proc/%d/maps", pid);
+  FILE* fp = fopen(data, "r");
+  if (fp != NULL) {
+    while (fgets(data, sizeof(data), fp) != NULL) {
+      mapinfo_t* mi = parse_maps_line(data);
+      if (mi) {
+        mi->next = milist;
+        milist = mi;
+      }
+    }
+    fclose(fp);
+  }
+  return milist;
+}
+
+__LIBC_HIDDEN__ void mapinfo_destroy(mapinfo_t* mi) {
+  while (mi != NULL) {
+    mapinfo_t* del = mi;
+    mi = mi->next;
+    dlfree(del);
+  }
+}
+
+// Find the containing map info for the PC.
+__LIBC_HIDDEN__ const mapinfo_t* mapinfo_find(mapinfo_t* mi, uintptr_t pc, uintptr_t* rel_pc) {
+  for (; mi != NULL; mi = mi->next) {
+    if ((pc >= mi->start) && (pc < mi->end)) {
+      *rel_pc = pc - mi->start;
+      return mi;
+    }
+  }
+  *rel_pc = pc;
+  return NULL;
+}
diff --git a/libc/bionic/debug_mapinfo.h b/libc/bionic/debug_mapinfo.h
new file mode 100644
index 0000000..cccd2e3
--- /dev/null
+++ b/libc/bionic/debug_mapinfo.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef DEBUG_MAPINFO_H
+#define DEBUG_MAPINFO_H
+
+#include <sys/cdefs.h>
+
+struct mapinfo_t {
+  struct mapinfo_t* next;
+  unsigned start;
+  unsigned end;
+  char name[];
+};
+
+__LIBC_HIDDEN__ mapinfo_t* mapinfo_create(pid_t pid);
+__LIBC_HIDDEN__ void mapinfo_destroy(mapinfo_t* mi);
+__LIBC_HIDDEN__ const mapinfo_t* mapinfo_find(mapinfo_t* mi, uintptr_t pc, uintptr_t* rel_pc);
+
+#endif /* DEBUG_MAPINFO_H */
diff --git a/libc/bionic/debug_stacktrace.cpp b/libc/bionic/debug_stacktrace.cpp
new file mode 100644
index 0000000..9d53ad2
--- /dev/null
+++ b/libc/bionic/debug_stacktrace.cpp
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "debug_stacktrace.h"
+
+#include <dlfcn.h>
+#include <unistd.h>
+#include <unwind.h>
+#include <sys/types.h>
+
+#include "debug_format.h"
+#include "debug_mapinfo.h"
+#include "logd.h"
+
+/* depends how the system includes define this */
+#ifdef HAVE_UNWIND_CONTEXT_STRUCT
+typedef struct _Unwind_Context __unwind_context;
+#else
+typedef _Unwind_Context __unwind_context;
+#endif
+
+static mapinfo_t* gMapInfo = NULL;
+static void* gDemangler;
+typedef char* (*DemanglerFn)(const char*, char*, size_t*, int*);
+static DemanglerFn gDemanglerFn = NULL;
+
+__LIBC_HIDDEN__ void backtrace_startup() {
+  gMapInfo = mapinfo_create(getpid());
+  gDemangler = dlopen("libgccdemangle.so", RTLD_NOW);
+  if (gDemangler != NULL) {
+    void* sym = dlsym(gDemangler, "__cxa_demangle");
+    gDemanglerFn = reinterpret_cast<DemanglerFn>(sym);
+  }
+}
+
+__LIBC_HIDDEN__ void backtrace_shutdown() {
+  mapinfo_destroy(gMapInfo);
+  dlclose(gDemangler);
+}
+
+static char* demangle(const char* symbol) {
+  if (gDemanglerFn == NULL) {
+    return NULL;
+  }
+  return (*gDemanglerFn)(symbol, NULL, NULL, NULL);
+}
+
+struct stack_crawl_state_t {
+  uintptr_t* frames;
+  size_t frame_count;
+  size_t max_depth;
+  bool have_skipped_self;
+
+  stack_crawl_state_t(uintptr_t* frames, size_t max_depth)
+      : frames(frames), frame_count(0), max_depth(max_depth), have_skipped_self(false) {
+  }
+};
+
+static _Unwind_Reason_Code trace_function(__unwind_context* context, void* arg) {
+  stack_crawl_state_t* state = static_cast<stack_crawl_state_t*>(arg);
+
+  uintptr_t ip = _Unwind_GetIP(context);
+
+  // The first stack frame is get_backtrace itself. Skip it.
+  if (ip != 0 && !state->have_skipped_self) {
+    state->have_skipped_self = true;
+    return _URC_NO_REASON;
+  }
+
+  state->frames[state->frame_count++] = ip;
+  return (state->frame_count >= state->max_depth) ? _URC_END_OF_STACK : _URC_NO_REASON;
+}
+
+__LIBC_HIDDEN__ int get_backtrace(uintptr_t* frames, size_t max_depth) {
+  stack_crawl_state_t state(frames, max_depth);
+  _Unwind_Backtrace(trace_function, &state);
+  return state.frame_count;
+}
+
+__LIBC_HIDDEN__ void log_backtrace(uintptr_t* frames, size_t frame_count) {
+  uintptr_t self_bt[16];
+  if (frames == NULL) {
+    frame_count = get_backtrace(self_bt, 16);
+    frames = self_bt;
+  }
+
+  __libc_format_log(ANDROID_LOG_ERROR, "libc",
+                    "*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n");
+
+  for (size_t i = 0 ; i < frame_count; ++i) {
+    void* offset = 0;
+    const char* symbol = NULL;
+
+    Dl_info info;
+    if (dladdr((void*) frames[i], &info) != 0) {
+      offset = info.dli_saddr;
+      symbol = info.dli_sname;
+    }
+
+    uintptr_t rel_pc;
+    const mapinfo_t* mi = (gMapInfo != NULL) ? mapinfo_find(gMapInfo, frames[i], &rel_pc) : NULL;
+    const char* soname = (mi != NULL) ? mi->name : info.dli_fname;
+    if (soname == NULL) {
+      soname = "<unknown>";
+    }
+    if (symbol != NULL) {
+      // TODO: we might need a flag to say whether it's safe to allocate (demangling allocates).
+      char* demangled_symbol = demangle(symbol);
+      const char* best_name = (demangled_symbol != NULL) ? demangled_symbol : symbol;
+
+      __libc_format_log(ANDROID_LOG_ERROR, "libc", "          #%02d  pc %08x  %s (%s+0x%x)",
+                        i, rel_pc, soname, best_name, frames[i] - (uintptr_t) offset);
+
+      free(demangled_symbol);
+    } else {
+      __libc_format_log(ANDROID_LOG_ERROR, "libc", "          #%02d  pc %08x  %s",
+                        i, rel_pc, soname);
+    }
+  }
+}
diff --git a/libc/bionic/debug_stacktrace.h b/libc/bionic/debug_stacktrace.h
new file mode 100644
index 0000000..2cf8636
--- /dev/null
+++ b/libc/bionic/debug_stacktrace.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef DEBUG_STACKTRACE_H
+#define DEBUG_STACKTRACE_H
+
+#include <stdint.h>
+#include <sys/cdefs.h>
+
+__LIBC_HIDDEN__ void backtrace_startup();
+__LIBC_HIDDEN__ void backtrace_shutdown();
+__LIBC_HIDDEN__ int get_backtrace(uintptr_t* stack_frames, size_t max_depth);
+__LIBC_HIDDEN__ void log_backtrace(uintptr_t* stack_frames, size_t frame_count);
+
+#endif /* DEBUG_STACKTRACE_H */
diff --git a/libc/bionic/dirent.cpp b/libc/bionic/dirent.cpp
new file mode 100644
index 0000000..0565698
--- /dev/null
+++ b/libc/bionic/dirent.cpp
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <dirent.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "private/ErrnoRestorer.h"
+#include "private/ScopedPthreadMutexLocker.h"
+
+struct DIR {
+  int fd_;
+  size_t available_bytes_;
+  dirent* next_;
+  pthread_mutex_t mutex_;
+  dirent buff_[15];
+};
+
+static DIR* __allocate_DIR(int fd) {
+  DIR* d = reinterpret_cast<DIR*>(malloc(sizeof(DIR)));
+  if (d == NULL) {
+    return NULL;
+  }
+  d->fd_ = fd;
+  d->available_bytes_ = 0;
+  d->next_ = NULL;
+  pthread_mutex_init(&d->mutex_, NULL);
+  return d;
+}
+
+int dirfd(DIR* dirp) {
+  return dirp->fd_;
+}
+
+DIR* fdopendir(int fd) {
+  // Is 'fd' actually a directory?
+  struct stat sb;
+  if (fstat(fd, &sb) == -1) {
+    return NULL;
+  }
+  if (!S_ISDIR(sb.st_mode)) {
+    errno = ENOTDIR;
+    return NULL;
+  }
+
+  return __allocate_DIR(fd);
+}
+
+DIR* opendir(const char* path) {
+  int fd = open(path, O_RDONLY | O_DIRECTORY);
+  return (fd != -1) ? __allocate_DIR(fd) : NULL;
+}
+
+static bool __fill_DIR(DIR* d) {
+  int rc = TEMP_FAILURE_RETRY(getdents(d->fd_, d->buff_, sizeof(d->buff_)));
+  if (rc <= 0) {
+    return false;
+  }
+  d->available_bytes_ = rc;
+  d->next_ = d->buff_;
+  return true;
+}
+
+static dirent* __readdir_locked(DIR* d) {
+  if (d->available_bytes_ == 0 && !__fill_DIR(d)) {
+    return NULL;
+  }
+
+  dirent* entry = d->next_;
+  d->next_ = reinterpret_cast<dirent*>(reinterpret_cast<char*>(entry) + entry->d_reclen);
+  d->available_bytes_ -= entry->d_reclen;
+  return entry;
+}
+
+dirent* readdir(DIR* d) {
+  ScopedPthreadMutexLocker locker(&d->mutex_);
+  return __readdir_locked(d);
+}
+
+int readdir_r(DIR* d, dirent* entry, dirent** result) {
+  ErrnoRestorer errno_restorer;
+
+  *result = NULL;
+  errno = 0;
+
+  ScopedPthreadMutexLocker locker(&d->mutex_);
+
+  dirent* next = __readdir_locked(d);
+  if (errno != 0 && next == NULL) {
+    return errno;
+  }
+
+  if (next != NULL) {
+    memcpy(entry, next, next->d_reclen);
+    *result = entry;
+  }
+  return 0;
+}
+
+int closedir(DIR* d) {
+  if (d == NULL) {
+    errno = EINVAL;
+    return -1;
+  }
+
+  int fd = d->fd_;
+  pthread_mutex_destroy(&d->mutex_);
+  free(d);
+  return close(fd);
+}
+
+void rewinddir(DIR* d) {
+  ScopedPthreadMutexLocker locker(&d->mutex_);
+  lseek(d->fd_, 0, SEEK_SET);
+  d->available_bytes_ = 0;
+}
+
+int alphasort(const dirent** a, const dirent** b) {
+  return strcoll((*a)->d_name, (*b)->d_name);
+}
diff --git a/libc/bionic/dirname.c b/libc/bionic/dirname.c
deleted file mode 100644
index 8a1db90..0000000
--- a/libc/bionic/dirname.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <sys/cdefs.h>
-
-#include <errno.h>
-#include <libgen.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/param.h>
-
-char*
-dirname(const char*  path)
-{
-    static char*  bname = NULL;
-    int           ret;
-
-    if (bname == NULL) {
-        bname = (char *)malloc(MAXPATHLEN);
-        if (bname == NULL)
-            return(NULL);
-    }
-
-    ret = dirname_r(path, bname, MAXPATHLEN);
-    return (ret < 0) ? NULL : bname;
-}
diff --git a/libc/bionic/dirname_r.c b/libc/bionic/dirname_r.c
deleted file mode 100644
index df2e9bf..0000000
--- a/libc/bionic/dirname_r.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <libgen.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/param.h>
-
-int
-dirname_r(const char*  path, char*  buffer, size_t  bufflen)
-{
-    const char *endp;
-    int         result, len;
-
-    /* Empty or NULL string gets treated as "." */
-    if (path == NULL || *path == '\0') {
-        path = ".";
-        len  = 1;
-        goto Exit;
-    }
-
-    /* Strip trailing slashes */
-    endp = path + strlen(path) - 1;
-    while (endp > path && *endp == '/')
-        endp--;
-
-    /* Find the start of the dir */
-    while (endp > path && *endp != '/')
-        endp--;
-
-    /* Either the dir is "/" or there are no slashes */
-    if (endp == path) {
-        path = (*endp == '/') ? "/" : ".";
-        len  = 1;
-        goto Exit;
-    }
-
-    do {
-        endp--;
-    } while (endp > path && *endp == '/');
-
-    len = endp - path +1;
-
-Exit:
-    result = len;
-    if (len+1 > MAXPATHLEN) {
-        errno = ENAMETOOLONG;
-        return -1;
-    }
-    if (buffer == NULL)
-        return result;
-
-    if (len > (int)bufflen-1) {
-        len    = (int)bufflen-1;
-        result = -1;
-        errno  = ERANGE;
-    }
-
-    if (len >= 0) {
-        memcpy( buffer, path, len );
-        buffer[len] = 0;
-    }
-    return result;
-}
diff --git a/libc/bionic/dl_iterate_phdr_static.c b/libc/bionic/dl_iterate_phdr_static.c
index b8ef9e9..90ed1b7 100644
--- a/libc/bionic/dl_iterate_phdr_static.c
+++ b/libc/bionic/dl_iterate_phdr_static.c
@@ -26,8 +26,8 @@
  * SUCH DAMAGE.
  */
 
+#include <elf.h>
 #include <sys/types.h>
-#include <linux/elf.h>
 #include <link.h>
 
 /* Dynamic binaries get this from the dynamic linker (system/linker), which
diff --git a/libc/bionic/dlmalloc.c b/libc/bionic/dlmalloc.c
index dc5f8ab..1ed3205 100644
--- a/libc/bionic/dlmalloc.c
+++ b/libc/bionic/dlmalloc.c
@@ -16,61 +16,68 @@
 
 #include "dlmalloc.h"
 
-/* Bionic error handling declarations */
-#define PROCEED_ON_ERROR 0
-static void __bionic_heap_error(const char* msg, const char* function, void* p);
-#define CORRUPTION_ERROR_ACTION(m) \
-    __bionic_heap_error("HEAP MEMORY CORRUPTION", __FUNCTION__, NULL)
-#define USAGE_ERROR_ACTION(m,p) \
-    __bionic_heap_error("ARGUMENT IS INVALID HEAP ADDRESS", __FUNCTION__, p)
+#include <fcntl.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 
-/*
- * Ugly inclusion of C file so that bionic specific #defines configure
- * dlmalloc.
- */
+#include <linux/ashmem.h>
+
+#include <private/debug_format.h>
+#include <private/logd.h>
+
+// Send dlmalloc errors to the log.
+static void __bionic_heap_corruption_error(const char* function);
+static void __bionic_heap_usage_error(const char* function, void* address);
+#define PROCEED_ON_ERROR 0
+#define CORRUPTION_ERROR_ACTION(m) __bionic_heap_corruption_error(__FUNCTION__)
+#define USAGE_ERROR_ACTION(m,p) __bionic_heap_usage_error(__FUNCTION__, p)
+
+// We use ashmem to name the anonymous private regions created by dlmalloc.
+static void* __bionic_named_anonymous_mmap(size_t length);
+#define MMAP(s) __bionic_named_anonymous_mmap(s)
+
+// Ugly inclusion of C file so that bionic specific #defines configure dlmalloc.
 #include "../upstream-dlmalloc/malloc.c"
 
-
-/* Bionic error handling definitions */
-/* Convert a pointer into hex string */
-static void __bionic_itox(char* hex, void* ptr)
-{
-    intptr_t val = (intptr_t) ptr;
-    /* Terminate with NULL */
-    hex[8] = 0;
-    int i;
-
-    for (i = 7; i >= 0; i--) {
-        int digit = val & 15;
-        hex[i] = (digit <= 9) ? digit + '0' : digit - 10 + 'a';
-        val >>= 4;
-    }
+static void __bionic_heap_corruption_error(const char* function) {
+  __libc_format_log(ANDROID_LOG_FATAL, "libc", "@@@ ABORTING: heap corruption detected by %s",
+                    function);
+  abort();
 }
 
-#include <private/logd.h>
-static void __bionic_heap_error(const char* msg, const char* function, void* p)
-{
-    /* We format the buffer explicitely, i.e. without using snprintf()
-     * which may use malloc() internally. Not something we can trust
-     * if we just detected a corrupted heap.
-     */
-    char buffer[256];
-    strlcpy(buffer, "@@@ ABORTING: LIBC: ", sizeof(buffer));
-    strlcat(buffer, msg, sizeof(buffer));
-    if (function != NULL) {
-        strlcat(buffer, " IN ", sizeof(buffer));
-        strlcat(buffer, function, sizeof(buffer));
-    }
+static void __bionic_heap_usage_error(const char* function, void* address) {
+  __libc_format_log(ANDROID_LOG_FATAL, "libc", "@@@ ABORTING: invalid address %p passed to %s",
+                    address, function);
+  // So that we can get a memory dump around the specific address.
+  *((int**) 0xdeadbaad) = (int*) address;
+}
 
-    if (p != NULL) {
-        char hexbuffer[9];
-        __bionic_itox(hexbuffer, p);
-        strlcat(buffer, " addr=0x", sizeof(buffer));
-        strlcat(buffer, hexbuffer, sizeof(buffer));
-    }
+static int __ashmem_create_region(const char* name, size_t size) {
+  int fd = open("/dev/ashmem", O_RDWR);
+  if (fd == -1) {
+    return fd;
+  }
+  int rc = ioctl(fd, ASHMEM_SET_NAME, name);
+  if (rc < 0) {
+    close(fd);
+    return rc;
+  }
+  rc = ioctl(fd, ASHMEM_SET_SIZE, size);
+  if (rc < 0) {
+    close(fd);
+    return rc;
+  }
+  return fd;
+}
 
-    __libc_android_log_write(ANDROID_LOG_FATAL, "libc", buffer);
-
-    /* So that we can get a memory dump around p */
-    *((int **) 0xdeadbaad) = (int *) p;
+static void* __bionic_named_anonymous_mmap(size_t length) {
+  int fd = __ashmem_create_region("libc malloc", length);
+  if (fd < 0) {
+    return MAP_FAILED;
+  }
+  void* result = mmap(NULL, length, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
+  close (fd);
+  return result;
 }
diff --git a/libc/bionic/drand48.c b/libc/bionic/drand48.c
deleted file mode 100644
index 93272cf..0000000
--- a/libc/bionic/drand48.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 1993 Martin Birgmeier
- * All rights reserved.
- *
- * You may redistribute unmodified or modified versions of this source
- * code provided that the above copyright notice and this and the
- * following conditions are retained.
- *
- * This software is provided ``as is'', and comes with no warranties
- * of any kind. I shall in no event be liable for anything that happens
- * to anyone/anything when using this software.
- */
-
-#include <sys/cdefs.h>
-
-#include "rand48.h"
-
-extern unsigned short __rand48_seed[3];
-
-double
-drand48(void)
-{
-	return erand48(__rand48_seed);
-}
diff --git a/libc/bionic/erand48.c b/libc/bionic/erand48.c
deleted file mode 100644
index 4ecbead..0000000
--- a/libc/bionic/erand48.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 1993 Martin Birgmeier
- * All rights reserved.
- *
- * You may redistribute unmodified or modified versions of this source
- * code provided that the above copyright notice and this and the
- * following conditions are retained.
- *
- * This software is provided ``as is'', and comes with no warranties
- * of any kind. I shall in no event be liable for anything that happens
- * to anyone/anything when using this software.
- */
-
-#include <sys/cdefs.h>
-
-#include "rand48.h"
-
-double
-erand48(unsigned short xseed[3])
-{
-	__dorand48(xseed);
-	return ldexp((double) xseed[0], -48) +
-	       ldexp((double) xseed[1], -32) +
-	       ldexp((double) xseed[2], -16);
-}
diff --git a/libc/bionic/err.c b/libc/bionic/err.c
index 535b7e1..84a3d85 100644
--- a/libc/bionic/err.c
+++ b/libc/bionic/err.c
@@ -34,7 +34,7 @@
 #include <stdarg.h>
 #include <errno.h>
 
-extern char *__progname;
+extern const char* __progname;
 
 __noreturn void
 err(int eval, const char *fmt, ...)
diff --git a/libc/inet/ether_aton.c b/libc/bionic/ether_aton.c
similarity index 100%
rename from libc/inet/ether_aton.c
rename to libc/bionic/ether_aton.c
diff --git a/libc/inet/ether_ntoa.c b/libc/bionic/ether_ntoa.c
similarity index 100%
rename from libc/inet/ether_ntoa.c
rename to libc/bionic/ether_ntoa.c
diff --git a/libc/unistd/eventfd.c b/libc/bionic/eventfd.cpp
similarity index 100%
rename from libc/unistd/eventfd.c
rename to libc/bionic/eventfd.cpp
diff --git a/libc/unistd/fcntl.c b/libc/bionic/fcntl.c
similarity index 100%
rename from libc/unistd/fcntl.c
rename to libc/bionic/fcntl.c
diff --git a/libc/stdio/flockfile.c b/libc/bionic/flockfile.c
similarity index 100%
rename from libc/stdio/flockfile.c
rename to libc/bionic/flockfile.c
diff --git a/libc/bionic/fork.c b/libc/bionic/fork.c
index 2d5a10a..d83c535 100644
--- a/libc/bionic/fork.c
+++ b/libc/bionic/fork.c
@@ -9,7 +9,7 @@
  *    notice, this list of conditions and the following disclaimer.
  *  * Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the 
+ *    the documentation and/or other materials provided with the
  *    distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
@@ -19,7 +19,7 @@
  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
@@ -49,8 +49,8 @@
         __timer_table_start_stop(0);
         __bionic_atfork_run_parent();
     } else {
-        /* Adjusting the kernel id after a fork */
-        (void)__pthread_settid(pthread_self(), gettid());
+        // Fix the tid in the pthread_internal_t struct after a fork.
+        __pthread_settid(pthread_self(), gettid());
 
         /*
          * Newly created process must update cpu accounting.
diff --git a/libc/unistd/fstatfs.c b/libc/bionic/fstatfs.c
similarity index 100%
rename from libc/unistd/fstatfs.c
rename to libc/bionic/fstatfs.c
diff --git a/libc/unistd/ftime.c b/libc/bionic/ftime.c
similarity index 100%
rename from libc/unistd/ftime.c
rename to libc/bionic/ftime.c
diff --git a/libc/unistd/ftok.c b/libc/bionic/ftok.c
similarity index 100%
rename from libc/unistd/ftok.c
rename to libc/bionic/ftok.c
diff --git a/libc/bionic/getauxval.cpp b/libc/bionic/getauxval.cpp
new file mode 100644
index 0000000..fd225e0
--- /dev/null
+++ b/libc/bionic/getauxval.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stddef.h>
+#include <sys/cdefs.h>
+#include <sys/auxv.h>
+#include <private/bionic_auxv.h>
+#include <elf.h>
+
+__LIBC_HIDDEN__ Elf32_auxv_t* __libc_auxv = NULL;
+
+extern "C" unsigned long int getauxval(unsigned long int type) {
+  for (Elf32_auxv_t* v = __libc_auxv; v->a_type != AT_NULL; ++v) {
+    if (v->a_type == type) {
+      return v->a_un.a_val;
+    }
+  }
+  return 0;
+}
diff --git a/libc/bionic/getcwd.cpp b/libc/bionic/getcwd.cpp
index 2ff22db..47c807f 100644
--- a/libc/bionic/getcwd.cpp
+++ b/libc/bionic/getcwd.cpp
@@ -40,22 +40,23 @@
 
   // Allocate a buffer if necessary.
   char* allocated_buf = NULL;
+  size_t allocated_size = size;
   if (buf == NULL) {
-    size_t allocated_size = size;
     if (size == 0) {
       // The Linux kernel won't return more than a page, so translate size 0 to 4KiB.
       // TODO: if we need to support paths longer than that, we'll have to walk the tree ourselves.
-      size = getpagesize();
+      allocated_size = getpagesize();
     }
     buf = allocated_buf = static_cast<char*>(malloc(allocated_size));
     if (buf == NULL) {
-      // malloc set errno.
+      // malloc should set errno, but valgrind's malloc wrapper doesn't.
+      errno = ENOMEM;
       return NULL;
     }
   }
 
   // Ask the kernel to fill our buffer.
-  int rc = __getcwd(buf, size);
+  int rc = __getcwd(buf, allocated_size);
   if (rc == -1) {
     free(allocated_buf);
     // __getcwd set errno.
diff --git a/libc/unistd/getdtablesize.c b/libc/bionic/getdtablesize.c
similarity index 100%
rename from libc/unistd/getdtablesize.c
rename to libc/bionic/getdtablesize.c
diff --git a/libc/unistd/gethostname.c b/libc/bionic/gethostname.c
similarity index 100%
rename from libc/unistd/gethostname.c
rename to libc/bionic/gethostname.c
diff --git a/libc/unistd/getpgrp.c b/libc/bionic/getpgrp.c
similarity index 100%
rename from libc/unistd/getpgrp.c
rename to libc/bionic/getpgrp.c
diff --git a/libc/unistd/getpriority.c b/libc/bionic/getpriority.c
similarity index 100%
rename from libc/unistd/getpriority.c
rename to libc/bionic/getpriority.c
diff --git a/libc/unistd/getpt.c b/libc/bionic/getpt.c
similarity index 100%
rename from libc/unistd/getpt.c
rename to libc/bionic/getpt.c
diff --git a/libc/unistd/initgroups.c b/libc/bionic/initgroups.c
similarity index 100%
rename from libc/unistd/initgroups.c
rename to libc/bionic/initgroups.c
diff --git a/libc/unistd/isatty.c b/libc/bionic/isatty.c
similarity index 100%
rename from libc/unistd/isatty.c
rename to libc/bionic/isatty.c
diff --git a/libc/unistd/issetugid.c b/libc/bionic/issetugid.c
similarity index 100%
rename from libc/unistd/issetugid.c
rename to libc/bionic/issetugid.c
diff --git a/libc/bionic/libc_init_common.c b/libc/bionic/libc_init_common.c
deleted file mode 100644
index 6508c0b..0000000
--- a/libc/bionic/libc_init_common.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <elf.h>
-#include <asm/page.h>
-#include "pthread_internal.h"
-#include "atexit.h"
-#include "libc_init_common.h"
-
-#include <bionic_tls.h>
-#include <errno.h>
-
-extern unsigned __get_sp(void);
-extern pid_t    gettid(void);
-
-char*  __progname;
-char **environ;
-
-/* from asm/page.h */
-unsigned int __page_size = PAGE_SIZE;
-unsigned int __page_shift = PAGE_SHIFT;
-
-
-int __system_properties_init(void);
-
-/* Init TLS for the initial thread. Called by the linker _before_ libc is mapped
- * in memory. Beware: all writes to libc globals from this function will
- * apply to linker-private copies and will not be visible from libc later on.
- *
- * Note: this function creates a pthread_internal_t for the initial thread and
- * stores the pointer in TLS, but does not add it to pthread's gThreadList. This
- * has to be done later from libc itself (see __libc_init_common).
- *
- * This function also stores elfdata argument in a specific TLS slot to be later
- * picked up by the libc constructor.
- */
-void __libc_init_tls(unsigned** elfdata)
-{
-    pthread_attr_t             thread_attr;
-    static pthread_internal_t  thread;
-    static void*               tls_area[BIONIC_TLS_SLOTS];
-
-    /* setup pthread runtime and main thread descriptor */
-    unsigned stacktop = (__get_sp() & ~(PAGE_SIZE - 1)) + PAGE_SIZE;
-    unsigned stacksize = 128 * 1024;
-    unsigned stackbottom = stacktop - stacksize;
-
-    pthread_attr_init(&thread_attr);
-    pthread_attr_setstack(&thread_attr, (void*)stackbottom, stacksize);
-    _init_thread(&thread, gettid(), &thread_attr, (void*)stackbottom, false);
-    __init_tls(tls_area, &thread);
-
-    tls_area[TLS_SLOT_BIONIC_PREINIT] = elfdata;
-}
-
-void __libc_init_common(uintptr_t *elfdata)
-{
-    int     argc = *elfdata;
-    char**  argv = (char**)(elfdata + 1);
-    char**  envp = argv + argc + 1;
-
-    /* get the initial thread from TLS and add it to gThreadList */
-    _pthread_internal_add(__get_thread());
-
-    /* clear errno */
-    errno = 0;
-
-    /* set program name */
-    __progname = argv[0] ? argv[0] : "<unknown>";
-
-    /* setup environment pointer */
-    environ = envp;
-
-    /* setup system properties - requires environment */
-    __system_properties_init();
-}
-
-/* This function will be called during normal program termination
- * to run the destructors that are listed in the .fini_array section
- * of the executable, if any.
- *
- * 'fini_array' points to a list of function addresses. The first
- * entry in the list has value -1, the last one has value 0.
- */
-void __libc_fini(void* array)
-{
-    int count;
-    void** fini_array = array;
-    const size_t  minus1 = ~(size_t)0; /* ensure proper sign extension */
-
-    /* Sanity check - first entry must be -1 */
-    if (array == NULL || (size_t)fini_array[0] != minus1) {
-        return;
-    }
-
-    /* skip over it */
-    fini_array += 1;
-
-    /* Count the number of destructors. */
-    for (count = 0; fini_array[count] != NULL; count++);
-
-    /* Now call each destructor in reverse order. */
-    while (count > 0) {
-        void (*func)() = (void (*)) fini_array[--count];
-
-        /* Sanity check, any -1 in the list is ignored */
-        if ((size_t)func == minus1)
-            continue;
-
-        func();
-    }
-
-#ifndef LIBC_STATIC
-    {
-        extern void __libc_postfini(void) __attribute__((weak));
-        if (__libc_postfini)
-            __libc_postfini();
-    }
-#endif
-}
diff --git a/libc/bionic/libc_init_common.cpp b/libc/bionic/libc_init_common.cpp
new file mode 100644
index 0000000..33ec1db
--- /dev/null
+++ b/libc/bionic/libc_init_common.cpp
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "libc_init_common.h"
+
+#include <asm/page.h>
+#include <bionic_tls.h>
+#include <elf.h>
+#include <errno.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/auxv.h>
+#include <unistd.h>
+
+#include "atexit.h"
+#include "private/bionic_auxv.h"
+#include "private/bionic_ssp.h"
+#include "private/KernelArgumentBlock.h"
+#include "pthread_internal.h"
+
+extern "C" unsigned __get_sp(void);
+extern "C" int __system_properties_init(void);
+
+// Not public, but well-known in the BSDs.
+const char* __progname;
+
+// Declared in <unistd.h>.
+char** environ;
+
+// Declared in <private/bionic_ssp.h>.
+uintptr_t __stack_chk_guard = 0;
+
+// Declared in <asm/page.h>.
+unsigned int __page_size = PAGE_SIZE;
+unsigned int __page_shift = PAGE_SHIFT;
+
+/* Init TLS for the initial thread. Called by the linker _before_ libc is mapped
+ * in memory. Beware: all writes to libc globals from this function will
+ * apply to linker-private copies and will not be visible from libc later on.
+ *
+ * Note: this function creates a pthread_internal_t for the initial thread and
+ * stores the pointer in TLS, but does not add it to pthread's gThreadList. This
+ * has to be done later from libc itself (see __libc_init_common).
+ *
+ * This function also stores a pointer to the kernel argument block in a TLS slot to be
+ * picked up by the libc constructor.
+ */
+void __libc_init_tls(KernelArgumentBlock& args) {
+  __libc_auxv = args.auxv;
+
+  unsigned stack_top = (__get_sp() & ~(PAGE_SIZE - 1)) + PAGE_SIZE;
+  unsigned stack_size = 128 * 1024;
+  unsigned stack_bottom = stack_top - stack_size;
+
+  static void* tls[BIONIC_TLS_SLOTS];
+  static pthread_internal_t thread;
+  thread.tid = gettid();
+  thread.tls = tls;
+  pthread_attr_init(&thread.attr);
+  pthread_attr_setstack(&thread.attr, (void*) stack_bottom, stack_size);
+  _init_thread(&thread, false);
+  __init_tls(&thread);
+  tls[TLS_SLOT_BIONIC_PREINIT] = &args;
+}
+
+void __libc_init_common(KernelArgumentBlock& args) {
+  // Initialize various globals.
+  environ = args.envp;
+  errno = 0;
+  __libc_auxv = args.auxv;
+  __progname = args.argv[0] ? args.argv[0] : "<unknown>";
+
+  // AT_RANDOM is a pointer to 16 bytes of randomness on the stack.
+  __stack_chk_guard = *reinterpret_cast<uintptr_t*>(getauxval(AT_RANDOM));
+
+  // Get the main thread from TLS and add it to the thread list.
+  pthread_internal_t* main_thread = __get_thread();
+  main_thread->allocated_on_heap = false;
+  _pthread_internal_add(main_thread);
+
+  __system_properties_init(); // Requires 'environ'.
+}
+
+/* This function will be called during normal program termination
+ * to run the destructors that are listed in the .fini_array section
+ * of the executable, if any.
+ *
+ * 'fini_array' points to a list of function addresses. The first
+ * entry in the list has value -1, the last one has value 0.
+ */
+void __libc_fini(void* array) {
+  void** fini_array = reinterpret_cast<void**>(array);
+  const size_t minus1 = ~(size_t)0; /* ensure proper sign extension */
+
+  /* Sanity check - first entry must be -1 */
+  if (array == NULL || (size_t)fini_array[0] != minus1) {
+    return;
+  }
+
+  /* skip over it */
+  fini_array += 1;
+
+  /* Count the number of destructors. */
+  int count = 0;
+  while (fini_array[count] != NULL) {
+    ++count;
+  }
+
+  /* Now call each destructor in reverse order. */
+  while (count > 0) {
+    void (*func)() = (void (*)()) fini_array[--count];
+
+    /* Sanity check, any -1 in the list is ignored */
+    if ((size_t)func == minus1) {
+      continue;
+    }
+
+    func();
+  }
+
+#ifndef LIBC_STATIC
+  {
+    extern void __libc_postfini(void) __attribute__((weak));
+    if (__libc_postfini) {
+      __libc_postfini();
+    }
+  }
+#endif
+}
diff --git a/libc/bionic/libc_init_common.h b/libc/bionic/libc_init_common.h
index c55594b..23ac305 100644
--- a/libc/bionic/libc_init_common.h
+++ b/libc/bionic/libc_init_common.h
@@ -28,16 +28,29 @@
 #ifndef LIBC_INIT_COMMON_H
 #define LIBC_INIT_COMMON_H
 
-#include <stdint.h>
+#include <sys/cdefs.h>
 
-typedef struct
-{
-    void (**preinit_array)(void);
-    void (**init_array)(void);
-    void (**fini_array)(void);
+typedef struct {
+  void (**preinit_array)(void);
+  void (**init_array)(void);
+  void (**fini_array)(void);
 } structors_array_t;
 
-extern void __libc_init_common(uintptr_t *elfdata);
-extern void __libc_fini(void* finit_array);
+__BEGIN_DECLS
+
+extern int main(int argc, char** argv, char** env);
+
+__noreturn void __libc_init(void* raw_args,
+                            void (*onexit)(void),
+                            int (*slingshot)(int, char**, char**),
+                            structors_array_t const * const structors);
+void __libc_fini(void* finit_array);
+
+__END_DECLS
+
+#if defined(__cplusplus)
+struct KernelArgumentBlock;
+void __libc_init_common(KernelArgumentBlock& args);
+#endif
 
 #endif
diff --git a/libc/bionic/libc_init_dynamic.c b/libc/bionic/libc_init_dynamic.c
deleted file mode 100644
index 3a7e8e2..0000000
--- a/libc/bionic/libc_init_dynamic.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-/*
- * libc_init_dynamic.c
- *
- * This source files provides two important functions for dynamic
- * executables:
- *
- * - a C runtime initializer (__libc_preinit), which is called by
- *   the dynamic linker when libc.so is loaded. This happens before
- *   any other initializer (e.g. static C++ constructors in other
- *   shared libraries the program depends on).
- *
- * - a program launch function (__libc_init), which is called after
- *   all dynamic linking has been performed. Technically, it is called
- *   from arch-$ARCH/bionic/crtbegin_dynamic.S which is itself called
- *   by the dynamic linker after all libraries have been loaded and
- *   initialized.
- */
-
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <elf.h>
-#include "atexit.h"
-#include "libc_init_common.h"
-#include <bionic_tls.h>
-
-/* We flag the __libc_preinit function as a constructor to ensure
- * that its address is listed in libc.so's .init_array section.
- * This ensures that the function is called by the dynamic linker
- * as soon as the shared library is loaded.
- */
-void __attribute__((constructor)) __libc_preinit(void);
-
-void __libc_preinit(void)
-{
-    /* Read the ELF data pointer from a special slot of the
-     * TLS area, then call __libc_init_common with it.
-     *
-     * Note that:
-     * - we clear the slot so no other initializer sees its value.
-     * - __libc_init_common() will change the TLS area so the old one
-     *   won't be accessible anyway.
-     */
-    void**      tls_area = (void**)__get_tls();
-    unsigned*   elfdata   = tls_area[TLS_SLOT_BIONIC_PREINIT];
-
-    tls_area[TLS_SLOT_BIONIC_PREINIT] = NULL;
-
-    __libc_init_common(elfdata);
-
-    /* Setup pthread routines accordingly to the environment.
-     * Requires system properties
-     */
-    extern void pthread_debug_init(void);
-    pthread_debug_init();
-
-    /* Setup malloc routines accordingly to the environment.
-     * Requires system properties
-     */
-    extern void malloc_debug_init(void);
-    malloc_debug_init();
-}
-
-void __libc_postfini(void)
-{
-    extern void malloc_debug_fini(void);
-    malloc_debug_fini();
-}
-
-/* This function is called from the executable's _start entry point
- * (see arch-$ARCH/bionic/crtbegin_dynamic.S), which is itself
- * called by the dynamic linker after it has loaded all shared
- * libraries the executable depends on.
- *
- * Note that the dynamic linker has also run all constructors in the
- * executable at this point.
- */
-__noreturn void __libc_init(uintptr_t *elfdata,
-                       void (*onexit)(void),
-                       int (*slingshot)(int, char**, char**),
-                       structors_array_t const * const structors)
-{
-    int     argc = (int)*elfdata;
-    char**  argv = (char**)(elfdata + 1);
-    char**  envp = argv + argc + 1;
-
-    /* Several Linux ABIs don't pass the onexit pointer, and the ones that
-     * do never use it.  Therefore, we ignore it.
-     */
-
-    /* The executable may have its own destructors listed in its .fini_array
-     * so we need to ensure that these are called when the program exits
-     * normally.
-     */
-    if (structors->fini_array)
-        __cxa_atexit(__libc_fini,structors->fini_array,NULL);
-
-    exit(slingshot(argc, argv, envp));
-}
diff --git a/libc/bionic/libc_init_dynamic.cpp b/libc/bionic/libc_init_dynamic.cpp
new file mode 100644
index 0000000..af03fb0
--- /dev/null
+++ b/libc/bionic/libc_init_dynamic.cpp
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/*
+ * libc_init_dynamic.c
+ *
+ * This source files provides two important functions for dynamic
+ * executables:
+ *
+ * - a C runtime initializer (__libc_preinit), which is called by
+ *   the dynamic linker when libc.so is loaded. This happens before
+ *   any other initializer (e.g. static C++ constructors in other
+ *   shared libraries the program depends on).
+ *
+ * - a program launch function (__libc_init), which is called after
+ *   all dynamic linking has been performed. Technically, it is called
+ *   from arch-$ARCH/bionic/crtbegin_dynamic.S which is itself called
+ *   by the dynamic linker after all libraries have been loaded and
+ *   initialized.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <elf.h>
+#include "atexit.h"
+#include "KernelArgumentBlock.h"
+#include "libc_init_common.h"
+#include <bionic_tls.h>
+
+extern "C" {
+  extern void pthread_debug_init(void);
+  extern void malloc_debug_init(void);
+  extern void malloc_debug_fini(void);
+};
+
+// We flag the __libc_preinit function as a constructor to ensure
+// that its address is listed in libc.so's .init_array section.
+// This ensures that the function is called by the dynamic linker
+// as soon as the shared library is loaded.
+void __attribute__((constructor)) __libc_preinit(void);
+
+void __libc_preinit() {
+  // Read the kernel argument block pointer from TLS.
+  void* tls = const_cast<void*>(__get_tls());
+  KernelArgumentBlock** args_slot = &reinterpret_cast<KernelArgumentBlock**>(tls)[TLS_SLOT_BIONIC_PREINIT];
+  KernelArgumentBlock* args = *args_slot;
+
+  // Clear the slot so no other initializer sees its value.
+  // __libc_init_common() will change the TLS area so the old one won't be accessible anyway.
+  *args_slot = NULL;
+
+  __libc_init_common(*args);
+
+  // Hooks for the debug malloc and pthread libraries to let them know that we're starting up.
+  pthread_debug_init();
+  malloc_debug_init();
+}
+
+void __libc_postfini() {
+  // A hook for the debug malloc library to let it know that we're shutting down.
+  malloc_debug_fini();
+}
+
+// This function is called from the executable's _start entry point
+// (see arch-$ARCH/bionic/crtbegin_dynamic.S), which is itself
+// called by the dynamic linker after it has loaded all shared
+// libraries the executable depends on.
+//
+// Note that the dynamic linker has also run all constructors in the
+// executable at this point.
+__noreturn void __libc_init(void* raw_args,
+                            void (*onexit)(void),
+                            int (*slingshot)(int, char**, char**),
+                            structors_array_t const * const structors) {
+
+  KernelArgumentBlock args(raw_args);
+
+  // Several Linux ABIs don't pass the onexit pointer, and the ones that
+  // do never use it.  Therefore, we ignore it.
+
+  // The executable may have its own destructors listed in its .fini_array
+  // so we need to ensure that these are called when the program exits
+  // normally.
+  if (structors->fini_array) {
+    __cxa_atexit(__libc_fini,structors->fini_array,NULL);
+  }
+
+  exit(slingshot(args.argc, args.argv, args.envp));
+}
diff --git a/libc/bionic/libc_init_static.c b/libc/bionic/libc_init_static.c
deleted file mode 100644
index a73bb71..0000000
--- a/libc/bionic/libc_init_static.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-/*
- * libc_init_static.c
- *
- * The program startup function __libc_init() defined here is
- * used for static executables only (i.e. those that don't depend
- * on shared libraries). It is called from arch-$ARCH/bionic/crtbegin_static.S
- * which is directly invoked by the kernel when the program is launched.
- *
- * The 'structors' parameter contains pointers to various initializer
- * arrays that must be run before the program's 'main' routine is launched.
- */
-
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <elf.h>
-#include "pthread_internal.h"
-#include "atexit.h"
-#include "libc_init_common.h"
-
-#include <bionic_tls.h>
-#include <errno.h>
-
-static void call_array(void(**list)())
-{
-    // First element is -1, list is null-terminated
-    while (*++list) {
-        (*list)();
-    }
-}
-
-__noreturn void __libc_init(uintptr_t *elfdata,
-                       void (*onexit)(void),
-                       int (*slingshot)(int, char**, char**),
-                       structors_array_t const * const structors)
-{
-    int  argc;
-    char **argv, **envp;
-
-    __libc_init_tls(NULL);
-
-    /* Initialize the C runtime environment */
-    __libc_init_common(elfdata);
-
-    /* Several Linux ABIs don't pass the onexit pointer, and the ones that
-     * do never use it.  Therefore, we ignore it.
-     */
-
-    /* pre-init array. */
-    call_array(structors->preinit_array);
-
-    // call static constructors
-    call_array(structors->init_array);
-
-    argc = (int) *elfdata;
-    argv = (char**)(elfdata + 1);
-    envp = argv + argc + 1;
-
-    /* The executable may have its own destructors listed in its .fini_array
-     * so we need to ensure that these are called when the program exits
-     * normally.
-     */
-    if (structors->fini_array)
-        __cxa_atexit(__libc_fini,structors->fini_array,NULL);
-
-    exit(slingshot(argc, argv, envp));
-}
diff --git a/libc/bionic/libc_init_static.cpp b/libc/bionic/libc_init_static.cpp
new file mode 100644
index 0000000..a6b20eb
--- /dev/null
+++ b/libc/bionic/libc_init_static.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/*
+ * libc_init_static.c
+ *
+ * The program startup function __libc_init() defined here is
+ * used for static executables only (i.e. those that don't depend
+ * on shared libraries). It is called from arch-$ARCH/bionic/crtbegin_static.S
+ * which is directly invoked by the kernel when the program is launched.
+ *
+ * The 'structors' parameter contains pointers to various initializer
+ * arrays that must be run before the program's 'main' routine is launched.
+ */
+
+#include <elf.h>
+#include <errno.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/auxv.h>
+#include <sys/mman.h>
+
+#include "atexit.h"
+#include "bionic_tls.h"
+#include "KernelArgumentBlock.h"
+#include "libc_init_common.h"
+#include "pthread_internal.h"
+
+// Returns the address of the page containing address 'x'.
+#define PAGE_START(x)  ((x) & PAGE_MASK)
+
+// Returns the address of the next page after address 'x', unless 'x' is
+// itself at the start of a page.
+#define PAGE_END(x)    PAGE_START((x) + (PAGE_SIZE-1))
+
+static void call_array(void(**list)()) {
+  // First element is -1, list is null-terminated
+  while (*++list) {
+    (*list)();
+  }
+}
+
+static void apply_gnu_relro() {
+  Elf32_Phdr* phdr_start = reinterpret_cast<Elf32_Phdr*>(getauxval(AT_PHDR));
+  unsigned long int phdr_ct = getauxval(AT_PHNUM);
+
+  for (Elf32_Phdr* phdr = phdr_start; phdr < (phdr_start + phdr_ct); phdr++) {
+    if (phdr->p_type != PT_GNU_RELRO) {
+      continue;
+    }
+
+    Elf32_Addr seg_page_start = PAGE_START(phdr->p_vaddr);
+    Elf32_Addr seg_page_end = PAGE_END(phdr->p_vaddr + phdr->p_memsz);
+
+    // Check return value here? What do we do if we fail?
+    mprotect(reinterpret_cast<void*>(seg_page_start), seg_page_end - seg_page_start, PROT_READ);
+  }
+}
+
+__noreturn void __libc_init(void* raw_args,
+                            void (*onexit)(void),
+                            int (*slingshot)(int, char**, char**),
+                            structors_array_t const * const structors) {
+  KernelArgumentBlock args(raw_args);
+  __libc_init_tls(args);
+  __libc_init_common(args);
+
+  apply_gnu_relro();
+
+  // Several Linux ABIs don't pass the onexit pointer, and the ones that
+  // do never use it.  Therefore, we ignore it.
+
+  call_array(structors->preinit_array);
+  call_array(structors->init_array);
+
+  // The executable may have its own destructors listed in its .fini_array
+  // so we need to ensure that these are called when the program exits
+  // normally.
+  if (structors->fini_array != NULL) {
+    __cxa_atexit(__libc_fini,structors->fini_array,NULL);
+  }
+
+  exit(slingshot(args.argc, args.argv, args.envp));
+}
diff --git a/libc/bionic/libgen.cpp b/libc/bionic/libgen.cpp
new file mode 100644
index 0000000..f7181e7
--- /dev/null
+++ b/libc/bionic/libgen.cpp
@@ -0,0 +1,163 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <libgen.h>
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/cdefs.h>
+#include <sys/param.h>
+
+#include "ThreadLocalBuffer.h"
+
+GLOBAL_INIT_THREAD_LOCAL_BUFFER(basename);
+GLOBAL_INIT_THREAD_LOCAL_BUFFER(dirname);
+
+char* basename(const char* path) {
+  LOCAL_INIT_THREAD_LOCAL_BUFFER(char*, basename, MAXPATHLEN);
+  int rc = basename_r(path, basename_tls_buffer, basename_tls_buffer_size);
+  return (rc < 0) ? NULL : basename_tls_buffer;
+}
+
+char* dirname(const char* path) {
+  LOCAL_INIT_THREAD_LOCAL_BUFFER(char*, dirname, MAXPATHLEN);
+  int rc = dirname_r(path, dirname_tls_buffer, dirname_tls_buffer_size);
+  return (rc < 0) ? NULL : dirname_tls_buffer;
+}
+
+int basename_r(const char* path, char* buffer, size_t buffer_size) {
+  const char* startp = NULL;
+  const char* endp = NULL;
+  int len;
+  int result;
+
+  // Empty or NULL string gets treated as ".".
+  if (path == NULL || *path == '\0') {
+    startp = ".";
+    len = 1;
+    goto Exit;
+  }
+
+  // Strip trailing slashes.
+  endp = path + strlen(path) - 1;
+  while (endp > path && *endp == '/') {
+    endp--;
+  }
+
+  // All slashes becomes "/".
+  if (endp == path && *endp == '/') {
+    startp = "/";
+    len = 1;
+    goto Exit;
+  }
+
+  // Find the start of the base.
+  startp = endp;
+  while (startp > path && *(startp - 1) != '/') {
+    startp--;
+  }
+
+  len = endp - startp +1;
+
+ Exit:
+  result = len;
+  if (buffer == NULL) {
+    return result;
+  }
+  if (len > static_cast<int>(buffer_size) - 1) {
+    len = buffer_size - 1;
+    result = -1;
+    errno = ERANGE;
+  }
+
+  if (len >= 0) {
+    memcpy(buffer, startp, len);
+    buffer[len] = 0;
+  }
+  return result;
+}
+
+int dirname_r(const char* path, char* buffer, size_t buffer_size) {
+  const char* endp = NULL;
+  int len;
+  int result;
+
+  // Empty or NULL string gets treated as ".".
+  if (path == NULL || *path == '\0') {
+    path = ".";
+    len = 1;
+    goto Exit;
+  }
+
+  // Strip trailing slashes.
+  endp = path + strlen(path) - 1;
+  while (endp > path && *endp == '/') {
+    endp--;
+  }
+
+  // Find the start of the dir.
+  while (endp > path && *endp != '/') {
+    endp--;
+  }
+
+  // Either the dir is "/" or there are no slashes.
+  if (endp == path) {
+    path = (*endp == '/') ? "/" : ".";
+    len = 1;
+    goto Exit;
+  }
+
+  do {
+    endp--;
+  } while (endp > path && *endp == '/');
+
+  len = endp - path + 1;
+
+ Exit:
+  result = len;
+  if (len + 1 > MAXPATHLEN) {
+    errno = ENAMETOOLONG;
+    return -1;
+  }
+  if (buffer == NULL) {
+    return result;
+  }
+
+  if (len > static_cast<int>(buffer_size) - 1) {
+    len = buffer_size - 1;
+    result = -1;
+    errno = ERANGE;
+  }
+
+  if (len >= 0) {
+    memcpy(buffer, path, len);
+    buffer[len] = 0;
+  }
+  return result;
+}
diff --git a/libc/bionic/logd_write.c b/libc/bionic/logd_write.c
index ac71689..11c0e68 100644
--- a/libc/bionic/logd_write.c
+++ b/libc/bionic/logd_write.c
@@ -247,3 +247,12 @@
 {
     __libc_android_log_event_int(tag, getuid());
 }
+
+__LIBC_HIDDEN__
+void __fortify_chk_fail(const char *msg, uint32_t tag) {
+    __libc_format_log(ANDROID_LOG_FATAL, "libc", "FORTIFY_SOURCE: %s. Calling abort().\n", msg);
+    if (tag != 0) {
+        __libc_android_log_event_uid(tag);
+    }
+    abort();
+}
diff --git a/libc/unistd/lseek64.c b/libc/bionic/lseek64.c
similarity index 100%
rename from libc/unistd/lseek64.c
rename to libc/bionic/lseek64.c
diff --git a/libc/bionic/malloc_debug_check.cpp b/libc/bionic/malloc_debug_check.cpp
index 9e6d92e..2ae98b6 100644
--- a/libc/bionic/malloc_debug_check.cpp
+++ b/libc/bionic/malloc_debug_check.cpp
@@ -26,71 +26,59 @@
  * SUCH DAMAGE.
  */
 
-#include <errno.h>
-#include <pthread.h>
-#include <time.h>
-#include <stdio.h>
 #include <arpa/inet.h>
-#include <sys/socket.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <stddef.h>
-#include <stdarg.h>
-#include <fcntl.h>
-#include <unwind.h>
-#include <dlfcn.h>
-#include <stdbool.h>
-
-#include <sys/types.h>
+#include <sys/socket.h>
 #include <sys/system_properties.h>
+#include <sys/types.h>
+#include <time.h>
+#include <unistd.h>
+#include <unwind.h>
 
+#include "debug_mapinfo.h"
+#include "debug_stacktrace.h"
 #include "dlmalloc.h"
 #include "logd.h"
-
 #include "malloc_debug_common.h"
-#include "malloc_debug_check_mapinfo.h"
-
-static mapinfo *milist;
+#include "ScopedPthreadMutexLocker.h"
 
 /* libc.debug.malloc.backlog */
-extern unsigned int malloc_double_free_backlog;
+extern unsigned int gMallocDebugBacklog;
+extern int gMallocDebugLevel;
 
-#define MAX_BACKTRACE_DEPTH 15
+#define MAX_BACKTRACE_DEPTH 16
 #define ALLOCATION_TAG      0x1ee7d00d
 #define BACKLOG_TAG         0xbabecafe
 #define FREE_POISON         0xa5
-#define BACKLOG_DEFAULT_LEN 100
 #define FRONT_GUARD         0xaa
 #define FRONT_GUARD_LEN     (1<<5)
 #define REAR_GUARD          0xbb
 #define REAR_GUARD_LEN      (1<<5)
 
 static void log_message(const char* format, ...) {
-    extern const MallocDebug __libc_malloc_default_dispatch;
-    extern const MallocDebug* __libc_malloc_dispatch;
-    extern pthread_mutex_t gAllocationsMutex;
-
-    va_list args;
-    {
-        ScopedPthreadMutexLocker locker(&gAllocationsMutex);
-        const MallocDebug* current_dispatch = __libc_malloc_dispatch;
-        __libc_malloc_dispatch = &__libc_malloc_default_dispatch;
-        va_start(args, format);
-        __libc_android_log_vprint(ANDROID_LOG_ERROR, "libc", format, args);
-        va_end(args);
-        __libc_malloc_dispatch = current_dispatch;
-    }
+  va_list args;
+  va_start(args, format);
+  __libc_format_log_va_list(ANDROID_LOG_ERROR, "libc", format, args);
+  va_end(args);
 }
 
 struct hdr_t {
     uint32_t tag;
     hdr_t* prev;
     hdr_t* next;
-    intptr_t bt[MAX_BACKTRACE_DEPTH];
+    uintptr_t bt[MAX_BACKTRACE_DEPTH];
     int bt_depth;
-    intptr_t freed_bt[MAX_BACKTRACE_DEPTH];
+    uintptr_t freed_bt[MAX_BACKTRACE_DEPTH];
     int freed_bt_depth;
     size_t size;
     char front_guard[FRONT_GUARD_LEN];
@@ -112,7 +100,7 @@
     return reinterpret_cast<hdr_t*>(user) - 1;
 }
 
-static unsigned num;
+static unsigned gAllocatedBlockCount;
 static hdr_t *tail;
 static hdr_t *head;
 static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
@@ -122,28 +110,6 @@
 static hdr_t *backlog_head;
 static pthread_mutex_t backlog_lock = PTHREAD_MUTEX_INITIALIZER;
 
-extern __LIBC_HIDDEN__ int get_backtrace(intptr_t* addrs, size_t max_entries);
-
-static void print_backtrace(const intptr_t *bt, unsigned int depth) {
-    const mapinfo *mi;
-    unsigned int cnt;
-    unsigned int rel_pc;
-    intptr_t self_bt[MAX_BACKTRACE_DEPTH];
-
-    if (!bt) {
-        depth = get_backtrace(self_bt, MAX_BACKTRACE_DEPTH);
-        bt = self_bt;
-    }
-
-    log_message("*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n");
-    for (cnt = 0; cnt < depth && cnt < MAX_BACKTRACE_DEPTH; cnt++) {
-        mi = pc_to_mapinfo(milist, bt[cnt], &rel_pc);
-        log_message("\t#%02d  pc %08x  %s\n", cnt,
-                   mi ? (intptr_t)rel_pc : bt[cnt],
-                   mi ? mi->name : "(unknown)");
-    }
-}
-
 static inline void init_front_guard(hdr_t *hdr) {
     memset(hdr->front_guard, FRONT_GUARD, FRONT_GUARD_LEN);
 }
@@ -213,7 +179,7 @@
     hdr->size = size;
     init_front_guard(hdr);
     init_rear_guard(hdr);
-    num++;
+    ++gAllocatedBlockCount;
     add_locked(hdr, &tail, &head);
 }
 
@@ -224,7 +190,7 @@
 
     ScopedPthreadMutexLocker locker(&lock);
     del_locked(hdr, &tail, &head);
-    num--;
+    --gAllocatedBlockCount;
     return 0;
 }
 
@@ -293,11 +259,11 @@
     if (!valid && *safe) {
         log_message("+++ ALLOCATION %p SIZE %d ALLOCATED HERE:\n",
                         user(hdr), hdr->size);
-        print_backtrace(hdr->bt, hdr->bt_depth);
+        log_backtrace(hdr->bt, hdr->bt_depth);
         if (hdr->tag == BACKLOG_TAG) {
             log_message("+++ ALLOCATION %p SIZE %d FREED HERE:\n",
                        user(hdr), hdr->size);
-            print_backtrace(hdr->freed_bt, hdr->freed_bt_depth);
+            log_backtrace(hdr->freed_bt, hdr->freed_bt_depth);
         }
     }
 
@@ -330,7 +296,7 @@
 
 static inline int del_leak(hdr_t *hdr, int *safe) {
     ScopedPthreadMutexLocker locker(&lock);
-    return del_and_check_locked(hdr, &tail, &head, &num, safe);
+    return del_and_check_locked(hdr, &tail, &head, &gAllocatedBlockCount, safe);
 }
 
 static inline void add_to_backlog(hdr_t *hdr) {
@@ -340,7 +306,7 @@
     add_locked(hdr, &backlog_tail, &backlog_head);
     poison(hdr);
     /* If we've exceeded the maximum backlog, clear it up */
-    while (backlog_num > malloc_double_free_backlog) {
+    while (backlog_num > gMallocDebugBacklog) {
         hdr_t *gone = backlog_tail;
         del_from_backlog_locked(gone);
         dlfree(gone);
@@ -374,32 +340,28 @@
     hdr_t* hdr = meta(ptr);
 
     if (del(hdr) < 0) {
-        intptr_t bt[MAX_BACKTRACE_DEPTH];
-        int depth;
-        depth = get_backtrace(bt, MAX_BACKTRACE_DEPTH);
+        uintptr_t bt[MAX_BACKTRACE_DEPTH];
+        int depth = get_backtrace(bt, MAX_BACKTRACE_DEPTH);
         if (hdr->tag == BACKLOG_TAG) {
             log_message("+++ ALLOCATION %p SIZE %d BYTES MULTIPLY FREED!\n",
                        user(hdr), hdr->size);
             log_message("+++ ALLOCATION %p SIZE %d ALLOCATED HERE:\n",
                        user(hdr), hdr->size);
-            print_backtrace(hdr->bt, hdr->bt_depth);
+            log_backtrace(hdr->bt, hdr->bt_depth);
             /* hdr->freed_bt_depth should be nonzero here */
             log_message("+++ ALLOCATION %p SIZE %d FIRST FREED HERE:\n",
                        user(hdr), hdr->size);
-            print_backtrace(hdr->freed_bt, hdr->freed_bt_depth);
+            log_backtrace(hdr->freed_bt, hdr->freed_bt_depth);
             log_message("+++ ALLOCATION %p SIZE %d NOW BEING FREED HERE:\n",
                        user(hdr), hdr->size);
-            print_backtrace(bt, depth);
+            log_backtrace(bt, depth);
         } else {
             log_message("+++ ALLOCATION %p IS CORRUPTED OR NOT ALLOCATED VIA TRACKER!\n",
                        user(hdr));
-            print_backtrace(bt, depth);
-            /* Leak here so that we do not crash */
-            //dlfree(user(hdr));
+            log_backtrace(bt, depth);
         }
     } else {
-        hdr->freed_bt_depth = get_backtrace(hdr->freed_bt,
-                                      MAX_BACKTRACE_DEPTH);
+        hdr->freed_bt_depth = get_backtrace(hdr->freed_bt, MAX_BACKTRACE_DEPTH);
         add_to_backlog(hdr);
     }
 }
@@ -407,34 +369,35 @@
 extern "C" void *chk_realloc(void *ptr, size_t size) {
 //  log_message("%s: %s\n", __FILE__, __FUNCTION__);
 
-    if (!size) {
-        chk_free(ptr);
-        return NULL;
-    }
-
     if (!ptr) {
         return chk_malloc(size);
     }
 
+#ifdef REALLOC_ZERO_BYTES_FREE
+    if (!size) {
+        chk_free(ptr);
+        return NULL;
+    }
+#endif
+
     hdr_t* hdr = meta(ptr);
 
     if (del(hdr) < 0) {
-        intptr_t bt[MAX_BACKTRACE_DEPTH];
-        int depth;
-        depth = get_backtrace(bt, MAX_BACKTRACE_DEPTH);
+        uintptr_t bt[MAX_BACKTRACE_DEPTH];
+        int depth = get_backtrace(bt, MAX_BACKTRACE_DEPTH);
         if (hdr->tag == BACKLOG_TAG) {
             log_message("+++ REALLOCATION %p SIZE %d OF FREED MEMORY!\n",
                        user(hdr), size, hdr->size);
             log_message("+++ ALLOCATION %p SIZE %d ALLOCATED HERE:\n",
                        user(hdr), hdr->size);
-            print_backtrace(hdr->bt, hdr->bt_depth);
+            log_backtrace(hdr->bt, hdr->bt_depth);
             /* hdr->freed_bt_depth should be nonzero here */
             log_message("+++ ALLOCATION %p SIZE %d FIRST FREED HERE:\n",
                        user(hdr), hdr->size);
-            print_backtrace(hdr->freed_bt, hdr->freed_bt_depth);
+            log_backtrace(hdr->freed_bt, hdr->freed_bt_depth);
             log_message("+++ ALLOCATION %p SIZE %d NOW BEING REALLOCATED HERE:\n",
                        user(hdr), hdr->size);
-            print_backtrace(bt, depth);
+            log_backtrace(bt, depth);
 
              /* We take the memory out of the backlog and fall through so the
              * reallocation below succeeds.  Since we didn't really free it, we
@@ -444,7 +407,7 @@
         } else {
             log_message("+++ REALLOCATION %p SIZE %d IS CORRUPTED OR NOT ALLOCATED VIA TRACKER!\n",
                        user(hdr), size);
-            print_backtrace(bt, depth);
+            log_backtrace(bt, depth);
             // just get a whole new allocation and leak the old one
             return dlrealloc(0, size);
             // return dlrealloc(user(hdr), size); // assuming it was allocated externally
@@ -466,53 +429,58 @@
     size_t total_size = nmemb * size;
     hdr_t* hdr = static_cast<hdr_t*>(dlcalloc(1, sizeof(hdr_t) + total_size + sizeof(ftr_t)));
     if (hdr) {
-        hdr->bt_depth = get_backtrace(
-                            hdr->bt, MAX_BACKTRACE_DEPTH);
+        hdr->bt_depth = get_backtrace(hdr->bt, MAX_BACKTRACE_DEPTH);
         add(hdr, total_size);
         return user(hdr);
     }
     return NULL;
 }
 
-static void heaptracker_free_leaked_memory() {
-    if (num) {
-        log_message("+++ THERE ARE %d LEAKED ALLOCATIONS\n", num);
-    }
+static void ReportMemoryLeaks() {
+  // We only track leaks at level 10.
+  if (gMallocDebugLevel != 10) {
+    return;
+  }
 
-    hdr_t *del = NULL;
-    while (head) {
-        int safe;
-        del = head;
-        log_message("+++ DELETING %d BYTES OF LEAKED MEMORY AT %p (%d REMAINING)\n",
-                del->size, user(del), num);
-        if (del_leak(del, &safe)) {
-            /* safe == 1, because the allocation is valid */
-            log_message("+++ ALLOCATION %p SIZE %d ALLOCATED HERE:\n",
-                        user(del), del->size);
-            print_backtrace(del->bt, del->bt_depth);
-        }
-        dlfree(del);
-    }
+  // Use /proc/self/exe link to obtain the program name for logging
+  // purposes. If it's not available, we set it to "<unknown>".
+  char exe[PATH_MAX];
+  int count;
+  if ((count = readlink("/proc/self/exe", exe, sizeof(exe) - 1)) == -1) {
+    strlcpy(exe, "<unknown>", sizeof(exe));
+  } else {
+    exe[count] = '\0';
+  }
 
-//  log_message("+++ DELETING %d BACKLOGGED ALLOCATIONS\n", backlog_num);
-    while (backlog_head) {
-        del = backlog_tail;
-        del_from_backlog(del);
-        dlfree(del);
+  if (gAllocatedBlockCount == 0) {
+    log_message("+++ %s did not leak", exe);
+    return;
+  }
+
+  size_t index = 1;
+  const size_t total = gAllocatedBlockCount;
+  while (head != NULL) {
+    int safe;
+    hdr_t* block = head;
+    log_message("+++ %s leaked block of size %d at %p (leak %d of %d)",
+                exe, block->size, user(block), index++, total);
+    if (del_leak(block, &safe)) {
+      /* safe == 1, because the allocation is valid */
+      log_backtrace(block->bt, block->bt_depth);
     }
+  }
+
+  while (backlog_head != NULL) {
+    del_from_backlog(backlog_tail);
+  }
 }
 
-/* Initializes malloc debugging framework.
- * See comments on MallocDebugInit in malloc_debug_common.h
- */
 extern "C" int malloc_debug_initialize() {
-    if (!malloc_double_free_backlog)
-        malloc_double_free_backlog = BACKLOG_DEFAULT_LEN;
-    milist = init_mapinfo(getpid());
-    return 0;
+  backtrace_startup();
+  return 0;
 }
 
 extern "C" void malloc_debug_finalize() {
-    heaptracker_free_leaked_memory();
-    deinit_mapinfo(milist);
+  ReportMemoryLeaks();
+  backtrace_shutdown();
 }
diff --git a/libc/bionic/malloc_debug_check_mapinfo.cpp b/libc/bionic/malloc_debug_check_mapinfo.cpp
deleted file mode 100644
index 8cc2c99..0000000
--- a/libc/bionic/malloc_debug_check_mapinfo.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "dlmalloc.h"
-#include "malloc_debug_check_mapinfo.h"
-
-// 6f000000-6f01e000 rwxp 00000000 00:0c 16389419   /system/lib/libcomposer.so
-// 012345678901234567890123456789012345678901234567890123456789
-// 0         1         2         3         4         5
-
-static mapinfo* parse_maps_line(char* line) {
-    int len = strlen(line);
-
-    if (len < 1) return 0;
-    line[--len] = 0;
-
-    if (len < 50) return 0;
-    if (line[20] != 'x') return 0;
-
-    mapinfo* mi = static_cast<mapinfo*>(dlmalloc(sizeof(mapinfo) + (len - 47)));
-    if (mi == 0) return 0;
-
-    mi->start = strtoul(line, 0, 16);
-    mi->end = strtoul(line + 9, 0, 16);
-    /* To be filled in parse_elf_info if the mapped section starts with
-     * elf_header
-     */
-    mi->next = 0;
-    strcpy(mi->name, line + 49);
-
-    return mi;
-}
-
-__LIBC_HIDDEN__
-mapinfo *init_mapinfo(int pid) {
-    struct mapinfo *milist = NULL;
-    char data[1024]; // Used to read lines as well as to construct the filename.
-    snprintf(data, sizeof(data), "/proc/%d/maps", pid);
-    FILE *fp = fopen(data, "r");
-    if (fp) {
-        while (fgets(data, sizeof(data), fp)) {
-            mapinfo *mi = parse_maps_line(data);
-            if (mi) {
-                mi->next = milist;
-                milist = mi;
-            }
-        }
-        fclose(fp);
-    }
-
-    return milist;
-}
-
-__LIBC_HIDDEN__
-void deinit_mapinfo(mapinfo *mi) {
-    mapinfo *del;
-    while (mi) {
-        del = mi;
-        mi = mi->next;
-        dlfree(del);
-    }
-}
-
-/* Map a pc address to the name of the containing ELF file */
-__LIBC_HIDDEN__
-const char *map_to_name(mapinfo *mi, unsigned pc, const char* def) {
-    while (mi) {
-        if ((pc >= mi->start) && (pc < mi->end)) {
-            return mi->name;
-        }
-        mi = mi->next;
-    }
-    return def;
-}
-
-/* Find the containing map info for the pc */
-__LIBC_HIDDEN__
-const mapinfo *pc_to_mapinfo(mapinfo *mi, unsigned pc, unsigned *rel_pc) {
-    *rel_pc = pc;
-    while (mi) {
-        if ((pc >= mi->start) && (pc < mi->end)) {
-            // Only calculate the relative offset for shared libraries
-            if (strstr(mi->name, ".so")) {
-                *rel_pc -= mi->start;
-            }
-            return mi;
-        }
-        mi = mi->next;
-    }
-    return NULL;
-}
diff --git a/libc/bionic/malloc_debug_check_mapinfo.h b/libc/bionic/malloc_debug_check_mapinfo.h
deleted file mode 100644
index e19f71e..0000000
--- a/libc/bionic/malloc_debug_check_mapinfo.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef MALLOC_DEBUG_CHECK_MAPINFO_H
-#define MALLOC_DEBUG_CHECK_MAPINFO_H
-
-#include <sys/cdefs.h>
-
-struct mapinfo {
-  struct mapinfo* next;
-  unsigned start;
-  unsigned end;
-  char name[];
-};
-
-__LIBC_HIDDEN__ mapinfo *init_mapinfo(int pid);
-__LIBC_HIDDEN__ void deinit_mapinfo(mapinfo *mi);
-__LIBC_HIDDEN__ const char *map_to_name(mapinfo *mi, unsigned pc, const char* def);
-__LIBC_HIDDEN__ const mapinfo *pc_to_mapinfo(mapinfo *mi, unsigned pc, unsigned *rel_pc);
-
-#endif /*MALLOC_DEBUG_CHECK_MAPINFO_H*/
diff --git a/libc/bionic/malloc_debug_common.cpp b/libc/bionic/malloc_debug_common.cpp
index 3a12cd4..a05a5ef 100644
--- a/libc/bionic/malloc_debug_common.cpp
+++ b/libc/bionic/malloc_debug_common.cpp
@@ -40,12 +40,15 @@
  * or static (libc.a) linking.
  */
 
-#include <stdlib.h>
-#include <pthread.h>
-#include <unistd.h>
-#include "dlmalloc.h"
 #include "malloc_debug_common.h"
 
+#include <pthread.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "dlmalloc.h"
+#include "ScopedPthreadMutexLocker.h"
+
 /*
  * In a VM process, this is set to 1 after fork()ing out of zygote.
  */
@@ -145,7 +148,7 @@
     }
 
     // XXX: the protocol doesn't allow variable size for the stack trace (yet)
-    *infoSize = (sizeof(size_t) * 2) + (sizeof(intptr_t) * BACKTRACE_SIZE);
+    *infoSize = (sizeof(size_t) * 2) + (sizeof(uintptr_t) * BACKTRACE_SIZE);
     *overallSize = *infoSize * gHashTable.count;
     *backtraceSize = BACKTRACE_SIZE;
 
@@ -164,7 +167,7 @@
     const int count = gHashTable.count;
     for (int i = 0 ; i < count ; ++i) {
         HashEntry* entry = list[i];
-        size_t entrySize = (sizeof(size_t) * 2) + (sizeof(intptr_t) * entry->numEntries);
+        size_t entrySize = (sizeof(size_t) * 2) + (sizeof(uintptr_t) * entry->numEntries);
         if (entrySize < *infoSize) {
             /* we're writing less than a full entry, clear out the rest */
             memset(head + entrySize, 0, *infoSize - entrySize);
@@ -239,7 +242,7 @@
     return __libc_malloc_dispatch->memalign(alignment, bytes);
 }
 
-/* We implement malloc debugging only in libc.so, so code bellow
+/* We implement malloc debugging only in libc.so, so code below
  * must be excluded if we compile this file for static libc.a
  */
 #ifndef LIBC_STATIC
@@ -253,7 +256,7 @@
     dlmalloc, dlfree, dlcalloc, dlrealloc, dlmemalign
 };
 
-extern char* __progname;
+extern const char* __progname;
 
 /* Handle to shared library where actual memory allocation is implemented.
  * This library is loaded and memory allocation calls are redirected there
@@ -277,25 +280,25 @@
  */
 static void* libc_malloc_impl_handle = NULL;
 
-/* Make sure we have MALLOC_ALIGNMENT that matches the one that is
- * used in dlmalloc. Emulator's memchecker needs this value to properly
- * align its guarding zones.
- */
+// This must match the alignment used by dlmalloc.
 #ifndef MALLOC_ALIGNMENT
-#define MALLOC_ALIGNMENT ((size_t)8U)
-#endif  /* MALLOC_ALIGNMENT */
+#define MALLOC_ALIGNMENT ((size_t)(2 * sizeof(void *)))
+#endif
 
 /* This variable is set to the value of property libc.debug.malloc.backlog,
  * when the value of libc.debug.malloc = 10.  It determines the size of the
  * backlog we use to detect multiple frees.  If the property is not set, the
- * backlog length defaults to an internal constant defined in
- * malloc_debug_check.cpp.
+ * backlog length defaults to BACKLOG_DEFAULT_LEN.
  */
-unsigned int malloc_double_free_backlog;
+unsigned int gMallocDebugBacklog;
+#define BACKLOG_DEFAULT_LEN 100
 
-static void InitMalloc(MallocDebug* table, int debug_level, const char* prefix) {
-  __libc_android_log_print(ANDROID_LOG_INFO, "libc", "%s: using libc.debug.malloc %d (%s)\n",
-                           __progname, debug_level, prefix);
+/* The value of libc.debug.malloc. */
+int gMallocDebugLevel;
+
+static void InitMalloc(MallocDebug* table, const char* prefix) {
+  __libc_format_log(ANDROID_LOG_INFO, "libc", "%s: using libc.debug.malloc %d (%s)\n",
+                    __progname, gMallocDebugLevel, prefix);
 
   char symbol[128];
 
@@ -335,7 +338,6 @@
     const char* so_name = NULL;
     MallocDebugInit malloc_debug_initialize = NULL;
     unsigned int qemu_running = 0;
-    unsigned int debug_level = 0;
     unsigned int memcheck_enabled = 0;
     char env[PROP_VALUE_MAX];
     char memcheck_tracing[PROP_VALUE_MAX];
@@ -349,7 +351,7 @@
         if (__system_property_get("ro.kernel.memcheck", memcheck_tracing)) {
             if (memcheck_tracing[0] != '0') {
                 // Emulator has started with memory tracing enabled. Enforce it.
-                debug_level = 20;
+                gMallocDebugLevel = 20;
                 memcheck_enabled = 1;
             }
         }
@@ -357,13 +359,13 @@
 
     /* If debug level has not been set by memcheck option in the emulator,
      * lets grab it from libc.debug.malloc system property. */
-    if (debug_level == 0 && __system_property_get("libc.debug.malloc", env)) {
-        debug_level = atoi(env);
+    if (gMallocDebugLevel == 0 && __system_property_get("libc.debug.malloc", env)) {
+        gMallocDebugLevel = atoi(env);
     }
 
     /* Debug level 0 means that we should use dlxxx allocation
      * routines (default). */
-    if (debug_level == 0) {
+    if (gMallocDebugLevel == 0) {
         return;
     }
 
@@ -376,18 +378,26 @@
         }
     }
 
-    // Lets see which .so must be loaded for the requested debug level
-    switch (debug_level) {
+    // mksh is way too leaky. http://b/7291287.
+    if (gMallocDebugLevel >= 10) {
+        if (strcmp(__progname, "sh") == 0 || strcmp(__progname, "/system/bin/sh") == 0) {
+            return;
+        }
+    }
+
+    // Choose the appropriate .so for the requested debug level.
+    switch (gMallocDebugLevel) {
         case 1:
         case 5:
         case 10: {
             char debug_backlog[PROP_VALUE_MAX];
             if (__system_property_get("libc.debug.malloc.backlog", debug_backlog)) {
-                malloc_double_free_backlog = atoi(debug_backlog);
-                info_log("%s: setting backlog length to %d\n",
-                         __progname, malloc_double_free_backlog);
+                gMallocDebugBacklog = atoi(debug_backlog);
+                info_log("%s: setting backlog length to %d\n", __progname, gMallocDebugBacklog);
             }
-
+            if (gMallocDebugBacklog == 0) {
+                gMallocDebugBacklog = BACKLOG_DEFAULT_LEN;
+            }
             so_name = "/system/lib/libc_malloc_debug_leak.so";
             break;
         }
@@ -395,7 +405,7 @@
             // Quick check: debug level 20 can only be handled in emulator.
             if (!qemu_running) {
                 error_log("%s: Debug level %d can only be set in emulator\n",
-                          __progname, debug_level);
+                          __progname, gMallocDebugLevel);
                 return;
             }
             // Make sure that memory checking has been enabled in emulator.
@@ -407,8 +417,7 @@
             so_name = "/system/lib/libc_malloc_debug_qemu.so";
             break;
         default:
-            error_log("%s: Debug level %d is unknown\n",
-                      __progname, debug_level);
+            error_log("%s: Debug level %d is unknown\n", __progname, gMallocDebugLevel);
             return;
     }
 
@@ -416,7 +425,7 @@
     libc_malloc_impl_handle = dlopen(so_name, RTLD_LAZY);
     if (libc_malloc_impl_handle == NULL) {
         error_log("%s: Missing module %s required for malloc debug level %d: %s",
-                  __progname, so_name, debug_level, dlerror());
+                  __progname, so_name, gMallocDebugLevel, dlerror());
         return;
     }
 
@@ -429,12 +438,12 @@
         dlclose(libc_malloc_impl_handle);
         return;
     }
-    if (malloc_debug_initialize()) {
+    if (malloc_debug_initialize() == -1) {
         dlclose(libc_malloc_impl_handle);
         return;
     }
 
-    if (debug_level == 20) {
+    if (gMallocDebugLevel == 20) {
         // For memory checker we need to do extra initialization.
         typedef int (*MemCheckInit)(int, const char*);
         MemCheckInit memcheck_initialize =
@@ -446,6 +455,7 @@
             dlclose(libc_malloc_impl_handle);
             return;
         }
+
         if (memcheck_initialize(MALLOC_ALIGNMENT, memcheck_tracing)) {
             dlclose(libc_malloc_impl_handle);
             return;
@@ -453,18 +463,18 @@
     }
 
     // Initialize malloc dispatch table with appropriate routines.
-    switch (debug_level) {
+    switch (gMallocDebugLevel) {
         case 1:
-            InitMalloc(&gMallocUse, debug_level, "leak");
+            InitMalloc(&gMallocUse, "leak");
             break;
         case 5:
-            InitMalloc(&gMallocUse, debug_level, "fill");
+            InitMalloc(&gMallocUse, "fill");
             break;
         case 10:
-            InitMalloc(&gMallocUse, debug_level, "chk");
+            InitMalloc(&gMallocUse, "chk");
             break;
         case 20:
-            InitMalloc(&gMallocUse, debug_level, "qemu_instrumented");
+            InitMalloc(&gMallocUse, "qemu_instrumented");
             break;
         default:
             break;
@@ -477,7 +487,7 @@
         (gMallocUse.realloc == NULL) ||
         (gMallocUse.memalign == NULL)) {
         error_log("%s: some symbols for libc.debug.malloc level %d were not found (see above)",
-                  __progname, debug_level);
+                  __progname, gMallocDebugLevel);
         dlclose(libc_malloc_impl_handle);
         libc_malloc_impl_handle = NULL;
     } else {
@@ -486,11 +496,19 @@
 }
 
 static void malloc_fini_impl() {
-    if (libc_malloc_impl_handle) {
+    // Our BSD stdio implementation doesn't close the standard streams, it only flushes them.
+    // And it doesn't do that until its atexit handler (_cleanup) is run, and we run first!
+    // It's great that other unclosed FILE*s show up as malloc leaks, but we need to manually
+    // clean up the standard streams ourselves.
+    fclose(stdin);
+    fclose(stdout);
+    fclose(stderr);
+
+    if (libc_malloc_impl_handle != NULL) {
         MallocDebugFini malloc_debug_finalize =
             reinterpret_cast<MallocDebugFini>(dlsym(libc_malloc_impl_handle,
                                                     "malloc_debug_finalize"));
-        if (malloc_debug_finalize) {
+        if (malloc_debug_finalize != NULL) {
             malloc_debug_finalize();
         }
     }
@@ -510,17 +528,17 @@
     /* We need to initialize malloc iff we implement here custom
      * malloc routines (i.e. USE_DL_PREFIX is defined) for libc.so */
 #if defined(USE_DL_PREFIX) && !defined(LIBC_STATIC)
-  if (pthread_once(&malloc_init_once_ctl, malloc_init_impl)) {
+    if (pthread_once(&malloc_init_once_ctl, malloc_init_impl)) {
         error_log("Unable to initialize malloc_debug component.");
     }
 #endif  // USE_DL_PREFIX && !LIBC_STATIC
 }
 
 extern "C" void malloc_debug_fini() {
-  /* We need to finalize malloc iff we implement here custom
+    /* We need to finalize malloc iff we implement here custom
      * malloc routines (i.e. USE_DL_PREFIX is defined) for libc.so */
 #if defined(USE_DL_PREFIX) && !defined(LIBC_STATIC)
-  if (pthread_once(&malloc_fini_once_ctl, malloc_fini_impl)) {
+    if (pthread_once(&malloc_fini_once_ctl, malloc_fini_impl)) {
         error_log("Unable to finalize malloc_debug component.");
     }
 #endif  // USE_DL_PREFIX && !LIBC_STATIC
diff --git a/libc/bionic/malloc_debug_common.h b/libc/bionic/malloc_debug_common.h
index 45b4e36..e15ccd0 100644
--- a/libc/bionic/malloc_debug_common.h
+++ b/libc/bionic/malloc_debug_common.h
@@ -33,6 +33,10 @@
 #ifndef MALLOC_DEBUG_COMMON_H
 #define MALLOC_DEBUG_COMMON_H
 
+#include <stdlib.h>
+
+#include <private/debug_format.h>
+
 #define HASHTABLE_SIZE      1543
 #define BACKTRACE_SIZE      32
 /* flag definitions, currently sharing storage with "size" */
@@ -53,7 +57,7 @@
     // fields above "size" are NOT sent to the host
     size_t size;
     size_t allocations;
-    intptr_t backtrace[0];
+    uintptr_t backtrace[0];
 };
 
 struct HashTable {
@@ -95,24 +99,10 @@
 // =============================================================================
 
 #define debug_log(format, ...)  \
-    __libc_android_log_print(ANDROID_LOG_DEBUG, "malloc_leak_check", (format), ##__VA_ARGS__ )
+    __libc_format_log(ANDROID_LOG_DEBUG, "malloc_leak_check", (format), ##__VA_ARGS__ )
 #define error_log(format, ...)  \
-    __libc_android_log_print(ANDROID_LOG_ERROR, "malloc_leak_check", (format), ##__VA_ARGS__ )
+    __libc_format_log(ANDROID_LOG_ERROR, "malloc_leak_check", (format), ##__VA_ARGS__ )
 #define info_log(format, ...)  \
-    __libc_android_log_print(ANDROID_LOG_INFO, "malloc_leak_check", (format), ##__VA_ARGS__ )
-
-class ScopedPthreadMutexLocker {
- public:
-  explicit ScopedPthreadMutexLocker(pthread_mutex_t* mu) : mu_(mu) {
-    pthread_mutex_lock(mu_);
-  }
-
-  ~ScopedPthreadMutexLocker() {
-    pthread_mutex_unlock(mu_);
-  }
-
- private:
-  pthread_mutex_t* mu_;
-};
+    __libc_format_log(ANDROID_LOG_INFO, "malloc_leak_check", (format), ##__VA_ARGS__ )
 
 #endif  // MALLOC_DEBUG_COMMON_H
diff --git a/libc/bionic/malloc_debug_leak.cpp b/libc/bionic/malloc_debug_leak.cpp
index c13b520..9e63a86 100644
--- a/libc/bionic/malloc_debug_leak.cpp
+++ b/libc/bionic/malloc_debug_leak.cpp
@@ -26,6 +26,7 @@
  * SUCH DAMAGE.
  */
 
+#include <arpa/inet.h>
 #include <dlfcn.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -36,19 +37,19 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
-#include <unwind.h>
-
-#include <arpa/inet.h>
 #include <sys/select.h>
 #include <sys/socket.h>
 #include <sys/system_properties.h>
 #include <sys/types.h>
 #include <sys/un.h>
+#include <unistd.h>
+#include <unwind.h>
 
+#include "debug_stacktrace.h"
 #include "dlmalloc.h"
 #include "logd.h"
 #include "malloc_debug_common.h"
+#include "ScopedPthreadMutexLocker.h"
 
 // This file should be included into the build only when
 // MALLOC_LEAK_CHECK, or MALLOC_QEMU_INSTRUMENT, or both
@@ -89,7 +90,7 @@
 // Hash Table functions
 // =============================================================================
 
-static uint32_t get_hash(intptr_t* backtrace, size_t numEntries) {
+static uint32_t get_hash(uintptr_t* backtrace, size_t numEntries) {
     if (backtrace == NULL) return 0;
 
     int hash = 0;
@@ -102,7 +103,7 @@
 }
 
 static HashEntry* find_entry(HashTable* table, int slot,
-        intptr_t* backtrace, size_t numEntries, size_t size) {
+                             uintptr_t* backtrace, size_t numEntries, size_t size) {
     HashEntry* entry = table->slots[slot];
     while (entry != NULL) {
         //debug_log("backtrace: %p, entry: %p entry->backtrace: %p\n",
@@ -112,7 +113,7 @@
          * including the flag bits.
          */
         if (entry->size == size && entry->numEntries == numEntries &&
-                !memcmp(backtrace, entry->backtrace, numEntries * sizeof(intptr_t))) {
+                !memcmp(backtrace, entry->backtrace, numEntries * sizeof(uintptr_t))) {
             return entry;
         }
 
@@ -122,7 +123,7 @@
     return NULL;
 }
 
-static HashEntry* record_backtrace(intptr_t* backtrace, size_t numEntries, size_t size) {
+static HashEntry* record_backtrace(uintptr_t* backtrace, size_t numEntries, size_t size) {
     size_t hash = get_hash(backtrace, numEntries);
     size_t slot = hash % HASHTABLE_SIZE;
 
@@ -141,7 +142,7 @@
         entry->allocations++;
     } else {
         // create a new entry
-        entry = static_cast<HashEntry*>(dlmalloc(sizeof(HashEntry) + numEntries*sizeof(intptr_t)));
+        entry = static_cast<HashEntry*>(dlmalloc(sizeof(HashEntry) + numEntries*sizeof(uintptr_t)));
         if (!entry) {
             return NULL;
         }
@@ -152,7 +153,7 @@
         entry->numEntries = numEntries;
         entry->size = size;
 
-        memcpy(entry->backtrace, backtrace, numEntries * sizeof(intptr_t));
+        memcpy(entry->backtrace, backtrace, numEntries * sizeof(uintptr_t));
 
         gHashTable.slots[slot] = entry;
 
@@ -255,8 +256,6 @@
 
 static void* MEMALIGN_GUARD = reinterpret_cast<void*>(0xA1A41520);
 
-extern __LIBC_HIDDEN__ int get_backtrace(intptr_t* addrs, size_t max_entries);
-
 extern "C" void* leak_malloc(size_t bytes) {
     // allocate enough space infront of the allocation to store the pointer for
     // the alloc structure. This will making free'ing the structer really fast!
@@ -273,7 +272,7 @@
     if (base != NULL) {
         ScopedPthreadMutexLocker locker(&gAllocationsMutex);
 
-        intptr_t backtrace[BACKTRACE_SIZE];
+        uintptr_t backtrace[BACKTRACE_SIZE];
         size_t numEntries = get_backtrace(backtrace, BACKTRACE_SIZE);
 
         AllocationEntry* header = reinterpret_cast<AllocationEntry*>(base);
@@ -366,7 +365,7 @@
         alignment = 1L << (31 - __builtin_clz(alignment));
     }
 
-    // here, aligment is at least MALLOC_ALIGNMENT<<1 bytes
+    // here, alignment is at least MALLOC_ALIGNMENT<<1 bytes
     // we will align by at least MALLOC_ALIGNMENT bytes
     // and at most alignment-MALLOC_ALIGNMENT bytes
     size_t size = (alignment-MALLOC_ALIGNMENT) + bytes;
diff --git a/libc/bionic/malloc_debug_qemu.cpp b/libc/bionic/malloc_debug_qemu.cpp
index e586b1b..812a451 100644
--- a/libc/bionic/malloc_debug_qemu.cpp
+++ b/libc/bionic/malloc_debug_qemu.cpp
@@ -257,8 +257,8 @@
                              INFO_TRACING_ENABLED)
 
 /* Prints a string to the emulator's stdout.
- * In early stages of system loading, logging mesages via
- * __libc_android_log_print API is not available, because ADB API has not been
+ * In early stages of system loading, logging messages to logcat
+ * is not available, because ADB API has not been
  * hooked up yet. So, in order to see such messages we need to print them to
  * the emulator's stdout.
  * Parameters passed to this macro are the same as parameters for printf
@@ -289,8 +289,7 @@
  */
 #define qemu_debug_log(format, ...)                                         \
     do {                                                                    \
-        __libc_android_log_print(ANDROID_LOG_DEBUG, "memcheck",             \
-                                 (format), ##__VA_ARGS__);                  \
+        __libc_format_log(ANDROID_LOG_DEBUG, "memcheck", (format), ##__VA_ARGS__); \
         if (tracing_flags & DEBUG_TRACING_ENABLED) {                        \
             qemu_log(ANDROID_LOG_DEBUG, (format), ##__VA_ARGS__);           \
         }                                                                   \
@@ -298,8 +297,7 @@
 
 #define qemu_error_log(format, ...)                                         \
     do {                                                                    \
-        __libc_android_log_print(ANDROID_LOG_ERROR, "memcheck",             \
-                                 (format), ##__VA_ARGS__);                  \
+        __libc_format_log(ANDROID_LOG_ERROR, "memcheck", (format), ##__VA_ARGS__); \
         if (tracing_flags & ERROR_TRACING_ENABLED) {                        \
             qemu_log(ANDROID_LOG_ERROR, (format), ##__VA_ARGS__);           \
         }                                                                   \
@@ -307,8 +305,7 @@
 
 #define qemu_info_log(format, ...)                                          \
     do {                                                                    \
-        __libc_android_log_print(ANDROID_LOG_INFO, "memcheck",              \
-                                 (format), ##__VA_ARGS__);                  \
+        __libc_format_log(ANDROID_LOG_INFO, "memcheck", (format), ##__VA_ARGS__); \
         if (tracing_flags & INFO_TRACING_ENABLED) {                         \
             qemu_log(ANDROID_LOG_INFO, (format), ##__VA_ARGS__);            \
         }                                                                   \
@@ -318,20 +315,19 @@
  * Param:
  *  type - Message type: debug, error, or info
  *  desc - MallocDesc instance to dump.
- *  frmt + rest - Formats message preceding dumped descriptor.
+ *  fmt + rest - Formats message preceding dumped descriptor.
 */
-#define log_mdesc(type, desc, frmt, ...)                                    \
+#define log_mdesc(type, desc, fmt, ...)                                    \
     do {                                                                    \
         if (tracing_enabled(type)) {                                        \
             char log_str[4096];                                             \
-            size_t str_len;                                                 \
-            snprintf(log_str, sizeof(log_str), frmt, ##__VA_ARGS__);        \
+            __libc_format_buffer(log_str, sizeof(log_str), fmt, ##__VA_ARGS__); \
             log_str[sizeof(log_str) - 1] = '\0';                            \
-            str_len = strlen(log_str);                                      \
+            size_t str_len = strlen(log_str);                               \
             dump_malloc_descriptor(log_str + str_len,                       \
                                    sizeof(log_str) - str_len,               \
                                    (desc));                                 \
-            type##_log(log_str);                                            \
+            type##_log("%s", log_str);                                      \
         }                                                                   \
     } while (0)
 
diff --git a/libc/bionic/malloc_debug_stacktrace.cpp b/libc/bionic/malloc_debug_stacktrace.cpp
deleted file mode 100644
index 32b8ac0..0000000
--- a/libc/bionic/malloc_debug_stacktrace.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <unwind.h>
-#include <sys/types.h>
-
-// =============================================================================
-// stack trace functions
-// =============================================================================
-
-struct stack_crawl_state_t {
-    size_t count;
-    intptr_t* addrs;
-};
-
-
-/* depends how the system includes define this */
-#ifdef HAVE_UNWIND_CONTEXT_STRUCT
-typedef struct _Unwind_Context __unwind_context;
-#else
-typedef _Unwind_Context __unwind_context;
-#endif
-
-static _Unwind_Reason_Code trace_function(__unwind_context* context, void* arg) {
-    stack_crawl_state_t* state = static_cast<stack_crawl_state_t*>(arg);
-    if (state->count) {
-        intptr_t ip = (intptr_t)_Unwind_GetIP(context);
-        if (ip) {
-            state->addrs[0] = ip;
-            state->addrs++;
-            state->count--;
-            return _URC_NO_REASON;
-        }
-    }
-    /*
-     * If we run out of space to record the address or 0 has been seen, stop
-     * unwinding the stack.
-     */
-    return _URC_END_OF_STACK;
-}
-
-__LIBC_HIDDEN__ int get_backtrace(intptr_t* addrs, size_t max_entries) {
-    stack_crawl_state_t state;
-    state.count = max_entries;
-    state.addrs = addrs;
-    _Unwind_Backtrace(trace_function, &state);
-    return max_entries - state.count;
-}
diff --git a/libc/string/memchr.c b/libc/bionic/memchr.c
similarity index 100%
rename from libc/string/memchr.c
rename to libc/bionic/memchr.c
diff --git a/libc/string/memcmp.c b/libc/bionic/memcmp.c
similarity index 100%
rename from libc/string/memcmp.c
rename to libc/bionic/memcmp.c
diff --git a/libc/string/memcpy.c b/libc/bionic/memcpy.c
similarity index 100%
rename from libc/string/memcpy.c
rename to libc/bionic/memcpy.c
diff --git a/libc/string/memmem.c b/libc/bionic/memmem.c
similarity index 100%
rename from libc/string/memmem.c
rename to libc/bionic/memmem.c
diff --git a/libc/string/memmove.c b/libc/bionic/memmove.c
similarity index 100%
rename from libc/string/memmove.c
rename to libc/bionic/memmove.c
diff --git a/libc/bionic/memmove_words.c b/libc/bionic/memmove_words.c
deleted file mode 100644
index 26df7fa..0000000
--- a/libc/bionic/memmove_words.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <assert.h>
-
-/*
- * Works like memmove(), except:
- * - if all arguments are at least 32-bit aligned, we guarantee that we
- *   will use operations that preserve atomicity of 32-bit values
- * - if not, we guarantee atomicity of 16-bit values
- *
- * If all three arguments are not at least 16-bit aligned, the behavior
- * of this function is undefined.  (We could remove this restriction by
- * testing for unaligned values and punting to memmove(), but that's
- * not currently useful.)
- *
- * TODO: add loop for 64-bit alignment
- * TODO: use __builtin_prefetch
- * TODO: write an ARM-optimized version
- */
-void _memmove_words(void* dest, const void* src, size_t n)
-{
-    assert((((uintptr_t) dest | (uintptr_t) src | n) & 0x01) == 0);
-
-    char* d = (char*) dest;
-    const char* s = (const char*) src;
-    size_t copyCount;
-
-    /*
-     * If the source and destination pointers are the same, this is
-     * an expensive no-op.  Testing for an empty move now allows us
-     * to skip a check later.
-     */
-    if (n == 0 || d == s)
-        return;
-
-    /*
-     * Determine if the source and destination buffers will overlap if
-     * we copy data forward (i.e. *dest++ = *src++).
-     *
-     * It's okay if the destination buffer starts before the source and
-     * there is some overlap, because the reader is always ahead of the
-     * writer.
-     */
-    if (__builtin_expect((d < s) || ((size_t)(d - s) >= n), 1)) {
-        /*
-         * Copy forward.  We prefer 32-bit loads and stores even for 16-bit
-         * data, so sort that out.
-         */
-        if ((((uintptr_t) d | (uintptr_t) s) & 0x03) != 0) {
-            /*
-             * Not 32-bit aligned.  Two possibilities:
-             * (1) Congruent, we can align to 32-bit by copying one 16-bit val
-             * (2) Non-congruent, we can do one of:
-             *   a. copy whole buffer as a series of 16-bit values
-             *   b. load/store 32 bits, using shifts to ensure alignment
-             *   c. just copy the as 32-bit values and assume the CPU
-             *      will do a reasonable job
-             *
-             * We're currently using (a), which is suboptimal.
-             */
-            if ((((uintptr_t) d ^ (uintptr_t) s) & 0x03) != 0) {
-                copyCount = n;
-            } else {
-                copyCount = 2;
-            }
-            n -= copyCount;
-            copyCount /= sizeof(uint16_t);
-
-            while (copyCount--) {
-                *(uint16_t*)d = *(uint16_t*)s;
-                d += sizeof(uint16_t);
-                s += sizeof(uint16_t);
-            }
-        }
-
-        /*
-         * Copy 32-bit aligned words.
-         */
-        copyCount = n / sizeof(uint32_t);
-        while (copyCount--) {
-            *(uint32_t*)d = *(uint32_t*)s;
-            d += sizeof(uint32_t);
-            s += sizeof(uint32_t);
-        }
-
-        /*
-         * Check for leftovers.  Either we finished exactly, or we have
-         * one remaining 16-bit chunk.
-         */
-        if ((n & 0x02) != 0) {
-            *(uint16_t*)d = *(uint16_t*)s;
-        }
-    } else {
-        /*
-         * Copy backward, starting at the end.
-         */
-        d += n;
-        s += n;
-
-        if ((((uintptr_t) d | (uintptr_t) s) & 0x03) != 0) {
-            /* try for 32-bit alignment */
-            if ((((uintptr_t) d ^ (uintptr_t) s) & 0x03) != 0) {
-                copyCount = n;
-            } else {
-                copyCount = 2;
-            }
-            n -= copyCount;
-            copyCount /= sizeof(uint16_t);
-
-            while (copyCount--) {
-                d -= sizeof(uint16_t);
-                s -= sizeof(uint16_t);
-                *(uint16_t*)d = *(uint16_t*)s;
-            }
-        }
-
-        /* copy 32-bit aligned words */
-        copyCount = n / sizeof(uint32_t);
-        while (copyCount--) {
-            d -= sizeof(uint32_t);
-            s -= sizeof(uint32_t);
-            *(uint32_t*)d = *(uint32_t*)s;
-        }
-
-        /* copy leftovers */
-        if ((n & 0x02) != 0) {
-            d -= sizeof(uint16_t);
-            s -= sizeof(uint16_t);
-            *(uint16_t*)d = *(uint16_t*)s;
-        }
-    }
-}
diff --git a/libc/string/memrchr.c b/libc/bionic/memrchr.c
similarity index 100%
rename from libc/string/memrchr.c
rename to libc/bionic/memrchr.c
diff --git a/libc/string/memset.c b/libc/bionic/memset.c
similarity index 100%
rename from libc/string/memset.c
rename to libc/bionic/memset.c
diff --git a/libc/string/memswap.c b/libc/bionic/memswap.c
similarity index 100%
rename from libc/string/memswap.c
rename to libc/bionic/memswap.c
diff --git a/libc/bionic/mmap.c b/libc/bionic/mmap.c
new file mode 100644
index 0000000..40a6538
--- /dev/null
+++ b/libc/bionic/mmap.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include <unistd.h>
+#include <errno.h>
+#include <sys/mman.h>
+
+extern void*  __mmap2(void*, size_t, int, int, int, size_t);
+
+#define  MMAP2_SHIFT  12
+void* mmap(void *addr, size_t size, int prot, int flags, int fd, long offset)
+{
+    if (offset & ((1UL << MMAP2_SHIFT)-1)) {
+        errno = EINVAL;
+        return MAP_FAILED;
+    }
+
+    return __mmap2(addr, size, prot, flags, fd, (size_t)offset >> MMAP2_SHIFT);
+}
diff --git a/libc/bionic/open.c b/libc/bionic/open.c
new file mode 100644
index 0000000..be4f04b
--- /dev/null
+++ b/libc/bionic/open.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <private/logd.h>
+
+extern int  __open(const char*, int, int);
+
+int open(const char *pathname, int flags, ...)
+{
+    mode_t  mode = 0;
+
+    flags |= O_LARGEFILE;
+
+    if (flags & O_CREAT)
+    {
+        va_list  args;
+
+        va_start(args, flags);
+        mode = (mode_t) va_arg(args, int);
+        va_end(args);
+    }
+
+    return __open(pathname, flags, mode);
+}
+
+int __open_2(const char *pathname, int flags) {
+    if (flags & O_CREAT) {
+        __fortify_chk_fail("open(O_CREAT) called without specifying a mode", 0);
+    }
+
+    flags |= O_LARGEFILE;
+
+    return __open(pathname, flags, 0);
+}
+
diff --git a/libc/bionic/openat.c b/libc/bionic/openat.c
new file mode 100644
index 0000000..c1abbaa
--- /dev/null
+++ b/libc/bionic/openat.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <private/logd.h>
+
+extern int  __openat(int, const char*, int, int);
+
+int openat(int fd, const char *pathname, int flags, ...)
+{
+    mode_t  mode = 0;
+
+    flags |= O_LARGEFILE;
+
+    if (flags & O_CREAT)
+    {
+        va_list  args;
+
+        va_start(args, flags);
+        mode = (mode_t) va_arg(args, int);
+        va_end(args);
+    }
+
+    return __openat(fd, pathname, flags, mode);
+}
+
+int __openat_2(int fd, const char *pathname, int flags)
+{
+    if (flags & O_CREAT) {
+        __fortify_chk_fail("openat(O_CREAT) called without specifying a mode", 0);
+    }
+
+    flags |= O_LARGEFILE;
+
+    return __openat(fd, pathname, flags, 0);
+}
+
diff --git a/libc/unistd/pathconf.c b/libc/bionic/pathconf.c
similarity index 100%
rename from libc/unistd/pathconf.c
rename to libc/bionic/pathconf.c
diff --git a/libc/unistd/perror.c b/libc/bionic/perror.c
similarity index 100%
rename from libc/unistd/perror.c
rename to libc/bionic/perror.c
diff --git a/libc/unistd/pread.c b/libc/bionic/pread.c
similarity index 100%
rename from libc/unistd/pread.c
rename to libc/bionic/pread.c
diff --git a/libc/unistd/pselect.c b/libc/bionic/pselect.c
similarity index 100%
rename from libc/unistd/pselect.c
rename to libc/bionic/pselect.c
diff --git a/libc/bionic/pthread-rwlocks.c b/libc/bionic/pthread-rwlocks.c
index ca3e95c..deee577 100644
--- a/libc/bionic/pthread-rwlocks.c
+++ b/libc/bionic/pthread-rwlocks.c
@@ -42,7 +42,7 @@
  *  - trying to get the read-lock while there is a writer blocks
  *  - a single thread can acquire the lock multiple times in the same mode
  *
- *  - Posix states that behaviour is undefined it a thread tries to acquire
+ *  - Posix states that behavior is undefined it a thread tries to acquire
  *    the lock in two distinct modes (e.g. write after read, or read after write).
  *
  *  - This implementation tries to avoid writer starvation by making the readers
@@ -61,12 +61,6 @@
 
 extern pthread_internal_t* __get_thread(void);
 
-/* Return a global kernel ID for the current thread */
-static int __get_thread_id(void)
-{
-    return __get_thread()->kernel_id;
-}
-
 int pthread_rwlockattr_init(pthread_rwlockattr_t *attr)
 {
     if (!attr)
@@ -150,8 +144,6 @@
 
 int pthread_rwlock_destroy(pthread_rwlock_t *rwlock)
 {
-    int  ret;
-
     if (rwlock == NULL)
         return EINVAL;
 
@@ -164,7 +156,7 @@
 }
 
 /* Returns TRUE iff we can acquire a read lock. */
-static __inline__ int read_precondition(pthread_rwlock_t *rwlock, int  thread_id)
+static __inline__ int read_precondition(pthread_rwlock_t* rwlock, int tid)
 {
     /* We can't have the lock if any writer is waiting for it (writer bias).
      * This tries to avoid starvation when there are multiple readers racing.
@@ -174,7 +166,7 @@
 
     /* We can have the lock if there is no writer, or if we write-own it */
     /* The second test avoids a self-dead lock in case of buggy code. */
-    if (rwlock->writerThreadId == 0 || rwlock->writerThreadId == thread_id)
+    if (rwlock->writerThreadId == 0 || rwlock->writerThreadId == tid)
         return 1;
 
     /* Otherwise, we can't have it */
@@ -182,14 +174,14 @@
 }
 
 /* returns TRUE iff we can acquire a write lock. */
-static __inline__ int write_precondition(pthread_rwlock_t *rwlock, int  thread_id)
+static __inline__ int write_precondition(pthread_rwlock_t* rwlock, int tid)
 {
     /* We can get the lock if nobody has it */
     if (rwlock->numLocks == 0)
         return 1;
 
     /* Or if we already own it */
-    if (rwlock->writerThreadId == thread_id)
+    if (rwlock->writerThreadId == tid)
         return 1;
 
     /* Otherwise, not */
@@ -220,7 +212,7 @@
         return EINVAL;
 
     pthread_mutex_lock(&rwlock->lock);
-    if (__unlikely(!read_precondition(rwlock, __get_thread_id())))
+    if (__unlikely(!read_precondition(rwlock, __get_thread()->tid)))
         ret = EBUSY;
     else
         rwlock->numLocks ++;
@@ -231,18 +223,18 @@
 
 int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, const struct timespec *abs_timeout)
 {
-    int thread_id, ret = 0;
+    int ret = 0;
 
     if (rwlock == NULL)
         return EINVAL;
 
     pthread_mutex_lock(&rwlock->lock);
-    thread_id = __get_thread_id();
-    if (__unlikely(!read_precondition(rwlock, thread_id))) {
+    int tid = __get_thread()->tid;
+    if (__unlikely(!read_precondition(rwlock, tid))) {
         rwlock->pendingReaders += 1;
         do {
             ret = pthread_cond_timedwait(&rwlock->cond, &rwlock->lock, abs_timeout);
-        } while (ret == 0 && !read_precondition(rwlock, thread_id));
+        } while (ret == 0 && !read_precondition(rwlock, tid));
         rwlock->pendingReaders -= 1;
         if (ret != 0)
             goto EXIT;
@@ -261,18 +253,18 @@
 
 int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock)
 {
-    int thread_id, ret = 0;
+    int ret = 0;
 
     if (rwlock == NULL)
         return EINVAL;
 
     pthread_mutex_lock(&rwlock->lock);
-    thread_id = __get_thread_id();
-    if (__unlikely(!write_precondition(rwlock, thread_id))) {
+    int tid = __get_thread()->tid;
+    if (__unlikely(!write_precondition(rwlock, tid))) {
         ret = EBUSY;
     } else {
         rwlock->numLocks ++;
-        rwlock->writerThreadId = thread_id;
+        rwlock->writerThreadId = tid;
     }
     pthread_mutex_unlock(&rwlock->lock);
     return ret;
@@ -280,14 +272,14 @@
 
 int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *abs_timeout)
 {
-    int thread_id, ret = 0;
+    int ret = 0;
 
     if (rwlock == NULL)
         return EINVAL;
 
     pthread_mutex_lock(&rwlock->lock);
-    thread_id = __get_thread_id();
-    if (__unlikely(!write_precondition(rwlock, thread_id))) {
+    int tid = __get_thread()->tid;
+    if (__unlikely(!write_precondition(rwlock, tid))) {
         /* If we can't read yet, wait until the rwlock is unlocked
          * and try again. Increment pendingReaders to get the
          * cond broadcast when that happens.
@@ -295,13 +287,13 @@
         rwlock->pendingWriters += 1;
         do {
             ret = pthread_cond_timedwait(&rwlock->cond, &rwlock->lock, abs_timeout);
-        } while (ret == 0 && !write_precondition(rwlock, thread_id));
+        } while (ret == 0 && !write_precondition(rwlock, tid));
         rwlock->pendingWriters -= 1;
         if (ret != 0)
             goto EXIT;
     }
     rwlock->numLocks ++;
-    rwlock->writerThreadId = thread_id;
+    rwlock->writerThreadId = tid;
 EXIT:
     pthread_mutex_unlock(&rwlock->lock);
     return ret;
@@ -332,7 +324,7 @@
      * must be ourselves.
      */
     else {
-        if (rwlock->writerThreadId != __get_thread_id()) {
+        if (rwlock->writerThreadId != __get_thread()->tid) {
             ret = EPERM;
             goto EXIT;
         }
diff --git a/libc/bionic/pthread.c b/libc/bionic/pthread.c
index da3a551..e30fa9d 100644
--- a/libc/bionic/pthread.c
+++ b/libc/bionic/pthread.c
@@ -26,23 +26,11 @@
  * SUCH DAMAGE.
  */
 
-#include <assert.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <malloc.h>
-#include <memory.h>
 #include <pthread.h>
-#include <signal.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
+
+#include <errno.h>
+#include <limits.h>
 #include <sys/atomics.h>
-#include <sys/mman.h>
-#include <sys/prctl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <time.h>
 #include <unistd.h>
 
 #include "bionic_atomic_inline.h"
@@ -55,10 +43,8 @@
 extern void pthread_debug_mutex_lock_check(pthread_mutex_t *mutex);
 extern void pthread_debug_mutex_unlock_check(pthread_mutex_t *mutex);
 
-extern int  __pthread_clone(int (*fn)(void*), void *child_stack, int flags, void *arg);
 extern void _exit_with_stack_teardown(void * stackBase, int stackSize, int retCode);
 extern void _exit_thread(int  retCode);
-extern int  __set_errno(int);
 
 int  __futex_wake_ex(volatile void *ftx, int pshared, int val)
 {
@@ -73,86 +59,6 @@
 #define  __likely(cond)    __builtin_expect(!!(cond), 1)
 #define  __unlikely(cond)  __builtin_expect(!!(cond), 0)
 
-#ifdef __i386__
-#define ATTRIBUTES __attribute__((noinline)) __attribute__((fastcall))
-#else
-#define ATTRIBUTES __attribute__((noinline))
-#endif
-
-void ATTRIBUTES _thread_created_hook(pid_t thread_id);
-
-static const int kPthreadInitFailed = 1;
-
-#define PTHREAD_ATTR_FLAG_DETACHED      0x00000001
-#define PTHREAD_ATTR_FLAG_USER_STACK    0x00000002
-
-#define DEFAULT_STACKSIZE (1024 * 1024)
-
-static pthread_mutex_t mmap_lock = PTHREAD_MUTEX_INITIALIZER;
-
-
-static const pthread_attr_t gDefaultPthreadAttr = {
-    .flags = 0,
-    .stack_base = NULL,
-    .stack_size = DEFAULT_STACKSIZE,
-    .guard_size = PAGE_SIZE,
-    .sched_policy = SCHED_NORMAL,
-    .sched_priority = 0
-};
-
-static pthread_internal_t* gThreadList = NULL;
-static pthread_mutex_t gThreadListLock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t gDebuggerNotificationLock = PTHREAD_MUTEX_INITIALIZER;
-
-
-static void
-_pthread_internal_free(pthread_internal_t* thread)
-{
-    if (thread != NULL) {
-        free(thread);
-    }
-}
-
-
-static void
-_pthread_internal_remove_locked( pthread_internal_t*  thread )
-{
-    thread->next->prev = thread->prev;
-    thread->prev[0]    = thread->next;
-}
-
-static void
-_pthread_internal_remove( pthread_internal_t*  thread )
-{
-    pthread_mutex_lock(&gThreadListLock);
-    _pthread_internal_remove_locked(thread);
-    pthread_mutex_unlock(&gThreadListLock);
-}
-
-__LIBC_ABI_PRIVATE__ void
-_pthread_internal_add(pthread_internal_t* thread)
-{
-    pthread_mutex_lock(&gThreadListLock);
-
-    thread->prev = &gThreadList;
-    thread->next = *(thread->prev);
-    if (thread->next != NULL) {
-        thread->next->prev = &thread->next;
-    }
-    *(thread->prev) = thread;
-
-    pthread_mutex_unlock(&gThreadListLock);
-}
-
-__LIBC_ABI_PRIVATE__ pthread_internal_t*
-__get_thread(void)
-{
-    void**  tls = (void**)__get_tls();
-
-    return  (pthread_internal_t*) tls[TLS_SLOT_THREAD_ID];
-}
-
-
 void*
 __get_stack_base(int  *p_stack_size)
 {
@@ -163,375 +69,6 @@
 }
 
 
-void  __init_tls(void**  tls, void*  thread)
-{
-    int  nn;
-
-    ((pthread_internal_t*)thread)->tls = tls;
-
-    // slot 0 must point to the tls area, this is required by the implementation
-    // of the x86 Linux kernel thread-local-storage
-    tls[TLS_SLOT_SELF]      = (void*)tls;
-    tls[TLS_SLOT_THREAD_ID] = thread;
-    for (nn = TLS_SLOT_ERRNO; nn < BIONIC_TLS_SLOTS; nn++)
-       tls[nn] = 0;
-
-    __set_tls( (void*)tls );
-}
-
-
-/*
- * This trampoline is called from the assembly _pthread_clone() function.
- */
-void __thread_entry(int (*func)(void*), void *arg, void **tls)
-{
-    // Wait for our creating thread to release us. This lets it have time to
-    // notify gdb about this thread before we start doing anything.
-    //
-    // This also provides the memory barrier needed to ensure that all memory
-    // accesses previously made by the creating thread are visible to us.
-    pthread_mutex_t* start_mutex = (pthread_mutex_t*) &tls[TLS_SLOT_SELF];
-    pthread_mutex_lock(start_mutex);
-    pthread_mutex_destroy(start_mutex);
-
-    pthread_internal_t* thread = (pthread_internal_t*) tls[TLS_SLOT_THREAD_ID];
-    __init_tls(tls, thread);
-
-    if ((thread->internal_flags & kPthreadInitFailed) != 0) {
-        pthread_exit(NULL);
-    }
-
-    int result = func(arg);
-    pthread_exit((void*) result);
-}
-
-#include <private/logd.h>
-
-__LIBC_ABI_PRIVATE__
-int _init_thread(pthread_internal_t* thread, pid_t kernel_id, pthread_attr_t* attr,
-                 void* stack_base, bool add_to_thread_list)
-{
-    int error = 0;
-
-    if (attr == NULL) {
-        thread->attr = gDefaultPthreadAttr;
-    } else {
-        thread->attr = *attr;
-    }
-    thread->attr.stack_base = stack_base;
-    thread->kernel_id       = kernel_id;
-
-    // Make a note of whether the user supplied this stack (so we know whether or not to free it).
-    if (attr->stack_base == stack_base) {
-        thread->attr.flags |= PTHREAD_ATTR_FLAG_USER_STACK;
-    }
-
-    // Set the scheduling policy/priority of the thread.
-    if (thread->attr.sched_policy != SCHED_NORMAL) {
-        struct sched_param param;
-        param.sched_priority = thread->attr.sched_priority;
-        if (sched_setscheduler(kernel_id, thread->attr.sched_policy, &param) == -1) {
-            // For back compat reasons, we just warn about possible invalid sched_policy
-            const char* msg = "pthread_create sched_setscheduler call failed: %s\n";
-            __libc_android_log_print(ANDROID_LOG_WARN, "libc", msg, strerror(errno));
-        }
-    }
-
-    pthread_cond_init(&thread->join_cond, NULL);
-    thread->join_count = 0;
-    thread->cleanup_stack = NULL;
-
-    if (add_to_thread_list) {
-        _pthread_internal_add(thread);
-    }
-
-    return error;
-}
-
-static void *mkstack(size_t size, size_t guard_size)
-{
-    pthread_mutex_lock(&mmap_lock);
-
-    int prot = PROT_READ | PROT_WRITE;
-    int flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE;
-    void* stack = mmap(NULL, size, prot, flags, -1, 0);
-    if (stack == MAP_FAILED) {
-        stack = NULL;
-        goto done;
-    }
-
-    if (mprotect(stack, guard_size, PROT_NONE) == -1) {
-        munmap(stack, size);
-        stack = NULL;
-        goto done;
-    }
-
-done:
-    pthread_mutex_unlock(&mmap_lock);
-    return stack;
-}
-
-/*
- * Create a new thread. The thread's stack is laid out like so:
- *
- * +---------------------------+
- * |     pthread_internal_t    |
- * +---------------------------+
- * |                           |
- * |          TLS area         |
- * |                           |
- * +---------------------------+
- * |                           |
- * .                           .
- * .         stack area        .
- * .                           .
- * |                           |
- * +---------------------------+
- * |         guard page        |
- * +---------------------------+
- *
- *  note that TLS[0] must be a pointer to itself, this is required
- *  by the thread-local storage implementation of the x86 Linux
- *  kernel, where the TLS pointer is read by reading fs:[0]
- */
-int pthread_create(pthread_t *thread_out, pthread_attr_t const * attr,
-                   void *(*start_routine)(void *), void * arg)
-{
-    int old_errno = errno;
-
-    /* this will inform the rest of the C library that at least one thread
-     * was created. this will enforce certain functions to acquire/release
-     * locks (e.g. atexit()) to protect shared global structures.
-     *
-     * this works because pthread_create() is not called by the C library
-     * initialization routine that sets up the main thread's data structures.
-     */
-    __isthreaded = 1;
-
-    pthread_internal_t* thread = calloc(sizeof(*thread), 1);
-    if (thread == NULL) {
-        return ENOMEM;
-    }
-
-    if (attr == NULL) {
-        attr = &gDefaultPthreadAttr;
-    }
-
-    // make sure the stack is PAGE_SIZE aligned
-    size_t stack_size = (attr->stack_size + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1);
-    uint8_t* stack = attr->stack_base;
-    if (stack == NULL) {
-        stack = mkstack(stack_size, attr->guard_size);
-        if (stack == NULL) {
-            _pthread_internal_free(thread);
-            return ENOMEM;
-        }
-    }
-
-    // Make room for TLS
-    void** tls = (void**)(stack + stack_size - BIONIC_TLS_SLOTS*sizeof(void*));
-
-    // Create a mutex for the thread in TLS_SLOT_SELF to wait on once it starts so we can keep
-    // it from doing anything until after we notify the debugger about it
-    //
-    // This also provides the memory barrier we need to ensure that all
-    // memory accesses previously performed by this thread are visible to
-    // the new thread.
-    pthread_mutex_t* start_mutex = (pthread_mutex_t*) &tls[TLS_SLOT_SELF];
-    pthread_mutex_init(start_mutex, NULL);
-    pthread_mutex_lock(start_mutex);
-
-    tls[TLS_SLOT_THREAD_ID] = thread;
-
-    int flags = CLONE_FILES | CLONE_FS | CLONE_VM | CLONE_SIGHAND |
-                CLONE_THREAD | CLONE_SYSVSEM | CLONE_DETACHED;
-    int tid = __pthread_clone((int(*)(void*))start_routine, tls, flags, arg);
-
-    if (tid < 0) {
-        int clone_errno = errno;
-        pthread_mutex_unlock(start_mutex);
-        if (stack != attr->stack_base) {
-            munmap(stack, stack_size);
-        }
-        _pthread_internal_free(thread);
-        errno = old_errno;
-        return clone_errno;
-    }
-
-    int init_errno = _init_thread(thread, tid, (pthread_attr_t*) attr, stack, true);
-    if (init_errno != 0) {
-        // Mark the thread detached and let its __thread_entry run to
-        // completion. (It'll just exit immediately, cleaning up its resources.)
-        thread->internal_flags |= kPthreadInitFailed;
-        thread->attr.flags |= PTHREAD_ATTR_FLAG_DETACHED;
-        pthread_mutex_unlock(start_mutex);
-        errno = old_errno;
-        return init_errno;
-    }
-
-    // Notify any debuggers about the new thread.
-    pthread_mutex_lock(&gDebuggerNotificationLock);
-    _thread_created_hook(tid);
-    pthread_mutex_unlock(&gDebuggerNotificationLock);
-
-    // Publish the pthread_t and let the thread run.
-    *thread_out = (pthread_t) thread;
-    pthread_mutex_unlock(start_mutex);
-
-    return 0;
-}
-
-
-int pthread_attr_init(pthread_attr_t * attr)
-{
-    *attr = gDefaultPthreadAttr;
-    return 0;
-}
-
-int pthread_attr_destroy(pthread_attr_t * attr)
-{
-    memset(attr, 0x42, sizeof(pthread_attr_t));
-    return 0;
-}
-
-int pthread_attr_setdetachstate(pthread_attr_t * attr, int state)
-{
-    if (state == PTHREAD_CREATE_DETACHED) {
-        attr->flags |= PTHREAD_ATTR_FLAG_DETACHED;
-    } else if (state == PTHREAD_CREATE_JOINABLE) {
-        attr->flags &= ~PTHREAD_ATTR_FLAG_DETACHED;
-    } else {
-        return EINVAL;
-    }
-    return 0;
-}
-
-int pthread_attr_getdetachstate(pthread_attr_t const * attr, int * state)
-{
-    *state = (attr->flags & PTHREAD_ATTR_FLAG_DETACHED)
-           ? PTHREAD_CREATE_DETACHED
-           : PTHREAD_CREATE_JOINABLE;
-    return 0;
-}
-
-int pthread_attr_setschedpolicy(pthread_attr_t * attr, int policy)
-{
-    attr->sched_policy = policy;
-    return 0;
-}
-
-int pthread_attr_getschedpolicy(pthread_attr_t const * attr, int * policy)
-{
-    *policy = attr->sched_policy;
-    return 0;
-}
-
-int pthread_attr_setschedparam(pthread_attr_t * attr, struct sched_param const * param)
-{
-    attr->sched_priority = param->sched_priority;
-    return 0;
-}
-
-int pthread_attr_getschedparam(pthread_attr_t const * attr, struct sched_param * param)
-{
-    param->sched_priority = attr->sched_priority;
-    return 0;
-}
-
-int pthread_attr_setstacksize(pthread_attr_t * attr, size_t stack_size)
-{
-    if ((stack_size & (PAGE_SIZE - 1) || stack_size < PTHREAD_STACK_MIN)) {
-        return EINVAL;
-    }
-    attr->stack_size = stack_size;
-    return 0;
-}
-
-int pthread_attr_getstacksize(pthread_attr_t const * attr, size_t * stack_size)
-{
-    *stack_size = attr->stack_size;
-    return 0;
-}
-
-int pthread_attr_setstackaddr(pthread_attr_t * attr, void * stack_addr)
-{
-#if 1
-    // It's not clear if this is setting the top or bottom of the stack, so don't handle it for now.
-    return ENOSYS;
-#else
-    if ((uint32_t)stack_addr & (PAGE_SIZE - 1)) {
-        return EINVAL;
-    }
-    attr->stack_base = stack_addr;
-    return 0;
-#endif
-}
-
-int pthread_attr_getstackaddr(pthread_attr_t const * attr, void ** stack_addr)
-{
-    *stack_addr = (char*)attr->stack_base + attr->stack_size;
-    return 0;
-}
-
-int pthread_attr_setstack(pthread_attr_t * attr, void * stack_base, size_t stack_size)
-{
-    if ((stack_size & (PAGE_SIZE - 1) || stack_size < PTHREAD_STACK_MIN)) {
-        return EINVAL;
-    }
-    if ((uint32_t)stack_base & (PAGE_SIZE - 1)) {
-        return EINVAL;
-    }
-    attr->stack_base = stack_base;
-    attr->stack_size = stack_size;
-    return 0;
-}
-
-int pthread_attr_getstack(pthread_attr_t const * attr, void ** stack_base, size_t * stack_size)
-{
-    *stack_base = attr->stack_base;
-    *stack_size = attr->stack_size;
-    return 0;
-}
-
-int pthread_attr_setguardsize(pthread_attr_t * attr, size_t guard_size)
-{
-    if (guard_size & (PAGE_SIZE - 1) || guard_size < PAGE_SIZE) {
-        return EINVAL;
-    }
-
-    attr->guard_size = guard_size;
-    return 0;
-}
-
-int pthread_attr_getguardsize(pthread_attr_t const * attr, size_t * guard_size)
-{
-    *guard_size = attr->guard_size;
-    return 0;
-}
-
-int pthread_getattr_np(pthread_t thid, pthread_attr_t * attr)
-{
-    pthread_internal_t * thread = (pthread_internal_t *)thid;
-    *attr = thread->attr;
-    return 0;
-}
-
-int pthread_attr_setscope(pthread_attr_t *attr, int  scope)
-{
-    if (scope == PTHREAD_SCOPE_SYSTEM)
-        return 0;
-    if (scope == PTHREAD_SCOPE_PROCESS)
-        return ENOTSUP;
-
-    return EINVAL;
-}
-
-int pthread_attr_getscope(pthread_attr_t const *attr)
-{
-    return PTHREAD_SCOPE_SYSTEM;
-}
-
-
 /* CAVEAT: our implementation of pthread_cleanup_push/pop doesn't support C++ exceptions
  *         and thread cancelation
  */
@@ -557,9 +94,6 @@
         c->__cleanup_routine(c->__cleanup_arg);
 }
 
-/* used by pthread_exit() to clean all TLS keys of the current thread */
-static void pthread_key_clean_all(void);
-
 void pthread_exit(void * retval)
 {
     pthread_internal_t*  thread     = __get_thread();
@@ -582,13 +116,11 @@
     pthread_key_clean_all();
 
     // if the thread is detached, destroy the pthread_internal_t
-    // otherwise, keep it in memory and signal any joiners
+    // otherwise, keep it in memory and signal any joiners.
+    pthread_mutex_lock(&gThreadListLock);
     if (thread->attr.flags & PTHREAD_ATTR_FLAG_DETACHED) {
-        _pthread_internal_remove(thread);
-        _pthread_internal_free(thread);
+        _pthread_internal_remove_locked(thread);
     } else {
-        pthread_mutex_lock(&gThreadListLock);
-
        /* make sure that the thread struct doesn't have stale pointers to a stack that
         * will be unmapped after the exit call below.
         */
@@ -616,8 +148,8 @@
         } else {
             thread->join_count = -1;  /* zombie thread */
         }
-        pthread_mutex_unlock(&gThreadListLock);
     }
+    pthread_mutex_unlock(&gThreadListLock);
 
     sigfillset(&mask);
     sigdelset(&mask, SIGSEGV);
@@ -630,131 +162,10 @@
         _exit_with_stack_teardown(stack_base, stack_size, (int)retval);
 }
 
-int pthread_join(pthread_t thid, void ** ret_val)
-{
-    pthread_internal_t*  thread = (pthread_internal_t*)thid;
-    int                  count;
-
-    // check that the thread still exists and is not detached
-    pthread_mutex_lock(&gThreadListLock);
-
-    for (thread = gThreadList; thread != NULL; thread = thread->next)
-        if (thread == (pthread_internal_t*)thid)
-            goto FoundIt;
-
-    pthread_mutex_unlock(&gThreadListLock);
-    return ESRCH;
-
-FoundIt:
-    if (thread->attr.flags & PTHREAD_ATTR_FLAG_DETACHED) {
-        pthread_mutex_unlock(&gThreadListLock);
-        return EINVAL;
-    }
-
-   /* wait for thread death when needed
-    *
-    * if the 'join_count' is negative, this is a 'zombie' thread that
-    * is already dead and without stack/TLS
-    *
-    * otherwise, we need to increment 'join-count' and wait to be signaled
-    */
-   count = thread->join_count;
-    if (count >= 0) {
-        thread->join_count += 1;
-        pthread_cond_wait( &thread->join_cond, &gThreadListLock );
-        count = --thread->join_count;
-    }
-    if (ret_val)
-        *ret_val = thread->return_value;
-
-    /* remove thread descriptor when we're the last joiner or when the
-     * thread was already a zombie.
-     */
-    if (count <= 0) {
-        _pthread_internal_remove_locked(thread);
-        _pthread_internal_free(thread);
-    }
-    pthread_mutex_unlock(&gThreadListLock);
-    return 0;
-}
-
-int  pthread_detach( pthread_t  thid )
-{
-    pthread_internal_t*  thread;
-    int                  result = 0;
-    int                  flags;
-
-    pthread_mutex_lock(&gThreadListLock);
-    for (thread = gThreadList; thread != NULL; thread = thread->next)
-        if (thread == (pthread_internal_t*)thid)
-            goto FoundIt;
-
-    result = ESRCH;
-    goto Exit;
-
-FoundIt:
-    do {
-        flags = thread->attr.flags;
-
-        if ( flags & PTHREAD_ATTR_FLAG_DETACHED ) {
-            /* thread is not joinable ! */
-            result = EINVAL;
-            goto Exit;
-        }
-    }
-    while ( __bionic_cmpxchg( flags, flags | PTHREAD_ATTR_FLAG_DETACHED,
-                              (volatile int*)&thread->attr.flags ) != 0 );
-Exit:
-    pthread_mutex_unlock(&gThreadListLock);
-    return result;
-}
-
-pthread_t pthread_self(void)
-{
-    return (pthread_t)__get_thread();
-}
-
-int pthread_equal(pthread_t one, pthread_t two)
-{
-    return (one == two ? 1 : 0);
-}
-
-int pthread_getschedparam(pthread_t thid, int * policy,
-                          struct sched_param * param)
-{
-    int  old_errno = errno;
-
-    pthread_internal_t * thread = (pthread_internal_t *)thid;
-    int err = sched_getparam(thread->kernel_id, param);
-    if (!err) {
-        *policy = sched_getscheduler(thread->kernel_id);
-    } else {
-        err = errno;
-        errno = old_errno;
-    }
-    return err;
-}
-
-int pthread_setschedparam(pthread_t thid, int policy,
-                          struct sched_param const * param)
-{
-    pthread_internal_t * thread = (pthread_internal_t *)thid;
-    int                  old_errno = errno;
-    int                  ret;
-
-    ret = sched_setscheduler(thread->kernel_id, policy, param);
-    if (ret < 0) {
-        ret = errno;
-        errno = old_errno;
-    }
-    return ret;
-}
-
-
 /* a mutex is implemented as a 32-bit integer holding the following fields
  *
  * bits:     name     description
- * 31-16     tid      owner thread's kernel id (recursive and errorcheck only)
+ * 31-16     tid      owner thread's tid (recursive and errorcheck only)
  * 15-14     type     mutex type
  * 13        shared   process-shared flag
  * 12-2      counter  counter of recursive mutexes
@@ -864,8 +275,8 @@
 /* Mutex owner field:
  *
  * This is only used for recursive and errorcheck mutexes. It holds the
- * kernel TID of the owning thread. Note that this works because the Linux
- * kernel _only_ uses 16-bit values for thread ids.
+ * tid of the owning thread. Note that this works because the Linux
+ * kernel _only_ uses 16-bit values for tids.
  *
  * More specifically, it will wrap to 10000 when it reaches over 32768 for
  * application processes. You can check this by running the following inside
@@ -1179,7 +590,7 @@
 __LIBC_HIDDEN__
 int pthread_mutex_lock_impl(pthread_mutex_t *mutex)
 {
-    int mvalue, mtype, tid, new_lock_type, shared;
+    int mvalue, mtype, tid, shared;
 
     if (__unlikely(mutex == NULL))
         return EINVAL;
@@ -1195,7 +606,7 @@
     }
 
     /* Do we already own this recursive or error-check mutex ? */
-    tid = __get_thread()->kernel_id;
+    tid = __get_thread()->tid;
     if ( tid == MUTEX_OWNER_FROM_BITS(mvalue) )
         return _recursive_increment(mutex, mvalue, mtype);
 
@@ -1273,7 +684,7 @@
 __LIBC_HIDDEN__
 int pthread_mutex_unlock_impl(pthread_mutex_t *mutex)
 {
-    int mvalue, mtype, tid, oldv, shared;
+    int mvalue, mtype, tid, shared;
 
     if (__unlikely(mutex == NULL))
         return EINVAL;
@@ -1289,7 +700,7 @@
     }
 
     /* Do we already own this recursive or error-check mutex ? */
-    tid = __get_thread()->kernel_id;
+    tid = __get_thread()->tid;
     if ( tid != MUTEX_OWNER_FROM_BITS(mvalue) )
         return EPERM;
 
@@ -1340,7 +751,7 @@
 __LIBC_HIDDEN__
 int pthread_mutex_trylock_impl(pthread_mutex_t *mutex)
 {
-    int mvalue, mtype, tid, oldv, shared;
+    int mvalue, mtype, tid, shared;
 
     if (__unlikely(mutex == NULL))
         return EINVAL;
@@ -1363,7 +774,7 @@
     }
 
     /* Do we already own this recursive or error-check mutex ? */
-    tid = __get_thread()->kernel_id;
+    tid = __get_thread()->tid;
     if ( tid == MUTEX_OWNER_FROM_BITS(mvalue) )
         return _recursive_increment(mutex, mvalue, mtype);
 
@@ -1435,7 +846,7 @@
     clockid_t        clock = CLOCK_MONOTONIC;
     struct timespec  abstime;
     struct timespec  ts;
-    int               mvalue, mtype, tid, oldv, new_lock_type, shared;
+    int               mvalue, mtype, tid, shared;
 
     /* compute absolute expiration time */
     __timespec_to_relative_msec(&abstime, msecs, clock);
@@ -1472,7 +883,7 @@
     }
 
     /* Do we already own this recursive or error-check mutex ? */
-    tid = __get_thread()->kernel_id;
+    tid = __get_thread()->tid;
     if ( tid == MUTEX_OWNER_FROM_BITS(mvalue) )
         return _recursive_increment(mutex, mvalue, mtype);
 
@@ -1782,395 +1193,12 @@
 }
 
 
-
-/* A technical note regarding our thread-local-storage (TLS) implementation:
- *
- * There can be up to TLSMAP_SIZE independent TLS keys in a given process,
- * though the first TLSMAP_START keys are reserved for Bionic to hold
- * special thread-specific variables like errno or a pointer to
- * the current thread's descriptor.
- *
- * while stored in the TLS area, these entries cannot be accessed through
- * pthread_getspecific() / pthread_setspecific() and pthread_key_delete()
- *
- * also, some entries in the key table are pre-allocated (see tlsmap_lock)
- * to greatly simplify and speedup some OpenGL-related operations. though the
- * initialy value will be NULL on all threads.
- *
- * you can use pthread_getspecific()/setspecific() on these, and in theory
- * you could also call pthread_key_delete() as well, though this would
- * probably break some apps.
- *
- * The 'tlsmap_t' type defined below implements a shared global map of
- * currently created/allocated TLS keys and the destructors associated
- * with them. You should use tlsmap_lock/unlock to access it to avoid
- * any race condition.
- *
- * the global TLS map simply contains a bitmap of allocated keys, and
- * an array of destructors.
- *
- * each thread has a TLS area that is a simple array of TLSMAP_SIZE void*
- * pointers. the TLS area of the main thread is stack-allocated in
- * __libc_init_common, while the TLS area of other threads is placed at
- * the top of their stack in pthread_create.
- *
- * when pthread_key_create() is called, it finds the first free key in the
- * bitmap, then set it to 1, saving the destructor altogether
- *
- * when pthread_key_delete() is called. it will erase the key's bitmap bit
- * and its destructor, and will also clear the key data in the TLS area of
- * all created threads. As mandated by Posix, it is the responsability of
- * the caller of pthread_key_delete() to properly reclaim the objects that
- * were pointed to by these data fields (either before or after the call).
- *
- */
-
-/* TLS Map implementation
- */
-
-#define TLSMAP_START      (TLS_SLOT_MAX_WELL_KNOWN+1)
-#define TLSMAP_SIZE       BIONIC_TLS_SLOTS
-#define TLSMAP_BITS       32
-#define TLSMAP_WORDS      ((TLSMAP_SIZE+TLSMAP_BITS-1)/TLSMAP_BITS)
-#define TLSMAP_WORD(m,k)  (m)->map[(k)/TLSMAP_BITS]
-#define TLSMAP_MASK(k)    (1U << ((k)&(TLSMAP_BITS-1)))
-
-/* this macro is used to quickly check that a key belongs to a reasonable range */
-#define TLSMAP_VALIDATE_KEY(key)  \
-    ((key) >= TLSMAP_START && (key) < TLSMAP_SIZE)
-
-/* the type of tls key destructor functions */
-typedef void (*tls_dtor_t)(void*);
-
-typedef struct {
-    int         init;                  /* see comment in tlsmap_lock() */
-    uint32_t    map[TLSMAP_WORDS];     /* bitmap of allocated keys */
-    tls_dtor_t  dtors[TLSMAP_SIZE];    /* key destructors */
-} tlsmap_t;
-
-static pthread_mutex_t  _tlsmap_lock = PTHREAD_MUTEX_INITIALIZER;
-static tlsmap_t         _tlsmap;
-
-/* lock the global TLS map lock and return a handle to it */
-static __inline__ tlsmap_t* tlsmap_lock(void)
-{
-    tlsmap_t*   m = &_tlsmap;
-
-    pthread_mutex_lock(&_tlsmap_lock);
-    /* we need to initialize the first entry of the 'map' array
-     * with the value TLS_DEFAULT_ALLOC_MAP. doing it statically
-     * when declaring _tlsmap is a bit awkward and is going to
-     * produce warnings, so do it the first time we use the map
-     * instead
-     */
-    if (__unlikely(!m->init)) {
-        TLSMAP_WORD(m,0) = TLS_DEFAULT_ALLOC_MAP;
-        m->init          = 1;
-    }
-    return m;
-}
-
-/* unlock the global TLS map */
-static __inline__ void tlsmap_unlock(tlsmap_t*  m)
-{
-    pthread_mutex_unlock(&_tlsmap_lock);
-    (void)m;  /* a good compiler is a happy compiler */
-}
-
-/* test to see wether a key is allocated */
-static __inline__ int tlsmap_test(tlsmap_t*  m, int  key)
-{
-    return (TLSMAP_WORD(m,key) & TLSMAP_MASK(key)) != 0;
-}
-
-/* set the destructor and bit flag on a newly allocated key */
-static __inline__ void tlsmap_set(tlsmap_t*  m, int  key, tls_dtor_t  dtor)
-{
-    TLSMAP_WORD(m,key) |= TLSMAP_MASK(key);
-    m->dtors[key]       = dtor;
-}
-
-/* clear the destructor and bit flag on an existing key */
-static __inline__ void  tlsmap_clear(tlsmap_t*  m, int  key)
-{
-    TLSMAP_WORD(m,key) &= ~TLSMAP_MASK(key);
-    m->dtors[key]       = NULL;
-}
-
-/* allocate a new TLS key, return -1 if no room left */
-static int tlsmap_alloc(tlsmap_t*  m, tls_dtor_t  dtor)
-{
-    int  key;
-
-    for ( key = TLSMAP_START; key < TLSMAP_SIZE; key++ ) {
-        if ( !tlsmap_test(m, key) ) {
-            tlsmap_set(m, key, dtor);
-            return key;
-        }
-    }
-    return -1;
-}
-
-
-int pthread_key_create(pthread_key_t *key, void (*destructor_function)(void *))
-{
-    uint32_t   err = ENOMEM;
-    tlsmap_t*  map = tlsmap_lock();
-    int        k   = tlsmap_alloc(map, destructor_function);
-
-    if (k >= 0) {
-        *key = k;
-        err  = 0;
-    }
-    tlsmap_unlock(map);
-    return err;
-}
-
-
-/* This deletes a pthread_key_t. note that the standard mandates that this does
- * not call the destructor of non-NULL key values. Instead, it is the
- * responsibility of the caller to properly dispose of the corresponding data
- * and resources, using any means it finds suitable.
- *
- * On the other hand, this function will clear the corresponding key data
- * values in all known threads. this prevents later (invalid) calls to
- * pthread_getspecific() to receive invalid/stale values.
- */
-int pthread_key_delete(pthread_key_t key)
-{
-    uint32_t             err;
-    pthread_internal_t*  thr;
-    tlsmap_t*            map;
-
-    if (!TLSMAP_VALIDATE_KEY(key)) {
-        return EINVAL;
-    }
-
-    map = tlsmap_lock();
-
-    if (!tlsmap_test(map, key)) {
-        err = EINVAL;
-        goto err1;
-    }
-
-    /* clear value in all threads */
-    pthread_mutex_lock(&gThreadListLock);
-    for ( thr = gThreadList; thr != NULL; thr = thr->next ) {
-        /* avoid zombie threads with a negative 'join_count'. these are really
-         * already dead and don't have a TLS area anymore.
-         *
-         * similarly, it is possible to have thr->tls == NULL for threads that
-         * were just recently created through pthread_create() but whose
-         * startup trampoline (__thread_entry) hasn't been run yet by the
-         * scheduler. thr->tls will also be NULL after it's stack has been
-         * unmapped but before the ongoing pthread_join() is finished.
-         * so check for this too.
-         */
-        if (thr->join_count < 0 || !thr->tls)
-            continue;
-
-        thr->tls[key] = NULL;
-    }
-    tlsmap_clear(map, key);
-
-    pthread_mutex_unlock(&gThreadListLock);
-    err = 0;
-
-err1:
-    tlsmap_unlock(map);
-    return err;
-}
-
-
-int pthread_setspecific(pthread_key_t key, const void *ptr)
-{
-    int        err = EINVAL;
-    tlsmap_t*  map;
-
-    if (TLSMAP_VALIDATE_KEY(key)) {
-        /* check that we're trying to set data for an allocated key */
-        map = tlsmap_lock();
-        if (tlsmap_test(map, key)) {
-            ((uint32_t *)__get_tls())[key] = (uint32_t)ptr;
-            err = 0;
-        }
-        tlsmap_unlock(map);
-    }
-    return err;
-}
-
-void * pthread_getspecific(pthread_key_t key)
-{
-    if (!TLSMAP_VALIDATE_KEY(key)) {
-        return NULL;
-    }
-
-    /* for performance reason, we do not lock/unlock the global TLS map
-     * to check that the key is properly allocated. if the key was not
-     * allocated, the value read from the TLS should always be NULL
-     * due to pthread_key_delete() clearing the values for all threads.
-     */
-    return (void *)(((unsigned *)__get_tls())[key]);
-}
-
-/* Posix mandates that this be defined in <limits.h> but we don't have
- * it just yet.
- */
-#ifndef PTHREAD_DESTRUCTOR_ITERATIONS
-#  define PTHREAD_DESTRUCTOR_ITERATIONS  4
-#endif
-
-/* this function is called from pthread_exit() to remove all TLS key data
- * from this thread's TLS area. this must call the destructor of all keys
- * that have a non-NULL data value (and a non-NULL destructor).
- *
- * because destructors can do funky things like deleting/creating other
- * keys, we need to implement this in a loop
- */
-static void pthread_key_clean_all(void)
-{
-    tlsmap_t*    map;
-    void**       tls = (void**)__get_tls();
-    int          rounds = PTHREAD_DESTRUCTOR_ITERATIONS;
-
-    map = tlsmap_lock();
-
-    for (rounds = PTHREAD_DESTRUCTOR_ITERATIONS; rounds > 0; rounds--)
-    {
-        int  kk, count = 0;
-
-        for (kk = TLSMAP_START; kk < TLSMAP_SIZE; kk++) {
-            if ( tlsmap_test(map, kk) )
-            {
-                void*       data = tls[kk];
-                tls_dtor_t  dtor = map->dtors[kk];
-
-                if (data != NULL && dtor != NULL)
-                {
-                   /* we need to clear the key data now, this will prevent the
-                    * destructor (or a later one) from seeing the old value if
-                    * it calls pthread_getspecific() for some odd reason
-                    *
-                    * we do not do this if 'dtor == NULL' just in case another
-                    * destructor function might be responsible for manually
-                    * releasing the corresponding data.
-                    */
-                    tls[kk] = NULL;
-
-                   /* because the destructor is free to call pthread_key_create
-                    * and/or pthread_key_delete, we need to temporarily unlock
-                    * the TLS map
-                    */
-                    tlsmap_unlock(map);
-                    (*dtor)(data);
-                    map = tlsmap_lock();
-
-                    count += 1;
-                }
-            }
-        }
-
-        /* if we didn't call any destructor, there is no need to check the
-         * TLS data again
-         */
-        if (count == 0)
-            break;
-    }
-    tlsmap_unlock(map);
-}
-
-// man says this should be in <linux/unistd.h>, but it isn't
-extern int tgkill(int tgid, int tid, int sig);
-
-int pthread_kill(pthread_t tid, int sig)
-{
-    int  ret;
-    int  old_errno = errno;
-    pthread_internal_t * thread = (pthread_internal_t *)tid;
-
-    ret = tgkill(getpid(), thread->kernel_id, sig);
-    if (ret < 0) {
-        ret = errno;
-        errno = old_errno;
-    }
-
-    return ret;
-}
-
-/* Despite the fact that our kernel headers define sigset_t explicitly
- * as a 32-bit integer, the kernel system call really expects a 64-bit
- * bitmap for the signal set, or more exactly an array of two-32-bit
- * values (see $KERNEL/arch/$ARCH/include/asm/signal.h for details).
- *
- * Unfortunately, we cannot fix the sigset_t definition without breaking
- * the C library ABI, so perform a little runtime translation here.
- */
-typedef union {
-    sigset_t   bionic;
-    uint32_t   kernel[2];
-} kernel_sigset_t;
-
-/* this is a private syscall stub */
-extern int __rt_sigprocmask(int, const kernel_sigset_t *, kernel_sigset_t *, size_t);
-
-int pthread_sigmask(int how, const sigset_t *set, sigset_t *oset)
-{
-    /* pthread_sigmask must return the error code, but the syscall
-     * will set errno instead and return 0/-1
-     */
-    int ret, old_errno = errno;
-
-    /* We must convert *set into a kernel_sigset_t */
-    kernel_sigset_t  in_set, *in_set_ptr;
-    kernel_sigset_t  out_set;
-
-    in_set.kernel[0] = in_set.kernel[1] = 0;
-    out_set.kernel[0] = out_set.kernel[1] = 0;
-
-    /* 'in_set_ptr' is the second parameter to __rt_sigprocmask. It must be NULL
-     * if 'set' is NULL to ensure correct semantics (which in this case would
-     * be to ignore 'how' and return the current signal set into 'oset'.
-     */
-    if (set == NULL) {
-        in_set_ptr = NULL;
-    } else {
-        in_set.bionic = *set;
-        in_set_ptr = &in_set;
-    }
-
-    ret = __rt_sigprocmask(how, in_set_ptr, &out_set, sizeof(kernel_sigset_t));
-    if (ret < 0)
-        ret = errno;
-
-    if (oset)
-        *oset = out_set.bionic;
-
-    errno = old_errno;
-    return ret;
-}
-
-
-int pthread_getcpuclockid(pthread_t  tid, clockid_t  *clockid)
-{
-    const int            CLOCK_IDTYPE_BITS = 3;
-    pthread_internal_t*  thread = (pthread_internal_t*)tid;
-
-    if (!thread)
-        return ESRCH;
-
-    *clockid = CLOCK_THREAD_CPUTIME_ID | (thread->kernel_id << CLOCK_IDTYPE_BITS);
-    return 0;
-}
-
-
 /* NOTE: this implementation doesn't support a init function that throws a C++ exception
  *       or calls fork()
  */
-int  pthread_once( pthread_once_t*  once_control,  void (*init_routine)(void) )
+int pthread_once( pthread_once_t*  once_control,  void (*init_routine)(void) )
 {
-    static pthread_mutex_t   once_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER;
     volatile pthread_once_t* ocptr = once_control;
-    pthread_once_t value;
 
     /* PTHREAD_ONCE_INIT is 0, we use the following bit flags
      *
@@ -2237,76 +1265,18 @@
     return 0;
 }
 
-/* This value is not exported by kernel headers, so hardcode it here */
-#define MAX_TASK_COMM_LEN	16
-#define TASK_COMM_FMT 		"/proc/self/task/%u/comm"
-
-int pthread_setname_np(pthread_t thid, const char *thname)
-{
-    size_t thname_len;
-    int saved_errno, ret;
-
-    if (thid == 0 || thname == NULL)
-        return EINVAL;
-
-    thname_len = strlen(thname);
-    if (thname_len >= MAX_TASK_COMM_LEN)
-        return ERANGE;
-
-    saved_errno = errno;
-    if (thid == pthread_self())
-    {
-        ret = prctl(PR_SET_NAME, (unsigned long)thname, 0, 0, 0) ? errno : 0;
-    }
-    else
-    {
-        /* Have to change another thread's name */
-        pthread_internal_t *thread = (pthread_internal_t *)thid;
-        char comm_name[sizeof(TASK_COMM_FMT) + 8];
-        ssize_t n;
-        int fd;
-
-        snprintf(comm_name, sizeof(comm_name), TASK_COMM_FMT, (unsigned int)thread->kernel_id);
-        fd = open(comm_name, O_RDWR);
-        if (fd == -1)
-        {
-            ret = errno;
-            goto exit;
-        }
-        n = TEMP_FAILURE_RETRY(write(fd, thname, thname_len));
-        close(fd);
-
-        if (n < 0)
-            ret = errno;
-        else if ((size_t)n != thname_len)
-            ret = EIO;
-        else
-            ret = 0;
-    }
-exit:
-    errno = saved_errno;
-    return ret;
+pid_t __pthread_gettid(pthread_t thid) {
+  pthread_internal_t* thread = (pthread_internal_t*) thid;
+  return thread->tid;
 }
 
-/* Return the kernel thread ID for a pthread.
- * This is only defined for implementations where pthread <-> kernel is 1:1, which this is.
- * Not the same as pthread_getthreadid_np, which is commonly defined to be opaque.
- * Internal, not an NDK API.
- */
+int __pthread_settid(pthread_t thid, pid_t tid) {
+  if (thid == 0) {
+      return EINVAL;
+  }
 
-pid_t __pthread_gettid(pthread_t thid)
-{
-    pthread_internal_t* thread = (pthread_internal_t*)thid;
-    return thread->kernel_id;
-}
+  pthread_internal_t* thread = (pthread_internal_t*) thid;
+  thread->tid = tid;
 
-int __pthread_settid(pthread_t thid, pid_t tid)
-{
-    if (thid == 0)
-        return EINVAL;
-
-    pthread_internal_t* thread = (pthread_internal_t*)thid;
-    thread->kernel_id = tid;
-
-    return 0;
+  return 0;
 }
diff --git a/libc/bionic/pthread_accessor.h b/libc/bionic/pthread_accessor.h
new file mode 100644
index 0000000..2a320f6
--- /dev/null
+++ b/libc/bionic/pthread_accessor.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PTHREAD_ACCESSOR_H
+#define PTHREAD_ACCESSOR_H
+
+#include <pthread.h>
+
+#include "pthread_internal.h"
+
+class pthread_accessor {
+ public:
+  explicit pthread_accessor(pthread_t desired_thread) {
+    Lock();
+    for (thread_ = gThreadList; thread_ != NULL; thread_ = thread_->next) {
+      if (thread_ == reinterpret_cast<pthread_internal_t*>(desired_thread)) {
+        break;
+      }
+    }
+  }
+
+  ~pthread_accessor() {
+    Unlock();
+  }
+
+  void Unlock() {
+    if (is_locked_) {
+      is_locked_ = false;
+      thread_ = NULL;
+      pthread_mutex_unlock(&gThreadListLock);
+    }
+  }
+
+  pthread_internal_t& operator*() const { return *thread_; }
+  pthread_internal_t* operator->() const { return thread_; }
+  pthread_internal_t* get() const { return thread_; }
+
+ private:
+  pthread_internal_t* thread_;
+  bool is_locked_;
+
+  void Lock() {
+    pthread_mutex_lock(&gThreadListLock);
+    is_locked_ = true;
+  }
+
+  // Disallow copy and assignment.
+  pthread_accessor(const pthread_accessor&);
+  void operator=(const pthread_accessor&);
+};
+
+#endif // PTHREAD_ACCESSOR_H
diff --git a/libc/bionic/pthread_attr.cpp b/libc/bionic/pthread_attr.cpp
new file mode 100644
index 0000000..c47f95e
--- /dev/null
+++ b/libc/bionic/pthread_attr.cpp
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <pthread.h>
+
+#include "pthread_internal.h"
+
+#define DEFAULT_STACK_SIZE (1024 * 1024)
+
+int pthread_attr_init(pthread_attr_t* attr) {
+  attr->flags = 0;
+  attr->stack_base = NULL;
+  attr->stack_size = DEFAULT_STACK_SIZE;
+  attr->guard_size = PAGE_SIZE;
+  attr->sched_policy = SCHED_NORMAL;
+  attr->sched_priority = 0;
+  return 0;
+}
+
+int pthread_attr_destroy(pthread_attr_t* attr) {
+  memset(attr, 0x42, sizeof(pthread_attr_t));
+  return 0;
+}
+
+int pthread_attr_setdetachstate(pthread_attr_t* attr, int state) {
+  if (state == PTHREAD_CREATE_DETACHED) {
+    attr->flags |= PTHREAD_ATTR_FLAG_DETACHED;
+  } else if (state == PTHREAD_CREATE_JOINABLE) {
+    attr->flags &= ~PTHREAD_ATTR_FLAG_DETACHED;
+  } else {
+    return EINVAL;
+  }
+  return 0;
+}
+
+int pthread_attr_getdetachstate(pthread_attr_t const* attr, int* state) {
+  *state = (attr->flags & PTHREAD_ATTR_FLAG_DETACHED) ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE;
+  return 0;
+}
+
+int pthread_attr_setschedpolicy(pthread_attr_t* attr, int policy) {
+  attr->sched_policy = policy;
+  return 0;
+}
+
+int pthread_attr_getschedpolicy(pthread_attr_t const* attr, int* policy) {
+  *policy = attr->sched_policy;
+  return 0;
+}
+
+int pthread_attr_setschedparam(pthread_attr_t * attr, struct sched_param const* param) {
+  attr->sched_priority = param->sched_priority;
+  return 0;
+}
+
+int pthread_attr_getschedparam(pthread_attr_t const* attr, struct sched_param* param) {
+  param->sched_priority = attr->sched_priority;
+  return 0;
+}
+
+int pthread_attr_setstacksize(pthread_attr_t* attr, size_t stack_size) {
+  if ((stack_size & (PAGE_SIZE - 1) || stack_size < PTHREAD_STACK_MIN)) {
+    return EINVAL;
+  }
+  attr->stack_size = stack_size;
+  return 0;
+}
+
+int pthread_attr_getstacksize(pthread_attr_t const* attr, size_t* stack_size) {
+  *stack_size = attr->stack_size;
+  return 0;
+}
+
+int pthread_attr_setstackaddr(pthread_attr_t*, void*) {
+  // This was removed from POSIX.1-2008, and is not implemented on bionic.
+  // Needed for ABI compatibility with the NDK.
+  return ENOSYS;
+}
+
+int pthread_attr_getstackaddr(pthread_attr_t const* attr, void** stack_addr) {
+  // This was removed from POSIX.1-2008.
+  // Needed for ABI compatibility with the NDK.
+  *stack_addr = (char*)attr->stack_base + attr->stack_size;
+  return 0;
+}
+
+int pthread_attr_setstack(pthread_attr_t* attr, void* stack_base, size_t stack_size) {
+  if ((stack_size & (PAGE_SIZE - 1) || stack_size < PTHREAD_STACK_MIN)) {
+    return EINVAL;
+  }
+  if ((uint32_t)stack_base & (PAGE_SIZE - 1)) {
+    return EINVAL;
+  }
+  attr->stack_base = stack_base;
+  attr->stack_size = stack_size;
+  return 0;
+}
+
+int pthread_attr_getstack(pthread_attr_t const* attr, void** stack_base, size_t* stack_size) {
+  *stack_base = attr->stack_base;
+  *stack_size = attr->stack_size;
+  return 0;
+}
+
+int pthread_attr_setguardsize(pthread_attr_t* attr, size_t guard_size) {
+  if (guard_size & (PAGE_SIZE - 1) || guard_size < PAGE_SIZE) {
+    return EINVAL;
+  }
+  attr->guard_size = guard_size;
+  return 0;
+}
+
+int pthread_attr_getguardsize(pthread_attr_t const* attr, size_t* guard_size) {
+  *guard_size = attr->guard_size;
+  return 0;
+}
+
+int pthread_getattr_np(pthread_t thid, pthread_attr_t* attr) {
+  pthread_internal_t* thread = (pthread_internal_t*) thid;
+  *attr = thread->attr;
+  return 0;
+}
+
+int pthread_attr_setscope(pthread_attr_t* , int scope) {
+  if (scope == PTHREAD_SCOPE_SYSTEM) {
+    return 0;
+  }
+  if (scope == PTHREAD_SCOPE_PROCESS) {
+    return ENOTSUP;
+  }
+  return EINVAL;
+}
+
+int pthread_attr_getscope(pthread_attr_t const*) {
+  return PTHREAD_SCOPE_SYSTEM;
+}
diff --git a/libc/bionic/pthread_create.cpp b/libc/bionic/pthread_create.cpp
new file mode 100644
index 0000000..368c46d
--- /dev/null
+++ b/libc/bionic/pthread_create.cpp
@@ -0,0 +1,231 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <pthread.h>
+
+#include <errno.h>
+#include <sys/mman.h>
+
+#include "pthread_internal.h"
+
+#include "private/bionic_ssp.h"
+#include "private/bionic_tls.h"
+#include "private/debug_format.h"
+#include "private/logd.h"
+#include "private/thread_private.h"
+#include "private/ErrnoRestorer.h"
+#include "private/ScopedPthreadMutexLocker.h"
+
+extern "C" int __pthread_clone(void* (*fn)(void*), void* child_stack, int flags, void* arg);
+
+#ifdef __i386__
+#define ATTRIBUTES __attribute__((noinline)) __attribute__((fastcall))
+#else
+#define ATTRIBUTES __attribute__((noinline))
+#endif
+
+extern "C" void ATTRIBUTES _thread_created_hook(pid_t thread_id);
+
+static const int kPthreadInitFailed = 1;
+
+static pthread_mutex_t gPthreadStackCreationLock = PTHREAD_MUTEX_INITIALIZER;
+
+static pthread_mutex_t gDebuggerNotificationLock = PTHREAD_MUTEX_INITIALIZER;
+
+void  __init_tls(pthread_internal_t* thread) {
+  // Zero-initialize all the slots.
+  for (size_t i = 0; i < BIONIC_TLS_SLOTS; ++i) {
+    thread->tls[i] = NULL;
+  }
+
+  // Slot 0 must point to itself. The x86 Linux kernel reads the TLS from %fs:0.
+  thread->tls[TLS_SLOT_SELF] = thread->tls;
+  thread->tls[TLS_SLOT_THREAD_ID] = thread;
+  // GCC looks in the TLS for the stack guard on x86, so copy it there from our global.
+  thread->tls[TLS_SLOT_STACK_GUARD] = (void*) __stack_chk_guard;
+
+  __set_tls(thread->tls);
+}
+
+// This trampoline is called from the assembly _pthread_clone() function.
+extern "C" void __thread_entry(void* (*func)(void*), void* arg, void** tls) {
+  // Wait for our creating thread to release us. This lets it have time to
+  // notify gdb about this thread before we start doing anything.
+  // This also provides the memory barrier needed to ensure that all memory
+  // accesses previously made by the creating thread are visible to us.
+  pthread_mutex_t* start_mutex = (pthread_mutex_t*) &tls[TLS_SLOT_SELF];
+  pthread_mutex_lock(start_mutex);
+  pthread_mutex_destroy(start_mutex);
+
+  pthread_internal_t* thread = (pthread_internal_t*) tls[TLS_SLOT_THREAD_ID];
+  thread->tls = tls;
+  __init_tls(thread);
+
+  if ((thread->internal_flags & kPthreadInitFailed) != 0) {
+    pthread_exit(NULL);
+  }
+
+  void* result = func(arg);
+  pthread_exit(result);
+}
+
+__LIBC_ABI_PRIVATE__
+int _init_thread(pthread_internal_t* thread, bool add_to_thread_list) {
+  int error = 0;
+
+  // Set the scheduling policy/priority of the thread.
+  if (thread->attr.sched_policy != SCHED_NORMAL) {
+    struct sched_param param;
+    param.sched_priority = thread->attr.sched_priority;
+    if (sched_setscheduler(thread->tid, thread->attr.sched_policy, &param) == -1) {
+      // For backwards compatibility reasons, we just warn about failures here.
+      // error = errno;
+      const char* msg = "pthread_create sched_setscheduler call failed: %s\n";
+      __libc_format_log(ANDROID_LOG_WARN, "libc", msg, strerror(errno));
+    }
+  }
+
+  pthread_cond_init(&thread->join_cond, NULL);
+  thread->join_count = 0;
+  thread->cleanup_stack = NULL;
+
+  if (add_to_thread_list) {
+    _pthread_internal_add(thread);
+  }
+
+  return error;
+}
+
+static void* __create_thread_stack(size_t stack_size, size_t guard_size) {
+  ScopedPthreadMutexLocker lock(&gPthreadStackCreationLock);
+
+  // Create a new private anonymous map.
+  int prot = PROT_READ | PROT_WRITE;
+  int flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE;
+  void* stack = mmap(NULL, stack_size, prot, flags, -1, 0);
+  if (stack == MAP_FAILED) {
+    return NULL;
+  }
+
+  // Set the guard region at the end of the stack to PROT_NONE.
+  if (mprotect(stack, guard_size, PROT_NONE) == -1) {
+    munmap(stack, stack_size);
+    return NULL;
+  }
+
+  return stack;
+}
+
+int pthread_create(pthread_t* thread_out, pthread_attr_t const* attr,
+                   void* (*start_routine)(void*), void* arg) {
+  ErrnoRestorer errno_restorer;
+
+  // Inform the rest of the C library that at least one thread
+  // was created. This will enforce certain functions to acquire/release
+  // locks (e.g. atexit()) to protect shared global structures.
+  // This works because pthread_create() is not called by the C library
+  // initialization routine that sets up the main thread's data structures.
+  __isthreaded = 1;
+
+  pthread_internal_t* thread = reinterpret_cast<pthread_internal_t*>(calloc(sizeof(*thread), 1));
+  if (thread == NULL) {
+    return EAGAIN;
+  }
+  thread->allocated_on_heap = true;
+
+  if (attr == NULL) {
+    pthread_attr_init(&thread->attr);
+  } else {
+    thread->attr = *attr;
+    attr = NULL; // Prevent misuse below.
+  }
+
+  // Make sure the stack size is PAGE_SIZE aligned.
+  size_t stack_size = (thread->attr.stack_size + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1);
+
+  if (thread->attr.stack_base == NULL) {
+    // The caller didn't provide a stack, so allocate one.
+    thread->attr.stack_base = __create_thread_stack(stack_size, thread->attr.guard_size);
+    if (thread->attr.stack_base == NULL) {
+      free(thread);
+      return EAGAIN;
+    }
+  } else {
+    // The caller did provide a stack, so remember we're not supposed to free it.
+    thread->attr.flags |= PTHREAD_ATTR_FLAG_USER_STACK;
+  }
+
+  // Make room for TLS.
+  void** tls = (void**)((uint8_t*)(thread->attr.stack_base) + stack_size - BIONIC_TLS_SLOTS * sizeof(void*));
+
+  // Create a mutex for the thread in TLS_SLOT_SELF to wait on once it starts so we can keep
+  // it from doing anything until after we notify the debugger about it
+  //
+  // This also provides the memory barrier we need to ensure that all
+  // memory accesses previously performed by this thread are visible to
+  // the new thread.
+  pthread_mutex_t* start_mutex = (pthread_mutex_t*) &tls[TLS_SLOT_SELF];
+  pthread_mutex_init(start_mutex, NULL);
+  ScopedPthreadMutexLocker start_locker(start_mutex);
+
+  tls[TLS_SLOT_THREAD_ID] = thread;
+
+  int flags = CLONE_FILES | CLONE_FS | CLONE_VM | CLONE_SIGHAND | CLONE_THREAD | CLONE_SYSVSEM;
+
+  int tid = __pthread_clone(start_routine, tls, flags, arg);
+  if (tid < 0) {
+    int clone_errno = errno;
+    if ((thread->attr.flags & PTHREAD_ATTR_FLAG_USER_STACK) == 0) {
+      munmap(thread->attr.stack_base, stack_size);
+    }
+    free(thread);
+    return clone_errno;
+  }
+
+  thread->tid = tid;
+
+  int init_errno = _init_thread(thread, true);
+  if (init_errno != 0) {
+    // Mark the thread detached and let its __thread_entry run to
+    // completion. (It'll just exit immediately, cleaning up its resources.)
+    thread->internal_flags |= kPthreadInitFailed;
+    thread->attr.flags |= PTHREAD_ATTR_FLAG_DETACHED;
+    return init_errno;
+  }
+
+  // Notify any debuggers about the new thread.
+  {
+    ScopedPthreadMutexLocker debugger_locker(&gDebuggerNotificationLock);
+    _thread_created_hook(thread->tid);
+  }
+
+  // Publish the pthread_t and let the thread run.
+  *thread_out = (pthread_t) thread;
+
+  return 0;
+}
diff --git a/libc/bionic/pthread_debug.c b/libc/bionic/pthread_debug.c
deleted file mode 100644
index 7ee208c..0000000
--- a/libc/bionic/pthread_debug.c
+++ /dev/null
@@ -1,903 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <sys/atomics.h>
-#include <sys/system_properties.h>
-#include <sys/mman.h>
-
-#if HAVE_DLADDR
-#include <dlfcn.h>
-#endif
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <pthread.h>
-#include <unwind.h>
-#include <unistd.h>
-
-#include "logd.h"
-#include "bionic_tls.h"
-
-/*
- * ===========================================================================
- *      Deadlock prediction
- * ===========================================================================
- */
-/*
-The idea is to predict the possibility of deadlock by recording the order
-in which locks are acquired.  If we see an attempt to acquire a lock
-out of order, we can identify the locks and offending code.
-
-To make this work, we need to keep track of the locks held by each thread,
-and create history trees for each lock.  When a thread tries to acquire
-a new lock, we walk through the "history children" of the lock, looking
-for a match with locks the thread already holds.  If we find a match,
-it means the thread has made a request that could result in a deadlock.
-
-To support recursive locks, we always allow re-locking a currently-held
-lock, and maintain a recursion depth count.
-
-An ASCII-art example, where letters represent locks:
-
-        A
-       /|\
-      / | \
-     B  |  D
-      \ |
-       \|
-        C
-
-The above is the tree we'd have after handling lock synchronization
-sequences "ABC", "AC", "AD".  A has three children, {B, C, D}.  C is also
-a child of B.  (The lines represent pointers between parent and child.
-Every node can have multiple parents and multiple children.)
-
-If we hold AC, and want to lock B, we recursively search through B's
-children to see if A or C appears.  It does, so we reject the attempt.
-(A straightforward way to implement it: add a link from C to B, then
-determine whether the graph starting at B contains a cycle.)
-
-If we hold AC and want to lock D, we would succeed, creating a new link
-from C to D.
-
-Updates to MutexInfo structs are only allowed for the thread that holds
-the lock, so we actually do most of our deadlock prediction work after
-the lock has been acquired.
-*/
-
-// =============================================================================
-// log functions
-// =============================================================================
-
-#define LOGD(format, ...)  \
-    __libc_android_log_print(ANDROID_LOG_DEBUG, \
-            "pthread_debug", (format), ##__VA_ARGS__ )
-
-#define LOGW(format, ...)  \
-    __libc_android_log_print(ANDROID_LOG_WARN, \
-            "pthread_debug", (format), ##__VA_ARGS__ )
-
-#define LOGE(format, ...)  \
-    __libc_android_log_print(ANDROID_LOG_ERROR, \
-            "pthread_debug", (format), ##__VA_ARGS__ )
-
-#define LOGI(format, ...)  \
-    __libc_android_log_print(ANDROID_LOG_INFO, \
-            "pthread_debug", (format), ##__VA_ARGS__ )
-
-static const char* const kStartBanner =
-        "===============================================================";
-
-static const char* const kEndBanner =
-        "===============================================================";
-
-extern char* __progname;
-
-// =============================================================================
-// map info functions
-// =============================================================================
-
-typedef struct mapinfo {
-    struct mapinfo *next;
-    unsigned start;
-    unsigned end;
-    char name[];
-} mapinfo;
-
-static mapinfo* sMapInfo = NULL;
-
-static mapinfo *parse_maps_line(char *line)
-{
-    mapinfo *mi;
-    int len = strlen(line);
-
-    if(len < 1) return 0;
-    line[--len] = 0;
-
-    if(len < 50) return 0;
-    if(line[20] != 'x') return 0;
-
-    mi = malloc(sizeof(mapinfo) + (len - 47));
-    if(mi == 0) return 0;
-
-    mi->start = strtoul(line, 0, 16);
-    mi->end = strtoul(line + 9, 0, 16);
-    /* To be filled in parse_elf_info if the mapped section starts with
-     * elf_header
-     */
-    mi->next = 0;
-    strcpy(mi->name, line + 49);
-
-    return mi;
-}
-
-static mapinfo *init_mapinfo(int pid)
-{
-    struct mapinfo *milist = NULL;
-    char data[1024];
-    sprintf(data, "/proc/%d/maps", pid);
-    FILE *fp = fopen(data, "r");
-    if(fp) {
-        while(fgets(data, sizeof(data), fp)) {
-            mapinfo *mi = parse_maps_line(data);
-            if(mi) {
-                mi->next = milist;
-                milist = mi;
-            }
-        }
-        fclose(fp);
-    }
-
-    return milist;
-}
-
-static void deinit_mapinfo(mapinfo *mi)
-{
-   mapinfo *del;
-   while(mi) {
-       del = mi;
-       mi = mi->next;
-       free(del);
-   }
-}
-
-/* Find the containing map info for the pc */
-static const mapinfo *pc_to_mapinfo(mapinfo *mi, unsigned pc, unsigned *rel_pc)
-{
-    *rel_pc = pc;
-    while(mi) {
-        if((pc >= mi->start) && (pc < mi->end)){
-            // Only calculate the relative offset for shared libraries
-            if (strstr(mi->name, ".so")) {
-                *rel_pc -= mi->start;
-            }
-            return mi;
-        }
-        mi = mi->next;
-    }
-    return NULL;
-}
-
-// =============================================================================
-// stack trace functions
-// =============================================================================
-
-#define STACK_TRACE_DEPTH 16
-
-typedef struct
-{
-    size_t count;
-    intptr_t* addrs;
-} stack_crawl_state_t;
-
-/* depends how the system includes define this */
-#ifdef HAVE_UNWIND_CONTEXT_STRUCT
-typedef struct _Unwind_Context __unwind_context;
-#else
-typedef _Unwind_Context __unwind_context;
-#endif
-
-static _Unwind_Reason_Code trace_function(__unwind_context *context, void *arg)
-{
-    stack_crawl_state_t* state = (stack_crawl_state_t*)arg;
-    if (state->count) {
-        intptr_t ip = (intptr_t)_Unwind_GetIP(context);
-        if (ip) {
-            state->addrs[0] = ip;
-            state->addrs++;
-            state->count--;
-            return _URC_NO_REASON;
-        }
-    }
-    /*
-     * If we run out of space to record the address or 0 has been seen, stop
-     * unwinding the stack.
-     */
-    return _URC_END_OF_STACK;
-}
-
-static inline
-int get_backtrace(intptr_t* addrs, size_t max_entries)
-{
-    stack_crawl_state_t state;
-    state.count = max_entries;
-    state.addrs = (intptr_t*)addrs;
-    _Unwind_Backtrace(trace_function, (void*)&state);
-    return max_entries - state.count;
-}
-
-static void log_backtrace(intptr_t* addrs, size_t c)
-{
-    int index = 0;
-    size_t i;
-    for (i=0 ; i<c; i++) {
-        unsigned int relpc;
-        void* offset = 0;
-        const char* symbol = NULL;
-
-#if HAVE_DLADDR
-        Dl_info info;
-        if (dladdr((void*)addrs[i], &info)) {
-            offset = info.dli_saddr;
-            symbol = info.dli_sname;
-        }
-#endif
-
-        if (symbol || index>0 || !HAVE_DLADDR) {
-            /*
-             * this test is a bit sketchy, but it allows us to skip the
-             * stack trace entries due to this debugging code. it works
-             * because those don't have a symbol (they're not exported)
-             */
-            mapinfo const* mi = pc_to_mapinfo(sMapInfo, addrs[i], &relpc);
-            char const* soname = mi ? mi->name : NULL;
-#if HAVE_DLADDR
-            if (!soname)
-                soname = info.dli_fname;
-#endif
-            if (!soname)
-                soname = "unknown";
-
-            if (symbol) {
-                LOGW("          "
-                     "#%02d  pc %08lx  %s (%s+0x%x)",
-                     index, relpc, soname, symbol,
-                     addrs[i] - (intptr_t)offset);
-            } else {
-                LOGW("          "
-                     "#%02d  pc %08lx  %s",
-                     index, relpc, soname);
-            }
-            index++;
-        }
-    }
-}
-
-/****************************************************************************/
-
-/*
- * level <= 0 : deadlock prediction disabled
- * level    1 : deadlock prediction enabled, w/o call stacks
- * level    2 : deadlock prediction enabled w/ call stacks
- */
-#define CAPTURE_CALLSTACK 2
-static int sPthreadDebugLevel = 0;
-static pid_t sPthreadDebugDisabledThread = -1;
-static pthread_mutex_t sDbgLock = PTHREAD_MUTEX_INITIALIZER;
-
-/****************************************************************************/
-
-/* some simple/lame malloc replacement
- * NOT thread-safe and leaks everything
- */
-
-#define DBG_ALLOC_BLOCK_SIZE PAGESIZE
-static size_t sDbgAllocOffset = DBG_ALLOC_BLOCK_SIZE;
-static char* sDbgAllocPtr = NULL;
-
-static void* DbgAllocLocked(size_t size) {
-    if ((sDbgAllocOffset + size) > DBG_ALLOC_BLOCK_SIZE) {
-        sDbgAllocOffset = 0;
-        sDbgAllocPtr = mmap(NULL, DBG_ALLOC_BLOCK_SIZE, PROT_READ|PROT_WRITE,
-                MAP_ANON | MAP_PRIVATE, 0, 0);
-        if (sDbgAllocPtr == MAP_FAILED) {
-            return NULL;
-        }
-    }
-    void* addr = sDbgAllocPtr + sDbgAllocOffset;
-    sDbgAllocOffset += size;
-    return addr;
-}
-
-static void* debug_realloc(void *ptr, size_t size, size_t old_size) {
-    void* addr = mmap(NULL, size, PROT_READ|PROT_WRITE,
-            MAP_ANON | MAP_PRIVATE, 0, 0);
-    if (addr != MAP_FAILED) {
-        if (ptr) {
-            memcpy(addr, ptr, old_size);
-            munmap(ptr, old_size);
-        }
-    } else {
-        addr = NULL;
-    }
-    return addr;
-}
-
-/*****************************************************************************/
-
-struct MutexInfo;
-
-typedef struct CallStack {
-    intptr_t    depth;
-    intptr_t*   addrs;
-} CallStack;
-
-typedef struct MutexInfo* MutexInfoListEntry;
-typedef struct CallStack  CallStackListEntry;
-
-typedef struct GrowingList {
-    int alloc;
-    int count;
-    union {
-        void*               data;
-        MutexInfoListEntry* list;
-        CallStackListEntry* stack;
-    };
-} GrowingList;
-
-typedef GrowingList MutexInfoList;
-typedef GrowingList CallStackList;
-
-typedef struct MutexInfo {
-    // thread currently holding the lock or 0
-    pid_t               owner;
-
-    // most-recently-locked doubly-linked list
-    struct MutexInfo*   prev;
-    struct MutexInfo*   next;
-
-    // for reentrant locks
-    int                 lockCount;
-    // when looking for loops in the graph, marks visited nodes
-    int                 historyMark;
-    // the actual mutex
-    pthread_mutex_t*    mutex;
-    // list of locks directly acquired AFTER this one in the same thread
-    MutexInfoList       children;
-    // list of locks directly acquired BEFORE this one in the same thread
-    MutexInfoList       parents;
-    // list of call stacks when a new link is established to this lock form its parent
-    CallStackList       stacks;
-    // call stack when this lock was acquired last
-    int                 stackDepth;
-    intptr_t            stackTrace[STACK_TRACE_DEPTH];
-} MutexInfo;
-
-static void growingListInit(GrowingList* list) {
-    list->alloc = 0;
-    list->count = 0;
-    list->data = NULL;
-}
-
-static void growingListAdd(GrowingList* pList, size_t objSize) {
-    if (pList->count == pList->alloc) {
-        size_t oldsize = pList->alloc * objSize;
-        pList->alloc += PAGESIZE / objSize;
-        size_t size = pList->alloc * objSize;
-        pList->data = debug_realloc(pList->data, size, oldsize);
-    }
-    pList->count++;
-}
-
-static void initMutexInfo(MutexInfo* object, pthread_mutex_t* mutex) {
-    object->owner = 0;
-    object->prev = 0;
-    object->next = 0;
-    object->lockCount = 0;
-    object->historyMark = 0;
-    object->mutex = mutex;
-    growingListInit(&object->children);
-    growingListInit(&object->parents);
-    growingListInit(&object->stacks);
-    object->stackDepth = 0;
-}
-
-typedef struct ThreadInfo {
-    pid_t       pid;
-    MutexInfo*  mrl;
-} ThreadInfo;
-
-static void initThreadInfo(ThreadInfo* object, pid_t pid) {
-    object->pid = pid;
-    object->mrl = NULL;
-}
-
-/****************************************************************************/
-
-static MutexInfo* get_mutex_info(pthread_mutex_t *mutex);
-static void mutex_lock_checked(MutexInfo* mrl, MutexInfo* object);
-static void mutex_unlock_checked(MutexInfo* object);
-
-/****************************************************************************/
-
-extern int pthread_mutex_lock_impl(pthread_mutex_t *mutex);
-extern int pthread_mutex_unlock_impl(pthread_mutex_t *mutex);
-
-static int pthread_mutex_lock_unchecked(pthread_mutex_t *mutex) {
-    return pthread_mutex_lock_impl(mutex);
-}
-
-static int pthread_mutex_unlock_unchecked(pthread_mutex_t *mutex) {
-    return pthread_mutex_unlock_impl(mutex);
-}
-
-/****************************************************************************/
-
-static void dup_backtrace(CallStack* stack, int count, intptr_t const* addrs) {
-    stack->depth = count;
-    stack->addrs = DbgAllocLocked(count * sizeof(intptr_t));
-    memcpy(stack->addrs, addrs, count * sizeof(intptr_t));
-}
-
-/****************************************************************************/
-
-static int historyListHas(
-        const MutexInfoList* list, MutexInfo const * obj) {
-    int i;
-    for (i=0; i<list->count; i++) {
-        if (list->list[i] == obj) {
-            return i;
-        }
-    }
-    return -1;
-}
-
-static void historyListAdd(MutexInfoList* pList, MutexInfo* obj) {
-    growingListAdd(pList, sizeof(MutexInfoListEntry));
-    pList->list[pList->count - 1] = obj;
-}
-
-static int historyListRemove(MutexInfoList* pList, MutexInfo* obj) {
-    int i;
-    for (i = pList->count-1; i >= 0; i--) {
-        if (pList->list[i] == obj) {
-            break;
-        }
-    }
-    if (i < 0) {
-        // not found!
-        return 0;
-    }
-
-    if (i != pList->count-1) {
-        // copy the last entry to the new free slot
-        pList->list[i] = pList->list[pList->count-1];
-    }
-    pList->count--;
-    memset(&pList->list[pList->count], 0, sizeof(MutexInfoListEntry));
-    return 1;
-}
-
-static void linkParentToChild(MutexInfo* parent, MutexInfo* child) {
-    historyListAdd(&parent->children, child);
-    historyListAdd(&child->parents, parent);
-}
-
-static void unlinkParentFromChild(MutexInfo* parent, MutexInfo* child) {
-    historyListRemove(&parent->children, child);
-    historyListRemove(&child->parents, parent);
-}
-
-/****************************************************************************/
-
-static void callstackListAdd(CallStackList* pList,
-        int count, intptr_t const* addrs) {
-    growingListAdd(pList, sizeof(CallStackListEntry));
-    dup_backtrace(&pList->stack[pList->count - 1], count, addrs);
-}
-
-/****************************************************************************/
-
-/*
- * Recursively traverse the object hierarchy starting at "obj".  We mark
- * ourselves on entry and clear the mark on exit.  If we ever encounter
- * a marked object, we have a cycle.
- *
- * Returns "true" if all is well, "false" if we found a cycle.
- */
-
-static int traverseTree(MutexInfo* obj, MutexInfo const* objParent)
-{
-    /*
-     * Have we been here before?
-     */
-    if (obj->historyMark) {
-        int stackDepth;
-        intptr_t addrs[STACK_TRACE_DEPTH];
-
-        /* Turn off prediction temporarily in this thread while logging */
-        sPthreadDebugDisabledThread = gettid();
-
-        if (sMapInfo == NULL) {
-            // note: we're protected by sDbgLock
-            sMapInfo = init_mapinfo(getpid());
-        }
-
-        LOGW("%s\n", kStartBanner);
-        LOGW("pid: %d, tid: %d >>> %s <<<", getpid(), gettid(), __progname);
-        LOGW("Illegal lock attempt:\n");
-        LOGW("--- pthread_mutex_t at %p\n", obj->mutex);
-        stackDepth = get_backtrace(addrs, STACK_TRACE_DEPTH);
-        log_backtrace(addrs, stackDepth);
-
-        LOGW("+++ Currently held locks in this thread (in reverse order):");
-        MutexInfo* cur = obj;
-        pid_t ourtid = gettid();
-        int i;
-        for (i=0 ; i<cur->parents.count ; i++) {
-            MutexInfo* parent = cur->parents.list[i];
-            if (parent->owner == ourtid) {
-                LOGW("--- pthread_mutex_t at %p\n", parent->mutex);
-                if (sPthreadDebugLevel >= CAPTURE_CALLSTACK) {
-                    log_backtrace(parent->stackTrace, parent->stackDepth);
-                }
-                cur = parent;
-                break;
-            }
-        }
-
-        LOGW("+++ Earlier, the following lock order (from last to first) was established\n");
-        return 0;
-    }
-
-    obj->historyMark = 1;
-
-    MutexInfoList* pList = &obj->children;
-    int result = 1;
-    int i;
-    for (i = pList->count-1; i >= 0; i--) {
-        MutexInfo* child = pList->list[i];
-        if (!traverseTree(child,  obj)) {
-            LOGW("--- pthread_mutex_t at %p\n", obj->mutex);
-            if (sPthreadDebugLevel >= CAPTURE_CALLSTACK) {
-                int index = historyListHas(&obj->parents, objParent);
-                if ((size_t)index < (size_t)obj->stacks.count) {
-                    log_backtrace(
-                            obj->stacks.stack[index].addrs,
-                            obj->stacks.stack[index].depth);
-                } else {
-                    log_backtrace(
-                            obj->stackTrace,
-                            obj->stackDepth);
-                }
-            }
-            result = 0;
-            break;
-        }
-    }
-
-    obj->historyMark = 0;
-    return result;
-}
-
-/****************************************************************************/
-
-static void mutex_lock_checked(MutexInfo* mrl, MutexInfo* object)
-{
-    pid_t tid = gettid();
-    if (object->owner == tid) {
-        object->lockCount++;
-        return;
-    }
-
-    object->owner = tid;
-    object->lockCount = 0;
-
-    if (sPthreadDebugLevel >= CAPTURE_CALLSTACK) {
-        // always record the call stack when acquiring a lock.
-        // it's not efficient, but is useful during diagnostics
-        object->stackDepth = get_backtrace(object->stackTrace, STACK_TRACE_DEPTH);
-    }
-
-    // no other locks held in this thread -- no deadlock possible!
-    if (mrl == NULL)
-        return;
-
-    // check if the lock we're trying to acquire is a direct descendant of
-    // the most recently locked mutex in this thread, in which case we're
-    // in a good situation -- no deadlock possible
-    if (historyListHas(&mrl->children, object) >= 0)
-        return;
-
-    pthread_mutex_lock_unchecked(&sDbgLock);
-
-    linkParentToChild(mrl, object);
-    if (!traverseTree(object, mrl)) {
-        deinit_mapinfo(sMapInfo);
-        sMapInfo = NULL;
-        LOGW("%s\n", kEndBanner);
-        unlinkParentFromChild(mrl, object);
-        // reenable pthread debugging for this thread
-        sPthreadDebugDisabledThread = -1;
-    } else {
-        // record the call stack for this link
-        // NOTE: the call stack is added at the same index
-        // as mrl in object->parents[]
-        // ie: object->parents.count == object->stacks.count, which is
-        // also the index.
-        if (sPthreadDebugLevel >= CAPTURE_CALLSTACK) {
-            callstackListAdd(&object->stacks,
-                    object->stackDepth, object->stackTrace);
-        }
-    }
-
-    pthread_mutex_unlock_unchecked(&sDbgLock);
-}
-
-static void mutex_unlock_checked(MutexInfo* object)
-{
-    pid_t tid = gettid();
-    if (object->owner == tid) {
-        if (object->lockCount == 0) {
-            object->owner = 0;
-        } else {
-            object->lockCount--;
-        }
-    }
-}
-
-
-// =============================================================================
-// Hash Table functions
-// =============================================================================
-
-/****************************************************************************/
-
-#define HASHTABLE_SIZE      256
-
-typedef struct HashEntry HashEntry;
-struct HashEntry {
-    size_t slot;
-    HashEntry* prev;
-    HashEntry* next;
-    void* data;
-};
-
-typedef struct HashTable HashTable;
-struct HashTable {
-    HashEntry* slots[HASHTABLE_SIZE];
-};
-
-static HashTable sMutexMap;
-static HashTable sThreadMap;
-
-/****************************************************************************/
-
-static uint32_t get_hashcode(void const * key, size_t keySize)
-{
-    uint32_t h = keySize;
-    char const* data = (char const*)key;
-    size_t i;
-    for (i = 0; i < keySize; i++) {
-        h = h * 31 + *data;
-        data++;
-    }
-    return (uint32_t)h;
-}
-
-static size_t get_index(uint32_t h)
-{
-    // We apply this secondary hashing discovered by Doug Lea to defend
-    // against bad hashes.
-    h += ~(h << 9);
-    h ^= (((unsigned int) h) >> 14);
-    h += (h << 4);
-    h ^= (((unsigned int) h) >> 10);
-    return (size_t)h & (HASHTABLE_SIZE - 1);
-}
-
-/****************************************************************************/
-
-static void hashmap_init(HashTable* table) {
-    memset(table, 0, sizeof(HashTable));
-}
-
-static void hashmap_removeEntry(HashTable* table, HashEntry* entry)
-{
-    HashEntry* prev = entry->prev;
-    HashEntry* next = entry->next;
-    if (prev != NULL) entry->prev->next = next;
-    if (next != NULL) entry->next->prev = prev;
-    if (prev == NULL) {
-        // we are the head of the list. set the head to be next
-        table->slots[entry->slot] = entry->next;
-    }
-}
-
-static HashEntry* hashmap_lookup(HashTable* table,
-        void const* key, size_t ksize,
-        int (*equals)(void const* data, void const* key))
-{
-    const uint32_t hash = get_hashcode(key, ksize);
-    const size_t slot = get_index(hash);
-
-    HashEntry* entry = table->slots[slot];
-    while (entry) {
-        if (equals(entry->data, key)) {
-            break;
-        }
-        entry = entry->next;
-    }
-
-    if (entry == NULL) {
-        // create a new entry
-        entry = (HashEntry*)DbgAllocLocked(sizeof(HashEntry));
-        entry->data = NULL;
-        entry->slot = slot;
-        entry->prev = NULL;
-        entry->next = table->slots[slot];
-        if (entry->next != NULL) {
-            entry->next->prev = entry;
-        }
-        table->slots[slot] = entry;
-    }
-    return entry;
-}
-
-/****************************************************************************/
-
-static int MutexInfo_equals(void const* data, void const* key) {
-    return ((MutexInfo const *)data)->mutex == *(pthread_mutex_t **)key;
-}
-
-static MutexInfo* get_mutex_info(pthread_mutex_t *mutex)
-{
-    pthread_mutex_lock_unchecked(&sDbgLock);
-
-    HashEntry* entry = hashmap_lookup(&sMutexMap,
-            &mutex, sizeof(mutex),
-            &MutexInfo_equals);
-    if (entry->data == NULL) {
-        entry->data = (MutexInfo*)DbgAllocLocked(sizeof(MutexInfo));
-        initMutexInfo(entry->data, mutex);
-    }
-
-    pthread_mutex_unlock_unchecked(&sDbgLock);
-
-    return (MutexInfo *)entry->data;
-}
-
-/****************************************************************************/
-
-static int ThreadInfo_equals(void const* data, void const* key) {
-    return ((ThreadInfo const *)data)->pid == *(pid_t *)key;
-}
-
-static ThreadInfo* get_thread_info(pid_t pid)
-{
-    pthread_mutex_lock_unchecked(&sDbgLock);
-
-    HashEntry* entry = hashmap_lookup(&sThreadMap,
-            &pid, sizeof(pid),
-            &ThreadInfo_equals);
-    if (entry->data == NULL) {
-        entry->data = (ThreadInfo*)DbgAllocLocked(sizeof(ThreadInfo));
-        initThreadInfo(entry->data, pid);
-    }
-
-    pthread_mutex_unlock_unchecked(&sDbgLock);
-
-    return (ThreadInfo *)entry->data;
-}
-
-static void push_most_recently_locked(MutexInfo* mrl) {
-    ThreadInfo* tinfo = get_thread_info(gettid());
-    mrl->next = NULL;
-    mrl->prev = tinfo->mrl;
-    tinfo->mrl = mrl;
-}
-
-static void remove_most_recently_locked(MutexInfo* mrl) {
-    ThreadInfo* tinfo = get_thread_info(gettid());
-    if (mrl->next) {
-        (mrl->next)->prev = mrl->prev;
-    }
-    if (mrl->prev) {
-        (mrl->prev)->next = mrl->next;
-    }
-    if (tinfo->mrl == mrl) {
-        tinfo->mrl = mrl->next;
-    }
-}
-
-static MutexInfo* get_most_recently_locked() {
-    ThreadInfo* tinfo = get_thread_info(gettid());
-    return tinfo->mrl;
-}
-
-/****************************************************************************/
-
-/* pthread_debug_init() is called from libc_init_dynamic() just
- * after system properties have been initialized
- */
-
-__LIBC_HIDDEN__
-void pthread_debug_init(void) {
-    char env[PROP_VALUE_MAX];
-    if (__system_property_get("debug.libc.pthread", env)) {
-        int level = atoi(env);
-        if (level) {
-            LOGI("pthread deadlock detection level %d enabled for pid %d (%s)",
-                    level, getpid(), __progname);
-            hashmap_init(&sMutexMap);
-            sPthreadDebugLevel = level;
-        }
-    }
-}
-
-/*
- * See if we were allowed to grab the lock at this time.  We do it
- * *after* acquiring the lock, rather than before, so that we can
- * freely update the MutexInfo struct.  This seems counter-intuitive,
- * but our goal is deadlock *prediction* not deadlock *prevention*.
- * (If we actually deadlock, the situation is easy to diagnose from
- * a thread dump, so there's no point making a special effort to do
- * the checks before the lock is held.)
- */
-
-__LIBC_HIDDEN__
-void pthread_debug_mutex_lock_check(pthread_mutex_t *mutex)
-{
-    if (sPthreadDebugLevel == 0) return;
-    // prediction disabled for this thread
-    if (sPthreadDebugDisabledThread == gettid())
-        return;
-    MutexInfo* object = get_mutex_info(mutex);
-    MutexInfo* mrl = get_most_recently_locked();
-    mutex_lock_checked(mrl, object);
-    push_most_recently_locked(object);
-}
-
-/*
- * pthread_debug_mutex_unlock_check() must be called with the mutex
- * still held (ie: before calling the real unlock)
- */
-
-__LIBC_HIDDEN__
-void pthread_debug_mutex_unlock_check(pthread_mutex_t *mutex)
-{
-    if (sPthreadDebugLevel == 0) return;
-    // prediction disabled for this thread
-    if (sPthreadDebugDisabledThread == gettid())
-        return;
-    MutexInfo* object = get_mutex_info(mutex);
-    remove_most_recently_locked(object);
-    mutex_unlock_checked(object);
-}
diff --git a/libc/bionic/pthread_debug.cpp b/libc/bionic/pthread_debug.cpp
new file mode 100644
index 0000000..f8f0c59
--- /dev/null
+++ b/libc/bionic/pthread_debug.cpp
@@ -0,0 +1,717 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/atomics.h>
+#include <sys/system_properties.h>
+#include <sys/mman.h>
+
+//#include <dlfcn.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <pthread.h>
+#include <unwind.h>
+#include <unistd.h>
+
+#include "bionic_tls.h"
+#include "debug_mapinfo.h"
+#include "debug_stacktrace.h"
+#include "logd.h"
+
+#include <private/debug_format.h>
+
+/*
+ * ===========================================================================
+ *      Deadlock prediction
+ * ===========================================================================
+ */
+/*
+The idea is to predict the possibility of deadlock by recording the order
+in which locks are acquired.  If we see an attempt to acquire a lock
+out of order, we can identify the locks and offending code.
+
+To make this work, we need to keep track of the locks held by each thread,
+and create history trees for each lock.  When a thread tries to acquire
+a new lock, we walk through the "history children" of the lock, looking
+for a match with locks the thread already holds.  If we find a match,
+it means the thread has made a request that could result in a deadlock.
+
+To support recursive locks, we always allow re-locking a currently-held
+lock, and maintain a recursion depth count.
+
+An ASCII-art example, where letters represent locks:
+
+        A
+       /|\
+      / | \
+     B  |  D
+      \ |
+       \|
+        C
+
+The above is the tree we'd have after handling lock synchronization
+sequences "ABC", "AC", "AD".  A has three children, {B, C, D}.  C is also
+a child of B.  (The lines represent pointers between parent and child.
+Every node can have multiple parents and multiple children.)
+
+If we hold AC, and want to lock B, we recursively search through B's
+children to see if A or C appears.  It does, so we reject the attempt.
+(A straightforward way to implement it: add a link from C to B, then
+determine whether the graph starting at B contains a cycle.)
+
+If we hold AC and want to lock D, we would succeed, creating a new link
+from C to D.
+
+Updates to MutexInfo structs are only allowed for the thread that holds
+the lock, so we actually do most of our deadlock prediction work after
+the lock has been acquired.
+*/
+
+// =============================================================================
+// log functions
+// =============================================================================
+
+#define LOGD(format, ...)  \
+    __libc_format_log(ANDROID_LOG_DEBUG, "pthread_debug", (format), ##__VA_ARGS__ )
+
+#define LOGW(format, ...)  \
+    __libc_format_log(ANDROID_LOG_WARN, "pthread_debug", (format), ##__VA_ARGS__ )
+
+#define LOGE(format, ...)  \
+    __libc_format_log(ANDROID_LOG_ERROR, "pthread_debug", (format), ##__VA_ARGS__ )
+
+#define LOGI(format, ...)  \
+    __libc_format_log(ANDROID_LOG_INFO, "pthread_debug", (format), ##__VA_ARGS__ )
+
+static const char* const kStartBanner =
+        "===============================================================";
+
+static const char* const kEndBanner =
+        "===============================================================";
+
+extern const char* __progname;
+
+#define STACK_TRACE_DEPTH 16
+
+/****************************************************************************/
+
+/*
+ * level <= 0 : deadlock prediction disabled
+ * level    1 : deadlock prediction enabled, w/o call stacks
+ * level    2 : deadlock prediction enabled w/ call stacks
+ */
+#define CAPTURE_CALLSTACK 2
+static int sPthreadDebugLevel = 0;
+static pid_t sPthreadDebugDisabledThread = -1;
+static pthread_mutex_t sDbgLock = PTHREAD_MUTEX_INITIALIZER;
+
+/****************************************************************************/
+
+/* some simple/lame malloc replacement
+ * NOT thread-safe and leaks everything
+ */
+
+#define DBG_ALLOC_BLOCK_SIZE PAGESIZE
+static size_t sDbgAllocOffset = DBG_ALLOC_BLOCK_SIZE;
+static char* sDbgAllocPtr = NULL;
+
+template <typename T>
+static T* DbgAllocLocked(size_t count = 1) {
+    size_t size = sizeof(T) * count;
+    if ((sDbgAllocOffset + size) > DBG_ALLOC_BLOCK_SIZE) {
+        sDbgAllocOffset = 0;
+        sDbgAllocPtr = reinterpret_cast<char*>(mmap(NULL, DBG_ALLOC_BLOCK_SIZE,
+                                                    PROT_READ|PROT_WRITE,
+                                                    MAP_ANON | MAP_PRIVATE, 0, 0));
+        if (sDbgAllocPtr == MAP_FAILED) {
+            return NULL;
+        }
+    }
+    void* addr = sDbgAllocPtr + sDbgAllocOffset;
+    sDbgAllocOffset += size;
+    return reinterpret_cast<T*>(addr);
+}
+
+static void* debug_realloc(void *ptr, size_t size, size_t old_size) {
+    void* addr = mmap(NULL, size, PROT_READ|PROT_WRITE,
+            MAP_ANON | MAP_PRIVATE, 0, 0);
+    if (addr != MAP_FAILED) {
+        if (ptr) {
+            memcpy(addr, ptr, old_size);
+            munmap(ptr, old_size);
+        }
+    } else {
+        addr = NULL;
+    }
+    return addr;
+}
+
+/*****************************************************************************/
+
+struct MutexInfo;
+
+typedef struct CallStack {
+    uintptr_t    depth;
+    uintptr_t*   addrs;
+} CallStack;
+
+typedef struct MutexInfo* MutexInfoListEntry;
+typedef struct CallStack  CallStackListEntry;
+
+typedef struct GrowingList {
+    int alloc;
+    int count;
+    union {
+        void*               data;
+        MutexInfoListEntry* list;
+        CallStackListEntry* stack;
+    };
+} GrowingList;
+
+typedef GrowingList MutexInfoList;
+typedef GrowingList CallStackList;
+
+typedef struct MutexInfo {
+    // thread currently holding the lock or 0
+    pid_t               owner;
+
+    // most-recently-locked doubly-linked list
+    struct MutexInfo*   prev;
+    struct MutexInfo*   next;
+
+    // for reentrant locks
+    int                 lockCount;
+    // when looking for loops in the graph, marks visited nodes
+    int                 historyMark;
+    // the actual mutex
+    pthread_mutex_t*    mutex;
+    // list of locks directly acquired AFTER this one in the same thread
+    MutexInfoList       children;
+    // list of locks directly acquired BEFORE this one in the same thread
+    MutexInfoList       parents;
+    // list of call stacks when a new link is established to this lock form its parent
+    CallStackList       stacks;
+    // call stack when this lock was acquired last
+    int                 stackDepth;
+    uintptr_t           stackTrace[STACK_TRACE_DEPTH];
+} MutexInfo;
+
+static void growingListInit(GrowingList* list) {
+    list->alloc = 0;
+    list->count = 0;
+    list->data = NULL;
+}
+
+static void growingListAdd(GrowingList* pList, size_t objSize) {
+    if (pList->count == pList->alloc) {
+        size_t oldsize = pList->alloc * objSize;
+        pList->alloc += PAGESIZE / objSize;
+        size_t size = pList->alloc * objSize;
+        pList->data = debug_realloc(pList->data, size, oldsize);
+    }
+    pList->count++;
+}
+
+static void initMutexInfo(MutexInfo* object, pthread_mutex_t* mutex) {
+    object->owner = 0;
+    object->prev = 0;
+    object->next = 0;
+    object->lockCount = 0;
+    object->historyMark = 0;
+    object->mutex = mutex;
+    growingListInit(&object->children);
+    growingListInit(&object->parents);
+    growingListInit(&object->stacks);
+    object->stackDepth = 0;
+}
+
+typedef struct ThreadInfo {
+    pid_t       pid;
+    MutexInfo*  mrl;
+} ThreadInfo;
+
+static void initThreadInfo(ThreadInfo* object, pid_t pid) {
+    object->pid = pid;
+    object->mrl = NULL;
+}
+
+/****************************************************************************/
+
+static MutexInfo* get_mutex_info(pthread_mutex_t *mutex);
+static void mutex_lock_checked(MutexInfo* mrl, MutexInfo* object);
+static void mutex_unlock_checked(MutexInfo* object);
+
+/****************************************************************************/
+
+extern "C" int pthread_mutex_lock_impl(pthread_mutex_t *mutex);
+extern "C" int pthread_mutex_unlock_impl(pthread_mutex_t *mutex);
+
+static int pthread_mutex_lock_unchecked(pthread_mutex_t *mutex) {
+    return pthread_mutex_lock_impl(mutex);
+}
+
+static int pthread_mutex_unlock_unchecked(pthread_mutex_t *mutex) {
+    return pthread_mutex_unlock_impl(mutex);
+}
+
+/****************************************************************************/
+
+static void dup_backtrace(CallStack* stack, size_t count, uintptr_t const* addrs) {
+    stack->depth = count;
+    stack->addrs = DbgAllocLocked<uintptr_t>(count);
+    memcpy(stack->addrs, addrs, count * sizeof(uintptr_t));
+}
+
+/****************************************************************************/
+
+static int historyListHas(
+        const MutexInfoList* list, MutexInfo const * obj) {
+    int i;
+    for (i=0; i<list->count; i++) {
+        if (list->list[i] == obj) {
+            return i;
+        }
+    }
+    return -1;
+}
+
+static void historyListAdd(MutexInfoList* pList, MutexInfo* obj) {
+    growingListAdd(pList, sizeof(MutexInfoListEntry));
+    pList->list[pList->count - 1] = obj;
+}
+
+static int historyListRemove(MutexInfoList* pList, MutexInfo* obj) {
+    int i;
+    for (i = pList->count-1; i >= 0; i--) {
+        if (pList->list[i] == obj) {
+            break;
+        }
+    }
+    if (i < 0) {
+        // not found!
+        return 0;
+    }
+
+    if (i != pList->count-1) {
+        // copy the last entry to the new free slot
+        pList->list[i] = pList->list[pList->count-1];
+    }
+    pList->count--;
+    memset(&pList->list[pList->count], 0, sizeof(MutexInfoListEntry));
+    return 1;
+}
+
+static void linkParentToChild(MutexInfo* parent, MutexInfo* child) {
+    historyListAdd(&parent->children, child);
+    historyListAdd(&child->parents, parent);
+}
+
+static void unlinkParentFromChild(MutexInfo* parent, MutexInfo* child) {
+    historyListRemove(&parent->children, child);
+    historyListRemove(&child->parents, parent);
+}
+
+/****************************************************************************/
+
+static void callstackListAdd(CallStackList* pList,
+        int count, uintptr_t const* addrs) {
+    growingListAdd(pList, sizeof(CallStackListEntry));
+    dup_backtrace(&pList->stack[pList->count - 1], count, addrs);
+}
+
+/****************************************************************************/
+
+/*
+ * Recursively traverse the object hierarchy starting at "obj".  We mark
+ * ourselves on entry and clear the mark on exit.  If we ever encounter
+ * a marked object, we have a cycle.
+ *
+ * Returns "true" if all is well, "false" if we found a cycle.
+ */
+
+static int traverseTree(MutexInfo* obj, MutexInfo const* objParent)
+{
+    /*
+     * Have we been here before?
+     */
+    if (obj->historyMark) {
+        int stackDepth;
+        uintptr_t addrs[STACK_TRACE_DEPTH];
+
+        /* Turn off prediction temporarily in this thread while logging */
+        sPthreadDebugDisabledThread = gettid();
+
+        backtrace_startup();
+
+        LOGW("%s\n", kStartBanner);
+        LOGW("pid: %d, tid: %d >>> %s <<<", getpid(), gettid(), __progname);
+        LOGW("Illegal lock attempt:\n");
+        LOGW("--- pthread_mutex_t at %p\n", obj->mutex);
+        stackDepth = get_backtrace(addrs, STACK_TRACE_DEPTH);
+        log_backtrace(addrs, stackDepth);
+
+        LOGW("+++ Currently held locks in this thread (in reverse order):");
+        MutexInfo* cur = obj;
+        pid_t ourtid = gettid();
+        int i;
+        for (i=0 ; i<cur->parents.count ; i++) {
+            MutexInfo* parent = cur->parents.list[i];
+            if (parent->owner == ourtid) {
+                LOGW("--- pthread_mutex_t at %p\n", parent->mutex);
+                if (sPthreadDebugLevel >= CAPTURE_CALLSTACK) {
+                    log_backtrace(parent->stackTrace, parent->stackDepth);
+                }
+                cur = parent;
+                break;
+            }
+        }
+
+        LOGW("+++ Earlier, the following lock order (from last to first) was established\n");
+        return 0;
+    }
+
+    obj->historyMark = 1;
+
+    MutexInfoList* pList = &obj->children;
+    int result = 1;
+    int i;
+    for (i = pList->count-1; i >= 0; i--) {
+        MutexInfo* child = pList->list[i];
+        if (!traverseTree(child,  obj)) {
+            LOGW("--- pthread_mutex_t at %p\n", obj->mutex);
+            if (sPthreadDebugLevel >= CAPTURE_CALLSTACK) {
+                int index = historyListHas(&obj->parents, objParent);
+                if ((size_t)index < (size_t)obj->stacks.count) {
+                    log_backtrace(obj->stacks.stack[index].addrs, obj->stacks.stack[index].depth);
+                } else {
+                    log_backtrace(obj->stackTrace, obj->stackDepth);
+                }
+            }
+            result = 0;
+            break;
+        }
+    }
+
+    obj->historyMark = 0;
+    return result;
+}
+
+/****************************************************************************/
+
+static void mutex_lock_checked(MutexInfo* mrl, MutexInfo* object)
+{
+    pid_t tid = gettid();
+    if (object->owner == tid) {
+        object->lockCount++;
+        return;
+    }
+
+    object->owner = tid;
+    object->lockCount = 0;
+
+    if (sPthreadDebugLevel >= CAPTURE_CALLSTACK) {
+        // always record the call stack when acquiring a lock.
+        // it's not efficient, but is useful during diagnostics
+        object->stackDepth = get_backtrace(object->stackTrace, STACK_TRACE_DEPTH);
+    }
+
+    // no other locks held in this thread -- no deadlock possible!
+    if (mrl == NULL)
+        return;
+
+    // check if the lock we're trying to acquire is a direct descendant of
+    // the most recently locked mutex in this thread, in which case we're
+    // in a good situation -- no deadlock possible
+    if (historyListHas(&mrl->children, object) >= 0)
+        return;
+
+    pthread_mutex_lock_unchecked(&sDbgLock);
+
+    linkParentToChild(mrl, object);
+    if (!traverseTree(object, mrl)) {
+        backtrace_shutdown();
+        LOGW("%s\n", kEndBanner);
+        unlinkParentFromChild(mrl, object);
+        // reenable pthread debugging for this thread
+        sPthreadDebugDisabledThread = -1;
+    } else {
+        // record the call stack for this link
+        // NOTE: the call stack is added at the same index
+        // as mrl in object->parents[]
+        // ie: object->parents.count == object->stacks.count, which is
+        // also the index.
+        if (sPthreadDebugLevel >= CAPTURE_CALLSTACK) {
+            callstackListAdd(&object->stacks,
+                    object->stackDepth, object->stackTrace);
+        }
+    }
+
+    pthread_mutex_unlock_unchecked(&sDbgLock);
+}
+
+static void mutex_unlock_checked(MutexInfo* object)
+{
+    pid_t tid = gettid();
+    if (object->owner == tid) {
+        if (object->lockCount == 0) {
+            object->owner = 0;
+        } else {
+            object->lockCount--;
+        }
+    }
+}
+
+
+// =============================================================================
+// Hash Table functions
+// =============================================================================
+
+/****************************************************************************/
+
+#define HASHTABLE_SIZE      256
+
+typedef struct HashEntry HashEntry;
+struct HashEntry {
+    size_t slot;
+    HashEntry* prev;
+    HashEntry* next;
+    void* data;
+};
+
+typedef struct HashTable HashTable;
+struct HashTable {
+    HashEntry* slots[HASHTABLE_SIZE];
+};
+
+static HashTable sMutexMap;
+static HashTable sThreadMap;
+
+/****************************************************************************/
+
+static uint32_t get_hashcode(void const * key, size_t keySize)
+{
+    uint32_t h = keySize;
+    char const* data = (char const*)key;
+    size_t i;
+    for (i = 0; i < keySize; i++) {
+        h = h * 31 + *data;
+        data++;
+    }
+    return (uint32_t)h;
+}
+
+static size_t get_index(uint32_t h)
+{
+    // We apply this secondary hashing discovered by Doug Lea to defend
+    // against bad hashes.
+    h += ~(h << 9);
+    h ^= (((unsigned int) h) >> 14);
+    h += (h << 4);
+    h ^= (((unsigned int) h) >> 10);
+    return (size_t)h & (HASHTABLE_SIZE - 1);
+}
+
+/****************************************************************************/
+
+static void hashmap_init(HashTable* table) {
+    memset(table, 0, sizeof(HashTable));
+}
+
+static void hashmap_removeEntry(HashTable* table, HashEntry* entry)
+{
+    HashEntry* prev = entry->prev;
+    HashEntry* next = entry->next;
+    if (prev != NULL) entry->prev->next = next;
+    if (next != NULL) entry->next->prev = prev;
+    if (prev == NULL) {
+        // we are the head of the list. set the head to be next
+        table->slots[entry->slot] = entry->next;
+    }
+}
+
+static HashEntry* hashmap_lookup(HashTable* table,
+        void const* key, size_t ksize,
+        int (*equals)(void const* data, void const* key))
+{
+    const uint32_t hash = get_hashcode(key, ksize);
+    const size_t slot = get_index(hash);
+
+    HashEntry* entry = table->slots[slot];
+    while (entry) {
+        if (equals(entry->data, key)) {
+            break;
+        }
+        entry = entry->next;
+    }
+
+    if (entry == NULL) {
+        // create a new entry
+        entry = DbgAllocLocked<HashEntry>();
+        entry->data = NULL;
+        entry->slot = slot;
+        entry->prev = NULL;
+        entry->next = table->slots[slot];
+        if (entry->next != NULL) {
+            entry->next->prev = entry;
+        }
+        table->slots[slot] = entry;
+    }
+    return entry;
+}
+
+/****************************************************************************/
+
+static int MutexInfo_equals(void const* data, void const* key) {
+    return ((MutexInfo const *)data)->mutex == *(pthread_mutex_t **)key;
+}
+
+static MutexInfo* get_mutex_info(pthread_mutex_t *mutex)
+{
+    pthread_mutex_lock_unchecked(&sDbgLock);
+
+    HashEntry* entry = hashmap_lookup(&sMutexMap,
+            &mutex, sizeof(mutex),
+            &MutexInfo_equals);
+    if (entry->data == NULL) {
+        MutexInfo* mutex_info = DbgAllocLocked<MutexInfo>();
+        entry->data = mutex_info;
+        initMutexInfo(mutex_info, mutex);
+    }
+
+    pthread_mutex_unlock_unchecked(&sDbgLock);
+
+    return (MutexInfo *)entry->data;
+}
+
+/****************************************************************************/
+
+static int ThreadInfo_equals(void const* data, void const* key) {
+    return ((ThreadInfo const *)data)->pid == *(pid_t *)key;
+}
+
+static ThreadInfo* get_thread_info(pid_t pid)
+{
+    pthread_mutex_lock_unchecked(&sDbgLock);
+
+    HashEntry* entry = hashmap_lookup(&sThreadMap,
+            &pid, sizeof(pid),
+            &ThreadInfo_equals);
+    if (entry->data == NULL) {
+        ThreadInfo* thread_info = DbgAllocLocked<ThreadInfo>();
+        entry->data = thread_info;
+        initThreadInfo(thread_info, pid);
+    }
+
+    pthread_mutex_unlock_unchecked(&sDbgLock);
+
+    return (ThreadInfo *)entry->data;
+}
+
+static void push_most_recently_locked(MutexInfo* mrl) {
+    ThreadInfo* tinfo = get_thread_info(gettid());
+    mrl->next = NULL;
+    mrl->prev = tinfo->mrl;
+    tinfo->mrl = mrl;
+}
+
+static void remove_most_recently_locked(MutexInfo* mrl) {
+    ThreadInfo* tinfo = get_thread_info(gettid());
+    if (mrl->next) {
+        (mrl->next)->prev = mrl->prev;
+    }
+    if (mrl->prev) {
+        (mrl->prev)->next = mrl->next;
+    }
+    if (tinfo->mrl == mrl) {
+        tinfo->mrl = mrl->next;
+    }
+}
+
+static MutexInfo* get_most_recently_locked() {
+    ThreadInfo* tinfo = get_thread_info(gettid());
+    return tinfo->mrl;
+}
+
+/****************************************************************************/
+
+/* pthread_debug_init() is called from libc_init_dynamic() just
+ * after system properties have been initialized
+ */
+
+extern "C" __LIBC_HIDDEN__ void pthread_debug_init() {
+    char env[PROP_VALUE_MAX];
+    if (__system_property_get("debug.libc.pthread", env)) {
+        int level = atoi(env);
+        if (level) {
+            LOGI("pthread deadlock detection level %d enabled for pid %d (%s)",
+                    level, getpid(), __progname);
+            hashmap_init(&sMutexMap);
+            sPthreadDebugLevel = level;
+        }
+    }
+}
+
+/*
+ * See if we were allowed to grab the lock at this time.  We do it
+ * *after* acquiring the lock, rather than before, so that we can
+ * freely update the MutexInfo struct.  This seems counter-intuitive,
+ * but our goal is deadlock *prediction* not deadlock *prevention*.
+ * (If we actually deadlock, the situation is easy to diagnose from
+ * a thread dump, so there's no point making a special effort to do
+ * the checks before the lock is held.)
+ */
+
+extern "C" __LIBC_HIDDEN__ void pthread_debug_mutex_lock_check(pthread_mutex_t *mutex)
+{
+    if (sPthreadDebugLevel == 0) return;
+    // prediction disabled for this thread
+    if (sPthreadDebugDisabledThread == gettid())
+        return;
+    MutexInfo* object = get_mutex_info(mutex);
+    MutexInfo* mrl = get_most_recently_locked();
+    mutex_lock_checked(mrl, object);
+    push_most_recently_locked(object);
+}
+
+/*
+ * pthread_debug_mutex_unlock_check() must be called with the mutex
+ * still held (ie: before calling the real unlock)
+ */
+
+extern "C" __LIBC_HIDDEN__ void pthread_debug_mutex_unlock_check(pthread_mutex_t *mutex)
+{
+    if (sPthreadDebugLevel == 0) return;
+    // prediction disabled for this thread
+    if (sPthreadDebugDisabledThread == gettid())
+        return;
+    MutexInfo* object = get_mutex_info(mutex);
+    remove_most_recently_locked(object);
+    mutex_unlock_checked(object);
+}
diff --git a/libc/bionic/pthread_detach.cpp b/libc/bionic/pthread_detach.cpp
new file mode 100644
index 0000000..63f5809
--- /dev/null
+++ b/libc/bionic/pthread_detach.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+
+#include "pthread_accessor.h"
+
+int pthread_detach(pthread_t t) {
+  pthread_accessor thread(t);
+  if (thread.get() == NULL) {
+      return ESRCH;
+  }
+
+  if (thread->attr.flags & PTHREAD_ATTR_FLAG_DETACHED) {
+    return EINVAL; // Already detached.
+  }
+
+  if (thread->join_count > 0) {
+    return 0; // Already being joined; silently do nothing, like glibc.
+  }
+
+  thread->attr.flags |= PTHREAD_ATTR_FLAG_DETACHED;
+  return 0;
+}
diff --git a/libc/bionic/pthread_equal.cpp b/libc/bionic/pthread_equal.cpp
new file mode 100644
index 0000000..493b2c2
--- /dev/null
+++ b/libc/bionic/pthread_equal.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <pthread.h>
+
+int pthread_equal(pthread_t lhs, pthread_t rhs) {
+  return (lhs == rhs ? 1 : 0);
+}
diff --git a/libc/bionic/pthread_getcpuclockid.cpp b/libc/bionic/pthread_getcpuclockid.cpp
new file mode 100644
index 0000000..10046ba
--- /dev/null
+++ b/libc/bionic/pthread_getcpuclockid.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+
+#include "pthread_accessor.h"
+
+int pthread_getcpuclockid(pthread_t t, clockid_t* clockid) {
+  pthread_accessor thread(t);
+  if (thread.get() == NULL) {
+    return ESRCH;
+  }
+
+  enum { CLOCK_IDTYPE_BITS = 3 };
+  *clockid = CLOCK_THREAD_CPUTIME_ID | (thread->tid << CLOCK_IDTYPE_BITS);
+  return 0;
+}
diff --git a/libc/bionic/pthread_getschedparam.cpp b/libc/bionic/pthread_getschedparam.cpp
new file mode 100644
index 0000000..03fa5f2
--- /dev/null
+++ b/libc/bionic/pthread_getschedparam.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+
+#include "ErrnoRestorer.h"
+#include "pthread_accessor.h"
+
+int pthread_getschedparam(pthread_t t, int* policy, sched_param* param) {
+  ErrnoRestorer errno_restorer;
+
+  pthread_accessor thread(t);
+  if (thread.get() == NULL) {
+    return ESRCH;
+  }
+
+  int rc = sched_getparam(thread->tid, param);
+  if (rc == -1) {
+    return errno;
+  }
+  *policy = sched_getscheduler(thread->tid);
+  return 0;
+}
diff --git a/libc/bionic/pthread_internal.h b/libc/bionic/pthread_internal.h
index 58a809a..0eb0e0a 100644
--- a/libc/bionic/pthread_internal.h
+++ b/libc/bionic/pthread_internal.h
@@ -36,22 +36,39 @@
 typedef struct pthread_internal_t
 {
     struct pthread_internal_t*  next;
-    struct pthread_internal_t** prev;
+    struct pthread_internal_t*  prev;
     pthread_attr_t              attr;
-    pid_t                       kernel_id;
+    pid_t                       tid;
+    bool                        allocated_on_heap;
     pthread_cond_t              join_cond;
     int                         join_count;
     void*                       return_value;
     int                         internal_flags;
     __pthread_cleanup_t*        cleanup_stack;
     void**                      tls;         /* thread-local storage area */
+
+    /*
+     * The dynamic linker implements dlerror(3), which makes it hard for us to implement this
+     * per-thread buffer by simply using malloc(3) and free(3).
+     */
+#define __BIONIC_DLERROR_BUFFER_SIZE 512
+    char dlerror_buffer[__BIONIC_DLERROR_BUFFER_SIZE];
 } pthread_internal_t;
 
-int _init_thread(pthread_internal_t* thread, pid_t kernel_id, pthread_attr_t* attr,
-                 void* stack_base, bool add_to_thread_list);
-void _pthread_internal_add( pthread_internal_t*  thread );
+int _init_thread(pthread_internal_t* thread, bool add_to_thread_list);
+void __init_tls(pthread_internal_t* thread);
+void _pthread_internal_add(pthread_internal_t* thread);
 pthread_internal_t* __get_thread(void);
 
+__LIBC_HIDDEN__ void pthread_key_clean_all(void);
+__LIBC_HIDDEN__ void _pthread_internal_remove_locked(pthread_internal_t* thread);
+
+#define PTHREAD_ATTR_FLAG_DETACHED      0x00000001
+#define PTHREAD_ATTR_FLAG_USER_STACK    0x00000002
+
+__LIBC_HIDDEN__ extern pthread_internal_t* gThreadList;
+__LIBC_HIDDEN__ extern pthread_mutex_t gThreadListLock;
+
 /* needed by posix-timers.c */
 
 static __inline__ void timespec_add( struct timespec*  a, const struct timespec*  b )
diff --git a/libc/bionic/pthread_internals.cpp b/libc/bionic/pthread_internals.cpp
new file mode 100644
index 0000000..66bc5b7
--- /dev/null
+++ b/libc/bionic/pthread_internals.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "pthread_internal.h"
+
+#include "bionic_tls.h"
+#include "ScopedPthreadMutexLocker.h"
+
+__LIBC_HIDDEN__ pthread_internal_t* gThreadList = NULL;
+__LIBC_HIDDEN__ pthread_mutex_t gThreadListLock = PTHREAD_MUTEX_INITIALIZER;
+
+void _pthread_internal_remove_locked(pthread_internal_t* thread) {
+  if (thread->next != NULL) {
+    thread->next->prev = thread->prev;
+  }
+  if (thread->prev != NULL) {
+    thread->prev->next = thread->next;
+  } else {
+    gThreadList = thread->next;
+  }
+
+  // The main thread is not heap-allocated. See __libc_init_tls for the declaration,
+  // and __libc_init_common for the point where it's added to the thread list.
+  if (thread->allocated_on_heap) {
+    free(thread);
+  }
+}
+
+__LIBC_ABI_PRIVATE__ void _pthread_internal_add(pthread_internal_t* thread) {
+  ScopedPthreadMutexLocker locker(&gThreadListLock);
+
+  // We insert at the head.
+  thread->next = gThreadList;
+  thread->prev = NULL;
+  if (thread->next != NULL) {
+    thread->next->prev = thread;
+  }
+  gThreadList = thread;
+}
+
+__LIBC_ABI_PRIVATE__ pthread_internal_t* __get_thread(void) {
+  void** tls = reinterpret_cast<void**>(const_cast<void*>(__get_tls()));
+  return reinterpret_cast<pthread_internal_t*>(tls[TLS_SLOT_THREAD_ID]);
+}
diff --git a/libc/bionic/pthread_join.cpp b/libc/bionic/pthread_join.cpp
new file mode 100644
index 0000000..e6acc34
--- /dev/null
+++ b/libc/bionic/pthread_join.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+
+#include "pthread_accessor.h"
+
+int pthread_join(pthread_t t, void ** ret_val) {
+  if (t == pthread_self()) {
+    return EDEADLK;
+  }
+
+  pthread_accessor thread(t);
+  if (thread.get() == NULL) {
+      return ESRCH;
+  }
+
+  if (thread->attr.flags & PTHREAD_ATTR_FLAG_DETACHED) {
+    return EINVAL;
+  }
+
+  // Wait for thread death when needed.
+
+  // If the 'join_count' is negative, this is a 'zombie' thread that
+  // is already dead and without stack/TLS. Otherwise, we need to increment 'join-count'
+  // and wait to be signaled
+  int count = thread->join_count;
+  if (count >= 0) {
+    thread->join_count += 1;
+    pthread_cond_wait(&thread->join_cond, &gThreadListLock);
+    count = --thread->join_count;
+  }
+  if (ret_val) {
+    *ret_val = thread->return_value;
+  }
+
+  // Remove thread from thread list when we're the last joiner or when the
+  // thread was already a zombie.
+  if (count <= 0) {
+    _pthread_internal_remove_locked(thread.get());
+  }
+  return 0;
+}
diff --git a/libc/bionic/pthread_key.cpp b/libc/bionic/pthread_key.cpp
new file mode 100644
index 0000000..b01f9bd
--- /dev/null
+++ b/libc/bionic/pthread_key.cpp
@@ -0,0 +1,257 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <pthread.h>
+
+#include "bionic_tls.h"
+#include "pthread_internal.h"
+
+/* A technical note regarding our thread-local-storage (TLS) implementation:
+ *
+ * There can be up to BIONIC_TLS_SLOTS independent TLS keys in a given process,
+ * The keys below TLS_SLOT_FIRST_USER_SLOT are reserved for Bionic to hold
+ * special thread-specific variables like errno or a pointer to
+ * the current thread's descriptor. These entries cannot be accessed through
+ * pthread_getspecific() / pthread_setspecific() or pthread_key_delete()
+ *
+ * The 'tls_map_t' type defined below implements a shared global map of
+ * currently created/allocated TLS keys and the destructors associated
+ * with them.
+ *
+ * The global TLS map simply contains a bitmap of allocated keys, and
+ * an array of destructors.
+ *
+ * Each thread has a TLS area that is a simple array of BIONIC_TLS_SLOTS void*
+ * pointers. the TLS area of the main thread is stack-allocated in
+ * __libc_init_common, while the TLS area of other threads is placed at
+ * the top of their stack in pthread_create.
+ *
+ * When pthread_key_delete() is called it will erase the key's bitmap bit
+ * and its destructor, and will also clear the key data in the TLS area of
+ * all created threads. As mandated by Posix, it is the responsibility of
+ * the caller of pthread_key_delete() to properly reclaim the objects that
+ * were pointed to by these data fields (either before or after the call).
+ */
+
+#define TLSMAP_BITS       32
+#define TLSMAP_WORDS      ((BIONIC_TLS_SLOTS+TLSMAP_BITS-1)/TLSMAP_BITS)
+#define TLSMAP_WORD(m,k)  (m).map[(k)/TLSMAP_BITS]
+#define TLSMAP_MASK(k)    (1U << ((k)&(TLSMAP_BITS-1)))
+
+static inline bool IsValidUserKey(pthread_key_t key) {
+  return (key >= TLS_SLOT_FIRST_USER_SLOT && key < BIONIC_TLS_SLOTS);
+}
+
+typedef void (*key_destructor_t)(void*);
+
+struct tls_map_t {
+  bool is_initialized;
+
+  /* bitmap of allocated keys */
+  uint32_t map[TLSMAP_WORDS];
+
+  key_destructor_t key_destructors[BIONIC_TLS_SLOTS];
+};
+
+class ScopedTlsMapAccess {
+ public:
+  ScopedTlsMapAccess() {
+    Lock();
+
+    // If this is the first time the TLS map has been accessed,
+    // mark the slots belonging to well-known keys as being in use.
+    // This isn't currently necessary because the well-known keys
+    // can only be accessed directly by bionic itself, do not have
+    // destructors, and all the functions that touch the TLS map
+    // start after the maximum well-known slot.
+    if (!s_tls_map_.is_initialized) {
+      for (pthread_key_t key = 0; key < TLS_SLOT_FIRST_USER_SLOT; ++key) {
+        SetInUse(key, NULL);
+      }
+      s_tls_map_.is_initialized = true;
+    }
+  }
+
+  ~ScopedTlsMapAccess() {
+    Unlock();
+  }
+
+  int CreateKey(pthread_key_t* result, void (*key_destructor)(void*)) {
+    // Take the first unallocated key.
+    for (int key = 0; key < BIONIC_TLS_SLOTS; ++key) {
+      if (!IsInUse(key)) {
+        SetInUse(key, key_destructor);
+        *result = key;
+        return 0;
+      }
+    }
+
+    // We hit PTHREAD_KEYS_MAX. POSIX says EAGAIN for this case.
+    return EAGAIN;
+  }
+
+  void DeleteKey(pthread_key_t key) {
+    TLSMAP_WORD(s_tls_map_, key) &= ~TLSMAP_MASK(key);
+    s_tls_map_.key_destructors[key] = NULL;
+  }
+
+  bool IsInUse(pthread_key_t key) {
+    return (TLSMAP_WORD(s_tls_map_, key) & TLSMAP_MASK(key)) != 0;
+  }
+
+  void SetInUse(pthread_key_t key, void (*key_destructor)(void*)) {
+    TLSMAP_WORD(s_tls_map_, key) |= TLSMAP_MASK(key);
+    s_tls_map_.key_destructors[key] = key_destructor;
+  }
+
+  // Called from pthread_exit() to remove all TLS key data
+  // from this thread's TLS area. This must call the destructor of all keys
+  // that have a non-NULL data value and a non-NULL destructor.
+  void CleanAll() {
+    void** tls = (void**)__get_tls();
+
+    // Because destructors can do funky things like deleting/creating other
+    // keys, we need to implement this in a loop.
+    for (int rounds = PTHREAD_DESTRUCTOR_ITERATIONS; rounds > 0; --rounds) {
+      size_t called_destructor_count = 0;
+      for (int key = 0; key < BIONIC_TLS_SLOTS; ++key) {
+        if (IsInUse(key)) {
+          void* data = tls[key];
+          void (*key_destructor)(void*) = s_tls_map_.key_destructors[key];
+
+          if (data != NULL && key_destructor != NULL) {
+            // we need to clear the key data now, this will prevent the
+            // destructor (or a later one) from seeing the old value if
+            // it calls pthread_getspecific() for some odd reason
+
+            // we do not do this if 'key_destructor == NULL' just in case another
+            // destructor function might be responsible for manually
+            // releasing the corresponding data.
+            tls[key] = NULL;
+
+            // because the destructor is free to call pthread_key_create
+            // and/or pthread_key_delete, we need to temporarily unlock
+            // the TLS map
+            Unlock();
+            (*key_destructor)(data);
+            Lock();
+            ++called_destructor_count;
+          }
+        }
+      }
+
+      // If we didn't call any destructors, there is no need to check the TLS data again.
+      if (called_destructor_count == 0) {
+        break;
+      }
+    }
+  }
+
+ private:
+  static tls_map_t s_tls_map_;
+  static pthread_mutex_t s_tls_map_lock_;
+
+  void Lock() {
+    pthread_mutex_lock(&s_tls_map_lock_);
+  }
+
+  void Unlock() {
+    pthread_mutex_unlock(&s_tls_map_lock_);
+  }
+};
+
+tls_map_t ScopedTlsMapAccess::s_tls_map_;
+pthread_mutex_t ScopedTlsMapAccess::s_tls_map_lock_;
+
+__LIBC_HIDDEN__ void pthread_key_clean_all() {
+  ScopedTlsMapAccess tls_map;
+  tls_map.CleanAll();
+}
+
+int pthread_key_create(pthread_key_t* key, void (*key_destructor)(void*)) {
+  ScopedTlsMapAccess tls_map;
+  return tls_map.CreateKey(key, key_destructor);
+}
+
+// Deletes a pthread_key_t. note that the standard mandates that this does
+// not call the destructors for non-NULL key values. Instead, it is the
+// responsibility of the caller to properly dispose of the corresponding data
+// and resources, using any means it finds suitable.
+int pthread_key_delete(pthread_key_t key) {
+  ScopedTlsMapAccess tls_map;
+
+  if (!IsValidUserKey(key) || !tls_map.IsInUse(key)) {
+    return EINVAL;
+  }
+
+  // Clear value in all threads.
+  pthread_mutex_lock(&gThreadListLock);
+  for (pthread_internal_t*  t = gThreadList; t != NULL; t = t->next) {
+    // Avoid zombie threads with a negative 'join_count'. These are really
+    // already dead and don't have a TLS area anymore.
+
+    // Similarly, it is possible to have t->tls == NULL for threads that
+    // were just recently created through pthread_create() but whose
+    // startup trampoline (__thread_entry) hasn't been run yet by the
+    // scheduler. t->tls will also be NULL after it's stack has been
+    // unmapped but before the ongoing pthread_join() is finished.
+    // so check for this too.
+    if (t->join_count < 0 || !t->tls) {
+      continue;
+    }
+
+    t->tls[key] = NULL;
+  }
+  tls_map.DeleteKey(key);
+
+  pthread_mutex_unlock(&gThreadListLock);
+  return 0;
+}
+
+void* pthread_getspecific(pthread_key_t key) {
+  if (!IsValidUserKey(key)) {
+    return NULL;
+  }
+
+  // For performance reasons, we do not lock/unlock the global TLS map
+  // to check that the key is properly allocated. If the key was not
+  // allocated, the value read from the TLS should always be NULL
+  // due to pthread_key_delete() clearing the values for all threads.
+  return (void *)(((unsigned *)__get_tls())[key]);
+}
+
+int pthread_setspecific(pthread_key_t key, const void* ptr) {
+  ScopedTlsMapAccess tls_map;
+
+  if (!IsValidUserKey(key) || !tls_map.IsInUse(key)) {
+    return EINVAL;
+  }
+
+  ((uint32_t *)__get_tls())[key] = (uint32_t)ptr;
+  return 0;
+}
diff --git a/libc/bionic/pthread_kill.cpp b/libc/bionic/pthread_kill.cpp
new file mode 100644
index 0000000..54f71ee
--- /dev/null
+++ b/libc/bionic/pthread_kill.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <unistd.h>
+
+#include "ErrnoRestorer.h"
+#include "pthread_accessor.h"
+
+extern "C" int tgkill(int tgid, int tid, int sig);
+
+int pthread_kill(pthread_t t, int sig) {
+  ErrnoRestorer errno_restorer;
+
+  pthread_accessor thread(t);
+  if (thread.get() == NULL) {
+    return ESRCH;
+  }
+
+  // There's a race here, but it's one we share with all other C libraries.
+  pid_t tid = thread->tid;
+  thread.Unlock();
+
+  int rc = tgkill(getpid(), tid, sig);
+  if (rc == -1) {
+    return errno;
+  }
+
+  return 0;
+}
diff --git a/libc/bionic/pthread_self.cpp b/libc/bionic/pthread_self.cpp
new file mode 100644
index 0000000..0a83f07
--- /dev/null
+++ b/libc/bionic/pthread_self.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "pthread_internal.h"
+
+pthread_t pthread_self() {
+  return reinterpret_cast<pthread_t>(__get_thread());
+}
diff --git a/libc/bionic/pthread_setname_np.cpp b/libc/bionic/pthread_setname_np.cpp
new file mode 100644
index 0000000..6162aea
--- /dev/null
+++ b/libc/bionic/pthread_setname_np.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <pthread.h>
+
+#include <fcntl.h>
+#include <stdio.h> // For snprintf.
+#include <sys/prctl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "pthread_internal.h"
+#include "private/ErrnoRestorer.h"
+
+// This value is not exported by kernel headers.
+#define MAX_TASK_COMM_LEN 16
+#define TASK_COMM_FMT "/proc/self/task/%d/comm"
+
+int pthread_setname_np(pthread_t thread, const char* thread_name) {
+  ErrnoRestorer errno_restorer;
+
+  if (thread == 0 || thread_name == NULL) {
+    return EINVAL;
+  }
+
+  size_t thread_name_len = strlen(thread_name);
+  if (thread_name_len >= MAX_TASK_COMM_LEN) {
+    return ERANGE;
+  }
+
+  // Changing our own name is an easy special case.
+  if (thread == pthread_self()) {
+    return prctl(PR_SET_NAME, thread_name) ? errno : 0;
+  }
+
+  // Have to change another thread's name.
+  pthread_internal_t* t = reinterpret_cast<pthread_internal_t*>(thread);
+  char comm_name[sizeof(TASK_COMM_FMT) + 8];
+  snprintf(comm_name, sizeof(comm_name), TASK_COMM_FMT, t->tid);
+  int fd = open(comm_name, O_WRONLY);
+  if (fd == -1) {
+    return errno;
+  }
+  ssize_t n = TEMP_FAILURE_RETRY(write(fd, thread_name, thread_name_len));
+  close(fd);
+
+  if (n < 0) {
+    return errno;
+  } else if ((size_t)n != thread_name_len) {
+    return EIO;
+  }
+  return 0;
+}
diff --git a/libc/bionic/pthread_setschedparam.cpp b/libc/bionic/pthread_setschedparam.cpp
new file mode 100644
index 0000000..c383cca
--- /dev/null
+++ b/libc/bionic/pthread_setschedparam.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+
+#include "ErrnoRestorer.h"
+#include "pthread_accessor.h"
+
+int pthread_setschedparam(pthread_t t, int policy, struct sched_param const* param) {
+  ErrnoRestorer errno_restorer;
+
+  pthread_accessor thread(t);
+  if (thread.get() == NULL) {
+    return ESRCH;
+  }
+
+  int rc = sched_setscheduler(thread->tid, policy, param);
+  if (rc == -1) {
+    return errno;
+  }
+  return 0;
+}
diff --git a/libc/bionic/pthread_sigmask.cpp b/libc/bionic/pthread_sigmask.cpp
new file mode 100644
index 0000000..e4e1b2b
--- /dev/null
+++ b/libc/bionic/pthread_sigmask.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+
+#include "private/ErrnoRestorer.h"
+#include "private/kernel_sigset_t.h"
+
+extern "C" int __rt_sigprocmask(int, const kernel_sigset_t*, kernel_sigset_t*, size_t);
+
+int pthread_sigmask(int how, const sigset_t* iset, sigset_t* oset) {
+  ErrnoRestorer errno_restorer;
+
+  // 'in_set_ptr' is the second parameter to __rt_sigprocmask. It must be NULL
+  // if 'set' is NULL to ensure correct semantics (which in this case would
+  // be to ignore 'how' and return the current signal set into 'oset').
+  kernel_sigset_t in_set;
+  kernel_sigset_t* in_set_ptr = NULL;
+  if (iset != NULL) {
+    in_set.set(iset);
+    in_set_ptr = &in_set;
+  }
+
+  kernel_sigset_t out_set;
+  if (__rt_sigprocmask(how, in_set_ptr, &out_set, sizeof(out_set)) == -1) {
+    return errno;
+  }
+
+  if (oset != NULL) {
+    *oset = out_set.bionic;
+  }
+
+  return 0;
+}
diff --git a/libc/unistd/ptsname.c b/libc/bionic/ptsname.c
similarity index 100%
rename from libc/unistd/ptsname.c
rename to libc/bionic/ptsname.c
diff --git a/libc/unistd/ptsname_r.c b/libc/bionic/ptsname_r.c
similarity index 100%
rename from libc/unistd/ptsname_r.c
rename to libc/bionic/ptsname_r.c
diff --git a/libc/unistd/pwrite.c b/libc/bionic/pwrite.c
similarity index 100%
rename from libc/unistd/pwrite.c
rename to libc/bionic/pwrite.c
diff --git a/libc/bionic/raise.cpp b/libc/bionic/raise.cpp
new file mode 100644
index 0000000..f69d90b
--- /dev/null
+++ b/libc/bionic/raise.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <pthread.h>
+
+int raise(int sig) {
+  int rc = pthread_kill(pthread_self(), sig);
+  if (rc != 0) {
+    errno = rc;
+    return -1;
+  }
+  return 0;
+}
diff --git a/libc/bionic/realpath.c b/libc/bionic/realpath.c
deleted file mode 100644
index b909831..0000000
--- a/libc/bionic/realpath.c
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright (c) 2003 Constantin S. Svintsoff <kostik@iclub.nsu.ru>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The names of the authors may not be used to endorse or promote
- *    products derived from this software without specific prior written
- *    permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)realpath.c	8.1 (Berkeley) 2/16/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.0.0/lib/libc/stdlib/realpath.c 217144 2011-01-08 11:04:30Z kib $");
-
-#include <sys/param.h>
-#include <sys/stat.h>
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-/*
- * Find the real name of path, by removing all ".", ".." and symlink
- * components.  Returns (resolved) on success, or (NULL) on failure,
- * in which case the path which caused trouble is left in (resolved).
- */
-char *
-realpath(const char * __restrict path, char * __restrict resolved)
-{
-	struct stat sb;
-	char *p, *q, *s;
-	size_t left_len, resolved_len;
-	unsigned symlinks;
-	int m, serrno, slen;
-	char left[PATH_MAX], next_token[PATH_MAX], symlink[PATH_MAX];
-
-	if (path == NULL) {
-		errno = EINVAL;
-		return (NULL);
-	}
-	if (path[0] == '\0') {
-		errno = ENOENT;
-		return (NULL);
-	}
-	serrno = errno;
-	if (resolved == NULL) {
-		resolved = malloc(PATH_MAX);
-		if (resolved == NULL)
-			return (NULL);
-		m = 1;
-	} else
-		m = 0;
-	symlinks = 0;
-	if (path[0] == '/') {
-		resolved[0] = '/';
-		resolved[1] = '\0';
-		if (path[1] == '\0')
-			return (resolved);
-		resolved_len = 1;
-		left_len = strlcpy(left, path + 1, sizeof(left));
-	} else {
-		if (getcwd(resolved, PATH_MAX) == NULL) {
-			if (m)
-				free(resolved);
-			else {
-				resolved[0] = '.';
-				resolved[1] = '\0';
-			}
-			return (NULL);
-		}
-		resolved_len = strlen(resolved);
-		left_len = strlcpy(left, path, sizeof(left));
-	}
-	if (left_len >= sizeof(left) || resolved_len >= PATH_MAX) {
-		if (m)
-			free(resolved);
-		errno = ENAMETOOLONG;
-		return (NULL);
-	}
-
-	/*
-	 * Iterate over path components in `left'.
-	 */
-	while (left_len != 0) {
-		/*
-		 * Extract the next path component and adjust `left'
-		 * and its length.
-		 */
-		p = strchr(left, '/');
-		s = p ? p : left + left_len;
-		if (s - left >= sizeof(next_token)) {
-			if (m)
-				free(resolved);
-			errno = ENAMETOOLONG;
-			return (NULL);
-		}
-		memcpy(next_token, left, s - left);
-		next_token[s - left] = '\0';
-		left_len -= s - left;
-		if (p != NULL)
-			memmove(left, s + 1, left_len + 1);
-		if (resolved[resolved_len - 1] != '/') {
-			if (resolved_len + 1 >= PATH_MAX) {
-				if (m)
-					free(resolved);
-				errno = ENAMETOOLONG;
-				return (NULL);
-			}
-			resolved[resolved_len++] = '/';
-			resolved[resolved_len] = '\0';
-		}
-		if (next_token[0] == '\0')
-			continue;
-		else if (strcmp(next_token, ".") == 0)
-			continue;
-		else if (strcmp(next_token, "..") == 0) {
-			/*
-			 * Strip the last path component except when we have
-			 * single "/"
-			 */
-			if (resolved_len > 1) {
-				resolved[resolved_len - 1] = '\0';
-				q = strrchr(resolved, '/') + 1;
-				*q = '\0';
-				resolved_len = q - resolved;
-			}
-			continue;
-		}
-
-		/*
-		 * Append the next path component and lstat() it. If
-		 * lstat() fails we still can return successfully if
-		 * there are no more path components left.
-		 */
-		resolved_len = strlcat(resolved, next_token, PATH_MAX);
-		if (resolved_len >= PATH_MAX) {
-			if (m)
-				free(resolved);
-			errno = ENAMETOOLONG;
-			return (NULL);
-		}
-		if (lstat(resolved, &sb) != 0) {
-			if (errno == ENOENT && p == NULL) {
-				errno = serrno;
-				return (resolved);
-			}
-			if (m)
-				free(resolved);
-			return (NULL);
-		}
-		if (S_ISLNK(sb.st_mode)) {
-			if (symlinks++ > MAXSYMLINKS) {
-				if (m)
-					free(resolved);
-				errno = ELOOP;
-				return (NULL);
-			}
-			slen = readlink(resolved, symlink, sizeof(symlink) - 1);
-			if (slen < 0) {
-				if (m)
-					free(resolved);
-				return (NULL);
-			}
-			symlink[slen] = '\0';
-			if (symlink[0] == '/') {
-				resolved[1] = 0;
-				resolved_len = 1;
-			} else if (resolved_len > 1) {
-				/* Strip the last path component. */
-				resolved[resolved_len - 1] = '\0';
-				q = strrchr(resolved, '/') + 1;
-				*q = '\0';
-				resolved_len = q - resolved;
-			}
-
-			/*
-			 * If there are any path components left, then
-			 * append them to symlink. The result is placed
-			 * in `left'.
-			 */
-			if (p != NULL) {
-				if (symlink[slen - 1] != '/') {
-					if (slen + 1 >= sizeof(symlink)) {
-						if (m)
-							free(resolved);
-						errno = ENAMETOOLONG;
-						return (NULL);
-					}
-					symlink[slen] = '/';
-					symlink[slen + 1] = 0;
-				}
-				left_len = strlcat(symlink, left, sizeof(left));
-				if (left_len >= sizeof(left)) {
-					if (m)
-						free(resolved);
-					errno = ENAMETOOLONG;
-					return (NULL);
-				}
-			}
-			left_len = strlcpy(left, symlink, sizeof(left));
-		}
-	}
-
-	/*
-	 * Remove trailing slash except when the resolved pathname
-	 * is a single "/".
-	 */
-	if (resolved_len > 1 && resolved[resolved_len - 1] == '/')
-		resolved[resolved_len - 1] = '\0';
-	return (resolved);
-}
diff --git a/libc/unistd/reboot.c b/libc/bionic/reboot.c
similarity index 100%
rename from libc/unistd/reboot.c
rename to libc/bionic/reboot.c
diff --git a/libc/unistd/recv.c b/libc/bionic/recv.c
similarity index 100%
rename from libc/unistd/recv.c
rename to libc/bionic/recv.c
diff --git a/libc/bionic/sbrk.cpp b/libc/bionic/sbrk.cpp
new file mode 100644
index 0000000..6c9b534
--- /dev/null
+++ b/libc/bionic/sbrk.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+#include <errno.h>
+
+/* Shared with brk.c. */
+extern "C" {
+  void* __bionic_brk; // TODO: should be __LIBC_HIDDEN__ but accidentally exported by NDK :-(
+}
+
+void* sbrk(ptrdiff_t increment) {
+  if (__bionic_brk == NULL) {
+    __bionic_brk = __brk(NULL);
+  }
+
+  void* original_brk = __bionic_brk;
+  void* desired_brk = (void*) ((uintptr_t) original_brk + increment);
+
+  void* new_brk = __brk(desired_brk);
+  if (new_brk == (void*) -1) {
+    return new_brk;
+  } else if (new_brk < desired_brk) {
+    errno = ENOMEM;
+    return (void*) -1;
+  }
+
+  __bionic_brk = new_brk;
+  return original_brk;
+}
diff --git a/libc/bionic/scandir.cpp b/libc/bionic/scandir.cpp
new file mode 100644
index 0000000..dd22b22
--- /dev/null
+++ b/libc/bionic/scandir.cpp
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dirent.h>
+
+#include <errno.h>
+#include <stdlib.h>
+
+#include "private/ScopedReaddir.h"
+
+// A smart pointer to the scandir dirent**.
+class ScandirResult {
+ public:
+  ScandirResult() : names_(NULL), size_(0), capacity_(0) {
+  }
+
+  ~ScandirResult() {
+    while (size_ > 0) {
+      free(names_[--size_]);
+    }
+    free(names_);
+  }
+
+  size_t size() {
+    return size_;
+  }
+
+  dirent** release() {
+    dirent** result = names_;
+    names_ = NULL;
+    size_ = capacity_ = 0;
+    return result;
+  }
+
+  bool Add(dirent* entry) {
+    if (size_ >= capacity_) {
+      size_t new_capacity = capacity_ + 32;
+      dirent** new_names = (dirent**) realloc(names_, new_capacity * sizeof(dirent*));
+      if (new_names == NULL) {
+        return false;
+      }
+      names_ = new_names;
+      capacity_ = new_capacity;
+    }
+
+    dirent* copy = CopyDirent(entry);
+    if (copy == NULL) {
+      return false;
+    }
+    names_[size_++] = copy;
+    return true;
+  }
+
+  void Sort(int (*comparator)(const dirent**, const dirent**)) {
+    // If we have entries and a comparator, sort them.
+    if (size_ > 0 && comparator != NULL) {
+      qsort(names_, size_, sizeof(dirent*), (int (*)(const void*, const void*)) comparator);
+    }
+  }
+
+ private:
+  dirent** names_;
+  size_t size_;
+  size_t capacity_;
+
+  static dirent* CopyDirent(dirent* original) {
+    // Allocate the minimum number of bytes necessary, rounded up to a 4-byte boundary.
+    size_t size = ((original->d_reclen + 3) & ~3);
+    dirent* copy = (dirent*) malloc(size);
+    memcpy(copy, original, original->d_reclen);
+    return copy;
+  }
+
+  // Disallow copy and assignment.
+  ScandirResult(const ScandirResult&);
+  void operator=(const ScandirResult&);
+};
+
+int scandir(const char* dirname, dirent*** name_list,
+            int (*filter)(const dirent*),
+            int (*comparator)(const dirent**, const dirent**)) {
+  ScopedReaddir reader(dirname);
+  if (reader.IsBad()) {
+    return -1;
+  }
+
+  ScandirResult names;
+  dirent* entry;
+  while ((entry = reader.ReadEntry()) != NULL) {
+    // If we have a filter, skip names that don't match.
+    if (filter != NULL && !(*filter)(entry)) {
+      continue;
+    }
+    names.Add(entry);
+  }
+
+  names.Sort(comparator);
+
+  size_t size = names.size();
+  *name_list = names.release();
+  return size;
+}
diff --git a/libc/unistd/send.c b/libc/bionic/send.c
similarity index 100%
rename from libc/unistd/send.c
rename to libc/bionic/send.c
diff --git a/libc/unistd/setegid.c b/libc/bionic/setegid.c
similarity index 100%
rename from libc/unistd/setegid.c
rename to libc/bionic/setegid.c
diff --git a/libc/unistd/seteuid.c b/libc/bionic/seteuid.c
similarity index 100%
rename from libc/unistd/seteuid.c
rename to libc/bionic/seteuid.c
diff --git a/libc/bionic/setlocale.cpp b/libc/bionic/setlocale.cpp
new file mode 100644
index 0000000..e8fdc9e
--- /dev/null
+++ b/libc/bionic/setlocale.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <locale.h>
+#include <stdlib.h>
+
+// setlocale(3) always fails on bionic.
+char* setlocale(int /*category*/, char const* /*locale*/) {
+    return NULL;
+}
diff --git a/libc/unistd/setpgrp.c b/libc/bionic/setpgrp.c
similarity index 100%
rename from libc/unistd/setpgrp.c
rename to libc/bionic/setpgrp.c
diff --git a/libc/unistd/setresuid.c b/libc/bionic/setresuid.c
similarity index 100%
rename from libc/unistd/setresuid.c
rename to libc/bionic/setresuid.c
diff --git a/libc/unistd/setreuid.c b/libc/bionic/setreuid.c
similarity index 100%
rename from libc/unistd/setreuid.c
rename to libc/bionic/setreuid.c
diff --git a/libc/unistd/setuid.c b/libc/bionic/setuid.c
similarity index 100%
rename from libc/unistd/setuid.c
rename to libc/bionic/setuid.c
diff --git a/libc/bionic/sha1.c b/libc/bionic/sha1.c
deleted file mode 100644
index efa95a5..0000000
--- a/libc/bionic/sha1.c
+++ /dev/null
@@ -1,270 +0,0 @@
-/*	$NetBSD: sha1.c,v 1.1 2005/12/20 20:29:40 christos Exp $	*/
-/*	$OpenBSD: sha1.c,v 1.9 1997/07/23 21:12:32 kstailey Exp $	*/
-
-/*
- * SHA-1 in C
- * By Steve Reid <steve@edmweb.com>
- * 100% Public Domain
- *
- * Test Vectors (from FIPS PUB 180-1)
- * "abc"
- *   A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
- * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
- *   84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
- * A million repetitions of "a"
- *   34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
- */
-
-#define SHA1HANDSOFF		/* Copies data before messing with it. */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <assert.h>
-#include <sha1.h>
-#include <string.h>
-
-#if HAVE_NBTOOL_CONFIG_H
-#include "nbtool_config.h"
-#endif
-
-#if !HAVE_SHA1_H
-
-#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
-
-/*
- * blk0() and blk() perform the initial expand.
- * I got the idea of expanding during the round function from SSLeay
- */
-#if BYTE_ORDER == LITTLE_ENDIAN
-# define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
-    |(rol(block->l[i],8)&0x00FF00FF))
-#else
-# define blk0(i) block->l[i]
-#endif
-#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
-    ^block->l[(i+2)&15]^block->l[i&15],1))
-
-/*
- * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1
- */
-#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
-#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
-#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
-#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
-#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
-
-typedef union {
-    u_char c[64];
-    u_int l[16];
-} CHAR64LONG16;
-
-/* old sparc64 gcc could not compile this */
-#undef SPARC64_GCC_WORKAROUND
-#if defined(__sparc64__) && defined(__GNUC__) && __GNUC__ < 3
-#define SPARC64_GCC_WORKAROUND
-#endif
-
-#ifdef SPARC64_GCC_WORKAROUND
-void do_R01(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *);
-void do_R2(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *);
-void do_R3(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *);
-void do_R4(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *);
-
-#define nR0(v,w,x,y,z,i) R0(*v,*w,*x,*y,*z,i)
-#define nR1(v,w,x,y,z,i) R1(*v,*w,*x,*y,*z,i)
-#define nR2(v,w,x,y,z,i) R2(*v,*w,*x,*y,*z,i)
-#define nR3(v,w,x,y,z,i) R3(*v,*w,*x,*y,*z,i)
-#define nR4(v,w,x,y,z,i) R4(*v,*w,*x,*y,*z,i)
-
-void
-do_R01(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *block)
-{
-    nR0(a,b,c,d,e, 0); nR0(e,a,b,c,d, 1); nR0(d,e,a,b,c, 2); nR0(c,d,e,a,b, 3);
-    nR0(b,c,d,e,a, 4); nR0(a,b,c,d,e, 5); nR0(e,a,b,c,d, 6); nR0(d,e,a,b,c, 7);
-    nR0(c,d,e,a,b, 8); nR0(b,c,d,e,a, 9); nR0(a,b,c,d,e,10); nR0(e,a,b,c,d,11);
-    nR0(d,e,a,b,c,12); nR0(c,d,e,a,b,13); nR0(b,c,d,e,a,14); nR0(a,b,c,d,e,15);
-    nR1(e,a,b,c,d,16); nR1(d,e,a,b,c,17); nR1(c,d,e,a,b,18); nR1(b,c,d,e,a,19);
-}
-
-void
-do_R2(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *block)
-{
-    nR2(a,b,c,d,e,20); nR2(e,a,b,c,d,21); nR2(d,e,a,b,c,22); nR2(c,d,e,a,b,23);
-    nR2(b,c,d,e,a,24); nR2(a,b,c,d,e,25); nR2(e,a,b,c,d,26); nR2(d,e,a,b,c,27);
-    nR2(c,d,e,a,b,28); nR2(b,c,d,e,a,29); nR2(a,b,c,d,e,30); nR2(e,a,b,c,d,31);
-    nR2(d,e,a,b,c,32); nR2(c,d,e,a,b,33); nR2(b,c,d,e,a,34); nR2(a,b,c,d,e,35);
-    nR2(e,a,b,c,d,36); nR2(d,e,a,b,c,37); nR2(c,d,e,a,b,38); nR2(b,c,d,e,a,39);
-}
-
-void
-do_R3(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *block)
-{
-    nR3(a,b,c,d,e,40); nR3(e,a,b,c,d,41); nR3(d,e,a,b,c,42); nR3(c,d,e,a,b,43);
-    nR3(b,c,d,e,a,44); nR3(a,b,c,d,e,45); nR3(e,a,b,c,d,46); nR3(d,e,a,b,c,47);
-    nR3(c,d,e,a,b,48); nR3(b,c,d,e,a,49); nR3(a,b,c,d,e,50); nR3(e,a,b,c,d,51);
-    nR3(d,e,a,b,c,52); nR3(c,d,e,a,b,53); nR3(b,c,d,e,a,54); nR3(a,b,c,d,e,55);
-    nR3(e,a,b,c,d,56); nR3(d,e,a,b,c,57); nR3(c,d,e,a,b,58); nR3(b,c,d,e,a,59);
-}
-
-void
-do_R4(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *block)
-{
-    nR4(a,b,c,d,e,60); nR4(e,a,b,c,d,61); nR4(d,e,a,b,c,62); nR4(c,d,e,a,b,63);
-    nR4(b,c,d,e,a,64); nR4(a,b,c,d,e,65); nR4(e,a,b,c,d,66); nR4(d,e,a,b,c,67);
-    nR4(c,d,e,a,b,68); nR4(b,c,d,e,a,69); nR4(a,b,c,d,e,70); nR4(e,a,b,c,d,71);
-    nR4(d,e,a,b,c,72); nR4(c,d,e,a,b,73); nR4(b,c,d,e,a,74); nR4(a,b,c,d,e,75);
-    nR4(e,a,b,c,d,76); nR4(d,e,a,b,c,77); nR4(c,d,e,a,b,78); nR4(b,c,d,e,a,79);
-}
-#endif
-
-/*
- * Hash a single 512-bit block. This is the core of the algorithm.
- */
-void SHA1Transform(state, buffer)
-    u_int32_t state[5];
-    const u_char buffer[64];
-{
-    u_int32_t a, b, c, d, e;
-    CHAR64LONG16 *block;
-
-#ifdef SHA1HANDSOFF
-    CHAR64LONG16 workspace;
-#endif
-
-    assert(buffer != 0);
-    assert(state != 0);
-
-#ifdef SHA1HANDSOFF
-    block = &workspace;
-    (void)memcpy(block, buffer, 64);
-#else
-    block = (CHAR64LONG16 *)(void *)buffer;
-#endif
-
-    /* Copy context->state[] to working vars */
-    a = state[0];
-    b = state[1];
-    c = state[2];
-    d = state[3];
-    e = state[4];
-
-#ifdef SPARC64_GCC_WORKAROUND
-    do_R01(&a, &b, &c, &d, &e, block);
-    do_R2(&a, &b, &c, &d, &e, block);
-    do_R3(&a, &b, &c, &d, &e, block);
-    do_R4(&a, &b, &c, &d, &e, block);
-#else
-    /* 4 rounds of 20 operations each. Loop unrolled. */
-    R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
-    R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
-    R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
-    R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
-    R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
-    R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
-    R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
-    R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
-    R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
-    R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
-    R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
-    R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
-    R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
-    R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
-    R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
-    R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
-    R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
-    R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
-    R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
-    R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
-#endif
-
-    /* Add the working vars back into context.state[] */
-    state[0] += a;
-    state[1] += b;
-    state[2] += c;
-    state[3] += d;
-    state[4] += e;
-
-    /* Wipe variables */
-    a = b = c = d = e = 0;
-}
-
-
-/*
- * SHA1Init - Initialize new context
- */
-void SHA1Init(context)
-    SHA1_CTX *context;
-{
-
-    assert(context != 0);
-
-    /* SHA1 initialization constants */
-    context->state[0] = 0x67452301;
-    context->state[1] = 0xEFCDAB89;
-    context->state[2] = 0x98BADCFE;
-    context->state[3] = 0x10325476;
-    context->state[4] = 0xC3D2E1F0;
-    context->count[0] = context->count[1] = 0;
-}
-
-
-/*
- * Run your data through this.
- */
-void SHA1Update(context, data, len)
-    SHA1_CTX *context;
-    const u_char *data;
-    u_int len;
-{
-    u_int i, j;
-
-    assert(context != 0);
-    assert(data != 0);
-
-    j = context->count[0];
-    if ((context->count[0] += len << 3) < j)
-	context->count[1] += (len>>29)+1;
-    j = (j >> 3) & 63;
-    if ((j + len) > 63) {
-	(void)memcpy(&context->buffer[j], data, (i = 64-j));
-	SHA1Transform(context->state, context->buffer);
-	for ( ; i + 63 < len; i += 64)
-	    SHA1Transform(context->state, &data[i]);
-	j = 0;
-    } else {
-	i = 0;
-    }
-    (void)memcpy(&context->buffer[j], &data[i], len - i);
-}
-
-
-/*
- * Add padding and return the message digest.
- */
-void SHA1Final(digest, context)
-    u_char digest[20];
-    SHA1_CTX* context;
-{
-    u_int i;
-    u_char finalcount[8];
-
-    assert(digest != 0);
-    assert(context != 0);
-
-    for (i = 0; i < 8; i++) {
-	finalcount[i] = (u_char)((context->count[(i >= 4 ? 0 : 1)]
-	 >> ((3-(i & 3)) * 8) ) & 255);	 /* Endian independent */
-    }
-    SHA1Update(context, (const u_char *)"\200", 1);
-    while ((context->count[0] & 504) != 448)
-	SHA1Update(context, (const u_char *)"\0", 1);
-    SHA1Update(context, finalcount, 8);  /* Should cause a SHA1Transform() */
-
-    if (digest) {
-	for (i = 0; i < 20; i++)
-	    digest[i] = (u_char)
-		((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
-    }
-}
-
-#endif /* HAVE_SHA1_H */
diff --git a/libc/unistd/sigblock.c b/libc/bionic/sigblock.c
similarity index 100%
rename from libc/unistd/sigblock.c
rename to libc/bionic/sigblock.c
diff --git a/libc/unistd/siginterrupt.c b/libc/bionic/siginterrupt.c
similarity index 100%
rename from libc/unistd/siginterrupt.c
rename to libc/bionic/siginterrupt.c
diff --git a/libc/unistd/siglist.c b/libc/bionic/siglist.c
similarity index 100%
rename from libc/unistd/siglist.c
rename to libc/bionic/siglist.c
diff --git a/libc/unistd/signal.c b/libc/bionic/signal.c
similarity index 100%
rename from libc/unistd/signal.c
rename to libc/bionic/signal.c
diff --git a/libc/bionic/signalfd.cpp b/libc/bionic/signalfd.cpp
new file mode 100644
index 0000000..b7e6474
--- /dev/null
+++ b/libc/bionic/signalfd.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/signalfd.h>
+
+#include <private/kernel_sigset_t.h>
+
+extern "C" int signalfd4(int fd, kernel_sigset_t* mask, size_t sizemask, int flags);
+
+int signalfd(int fd, const sigset_t* mask, int flags) {
+  kernel_sigset_t in_set(mask);
+  return signalfd4(fd, &in_set, sizeof(in_set), flags);
+}
diff --git a/libc/unistd/signame.c b/libc/bionic/signame.c
similarity index 100%
rename from libc/unistd/signame.c
rename to libc/bionic/signame.c
diff --git a/libc/unistd/sigsetmask.c b/libc/bionic/sigsetmask.c
similarity index 100%
rename from libc/unistd/sigsetmask.c
rename to libc/bionic/sigsetmask.c
diff --git a/libc/unistd/sigsuspend.c b/libc/bionic/sigsuspend.c
similarity index 100%
rename from libc/unistd/sigsuspend.c
rename to libc/bionic/sigsuspend.c
diff --git a/libc/bionic/sigwait.cpp b/libc/bionic/sigwait.cpp
new file mode 100644
index 0000000..1546fd6
--- /dev/null
+++ b/libc/bionic/sigwait.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <signal.h>
+#include <string.h>
+#include <time.h>
+
+#include <private/kernel_sigset_t.h>
+
+extern "C" int __rt_sigtimedwait(const sigset_t* uthese, siginfo_t* uinfo, const struct timespec* uts, size_t sigsetsize);
+
+int sigwait(const sigset_t* set, int* sig) {
+  kernel_sigset_t sigset(set);
+  while (true) {
+    // __rt_sigtimedwait can return EAGAIN or EINTR, we need to loop
+    // around them since sigwait is only allowed to return EINVAL.
+    int result = __rt_sigtimedwait(sigset.get(), NULL, NULL, sizeof(sigset));
+    if (result >= 0) {
+      *sig = result;
+      return 0;
+    }
+
+    if (errno != EAGAIN && errno != EINTR) {
+      return errno;
+    }
+  }
+}
diff --git a/libc/unistd/sleep.c b/libc/bionic/sleep.c
similarity index 100%
rename from libc/unistd/sleep.c
rename to libc/bionic/sleep.c
diff --git a/libc/unistd/socketcalls.c b/libc/bionic/socketcalls.c
similarity index 100%
rename from libc/unistd/socketcalls.c
rename to libc/bionic/socketcalls.c
diff --git a/libc/bionic/ssp.c b/libc/bionic/ssp.c
deleted file mode 100644
index f83b2a4..0000000
--- a/libc/bionic/ssp.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include "logd.h"
-
-void *__stack_chk_guard = 0;
-
-/* Initialize the canary with a random value from /dev/urandom.
- * If that fails, use the "terminator canary". */
-static void __attribute__ ((constructor))
-__guard_setup(void)
-{
-    int fd;
-
-    fd = open("/dev/urandom", O_RDONLY);
-    if (fd != -1) {
-        ssize_t len = read(fd, &__stack_chk_guard,
-                           sizeof(__stack_chk_guard));
-        close(fd);
-        if (len == sizeof(__stack_chk_guard))
-            return;
-    }
-
-    /* If that failed, switch to 'terminator canary' */
-    ((unsigned char *)&__stack_chk_guard)[0] = 0;
-    ((unsigned char *)&__stack_chk_guard)[1] = 0;
-    ((unsigned char *)&__stack_chk_guard)[2] = '\n';
-    ((unsigned char *)&__stack_chk_guard)[3] = 255;
-}
-
-/* This is the crash handler.
- * Does a best effort at logging and calls _exit to terminate
- * the process immediately (without atexit handlers, etc.) */
-void __stack_chk_fail(void)
-{
-    struct sigaction sa;
-    sigset_t sigmask;
-    static const char message[] = "stack corruption detected: aborted";
-    char path[PATH_MAX];
-    int count;
-
-    /* Immediately block all (but SIGABRT) signal handlers from running code */
-    sigfillset(&sigmask);
-    sigdelset(&sigmask, SIGABRT);
-    sigprocmask(SIG_BLOCK, &sigmask, NULL);
-
-    /* Use /proc/self/exe link to obtain the program name for logging
-     * purposes. If it's not available, we set it to "<unknown>" */
-    if ((count = readlink("/proc/self/exe", path, sizeof(path) - 1)) == -1) {
-        strlcpy(path, "<unknown>", sizeof(path));
-    } else {
-        path[count] = '\0';
-    }
-
-    /* Do a best effort at logging. This ends up calling writev(2) */
-    __libc_android_log_print(ANDROID_LOG_FATAL, path, message);
-
-    /* Make sure there is no default action for SIGABRT */
-    bzero(&sa, sizeof(struct sigaction));
-    sigemptyset(&sa.sa_mask);
-    sa.sa_flags = 0;
-    sa.sa_handler = SIG_DFL;
-    sigaction(SIGABRT, &sa, NULL);
-
-    /* Terminate the process and exit immediately */
-    kill(getpid(), SIGABRT);
-
-    _exit(127);
-}
diff --git a/libc/unistd/statfs.c b/libc/bionic/statfs.c
similarity index 100%
rename from libc/unistd/statfs.c
rename to libc/bionic/statfs.c
diff --git a/libc/bionic/strerror.cpp b/libc/bionic/strerror.cpp
index 455dc52..a50c99f 100644
--- a/libc/bionic/strerror.cpp
+++ b/libc/bionic/strerror.cpp
@@ -41,6 +41,6 @@
   }
 
   LOCAL_INIT_THREAD_LOCAL_BUFFER(char*, strerror, NL_TEXTMAX);
-  strerror_r(error_number, strerror_buffer, strerror_buffer_size);
-  return strerror_buffer;
+  strerror_r(error_number, strerror_tls_buffer, strerror_tls_buffer_size);
+  return strerror_tls_buffer;
 }
diff --git a/libc/bionic/strerror_r.cpp b/libc/bionic/strerror_r.cpp
index e6a3975..81120ec 100644
--- a/libc/bionic/strerror_r.cpp
+++ b/libc/bionic/strerror_r.cpp
@@ -7,6 +7,8 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "private/ErrnoRestorer.h"
+
 struct Pair {
   int code;
   const char* msg;
@@ -42,21 +44,20 @@
 }
 
 int strerror_r(int error_number, char* buf, size_t buf_len) {
-  int saved_errno = errno;
+  ErrnoRestorer errno_restorer;
   size_t length;
 
   const char* error_name = __strerror_lookup(error_number);
   if (error_name != NULL) {
     length = snprintf(buf, buf_len, "%s", error_name);
   } else {
-    length = snprintf(buf, buf_len, "Unknown error %u", error_number);
+    length = snprintf(buf, buf_len, "Unknown error %d", error_number);
   }
   if (length >= buf_len) {
-    errno = ERANGE;
+    errno_restorer.override(ERANGE);
     return -1;
   }
 
-  errno = saved_errno;
   return 0;
 }
 
diff --git a/libc/string/strndup.c b/libc/bionic/strndup.c
similarity index 100%
rename from libc/string/strndup.c
rename to libc/bionic/strndup.c
diff --git a/libc/string/strnlen.c b/libc/bionic/strnlen.c
similarity index 100%
rename from libc/string/strnlen.c
rename to libc/bionic/strnlen.c
diff --git a/libc/stdlib/strntoimax.c b/libc/bionic/strntoimax.c
similarity index 100%
rename from libc/stdlib/strntoimax.c
rename to libc/bionic/strntoimax.c
diff --git a/libc/stdlib/strntoumax.c b/libc/bionic/strntoumax.c
similarity index 100%
rename from libc/stdlib/strntoumax.c
rename to libc/bionic/strntoumax.c
diff --git a/libc/bionic/strsignal.cpp b/libc/bionic/strsignal.cpp
index 9b046d4..c549e74 100644
--- a/libc/bionic/strsignal.cpp
+++ b/libc/bionic/strsignal.cpp
@@ -42,5 +42,5 @@
   }
 
   LOCAL_INIT_THREAD_LOCAL_BUFFER(char*, strsignal, NL_TEXTMAX);
-  return const_cast<char*>(__strsignal(signal_number, strsignal_buffer, strsignal_buffer_size));
+  return const_cast<char*>(__strsignal(signal_number, strsignal_tls_buffer, strsignal_tls_buffer_size));
 }
diff --git a/libc/string/strtotimeval.c b/libc/bionic/strtotimeval.c
similarity index 100%
rename from libc/string/strtotimeval.c
rename to libc/bionic/strtotimeval.c
diff --git a/libc/bionic/stubs.cpp b/libc/bionic/stubs.cpp
index 1cab7d3..8ddc326 100644
--- a/libc/bionic/stubs.cpp
+++ b/libc/bionic/stubs.cpp
@@ -31,14 +31,17 @@
 #include <grp.h>
 #include <mntent.h>
 #include <netdb.h>
-#include <private/android_filesystem_config.h>
-#include <private/logd.h>
 #include <pthread.h>
 #include <pwd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 
+#include "private/android_filesystem_config.h"
+#include "private/debug_format.h"
+#include "private/ErrnoRestorer.h"
+#include "private/logd.h"
+
 // Thread-specific state for the non-reentrant functions.
 static pthread_once_t stubs_once = PTHREAD_ONCE_INIT;
 static pthread_key_t stubs_key;
@@ -57,7 +60,7 @@
                       passwd** result) {
   // getpwnam_r and getpwuid_r don't modify errno, but library calls we
   // make might.
-  int old_errno = errno;
+  ErrnoRestorer errno_restorer;
   *result = NULL;
 
   // Our implementation of getpwnam(3) and getpwuid(3) use thread-local
@@ -68,9 +71,7 @@
   // POSIX allows failure to find a match to be considered a non-error.
   // Reporting success (0) but with *result NULL is glibc's behavior.
   if (src == NULL) {
-    int rc = (errno == ENOENT) ? 0 : errno;
-    errno = old_errno;
-    return rc;
+    return (errno == ENOENT) ? 0 : errno;
   }
 
   // Work out where our strings will go in 'buf', and whether we've got
@@ -83,13 +84,11 @@
   dst->pw_shell = buf + required_byte_count;
   required_byte_count += strlen(src->pw_shell) + 1;
   if (byte_count < required_byte_count) {
-    errno = old_errno;
     return ERANGE;
   }
 
   // Copy the strings.
-  snprintf(buf, byte_count, "%s%c%s%c%s",
-           src->pw_name, 0, src->pw_dir, 0, src->pw_shell);
+  snprintf(buf, byte_count, "%s%c%s%c%s", src->pw_name, 0, src->pw_dir, 0, src->pw_shell);
 
   // pw_passwd is non-POSIX and unused (always NULL) in bionic.
   // pw_gecos is non-POSIX and missing in bionic.
@@ -100,7 +99,6 @@
   dst->pw_uid = src->pw_uid;
 
   *result = dst;
-  errno = old_errno;
   return 0;
 }
 
@@ -371,7 +369,8 @@
   return app_id_to_passwd(app_id_from_name(login), state);
 }
 
-int getgrouplist(const char* user, gid_t group, gid_t* groups, int* ngroups) {
+// All users are in just one group, the one passed in.
+int getgrouplist(const char* /*user*/, gid_t group, gid_t* groups, int* ngroups) {
     if (*ngroups < 1) {
         *ngroups = 1;
         return -1;
@@ -412,53 +411,53 @@
   return app_id_to_group(app_id_from_name(name), state);
 }
 
+// We don't have an /etc/networks, so all inputs return NULL.
+netent* getnetbyname(const char* /*name*/) {
+  return NULL;
+}
+
+// We don't have an /etc/networks, so all inputs return NULL.
+netent* getnetbyaddr(uint32_t /*net*/, int /*type*/) {
+  return NULL;
+}
+
+// We don't have an /etc/protocols, so all inputs return NULL.
+protoent* getprotobyname(const char* /*name*/) {
+  return NULL;
+}
+
+// We don't have an /etc/protocols, so all inputs return NULL.
+protoent* getprotobynumber(int /*proto*/) {
+  return NULL;
+}
+
 static void unimplemented_stub(const char* function) {
   const char* fmt = "%s(3) is not implemented on Android\n";
-  __libc_android_log_print(ANDROID_LOG_WARN, "libc", fmt, function);
+  __libc_format_log(ANDROID_LOG_WARN, "libc", fmt, function);
   fprintf(stderr, fmt, function);
 }
 
 #define UNIMPLEMENTED unimplemented_stub(__PRETTY_FUNCTION__)
 
-netent* getnetbyname(const char* name) {
-  UNIMPLEMENTED;
-  return NULL;
-}
-
 void endpwent() {
   UNIMPLEMENTED;
 }
 
-mntent* getmntent(FILE* f) {
+mntent* getmntent(FILE* /*f*/) {
   UNIMPLEMENTED;
   return NULL;
 }
 
-char* ttyname(int fd) { // NOLINT: implementing bad function.
+char* ttyname(int /*fd*/) { // NOLINT: implementing bad function.
   UNIMPLEMENTED;
   return NULL;
 }
 
-int ttyname_r(int fd, char* buf, size_t buflen) {
+int ttyname_r(int /*fd*/, char* /*buf*/, size_t /*buflen*/) {
   UNIMPLEMENTED;
   return -ERANGE;
 }
 
-netent* getnetbyaddr(uint32_t net, int type) {
-  UNIMPLEMENTED;
-  return NULL;
-}
-
-protoent* getprotobyname(const char* name) {
-  UNIMPLEMENTED;
-  return NULL;
-}
-
-protoent* getprotobynumber(int proto) {
-  UNIMPLEMENTED;
-  return NULL;
-}
-
 char* getusershell() {
   UNIMPLEMENTED;
   return NULL;
diff --git a/libc/bionic/sysconf.cpp b/libc/bionic/sysconf.cpp
new file mode 100644
index 0000000..5e39e61
--- /dev/null
+++ b/libc/bionic/sysconf.cpp
@@ -0,0 +1,349 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <asm/page.h>
+#include <bionic_tls.h>
+#include <ctype.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stdio.h>  // For FOPEN_MAX.
+#include <string.h>
+#include <sys/sysconf.h>
+#include <time.h>
+#include <unistd.h>
+
+#include "private/ScopedReaddir.h"
+
+/* seems to be the default on Linux, per the GLibc sources and my own digging */
+
+#define  SYSTEM_CLK_TCK         100
+#define  SYSTEM_IOV_MAX         1024
+#define  SYSTEM_DELAYTIMER_MAX  2147483647
+#define  SYSTEM_MQ_OPEN_MAX     8
+#define  SYSTEM_MQ_PRIO_MAX     32768
+#define  SYSTEM_SEM_NSEMS_MAX   256
+#define  SYSTEM_SEM_VALUE_MAX   0x3fffffff  /* see bionic/semaphore.c */
+#define  SYSTEM_SIGQUEUE_MAX    32
+#define  SYSTEM_TIMER_MAX       32
+#define  SYSTEM_LOGIN_NAME_MAX  256
+#define  SYSTEM_TTY_NAME_MAX    32
+
+/* the following depends on our implementation */
+#define  SYSTEM_ATEXIT_MAX          65536    /* our implementation is unlimited */
+#define  SYSTEM_THREAD_STACK_MIN    32768    /* lower values may be possible, but be conservative */
+#define  SYSTEM_THREAD_THREADS_MAX  2048     /* really unlimited */
+
+#define  SYSTEM_2_C_BIND     _POSIX_VERSION  /* Posix C binding version */
+#define  SYSTEM_2_C_VER      _POSIX2_C_VERSION
+#define  SYSTEM_2_C_DEV      -1       /* Posix C development tools unsupported on the device */
+#define  SYSTEM_2_FORT_DEV   -1       /* Fortran development unsupported */
+#define  SYSTEM_2_FORT_RUN   -1       /* Fortran runtime unsupported */
+#define  SYSTEM_2_SW_DEV     -1       /* posix software dev utilities unsupported */
+#define  SYSTEM_2_LOCALEDEF  -1       /* localedef() unimplemented */
+#define  SYSTEM_2_UPE        -1       /* No UPE for you ! (User Portability Utilities) */
+#define  SYSTEM_2_VERSION    -1       /* No posix command-line tools */
+
+static bool __matches_cpuN(const char* s) {
+  // The %c trick is to ensure that we have the anchored match "^cpu[0-9]+$".
+  unsigned cpu;
+  char dummy;
+  return (sscanf(s, "cpu%u%c", &cpu, &dummy) == 1);
+}
+
+static int __sysconf_nprocessors_conf() {
+  // On x86 kernels you can use /proc/cpuinfo for this, but on ARM kernels offline CPUs disappear
+  // from there. This method works on both.
+  ScopedReaddir reader("/sys/devices/system/cpu");
+  if (reader.IsBad()) {
+    return 1;
+  }
+
+  int result = 0;
+  dirent* entry;
+  while ((entry = reader.ReadEntry()) != NULL) {
+    if (entry->d_type == DT_DIR && __matches_cpuN(entry->d_name)) {
+      ++result;
+    }
+  }
+  return result;
+}
+
+static int __sysconf_nprocessors_onln() {
+  FILE* fp = fopen("/proc/stat", "r");
+  if (fp == NULL) {
+    return 1;
+  }
+
+  int result = 0;
+  char buf[256];
+  while (fgets(buf, sizeof(buf), fp) != NULL) {
+    // Extract just the first word from the line.
+    // 'cpu0 7976751 1364388 3116842 469770388 8629405 0 49047 0 0 0'
+    char* p = strchr(buf, ' ');
+    if (p != NULL) {
+      *p = 0;
+    }
+    if (__matches_cpuN(buf)) {
+      ++result;
+    }
+  }
+  fclose(fp);
+  return result;
+}
+
+static int __get_meminfo(const char* pattern) {
+  FILE* fp = fopen("/proc/meminfo", "r");
+  if (fp == NULL) {
+    return -1;
+  }
+
+  int result = -1;
+  char buf[256];
+  while (fgets(buf, sizeof(buf), fp) != NULL) {
+    long total;
+    if (sscanf(buf, pattern, &total) == 1) {
+      result = (int) (total / (PAGE_SIZE/1024));
+      break;
+    }
+  }
+  fclose(fp);
+  return result;
+}
+
+static int __sysconf_phys_pages() {
+  return __get_meminfo("MemTotal: %ld kB");
+}
+
+static int __sysconf_avphys_pages() {
+  return __get_meminfo("MemFree: %ld kB");
+}
+
+static int __sysconf_monotonic_clock() {
+  timespec t;
+  int rc = clock_getres(CLOCK_MONOTONIC, &t);
+  return (rc == -1) ? -1 : _POSIX_VERSION;
+}
+
+int sysconf(int name) {
+    switch (name) {
+#ifdef _POSIX_ARG_MAX
+    case _SC_ARG_MAX:           return _POSIX_ARG_MAX;
+#endif
+#ifdef _POSIX2_BC_BASE_MAX
+    case _SC_BC_BASE_MAX:       return _POSIX2_BC_BASE_MAX;
+#endif
+#ifdef _POSIX2_BC_DIM_MAX
+    case _SC_BC_DIM_MAX:        return _POSIX2_BC_DIM_MAX;
+#endif
+#ifdef _POSIX2_BC_SCALE_MAX
+    case _SC_BC_SCALE_MAX:      return _POSIX2_BC_SCALE_MAX;
+#endif
+#ifdef _POSIX2_BC_STRING_MAX
+    case _SC_BC_STRING_MAX:     return _POSIX2_BC_STRING_MAX;
+#endif
+    case _SC_CHILD_MAX:         return CHILD_MAX;
+    case _SC_CLK_TCK:           return SYSTEM_CLK_TCK;
+#ifdef _POSIX2_COLL_WEIGHTS_MASK
+    case _SC_COLL_WEIGHTS_MAX:  return _POSIX2_COLL_WEIGHTS_MASK;
+#endif
+#ifdef _POSIX2_EXPR_NEST_MAX
+    case _SC_EXPR_NEST_MAX:    return _POSIX2_EXPR_NEST_MAX;
+#endif
+#ifdef _POSIX2_LINE_MAX
+    case _SC_LINE_MAX:          return _POSIX2_LINE_MAX;
+#endif
+    case _SC_NGROUPS_MAX:       return NGROUPS_MAX;
+    case _SC_OPEN_MAX:          return OPEN_MAX;
+    //case _SC_PASS_MAX:          return PASS_MAX;
+    case _SC_2_C_BIND:          return SYSTEM_2_C_BIND;
+    case _SC_2_C_DEV:           return SYSTEM_2_C_DEV;
+    case _SC_2_C_VERSION:       return SYSTEM_2_C_VER;
+    //case _SC_2_CHAR_TERM:         return ;
+    case _SC_2_FORT_DEV:        return SYSTEM_2_FORT_DEV;
+    case _SC_2_FORT_RUN:        return SYSTEM_2_FORT_RUN;
+    case _SC_2_LOCALEDEF:       return SYSTEM_2_LOCALEDEF;
+    case _SC_2_SW_DEV:          return SYSTEM_2_SW_DEV;
+    case _SC_2_UPE:             return SYSTEM_2_UPE;
+    case _SC_2_VERSION:         return SYSTEM_2_VERSION;
+#ifdef _POSIX_JOB_CONTROL
+    case _SC_JOB_CONTROL:       return _POSIX_JOB_CONTROL;
+#endif
+#ifdef _POSIX_SAVED_IDS
+    case _SC_SAVED_IDS:         return _POSIX_SAVED_IDS;
+#endif
+#ifdef _POSIX_VERSION
+    case _SC_VERSION:           return _POSIX_VERSION;
+#endif
+    //case _SC_RE_DUP_<AX:        return ;
+    case _SC_STREAM_MAX:        return FOPEN_MAX;
+    //case _SC_TZNAME_MAX:        return ;
+#if _XOPEN_CRYPT
+    case _SC_XOPEN_CRYPT:       return _XOPEN_CRYPT;
+#endif
+#ifdef _XOPEN_ENH_I18N
+    case _SC_XOPEN_ENH_I18N:    return _XOPEN_ENH_I18N;
+#endif
+#ifdef _XOPEN_SHM
+    case _SC_XOPEN_SHM:         return _XOPEN_SHM;
+#endif
+#ifdef _XOPEN_VERSION
+    case _SC_XOPEN_VERSION:     return _XOPEN_VERSION;
+#endif
+#ifdef _XOPEN_XCU_VERSION
+    case _SC_XOPEN_XCU_VERSION: return _XOPEN_XCU_VERSION;
+#endif
+#ifdef _XOPEN_REALTIME
+    case _SC_XOPEN_REALTIME:    return _XOPEN_REALTIME;
+#endif
+#ifdef _XOPEN_REALTIME_THREADS
+    case _SC_XOPEN_REALTIME_THREADS: return _XOPEN_REALTIME_THREADS;
+#endif
+#ifdef _XOPEN_LEGACY
+    case _SC_XOPEN_LEGACY:      return _XOPEN_LEGACY;
+#endif
+    case _SC_ATEXIT_MAX:        return SYSTEM_ATEXIT_MAX;
+    case _SC_IOV_MAX:           return SYSTEM_IOV_MAX;
+    case _SC_PAGESIZE:          return PAGE_SIZE;
+    case _SC_PAGE_SIZE:         return PAGE_SIZE;
+#ifdef _XOPEN_UNIX
+    case _SC_XOPEN_UNIX:        return _XOPEN_UNIX;
+#endif
+
+    // XXX: TODO: XBS5 nonsense
+
+#ifdef AIO_LISTIO_MAX
+    case _SC_AIO_LISTIO_MAX:       return AIO_LISTIO_MAX;
+#endif
+#ifdef AIO_MAX
+    case _SC_AIO_MAX:              return AIO_MAX;
+#endif
+#ifdef AIO_PRIO_DELTA_MAX
+    case _SC_AIO_PRIO_DELTA_MAX:   return AIO_PRIO_DELTA_MAX;
+#endif
+    case _SC_DELAYTIMER_MAX:    return SYSTEM_DELAYTIMER_MAX;
+    case _SC_MQ_OPEN_MAX:       return SYSTEM_MQ_OPEN_MAX;
+    case _SC_MQ_PRIO_MAX:       return SYSTEM_MQ_PRIO_MAX;
+    case _SC_RTSIG_MAX:         return RTSIG_MAX;
+    case _SC_SEM_NSEMS_MAX:     return SYSTEM_SEM_NSEMS_MAX;
+    case _SC_SEM_VALUE_MAX:     return SYSTEM_SEM_VALUE_MAX;
+    case _SC_SIGQUEUE_MAX:      return SYSTEM_SIGQUEUE_MAX;
+    case _SC_TIMER_MAX:         return SYSTEM_TIMER_MAX;
+#ifdef _POSIX_ASYNCHRONOUS_IO
+    case _SC_ASYNCHRONOUS_IO:   return _POSIX_ASYNCHRONOUS_IO;
+#endif
+#ifdef _POSIX_FSYNC
+    case _SC_FSYNC:             return _POSIX_FSYNC;
+#endif
+#ifdef _POSIX_MAPPED_FILES
+    case _SC_MAPPED_FILES:      return _POSIX_MAPPED_FILES;
+#endif
+#ifdef _POSIX_MEMLOCK
+    case _SC_MEMLOCK:           return _POSIX_MEMLOCK;
+#endif
+#ifdef _POSIX_MEMLOCK_RANGE
+    case _SC_MEMLOCK_RANGE:     return _POSIX_MEMLOCK_RANGE
+#endif
+#ifdef _POSIX_MEMORY_PROTECTION
+    case _SC_MEMORY_PROTECTION: return _POSIX_MEMORY_PROTECTION;
+#endif
+#ifdef _POSIX_MESSAGE_PASSING
+    case _SC_MESSAGE_PASSING:   return _POSIX_MESSAGE_PASSING;
+#endif
+#ifdef _POSIX_PRIORITIZED_IO
+    case _SC_PRIORITIZED_IO:    return _POSIX_PRIORITIZED_IO;
+#endif
+#ifdef _POSIX_PRIORITY_SCHEDULING
+    case _SC_PRIORITY_SCHEDULING:  return _POSIX_PRIORITY_SCHEDULING;
+#endif
+#ifdef _POSIX_REALTIME_SIGNALS
+    case _SC_REALTIME_SIGNALS:  return _POSIX_REALTIME_SIGNALS;
+#endif
+#ifdef _POSIX_SEMAPHORES
+    case _SC_SEMAPHORES:        return _POSIX_SEMAPHORES;
+#endif
+#ifdef _POSIX_SHARED_MEMORY_OBJECTS
+    case _SC_SHARED_MEMORY_OBJECTS:  return _POSIX_SHARED_MEMORY_OBJECTS;
+#endif
+#ifdef _POSIX_SYNCHRONIZED_IO
+    case _SC_SYNCHRONIZED_IO:   return _POSIX_SYNCHRONIZED_IO;
+#endif
+#ifdef _POSIX_TIMERS
+    case _SC_TIMERS:            return _POSIX_TIMERS;
+#endif
+
+    // GETGR_R_SIZE_MAX ?
+    // GETPW_R_SIZE_MAX ?
+
+    case _SC_LOGIN_NAME_MAX:    return SYSTEM_LOGIN_NAME_MAX;
+
+    case _SC_THREAD_DESTRUCTOR_ITERATIONS:
+      return _POSIX_THREAD_DESTRUCTOR_ITERATIONS;
+
+    case _SC_THREAD_KEYS_MAX:
+      return (BIONIC_TLS_SLOTS - TLS_SLOT_FIRST_USER_SLOT - GLOBAL_INIT_THREAD_LOCAL_BUFFER_COUNT);
+
+    case _SC_THREAD_STACK_MIN:    return SYSTEM_THREAD_STACK_MIN;
+    case _SC_THREAD_THREADS_MAX:  return SYSTEM_THREAD_THREADS_MAX;
+    case _SC_TTY_NAME_MAX:        return SYSTEM_TTY_NAME_MAX;
+#ifdef _POSIX_THREADS
+    case _SC_THREADS:             return _POSIX_THREADS;
+#endif
+#ifdef _POSIX_THREAD_ATTR_STACKADDR
+    case _SC_THREAD_ATTR_STACKADDR:   return _POSIX_THREAD_ATTR_STACKADDR;
+#endif
+#ifdef _POSIX_THREAD_ATTR_STACKSIZE
+    case _SC_THREAD_ATTR_STACKSIZE:   return _POSIX_THREAD_ATTR_STACKSIZE;
+#endif
+#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
+    case _SC_THREAD_PRIORITY_SCHEDULING:  return _POSIX_THREAD_PRIORITY_SCHEDULING;
+#endif
+#ifdef _POSIX_THREAD_PRIO_INHERIT
+    case _SC_THREAD_PRIO_INHERIT:         return _POSIX_THREAD_PRIO_INHERIT;
+#endif
+#ifdef _POSIX_THREAD_PRIO_PROTECT
+    case _SC_THREAD_PRIO_PROTECT: return _POSIX_THREAD_PRIO_PROTECT;
+#endif
+#ifdef _POSIX_THREAD_SAFE_FUNCTIONS
+    case _SC_THREAD_SAFE_FUNCTIONS:  return _POSIX_THREAD_SAFE_FUNCTIONS
+#endif
+
+    case _SC_MONOTONIC_CLOCK:   return __sysconf_monotonic_clock();
+    case _SC_NPROCESSORS_CONF:  return __sysconf_nprocessors_conf();
+    case _SC_NPROCESSORS_ONLN:  return __sysconf_nprocessors_onln();
+    case _SC_PHYS_PAGES:        return __sysconf_phys_pages();
+    case _SC_AVPHYS_PAGES:      return __sysconf_avphys_pages();
+
+    default:
+       /* Posix says EINVAL is the only error that shall be returned,
+        * but GLibc uses ENOSYS */
+        errno = ENOSYS;
+        return -1;
+    }
+}
diff --git a/libc/bionic/system_properties.c b/libc/bionic/system_properties.c
index caa5ca6..c9cf2f7 100644
--- a/libc/bionic/system_properties.c
+++ b/libc/bionic/system_properties.c
@@ -31,12 +31,15 @@
 #include <stddef.h>
 #include <errno.h>
 #include <poll.h>
+#include <fcntl.h>
+#include <stdbool.h>
 
 #include <sys/mman.h>
 
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <sys/select.h>
+#include <sys/stat.h>
 #include <sys/types.h>
 #include <netinet/in.h>
 #include <unistd.h>
@@ -52,41 +55,77 @@
 
 prop_area *__system_property_area__ = (void*) &dummy_props;
 
+static int get_fd_from_env(void)
+{
+    char *env = getenv("ANDROID_PROPERTY_WORKSPACE");
+
+    if (!env) {
+        return -1;
+    }
+
+    return atoi(env);
+}
+
 int __system_properties_init(void)
 {
-    prop_area *pa;
-    int s, fd;
-    unsigned sz;
-    char *env;
+    bool fromFile = true;
+    int result = -1;
 
     if(__system_property_area__ != ((void*) &dummy_props)) {
         return 0;
     }
 
-    env = getenv("ANDROID_PROPERTY_WORKSPACE");
-    if (!env) {
+    int fd = open(PROP_FILENAME, O_RDONLY | O_NOFOLLOW);
+
+    if ((fd < 0) && (errno == ENOENT)) {
+        /*
+         * For backwards compatibility, if the file doesn't
+         * exist, we use the environment to get the file descriptor.
+         * For security reasons, we only use this backup if the kernel
+         * returns ENOENT. We don't want to use the backup if the kernel
+         * returns other errors such as ENOMEM or ENFILE, since it
+         * might be possible for an external program to trigger this
+         * condition.
+         */
+        fd = get_fd_from_env();
+        fromFile = false;
+    }
+
+    if (fd < 0) {
         return -1;
     }
-    fd = atoi(env);
-    env = strchr(env, ',');
-    if (!env) {
-        return -1;
+
+    struct stat fd_stat;
+    if (fstat(fd, &fd_stat) < 0) {
+        goto cleanup;
     }
-    sz = atoi(env + 1);
-    
-    pa = mmap(0, sz, PROT_READ, MAP_SHARED, fd, 0);
-    
-    if(pa == MAP_FAILED) {
-        return -1;
+
+    if ((fd_stat.st_uid != 0)
+            || (fd_stat.st_gid != 0)
+            || ((fd_stat.st_mode & (S_IWGRP | S_IWOTH)) != 0)) {
+        goto cleanup;
+    }
+
+    prop_area *pa = mmap(0, fd_stat.st_size, PROT_READ, MAP_SHARED, fd, 0);
+
+    if (pa == MAP_FAILED) {
+        goto cleanup;
     }
 
     if((pa->magic != PROP_AREA_MAGIC) || (pa->version != PROP_AREA_VERSION)) {
-        munmap(pa, sz);
-        return -1;
+        munmap(pa, fd_stat.st_size);
+        goto cleanup;
     }
 
     __system_property_area__ = pa;
-    return 0;
+    result = 0;
+
+cleanup:
+    if (fromFile) {
+        close(fd);
+    }
+
+    return result;
 }
 
 const prop_info *__system_property_find_nth(unsigned n)
@@ -218,8 +257,6 @@
 int __system_property_set(const char *key, const char *value)
 {
     int err;
-    int tries = 0;
-    int update_seen = 0;
     prop_msg msg;
 
     if(key == 0) return -1;
diff --git a/libc/unistd/tcgetpgrp.c b/libc/bionic/tcgetpgrp.c
similarity index 100%
rename from libc/unistd/tcgetpgrp.c
rename to libc/bionic/tcgetpgrp.c
diff --git a/libc/unistd/tcsetpgrp.c b/libc/bionic/tcsetpgrp.c
similarity index 100%
rename from libc/unistd/tcsetpgrp.c
rename to libc/bionic/tcsetpgrp.c
diff --git a/libc/bionic/tdestroy.c b/libc/bionic/tdestroy.cpp
similarity index 100%
rename from libc/bionic/tdestroy.c
rename to libc/bionic/tdestroy.cpp
diff --git a/libc/bionic/tmpfile.cpp b/libc/bionic/tmpfile.cpp
new file mode 100644
index 0000000..8419ff5
--- /dev/null
+++ b/libc/bionic/tmpfile.cpp
@@ -0,0 +1,113 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "private/ErrnoRestorer.h"
+
+class ScopedSignalBlocker {
+ public:
+  ScopedSignalBlocker() {
+    sigset_t set;
+    sigfillset(&set);
+    sigprocmask(SIG_BLOCK, &set, &old_set_);
+  }
+
+  ~ScopedSignalBlocker() {
+    sigprocmask(SIG_SETMASK, &old_set_, NULL);
+  }
+
+ private:
+  sigset_t old_set_;
+};
+
+static FILE* __tmpfile_dir(const char* tmp_dir) {
+  char buf[PATH_MAX];
+  int path_length = snprintf(buf, sizeof(buf), "%s/tmp.XXXXXXXXXX", tmp_dir);
+  if (path_length >= static_cast<int>(sizeof(buf))) {
+    return NULL;
+  }
+
+  int fd;
+  {
+    ScopedSignalBlocker ssb;
+    fd = mkstemp(buf);
+    if (fd == -1) {
+      return NULL;
+    }
+
+    // Unlink the file now so that it's removed when closed.
+    unlink(buf);
+
+    // Can we still use the file now it's unlinked?
+    // File systems without hard link support won't have the usual Unix semantics.
+    struct stat sb;
+    int rc = fstat(fd, &sb);
+    if (rc == -1) {
+      ErrnoRestorer errno_restorer;
+      close(fd);
+      return NULL;
+    }
+  }
+
+  // Turn the file descriptor into a FILE*.
+  FILE* fp = fdopen(fd, "w+");
+  if (fp != NULL) {
+    return fp;
+  }
+
+  // Failure. Clean up. We already unlinked, so we just need to close.
+  ErrnoRestorer errno_restorer;
+  close(fd);
+  return NULL;
+}
+
+FILE* tmpfile() {
+  // TODO: get this app's temporary directory from the framework ("/data/data/app/cache").
+
+  // $EXTERNAL_STORAGE turns out not to be very useful because it doesn't support hard links.
+  // This means we can't do the usual trick of calling unlink before handing the file back.
+
+  FILE* fp = __tmpfile_dir("/data/local/tmp");
+  if (fp == NULL) {
+    // P_tmpdir is "/tmp/", but POSIX explicitly says that tmpdir(3) should try P_tmpdir before
+    // giving up. This is potentially useful for bionic on the host anyway.
+    fp = __tmpfile_dir(P_tmpdir);
+  }
+  return fp;
+}
diff --git a/libc/unistd/umount.c b/libc/bionic/umount.c
similarity index 100%
rename from libc/unistd/umount.c
rename to libc/bionic/umount.c
diff --git a/libc/unistd/unlockpt.c b/libc/bionic/unlockpt.c
similarity index 100%
rename from libc/unistd/unlockpt.c
rename to libc/bionic/unlockpt.c
diff --git a/libc/unistd/usleep.c b/libc/bionic/usleep.c
similarity index 100%
rename from libc/unistd/usleep.c
rename to libc/bionic/usleep.c
diff --git a/libc/bionic/utime.c b/libc/bionic/utime.c
deleted file mode 100644
index 7239847..0000000
--- a/libc/bionic/utime.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)utime.c	8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
-//__FBSDID("$FreeBSD: /repoman/r/ncvs/src/lib/libc/gen/utime.c,v 1.3 2007/01/09 00:27:56 imp Exp $");
-
-#include <sys/time.h>
-
-#include <utime.h>
-
-int
-utime(path, times)
-	const char *path;
-	const struct utimbuf *times;
-{
-	struct timeval tv[2], *tvp;
-
-	if (times) {
-		tv[0].tv_sec = times->actime;
-		tv[1].tv_sec = times->modtime;
-		tv[0].tv_usec = tv[1].tv_usec = 0;
-		tvp = tv;
-	} else
-		tvp = NULL;
-	return (utimes(path, tvp));
-}
diff --git a/libc/unistd/wait.c b/libc/bionic/wait.c
similarity index 100%
rename from libc/unistd/wait.c
rename to libc/bionic/wait.c
diff --git a/libc/bionic/wchar.cpp b/libc/bionic/wchar.cpp
new file mode 100644
index 0000000..50a3875
--- /dev/null
+++ b/libc/bionic/wchar.cpp
@@ -0,0 +1,286 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ctype.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+
+/* stubs for wide-char functions */
+
+wint_t btowc(int c) {
+  return (c == EOF) ? WEOF : c;
+}
+
+int fwprintf(FILE* stream, const wchar_t* format, ...) {
+  va_list args;
+  va_start(args, format);
+  int result = vfwprintf(stream, format, args);
+  va_end(args);
+  return result;
+}
+
+int wprintf(const wchar_t* format, ...) {
+  va_list args;
+  va_start(args, format);
+  int result = vwprintf(format, args);
+  va_end(args);
+  return result;
+}
+
+int swprintf(wchar_t* s, size_t n, const wchar_t* format, ...) {
+  va_list args;
+  va_start(args, format);
+  int result = vswprintf(s, n, format, args);
+  va_end(args);
+  return result;
+}
+
+int vwprintf(const wchar_t* format, va_list arg) {
+  return vfwprintf(stdout, format, arg);
+}
+
+int vfwprintf(FILE* /*stream*/, const wchar_t* /*format*/, va_list /*arg*/) {
+  errno = ENOTSUP;
+  return -1;
+}
+
+int vswprintf(wchar_t* /*s*/, size_t /*n*/, const wchar_t* /*format*/, va_list /*arg*/) {
+  errno = ENOTSUP;
+  return -1;
+}
+
+int fwscanf(FILE* /*stream*/, const wchar_t* /*format*/, ... ) {
+  errno = ENOTSUP;
+  return -1;
+}
+
+int wscanf(const wchar_t* format, ... ) {
+  va_list args;
+  va_start (args, format);
+  int result = fwscanf(stdout, format, args );
+  va_end (args);
+  return result;
+}
+
+int swscanf(const wchar_t* /*s*/, const wchar_t* /*format*/, ... ) {
+  errno = ENOTSUP;
+  return -1;
+}
+
+int iswalnum(wint_t wc) { return isalnum(wc); }
+int iswalpha(wint_t wc) { return isalpha(wc); }
+int iswcntrl(wint_t wc) { return iscntrl(wc); }
+int iswdigit(wint_t wc) { return isdigit(wc); }
+int iswgraph(wint_t wc) { return isgraph(wc); }
+int iswlower(wint_t wc) { return islower(wc); }
+int iswprint(wint_t wc) { return isprint(wc); }
+int iswpunct(wint_t wc) { return ispunct(wc); }
+int iswspace(wint_t wc) { return isspace(wc); }
+int iswupper(wint_t wc) { return isupper(wc); }
+int iswxdigit(wint_t wc) { return isxdigit(wc); }
+
+int iswctype(wint_t wc, wctype_t char_class) {
+  switch (char_class) {
+    case WC_TYPE_ALNUM: return isalnum(wc);
+    case WC_TYPE_ALPHA: return isalpha(wc);
+    case WC_TYPE_BLANK: return isblank(wc);
+    case WC_TYPE_CNTRL: return iscntrl(wc);
+    case WC_TYPE_DIGIT: return isdigit(wc);
+    case WC_TYPE_GRAPH: return isgraph(wc);
+    case WC_TYPE_LOWER: return islower(wc);
+    case WC_TYPE_PRINT: return isprint(wc);
+    case WC_TYPE_PUNCT: return ispunct(wc);
+    case WC_TYPE_SPACE: return isspace(wc);
+    case WC_TYPE_UPPER: return isupper(wc);
+    case WC_TYPE_XDIGIT: return isxdigit(wc);
+    default: return 0;
+  }
+}
+
+wint_t fgetwc(FILE* stream) {
+  return static_cast<wint_t>(fgetc(stream));
+}
+
+wchar_t* fgetws(wchar_t* ws, int n, FILE* stream) {
+  return reinterpret_cast<wchar_t*>(fgets(reinterpret_cast<char*>(ws), n, stream));
+}
+
+wint_t fputwc(wchar_t wc, FILE* stream) {
+  return static_cast<wint_t>(fputc(static_cast<char>(wc), stream));
+}
+
+int fputws(const wchar_t* str, FILE* stream) {
+  return fputs(reinterpret_cast<const char*>(str), stream );
+}
+
+int fwide(FILE* /*stream*/, int mode) {
+  return mode;
+}
+
+wint_t getwc(FILE* stream) {
+  return getc(stream);
+}
+
+wint_t getwchar() {
+  return getchar();
+}
+
+int mbsinit(const mbstate_t* /*ps*/) {
+  return 1;
+}
+
+size_t mbrlen(const char* /*s*/, size_t n, mbstate_t* /*ps*/) {
+  return (n != 0);
+}
+
+size_t mbrtowc(wchar_t* pwc, const char* s, size_t n, mbstate_t* /*ps*/) {
+  if (s == NULL) {
+    s   = "";
+    pwc = NULL;
+  }
+  if (n == 0) {
+    if (pwc) {
+      *pwc = 0;
+      return 0;
+    }
+  }
+  if (pwc) {
+    *pwc = *s;
+  }
+  return (*s != 0);
+}
+
+size_t mbsrtowcs(wchar_t* dst, const char** src, size_t len, mbstate_t* /*ps*/) {
+  const char* s  = *src;
+  const char* s2 = reinterpret_cast<const char*>(memchr(s, 0, len));
+
+  if (s2 != NULL) {
+    len = (size_t)(s2 - s) + 1U;
+  }
+
+  if (dst) {
+    memcpy(reinterpret_cast<char*>(dst), s, len );
+  }
+
+  *src = s + len;
+  return len;
+}
+
+size_t mbstowcs(wchar_t* dst, const char* src, size_t len) {
+  return mbsrtowcs(dst, &src, len, NULL);
+}
+
+wint_t putwc(wchar_t wc, FILE* stream) {
+  return fputc(static_cast<char>(wc), stream);
+}
+
+wint_t putwchar(wchar_t wc) {
+  return putchar(static_cast<char>(wc));
+}
+
+wint_t towlower(wint_t wc) {
+  return tolower(wc);
+}
+
+wint_t towupper(wint_t wc) {
+  return toupper(wc);
+}
+
+wint_t ungetwc(wint_t wc, FILE* stream) {
+  return ungetc(static_cast<char>(wc), stream);
+}
+
+size_t wcrtomb(char* s, wchar_t /*wc*/, mbstate_t* /*ps*/) {
+  if (s != NULL) {
+    *s = 1;
+  }
+  return 1;
+}
+
+size_t wcsftime(wchar_t* wcs, size_t maxsize, const wchar_t* format,  const struct tm* timptr) {
+  return strftime(reinterpret_cast<char*>(wcs), maxsize, reinterpret_cast<const char*>(format), timptr);
+}
+
+size_t wcsrtombs(char* dst, const wchar_t** src, size_t len, mbstate_t* /*ps*/) {
+  const char* s = reinterpret_cast<const char*>(*src);
+  const char* s2 = reinterpret_cast<const char*>(memchr(s, 0, len));
+  if (s2 != NULL) {
+    len = (s2 - s)+1;
+  }
+  if (dst != NULL) {
+    memcpy( dst, s, len );
+  }
+  *src = (wchar_t*)(s + len);
+  return len;
+}
+
+size_t wcstombs(char* dst, const wchar_t* src, size_t len) {
+  return wcsrtombs(dst, &src, len, NULL);
+}
+
+double wcstod(const wchar_t* nptr, wchar_t** endptr) {
+  return strtod(reinterpret_cast<const char*>(nptr), reinterpret_cast<char**>(endptr));
+}
+
+long int wcstol(const wchar_t* nptr, wchar_t** endptr, int base) {
+  return strtol(reinterpret_cast<const char*>(nptr), reinterpret_cast<char**>(endptr), base);
+}
+
+unsigned long int wcstoul(const wchar_t* nptr, wchar_t** endptr, int base) {
+  return strtoul(reinterpret_cast<const char*>(nptr), reinterpret_cast<char**>(endptr), base);
+}
+
+wchar_t* wcswcs(const wchar_t* ws1, const wchar_t* ws2) {
+  const char* s1 = reinterpret_cast<const char*>(ws1);
+  const char* s2 = reinterpret_cast<const char*>(ws2);
+  return reinterpret_cast<wchar_t*>(strstr(s1, s2));
+}
+
+int wctob(wint_t c) {
+  return c;
+}
+
+wctype_t wctype(const char* property) {
+  static const char* const  properties[WC_TYPE_MAX] = {
+    "<invalid>",
+    "alnum", "alpha", "blank", "cntrl", "digit", "graph",
+    "lower", "print", "punct", "space", "upper", "xdigit"
+  };
+  for (size_t i = 0; i < WC_TYPE_MAX; ++i) {
+    if (!strcmp(properties[i], property)) {
+      return static_cast<wctype_t>(i);
+    }
+  }
+  return static_cast<wctype_t>(0);
+}
+
+int wcwidth(wchar_t wc) {
+  return (wc > 0);
+}
diff --git a/libc/wchar/wcscoll.c b/libc/bionic/wcscoll.c
similarity index 100%
rename from libc/wchar/wcscoll.c
rename to libc/bionic/wcscoll.c
diff --git a/libc/docs/CHANGES.TXT b/libc/docs/CHANGES.TXT
deleted file mode 100644
index 98b7fcf..0000000
--- a/libc/docs/CHANGES.TXT
+++ /dev/null
@@ -1,277 +0,0 @@
-Bionic ChangeLog:
------------------
-
-Differences between current and Android 2.3:
-
-- <android/api-level.h>: Added new header to define __ANDROID_API__ to
-  a constant integer corresponding to the native API level. This header
-  also exists in the NDK's platform headers.
-
-- <sys/cdefs.h>: Include <android/api-level.h>
-
-- <time.h>: Add timegm(), timelocal(), time2posix() and posix2time()
-
-- <sched.h>: Add sched_getcpu(), sched_getaffinity(), sched_setaffinity(),
-  cpu_set_t and related macros (e.g. CPU_SETSIZE, CPU_ZERO, CPU_SET, ...)
-
-- <unistd.h>: Add ftruncate64().
-
-- <signal.h>: Changed the definition of SIGRTMAX to 64. However, note that
-  sigset_t is only 32-bit and cannot deal with real-time signals.
-
--------------------------------------------------------------------------------
-Differences between Android 2.3 and Android 2.2:
-
-- <pthread.h>: Add reader/writer locks implementation. Add sanity
-  checking to pthread_mutex_destroy() (e.g. a locked mutex will return
-  EBUSY).
-
-- <semaphore.h>: Use private futexes for semaphore implementation,
-  unless your set 'pshared' to non-0 when calling sem_init().
-
-  Also fixed a bug in sem_post() to make it wake up all waiting
-  threads, instead of one. As a consequence, the maximum semaphore
-  value is now reduced to 0x3fffffff.
-
-- <math.h>: Added sincos(), sincosf() and sincosl() (GLibc compatibility).
-
-- <sys/sysinfo.h>: Added missing sysinfo() system call implementation
-  (the function was already declared in the header though).
-
-- sysconf() didn't work for some arguments due to a small bug in the
-  /proc line parser.
-
-- <termio.h>: added missing header (just includes <termios.h>)
-
-- <unistd.h>: add missing declaration for truncate(). The implementation
-  was already here since Android 1.5.
-
-  modify implementation of alarm() to return 0 in case of error (i.e.
-  if a value larger than 0x7fffffff seconds is passed to it). This
-  makes the implementation compliant with the GLibc behaviour.
-
-- <wchar.h>: small fixes to really support wchar_t in Bionic (not there yet).
-
-     the size of wchar_t is still 32-bit (decided by the compiler)
-
-     WCHAR_MIN: changed from 0 to INT_MIN
-     WCHAR_MAX: changed from 255 to INT_MAX
-
-     wcpcpy(), wcpncpy(), wcscat(), wcschr(), wcscmp(),
-     wcscpy(), wcscspn(), wcsdup(), wcslcat(), wcslcpy(),
-     wcslen(), wcsncat(), wcsncmp(), wcsncpy(), wcsnlen(),
-     wcspbrk(), wcsrchr(), wcsrchr(), wcsspn(), wcsstr(),
-     wcstok(), wcswidth(), wmemchr(), wmemcmp(), wmemcpy(),
-     wmemmove(), wmemset(): Added proper implementations.
-
-     wcscasecmp(), wcsncasecmp(): Added implementation limited
-     to ASCII codes for lower/upper.
-
-     wcscoll(): added dummy implementation that calls wcscmp()
-     wcsxfrm(): added dummy implementation that calls wcsncpy()
-
-  NOTE: Technically, this breaks the ABI, but we never claimed to support
-        wchar_t anyway. The wchar_t support is still *NOT* official at this
-        point. We need better multi-byte support code, and wprintf/wscanf
-        stuff too.
-
-- <inttypes.h>: add missing declarations for strntoimax abd strntoumax.
-
-- <stdlib.h>: add missing declarations for drand48() and erand48().
-
-- clearerr(): fix broken implementation.
-
-- Feature test macros like _POSIX_C_SOURCE / _XOPEN_SOURCE / _C99_SOURCE
-  are now handled correctly by our C library headers (see <sys/cdefs.h>)
-
-- <sys/select.h>: add missing declaration for pselect()
-
-- <sys/vfs.h>: fixed implementation of fstatfs() (also fixes fpathconf()
-  which uses it).
-
-- Added an implementation of pthread_atfork()
-
-- <dlfcn.h>: fixed dlopen() implementation to support dlopen(NULL, ...).
-  This allows one to look at the dynamic symbols exported by an executable.
-
-- <private/bionic_tls.h>: use kernel helper functions for static versions
-  of the C library. This is necessary because we don't know where the corresponding
-  machine code is going to run, and the optimization for __get_tls() might
-  not match the features of the target device where we run a static executable
-  linked to the C library. This fixes one of the bug that explains why gdbserver
-  didn't work well with threads.
-
--------------------------------------------------------------------------------
-Differences between Android 2.2. and Android 2.1:
-
-- Support FP register save/load in setjmp()/longjmp() on ARMv7 builds.
-
-- Add support for SH-4 CPU architecture !
-
-- __atomic_swap(): use LDREX/STREX CPU instructions on ARMv6 and higher.
-
-- <arpa/telnet.h>: New header (declarations only, no implementation).
-
-- <err.h>: New header + implementation. GLibc compatibility.
-
-- <warn.h>: New header + implementation. GLibc compatibility.
-
-- <fts.h>: New header + implementation.
-
-- <mntent.h>: Add missing <stdio.h> include.
-
-- <regex.h>: New header + implementation.
-
-- <signal.h>: Added killpg()
-
-- <stdint.h>: Allow 64-bit type declarations on C99 builds.
-
-- <stdio.h>: Add fdprintf() and vfdprintf(). Note that GLibc provides
-  the confusing 'dprintf' and 'vdprintf()' functions instead.
-
-- <stdlib.h>: Fix ptsname_r(): the return type is int instead of char*.
-  The mistake comes from a GLibc man page bug (the man page listed a return
-  type of char*, while the implementation used int. Fixed in late 2009 only).
-  The Bionic implementation was incorrect. Technically, this is an ABI
-  breakage, but code that used this function probably never worked or
-  compiled properly anyway.
-
-- <strings.h>: Add missing <sys/types.h> include.
-
-- <sys/queue.h>: Added new header (no implementation - macro templates).
-
-- <sys/resource.h>: Add rlim_t proper definition.
-
-- <time64.h>: Add missing C++ header inclusion guards.
-
-- <unistd.h>: Add getusershell(), setusershell() and endusershell(), though
-  implementation are bogus. GLibc compatibility.
-
-- <wchar.h>: Add mbstowcs() and wcstombs()
-
-- add clone() implementation for ARM (x86 and SH-4 not working yet).
-
-- <sys/epoll.h>: <sys/system_properties.h>: Add missing C++ inclusion guards
-
-- fix getpwnam() and getpwgrp() to accept "app_0" as a valid user name.
-
-- fix sem_trywait() to return -1 and set errno to EAGAIN, instead of
-  returning EAGAIN directly.
-
-- fix sem_post() to wake up multiple threads when called rapidly in
-  succession.
-
-- DNS: partial implementation of RFC3484 (rule 1, 2, 5, 6, 8, 10 and
-  modified rule 9), for better address selection/sorting.
-  In the process, removed code that was previously used for "sortlist"
-  in /etc/resolv.conf. (resolv.conf is already ignored, so the latter
-  is a no-op for actual functionality.)
-
-- fix pthread_sigmask() to properly return an error code without touching
-  errno. Previous implementation returned -1 on error, setting errno, which
-  is not Posix compliant.
-
-- add sigaltstack() implementation for ARM.
-
-- <time.h>: Properly implement the 'timezone' and 'daylight' global variables
-  (they were not defined previously, though declared in the header).
-
-- <time.h>: Fix timezone management implementation to properly update
-  'tm_gmtoff' field in 'struct tm' structure.
-
-- DNS: get rid of spurious random DNS queries when trying to resolve
-  an unknown domain name. Due to an initialization bug, a random DNS search
-  list was generated for each thread if net.dns.search is not defined.
-
-- <pthread.h>: Add pthread_condattr_init/destroy/setpshared/getpshared functions
-  to enable proper shared conditional variable initialization.
-
-  Modify the pthread_mutex_t and pthread_cond_t implementation to use private
-  futexes for performance reasons. Mutexes and Condvars are no longer shareable
-  between processes by default anymore, unless you use PTHREAD_PROCESS_SHARED
-  with pthread_mutexattr_setpshared() and/or pthread_condattr_setpshared().
-
--------------------------------------------------------------------------------
-Differences between Android 2.1 and 2.0.1:
-
-- zoneinfo: updated data tables to version 2009s
-
-
--------------------------------------------------------------------------------
-Differences between Android 2.0.1 and 2.0:
-
-- abort(): ARM-specific hack to preserve the 'lr' register when abort()
-  is called (GCC does not preserve it by default since it thinks that
-  abort() never returns). This improves stack traces considerably.
-
-
--------------------------------------------------------------------------------
-Differences between Android 2.0 and 1.6:
-
-- memcmp(), memcpy(): ARMv7 optimized versions.
-
-- pthread_mutexattr_setpshared(): implementation will not return ENOTSUP
-  if PTHREAD_PROCESS_SHARED is used, because our Mutex implementation can
-  work across multiple processes.
-
-  *HOWEVER* it does not use "robust futexes" which means that held mutexes
-  *are not* automatically released by the kernel when the owner process
-  crashes or exits. This is only done to simplify communication between
-  two always-live system processes, DO NOT USE THIS IN APPLICATIONS !
-
-- pthread_mutex_lock_timeout_np(): New Android-specific function to
-  perform a timed lock (). In case of timeout, it returns EBUSY.
-
-- pthread_cond_timedwait_monotonic_np(): Same as pthread_cond_timedwait()
-  but uses the monotonic clock(). Android-specific.
-
-- pthread_cond_timedwait_relative_np(): Same as pthread_cond_timedwait()
-  but uses a relative timeout instead. Android-specific.
-
-- <netinet/in.h>: Now includes <netinet/in6.h>.
-
-- <netinet/in6.h>: Added IPV6_JOIN_GROUP, IPV6_LEAVE_GROUP, IN6ADDR_ANY_INIT
-  and ipv6mr_interface definitions.
-
-- <time.h>:
-    * Add missing tzset() declaration.
-    * Add Android-specific strftime_tz().
-
-- getaddrinfo():
-    Only perform IPv6 lookup for AF_UNSPEC if we have IPv6 connectivity.
-    This saves one DNS query per lookup on non-IPv6 systems.
-
-- mktime(): Fix an infinite loop problen that appeared when switching to
-  GCC 4.4.0.
-
-- strftime(): fix incorrect handling of dates > 2038 due to 64-bit issue
-  in original code.
-
--------------------------------------------------------------------------------
-Differences between Android 1.6 and 1.5:
-
-- C runtime: Fix runtime initialization to be called before any static C++
-  constructors. This allows these to use pthread functions properly.
-
-- __aeabi_atexit(): Fix implementation to properly call C++ static destructors
-  when the program exits (or when a shared library is unloaded).
-
-- <sys/stat.h>: added GLibc compatibility macros definitions:
-
-        #define  st_atimensec  st_atime_nsec
-        #define  st_mtimensec  st_mtime_nsec
-        #define  st_ctimensec  st_ctime_nsec
-
-- getaddrinfo(): implementation will now allow numeric ports if ai_socktype is
-  set to ANY. This is to match the GLibc behaviour.
-
-- getservent(): and getservent_r() incorrectly returned the port in host-endian
-  order in the s_port field. It now returns it in big-endian order.
-
-- DNS: Allow underscore in the middle of DNS labels. While not really
-  standard, this extension is needed for some VPN configurations and is
-  supported by other operating systems.
-
-- DNS: Support for DNS domain search lists through the new net.dns.search
-  system property. The corresponding value must be a space-separated list of
-  domain suffixes.
diff --git a/libc/docs/ISSUES.TXT b/libc/docs/ISSUES.TXT
deleted file mode 100644
index b53eb16..0000000
--- a/libc/docs/ISSUES.TXT
+++ /dev/null
@@ -1,20 +0,0 @@
-Bionic C Library Issues:
-========================
-
-This document lists important known issues of various releases
-of the Bionic C library. Note that these differ from specific
-implementation choices that are documented in the OVERVIEW.TXT
-document.
-
-Currently known issues:
------------------------
-
-- The C library initialization will improperly run static C++
-  constructors located in shared libraries twice.
-
-Android-1.5 issues:
--------------------
-
-- getservbyname() returned the port number in the s_port field of
-  the 'struct servent' structure in host-byte-order, instead of
-  network-byte-order.
diff --git a/libc/docs/OVERVIEW.TXT b/libc/docs/OVERVIEW.TXT
deleted file mode 100644
index 753e48a..0000000
--- a/libc/docs/OVERVIEW.TXT
+++ /dev/null
@@ -1,400 +0,0 @@
-Bionic C Library Overview:
-==========================
-
-Introduction:
-
-Core Philosophy:
-
-  The core idea behind Bionic's design is: KEEP IT REALLY SIMPLE.
-
-  This implies that the C library should only provide lightweight wrappers
-  around kernel facilities and not try to be too smart to deal with edge cases.
-
-  The name "Bionic" comes from the fact that it is part-BSD and part-Linux:
-  its source code consists in a mix of BSD C library pieces with custom
-  Linux-specific bits used to deal with threads, processes, signals and a few
-  others things.
-
-  All original BSD pieces carry the BSD copyright disclaimer. Bionic-specific 
-  bits carry the Android Open Source Project copyright disclaimer. And
-  everything is released under the BSD license.
-
-Architectures:
-
-  Bionic currently supports the ARM and x86 instruction sets. In theory, it
-  should be possible to support more, but this may require a little work (e.g.
-  adding system call IDs to SYSCALLS.TXT, described below, or modifying the
-  dynamic linker).
-
-  The ARM-specific code is under arch-arm/ and the x86-specific one is under
-  arch-x86/
-
-  Note that the x86 version is only meant to run on an x86 Android device. We
-  make absolutely no claim that you could build and use Bionic on a stock x86
-  Linux distribution (though that would be cool, so patches are welcomed :-))
-
-Syscall stubs:
-
-  Each system call function is implemented by a tiny assembler source fragment
-  (called a "syscall stub"), which is generated automatically by
-  tools/gensyscalls.py which reads the SYSCALLS.TXT file for input.
-
-  SYSCALLS.TXT contains the list of all syscall stubs to generate, along with
-  the corresponding syscall numeric identifier (which may differ between ARM
-  and x86), and its signature
-
-  If you modify this file, you may want to use tools/checksyscalls.py which
-  checks its content against official Linux kernel header files, and will
-  report errors when invalid syscall ids are used.
-
-  Sometimes, the C library function is really a wrapper that calls the
-  corresponding syscall with another name. For example, the exit() function
-  is provided by the C library and calls the _exit() syscall stub.
-
-  See SYSCALLS.TXT for documentation and details.
-
-
-time_t:
-
-  time_t is 32-bit as defined by the kernel on 32-bit CPUs. A 64-bit version
-  would be preferrable to avoid the Y2038 bug, but the kernel maintainers
-  consider that this is not needed at the moment.
-
-  Instead, Bionic provides a <time64.h> header that defines a time64_t type,
-  and related functions like mktime64(), localtime64(), etc...
-
-  strftime() uses time64_t internally, so the '%s' format (seconds since the
-  epoch) is supported for dates >= 2038.
-
-
-strftime_tz():
-
-  Bionic also provides the non-standard strftime_tz() function, a variant
-  of strftime() which also accepts a time locale descriptor as defined
-  by "struct strftime_locale" in <time.h>.
-
-  This function is used by the low-level framework code in Android.
-
-
-Timezone management:
-
-  The name of the current timezone is taken from the TZ environment variable,
-  if defined. Otherwise, the system property named 'persist.sys.timezone' is
-  checked instead.
-
-  The zoneinfo timezone database and index files are located under directory
-  /system/usr/share/zoneinfo, instead of the more Posix-compliant path of
-  /usr/share/zoneinfo
-
-
-off_t:
-
-  For similar reasons, off_t is 32-bit. We define loff_t as the 64-bit variant
-  due to BSD inheritance, but off64_t should be available as a typedef to ease
-  porting of current Linux-specific code.
-
-
-Linux kernel headers:
-
-  Bionic comes with its own set of "clean" Linux kernel headers to allow
-  user-space code to use kernel-specific declarations (e.g. IOCTLs, structure
-  declarations, constants, etc...). They are located in:
-
-     ./kernel/common,
-     ./kernel/arch-arm
-     ./kernel/arch-x86
-
-  These headers have been generated by a tool (kernel/tools/update-all.py) to
-  only include the public definitions from the original Linux kernel headers.
-
-  If you want to know why and how this is done, read kernel/README.TXT to get
-  all the (gory) details.
-
-
-PThread implementation:
-
-   Bionic's C library comes with its own pthread implementation bundled in.
-   This is different from other historical C libraries which:
-
-    - place it in an external library (-lpthread)
-    - play linker tricks with weak symbols at dynamic link time
-
-   The support for real-time features (a.k.a. -lrt) is also bundled in the
-   C library.
-
-   The implementation is based on futexes and strives to provide *very* short
-   code paths for common operations. Notable features are the following:
-
-      - pthread_mutex_t, pthread_cond_t are only 4 bytes each.
-
-      - Normal, recursive and error-check mutexes are supported, and the code
-        path is heavily optimized for the normal case, which is used most of
-        the time.
-
-      - Process-shared mutexes and condition variables are not supported.
-        Their implementation requires far more complexity and was absolutely
-        not needed for Android (which uses other inter-process synchronization
-        capabilities).
-
-        Note that they could be added in the future without breaking the ABI
-        by specifying more sophisticated code paths (which may make the common
-        paths slightly slower though).
-
-      - There is currently no support for read/write locks, priority-ceiling in
-        mutexes and other more advanced features. Again, the main idea being
-        that this was not needed for Android at all but could be added in the
-        future.
-
-pthread_cancel():
-
-   pthread_cancel() will *not* be supported in Bionic, because doing this would
-   involve making the C library significantly bigger for very little benefit.
-
-   Consider that:
-
-     - A proper implementation must insert pthread cancellation checks in a lot
-       of different places of the C library. And conformance is very difficult
-       to test properly.
-
-     - A proper implementation must also clean up resources, like releasing
-       memory, or unlocking mutexes, properly if the cancellation happens in a
-       complex function (e.g. inside gethostbyname() or fprintf() + complex
-       formatting rules). This tends to slow down the path of many functions.
-
-     - pthread cancellation cannot stop all threads: e.g. it can't do anything
-       against an infinite loop
-
-     - pthread cancellation itself has short-comings and isn't very portable
-       (see http://advogato.org/person/slamb/diary.html?start=49 for example).
-
-   All of this is contrary to the Bionic design goals. If your code depends on
-   thread cancellation, please consider alternatives.
-
-   Note however that Bionic does implement pthread_cleanup_push() and
-   pthread_cleanup_pop(), which can be used to handle cleanups that happen when
-   a thread voluntarily exits through pthread_exit() or returning from its
-   main function.
-
-
-pthread_once():
-
-  Do not call fork() within a callback provided to pthread_once(). Doing this
-  may result in a deadlock in the child process the next time it calls
-  pthread_once().
-
-  Also, you can't throw a C++ Exception from the callback (see C++ Exception
-  Support below).
-
-  The current implementation of pthread_once() lacks the necessary support of
-  multi-core-safe double-checked-locking (read and write barriers).
-
-
-Thread-specific data
-
-  The thread-specific storage only provides for a bit less than 64
-  pthread_key_t objects to each process. The implementation provides 64 real
-  slots but also uses about 5 of them (exact number may depend on
-  implementation) for its own use (e.g. two slots are pre-allocated by the C
-  library to speed-up the Android OpenGL sub-system).
-
-  Note that Posix mandates a minimum of 128 slots, but we do not claim to be
-  Posix-compliant.
-
-  Except for the main thread, the TLS area is stored at the top of the stack.
-  See comments in bionic/libc/bionic/pthread.c for details.
-
-  At the moment, thread-local storage defined through the __thread compiler
-  keyword is not supported by the Bionic C library and dynamic linker.
-
-
-Multi-core support
-
-  At the moment, Bionic does not provide or use read/write memory barriers.
-  This means that using it on certain multi-core systems might not be
-  supported, depending on its exact CPU architecture.
-
-
-Android-specific features:
-
-  Bionic provides a small number of Android-specific features to its clients:
-
-  - access to system properties:
-
-       Android provides a simple shared value/key space to all processes on the
-       system. It stores a liberal number of 'properties', each of them being a
-       simple size-limited string that can be associated to a size-limited
-       string value.
-
-       The header <sys/system_properties.h> can be used to read system
-       properties and also defines the maximum size of keys and values.
-
-   - Android-specific user/group management:
-
-       There is no /etc/passwd or /etc/groups in Android. By design, it is
-       meant to be used by a single handset user. On the other hand, Android
-       uses the Linux user/group management features extensively to secure
-       process permissions, like access to various filesystem directories.
-
-       In the Android scheme, each installed application gets its own
-       uid_t/gid_t starting from 10000; lower numerical ids are reserved for
-       system daemons.
-
-       getpwnam() recognizes some hard-coded subsystems names (e.g. "radio")
-       and will translate them to their low-user-id values. It also recognizes
-       "app_1234" as the synthetic name of the application that was installed
-       with uid 10000 + 1234, which is 11234. getgrnam() works similarly
-
-       getgrouplist() will always return a single group for any user name,
-       which is the one passed as an input parameter.
-
-       getgrgid() will similarly only return a structure that contains a
-       single-element members list, corresponding to the user with the same
-       numerical value than the group.
-
-       See bionic/libc/bionic/stubs.c for more details.
-
-    - getservent()
-
-       There is no /etc/services on Android. Instead the C library embeds a
-       constant list of services in its executable, which is parsed on demand
-       by the various functions that depend on it. See
-       bionic/libc/netbsd/net/getservent.c and
-       bionic/libc/netbsd/net/services.h
-
-       The list of services defined internally might change liberally in the
-       future. This feature is mostly historically and is very rarely used.
-
-       The getservent() returns thread-local data. getservbyport() and
-       getservbyname() are also implemented in a similar fashion.
-
-     - getprotoent()
-
-       There is no /etc/protocol on Android. Bionic does not currently
-       implement getprotoent() and related functions. If added, it will
-       likely be done in a way similar to getservent()
-
-DNS resolver:
-
-  Bionic uses a NetBSD-derived resolver library which has been modified in
-  the following ways:
-
-     - don't implement the name-server-switch feature (a.k.a. <nsswitch.h>)
-
-     - read /system/etc/resolv.conf instead of /etc/resolv.conf
-
-     - read the list of servers from system properties. the code looks for
-       'net.dns1', 'net.dns2', etc.. Each property should contain the IP
-       address of a DNS server.
-
-       these properties are set/modified by other parts of the Android system
-       (e.g. the dhcpd daemon).
-
-       the implementation also supports per-process DNS server list, using the
-       properties 'net.dns1.<pid>', 'net.dns2.<pid>', etc... Where <pid> stands
-       for the numerical ID of the current process.
-
-     - when performing a query, use a properly randomized Query ID (instead of
-       a incremented one), for increased security.
-
-     - when performing a query, bind the local client socket to a random port
-       for increased security.
-
-     - get rid of *many* unfortunate thread-safety issues in the original code
-
-  Bionic does *not* expose implementation details of its DNS resolver; the
-  content of <arpa/nameser.h> is intentionally blank. The resolver
-  implementation might change completely in the future.
-
-
-PThread Real-Time Timers:
-
-  timer_create(), timer_gettime(), timer_settime() and timer_getoverrun() are
-  supported.
-
-  Bionic also now supports SIGEV_THREAD real-time timers (see timer_create()).
-  The implementation simply uses a single thread per timer, unlike GLibc which
-  uses complex heuristics to try to use the less threads possible when several
-  timers with compatible properties are used.
-
-  This means that if your code uses a lot of SIGEV_THREAD timers, your program
-  may consume a lot of memory. However, if your program needs many of these
-  timers, it'd better handle timeout events directly instead.
-
-  Other timers (e.g. SIGEV_SIGNAL) are handled by the kernel and use much less
-  system resources.
-
-
-Binary Compatibility:
-
-  Bionic is *not* in any way binary-compatible with the GNU C Library, ucLibc
-  or any known Linux C library. This means several things:
-
-  - You cannot expect to build something against the GNU C Library headers and
-    have it dynamically link properly to Bionic later.
-
-  - You should *really* use the Android toolchain to build your program against
-    Bionic. The toolchain deals with many important details that are crucial
-    to get something working properly.
-
-  Failure to do so will usually result in the inability to run or link your
-  program, or even runtime crashes. Several random web pages on the Internet
-  describe how you can succesfully write a "hello-world" program with the
-  ARM GNU toolchain. These examples usually work by chance, if anything else,
-  and you should not follow these instructions unless you want to waste a lot
-  of your time in the process.
-
-  Note however that you *can* generate a binary that is built against the
-  GNU C Library headers and then statically linked to it. The corresponding
-  executable should be able to run (if it doesn't use dlopen()/dlsym())
-
-
-Dynamic Linker:
-
-  Bionic comes with its own dynamic linker (just like ld.so on Linux really
-  comes from GLibc). This linker does not support all the relocations
-  generated by other GCC ARM toolchains.
-
-
-C++ Exceptions Support:
-
-  At the moment, Bionic doesn't support C++ exceptions, what this really means
-  is the following:
-
-    - If pthread_once() is called with a C++ callback that throws an exception,
-      then the C library will keep the corresponding pthread_once_t mutex
-      locked. Any further call to pthread_once() will result in a deadlock.
-
-      A proper implementation should be able to register a C++ exception
-      cleanup handler before the callback to properly unlock the
-      pthread_once_t. Unfortunately this requires tricky assembly code that
-      is highly dependent on the compiler.
-
-      This feature is not planned to be supported anytime soon.
-
-    - The same problem may arise if you throw an exception within a callback
-      called from the C library. Fortunately, these cases are very rare in the
-      real-world, but any callback you provide to the C library should *not*
-      throw an exception.
-
-    - Bionic lacks a few support functions to have exception support work
-      properly.
-
-System V IPCs:
-
-  Bionic intentionally does not provide support for System-V IPCs mechanisms,
-  like the ones provided by semget(), shmget(), msgget(). The reason for this
-  is to avoid denial-of-service. For a detailed rationale about this, please
-  read the file docs/SYSV-IPCS.TXT.
-
-Include Paths:
-
-  The Android build system should automatically provide the necessary include
-  paths required to build against the C library headers. However, if you want
-  to do that yourself, you will need to add:
-
-      libc/arch-$ARCH/include
-      libc/include
-      libc/kernel/common
-      libc/kernel/arch-$ARCH
-
-  to your C include path.
diff --git a/libc/docs/SYSV-IPC.TXT b/libc/docs/SYSV-IPC.TXT
deleted file mode 100644
index 5a3eef0..0000000
--- a/libc/docs/SYSV-IPC.TXT
+++ /dev/null
@@ -1,103 +0,0 @@
-Android does not support System V IPCs, i.e. the facilities provided by the
-following standard Posix headers:
-
-  <sys/sem.h>   /* SysV semaphores */
-  <sys/shm.h>   /* SysV shared memory segments */
-  <sys/msg.h>   /* SysV message queues */
-  <sys/ipc.h>   /* General IPC definitions */
-
-The reason for this is due to the fact that, by design, they lead to global
-kernel resource leakage.
-
-For example, there is no way to automatically release a SysV semaphore
-allocated in the kernel when:
-
-- a buggy or malicious process exits
-- a non-buggy and non-malicious process crashes or is explicitely killed.
-
-Killing processes automatically to make room for new ones is an
-important part of Android's application lifecycle implementation. This means
-that, even assuming only non-buggy and non-malicious code, it is very likely
-that over time, the kernel global tables used to implement SysV IPCs will fill
-up.
-
-At that point, strange failures are likely to occur and prevent programs that
-use them to run properly until the next reboot of the system.
-
-And we can't ignore potential malicious applications. As a proof of concept
-here is a simple exploit that you can run on a standard Linux box today:
-
---------------- cut here ------------------------
-#include <sys/sem.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#define  NUM_SEMAPHORES  32
-#define  MAX_FAILS       10
-
-int  main(void)
-{
-    int   counter = 0;
-    int   fails   = 0;
-
-    if (counter == IPC_PRIVATE)
-        counter++;
-
-    printf( "%d (NUM_SEMAPHORES=%d)\n", counter, NUM_SEMAPHORES);
-
-    for (;;) {
-        int  ret = fork();
-        int  status;
-
-        if (ret < 0) {
-            perror("fork:");
-            break;
-        }
-        if (ret == 0) {
-            /* in the child */
-            ret = semget( (key_t)counter, NUM_SEMAPHORES, IPC_CREAT );
-            if (ret < 0) {
-                return errno;
-            }
-            return 0;
-        }
-        else {
-            /* in the parent */
-            ret = wait(&status);
-            if (ret < 0) {
-                perror("waitpid:");
-                break;
-            }
-            if (status != 0) {
-                status = WEXITSTATUS(status);
-                fprintf(stderr, "child %d FAIL at counter=%d: %d\n", ret,
-                                counter, status);
-                if (++fails >= MAX_FAILS)
-                    break;
-            }
-        }
-
-        counter++;
-        if ((counter % 1000) == 0) {
-            printf("%d\n", counter);
-        }
-        if (counter == IPC_PRIVATE)
-            counter++;
-    }
-    return 0;
-}
---------------- cut here ------------------------
-
-If you run it on a typical Linux distribution today, you'll discover that it
-will quickly fill up the kernel's table of unique key_t values, and that
-strange things will happen in some parts of the system, but not all.
-
-(You can use the "ipcs -u" command to get a summary describing the kernel
- tables and their allocations)
-
-For example, in our experience, anything program launched after that that
-calls strerror() will simply crash. The USB sub-system starts spoutting weird
-errors to the system console, etc...
diff --git a/libc/include/arpa/inet.h b/libc/include/arpa/inet.h
index e78e7c5..b008812 100644
--- a/libc/include/arpa/inet.h
+++ b/libc/include/arpa/inet.h
@@ -42,7 +42,7 @@
 extern char*         inet_ntoa(struct in_addr);
 
 extern int           inet_pton(int, const char *, void *);
-extern const char*   inet_ntop(int, const void *, char *, size_t);
+extern const char*   inet_ntop(int, const void *, char *, socklen_t);
 
 extern unsigned int  inet_nsap_addr(const char *, unsigned char *, int);
 extern char*         inet_nsap_ntoa(int, const unsigned char *, char *);
diff --git a/libc/include/dirent.h b/libc/include/dirent.h
index 55eef7b..3bd7a0f 100644
--- a/libc/include/dirent.h
+++ b/libc/include/dirent.h
@@ -45,34 +45,30 @@
 #define  DT_WHT         14
 #endif
 
-/* the following structure is really called dirent64 by the kernel
- * headers. They also define a struct dirent, but the latter lack
- * the d_type field which is required by some libraries (e.g. hotplug)
- * who assume to be able to access it directly. sad...
- */
 struct dirent {
-    uint64_t         d_ino;
-    int64_t          d_off;
-    unsigned short   d_reclen;
-    unsigned char    d_type;
-    char             d_name[256];
+  uint64_t         d_ino;
+  int64_t          d_off;
+  unsigned short   d_reclen;
+  unsigned char    d_type;
+  char             d_name[256];
 };
 
-typedef struct DIR  DIR;
+typedef struct DIR DIR;
+
+extern  DIR*             opendir(const char* dirpath);
+extern  DIR*             fdopendir(int fd);
+extern  struct dirent*   readdir(DIR* dirp);
+extern  int              readdir_r(DIR*  dirp, struct dirent* entry, struct dirent** result);
+extern  int              closedir(DIR* dirp);
+extern  void             rewinddir(DIR* dirp);
+extern  int              dirfd(DIR* dirp);
+extern  int              alphasort(const struct dirent** a, const struct dirent** b);
+extern  int              scandir(const char* dir, struct dirent*** namelist,
+                                 int(*filter)(const struct dirent*),
+                                 int(*compar)(const struct dirent**,
+                                              const struct dirent**));
 
 extern  int              getdents(unsigned int, struct dirent*, unsigned int);
-extern  DIR*             opendir(const char*  dirpath);
-extern  DIR*             fdopendir(int fd);
-extern  struct dirent*   readdir(DIR*  dirp);
-extern  int              readdir_r(DIR*  dirp, struct dirent *entry, struct dirent **result);
-extern  int              closedir(DIR*  dirp);
-extern  void             rewinddir(DIR *dirp);
-extern  int              dirfd(DIR* dirp);
-extern  int              alphasort(const void *a, const void *b);
-extern  int              scandir(const char *dir, struct dirent ***namelist,
-                                 int(*filter)(const struct dirent *),
-                                 int(*compar)(const struct dirent **, 
-                                              const struct dirent **));
 
 __END_DECLS
 
diff --git a/libc/include/elf.h b/libc/include/elf.h
index c3e3226..ac0f1d2 100644
--- a/libc/include/elf.h
+++ b/libc/include/elf.h
@@ -28,8 +28,23 @@
 #ifndef _ELF_H
 #define _ELF_H
 
+#include <stdint.h>
 #include <linux/auxvec.h>
 #include <sys/exec_elf.h>
 
+typedef struct {
+  uint32_t a_type;
+  union {
+    uint32_t a_val;
+  } a_un;
+} Elf32_auxv_t;
+
+typedef struct {
+  uint64_t a_type;
+  union {
+    uint64_t a_val;
+  } a_un;
+} Elf64_auxv_t;
+
 #endif /* _ELF_H */
 
diff --git a/libc/include/errno.h b/libc/include/errno.h
index e1b15c0..2e5ce5f 100644
--- a/libc/include/errno.h
+++ b/libc/include/errno.h
@@ -40,10 +40,6 @@
 #define  ENOTSUP  EOPNOTSUPP
 #endif
 
-/* internal function that should *only* be called from system calls */
-/* use errno = xxxx instead in C code                               */
-extern int    __set_errno(int  error);
-
 /* internal function returning the address of the thread-specific errno */
 extern volatile int*   __errno(void);
 
diff --git a/libc/include/limits.h b/libc/include/limits.h
index d691a8f..b9d4354 100644
--- a/libc/include/limits.h
+++ b/libc/include/limits.h
@@ -89,6 +89,22 @@
 #include <sys/syslimits.h>
 #endif
 
+/* GLibc compatibility definitions.
+   Note that these are defined by GCC's <limits.h>
+   only when __GNU_LIBRARY__ is defined, i.e. when
+   targetting GLibc. */
+#ifndef LONG_LONG_MIN
+#define LONG_LONG_MIN  LLONG_MIN
+#endif
+
+#ifndef LONG_LONG_MAX
+#define LONG_LONG_MAX  LLONG_MAX
+#endif
+
+#ifndef ULONG_LONG_MAX
+#define ULONG_LONG_MAX  ULLONG_MAX
+#endif
+
 #ifndef PAGESIZE
 #include <asm/page.h>
 #define  PAGESIZE  PAGE_SIZE
diff --git a/libc/include/malloc.h b/libc/include/malloc.h
index ec21926..8875e54 100644
--- a/libc/include/malloc.h
+++ b/libc/include/malloc.h
@@ -27,30 +27,30 @@
 
 __BEGIN_DECLS
 
-extern __mallocfunc void*  malloc(size_t);
-extern __mallocfunc void*  calloc(size_t, size_t);
-extern void*  realloc(void *, size_t);
-extern void   free(void *);
+extern void* malloc(size_t byte_count) __mallocfunc __wur;
+extern void* calloc(size_t item_count, size_t item_size) __mallocfunc __wur;
+extern void* realloc(void* p, size_t byte_count) __wur;
+extern void free(void* p);
 
-extern void*  memalign(size_t  alignment, size_t  bytesize);
-extern size_t malloc_usable_size(void*);
+extern void* memalign(size_t alignment, size_t byte_count) __mallocfunc __wur;
+extern size_t malloc_usable_size(void* p);
 
-extern void*  valloc(size_t  bytesize);
-extern void*  pvalloc(size_t bytesize);
+extern void* valloc(size_t byte_count) __mallocfunc __wur;
+extern void* pvalloc(size_t byte_count) __mallocfunc __wur;
 
 #ifndef STRUCT_MALLINFO_DECLARED
 #define STRUCT_MALLINFO_DECLARED 1
 struct mallinfo {
-  size_t arena;
-  size_t ordblks;
-  size_t smblks;
-  size_t hblks;
-  size_t hblkhd;
-  size_t usmblks;
-  size_t fsmblks;
-  size_t uordblks;
-  size_t fordblks;
-  size_t keepcost;
+  size_t arena;    /* Total number of non-mmapped bytes currently allocated from OS. */
+  size_t ordblks;  /* Number of free chunks. */
+  size_t smblks;   /* (Unused.) */
+  size_t hblks;    /* (Unused.) */
+  size_t hblkhd;   /* Total number of bytes in mmapped regions. */
+  size_t usmblks;  /* Maximum total allocated space; greater than total if trimming has occurred. */
+  size_t fsmblks;  /* (Unused.) */
+  size_t uordblks; /* Total allocated space (normal or mmapped.) */
+  size_t fordblks; /* Total free space. */
+  size_t keepcost; /* Upper bound on number of bytes releasable by malloc_trim. */
 };
 #endif  /* STRUCT_MALLINFO_DECLARED */
 
diff --git a/libc/include/memory.h b/libc/include/memory.h
index e69de29..3b2f590 100644
--- a/libc/include/memory.h
+++ b/libc/include/memory.h
@@ -0,0 +1 @@
+#include <string.h>
diff --git a/libc/include/pthread.h b/libc/include/pthread.h
index 2015ac0..dbdee70 100644
--- a/libc/include/pthread.h
+++ b/libc/include/pthread.h
@@ -151,7 +151,7 @@
 
 int pthread_getschedparam(pthread_t thid, int * policy,
                           struct sched_param * param);
-int pthread_setschedparam(pthread_t thid, int poilcy,
+int pthread_setschedparam(pthread_t thid, int policy,
                           struct sched_param const * param);
 
 int pthread_mutexattr_init(pthread_mutexattr_t *attr);
@@ -310,9 +310,4 @@
 } /* extern "C" */
 #endif
 
-/************ TO FIX ************/
-
-#define LONG_LONG_MAX __LONG_LONG_MAX__
-#define LONG_LONG_MIN (-__LONG_LONG_MAX__ - 1)
-
 #endif /* _PTHREAD_H_ */
diff --git a/libc/include/search.h b/libc/include/search.h
index ed0d216..e12e49e 100644
--- a/libc/include/search.h
+++ b/libc/include/search.h
@@ -12,13 +12,6 @@
 #include <sys/cdefs.h>
 #include <sys/_types.h>
 
-#if 0
-#ifndef _SIZE_T_DECLARED
-typedef	__size_t	size_t;
-#define	_SIZE_T_DECLARED
-#endif
-#endif
-
 typedef	enum {
 	preorder,
 	postorder,
diff --git a/libc/include/sha1.h b/libc/include/sha1.h
index f7ada46..7f6cf5d 100644
--- a/libc/include/sha1.h
+++ b/libc/include/sha1.h
@@ -1,31 +1,23 @@
-/*	$NetBSD: sha1.h,v 1.13 2005/12/26 18:41:36 perry Exp $	*/
-
 /*
- * SHA-1 in C
- * By Steve Reid <steve@edmweb.com>
- * 100% Public Domain
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
-#ifndef _SYS_SHA1_H_
-#define	_SYS_SHA1_H_
+#ifndef _SHA1_H_
+#define _SHA1_H_
 
-#include <sys/cdefs.h>
-#include <sys/types.h>
+#warning "include <sys/sha1.h> instead for better portability"
+#include <sys/sha1.h>
 
-#define SHA1_DIGEST_LENGTH		20
-#define SHA1_DIGEST_STRING_LENGTH	41
-
-typedef struct {
-	uint32_t state[5];
-	uint32_t count[2];
-	u_char buffer[64];
-} SHA1_CTX;
-
-__BEGIN_DECLS
-void	SHA1Transform(uint32_t[5], const u_char[64]);
-void	SHA1Init(SHA1_CTX *);
-void	SHA1Update(SHA1_CTX *, const u_char *, u_int);
-void	SHA1Final(u_char[SHA1_DIGEST_LENGTH], SHA1_CTX *);
-__END_DECLS
-
-#endif /* _SYS_SHA1_H_ */
+#endif
diff --git a/libc/include/signal.h b/libc/include/signal.h
index 6432c18..8c9b170 100644
--- a/libc/include/signal.h
+++ b/libc/include/signal.h
@@ -28,6 +28,7 @@
 #ifndef _SIGNAL_H_
 #define _SIGNAL_H_
 
+#include <errno.h>
 #include <sys/cdefs.h>
 #include <limits.h>		/* For LONG_BIT */
 #include <string.h>		/* For memset() */
@@ -53,45 +54,57 @@
 #  define _NSIG  64
 #endif
 
-extern const char * const sys_siglist[];
-extern const char * const sys_signame[];
+extern const char* const sys_siglist[];
+extern const char* const sys_signame[];
 
-static __inline__ int sigismember(sigset_t *set, int signum)
-{
-    unsigned long *local_set = (unsigned long *)set;
-    signum--;
-    return (int)((local_set[signum/LONG_BIT] >> (signum%LONG_BIT)) & 1);
+static __inline__ int sigismember(const sigset_t* set, int signum) {
+  int bit = signum - 1; // Signal numbers start at 1, but bit positions start at 0.
+  if (set == NULL || bit < 0 || bit >= (int) (8*sizeof(sigset_t))) {
+    errno = EINVAL;
+    return -1;
+  }
+  const unsigned long* local_set = (const unsigned long*) set;
+  return (int) ((local_set[bit / LONG_BIT] >> (bit % LONG_BIT)) & 1);
 }
 
-
-static __inline__ int sigaddset(sigset_t *set, int signum)
-{
-    unsigned long *local_set = (unsigned long *)set;
-    signum--;
-    local_set[signum/LONG_BIT] |= 1UL << (signum%LONG_BIT);
-    return 0;
+static __inline__ int sigaddset(sigset_t* set, int signum) {
+  int bit = signum - 1; // Signal numbers start at 1, but bit positions start at 0.
+  if (set == NULL || bit < 0 || bit >= (int) (8*sizeof(sigset_t))) {
+    errno = EINVAL;
+    return -1;
+  }
+  unsigned long* local_set = (unsigned long*) set;
+  local_set[bit / LONG_BIT] |= 1UL << (bit % LONG_BIT);
+  return 0;
 }
 
-
-static __inline__ int sigdelset(sigset_t *set, int signum)
-{
-    unsigned long *local_set = (unsigned long *)set;
-    signum--;
-    local_set[signum/LONG_BIT] &= ~(1UL << (signum%LONG_BIT));
-    return 0;
+static __inline__ int sigdelset(sigset_t* set, int signum) {
+  int bit = signum - 1; // Signal numbers start at 1, but bit positions start at 0.
+  if (set == NULL || bit < 0 || bit >= (int) (8*sizeof(sigset_t))) {
+    errno = EINVAL;
+    return -1;
+  }
+  unsigned long* local_set = (unsigned long*) set;
+  local_set[bit / LONG_BIT] &= ~(1UL << (bit % LONG_BIT));
+  return 0;
 }
 
-
-static __inline__ int sigemptyset(sigset_t *set)
-{
-    memset(set, 0, sizeof *set);
-    return 0;
+static __inline__ int sigemptyset(sigset_t* set) {
+  if (set == NULL) {
+    errno = EINVAL;
+    return -1;
+  }
+  memset(set, 0, sizeof *set);
+  return 0;
 }
 
-static __inline__ int sigfillset(sigset_t *set)
-{
-    memset(set, ~0, sizeof *set);
-    return 0;
+static __inline__ int sigfillset(sigset_t* set) {
+  if (set == NULL) {
+    errno = EINVAL;
+    return -1;
+  }
+  memset(set, ~0, sizeof *set);
+  return 0;
 }
 
 
diff --git a/libc/include/stdint.h b/libc/include/stdint.h
index 49879cb..c3e29dd 100644
--- a/libc/include/stdint.h
+++ b/libc/include/stdint.h
@@ -226,12 +226,6 @@
 #  define UINTMAX_C(c)	UINT64_C(c)
 #endif
 
-/* size_t is defined by the GCC-specific <stddef.h> */
-#ifndef _SSIZE_T_DEFINED_
-#define _SSIZE_T_DEFINED_
-typedef long int  ssize_t;
-#endif
-
 #define _BITSIZE 32
 
 /* Keep the kernel from trying to define these types... */
diff --git a/libc/include/stdio.h b/libc/include/stdio.h
index 8b95663..62882db 100644
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -39,40 +39,14 @@
 #define	_STDIO_H_
 
 #include <sys/cdefs.h>
-#include <sys/_types.h>
+#include <sys/types.h>
 
-/* va_list and size_t must be defined by stdio.h according to Posix */
-#define __need___va_list
 #include <stdarg.h>
-
-/* note that this forces stddef.h to *only* define size_t */
-#define __need_size_t
 #include <stddef.h>
 
+#define __need_NULL
 #include <stddef.h>
 
-#if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
-#include <sys/types.h>	/* XXX should be removed */
-#endif
-
-#ifndef	_SIZE_T_DEFINED_
-#define	_SIZE_T_DEFINED_
-typedef	unsigned long    size_t;
-#endif
-
-#ifndef	_OFF_T_DEFINED_
-#define	_OFF_T_DEFINED_
-typedef	long    off_t;
-#endif
-
-#ifndef NULL
-#ifdef 	__GNUG__
-#define	NULL	__null
-#else
-#define	NULL	0L
-#endif
-#endif
-
 #define	_FSTDIO			/* Define for new stdio with functions. */
 
 typedef off_t fpos_t;		/* stdio file position type */
@@ -249,6 +223,9 @@
 size_t	 fwrite(const void *, size_t, size_t, FILE *);
 int	 getc(FILE *);
 int	 getchar(void);
+ssize_t	 getdelim(char ** __restrict, size_t * __restrict, int,
+	    FILE * __restrict);
+ssize_t	 getline(char ** __restrict, size_t * __restrict, FILE * __restrict);
 char	*gets(char *);
 #if __BSD_VISIBLE && !defined(__SYS_ERRLIST)
 #define __SYS_ERRLIST
@@ -482,6 +459,8 @@
 
 #if defined(__BIONIC_FORTIFY_INLINE)
 
+__BEGIN_DECLS
+
 __BIONIC_FORTIFY_INLINE
 __attribute__((__format__ (printf, 3, 0)))
 __attribute__((__nonnull__ (3)))
@@ -544,19 +523,21 @@
 
     // Compiler can prove, at compile time, that the passed in size
     // is always <= the actual object size. Don't call __fgets_chk
-    if (__builtin_constant_p(size) && (size <= bos)) {
+    if (__builtin_constant_p(size) && (size <= (int) bos)) {
         return __fgets_real(dest, size, stream);
     }
 
     // Compiler can prove, at compile time, that the passed in size
     // is always > the actual object size. Force a compiler error.
-    if (__builtin_constant_p(size) && (size > bos)) {
+    if (__builtin_constant_p(size) && (size > (int) bos)) {
         __fgets_too_big_error();
     }
 
     return __fgets_chk(dest, size, stream, bos);
 }
 
+__END_DECLS
+
 #endif /* defined(__BIONIC_FORTIFY_INLINE) */
 
 #endif /* _STDIO_H_ */
diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h
index 9c0e556..e728cb6 100644
--- a/libc/include/stdlib.h
+++ b/libc/include/stdlib.h
@@ -30,12 +30,6 @@
 
 #include <sys/cdefs.h>
 
-/* wchar_t is required in stdlib.h according to POSIX.
- * note that defining __need_wchar_t prevents stddef.h
- * to define all other symbols it does normally */
-#define __need_wchar_t
-#include <stddef.h>
-
 #include <stddef.h>
 #include <string.h>
 #include <alloca.h>
@@ -58,8 +52,8 @@
 extern int clearenv(void);
 
 extern char *mkdtemp(char *);
-extern char *mktemp (char *);
-extern int mkstemp (char *);
+extern char *mktemp(char *);
+extern int mkstemp(char *);
 
 extern long strtol(const char *, char **, int);
 extern long long strtoll(const char *, char **, int);
diff --git a/libc/include/string.h b/libc/include/string.h
index 06e2284..63e768e 100644
--- a/libc/include/string.h
+++ b/libc/include/string.h
@@ -45,7 +45,6 @@
 extern void   memswap(void *, void *, size_t);
 
 extern char*  index(const char *, int) __purefunc;
-extern char*  rindex(const char *, int) __purefunc;
 extern char*  strchr(const char *, int) __purefunc;
 extern char*  strrchr(const char *, int) __purefunc;
 
@@ -91,8 +90,6 @@
     __attribute__((__error__("memcpy called with size bigger than destination")));
 extern void __memcpy_src_size_error()
     __attribute__((__error__("memcpy called with size bigger than source")));
-extern void __memcpy_overlap_error()
-    __attribute__((__error__("memcpy called with overlapping regions")));
 
 __BIONIC_FORTIFY_INLINE
 void *memcpy (void *dest, const void *src, size_t copy_amount) {
@@ -109,11 +106,6 @@
         __memcpy_src_size_error();
     }
 
-    if (__builtin_constant_p(d - s) && __builtin_constant_p(copy_amount)
-            && (((size_t)(d - s) < copy_amount) || ((size_t)(s - d) < copy_amount))) {
-        __memcpy_overlap_error();
-    }
-
     return __builtin___memcpy_chk(dest, src, copy_amount, d_len);
 }
 
@@ -208,8 +200,6 @@
     return __strlcat_chk(dest, src, size, bos);
 }
 
-__purefunc extern size_t __strlen_real(const char *)
-    __asm__(__USER_LABEL_PREFIX__ "strlen");
 extern size_t __strlen_chk(const char *, size_t);
 
 __BIONIC_FORTIFY_INLINE
@@ -218,12 +208,56 @@
 
     // Compiler doesn't know destination size. Don't call __strlen_chk
     if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
-        return __strlen_real(s);
+        return __builtin_strlen(s);
+    }
+
+    size_t slen = __builtin_strlen(s);
+    if (__builtin_constant_p(slen)) {
+        return slen;
     }
 
     return __strlen_chk(s, bos);
 }
 
+extern char* __strchr_chk(const char *, int, size_t);
+
+__BIONIC_FORTIFY_INLINE
+char* strchr(const char *s, int c) {
+    size_t bos = __builtin_object_size(s, 0);
+
+    // Compiler doesn't know destination size. Don't call __strchr_chk
+    if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
+        return __builtin_strchr(s, c);
+    }
+
+    size_t slen = __builtin_strlen(s);
+    if (__builtin_constant_p(slen) && (slen < bos)) {
+        return __builtin_strchr(s, c);
+    }
+
+    return __strchr_chk(s, c, bos);
+}
+
+extern char* __strrchr_chk(const char *, int, size_t);
+
+__BIONIC_FORTIFY_INLINE
+char* strrchr(const char *s, int c) {
+    size_t bos = __builtin_object_size(s, 0);
+
+    // Compiler doesn't know destination size. Don't call __strrchr_chk
+    if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
+        return __builtin_strrchr(s, c);
+    }
+
+    size_t slen = __builtin_strlen(s);
+    if (__builtin_constant_p(slen) && (slen < bos)) {
+        return __builtin_strrchr(s, c);
+    }
+
+    return __strrchr_chk(s, c, bos);
+}
+
+
 #endif /* defined(__BIONIC_FORTIFY_INLINE) */
 
 __END_DECLS
diff --git a/libc/include/strings.h b/libc/include/strings.h
index db2aa3a..0ee691d 100644
--- a/libc/include/strings.h
+++ b/libc/include/strings.h
@@ -43,12 +43,10 @@
 #include <sys/cdefs.h>
 
 __BEGIN_DECLS
-int	 bcmp(const void *, const void *, size_t);
 void	 bcopy(const void *, void *, size_t);
 void	 bzero(void *, size_t);
 int	 ffs(int);
 char	*index(const char *, int);
-char	*rindex(const char *, int);
 int	 strcasecmp(const char *, const char *);
 int	 strncasecmp(const char *, const char *, size_t);
 
diff --git a/libc/include/sys/_system_properties.h b/libc/include/sys/_system_properties.h
index 42a7f6c..5d2043d 100644
--- a/libc/include/sys/_system_properties.h
+++ b/libc/include/sys/_system_properties.h
@@ -41,6 +41,7 @@
 #define PROP_AREA_VERSION 0x45434f76
 
 #define PROP_SERVICE_NAME "property_service"
+#define PROP_FILENAME "/dev/__properties__"
 
 /* #define PROP_MAX_ENTRIES 247 */
 /* 247 -> 32620 bytes (<32768) */
@@ -103,6 +104,7 @@
 #define PROP_PATH_SYSTEM_BUILD     "/system/build.prop"
 #define PROP_PATH_SYSTEM_DEFAULT   "/system/default.prop"
 #define PROP_PATH_LOCAL_OVERRIDE   "/data/local.prop"
+#define PROP_PATH_FACTORY          "/factory/factory.prop"
 
 #endif
 #endif
diff --git a/libc/include/sys/auxv.h b/libc/include/sys/auxv.h
new file mode 100644
index 0000000..918442f
--- /dev/null
+++ b/libc/include/sys/auxv.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef _SYS_AUXV_H_
+#define _SYS_AUXV_H_
+
+#include <linux/auxvec.h>
+
+__BEGIN_DECLS
+
+unsigned long int getauxval(unsigned long int type);
+
+__END_DECLS
+
+#endif /* _SYS_AUXV_H_ */
diff --git a/libc/include/sys/capability.h b/libc/include/sys/capability.h
new file mode 100644
index 0000000..7718a6c
--- /dev/null
+++ b/libc/include/sys/capability.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _BIONIC_SYS_CAPABILITY_H
+#define _BIONIC_SYS_CAPABILITY_H
+
+#include <sys/cdefs.h>
+#include <linux/capability.h>
+
+__BEGIN_DECLS
+
+extern int capget(cap_user_header_t hdrp, cap_user_data_t datap);
+extern int capset(cap_user_header_t hdrp, const cap_user_data_t datap);
+
+__END_DECLS
+
+#endif /* _BIONIC_SYS_CAPABILITY_H */
diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h
index ca81cb6..3617aba 100644
--- a/libc/include/sys/cdefs.h
+++ b/libc/include/sys/cdefs.h
@@ -177,6 +177,8 @@
 #define	__unused	/* delete */
 #endif
 
+#define __pure2 __attribute__((__const__)) /* Android-added: used by FreeBSD libm */
+
 #if __GNUC_PREREQ__(3, 1)
 #define	__used		__attribute__((__used__))
 #else
@@ -313,6 +315,18 @@
 #define __purefunc
 #endif
 
+#if __GNUC_PREREQ__(3, 1)
+#define __always_inline __attribute__((__always_inline__))
+#else
+#define __always_inline
+#endif
+
+#if __GNUC_PREREQ__(3, 4)
+#define __wur __attribute__((__warn_unused_result__))
+#else
+#define __wur
+#endif
+
 /*
  * Macros for manipulating "link sets".  Link sets are arrays of pointers
  * to objects, which are gathered up by the linker.
@@ -363,11 +377,11 @@
 #define	__link_set_entry(set, idx)	(__link_set_begin(set)[idx])
 
 /*
- * Some of the recend FreeBSD sources used in Bionic need this.
+ * Some of the FreeBSD sources used in Bionic need this.
  * Originally, this is used to embed the rcs versions of each source file
  * in the generated binary. We certainly don't want this in Bionic.
  */
-#define	__FBSDID(s)	struct __hack
+#define __FBSDID(s) /* nothing */
 
 /*-
  * The following definitions are an extension of the behavior originally
@@ -510,4 +524,11 @@
 #define __BIONIC_FORTIFY_UNKNOWN_SIZE ((size_t) -1)
 #endif
 
+/* Android-added: for FreeBSD's libm. */
+#define __weak_reference(sym,alias) \
+    __asm__(".weak " #alias); \
+    __asm__(".equ "  #alias ", " #sym)
+#define __strong_reference(sym,aliassym) \
+    extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))
+
 #endif /* !_SYS_CDEFS_H_ */
diff --git a/libc/include/sys/endian.h b/libc/include/sys/endian.h
index 00f4839..b0365d8 100644
--- a/libc/include/sys/endian.h
+++ b/libc/include/sys/endian.h
@@ -37,6 +37,7 @@
 #define _SYS_ENDIAN_H_
 
 #include <sys/cdefs.h>
+#include <machine/endian.h>
 #include <machine/_types.h>
 
 #define _LITTLE_ENDIAN	1234
@@ -158,22 +159,6 @@
 #define swap32 __swap32
 #define swap64 __swap64
 #define swap16_multi __swap16_multi
-
-__BEGIN_DECLS
-__uint64_t	htobe64(__uint64_t);
-__uint32_t	htobe32(__uint32_t);
-__uint16_t	htobe16(__uint16_t);
-__uint64_t	betoh64(__uint64_t);
-__uint32_t	betoh32(__uint32_t);
-__uint16_t	betoh16(__uint16_t);
-
-__uint64_t	htole64(__uint64_t);
-__uint32_t	htole32(__uint32_t);
-__uint16_t	htole16(__uint16_t);
-__uint64_t	letoh64(__uint64_t);
-__uint32_t	letoh32(__uint32_t);
-__uint16_t	letoh16(__uint16_t);
-__END_DECLS
 #endif /* __BSD_VISIBLE */
 
 #if _BYTE_ORDER == _LITTLE_ENDIAN
@@ -270,4 +255,20 @@
 #define  __BIG_ENDIAN       _BIG_ENDIAN
 #endif
 
+
+#ifdef __BSD_VISIBLE
+/*
+ * glibc-compatible beXXtoh/leXXtoh synonyms for htobeXX/htoleXX.
+ * The BSDs export both sets of names, bionic historically only
+ * exported the ones above (or on the rhs here), and glibc only
+ * exports these names (on the lhs).
+ */
+#define be16toh(x) htobe16(x)
+#define be32toh(x) htobe32(x)
+#define be64toh(x) htobe64(x)
+#define le16toh(x) htole16(x)
+#define le32toh(x) htole32(x)
+#define le64toh(x) htole64(x)
+#endif
+
 #endif /* _SYS_ENDIAN_H_ */
diff --git a/libc/include/sys/exec_elf.h b/libc/include/sys/exec_elf.h
index eecbd64..6d445bf 100644
--- a/libc/include/sys/exec_elf.h
+++ b/libc/include/sys/exec_elf.h
@@ -1,6 +1,11 @@
-/*	$OpenBSD: exec_elf.h,v 1.41 2006/01/06 18:53:05 millert Exp $	*/
-/*
- * Copyright (c) 1995, 1996 Erik Theisen.  All rights reserved.
+/*	$NetBSD: exec_elf.h,v 1.126 2012/08/05 01:43:59 matt Exp $	*/
+
+/*-
+ * Copyright (c) 1994 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -10,40 +15,164 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This is the ELF ABI header file
- * formerly known as "elf_abi.h".
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
  */
 
 #ifndef _SYS_EXEC_ELF_H_
 #define _SYS_EXEC_ELF_H_
 
-#include <machine/_types.h>
-#include <machine/exec.h>
-#include <linux/elf.h>
+/*
+ * The current ELF ABI specification is available at:
+ *	http://www.sco.com/developers/gabi/
+ *
+ * Current header definitions are in:
+ *	http://www.sco.com/developers/gabi/latest/ch4.eheader.html
+ */
 
-/* e_ident[] Operating System/ABI */
+#if defined(_KERNEL) || defined(_STANDALONE)
+#include <sys/types.h>
+#else
+#include <inttypes.h>
+#endif /* _KERNEL || _STANDALONE */
+
+#if HAVE_NBTOOL_CONFIG_H
+#include <nbinclude/machine/elf_machdep.h>
+#else
+#include <machine/elf_machdep.h>
+#endif
+
+typedef uint8_t		Elf_Byte;
+
+typedef uint32_t	Elf32_Addr;
+#define ELF32_FSZ_ADDR	4
+typedef uint32_t	Elf32_Off;
+typedef int32_t		Elf32_SOff;
+#define ELF32_FSZ_OFF	4
+typedef int32_t		Elf32_Sword;
+#define ELF32_FSZ_SWORD 4
+typedef uint32_t	Elf32_Word;
+#define ELF32_FSZ_WORD	4
+typedef uint16_t	Elf32_Half;
+#define ELF32_FSZ_HALF	2
+typedef uint64_t	Elf32_Lword;
+#define ELF32_FSZ_LWORD 8
+
+typedef uint64_t	Elf64_Addr;
+#define ELF64_FSZ_ADDR	8
+typedef uint64_t	Elf64_Off;
+typedef int64_t		Elf64_SOff;
+#define ELF64_FSZ_OFF	8
+typedef int32_t		Elf64_Shalf;
+#define ELF64_FSZ_SHALF 4
+
+typedef int32_t		Elf64_Sword;
+#define ELF64_FSZ_SWORD 4
+typedef uint32_t	Elf64_Word;
+#define ELF64_FSZ_WORD	4
+
+typedef int64_t		Elf64_Sxword;
+#define ELF64_FSZ_SXWORD 8
+typedef uint64_t	Elf64_Xword;
+#define ELF64_FSZ_XWORD 8
+typedef uint64_t	Elf64_Lword;
+#define ELF64_FSZ_LWORD 8
+typedef uint16_t	Elf64_Half;
+#define ELF64_FSZ_HALF 2
+
+/*
+ * ELF Header
+ */
+#define ELF_NIDENT	16
+
+typedef struct {
+	unsigned char	e_ident[ELF_NIDENT];	/* Id bytes */
+	Elf32_Half	e_type;			/* file type */
+	Elf32_Half	e_machine;		/* machine type */
+	Elf32_Word	e_version;		/* version number */
+	Elf32_Addr	e_entry;		/* entry point */
+	Elf32_Off	e_phoff;		/* Program hdr offset */
+	Elf32_Off	e_shoff;		/* Section hdr offset */
+	Elf32_Word	e_flags;		/* Processor flags */
+	Elf32_Half	e_ehsize;		/* sizeof ehdr */
+	Elf32_Half	e_phentsize;		/* Program header entry size */
+	Elf32_Half	e_phnum;		/* Number of program headers */
+	Elf32_Half	e_shentsize;		/* Section header entry size */
+	Elf32_Half	e_shnum;		/* Number of section headers */
+	Elf32_Half	e_shstrndx;		/* String table index */
+} Elf32_Ehdr;
+
+typedef struct {
+	unsigned char	e_ident[ELF_NIDENT];	/* Id bytes */
+	Elf64_Half	e_type;			/* file type */
+	Elf64_Half	e_machine;		/* machine type */
+	Elf64_Word	e_version;		/* version number */
+	Elf64_Addr	e_entry;		/* entry point */
+	Elf64_Off	e_phoff;		/* Program hdr offset */
+	Elf64_Off	e_shoff;		/* Section hdr offset */
+	Elf64_Word	e_flags;		/* Processor flags */
+	Elf64_Half	e_ehsize;		/* sizeof ehdr */
+	Elf64_Half	e_phentsize;		/* Program header entry size */
+	Elf64_Half	e_phnum;		/* Number of program headers */
+	Elf64_Half	e_shentsize;		/* Section header entry size */
+	Elf64_Half	e_shnum;		/* Number of section headers */
+	Elf64_Half	e_shstrndx;		/* String table index */
+} Elf64_Ehdr;
+
+/* e_ident offsets */
+#define EI_MAG0		0	/* '\177' */
+#define EI_MAG1		1	/* 'E'	  */
+#define EI_MAG2		2	/* 'L'	  */
+#define EI_MAG3		3	/* 'F'	  */
+#define EI_CLASS	4	/* File class */
+#define EI_DATA		5	/* Data encoding */
+#define EI_VERSION	6	/* File version */
+#define EI_OSABI	7	/* Operating system/ABI identification */
+#define EI_ABIVERSION	8	/* ABI version */
+#define EI_PAD		9	/* Start of padding bytes up to EI_NIDENT*/
+#define EI_NIDENT	16	/* First non-ident header byte */
+
+/* e_ident[EI_MAG0,EI_MAG3] */
+#define ELFMAG0		0x7f
+#define ELFMAG1		'E'
+#define ELFMAG2		'L'
+#define ELFMAG3		'F'
+#define ELFMAG		"\177ELF"
+#define SELFMAG		4
+
+/* e_ident[EI_CLASS] */
+#define ELFCLASSNONE	0	/* Invalid class */
+#define ELFCLASS32	1	/* 32-bit objects */
+#define ELFCLASS64	2	/* 64-bit objects */
+#define ELFCLASSNUM	3
+
+/* e_ident[EI_DATA] */
+#define ELFDATANONE	0	/* Invalid data encoding */
+#define ELFDATA2LSB	1	/* 2's complement values, LSB first */
+#define ELFDATA2MSB	2	/* 2's complement values, MSB first */
+
+/* e_ident[EI_VERSION] */
+#define EV_NONE		0	/* Invalid version */
+#define EV_CURRENT	1	/* Current version */
+#define EV_NUM		2
+
+/* e_ident[EI_OSABI] */
 #define ELFOSABI_SYSV		0	/* UNIX System V ABI */
 #define ELFOSABI_HPUX		1	/* HP-UX operating system */
 #define ELFOSABI_NETBSD		2	/* NetBSD */
 #define ELFOSABI_LINUX		3	/* GNU/Linux */
 #define ELFOSABI_HURD		4	/* GNU/Hurd */
-#define ELFOSABI_86OPEN		5	/* 86Open common IA32 ABI */
+#define ELFOSABI_86OPEN		5	/* 86Open */
 #define ELFOSABI_SOLARIS	6	/* Solaris */
 #define ELFOSABI_MONTEREY	7	/* Monterey */
 #define ELFOSABI_IRIX		8	/* IRIX */
@@ -51,85 +180,1054 @@
 #define ELFOSABI_TRU64		10	/* TRU64 UNIX */
 #define ELFOSABI_MODESTO	11	/* Novell Modesto */
 #define ELFOSABI_OPENBSD	12	/* OpenBSD */
+#define ELFOSABI_OPENVMS	13	/* OpenVMS */
+#define ELFOSABI_NSK		14	/* HP Non-Stop Kernel */
+#define ELFOSABI_AROS		15	/* Amiga Research OS */
+/* Unofficial OSABIs follow */
 #define ELFOSABI_ARM		97	/* ARM */
 #define ELFOSABI_STANDALONE	255	/* Standalone (embedded) application */
 
-/* e_ident */
-#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
-                      (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
-                      (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
-                      (ehdr).e_ident[EI_MAG3] == ELFMAG3)
+#define ELFOSABI_NONE		ELFOSABI_SYSV
+#define ELFOSABI_AIX		ELFOSABI_MONTEREY
+
+/* e_type */
+#define ET_NONE		0	/* No file type */
+#define ET_REL		1	/* Relocatable file */
+#define ET_EXEC		2	/* Executable file */
+#define ET_DYN		3	/* Shared object file */
+#define ET_CORE		4	/* Core file */
+#define ET_NUM		5
+
+#define ET_LOOS		0xfe00	/* Operating system specific range */
+#define ET_HIOS		0xfeff
+#define ET_LOPROC	0xff00	/* Processor-specific range */
+#define ET_HIPROC	0xffff
 
 /* e_machine */
-#define EM_NONE		0		/* No Machine */
-#define EM_M32		1		/* AT&T WE 32100 */
-#define EM_SPARC	2		/* SPARC */
-#define EM_386		3		/* Intel 80386 */
-#define EM_68K		4		/* Motorola 68000 */
-#define EM_88K		5		/* Motorola 88000 */
-#define EM_486		6		/* Intel 80486 - unused? */
-#define EM_860		7		/* Intel 80860 */
-#define EM_MIPS		8		/* MIPS R3000 Big-Endian only */
-/* 
- * Don't know if EM_MIPS_RS4_BE,
- * EM_SPARC64, EM_PARISC,
- * or EM_PPC are ABI compliant
+#define EM_NONE		0	/* No machine */
+#define EM_M32		1	/* AT&T WE 32100 */
+#define EM_SPARC	2	/* SPARC */
+#define EM_386		3	/* Intel 80386 */
+#define EM_68K		4	/* Motorola 68000 */
+#define EM_88K		5	/* Motorola 88000 */
+#define EM_486		6	/* Intel 80486 */
+#define EM_860		7	/* Intel 80860 */
+#define EM_MIPS		8	/* MIPS I Architecture */
+#define EM_S370		9	/* Amdahl UTS on System/370 */
+#define EM_MIPS_RS3_LE	10	/* MIPS RS3000 Little-endian */
+			/* 11-14 - Reserved */
+#define EM_RS6000	11	/* IBM RS/6000 XXX reserved */
+#define EM_PARISC	15	/* Hewlett-Packard PA-RISC */
+#define EM_NCUBE	16	/* NCube XXX reserved */
+#define EM_VPP500	17	/* Fujitsu VPP500 */
+#define EM_SPARC32PLUS	18	/* Enhanced instruction set SPARC */
+#define EM_960		19	/* Intel 80960 */
+#define EM_PPC		20	/* PowerPC */
+#define EM_PPC64	21	/* 64-bit PowerPC */
+			/* 22-35 - Reserved */
+#define EM_S390		22	/* System/390 XXX reserved */
+#define EM_V800		36	/* NEC V800 */
+#define EM_FR20		37	/* Fujitsu FR20 */
+#define EM_RH32		38	/* TRW RH-32 */
+#define EM_RCE		39	/* Motorola RCE */
+#define EM_ARM		40	/* Advanced RISC Machines ARM */
+#define EM_ALPHA	41	/* DIGITAL Alpha */
+#define EM_SH		42	/* Hitachi Super-H */
+#define EM_SPARCV9	43	/* SPARC Version 9 */
+#define EM_TRICORE	44	/* Siemens Tricore */
+#define EM_ARC		45	/* Argonaut RISC Core */
+#define EM_H8_300	46	/* Hitachi H8/300 */
+#define EM_H8_300H	47	/* Hitachi H8/300H */
+#define EM_H8S		48	/* Hitachi H8S */
+#define EM_H8_500	49	/* Hitachi H8/500 */
+#define EM_IA_64	50	/* Intel Merced Processor */
+#define EM_MIPS_X	51	/* Stanford MIPS-X */
+#define EM_COLDFIRE	52	/* Motorola Coldfire */
+#define EM_68HC12	53	/* Motorola MC68HC12 */
+#define EM_MMA		54	/* Fujitsu MMA Multimedia Accelerator */
+#define EM_PCP		55	/* Siemens PCP */
+#define EM_NCPU		56	/* Sony nCPU embedded RISC processor */
+#define EM_NDR1		57	/* Denso NDR1 microprocessor */
+#define EM_STARCORE	58	/* Motorola Star*Core processor */
+#define EM_ME16		59	/* Toyota ME16 processor */
+#define EM_ST100	60	/* STMicroelectronics ST100 processor */
+#define EM_TINYJ	61	/* Advanced Logic Corp. TinyJ embedded family processor */
+#define EM_X86_64	62	/* AMD x86-64 architecture */
+#define EM_PDSP		63	/* Sony DSP Processor */
+#define EM_PDP10	64	/* Digital Equipment Corp. PDP-10 */
+#define EM_PDP11	65	/* Digital Equipment Corp. PDP-11 */
+#define EM_FX66		66	/* Siemens FX66 microcontroller */
+#define EM_ST9PLUS	67	/* STMicroelectronics ST9+ 8/16 bit microcontroller */
+#define EM_ST7		68	/* STMicroelectronics ST7 8-bit microcontroller */
+#define EM_68HC16	69	/* Motorola MC68HC16 Microcontroller */
+#define EM_68HC11	70	/* Motorola MC68HC11 Microcontroller */
+#define EM_68HC08	71	/* Motorola MC68HC08 Microcontroller */
+#define EM_68HC05	72	/* Motorola MC68HC05 Microcontroller */
+#define EM_SVX		73	/* Silicon Graphics SVx */
+#define EM_ST19		74	/* STMicroelectronics ST19 8-bit CPU */
+#define EM_VAX		75	/* Digital VAX */
+#define EM_CRIS		76	/* Axis Communications 32-bit embedded processor */
+#define EM_JAVELIN	77	/* Infineon Technologies 32-bit embedded CPU */
+#define EM_FIREPATH	78	/* Element 14 64-bit DSP processor */
+#define EM_ZSP		79	/* LSI Logic's 16-bit DSP processor */
+#define EM_MMIX		80	/* Donald Knuth's educational 64-bit processor */
+#define EM_HUANY	81	/* Harvard's machine-independent format */
+#define EM_PRISM	82	/* SiTera Prism */
+#define EM_AVR		83	/* Atmel AVR 8-bit microcontroller */
+#define EM_FR30		84	/* Fujitsu FR30 */
+#define EM_D10V		85	/* Mitsubishi D10V */
+#define EM_D30V		86	/* Mitsubishi D30V */
+#define EM_V850		87	/* NEC v850 */
+#define EM_M32R		88	/* Mitsubishi M32R */
+#define EM_MN10300	89	/* Matsushita MN10300 */
+#define EM_MN10200	90	/* Matsushita MN10200 */
+#define EM_PJ		91	/* picoJava */
+#define EM_OPENRISC	92	/* OpenRISC 32-bit embedded processor */
+#define EM_ARC_A5	93	/* ARC Cores Tangent-A5 */
+#define EM_XTENSA	94	/* Tensilica Xtensa Architecture */
+#define EM_VIDEOCORE	95	/* Alphamosaic VideoCore processor */
+#define EM_TMM_GPP	96	/* Thompson Multimedia General Purpose Processor */
+#define EM_NS32K	97	/* National Semiconductor 32000 series */
+#define EM_TPC		98	/* Tenor Network TPC processor */
+#define EM_SNP1K	99	/* Trebia SNP 1000 processor */
+#define EM_ST200	100	/* STMicroelectronics ST200 microcontroller */
+#define EM_IP2K		101	/* Ubicom IP2xxx microcontroller family */
+#define EM_MAX		102	/* MAX processor */
+#define EM_CR		103	/* National Semiconductor CompactRISC micorprocessor */
+#define EM_F2MC16	104	/* Fujitsu F2MC16 */
+#define EM_MSP430	105	/* Texas Instruments MSP430 */
+#define EM_BLACKFIN	106	/* Analog Devices Blackfin DSP */
+#define EM_SE_C33	107	/* Seiko Epson S1C33 family */
+#define EM_SEP		108	/* Sharp embedded microprocessor */
+#define EM_ARCA		109	/* Arca RISC microprocessor */
+#define EM_UNICORE	110	/* UNICORE from PKU-Unity Ltd. and MPRC Peking University */
+
+/* Unofficial machine types follow */
+#define EM_AVR32	6317	/* used by NetBSD/avr32 */
+#define EM_ALPHA_EXP	36902	/* used by NetBSD/alpha; obsolete */
+#define EM_NUM		36903
+
+/*
+ * Program Header
  */
-#define EM_MIPS_RS4_BE	10		/* MIPS R4000 Big-Endian */
-#define EM_SPARC64	11		/* SPARC v9 64-bit unoffical */
-#define EM_PARISC	15		/* HPPA */
-#define EM_SPARC32PLUS	18		/* Enhanced instruction set SPARC */
-#define EM_PPC		20		/* PowerPC */
-#define EM_ARM		40		/* Advanced RISC Machines ARM */
-#define EM_ALPHA	41		/* DEC ALPHA */
-#define EM_SPARCV9	43		/* SPARC version 9 */
-#define EM_ALPHA_EXP	0x9026		/* DEC ALPHA */
-#define EM_AMD64	62		/* AMD64 architecture */
-#define EM_VAX		75		/* DEC VAX */
-#define EM_NUM		15		/* number of machine types */
+typedef struct {
+	Elf32_Word	p_type;		/* entry type */
+	Elf32_Off	p_offset;	/* offset */
+	Elf32_Addr	p_vaddr;	/* virtual address */
+	Elf32_Addr	p_paddr;	/* physical address */
+	Elf32_Word	p_filesz;	/* file size */
+	Elf32_Word	p_memsz;	/* memory size */
+	Elf32_Word	p_flags;	/* flags */
+	Elf32_Word	p_align;	/* memory & file alignment */
+} Elf32_Phdr;
 
+typedef struct {
+	Elf64_Word	p_type;		/* entry type */
+	Elf64_Word	p_flags;	/* flags */
+	Elf64_Off	p_offset;	/* offset */
+	Elf64_Addr	p_vaddr;	/* virtual address */
+	Elf64_Addr	p_paddr;	/* physical address */
+	Elf64_Xword	p_filesz;	/* file size */
+	Elf64_Xword	p_memsz;	/* memory size */
+	Elf64_Xword	p_align;	/* memory & file alignment */
+} Elf64_Phdr;
 
-/* Section names */
-#define ELF_BSS         ".bss"		/* uninitialized data */
-#define ELF_DATA        ".data"		/* initialized data */
-#define ELF_DEBUG       ".debug"	/* debug */
-#define ELF_DYNAMIC     ".dynamic"	/* dynamic linking information */
-#define ELF_DYNSTR      ".dynstr"	/* dynamic string table */
-#define ELF_DYNSYM      ".dynsym"	/* dynamic symbol table */
-#define ELF_FINI        ".fini"		/* termination code */
-#define ELF_GOT         ".got"		/* global offset table */
-#define ELF_HASH        ".hash"		/* symbol hash table */
-#define ELF_INIT        ".init"		/* initialization code */
-#define ELF_REL_DATA    ".rel.data"	/* relocation data */
-#define ELF_REL_FINI    ".rel.fini"	/* relocation termination code */
-#define ELF_REL_INIT    ".rel.init"	/* relocation initialization code */
-#define ELF_REL_DYN     ".rel.dyn"	/* relocaltion dynamic link info */
-#define ELF_REL_RODATA  ".rel.rodata"	/* relocation read-only data */
-#define ELF_REL_TEXT    ".rel.text"	/* relocation code */
-#define ELF_RODATA      ".rodata"	/* read-only data */
-#define ELF_SHSTRTAB    ".shstrtab"	/* section header string table */
-#define ELF_STRTAB      ".strtab"	/* string table */
-#define ELF_SYMTAB      ".symtab"	/* symbol table */
-#define ELF_TEXT        ".text"		/* code */
+/* p_type */
+#define PT_NULL		0		/* Program header table entry unused */
+#define PT_LOAD		1		/* Loadable program segment */
+#define PT_DYNAMIC	2		/* Dynamic linking information */
+#define PT_INTERP	3		/* Program interpreter */
+#define PT_NOTE		4		/* Auxiliary information */
+#define PT_SHLIB	5		/* Reserved, unspecified semantics */
+#define PT_PHDR		6		/* Entry for header table itself */
+#define PT_TLS		7		/* TLS initialisation image */
+#define PT_NUM		8
 
-/* Symbol Binding - ELF32_ST_BIND - st_info */
-#define STB_LOCAL	0		/* Local symbol */
-#define STB_GLOBAL	1		/* Global symbol */
-#define STB_WEAK	2		/* like global - lower precedence */
-#define STB_NUM		3		/* number of symbol bindings */
-#define STB_LOPROC	13		/* reserved range for processor */
-#define STB_HIPROC	15		/*  specific symbol bindings */
+#define PT_LOOS		0x60000000	/* OS-specific range */
 
-/* Symbol type - ELF32_ST_TYPE - st_info */
-#define STT_NOTYPE	0		/* not specified */
-#define STT_OBJECT	1		/* data object */
-#define STT_FUNC	2		/* function */
-#define STT_SECTION	3		/* section */
-#define STT_FILE	4		/* file */
-#define STT_NUM		5		/* number of symbol types */
-#define STT_LOPROC	13		/* reserved range for processor */
-#define STT_HIPROC	15		/*  specific symbol types */
+/* GNU-specific */
+#define PT_GNU_EH_FRAME 0x6474e550	/* EH frame segment */
+#define PT_GNU_STACK	0x6474e551	/* Indicate executable stack */
+#define PT_GNU_RELRO	0x6474e552	/* Make read-only after relocation */
 
-#define PT_GNU_RELRO    0x6474e552      /* Read-only post relocation */
+#define PT_HIOS		0x6fffffff
+#define PT_LOPROC	0x70000000	/* Processor-specific range */
+#define PT_HIPROC	0x7fffffff
 
-#endif /* _SYS_EXEC_ELF_H_ */
+#define PT_MIPS_REGINFO 0x70000000
+
+/* p_flags */
+#define PF_R		0x4		/* Segment is readable */
+#define PF_W		0x2		/* Segment is writable */
+#define PF_X		0x1		/* Segment is executable */
+
+#define PF_MASKOS	0x0ff00000	/* Operating system specific values */
+#define PF_MASKPROC	0xf0000000	/* Processor-specific values */
+
+/* Extended program header index. */
+#define PN_XNUM		0xffff
+
+/*
+ * Section Headers
+ */
+typedef struct {
+	Elf32_Word	sh_name;	/* section name (.shstrtab index) */
+	Elf32_Word	sh_type;	/* section type */
+	Elf32_Word	sh_flags;	/* section flags */
+	Elf32_Addr	sh_addr;	/* virtual address */
+	Elf32_Off	sh_offset;	/* file offset */
+	Elf32_Word	sh_size;	/* section size */
+	Elf32_Word	sh_link;	/* link to another */
+	Elf32_Word	sh_info;	/* misc info */
+	Elf32_Word	sh_addralign;	/* memory alignment */
+	Elf32_Word	sh_entsize;	/* table entry size */
+} Elf32_Shdr;
+
+typedef struct {
+	Elf64_Word	sh_name;	/* section name (.shstrtab index) */
+	Elf64_Word	sh_type;	/* section type */
+	Elf64_Xword	sh_flags;	/* section flags */
+	Elf64_Addr	sh_addr;	/* virtual address */
+	Elf64_Off	sh_offset;	/* file offset */
+	Elf64_Xword	sh_size;	/* section size */
+	Elf64_Word	sh_link;	/* link to another */
+	Elf64_Word	sh_info;	/* misc info */
+	Elf64_Xword	sh_addralign;	/* memory alignment */
+	Elf64_Xword	sh_entsize;	/* table entry size */
+} Elf64_Shdr;
+
+/* sh_type */
+#define SHT_NULL	      0		/* Section header table entry unused */
+#define SHT_PROGBITS	      1		/* Program information */
+#define SHT_SYMTAB	      2		/* Symbol table */
+#define SHT_STRTAB	      3		/* String table */
+#define SHT_RELA	      4		/* Relocation information w/ addend */
+#define SHT_HASH	      5		/* Symbol hash table */
+#define SHT_DYNAMIC	      6		/* Dynamic linking information */
+#define SHT_NOTE	      7		/* Auxiliary information */
+#define SHT_NOBITS	      8		/* No space allocated in file image */
+#define SHT_REL		      9		/* Relocation information w/o addend */
+#define SHT_SHLIB	     10		/* Reserved, unspecified semantics */
+#define SHT_DYNSYM	     11		/* Symbol table for dynamic linker */
+#define SHT_INIT_ARRAY	     14		/* Initialization function pointers */
+#define SHT_FINI_ARRAY	     15		/* Termination function pointers */
+#define SHT_PREINIT_ARRAY    16		/* Pre-initialization function ptrs */
+#define SHT_GROUP	     17		/* Section group */
+#define SHT_SYMTAB_SHNDX     18		/* Section indexes (see SHN_XINDEX) */
+#define SHT_NUM		     19
+
+#define SHT_LOOS	     0x60000000 /* Operating system specific range */
+#define SHT_GNU_HASH	     0x6ffffff6 /* GNU style symbol hash table */
+#define SHT_SUNW_move	     0x6ffffffa
+#define SHT_SUNW_syminfo     0x6ffffffc
+#define SHT_SUNW_verdef	     0x6ffffffd /* Versions defined by file */
+#define SHT_GNU_verdef	     SHT_SUNW_verdef
+#define SHT_SUNW_verneed     0x6ffffffe /* Versions needed by file */
+#define SHT_GNU_verneed	     SHT_SUNW_verneed
+#define SHT_SUNW_versym	     0x6fffffff /* Symbol versions */
+#define SHT_GNU_versym	     SHT_SUNW_versym
+#define SHT_HIOS	     0x6fffffff
+#define SHT_LOPROC	     0x70000000 /* Processor-specific range */
+#define SHT_AMD64_UNWIND     0x70000001 /* unwind information */
+#define SHT_HIPROC	     0x7fffffff
+#define SHT_LOUSER	     0x80000000 /* Application-specific range */
+#define SHT_HIUSER	     0xffffffff
+
+/* sh_flags */
+#define SHF_WRITE	     0x00000001 /* Contains writable data */
+#define SHF_ALLOC	     0x00000002 /* Occupies memory */
+#define SHF_EXECINSTR	     0x00000004 /* Contains executable insns */
+#define SHF_MERGE	     0x00000010 /* Might be merged */
+#define SHF_STRINGS	     0x00000020 /* Contains nul terminated strings */
+#define SHF_INFO_LINK	     0x00000040 /* "sh_info" contains SHT index */
+#define SHF_LINK_ORDER	     0x00000080 /* Preserve order after combining */
+#define SHF_OS_NONCONFORMING 0x00000100 /* OS specific handling required */
+#define SHF_GROUP	     0x00000200 /* Is member of a group */
+#define SHF_TLS		     0x00000400 /* Holds thread-local data */
+#define SHF_MASKOS	     0x0ff00000 /* Operating system specific values */
+#define SHF_MASKPROC	     0xf0000000 /* Processor-specific values */
+#define SHF_ORDERED	     0x40000000 /* Ordering requirement (Solaris) */
+#define SHF_EXCLUDE	     0x80000000 /* Excluded unless unles ref/alloc
+					   (Solaris).*/
+/*
+ * Symbol Table
+ */
+typedef struct {
+	Elf32_Word	st_name;	/* Symbol name (.strtab index) */
+	Elf32_Word	st_value;	/* value of symbol */
+	Elf32_Word	st_size;	/* size of symbol */
+	Elf_Byte	st_info;	/* type / binding attrs */
+	Elf_Byte	st_other;	/* unused */
+	Elf32_Half	st_shndx;	/* section index of symbol */
+} Elf32_Sym;
+
+typedef struct {
+	Elf64_Word	st_name;	/* Symbol name (.strtab index) */
+	Elf_Byte	st_info;	/* type / binding attrs */
+	Elf_Byte	st_other;	/* unused */
+	Elf64_Half	st_shndx;	/* section index of symbol */
+	Elf64_Addr	st_value;	/* value of symbol */
+	Elf64_Xword	st_size;	/* size of symbol */
+} Elf64_Sym;
+
+/* Symbol Table index of the undefined symbol */
+#define ELF_SYM_UNDEFINED	0
+
+#define STN_UNDEF		0	/* undefined index */
+
+/* st_info: Symbol Bindings */
+#define STB_LOCAL		0	/* local symbol */
+#define STB_GLOBAL		1	/* global symbol */
+#define STB_WEAK		2	/* weakly defined global symbol */
+#define STB_NUM			3
+
+#define STB_LOOS		10	/* Operating system specific range */
+#define STB_HIOS		12
+#define STB_LOPROC		13	/* Processor-specific range */
+#define STB_HIPROC		15
+
+/* st_info: Symbol Types */
+#define STT_NOTYPE		0	/* Type not specified */
+#define STT_OBJECT		1	/* Associated with a data object */
+#define STT_FUNC		2	/* Associated with a function */
+#define STT_SECTION		3	/* Associated with a section */
+#define STT_FILE		4	/* Associated with a file name */
+#define STT_COMMON		5	/* Uninitialised common block */
+#define STT_TLS			6	/* Thread local data object */
+#define STT_NUM			7
+
+#define STT_LOOS		10	/* Operating system specific range */
+#define STT_HIOS		12
+#define STT_LOPROC		13	/* Processor-specific range */
+#define STT_HIPROC		15
+
+/* st_other: Visibility Types */
+#define STV_DEFAULT		0	/* use binding type */
+#define STV_INTERNAL		1	/* not referenced from outside */
+#define STV_HIDDEN		2	/* not visible, may be used via ptr */
+#define STV_PROTECTED		3	/* visible, not preemptible */
+#define STV_EXPORTED		4
+#define STV_SINGLETON		5
+#define STV_ELIMINATE		6
+
+/* st_info/st_other utility macros */
+#define ELF_ST_BIND(info)		((uint32_t)(info) >> 4)
+#define ELF_ST_TYPE(info)		((uint32_t)(info) & 0xf)
+#define ELF_ST_INFO(bind,type)		((Elf_Byte)(((bind) << 4) | \
+					 ((type) & 0xf)))
+#define ELF_ST_VISIBILITY(other)	((uint32_t)(other) & 3)
+
+/*
+ * Special section indexes
+ */
+#define SHN_UNDEF	0		/* Undefined section */
+
+#define SHN_LORESERVE	0xff00		/* Reserved range */
+#define SHN_ABS		0xfff1		/*  Absolute symbols */
+#define SHN_COMMON	0xfff2		/*  Common symbols */
+#define SHN_XINDEX	0xffff		/* Escape -- index stored elsewhere */
+#define SHN_HIRESERVE	0xffff
+
+#define SHN_LOPROC	0xff00		/* Processor-specific range */
+#define SHN_HIPROC	0xff1f
+#define SHN_LOOS	0xff20		/* Operating system specific range */
+#define SHN_HIOS	0xff3f
+
+#define SHN_MIPS_ACOMMON 0xff00
+#define SHN_MIPS_TEXT	0xff01
+#define SHN_MIPS_DATA	0xff02
+#define SHN_MIPS_SCOMMON 0xff03
+
+/*
+ * Relocation Entries
+ */
+typedef struct {
+	Elf32_Word	r_offset;	/* where to do it */
+	Elf32_Word	r_info;		/* index & type of relocation */
+} Elf32_Rel;
+
+typedef struct {
+	Elf32_Word	r_offset;	/* where to do it */
+	Elf32_Word	r_info;		/* index & type of relocation */
+	Elf32_Sword	r_addend;	/* adjustment value */
+} Elf32_Rela;
+
+/* r_info utility macros */
+#define ELF32_R_SYM(info)	((info) >> 8)
+#define ELF32_R_TYPE(info)	((info) & 0xff)
+#define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type))
+
+typedef struct {
+	Elf64_Addr	r_offset;	/* where to do it */
+	Elf64_Xword	r_info;		/* index & type of relocation */
+} Elf64_Rel;
+
+typedef struct {
+	Elf64_Addr	r_offset;	/* where to do it */
+	Elf64_Xword	r_info;		/* index & type of relocation */
+	Elf64_Sxword	r_addend;	/* adjustment value */
+} Elf64_Rela;
+
+/* r_info utility macros */
+#define ELF64_R_SYM(info)	((info) >> 32)
+#define ELF64_R_TYPE(info)	((info) & 0xffffffff)
+#define ELF64_R_INFO(sym,type)	(((sym) << 32) + (type))
+
+/*
+ * Move entries
+ */
+typedef struct {
+	Elf32_Lword	m_value;	/* symbol value */
+	Elf32_Word	m_info;		/* size + index */
+	Elf32_Word	m_poffset;	/* symbol offset */
+	Elf32_Half	m_repeat;	/* repeat count */
+	Elf32_Half	m_stride;	/* stride info */
+} Elf32_Move;
+
+#define ELF32_M_SYM(info)	((info) >> 8)
+#define ELF32_M_SIZE(info)	((info) & 0xff)
+#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size))
+
+typedef struct {
+	Elf64_Lword	m_value;	/* symbol value */
+	Elf64_Xword	m_info;		/* size + index */
+	Elf64_Xword	m_poffset;	/* symbol offset */
+	Elf64_Word	m_repeat;	/* repeat count */
+	Elf64_Word	m_stride;	/* stride info */
+} Elf64_Move;
+
+#define ELF64_M_SYM(info)	((info) >> 8)
+#define ELF64_M_SIZE(info)	((info) & 0xff)
+#define ELF64_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size))
+
+/*
+ * Hardware/software capabilities entry
+ */
+typedef struct {
+	Elf32_Word		c_tag;	/* entry tag value */
+	union {
+		Elf32_Addr	c_ptr;
+		Elf32_Word	c_val;
+	} c_un;
+} Elf32_Cap;
+
+typedef struct {
+	Elf64_Xword		c_tag;	/* entry tag value */
+	union {
+		Elf64_Addr	c_ptr;
+		Elf64_Xword	c_val;
+	} c_un;
+} Elf64_Cap;
+
+/*
+ * Dynamic Section structure array
+ */
+typedef struct {
+	Elf32_Word		d_tag;	/* entry tag value */
+	union {
+		Elf32_Addr	d_ptr;
+		Elf32_Word	d_val;
+	} d_un;
+} Elf32_Dyn;
+
+typedef struct {
+	Elf64_Xword		d_tag;	/* entry tag value */
+	union {
+		Elf64_Addr	d_ptr;
+		Elf64_Xword	d_val;
+	} d_un;
+} Elf64_Dyn;
+
+/* d_tag */
+#define DT_NULL		0	/* Marks end of dynamic array */
+#define DT_NEEDED	1	/* Name of needed library (DT_STRTAB offset) */
+#define DT_PLTRELSZ	2	/* Size, in bytes, of relocations in PLT */
+#define DT_PLTGOT	3	/* Address of PLT and/or GOT */
+#define DT_HASH		4	/* Address of symbol hash table */
+#define DT_STRTAB	5	/* Address of string table */
+#define DT_SYMTAB	6	/* Address of symbol table */
+#define DT_RELA		7	/* Address of Rela relocation table */
+#define DT_RELASZ	8	/* Size, in bytes, of DT_RELA table */
+#define DT_RELAENT	9	/* Size, in bytes, of one DT_RELA entry */
+#define DT_STRSZ	10	/* Size, in bytes, of DT_STRTAB table */
+#define DT_SYMENT	11	/* Size, in bytes, of one DT_SYMTAB entry */
+#define DT_INIT		12	/* Address of initialization function */
+#define DT_FINI		13	/* Address of termination function */
+#define DT_SONAME	14	/* Shared object name (DT_STRTAB offset) */
+#define DT_RPATH	15	/* Library search path (DT_STRTAB offset) */
+#define DT_SYMBOLIC	16	/* Start symbol search within local object */
+#define DT_REL		17	/* Address of Rel relocation table */
+#define DT_RELSZ	18	/* Size, in bytes, of DT_REL table */
+#define DT_RELENT	19	/* Size, in bytes, of one DT_REL entry */
+#define DT_PLTREL	20	/* Type of PLT relocation entries */
+#define DT_DEBUG	21	/* Used for debugging; unspecified */
+#define DT_TEXTREL	22	/* Relocations might modify non-writable seg */
+#define DT_JMPREL	23	/* Address of relocations associated with PLT */
+#define DT_BIND_NOW	24	/* Process all relocations at load-time */
+#define DT_INIT_ARRAY	25	/* Address of initialization function array */
+#define DT_FINI_ARRAY	26	/* Size, in bytes, of DT_INIT_ARRAY array */
+#define DT_INIT_ARRAYSZ 27	/* Address of termination function array */
+#define DT_FINI_ARRAYSZ 28	/* Size, in bytes, of DT_FINI_ARRAY array*/
+#define DT_NUM		29
+
+#define DT_LOOS		0x60000000	/* Operating system specific range */
+#define DT_VERSYM	0x6ffffff0	/* Symbol versions */
+#define DT_FLAGS_1	0x6ffffffb	/* ELF dynamic flags */
+#define DT_VERDEF	0x6ffffffc	/* Versions defined by file */
+#define DT_VERDEFNUM	0x6ffffffd	/* Number of versions defined by file */
+#define DT_VERNEED	0x6ffffffe	/* Versions needed by file */
+#define DT_VERNEEDNUM	0x6fffffff	/* Number of versions needed by file */
+#define DT_HIOS		0x6fffffff
+#define DT_LOPROC	0x70000000	/* Processor-specific range */
+#define DT_HIPROC	0x7fffffff
+
+/* Flag values for DT_FLAGS_1 (incomplete) */
+#define DF_1_BIND_NOW	0x00000001	/* Same as DF_BIND_NOW */
+#define DF_1_NODELETE	0x00000008	/* Set the RTLD_NODELETE for object */
+#define DF_1_INITFIRST	0x00000020	/* Object's init/fini take priority */
+#define DF_1_NOOPEN	0x00000040	/* Do not allow loading on dlopen() */
+
+/*
+ * Auxiliary Vectors
+ */
+typedef struct {
+	Elf32_Word	a_type;				/* 32-bit id */
+	Elf32_Word	a_v;				/* 32-bit id */
+} Aux32Info;
+
+typedef struct {
+	Elf64_Word	a_type;		/* 32-bit id */
+	Elf64_Xword	a_v;		/* 64-bit id */
+} Aux64Info;
+
+/* BEGIN android-changed: these constants should come from <linux/auxvec.h>. */
+#if 0
+/* a_type */
+#define AT_NULL		0	/* Marks end of array */
+#define AT_IGNORE	1	/* No meaning, a_un is undefined */
+#define AT_EXECFD	2	/* Open file descriptor of object file */
+#define AT_PHDR		3	/* &phdr[0] */
+#define AT_PHENT	4	/* sizeof(phdr[0]) */
+#define AT_PHNUM	5	/* # phdr entries */
+#define AT_PAGESZ	6	/* PAGESIZE */
+#define AT_BASE		7	/* Interpreter base addr */
+#define AT_FLAGS	8	/* Processor flags */
+#define AT_ENTRY	9	/* Entry address of executable */
+#define AT_DCACHEBSIZE	10	/* Data cache block size */
+#define AT_ICACHEBSIZE	11	/* Instruction cache block size */
+#define AT_UCACHEBSIZE	12	/* Unified cache block size */
+#define AT_STACKBASE	13	/* Base address of the main thread */
+
+	/* Vendor specific */
+#define AT_MIPS_NOTELF	10	/* XXX a_val != 0 -> MIPS XCOFF executable */
+
+#define AT_EUID		2000	/* euid (solaris compatible numbers) */
+#define AT_RUID		2001	/* ruid (solaris compatible numbers) */
+#define AT_EGID		2002	/* egid (solaris compatible numbers) */
+#define AT_RGID		2003	/* rgid (solaris compatible numbers) */
+
+	/* Solaris kernel specific */
+#define AT_SUN_LDELF	2004	/* dynamic linker's ELF header */
+#define AT_SUN_LDSHDR	2005	/* dynamic linker's section header */
+#define AT_SUN_LDNAME	2006	/* dynamic linker's name */
+#define AT_SUN_LPGSIZE	2007	/* large pagesize */
+
+	/* Other information */
+#define AT_SUN_PLATFORM 2008	/* sysinfo(SI_PLATFORM) */
+#define AT_SUN_HWCAP	2009	/* process hardware capabilities */
+#define AT_SUN_IFLUSH	2010	/* do we need to flush the instruction cache? */
+#define AT_SUN_CPU	2011	/* CPU name */
+	/* ibcs2 emulation band aid */
+#define AT_SUN_EMUL_ENTRY 2012	/* coff entry point */
+#define AT_SUN_EMUL_EXECFD 2013 /* coff file descriptor */
+	/* Executable's fully resolved name */
+#define AT_SUN_EXECNAME 2014
+#endif
+/* END android-changed */
+
+/*
+ * Note Headers
+ */
+typedef struct {
+	Elf32_Word n_namesz;
+	Elf32_Word n_descsz;
+	Elf32_Word n_type;
+} Elf32_Nhdr;
+
+typedef struct {
+	Elf64_Word n_namesz;
+	Elf64_Word n_descsz;
+	Elf64_Word n_type;
+} Elf64_Nhdr;
+
+#define ELF_NOTE_GNU_NAMESZ		4
+#define ELF_NOTE_GNU_NAME		"GNU\0"
+
+/*
+ * GNU-specific note type: ABI tag
+ * name: GNU\0
+ * namesz: 4
+ * desc:
+ *	word[0]: OS tag
+ *	word[1]: major version
+ *	word[2]: minor version
+ *	word[3]: teeny version
+ * descsz: 16
+ */
+/* GNU-specific note name and description sizes */
+#define ELF_NOTE_TYPE_ABI_TAG		1
+#define ELF_NOTE_ABI_NAME		ELF_NOTE_GNU_NAME
+#define ELF_NOTE_ABI_NAMESZ		ELF_NOTE_GNU_NAMESZ
+#define ELF_NOTE_ABI_DESCSZ		16
+/* GNU-specific OS/version value stuff */
+#define ELF_NOTE_ABI_OS_LINUX		0
+#define ELF_NOTE_ABI_OS_HURD		1
+#define ELF_NOTE_ABI_OS_SOLARIS		2
+#define ELF_NOTE_ABI_OS_KFREEBSD	3
+#define ELF_NOTE_ABI_OS_KNETBSD		4
+
+/*
+ * GNU-specific note type: Hardware capabilities
+ * name: GNU\0
+ * namesz: 4
+ * desc:
+ *	word[0]: Number of entries
+ *	word[1]: Bitmask of enabled entries
+ *	Followed by a byte id, and a NUL terminated string per entry
+ * descsz: variable
+ */
+#define ELF_NOTE_TYPE_GNU_HWCAP		2
+
+/*
+ * GNU-specific note type: Build ID generated by ld
+ * name: GNU\0
+ * desc:
+ *	word[0..4] SHA1 [default] 
+ * or
+ *	word[0..3] md5 or uuid
+ * descsz: 16 or 20
+ */
+#define ELF_NOTE_TYPE_GNU_BUILD_ID	3
+
+/* SuSE-specific note type: ABI
+ * name: SuSE\0
+ * namesz: 5
+ * desc:
+ *	half[0] = MMmm
+ *
+ *	M = product major version
+ *	m = product minor version
+ * descsz: 2
+ */
+#define ELF_NOTE_TYPE_SUSE_TAG	1
+/* SuSE-specific note name and description sizes */
+#define ELF_NOTE_SUSE_NAMESZ	5
+#define ELF_NOTE_SUSE_DESCSZ	2
+/* SuSE-specific note name */
+#define ELF_NOTE_SUSE_NAME		"SuSE\0"
+
+/* SuSE-specific note type: version
+ * name: SuSE\0\0\0\0
+ * namesz: 8
+ * desc: 
+ *	word[0] = VVTTMMmm
+ *
+ *	V = version of following data
+ *	T = product type: [box, sles, nld, whatever]
+ *	M = product major version
+ *	m = product minor version
+ * descsz: 8
+ */
+#define ELF_NOTE_TYPE_SUSE_VERSION_TAG	0x45537553	/* SuSE in LE */
+/* SuSE-specific note name and description sizes */
+#define ELF_NOTE_SUSE_VERSION_NAMESZ	8
+#define ELF_NOTE_SUSE_VERSION_DESCSZ	8
+/* SuSE-specific note name */
+#define ELF_NOTE_SUSE_VERSION_NAME		"SuSE\0\0\0\0"
+
+/* NetBSD-specific note type: Emulation name.
+ * name: NetBSD\0\0
+ * namesz: 8
+ * desc: 
+ *	word[0]: MMmmrrpp00
+ *
+ *	M = major version
+ *	m = minor version
+ *	r = release ["",A-Z,Z[A-Z] but numeric]
+ *	p = patchlevel
+ * descsz: 4
+ */
+#define ELF_NOTE_TYPE_NETBSD_TAG	1
+/* NetBSD-specific note name and description sizes */
+#define ELF_NOTE_NETBSD_NAMESZ		7
+#define ELF_NOTE_NETBSD_DESCSZ		4
+/* NetBSD-specific note name */
+#define ELF_NOTE_NETBSD_NAME		"NetBSD\0\0"
+
+/* NetBSD-specific note type: Checksum. 
+ * There should be 1 NOTE per PT_LOAD section.
+ * name: ???
+ * namesz: ???
+ * desc:
+ *	a tuple of <phnum>(16),<chk-type>(16),<chk-value>.
+ * descsz: ???
+ */
+#define ELF_NOTE_TYPE_CHECKSUM_TAG	2
+#define ELF_NOTE_CHECKSUM_CRC32		1
+#define ELF_NOTE_CHECKSUM_MD5		2
+#define ELF_NOTE_CHECKSUM_SHA1		3
+#define ELF_NOTE_CHECKSUM_SHA256	4
+
+/*
+ * NetBSD-specific note type: PaX.
+ * There should be 1 NOTE per executable.
+ * name: PaX\0
+ * namesz: 4
+ * desc:
+ *	word[0]: capability bitmask
+ * descsz: 4
+ */
+#define ELF_NOTE_TYPE_PAX_TAG		3
+#define ELF_NOTE_PAX_MPROTECT		0x01	/* Force enable Mprotect */
+#define ELF_NOTE_PAX_NOMPROTECT		0x02	/* Force disable Mprotect */
+#define ELF_NOTE_PAX_GUARD		0x04	/* Force enable Segvguard */
+#define ELF_NOTE_PAX_NOGUARD		0x08	/* Force disable Servguard */
+#define ELF_NOTE_PAX_ASLR		0x10	/* Force enable ASLR */
+#define ELF_NOTE_PAX_NOASLR		0x20	/* Force disable ASLR */
+#define ELF_NOTE_PAX_NAMESZ		4
+#define ELF_NOTE_PAX_NAME		"PaX\0"
+#define ELF_NOTE_PAX_DESCSZ		4
+
+/*
+ * NetBSD-specific core file information.
+ *
+ * NetBSD ELF core files use notes to provide information about
+ * the process's state.	 The note name is "NetBSD-CORE" for
+ * information that is global to the process, and "NetBSD-CORE@nn",
+ * where "nn" is the lwpid of the LWP that the information belongs
+ * to (such as register state).
+ *
+ * We use the following note identifiers:
+ *
+ *	ELF_NOTE_NETBSD_CORE_PROCINFO
+ *		Note is a "netbsd_elfcore_procinfo" structure.
+ *
+ * We also use ptrace(2) request numbers (the ones that exist in
+ * machine-dependent space) to identify register info notes.  The
+ * info in such notes is in the same format that ptrace(2) would
+ * export that information.
+ *
+ * Please try to keep the members of this structure nicely aligned,
+ * and if you add elements, add them to the end and bump the version.
+ */
+
+#define ELF_NOTE_NETBSD_CORE_NAME	"NetBSD-CORE"
+
+#define ELF_NOTE_NETBSD_CORE_PROCINFO	1
+
+#define NETBSD_ELFCORE_PROCINFO_VERSION 1
+
+struct netbsd_elfcore_procinfo {
+	/* Version 1 fields start here. */
+	uint32_t	cpi_version;		/* our version */
+	uint32_t	cpi_cpisize;		/* sizeof(this struct) */
+	uint32_t	cpi_signo;		/* killing signal */
+	uint32_t	cpi_sigcode;		/* signal code */
+	uint32_t	cpi_sigpend[4];		/* pending signals */
+	uint32_t	cpi_sigmask[4];		/* blocked signals */
+	uint32_t	cpi_sigignore[4];	/* ignored signals */
+	uint32_t	cpi_sigcatch[4];	/* caught signals */
+	int32_t		cpi_pid;		/* process ID */
+	int32_t		cpi_ppid;		/* parent process ID */
+	int32_t		cpi_pgrp;		/* process group ID */
+	int32_t		cpi_sid;		/* session ID */
+	uint32_t	cpi_ruid;		/* real user ID */
+	uint32_t	cpi_euid;		/* effective user ID */
+	uint32_t	cpi_svuid;		/* saved user ID */
+	uint32_t	cpi_rgid;		/* real group ID */
+	uint32_t	cpi_egid;		/* effective group ID */
+	uint32_t	cpi_svgid;		/* saved group ID */
+	uint32_t	cpi_nlwps;		/* number of LWPs */
+	int8_t		cpi_name[32];		/* copy of p->p_comm */
+	/* Add version 2 fields below here. */
+	int32_t		cpi_siglwp;	/* LWP target of killing signal */
+};
+
+#if !defined(ELFSIZE) && defined(ARCH_ELFSIZE)
+#define ELFSIZE ARCH_ELFSIZE
+#endif
+
+#if defined(ELFSIZE)
+#define CONCAT(x,y)	__CONCAT(x,y)
+#define ELFNAME(x)	CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x)))
+#define ELFNAME2(x,y)	CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y))))
+#define ELFNAMEEND(x)	CONCAT(x,CONCAT(_elf,ELFSIZE))
+#define ELFDEFNNAME(x)	CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x)))
+#endif
+
+#if defined(ELFSIZE) && (ELFSIZE == 32)
+#define Elf_Ehdr	Elf32_Ehdr
+#define Elf_Phdr	Elf32_Phdr
+#define Elf_Shdr	Elf32_Shdr
+#define Elf_Sym		Elf32_Sym
+#define Elf_Rel		Elf32_Rel
+#define Elf_Rela	Elf32_Rela
+#define Elf_Dyn		Elf32_Dyn
+#define Elf_Word	Elf32_Word
+#define Elf_Sword	Elf32_Sword
+#define Elf_Half	Elf32_Half
+#define Elf_Addr	Elf32_Addr
+#define Elf_Off		Elf32_Off
+#define Elf_SOff	Elf32_SOff
+#define Elf_Nhdr	Elf32_Nhdr
+#define Elf_Verdef	Elf32_Verdef
+#define Elf_Verdaux	Elf32_Verdaux
+#define Elf_Verneed	Elf32_Verneed
+#define Elf_Vernaux	Elf32_Vernaux
+#define Elf_Versym	Elf32_Versym
+
+#define ELF_R_SYM	ELF32_R_SYM
+#define ELF_R_TYPE	ELF32_R_TYPE
+#define ELFCLASS	ELFCLASS32
+
+#define AuxInfo		Aux32Info
+#elif defined(ELFSIZE) && (ELFSIZE == 64)
+#define Elf_Ehdr	Elf64_Ehdr
+#define Elf_Phdr	Elf64_Phdr
+#define Elf_Shdr	Elf64_Shdr
+#define Elf_Sym		Elf64_Sym
+#define Elf_Rel		Elf64_Rel
+#define Elf_Rela	Elf64_Rela
+#define Elf_Dyn		Elf64_Dyn
+#define Elf_Word	Elf64_Word
+#define Elf_Sword	Elf64_Sword
+#define Elf_Half	Elf64_Half
+#define Elf_Addr	Elf64_Addr
+#define Elf_Off		Elf64_Off
+#define Elf_SOff	Elf64_SOff
+#define Elf_Nhdr	Elf64_Nhdr
+#define Elf_Verdef	Elf64_Verdef
+#define Elf_Verdaux	Elf64_Verdaux
+#define Elf_Verneed	Elf64_Verneed
+#define Elf_Vernaux	Elf64_Vernaux
+#define Elf_Versym	Elf64_Versym
+
+#define ELF_R_SYM	ELF64_R_SYM
+#define ELF_R_TYPE	ELF64_R_TYPE
+#define ELFCLASS	ELFCLASS64
+
+#define AuxInfo		Aux64Info
+#endif
+
+#ifndef Elf_Symindx
+#define Elf_Symindx	uint32_t
+#endif
+
+#define ELF32_ST_BIND(info)		ELF_ST_BIND(info)
+#define ELF32_ST_TYPE(info)		ELF_ST_TYPE(info)
+#define ELF32_ST_INFO(bind,type)	ELF_ST_INFO(bind,type)
+#define ELF32_ST_VISIBILITY(other)	ELF_ST_VISIBILITY(other)
+
+#define ELF64_ST_BIND(info)		ELF_ST_BIND(info)
+#define ELF64_ST_TYPE(info)		ELF_ST_TYPE(info)
+#define ELF64_ST_INFO(bind,type)	ELF_ST_INFO(bind,type)
+#define ELF64_ST_VISIBILITY(other)	ELF_ST_VISIBILITY(other)
+
+typedef struct {
+	Elf32_Half	si_boundto;	/* direct bindings - symbol bound to */
+	Elf32_Half	si_flags;	/* per symbol flags */
+} Elf32_Syminfo;
+
+typedef struct {
+	Elf64_Word	si_boundto;	/* direct bindings - symbol bound to */
+	Elf64_Word	si_flags;	/* per symbol flags */
+} Elf64_Syminfo;
+
+#define SYMINFO_FLG_DIRECT	0x0001	/* symbol ref has direct association
+					   to object containing definition */
+#define SYMINFO_FLG_PASSTHRU	0x0002	/* ignored - see SYMINFO_FLG_FILTER */
+#define SYMINFO_FLG_COPY	0x0004	/* symbol is a copy-reloc */
+#define SYMINFO_FLG_LAZYLOAD	0x0008	/* object containing defn should be
+					   lazily-loaded */
+#define SYMINFO_FLG_DIRECTBIND	0x0010	/* ref should be bound directly to
+					   object containing definition */
+#define SYMINFO_FLG_NOEXTDIRECT 0x0020	/* don't let an external reference
+					   directly bind to this symbol */
+#define SYMINFO_FLG_FILTER	0x0002	/* symbol ref is associated to a */
+#define SYMINFO_FLG_AUXILIARY	0x0040	/*	standard or auxiliary filter */
+
+#define SYMINFO_BT_SELF		0xffff	/* symbol bound to self */
+#define SYMINFO_BT_PARENT	0xfffe	/* symbol bound to parent */
+#define SYMINFO_BT_NONE		0xfffd	/* no special symbol binding */
+#define SYMINFO_BT_EXTERN	0xfffc	/* symbol defined as external */
+#define SYMINFO_BT_LOWRESERVE	0xff00	/* beginning of reserved entries */
+
+#define SYMINFO_NONE		0	/* Syminfo version */
+#define SYMINFO_CURRENT		1
+#define SYMINFO_NUM		2
+
+/*
+ * These constants are used for Elf32_Verdef struct's version number.  
+ */
+#define VER_DEF_NONE		0
+#define VER_DEF_CURRENT		1
+
+/*
+ * These constants are used for Elf32_Verdef struct's vd_ndx.
+ */
+#define VER_DEF_IDX(x)		VER_NDX(x)
+
+/*
+ * These constants are used for Elf32_Verdef struct's vd_flags.	 
+ */
+#define VER_FLG_BASE		0x1
+#define VER_FLG_WEAK		0x2
+
+/*
+ * These are used in an Elf32_Versym field.
+ */
+#define VER_NDX_LOCAL		0
+#define VER_NDX_GLOBAL		1
+#define VER_NDX_GIVEN		2
+
+/*
+ * These constants are used for Elf32_Verneed struct's version number.	
+ */
+#define VER_NEED_NONE		0
+#define VER_NEED_CURRENT	1
+
+/*
+ * These constants are used for Elf32_Vernaux struct's vna_other.
+ */
+#define VER_NEED_HIDDEN		VER_NDX_HIDDEN
+#define VER_NEED_IDX(x)		VER_NDX(x)
+
+/* index */
+#define VER_NDX_HIDDEN		0x8000
+#define VER_NDX(x)		((x) & ~VER_NDX_HIDDEN)
+
+/*
+ * GNU Extension hidding symbol
+ */
+#define VERSYM_HIDDEN		0x8000
+#define VERSYM_VERSION		0x7fff
+
+#define ELF_VER_CHR		'@'
+
+/*
+ * These are current size independent.
+ */
+
+typedef struct {
+	Elf32_Half	vd_version;	/* version number of structure */
+	Elf32_Half	vd_flags;	/* flags (VER_FLG_*) */
+	Elf32_Half	vd_ndx;		/* version index */
+	Elf32_Half	vd_cnt;		/* number of verdaux entries */
+	Elf32_Word	vd_hash;	/* hash of name */
+	Elf32_Word	vd_aux;		/* offset to verdaux entries */
+	Elf32_Word	vd_next;	/* offset to next verdef */
+} Elf32_Verdef;
+typedef Elf32_Verdef	Elf64_Verdef;
+
+typedef struct {
+	Elf32_Word	vda_name;	/* string table offset of name */
+	Elf32_Word	vda_next;	/* offset to verdaux */
+} Elf32_Verdaux;
+typedef Elf32_Verdaux	Elf64_Verdaux;
+
+typedef struct {
+	Elf32_Half	vn_version;	/* version number of structure */
+	Elf32_Half	vn_cnt;		/* number of vernaux entries */
+	Elf32_Word	vn_file;	/* string table offset of library name*/
+	Elf32_Word	vn_aux;		/* offset to vernaux entries */
+	Elf32_Word	vn_next;	/* offset to next verneed */
+} Elf32_Verneed;
+typedef Elf32_Verneed	Elf64_Verneed;
+
+typedef struct {
+	Elf32_Word	vna_hash;	/* Hash of dependency name */
+	Elf32_Half	vna_flags;	/* flags (VER_FLG_*) */
+	Elf32_Half	vna_other;	/* unused */
+	Elf32_Word	vna_name;	/* string table offset to version name*/
+	Elf32_Word	vna_next;	/* offset to next vernaux */
+} Elf32_Vernaux;
+typedef Elf32_Vernaux	Elf64_Vernaux;
+
+typedef struct {
+	Elf32_Half	vs_vers;
+} Elf32_Versym;
+typedef Elf32_Versym	Elf64_Versym;
+
+#ifdef _KERNEL
+
+#define ELF_AUX_ENTRIES 15	/* Max size of aux array passed to loader */
+#define ELF32_NO_ADDR	(~(Elf32_Addr)0) /* Indicates addr. not yet filled in */
+#define ELF32_LINK_ADDR ((Elf32_Addr)-2) /* advises to use link address */
+#define ELF64_NO_ADDR	(~(Elf64_Addr)0) /* Indicates addr. not yet filled in */
+#define ELF64_LINK_ADDR ((Elf64_Addr)-2) /* advises to use link address */
+
+#if defined(ELFSIZE) && (ELFSIZE == 64)
+#define ELF_NO_ADDR	ELF64_NO_ADDR
+#define ELF_LINK_ADDR	ELF64_LINK_ADDR
+#elif defined(ELFSIZE) && (ELFSIZE == 32)
+#define ELF_NO_ADDR	ELF32_NO_ADDR
+#define ELF_LINK_ADDR	ELF32_LINK_ADDR
+#endif
+
+#ifndef ELF32_EHDR_FLAGS_OK
+#define ELF32_EHDR_FLAGS_OK(eh) 1
+#endif
+
+#ifndef ELF64_EHDR_FLAGS_OK
+#define ELF64_EHDR_FLAGS_OK(eh) 1
+#endif
+
+#if defined(ELFSIZE) && (ELFSIZE == 64)
+#define ELF_EHDR_FLAGS_OK(eh)	ELF64_EHDR_FLAGS_OK(eh)
+#else
+#define ELF_EHDR_FLAGS_OK(eh)	ELF32_EHDR_FLAGS_OK(eh)
+#endif
+
+#if defined(ELFSIZE)
+struct elf_args {
+	Elf_Addr	arg_entry;	/* program entry point */
+	Elf_Addr	arg_interp;	/* Interpreter load address */
+	Elf_Addr	arg_phaddr;	/* program header address */
+	Elf_Addr	arg_phentsize;	/* Size of program header */
+	Elf_Addr	arg_phnum;	/* Number of program headers */
+};
+#endif
+
+#ifdef _KERNEL_OPT
+#include "opt_execfmt.h"
+#endif
+
+struct ps_strings;
+
+#ifdef EXEC_ELF32
+int	exec_elf32_makecmds(struct lwp *, struct exec_package *);
+int	elf32_copyargs(struct lwp *, struct exec_package *,
+    struct ps_strings *, char **, void *);
+
+int	coredump_elf32(struct lwp *, void *);
+int	coredump_writenote_elf32(struct proc *, void *, Elf32_Nhdr *,
+    const char *, void *);
+
+int	elf32_check_header(Elf32_Ehdr *, int);
+#endif
+
+#ifdef EXEC_ELF64
+int	exec_elf64_makecmds(struct lwp *, struct exec_package *);
+int	elf64_copyargs(struct lwp *, struct exec_package *,
+    struct ps_strings *, char **, void *);
+
+int	coredump_elf64(struct lwp *, void *);
+int	coredump_writenote_elf64(struct proc *, void *, Elf64_Nhdr *,
+    const char *, void *);
+
+int	elf64_check_header(Elf64_Ehdr *, int);
+#endif
+
+#endif /* _KERNEL */
+
+#endif /* !_SYS_EXEC_ELF_H_ */
diff --git a/libc/include/sys/limits.h b/libc/include/sys/limits.h
index 41d02ff..2d0d11e 100644
--- a/libc/include/sys/limits.h
+++ b/libc/include/sys/limits.h
@@ -169,11 +169,18 @@
 
 #undef   _POSIX_PROCESS_SHARED           /* we don't support process-shared synchronization */
 #undef   _POSIX_THREAD_SAFE_FUNCTIONS    /* most functions are, but not everything yet */
-#define  _POSIX_CHOWN_RESTRICTED    1    /* yes, chown requires appropriate priviledges */
+#define  _POSIX_CHOWN_RESTRICTED    1    /* yes, chown requires appropriate privileges */
+#define  _POSIX_MONOTONIC_CLOCK     0    /* the monotonic clock may be available; ask sysconf */
 #define  _POSIX_NO_TRUNC            1    /* very long pathnames generate an error */
 #define  _POSIX_SAVED_IDS           1    /* saved user ids is a Linux feature */
 #define  _POSIX_JOB_CONTROL         1    /* job control is a Linux feature */
 
+#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 /* the minimum mandated by POSIX */
+#define PTHREAD_DESTRUCTOR_ITERATIONS 4
+#define _POSIX_THREAD_KEYS_MAX 128            /* the minimum mandated by POSIX */
+/* TODO: our PTHREAD_KEYS_MAX is currently too low to be posix compliant! */
+#define _POSIX_THREAD_THREADS_MAX 64          /* the minimum mandated by POSIX */
+#define PTHREAD_THREADS_MAX                   /* bionic has no specific limit */
 
 
 #endif
diff --git a/libc/include/sys/linux-syscalls.h b/libc/include/sys/linux-syscalls.h
index 89ab167..738d9e8 100644
--- a/libc/include/sys/linux-syscalls.h
+++ b/libc/include/sys/linux-syscalls.h
@@ -83,8 +83,6 @@
 #define __NR_msync                        (__NR_SYSCALL_BASE + 144)
 #define __NR_readv                        (__NR_SYSCALL_BASE + 145)
 #define __NR_writev                       (__NR_SYSCALL_BASE + 146)
-#define __NR_getsid                       (__NR_SYSCALL_BASE + 147)
-#define __NR_perf_event_open              (__NR_SYSCALL_BASE + 364)
 
 #ifdef __arm__
 #define __NR_exit_group                   (__NR_SYSCALL_BASE + 248)
@@ -99,6 +97,7 @@
 #define __NR_gettid                       (__NR_SYSCALL_BASE + 224)
 #define __NR_readahead                    (__NR_SYSCALL_BASE + 225)
 #define __NR_getgroups32                  (__NR_SYSCALL_BASE + 205)
+#define __NR_getsid                       (__NR_SYSCALL_BASE + 147)
 #define __NR_setgid32                     (__NR_SYSCALL_BASE + 214)
 #define __NR_setreuid32                   (__NR_SYSCALL_BASE + 203)
 #define __NR_setresuid32                  (__NR_SYSCALL_BASE + 208)
@@ -174,6 +173,7 @@
 #define __NR_rt_sigaction                 (__NR_SYSCALL_BASE + 174)
 #define __NR_rt_sigprocmask               (__NR_SYSCALL_BASE + 175)
 #define __NR_rt_sigtimedwait              (__NR_SYSCALL_BASE + 177)
+#define __NR_signalfd4                    (__NR_SYSCALL_BASE + 355)
 #define __NR_socket                       (__NR_SYSCALL_BASE + 281)
 #define __NR_socketpair                   (__NR_SYSCALL_BASE + 288)
 #define __NR_bind                         (__NR_SYSCALL_BASE + 282)
@@ -202,6 +202,7 @@
 #define __NR_getcpu                       (__NR_SYSCALL_BASE + 345)
 #define __NR_ioprio_set                   (__NR_SYSCALL_BASE + 314)
 #define __NR_ioprio_get                   (__NR_SYSCALL_BASE + 315)
+#define __NR_perf_event_open              (__NR_SYSCALL_BASE + 364)
 #define __NR_futex                        (__NR_SYSCALL_BASE + 240)
 #define __NR_epoll_create                 (__NR_SYSCALL_BASE + 250)
 #define __NR_epoll_ctl                    (__NR_SYSCALL_BASE + 251)
@@ -221,6 +222,7 @@
 #define __NR_pipe                         (__NR_SYSCALL_BASE + 42)
 #define __NR_sigsuspend                   (__NR_SYSCALL_BASE + 72)
 #define __NR_socketcall                   (__NR_SYSCALL_BASE + 102)
+#define __NR_getsid                       (__NR_SYSCALL_BASE + 147)
 #define __NR_fdatasync                    (__NR_SYSCALL_BASE + 148)
 #define __NR_mlock                        (__NR_SYSCALL_BASE + 150)
 #define __NR_munlock                      (__NR_SYSCALL_BASE + 151)
@@ -328,8 +330,10 @@
 #define __NR_unshare                      (__NR_SYSCALL_BASE + 310)
 #define __NR_getcpu                       (__NR_SYSCALL_BASE + 318)
 #define __NR_utimensat                    (__NR_SYSCALL_BASE + 320)
+#define __NR_signalfd4                    (__NR_SYSCALL_BASE + 327)
 #define __NR_eventfd2                     (__NR_SYSCALL_BASE + 328)
 #define __NR_pipe2                        (__NR_SYSCALL_BASE + 331)
+#define __NR_perf_event_open              (__NR_SYSCALL_BASE + 336)
 #endif
 
 #ifdef __mips__
@@ -351,6 +355,7 @@
 #define __NR_setgroups                    (__NR_SYSCALL_BASE + 81)
 #define __NR_fchown                       (__NR_SYSCALL_BASE + 95)
 #define __NR_cacheflush                   (__NR_SYSCALL_BASE + 147)
+#define __NR_getsid                       (__NR_SYSCALL_BASE + 151)
 #define __NR_fdatasync                    (__NR_SYSCALL_BASE + 152)
 #define __NR_mlock                        (__NR_SYSCALL_BASE + 154)
 #define __NR_munlock                      (__NR_SYSCALL_BASE + 155)
@@ -460,8 +465,10 @@
 #define __NR_ioprio_set                   (__NR_SYSCALL_BASE + 314)
 #define __NR_ioprio_get                   (__NR_SYSCALL_BASE + 315)
 #define __NR_utimensat                    (__NR_SYSCALL_BASE + 316)
+#define __NR_signalfd4                    (__NR_SYSCALL_BASE + 324)
 #define __NR_eventfd2                     (__NR_SYSCALL_BASE + 325)
 #define __NR_pipe2                        (__NR_SYSCALL_BASE + 328)
+#define __NR_perf_event_open              (__NR_SYSCALL_BASE + 333)
 #endif
 
 #endif
diff --git a/libc/include/sys/param.h b/libc/include/sys/param.h
index 3a815cb..0bfdc5d 100644
--- a/libc/include/sys/param.h
+++ b/libc/include/sys/param.h
@@ -37,4 +37,6 @@
 #define ALIGNBYTES  3
 #define ALIGN(p)    (((unsigned int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
 
+#define powerof2(x) ((((x)-1)&(x))==0)
+
 #endif /* _SYS_PARAM_H_ */
diff --git a/libc/include/sys/prctl.h b/libc/include/sys/prctl.h
index 359d684..00e5837 100644
--- a/libc/include/sys/prctl.h
+++ b/libc/include/sys/prctl.h
@@ -29,6 +29,7 @@
 #define _SYS_PRCTL_H
 
 #include <linux/prctl.h>
+#include <sys/cdefs.h>
 
 __BEGIN_DECLS
 
diff --git a/libc/include/sys/sha1.h b/libc/include/sys/sha1.h
new file mode 100644
index 0000000..f7ada46
--- /dev/null
+++ b/libc/include/sys/sha1.h
@@ -0,0 +1,31 @@
+/*	$NetBSD: sha1.h,v 1.13 2005/12/26 18:41:36 perry Exp $	*/
+
+/*
+ * SHA-1 in C
+ * By Steve Reid <steve@edmweb.com>
+ * 100% Public Domain
+ */
+
+#ifndef _SYS_SHA1_H_
+#define	_SYS_SHA1_H_
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#define SHA1_DIGEST_LENGTH		20
+#define SHA1_DIGEST_STRING_LENGTH	41
+
+typedef struct {
+	uint32_t state[5];
+	uint32_t count[2];
+	u_char buffer[64];
+} SHA1_CTX;
+
+__BEGIN_DECLS
+void	SHA1Transform(uint32_t[5], const u_char[64]);
+void	SHA1Init(SHA1_CTX *);
+void	SHA1Update(SHA1_CTX *, const u_char *, u_int);
+void	SHA1Final(u_char[SHA1_DIGEST_LENGTH], SHA1_CTX *);
+__END_DECLS
+
+#endif /* _SYS_SHA1_H_ */
diff --git a/libc/include/sys/signal.h b/libc/include/sys/signal.h
new file mode 100644
index 0000000..2e602da
--- /dev/null
+++ b/libc/include/sys/signal.h
@@ -0,0 +1 @@
+#include <signal.h>
diff --git a/libc/include/sys/signalfd.h b/libc/include/sys/signalfd.h
new file mode 100644
index 0000000..c03a0e9
--- /dev/null
+++ b/libc/include/sys/signalfd.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_SIGNALFD_H_
+#define _SYS_SIGNALFD_H_
+
+#include <signal.h>
+#include <linux/signalfd.h>
+
+__BEGIN_DECLS
+
+extern int signalfd(int fd, const sigset_t* mask, int flags) __attribute__((__nonnull__(2)));
+
+__END_DECLS
+
+#endif /* _SYS_SIGNALFD_H */
diff --git a/libc/include/sys/socket.h b/libc/include/sys/socket.h
index e5e0c2e..17ba0a1 100644
--- a/libc/include/sys/socket.h
+++ b/libc/include/sys/socket.h
@@ -160,14 +160,22 @@
 #define AF_ASH 18
 #define AF_ECONET 19
 #define AF_ATMSVC 20
+#define AF_RDS 21
 #define AF_SNA 22
 #define AF_IRDA 23
 #define AF_PPPOX 24
 #define AF_WANPIPE 25
 #define AF_LLC 26
+#define AF_CAN 29
 #define AF_TIPC 30
 #define AF_BLUETOOTH 31
-#define AF_CAIF 38
+#define AF_IUCV 32
+#define AF_RXRPC 33
+#define AF_ISDN 34
+#define AF_PHONET 35
+#define AF_IEEE802154 36
+#define AF_CAIF 37
+#define AF_ALG 38
 #define AF_MAX 39
 
 #define PF_UNSPEC AF_UNSPEC
@@ -193,14 +201,22 @@
 #define PF_ASH AF_ASH
 #define PF_ECONET AF_ECONET
 #define PF_ATMSVC AF_ATMSVC
+#define PF_RDS AF_RDS
 #define PF_SNA AF_SNA
 #define PF_IRDA AF_IRDA
 #define PF_PPPOX AF_PPPOX
 #define PF_WANPIPE AF_WANPIPE
 #define PF_LLC AF_LLC
+#define PF_CAN AF_CAN
 #define PF_TIPC AF_TIPC
 #define PF_BLUETOOTH AF_BLUETOOTH
+#define PF_IUCV AF_IUCV
+#define PF_RXRPC AF_RXRPC
+#define PF_ISDN AF_ISDN
+#define PF_PHONET AF_PHONET
+#define PF_IEEE802154 AF_IEEE802154
 #define PF_CAIF AF_CAIF
+#define PF_ALG AF_ALG
 #define PF_MAX AF_MAX
 
 #define SOMAXCONN 128
diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h
index bee648e..05b221f 100644
--- a/libc/include/sys/stat.h
+++ b/libc/include/sys/stat.h
@@ -112,6 +112,13 @@
 #define  st_mtimensec  st_mtime_nsec
 #define  st_ctimensec  st_ctime_nsec
 
+#ifdef __USE_BSD
+/* Permission macros provided by glibc for compatibility with BSDs. */
+#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */
+#define ALLPERMS    (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) /* 07777 */
+#define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* 0666 */
+#endif
+
 extern int    chmod(const char *, mode_t);
 extern int    fchmod(int, mode_t);
 extern int    mkdir(const char *, mode_t);
@@ -122,6 +129,27 @@
 extern int    mknod(const char *, mode_t, dev_t);
 extern mode_t umask(mode_t);
 
+#if defined(__BIONIC_FORTIFY_INLINE)
+
+extern mode_t __umask_chk(mode_t);
+extern mode_t __umask_real(mode_t)
+    __asm__(__USER_LABEL_PREFIX__ "umask");
+extern void __umask_error()
+    __attribute__((__error__("umask called with invalid mode")));
+
+__BIONIC_FORTIFY_INLINE
+mode_t umask(mode_t mode) {
+  if (__builtin_constant_p(mode)) {
+    if ((mode & 0777) != mode) {
+      __umask_error();
+    }
+    return __umask_real(mode);
+  }
+  return __umask_chk(mode);
+}
+#endif /* defined(__BIONIC_FORTIFY_INLINE) */
+
+
 #define  stat64    stat
 #define  fstat64   fstat
 #define  lstat64   lstat
diff --git a/libc/include/sys/sysconf.h b/libc/include/sys/sysconf.h
index 2fc1b08..0a46e7a 100644
--- a/libc/include/sys/sysconf.h
+++ b/libc/include/sys/sysconf.h
@@ -127,8 +127,9 @@
 #define _SC_NPROCESSORS_ONLN            0x0061
 #define _SC_PHYS_PAGES                  0x0062
 #define _SC_AVPHYS_PAGES                0x0063
+#define _SC_MONOTONIC_CLOCK             0x0064
 
-extern int sysconf (int  name);
+extern int sysconf(int name);
 
 __END_DECLS
 
diff --git a/libc/include/sys/types.h b/libc/include/sys/types.h
index 33fe30e..a0ce405 100644
--- a/libc/include/sys/types.h
+++ b/libc/include/sys/types.h
@@ -28,8 +28,6 @@
 #ifndef _SYS_TYPES_H_
 #define _SYS_TYPES_H_
 
-#define __need_size_t
-#define __need_ptrdiff_t
 #include <stddef.h>
 #include <stdint.h>
 #include <sys/cdefs.h>
@@ -45,7 +43,7 @@
  * these are defined as 16-bit for legacy reason, but
  * the kernel uses 32-bits instead.
  *
- * 32-bit valuea are required for Android, so use
+ * 32-bit values are required for Android, so use
  * __kernel_uid32_t and __kernel_gid32_t
  */
 
@@ -85,15 +83,14 @@
 typedef  .... pthread_t;
 #endif
 
-#ifndef _SIZE_T_DEFINED_
-#define _SIZE_T_DEFINED_
-typedef unsigned int  size_t;
-#endif
-
-/* size_t is defined by the GCC-specific <stddef.h> */
 #ifndef _SSIZE_T_DEFINED_
 #define _SSIZE_T_DEFINED_
-typedef long int  ssize_t;
+/* Traditionally, bionic's ssize_t was "long int". This caused GCC to emit warnings when you
+ * pass a ssize_t to a printf-style function. The correct type is __kernel_ssize_t, which is
+ * "int", which isn't an ABI change for C code (because they're the same size) but is an ABI
+ * change for C++ because "int" and "long int" mangle to "i" and "l" respectively. So until
+ * we can fix the ABI, this change should not be propagated to the NDK. http://b/8253769. */
+typedef __kernel_ssize_t ssize_t;
 #endif
 
 typedef __kernel_suseconds_t  suseconds_t;
diff --git a/libc/include/unistd.h b/libc/include/unistd.h
index a6a6dbf..98970ae 100644
--- a/libc/include/unistd.h
+++ b/libc/include/unistd.h
@@ -33,7 +33,6 @@
 #include <sys/types.h>
 #include <sys/select.h>
 #include <sys/sysconf.h>
-#include <linux/capability.h>
 #include <pathconf.h>
 
 __BEGIN_DECLS
@@ -69,8 +68,6 @@
 extern int execl(const char *, const char *, ...);
 extern int execlp(const char *, const char *, ...);
 extern int execle(const char *, const char *, ...);
-extern int capget(cap_user_header_t hdrp, cap_user_data_t datap);
-extern int capset(cap_user_header_t hdrp, const cap_user_data_t datap);
 
 /* IMPORTANT: See comment under <sys/prctl.h> about this declaration */
 extern int prctl(int  option, ...);
diff --git a/libc/include/wchar.h b/libc/include/wchar.h
index 1361ff5..a4e19f0 100644
--- a/libc/include/wchar.h
+++ b/libc/include/wchar.h
@@ -31,16 +31,11 @@
 #include <sys/cdefs.h>
 #include <stdio.h>
 
-/* wchar_t is required in stdlib.h according to POSIX */
-#define __need___wchar_t
-#include <stddef.h>
-
 #include <stdarg.h>
+#include <stddef.h>
 #include <time.h>
 #include <malloc.h>
 
-#include <stddef.h>
-
 /* IMPORTANT: Any code that relies on wide character support is essentially
  *            non-portable and/or broken. the only reason this header exist
  *            is because I'm really a nice guy. However, I'm not nice enough
@@ -50,7 +45,7 @@
 
 __BEGIN_DECLS
 
-typedef int                     wint_t;
+typedef __WINT_TYPE__           wint_t;
 typedef struct { int  dummy; }  mbstate_t;
 
 typedef enum {
@@ -154,6 +149,11 @@
 extern wint_t		 towctrans(wint_t, wctrans_t);
 extern wctrans_t	 wctrans (const char *);
 
+#if _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
+wchar_t* wcsdup(const wchar_t*);
+size_t wcsnlen(const wchar_t*, size_t);
+#endif
+
 __END_DECLS
 
 #endif /* _WCHAR_H_ */
diff --git a/libc/inet/inet_addr.c b/libc/inet/inet_addr.c
deleted file mode 100644
index 8e480a4..0000000
--- a/libc/inet/inet_addr.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*	$OpenBSD: inet_addr.c,v 1.9 2005/08/06 20:30:03 espie Exp $	*/
-
-/*
- * ++Copyright++ 1983, 1990, 1993
- * -
- * Copyright (c) 1983, 1990, 1993
- *    The Regents of the University of California.  All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * -
- * Portions Copyright (c) 1993 by Digital Equipment Corporation.
- * 
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies, and that
- * the name of Digital Equipment Corporation not be used in advertising or
- * publicity pertaining to distribution of the document or software without
- * specific, written prior permission.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
- * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- * -
- * --Copyright--
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <ctype.h>
-
-/*
- * Ascii internet address interpretation routine.
- * The value returned is in network order.
- */
-in_addr_t
-inet_addr(const char *cp)
-{
-	struct in_addr val;
-
-	if (inet_aton(cp, &val))
-		return (val.s_addr);
-	return (INADDR_NONE);
-}
diff --git a/libc/inet/inet_aton.c b/libc/inet/inet_aton.c
deleted file mode 100644
index c456d07..0000000
--- a/libc/inet/inet_aton.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/*	$OpenBSD: inet_addr.c,v 1.9 2005/08/06 20:30:03 espie Exp $	*/
-
-/*
- * ++Copyright++ 1983, 1990, 1993
- * -
- * Copyright (c) 1983, 1990, 1993
- *    The Regents of the University of California.  All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * -
- * Portions Copyright (c) 1993 by Digital Equipment Corporation.
- * 
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies, and that
- * the name of Digital Equipment Corporation not be used in advertising or
- * publicity pertaining to distribution of the document or software without
- * specific, written prior permission.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
- * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- * -
- * --Copyright--
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <ctype.h>
-
-/* 
- * Check whether "cp" is a valid ascii representation
- * of an Internet address and convert to a binary address.
- * Returns 1 if the address is valid, 0 if not.
- * This replaces inet_addr, the return value from which
- * cannot distinguish between failure and a local broadcast address.
- */
-int
-inet_aton(const char *cp, struct in_addr *addr)
-{
-	in_addr_t val;
-	int base, n;
-	char c;
-	u_int parts[4];
-	u_int *pp = parts;
-
-	c = *cp;
-	for (;;) {
-		/*
-		 * Collect number up to ``.''.
-		 * Values are specified as for C:
-		 * 0x=hex, 0=octal, isdigit=decimal.
-		 */
-		if (!isdigit(c))
-			return (0);
-		val = 0; base = 10;
-		if (c == '0') {
-			c = *++cp;
-			if (c == 'x' || c == 'X')
-				base = 16, c = *++cp;
-			else
-				base = 8;
-		}
-		for (;;) {
-			if (isascii(c) && isdigit(c)) {
-				val = (val * base) + (c - '0');
-				c = *++cp;
-			} else if (base == 16 && isascii(c) && isxdigit(c)) {
-				val = (val << 4) |
-					(c + 10 - (islower(c) ? 'a' : 'A'));
-				c = *++cp;
-			} else
-				break;
-		}
-		if (c == '.') {
-			/*
-			 * Internet format:
-			 *	a.b.c.d
-			 *	a.b.c	(with c treated as 16 bits)
-			 *	a.b	(with b treated as 24 bits)
-			 */
-			if (pp >= parts + 3)
-				return (0);
-			*pp++ = val;
-			c = *++cp;
-		} else
-			break;
-	}
-	/*
-	 * Check for trailing characters.
-	 */
-	if (c != '\0' && (!isascii(c) || !isspace(c)))
-		return (0);
-	/*
-	 * Concoct the address according to
-	 * the number of parts specified.
-	 */
-	n = pp - parts + 1;
-	switch (n) {
-
-	case 0:
-		return (0);		/* initial nondigit */
-
-	case 1:				/* a -- 32 bits */
-		break;
-
-	case 2:				/* a.b -- 8.24 bits */
-		if ((val > 0xffffff) || (parts[0] > 0xff))
-			return (0);
-		val |= parts[0] << 24;
-		break;
-
-	case 3:				/* a.b.c -- 8.8.16 bits */
-		if ((val > 0xffff) || (parts[0] > 0xff) || (parts[1] > 0xff))
-			return (0);
-		val |= (parts[0] << 24) | (parts[1] << 16);
-		break;
-
-	case 4:				/* a.b.c.d -- 8.8.8.8 bits */
-		if ((val > 0xff) || (parts[0] > 0xff) || (parts[1] > 0xff) || (parts[2] > 0xff))
-			return (0);
-		val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
-		break;
-	}
-	if (addr)
-		addr->s_addr = htonl(val);
-	return (1);
-}
diff --git a/libc/inet/inet_ntoa.c b/libc/inet/inet_ntoa.c
deleted file mode 100644
index ff5d93d..0000000
--- a/libc/inet/inet_ntoa.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*	$OpenBSD: inet_ntoa.c,v 1.6 2005/08/06 20:30:03 espie Exp $ */
-/*
- * Copyright (c) 1983, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Convert network-format internet address
- * to base 256 d.d.d.d representation.
- */
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <stdio.h>
-
-char *
-inet_ntoa(struct in_addr in)
-{
-	static char b[18];
-	char *p;
-
-	p = (char *)&in;
-#define	UC(b)	(((int)b)&0xff)
-	(void)snprintf(b, sizeof(b),
-	    "%u.%u.%u.%u", UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3]));
-	return (b);
-}
diff --git a/libc/inet/inet_ntop.c b/libc/inet/inet_ntop.c
deleted file mode 100644
index c3448f1..0000000
--- a/libc/inet/inet_ntop.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*	$OpenBSD: inet_ntop.c,v 1.7 2005/08/06 20:30:03 espie Exp $	*/
-
-/* Copyright (c) 1996 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include "arpa_nameser.h"
-#include <string.h>
-#include <errno.h>
-#include <stdio.h>
-
-/*
- * WARNING: Don't even consider trying to compile this on a system where
- * sizeof(int) < 4.  sizeof(int) > 4 is fine; all the world's not a VAX.
- */
-
-static const char *inet_ntop4(const u_char *src, char *dst, size_t size);
-static const char *inet_ntop6(const u_char *src, char *dst, size_t size);
-
-/* char *
- * inet_ntop(af, src, dst, size)
- *	convert a network format address to presentation format.
- * return:
- *	pointer to presentation format address (`dst'), or NULL (see errno).
- * author:
- *	Paul Vixie, 1996.
- */
-const char *
-inet_ntop(int af, const void *src, char *dst, size_t size)
-{
-	switch (af) {
-	case AF_INET:
-		return (inet_ntop4(src, dst, size));
-	case AF_INET6:
-		return (inet_ntop6(src, dst, size));
-	default:
-		errno = EAFNOSUPPORT;
-		return (NULL);
-	}
-	/* NOTREACHED */
-}
-
-/* const char *
- * inet_ntop4(src, dst, size)
- *	format an IPv4 address, more or less like inet_ntoa()
- * return:
- *	`dst' (as a const)
- * notes:
- *	(1) uses no statics
- *	(2) takes a u_char* not an in_addr as input
- * author:
- *	Paul Vixie, 1996.
- */
-static const char *
-inet_ntop4(const u_char *src, char *dst, size_t size)
-{
-	static const char fmt[] = "%u.%u.%u.%u";
-	char tmp[sizeof "255.255.255.255"];
-	int l;
-
-#if defined(ANDROID_CHANGES)
-	l = snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]);
-	if (l <= 0 || (size_t)l >= size || (size_t)l >= sizeof(tmp)) {
-#else
-	l = snprintf(tmp, size, fmt, src[0], src[1], src[2], src[3]);
-	if (l <= 0 || (size_t)l >= size) {
-#endif
-		errno = ENOSPC;
-		return (NULL);
-	}
-	strlcpy(dst, tmp, size);
-	return (dst);
-}
-
-/* const char *
- * inet_ntop6(src, dst, size)
- *	convert IPv6 binary address into presentation (printable) format
- * author:
- *	Paul Vixie, 1996.
- */
-static const char *
-inet_ntop6(const u_char *src, char *dst, size_t size)
-{
-	/*
-	 * Note that int32_t and int16_t need only be "at least" large enough
-	 * to contain a value of the specified size.  On some systems, like
-	 * Crays, there is no such thing as an integer variable with 16 bits.
-	 * Keep this in mind if you think this function should have been coded
-	 * to use pointer overlays.  All the world's not a VAX.
-	 */
-	char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
-	char *tp, *ep;
-	struct { int base, len; } best, cur;
-	u_int words[IN6ADDRSZ / INT16SZ];
-	int i;
-	int advance;
-
-	/*
-	 * Preprocess:
-	 *	Copy the input (bytewise) array into a wordwise array.
-	 *	Find the longest run of 0x00's in src[] for :: shorthanding.
-	 */
-	memset(words, '\0', sizeof words);
-	for (i = 0; i < IN6ADDRSZ; i++)
-		words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
-	best.base = -1;
-	best.len  = 0;
-	cur.base = -1;
-	cur.len  = 0;
-	for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
-		if (words[i] == 0) {
-			if (cur.base == -1)
-				cur.base = i, cur.len = 1;
-			else
-				cur.len++;
-		} else {
-			if (cur.base != -1) {
-				if (best.base == -1 || cur.len > best.len)
-					best = cur;
-				cur.base = -1;
-			}
-		}
-	}
-	if (cur.base != -1) {
-		if (best.base == -1 || cur.len > best.len)
-			best = cur;
-	}
-	if (best.base != -1 && best.len < 2)
-		best.base = -1;
-
-	/*
-	 * Format the result.
-	 */
-	tp = tmp;
-	ep = tmp + sizeof(tmp);
-	for (i = 0; i < (IN6ADDRSZ / INT16SZ) && tp < ep; i++) {
-		/* Are we inside the best run of 0x00's? */
-		if (best.base != -1 && i >= best.base &&
-		    i < (best.base + best.len)) {
-			if (i == best.base) {
-				if (tp + 1 >= ep)
-					return (NULL);
-				*tp++ = ':';
-			}
-			continue;
-		}
-		/* Are we following an initial run of 0x00s or any real hex? */
-		if (i != 0) {
-			if (tp + 1 >= ep)
-				return (NULL);
-			*tp++ = ':';
-		}
-		/* Is this address an encapsulated IPv4? */
-		if (i == 6 && best.base == 0 &&
-		    (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
-			if (!inet_ntop4(src+12, tp, (size_t)(ep - tp)))
-				return (NULL);
-			tp += strlen(tp);
-			break;
-		}
-		advance = snprintf(tp, ep - tp, "%x", words[i]);
-		if (advance <= 0 || advance >= ep - tp)
-			return (NULL);
-		tp += advance;
-	}
-	/* Was it a trailing run of 0x00's? */
-	if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ)) {
-		if (tp + 1 >= ep)
-			return (NULL);
-		*tp++ = ':';
-	}
-	if (tp + 1 >= ep)
-		return (NULL);
-	*tp++ = '\0';
-
-	/*
-	 * Check for overflow, copy, and we're done.
-	 */
-	if ((size_t)(tp - tmp) > size) {
-		errno = ENOSPC;
-		return (NULL);
-	}
-	strlcpy(dst, tmp, size);
-	return (dst);
-}
diff --git a/libc/inet/inet_pton.c b/libc/inet/inet_pton.c
deleted file mode 100644
index 6e74e6a..0000000
--- a/libc/inet/inet_pton.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/*	$NetBSD: inet_pton.c,v 1.6.10.1 2011/01/10 00:42:17 riz Exp $	*/
-
-/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1996,1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static const char rcsid[] = "Id: inet_pton.c,v 1.5 2005/07/28 06:51:47 marka Exp";
-#else
-__RCSID("$NetBSD: inet_pton.c,v 1.6.10.1 2011/01/10 00:42:17 riz Exp $");
-#endif
-#endif /* LIBC_SCCS and not lint */
-
-// BEGIN android-added
-#define _DIAGASSERT(exp) assert(exp)
-#include "../private/arpa_nameser.h"
-// END android-added
-
-// android-removed: #include "port_before.h"
-
-// android-removed: #include "namespace.h"
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <arpa/nameser.h>
-#include <string.h>
-#include <assert.h>
-#include <ctype.h>
-#include <errno.h>
-
-// android-removed: #include "port_after.h"
-
-// BEGIN android-removed
-// #ifdef __weak_alias
-// __weak_alias(inet_pton,_inet_pton)
-// #endif
-// END android-removed
-
-/*%
- * WARNING: Don't even consider trying to compile this on a system where
- * sizeof(int) < 4.  sizeof(int) > 4 is fine; all the world's not a VAX.
- */
-
-static int	inet_pton4(const char *src, u_char *dst, int pton);
-static int	inet_pton6(const char *src, u_char *dst);
-
-/* int
- * inet_pton(af, src, dst)
- *	convert from presentation format (which usually means ASCII printable)
- *	to network format (which is usually some kind of binary format).
- * return:
- *	1 if the address was valid for the specified address family
- *	0 if the address wasn't valid (`dst' is untouched in this case)
- *	-1 if some other error occurred (`dst' is untouched in this case, too)
- * author:
- *	Paul Vixie, 1996.
- */
-int
-inet_pton(int af, const char *src, void *dst)
-{
-
-	_DIAGASSERT(src != NULL);
-	_DIAGASSERT(dst != NULL);
-
-	switch (af) {
-	case AF_INET:
-		return (inet_pton4(src, dst, 1));
-	case AF_INET6:
-		return (inet_pton6(src, dst));
-	default:
-		errno = EAFNOSUPPORT;
-		return (-1);
-	}
-	/* NOTREACHED */
-}
-
-/* int
- * inet_pton4(src, dst, pton)
- *	when last arg is 0: inet_aton(). with hexadecimal, octal and shorthand.
- *	when last arg is 1: inet_pton(). decimal dotted-quad only.
- * return:
- *	1 if `src' is a valid input, else 0.
- * notice:
- *	does not touch `dst' unless it's returning 1.
- * author:
- *	Paul Vixie, 1996.
- */
-static int
-inet_pton4(const char *src, u_char *dst, int pton)
-{
-	u_int32_t val;
-	u_int digit, base;
-	int n;
-	unsigned char c;
-	u_int parts[4];
-	register u_int *pp = parts;
-
-	_DIAGASSERT(src != NULL);
-	_DIAGASSERT(dst != NULL);
-
-	c = *src;
-	for (;;) {
-		/*
-		 * Collect number up to ``.''.
-		 * Values are specified as for C:
-		 * 0x=hex, 0=octal, isdigit=decimal.
-		 */
-		if (!isdigit(c))
-			return (0);
-		val = 0; base = 10;
-		if (c == '0') {
-			c = *++src;
-			if (c == 'x' || c == 'X')
-				base = 16, c = *++src;
-			else if (isdigit(c) && c != '9')
-				base = 8;
-		}
-		/* inet_pton() takes decimal only */
-		if (pton && base != 10)
-			return (0);
-		for (;;) {
-			if (isdigit(c)) {
-				digit = c - '0';
-				if (digit >= base)
-					break;
-				val = (val * base) + digit;
-				c = *++src;
-			} else if (base == 16 && isxdigit(c)) {
-				digit = c + 10 - (islower(c) ? 'a' : 'A');
-				if (digit >= 16)
-					break;
-				val = (val << 4) | digit;
-				c = *++src;
-			} else
-				break;
-		}
-		if (c == '.') {
-			/*
-			 * Internet format:
-			 *	a.b.c.d
-			 *	a.b.c	(with c treated as 16 bits)
-			 *	a.b	(with b treated as 24 bits)
-			 *	a	(with a treated as 32 bits)
-			 */
-			if (pp >= parts + 3)
-				return (0);
-			*pp++ = val;
-			c = *++src;
-		} else
-			break;
-	}
-	/*
-	 * Check for trailing characters.
-	 */
-	if (c != '\0' && !isspace(c))
-		return (0);
-	/*
-	 * Concoct the address according to
-	 * the number of parts specified.
-	 */
-	n = pp - parts + 1;
-	/* inet_pton() takes dotted-quad only.  it does not take shorthand. */
-	if (pton && n != 4)
-		return (0);
-	switch (n) {
-
-	case 0:
-		return (0);		/* initial nondigit */
-
-	case 1:				/* a -- 32 bits */
-		break;
-
-	case 2:				/* a.b -- 8.24 bits */
-		if (parts[0] > 0xff || val > 0xffffff)
-			return (0);
-		val |= parts[0] << 24;
-		break;
-
-	case 3:				/* a.b.c -- 8.8.16 bits */
-		if ((parts[0] | parts[1]) > 0xff || val > 0xffff)
-			return (0);
-		val |= (parts[0] << 24) | (parts[1] << 16);
-		break;
-
-	case 4:				/* a.b.c.d -- 8.8.8.8 bits */
-		if ((parts[0] | parts[1] | parts[2] | val) > 0xff)
-			return (0);
-		val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
-		break;
-	}
-	if (dst) {
-		val = htonl(val);
-		memcpy(dst, &val, NS_INADDRSZ);
-	}
-	return (1);
-}
-
-/* int
- * inet_pton6(src, dst)
- *	convert presentation level address to network order binary form.
- * return:
- *	1 if `src' is a valid [RFC1884 2.2] address, else 0.
- * notice:
- *	(1) does not touch `dst' unless it's returning 1.
- *	(2) :: in a full address is silently ignored.
- * credit:
- *	inspired by Mark Andrews.
- * author:
- *	Paul Vixie, 1996.
- */
-static int
-inet_pton6(const char *src, u_char *dst)
-{
-	static const char xdigits_l[] = "0123456789abcdef",
-			  xdigits_u[] = "0123456789ABCDEF";
-	u_char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
-	const char *xdigits, *curtok;
-	int ch, seen_xdigits;
-	u_int val;
-
-	_DIAGASSERT(src != NULL);
-	_DIAGASSERT(dst != NULL);
-
-	memset((tp = tmp), '\0', NS_IN6ADDRSZ);
-	endp = tp + NS_IN6ADDRSZ;
-	colonp = NULL;
-	/* Leading :: requires some special handling. */
-	if (*src == ':')
-		if (*++src != ':')
-			return (0);
-	curtok = src;
-	seen_xdigits = 0;
-	val = 0;
-	while ((ch = *src++) != '\0') {
-		const char *pch;
-
-		if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
-			pch = strchr((xdigits = xdigits_u), ch);
-		if (pch != NULL) {
-			val <<= 4;
-			val |= (pch - xdigits);
-			if (++seen_xdigits > 4)
-				return (0);
-			continue;
-		}
-		if (ch == ':') {
-			curtok = src;
-			if (!seen_xdigits) {
-				if (colonp)
-					return (0);
-				colonp = tp;
-				continue;
-			} else if (*src == '\0')
-				return (0);
-			if (tp + NS_INT16SZ > endp)
-				return (0);
-			*tp++ = (u_char) (val >> 8) & 0xff;
-			*tp++ = (u_char) val & 0xff;
-			seen_xdigits = 0;
-			val = 0;
-			continue;
-		}
-		if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
-		    inet_pton4(curtok, tp, 1) > 0) {
-			tp += NS_INADDRSZ;
-			seen_xdigits = 0;
-			break;	/*%< '\\0' was seen by inet_pton4(). */
-		}
-		return (0);
-	}
-	if (seen_xdigits) {
-		if (tp + NS_INT16SZ > endp)
-			return (0);
-		*tp++ = (u_char) (val >> 8) & 0xff;
-		*tp++ = (u_char) val & 0xff;
-	}
-	if (colonp != NULL) {
-		/*
-		 * Since some memmove()'s erroneously fail to handle
-		 * overlapping regions, we'll do the shift by hand.
-		 */
-		const int n = tp - colonp;
-		int i;
-
-		if (tp == endp)
-			return (0);
-		for (i = 1; i <= n; i++) {
-			endp[- i] = colonp[n - i];
-			colonp[n - i] = 0;
-		}
-		tp = endp;
-	}
-	if (tp != endp)
-		return (0);
-	memcpy(dst, tmp, NS_IN6ADDRSZ);
-	return (1);
-}
-
-/*! \file */
diff --git a/libc/kernel/README.TXT b/libc/kernel/README.TXT
index 1ca3350e..7d24fe9 100644
--- a/libc/kernel/README.TXT
+++ b/libc/kernel/README.TXT
@@ -60,13 +60,6 @@
     'external/kernel-headers/original'. this is the script you're likely going to
     run whenever you update the original headers.
 
-NOTE:
-  if ANDROID_PRODUCT_OUT is defined in your environment, both 'clean_header.py'
-  and 'update_all.py' will automatically issue "p4 add/edit/delete" commands
-  appropriately to reflect the changes being made.
-
-  you will need to "p4 submit" manually though...
-
 
 HOW TO BUILD BIONIC AND OTHER PROGRAMS WITH THE CLEAN HEADERS:
 ==============================================================
diff --git a/libc/kernel/arch-arm/asm/arch/dma.h b/libc/kernel/arch-arm/asm/arch/dma.h
index cdfe92b..5405469 100644
--- a/libc/kernel/arch-arm/asm/arch/dma.h
+++ b/libc/kernel/arch-arm/asm/arch/dma.h
@@ -64,7 +64,7 @@
 #define OMAP_DMA4_CAPS_2 (OMAP24XX_DMA_BASE + 0x6c)
 #define OMAP_DMA4_CAPS_3 (OMAP24XX_DMA_BASE + 0x70)
 #define OMAP_DMA4_CAPS_4 (OMAP24XX_DMA_BASE + 0x74)
-#define OMAP_LOGICAL_DMA_CH_COUNT 32  
+#define OMAP_LOGICAL_DMA_CH_COUNT 32
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OMAP_DMA_CCR_REG(n) __REG32(OMAP24XX_DMA_BASE + 0x60 * (n) + 0x80)
 #define OMAP_DMA_CLNK_CTRL_REG(n) __REG32(OMAP24XX_DMA_BASE + 0x60 * (n) + 0x84)
@@ -171,83 +171,83 @@
 #define OMAP_DMA_CRYPTO_DES_OUT 56
 #define OMAP24XX_DMA_NO_DEVICE 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OMAP24XX_DMA_XTI_DMA 1  
-#define OMAP24XX_DMA_EXT_DMAREQ0 2  
-#define OMAP24XX_DMA_EXT_DMAREQ1 3  
-#define OMAP24XX_DMA_GPMC 4  
+#define OMAP24XX_DMA_XTI_DMA 1
+#define OMAP24XX_DMA_EXT_DMAREQ0 2
+#define OMAP24XX_DMA_EXT_DMAREQ1 3
+#define OMAP24XX_DMA_GPMC 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OMAP24XX_DMA_GFX 5  
-#define OMAP24XX_DMA_DSS 6  
-#define OMAP24XX_DMA_VLYNQ_TX 7  
-#define OMAP24XX_DMA_CWT 8  
+#define OMAP24XX_DMA_GFX 5
+#define OMAP24XX_DMA_DSS 6
+#define OMAP24XX_DMA_VLYNQ_TX 7
+#define OMAP24XX_DMA_CWT 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OMAP24XX_DMA_AES_TX 9  
-#define OMAP24XX_DMA_AES_RX 10  
-#define OMAP24XX_DMA_DES_TX 11  
-#define OMAP24XX_DMA_DES_RX 12  
+#define OMAP24XX_DMA_AES_TX 9
+#define OMAP24XX_DMA_AES_RX 10
+#define OMAP24XX_DMA_DES_TX 11
+#define OMAP24XX_DMA_DES_RX 12
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OMAP24XX_DMA_SHA1MD5_RX 13  
-#define OMAP24XX_DMA_EXT_DMAREQ2 14  
-#define OMAP24XX_DMA_EXT_DMAREQ3 15  
-#define OMAP24XX_DMA_EXT_DMAREQ4 16  
+#define OMAP24XX_DMA_SHA1MD5_RX 13
+#define OMAP24XX_DMA_EXT_DMAREQ2 14
+#define OMAP24XX_DMA_EXT_DMAREQ3 15
+#define OMAP24XX_DMA_EXT_DMAREQ4 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OMAP24XX_DMA_EAC_AC_RD 17  
-#define OMAP24XX_DMA_EAC_AC_WR 18  
-#define OMAP24XX_DMA_EAC_MD_UL_RD 19  
-#define OMAP24XX_DMA_EAC_MD_UL_WR 20  
+#define OMAP24XX_DMA_EAC_AC_RD 17
+#define OMAP24XX_DMA_EAC_AC_WR 18
+#define OMAP24XX_DMA_EAC_MD_UL_RD 19
+#define OMAP24XX_DMA_EAC_MD_UL_WR 20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OMAP24XX_DMA_EAC_MD_DL_RD 21  
-#define OMAP24XX_DMA_EAC_MD_DL_WR 22  
-#define OMAP24XX_DMA_EAC_BT_UL_RD 23  
-#define OMAP24XX_DMA_EAC_BT_UL_WR 24  
+#define OMAP24XX_DMA_EAC_MD_DL_RD 21
+#define OMAP24XX_DMA_EAC_MD_DL_WR 22
+#define OMAP24XX_DMA_EAC_BT_UL_RD 23
+#define OMAP24XX_DMA_EAC_BT_UL_WR 24
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OMAP24XX_DMA_EAC_BT_DL_RD 25  
-#define OMAP24XX_DMA_EAC_BT_DL_WR 26  
-#define OMAP24XX_DMA_I2C1_TX 27  
-#define OMAP24XX_DMA_I2C1_RX 28  
+#define OMAP24XX_DMA_EAC_BT_DL_RD 25
+#define OMAP24XX_DMA_EAC_BT_DL_WR 26
+#define OMAP24XX_DMA_I2C1_TX 27
+#define OMAP24XX_DMA_I2C1_RX 28
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OMAP24XX_DMA_I2C2_TX 29  
-#define OMAP24XX_DMA_I2C2_RX 30  
-#define OMAP24XX_DMA_MCBSP1_TX 31  
-#define OMAP24XX_DMA_MCBSP1_RX 32  
+#define OMAP24XX_DMA_I2C2_TX 29
+#define OMAP24XX_DMA_I2C2_RX 30
+#define OMAP24XX_DMA_MCBSP1_TX 31
+#define OMAP24XX_DMA_MCBSP1_RX 32
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OMAP24XX_DMA_MCBSP2_TX 33  
-#define OMAP24XX_DMA_MCBSP2_RX 34  
-#define OMAP24XX_DMA_SPI1_TX0 35  
-#define OMAP24XX_DMA_SPI1_RX0 36  
+#define OMAP24XX_DMA_MCBSP2_TX 33
+#define OMAP24XX_DMA_MCBSP2_RX 34
+#define OMAP24XX_DMA_SPI1_TX0 35
+#define OMAP24XX_DMA_SPI1_RX0 36
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OMAP24XX_DMA_SPI1_TX1 37  
-#define OMAP24XX_DMA_SPI1_RX1 38  
-#define OMAP24XX_DMA_SPI1_TX2 39  
-#define OMAP24XX_DMA_SPI1_RX2 40  
+#define OMAP24XX_DMA_SPI1_TX1 37
+#define OMAP24XX_DMA_SPI1_RX1 38
+#define OMAP24XX_DMA_SPI1_TX2 39
+#define OMAP24XX_DMA_SPI1_RX2 40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OMAP24XX_DMA_SPI1_TX3 41  
-#define OMAP24XX_DMA_SPI1_RX3 42  
-#define OMAP24XX_DMA_SPI2_TX0 43  
-#define OMAP24XX_DMA_SPI2_RX0 44  
+#define OMAP24XX_DMA_SPI1_TX3 41
+#define OMAP24XX_DMA_SPI1_RX3 42
+#define OMAP24XX_DMA_SPI2_TX0 43
+#define OMAP24XX_DMA_SPI2_RX0 44
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OMAP24XX_DMA_SPI2_TX1 45  
-#define OMAP24XX_DMA_SPI2_RX1 46  
-#define OMAP24XX_DMA_UART1_TX 49  
-#define OMAP24XX_DMA_UART1_RX 50  
+#define OMAP24XX_DMA_SPI2_TX1 45
+#define OMAP24XX_DMA_SPI2_RX1 46
+#define OMAP24XX_DMA_UART1_TX 49
+#define OMAP24XX_DMA_UART1_RX 50
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OMAP24XX_DMA_UART2_TX 51  
-#define OMAP24XX_DMA_UART2_RX 52  
-#define OMAP24XX_DMA_UART3_TX 53  
-#define OMAP24XX_DMA_UART3_RX 54  
+#define OMAP24XX_DMA_UART2_TX 51
+#define OMAP24XX_DMA_UART2_RX 52
+#define OMAP24XX_DMA_UART3_TX 53
+#define OMAP24XX_DMA_UART3_RX 54
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OMAP24XX_DMA_USB_W2FC_TX0 55  
-#define OMAP24XX_DMA_USB_W2FC_RX0 56  
-#define OMAP24XX_DMA_USB_W2FC_TX1 57  
-#define OMAP24XX_DMA_USB_W2FC_RX1 58  
+#define OMAP24XX_DMA_USB_W2FC_TX0 55
+#define OMAP24XX_DMA_USB_W2FC_RX0 56
+#define OMAP24XX_DMA_USB_W2FC_TX1 57
+#define OMAP24XX_DMA_USB_W2FC_RX1 58
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OMAP24XX_DMA_USB_W2FC_TX2 59  
-#define OMAP24XX_DMA_USB_W2FC_RX2 60  
-#define OMAP24XX_DMA_MMC1_TX 61  
-#define OMAP24XX_DMA_MMC1_RX 62  
+#define OMAP24XX_DMA_USB_W2FC_TX2 59
+#define OMAP24XX_DMA_USB_W2FC_RX2 60
+#define OMAP24XX_DMA_MMC1_TX 61
+#define OMAP24XX_DMA_MMC1_RX 62
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OMAP24XX_DMA_MS 63  
-#define OMAP24XX_DMA_EXT_DMAREQ5 64  
+#define OMAP24XX_DMA_MS 63
+#define OMAP24XX_DMA_EXT_DMAREQ5 64
 #define OMAP1510_DMA_LCD_BASE (0xfffedb00)
 #define OMAP1510_DMA_LCD_CTRL (OMAP1510_DMA_LCD_BASE + 0x00)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-arm/asm/arch/fpga.h b/libc/kernel/arch-arm/asm/arch/fpga.h
index 64055a4..8439a80 100644
--- a/libc/kernel/arch-arm/asm/arch/fpga.h
+++ b/libc/kernel/arch-arm/asm/arch/fpga.h
@@ -22,19 +22,19 @@
 #define fpga_read(reg) __raw_readb(reg)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define fpga_write(val, reg) __raw_writeb(val, reg)
-#define H2P2_DBG_FPGA_BASE 0xE8000000  
-#define H2P2_DBG_FPGA_SIZE SZ_4K  
-#define H2P2_DBG_FPGA_START 0x04000000  
+#define H2P2_DBG_FPGA_BASE 0xE8000000
+#define H2P2_DBG_FPGA_SIZE SZ_4K
+#define H2P2_DBG_FPGA_START 0x04000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define H2P2_DBG_FPGA_ETHR_START (H2P2_DBG_FPGA_START + 0x300)
-#define H2P2_DBG_FPGA_FPGA_REV (H2P2_DBG_FPGA_BASE + 0x10)  
-#define H2P2_DBG_FPGA_BOARD_REV (H2P2_DBG_FPGA_BASE + 0x12)  
-#define H2P2_DBG_FPGA_GPIO (H2P2_DBG_FPGA_BASE + 0x14)  
+#define H2P2_DBG_FPGA_FPGA_REV (H2P2_DBG_FPGA_BASE + 0x10)
+#define H2P2_DBG_FPGA_BOARD_REV (H2P2_DBG_FPGA_BASE + 0x12)
+#define H2P2_DBG_FPGA_GPIO (H2P2_DBG_FPGA_BASE + 0x14)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define H2P2_DBG_FPGA_LEDS (H2P2_DBG_FPGA_BASE + 0x16)  
-#define H2P2_DBG_FPGA_MISC_INPUTS (H2P2_DBG_FPGA_BASE + 0x18)  
-#define H2P2_DBG_FPGA_LAN_STATUS (H2P2_DBG_FPGA_BASE + 0x1A)  
-#define H2P2_DBG_FPGA_LAN_RESET (H2P2_DBG_FPGA_BASE + 0x1C)  
+#define H2P2_DBG_FPGA_LEDS (H2P2_DBG_FPGA_BASE + 0x16)
+#define H2P2_DBG_FPGA_MISC_INPUTS (H2P2_DBG_FPGA_BASE + 0x18)
+#define H2P2_DBG_FPGA_LAN_STATUS (H2P2_DBG_FPGA_BASE + 0x1A)
+#define H2P2_DBG_FPGA_LAN_RESET (H2P2_DBG_FPGA_BASE + 0x1C)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct h2p2_dbg_fpga {
  u16 smc91x[8];
@@ -57,16 +57,16 @@
 #define H2P2_DBG_FPGA_LED_RED (1 << 13)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define H2P2_DBG_FPGA_LED_BLUE (1 << 12)
-#define H2P2_DBG_FPGA_LOAD_METER (1 << 0) 
+#define H2P2_DBG_FPGA_LOAD_METER (1 << 0)
 #define H2P2_DBG_FPGA_LOAD_METER_SIZE 11
 #define H2P2_DBG_FPGA_LOAD_METER_MASK ((1 << H2P2_DBG_FPGA_LOAD_METER_SIZE) - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define H2P2_DBG_FPGA_P2_LED_TIMER (1 << 0)
 #define H2P2_DBG_FPGA_P2_LED_IDLE (1 << 1)
-#define OMAP1510_FPGA_BASE 0xE8000000  
+#define OMAP1510_FPGA_BASE 0xE8000000
 #define OMAP1510_FPGA_SIZE SZ_4K
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OMAP1510_FPGA_START 0x08000000  
+#define OMAP1510_FPGA_START 0x08000000
 #define OMAP1510_FPGA_REV_LOW (OMAP1510_FPGA_BASE + 0x0)
 #define OMAP1510_FPGA_REV_HIGH (OMAP1510_FPGA_BASE + 0x1)
 #define OMAP1510_FPGA_LCD_PANEL_CONTROL (OMAP1510_FPGA_BASE + 0x2)
@@ -122,16 +122,16 @@
 #define OMAP1510_FPGA_PCR_4MHZ_CLK (1 << 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OMAP1510_FPGA_PCR_RSRVD_BIT0 (1 << 0)
-#define OMAP1510_FPGA_HID_SCLK (1<<0)  
-#define OMAP1510_FPGA_HID_MOSI (1<<1)  
-#define OMAP1510_FPGA_HID_nSS (1<<2)  
+#define OMAP1510_FPGA_HID_SCLK (1<<0)
+#define OMAP1510_FPGA_HID_MOSI (1<<1)
+#define OMAP1510_FPGA_HID_nSS (1<<2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OMAP1510_FPGA_HID_nHSUS (1<<3)  
-#define OMAP1510_FPGA_HID_MISO (1<<4)  
-#define OMAP1510_FPGA_HID_ATN (1<<5)  
+#define OMAP1510_FPGA_HID_nHSUS (1<<3)
+#define OMAP1510_FPGA_HID_MISO (1<<4)
+#define OMAP1510_FPGA_HID_ATN (1<<5)
 #define OMAP1510_FPGA_HID_rsrvd (1<<6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OMAP1510_FPGA_HID_RESETn (1<<7)  
+#define OMAP1510_FPGA_HID_RESETn (1<<7)
 #define OMAP1510_INT_FPGA (IH_GPIO_BASE + 13)
 #define OMAP1510_IH_FPGA_BASE IH_BOARD_BASE
 #define OMAP1510_INT_FPGA_ATN (OMAP1510_IH_FPGA_BASE + 0)
diff --git a/libc/kernel/arch-arm/asm/arch/hardware.h b/libc/kernel/arch-arm/asm/arch/hardware.h
index d13fb6a..a779d96 100644
--- a/libc/kernel/arch-arm/asm/arch/hardware.h
+++ b/libc/kernel/arch-arm/asm/arch/hardware.h
@@ -66,8 +66,8 @@
 #define ULPD_SETUP_ANALOG_CELL_3 (ULPD_REG_BASE + 0x24)
 #define ULPD_CLOCK_CTRL (ULPD_REG_BASE + 0x30)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DIS_USB_PVCI_CLK (1 << 5)  
-#define USB_MCLK_EN (1 << 4)  
+#define DIS_USB_PVCI_CLK (1 << 5)
+#define USB_MCLK_EN (1 << 4)
 #define ULPD_SOFT_REQ (ULPD_REG_BASE + 0x34)
 #define SOFT_UDC_REQ (1 << 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-arm/asm/arch/mcbsp.h b/libc/kernel/arch-arm/asm/arch/mcbsp.h
index 2090ef2..5f4e4d4 100644
--- a/libc/kernel/arch-arm/asm/arch/mcbsp.h
+++ b/libc/kernel/arch-arm/asm/arch/mcbsp.h
@@ -39,12 +39,12 @@
 #define RRDY 0x0002
 #define RFULL 0x0004
 #define RSYNC_ERR 0x0008
-#define RINTM(value) ((value)<<4)  
+#define RINTM(value) ((value)<<4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABIS 0x0040
 #define DXENA 0x0080
-#define CLKSTP(value) ((value)<<11)  
-#define RJUST(value) ((value)<<13)  
+#define CLKSTP(value) ((value)<<11)
+#define RJUST(value) ((value)<<13)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DLB 0x8000
 #define XRST 0x0001
@@ -52,7 +52,7 @@
 #define XEMPTY 0x0004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define XSYNC_ERR 0x0008
-#define XINTM(value) ((value)<<4)  
+#define XINTM(value) ((value)<<4)
 #define GRST 0x0040
 #define FRST 0x0080
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -77,29 +77,29 @@
 #define XIOEN 0x2000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IDLE_EN 0x4000
-#define RWDLEN1(value) ((value)<<5)  
-#define RFRLEN1(value) ((value)<<8)  
-#define XWDLEN1(value) ((value)<<5)  
+#define RWDLEN1(value) ((value)<<5)
+#define RFRLEN1(value) ((value)<<8)
+#define XWDLEN1(value) ((value)<<5)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define XFRLEN1(value) ((value)<<8)  
-#define RDATDLY(value) (value)  
+#define XFRLEN1(value) ((value)<<8)
+#define RDATDLY(value) (value)
 #define RFIG 0x0004
-#define RCOMPAND(value) ((value)<<3)  
+#define RCOMPAND(value) ((value)<<3)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RWDLEN2(value) ((value)<<5)  
-#define RFRLEN2(value) ((value)<<8)  
+#define RWDLEN2(value) ((value)<<5)
+#define RFRLEN2(value) ((value)<<8)
 #define RPHASE 0x8000
-#define XDATDLY(value) (value)  
+#define XDATDLY(value) (value)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define XFIG 0x0004
-#define XCOMPAND(value) ((value)<<3)  
-#define XWDLEN2(value) ((value)<<5)  
-#define XFRLEN2(value) ((value)<<8)  
+#define XCOMPAND(value) ((value)<<3)
+#define XWDLEN2(value) ((value)<<5)
+#define XFRLEN2(value) ((value)<<8)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define XPHASE 0x8000
-#define CLKGDV(value) (value)  
-#define FWID(value) ((value)<<8)  
-#define FPER(value) (value)  
+#define CLKGDV(value) (value)
+#define FWID(value) ((value)<<8)
+#define FPER(value) (value)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FSGM 0x1000
 #define CLKSM 0x2000
@@ -107,14 +107,14 @@
 #define GSYNC 0x8000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RMCM 0x0001
-#define RCBLK(value) ((value)<<2)  
-#define RPABLK(value) ((value)<<5)  
-#define RPBBLK(value) ((value)<<7)  
+#define RCBLK(value) ((value)<<2)
+#define RPABLK(value) ((value)<<5)
+#define RPBBLK(value) ((value)<<7)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define XMCM(value) (value)  
-#define XCBLK(value) ((value)<<2)  
-#define XPABLK(value) ((value)<<5)  
-#define XPBBLK(value) ((value)<<7)  
+#define XMCM(value) (value)
+#define XCBLK(value) ((value)<<2)
+#define XPABLK(value) ((value)<<5)
+#define XPBBLK(value) ((value)<<7)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct omap_mcbsp_reg_cfg {
  u16 spcr2;
diff --git a/libc/kernel/arch-arm/asm/arch/mux.h b/libc/kernel/arch-arm/asm/arch/mux.h
index 502b2c7..ef0848c 100644
--- a/libc/kernel/arch-arm/asm/arch/mux.h
+++ b/libc/kernel/arch-arm/asm/arch/mux.h
@@ -18,8 +18,8 @@
  ****************************************************************************/
 #ifndef __ASM_ARCH_MUX_H
 #define __ASM_ARCH_MUX_H
-#define PU_PD_SEL_NA 0  
-#define PULL_DWN_CTRL_NA 0  
+#define PU_PD_SEL_NA 0
+#define PULL_DWN_CTRL_NA 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MUX_REG(reg, mode_offset, mode) .mux_reg = FUNC_MUX_CTRL_##reg,   .mask_offset = mode_offset,   .mask = mode,
 #define PULL_REG(reg, bit, status) .pull_reg = PULL_DWN_CTRL_##reg,   .pull_bit = bit,   .pull_val = status,
diff --git a/libc/kernel/arch-arm/asm/delay.h b/libc/kernel/arch-arm/asm/delay.h
index 77b4293..a04c40b 100644
--- a/libc/kernel/arch-arm/asm/delay.h
+++ b/libc/kernel/arch-arm/asm/delay.h
@@ -18,7 +18,7 @@
  ****************************************************************************/
 #ifndef __ASM_ARM_DELAY_H
 #define __ASM_ARM_DELAY_H
-#include <asm/param.h>  
+#include <asm/param.h>
 #define MAX_UDELAY_MS 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define udelay(n)   (__builtin_constant_p(n) ?   ((n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() :   __const_udelay((n) * ((2199023U*HZ)>>11))) :   __udelay(n))
diff --git a/libc/kernel/arch-arm/asm/elf.h b/libc/kernel/arch-arm/asm/elf.h
deleted file mode 100644
index d23a01a..0000000
--- a/libc/kernel/arch-arm/asm/elf.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
- ****************************************************************************
- ***
- ***   This header was automatically generated from a Linux kernel header
- ***   of the same name, to make information necessary for userspace to
- ***   call into the kernel available to libc.  It contains only constants,
- ***   structures, and macros generated from the original header, and thus,
- ***   contains no copyrightable information.
- ***
- ***   To edit the content of this header, modify the corresponding
- ***   source file (e.g. under external/kernel-headers/original/) then
- ***   run bionic/libc/kernel/tools/update_all.py
- ***
- ***   Any manual change here will be lost the next time this script will
- ***   be run. You've been warned!
- ***
- ****************************************************************************
- ****************************************************************************/
-#ifndef __ASMARM_ELF_H
-#define __ASMARM_ELF_H
-#include <asm/ptrace.h>
-#include <asm/user.h>
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#ifdef __KERNEL
-#include <asm/procinfo.h>
-#endif
-typedef unsigned long elf_greg_t;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-typedef unsigned long elf_freg_t[3];
-#define EM_ARM 40
-#define EF_ARM_APCS26 0x08
-#define EF_ARM_SOFT_FLOAT 0x200
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EF_ARM_EABI_MASK 0xFF000000
-#define R_ARM_NONE 0
-#define R_ARM_PC24 1
-#define R_ARM_ABS32 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R_ARM_CALL 28
-#define R_ARM_JUMP24 29
-#define ELF_NGREG (sizeof (struct pt_regs) / sizeof(elf_greg_t))
-typedef elf_greg_t elf_gregset_t[ELF_NGREG];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-typedef struct user_fp elf_fpregset_t;
-#define elf_check_arch(x) ( ((x)->e_machine == EM_ARM) && (ELF_PROC_OK((x))) )
-#define ELF_CLASS ELFCLASS32
-#ifdef __ARMEB__
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ELF_DATA ELFDATA2MSB
-#else
-#define ELF_DATA ELFDATA2LSB
-#endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ELF_ARCH EM_ARM
-#define USE_ELF_CORE_DUMP
-#define ELF_EXEC_PAGESIZE 4096
-#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ELF_PLAT_INIT(_r, load_addr) (_r)->ARM_r0 = 0
-#define ELF_HWCAP (elf_hwcap)
-#define ELF_PLATFORM_SIZE 8
-#define ELF_PLATFORM (elf_platform)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
diff --git a/libc/kernel/arch-arm/asm/fcntl.h b/libc/kernel/arch-arm/asm/fcntl.h
index 348782e..995d145 100644
--- a/libc/kernel/arch-arm/asm/fcntl.h
+++ b/libc/kernel/arch-arm/asm/fcntl.h
@@ -18,10 +18,10 @@
  ****************************************************************************/
 #ifndef _ARM_FCNTL_H
 #define _ARM_FCNTL_H
-#define O_DIRECTORY 040000  
-#define O_NOFOLLOW 0100000  
+#define O_DIRECTORY 040000
+#define O_NOFOLLOW 0100000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define O_DIRECT 0200000  
+#define O_DIRECT 0200000
 #define O_LARGEFILE 0400000
 #include <asm-generic/fcntl.h>
 #endif
diff --git a/libc/kernel/arch-arm/asm/hardirq.h b/libc/kernel/arch-arm/asm/hardirq.h
index db06a9a..4d2db7c 100644
--- a/libc/kernel/arch-arm/asm/hardirq.h
+++ b/libc/kernel/arch-arm/asm/hardirq.h
@@ -27,7 +27,7 @@
  unsigned int local_timer_irqs;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } ____cacheline_aligned irq_cpustat_t;
-#include <linux/irq_cpustat.h>  
+#include <linux/irq_cpustat.h>
 #if NR_IRQS > 256
 #define HARDIRQ_BITS 9
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-arm/asm/ioctls.h b/libc/kernel/arch-arm/asm/ioctls.h
index 64d81bf..e89fd30 100644
--- a/libc/kernel/arch-arm/asm/ioctls.h
+++ b/libc/kernel/arch-arm/asm/ioctls.h
@@ -66,14 +66,14 @@
 #define TIOCSETD 0x5423
 #define TIOCGETD 0x5424
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TCSBRKP 0x5425  
-#define TIOCSBRK 0x5427  
-#define TIOCCBRK 0x5428  
-#define TIOCGSID 0x5429  
+#define TCSBRKP 0x5425
+#define TIOCSBRK 0x5427
+#define TIOCCBRK 0x5428
+#define TIOCGSID 0x5429
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCGPTN _IOR('T',0x30, unsigned int)  
-#define TIOCSPTLCK _IOW('T',0x31, int)  
-#define FIONCLEX 0x5450  
+#define TIOCGPTN _IOR('T',0x30, unsigned int)
+#define TIOCSPTLCK _IOW('T',0x31, int)
+#define FIONCLEX 0x5450
 #define FIOCLEX 0x5451
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FIOASYNC 0x5452
@@ -83,13 +83,13 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TIOCGLCKTRMIOS 0x5456
 #define TIOCSLCKTRMIOS 0x5457
-#define TIOCSERGSTRUCT 0x5458  
-#define TIOCSERGETLSR 0x5459  
+#define TIOCSERGSTRUCT 0x5458
+#define TIOCSERGETLSR 0x5459
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCSERGETMULTI 0x545A  
-#define TIOCSERSETMULTI 0x545B  
-#define TIOCMIWAIT 0x545C  
-#define TIOCGICOUNT 0x545D  
+#define TIOCSERGETMULTI 0x545A
+#define TIOCSERSETMULTI 0x545B
+#define TIOCMIWAIT 0x545C
+#define TIOCGICOUNT 0x545D
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FIOQSIZE 0x545E
 #define TIOCPKT_DATA 0
@@ -101,5 +101,5 @@
 #define TIOCPKT_NOSTOP 16
 #define TIOCPKT_DOSTOP 32
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCSER_TEMT 0x01  
+#define TIOCSER_TEMT 0x01
 #endif
diff --git a/libc/kernel/arch-arm/asm/mc146818rtc.h b/libc/kernel/arch-arm/asm/mc146818rtc.h
index a389401..9e205ba 100644
--- a/libc/kernel/arch-arm/asm/mc146818rtc.h
+++ b/libc/kernel/arch-arm/asm/mc146818rtc.h
@@ -23,7 +23,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifndef RTC_PORT
 #define RTC_PORT(x) (0x70 + (x))
-#define RTC_ALWAYS_BCD 1  
+#define RTC_ALWAYS_BCD 1
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CMOS_READ(addr) ({  outb_p((addr),RTC_PORT(0));  inb_p(RTC_PORT(1));  })
diff --git a/libc/kernel/arch-arm/asm/mman.h b/libc/kernel/arch-arm/asm/mman.h
index c391fe4..87a806a 100644
--- a/libc/kernel/arch-arm/asm/mman.h
+++ b/libc/kernel/arch-arm/asm/mman.h
@@ -19,16 +19,16 @@
 #ifndef __ARM_MMAN_H__
 #define __ARM_MMAN_H__
 #include <asm-generic/mman.h>
-#define MAP_GROWSDOWN 0x0100  
+#define MAP_GROWSDOWN 0x0100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MAP_DENYWRITE 0x0800  
-#define MAP_EXECUTABLE 0x1000  
-#define MAP_LOCKED 0x2000  
-#define MAP_NORESERVE 0x4000  
+#define MAP_DENYWRITE 0x0800
+#define MAP_EXECUTABLE 0x1000
+#define MAP_LOCKED 0x2000
+#define MAP_NORESERVE 0x4000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MAP_POPULATE 0x8000  
-#define MAP_NONBLOCK 0x10000  
-#define MCL_CURRENT 1  
-#define MCL_FUTURE 2  
+#define MAP_POPULATE 0x8000
+#define MAP_NONBLOCK 0x10000
+#define MCL_CURRENT 1
+#define MCL_FUTURE 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/arch-arm/asm/pgtable-hwdef.h b/libc/kernel/arch-arm/asm/pgtable-hwdef.h
index 7678ba3..cc47b37 100644
--- a/libc/kernel/arch-arm/asm/pgtable-hwdef.h
+++ b/libc/kernel/arch-arm/asm/pgtable-hwdef.h
@@ -26,19 +26,19 @@
 #define PMD_BIT4 (1 << 4)
 #define PMD_DOMAIN(x) ((x) << 5)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PMD_PROTECTION (1 << 9)  
+#define PMD_PROTECTION (1 << 9)
 #define PMD_SECT_BUFFERABLE (1 << 2)
 #define PMD_SECT_CACHEABLE (1 << 3)
-#define PMD_SECT_XN (1 << 4)  
+#define PMD_SECT_XN (1 << 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PMD_SECT_AP_WRITE (1 << 10)
 #define PMD_SECT_AP_READ (1 << 11)
-#define PMD_SECT_TEX(x) ((x) << 12)  
-#define PMD_SECT_APX (1 << 15)  
+#define PMD_SECT_TEX(x) ((x) << 12)
+#define PMD_SECT_APX (1 << 15)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PMD_SECT_S (1 << 16)  
-#define PMD_SECT_nG (1 << 17)  
-#define PMD_SECT_SUPER (1 << 18)  
+#define PMD_SECT_S (1 << 16)
+#define PMD_SECT_nG (1 << 17)
+#define PMD_SECT_SUPER (1 << 18)
 #define PMD_SECT_UNCACHED (0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
@@ -53,11 +53,11 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PTE_TYPE_LARGE (1 << 0)
 #define PTE_TYPE_SMALL (2 << 0)
-#define PTE_TYPE_EXT (3 << 0)  
+#define PTE_TYPE_EXT (3 << 0)
 #define PTE_BUFFERABLE (1 << 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PTE_CACHEABLE (1 << 3)
-#define PTE_EXT_XN (1 << 0)  
+#define PTE_EXT_XN (1 << 0)
 #define PTE_EXT_AP_MASK (3 << 4)
 #define PTE_EXT_AP0 (1 << 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -67,12 +67,12 @@
 #define PTE_EXT_AP_URO_SRW (PTE_EXT_AP1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PTE_EXT_AP_URW_SRW (PTE_EXT_AP1|PTE_EXT_AP0)
-#define PTE_EXT_TEX(x) ((x) << 6)  
-#define PTE_EXT_APX (1 << 9)  
-#define PTE_EXT_COHERENT (1 << 9)  
+#define PTE_EXT_TEX(x) ((x) << 6)
+#define PTE_EXT_APX (1 << 9)
+#define PTE_EXT_COHERENT (1 << 9)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PTE_EXT_SHARED (1 << 10)  
-#define PTE_EXT_NG (1 << 11)  
+#define PTE_EXT_SHARED (1 << 10)
+#define PTE_EXT_NG (1 << 11)
 #define PTE_SMALL_AP_MASK (0xff << 4)
 #define PTE_SMALL_AP_UNO_SRO (0x00 << 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-arm/asm/procinfo.h b/libc/kernel/arch-arm/asm/procinfo.h
index 7a665e7..e2ca039 100644
--- a/libc/kernel/arch-arm/asm/procinfo.h
+++ b/libc/kernel/arch-arm/asm/procinfo.h
@@ -48,7 +48,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HWCAP_HALF 2
 #define HWCAP_THUMB 4
-#define HWCAP_26BIT 8  
+#define HWCAP_26BIT 8
 #define HWCAP_FAST_MULT 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HWCAP_FPA 32
diff --git a/libc/kernel/arch-arm/asm/ptrace.h b/libc/kernel/arch-arm/asm/ptrace.h
index 661ba97..ab58990 100644
--- a/libc/kernel/arch-arm/asm/ptrace.h
+++ b/libc/kernel/arch-arm/asm/ptrace.h
@@ -63,11 +63,11 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PSR_N_BIT 0x80000000
 #define PCMASK 0
-#define PSR_f 0xff000000  
-#define PSR_s 0x00ff0000  
+#define PSR_f 0xff000000
+#define PSR_s 0x00ff0000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PSR_x 0x0000ff00  
-#define PSR_c 0x000000ff  
+#define PSR_x 0x0000ff00
+#define PSR_c 0x000000ff
 #ifndef __ASSEMBLY__
 struct pt_regs {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-arm/asm/shmparam.h b/libc/kernel/arch-arm/asm/shmparam.h
index 4061915..c01b413 100644
--- a/libc/kernel/arch-arm/asm/shmparam.h
+++ b/libc/kernel/arch-arm/asm/shmparam.h
@@ -18,7 +18,7 @@
  ****************************************************************************/
 #ifndef _ASMARM_SHMPARAM_H
 #define _ASMARM_SHMPARAM_H
-#define SHMLBA (4 * PAGE_SIZE)  
+#define SHMLBA (4 * PAGE_SIZE)
 #define __ARCH_FORCE_SHMLBA
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/arch-arm/asm/sockios.h b/libc/kernel/arch-arm/asm/sockios.h
index 909463f..3b240ea 100644
--- a/libc/kernel/arch-arm/asm/sockios.h
+++ b/libc/kernel/arch-arm/asm/sockios.h
@@ -24,6 +24,6 @@
 #define FIOGETOWN 0x8903
 #define SIOCGPGRP 0x8904
 #define SIOCATMARK 0x8905
-#define SIOCGSTAMP 0x8906  
+#define SIOCGSTAMP 0x8906
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/arch-arm/asm/stat.h b/libc/kernel/arch-arm/asm/stat.h
index 0a6d036..d8188bf 100644
--- a/libc/kernel/arch-arm/asm/stat.h
+++ b/libc/kernel/arch-arm/asm/stat.h
@@ -34,7 +34,7 @@
  unsigned long st_mtime;
  unsigned long st_ctime;
 };
-#define STAT_HAVE_NSEC 
+#define STAT_HAVE_NSEC
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct stat {
 #ifdef __ARMEB__
diff --git a/libc/kernel/arch-arm/asm/termbits.h b/libc/kernel/arch-arm/asm/termbits.h
index 4aa14d9..476432b 100644
--- a/libc/kernel/arch-arm/asm/termbits.h
+++ b/libc/kernel/arch-arm/asm/termbits.h
@@ -113,7 +113,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FF1 0100000
 #define CBAUD 0010017
-#define B0 0000000  
+#define B0 0000000
 #define B50 0000001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define B75 0000002
@@ -169,10 +169,10 @@
 #define B3000000 0010015
 #define B3500000 0010016
 #define B4000000 0010017
-#define CIBAUD 002003600000  
+#define CIBAUD 002003600000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CMSPAR 010000000000  
-#define CRTSCTS 020000000000  
+#define CMSPAR 010000000000
+#define CRTSCTS 020000000000
 #define ISIG 0000001
 #define ICANON 0000002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-arm/asm/termios.h b/libc/kernel/arch-arm/asm/termios.h
index 4b80774..46351cf 100644
--- a/libc/kernel/arch-arm/asm/termios.h
+++ b/libc/kernel/arch-arm/asm/termios.h
@@ -64,17 +64,17 @@
 #define N_PPP 3
 #define N_STRIP 4
 #define N_AX25 5
-#define N_X25 6  
+#define N_X25 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define N_6PACK 7
-#define N_MASC 8  
-#define N_R3964 9  
-#define N_PROFIBUS_FDL 10  
+#define N_MASC 8
+#define N_R3964 9
+#define N_PROFIBUS_FDL 10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define N_IRDA 11  
-#define N_SMSBLOCK 12  
-#define N_HDLC 13  
+#define N_IRDA 11
+#define N_SMSBLOCK 12
+#define N_HDLC 13
 #define N_SYNC_PPP 14
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define N_HCI 15  
+#define N_HCI 15
 #endif
diff --git a/libc/kernel/arch-arm/asm/ucontext.h b/libc/kernel/arch-arm/asm/ucontext.h
index 769f694..f54a7f1 100644
--- a/libc/kernel/arch-arm/asm/ucontext.h
+++ b/libc/kernel/arch-arm/asm/ucontext.h
@@ -27,7 +27,7 @@
  struct sigcontext uc_mcontext;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  sigset_t uc_sigmask;
- int __unused[32 - (sizeof (sigset_t) / sizeof (int))];
+ int __linux_unused[32 - (sizeof (sigset_t) / sizeof (int))];
  unsigned long uc_regspace[128] __attribute__((__aligned__(8)));
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-arm/asm/unistd.h b/libc/kernel/arch-arm/asm/unistd.h
index 454ed89..d2612e8 100644
--- a/libc/kernel/arch-arm/asm/unistd.h
+++ b/libc/kernel/arch-arm/asm/unistd.h
@@ -102,7 +102,7 @@
 #define __NR_sethostname (__NR_SYSCALL_BASE+ 74)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setrlimit (__NR_SYSCALL_BASE+ 75)
-#define __NR_getrlimit (__NR_SYSCALL_BASE+ 76)  
+#define __NR_getrlimit (__NR_SYSCALL_BASE+ 76)
 #define __NR_getrusage (__NR_SYSCALL_BASE+ 77)
 #define __NR_gettimeofday (__NR_SYSCALL_BASE+ 78)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -141,7 +141,7 @@
 #define __NR_fstat (__NR_SYSCALL_BASE+108)
 #define __NR_vhangup (__NR_SYSCALL_BASE+111)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define __NR_syscall (__NR_SYSCALL_BASE+113)  
+#define __NR_syscall (__NR_SYSCALL_BASE+113)
 #define __NR_wait4 (__NR_SYSCALL_BASE+114)
 #define __NR_swapoff (__NR_SYSCALL_BASE+115)
 #define __NR_sysinfo (__NR_SYSCALL_BASE+116)
@@ -228,7 +228,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sendfile (__NR_SYSCALL_BASE+187)
 #define __NR_vfork (__NR_SYSCALL_BASE+190)
-#define __NR_ugetrlimit (__NR_SYSCALL_BASE+191)  
+#define __NR_ugetrlimit (__NR_SYSCALL_BASE+191)
 #define __NR_mmap2 (__NR_SYSCALL_BASE+192)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_truncate64 (__NR_SYSCALL_BASE+193)
diff --git a/libc/kernel/arch-mips/asm/addrspace.h b/libc/kernel/arch-mips/asm/addrspace.h
index 69abbd4..cb72e2b 100644
--- a/libc/kernel/arch-mips/asm/addrspace.h
+++ b/libc/kernel/arch-mips/asm/addrspace.h
@@ -38,8 +38,8 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define _ACAST64_
 #else
-#define _ACAST32_ (_ATYPE_)(_ATYPE32_)  
-#define _ACAST64_ (_ATYPE64_)  
+#define _ACAST32_ (_ATYPE_)(_ATYPE32_)
+#define _ACAST64_ (_ATYPE64_)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #define KSEGX(a) ((_ACAST32_ (a)) & 0xe0000000)
@@ -83,10 +83,10 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define XKPHYS_TO_PHYS(p) ((p) & TO_PHYS_MASK)
 #define PHYS_TO_XKPHYS(cm, a) (_CONST64_(0x8000000000000000) |   (_CONST64_(cm) << 59) | (a))
-#define TO_PHYS_MASK _CONST64_(0x07ffffffffffffff)  
+#define TO_PHYS_MASK _CONST64_(0x07ffffffffffffff)
 #define COMPAT_K1BASE32 _CONST64_(0xffffffffa0000000)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PHYS_TO_COMPATK1(x) ((x) | COMPAT_K1BASE32)  
+#define PHYS_TO_COMPATK1(x) ((x) | COMPAT_K1BASE32)
 #define KDM_TO_PHYS(x) (_ACAST64_ (x) & TO_PHYS_MASK)
 #define PHYS_TO_K0(x) (_ACAST64_ (x) | CAC_BASE)
 #endif
diff --git a/libc/kernel/arch-mips/asm/asmmacro.h b/libc/kernel/arch-mips/asm/asmmacro.h
deleted file mode 100644
index c42d45e..0000000
--- a/libc/kernel/arch-mips/asm/asmmacro.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/****************************************************************************
- ****************************************************************************
- ***
- ***   This header was automatically generated from a Linux kernel header
- ***   of the same name, to make information necessary for userspace to
- ***   call into the kernel available to libc.  It contains only constants,
- ***   structures, and macros generated from the original header, and thus,
- ***   contains no copyrightable information.
- ***
- ***   To edit the content of this header, modify the corresponding
- ***   source file (e.g. under external/kernel-headers/original/) then
- ***   run bionic/libc/kernel/tools/update_all.py
- ***
- ***   Any manual change here will be lost the next time this script will
- ***   be run. You've been warned!
- ***
- ****************************************************************************
- ****************************************************************************/
-#ifndef _ASM_ASMMACRO_H
-#define _ASM_ASMMACRO_H
-#include <asm/hazards.h>
-#include <asm/asmmacro-32.h>
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
diff --git a/libc/kernel/arch-mips/asm/bitops.h b/libc/kernel/arch-mips/asm/bitops.h
index 749caaa..1e09e40 100644
--- a/libc/kernel/arch-mips/asm/bitops.h
+++ b/libc/kernel/arch-mips/asm/bitops.h
@@ -28,7 +28,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <asm/barrier.h>
 #include <asm/bug.h>
-#include <asm/byteorder.h>  
+#include <asm/byteorder.h>
 #include <asm/cpu-features.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <asm/sgidefs.h>
diff --git a/libc/kernel/arch-mips/asm/bootinfo.h b/libc/kernel/arch-mips/asm/bootinfo.h
index 97368ea..dd9296d 100644
--- a/libc/kernel/arch-mips/asm/bootinfo.h
+++ b/libc/kernel/arch-mips/asm/bootinfo.h
@@ -21,32 +21,32 @@
 #include <linux/types.h>
 #include <asm/setup.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MACH_UNKNOWN 0  
+#define MACH_UNKNOWN 0
 #define MACH_DSUNKNOWN 0
-#define MACH_DS23100 1  
-#define MACH_DS5100 2  
+#define MACH_DS23100 1
+#define MACH_DS5100 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MACH_DS5000_200 3  
-#define MACH_DS5000_1XX 4  
-#define MACH_DS5000_XX 5  
-#define MACH_DS5000_2X0 6  
+#define MACH_DS5000_200 3
+#define MACH_DS5000_1XX 4
+#define MACH_DS5000_XX 5
+#define MACH_DS5000_2X0 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MACH_DS5400 7  
-#define MACH_DS5500 8  
-#define MACH_DS5800 9  
-#define MACH_DS5900 10  
+#define MACH_DS5400 7
+#define MACH_DS5500 8
+#define MACH_DS5800 9
+#define MACH_DS5900 10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MACH_MSP4200_EVAL 0  
-#define MACH_MSP4200_GW 1  
-#define MACH_MSP4200_FPGA 2  
-#define MACH_MSP7120_EVAL 3  
+#define MACH_MSP4200_EVAL 0
+#define MACH_MSP4200_GW 1
+#define MACH_MSP4200_FPGA 2
+#define MACH_MSP7120_EVAL 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MACH_MSP7120_GW 4  
-#define MACH_MSP7120_FPGA 5  
-#define MACH_MSP_OTHER 255  
-#define MACH_MIKROTIK_RB532 0  
+#define MACH_MSP7120_GW 4
+#define MACH_MSP7120_FPGA 5
+#define MACH_MSP_OTHER 255
+#define MACH_MIKROTIK_RB532 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MACH_MIKROTIK_RB532A 1  
+#define MACH_MIKROTIK_RB532A 1
 #define CL_SIZE COMMAND_LINE_SIZE
 #define BOOT_MEM_MAP_MAX 32
 #define BOOT_MEM_RAM 1
diff --git a/libc/kernel/arch-mips/asm/cachectl.h b/libc/kernel/arch-mips/asm/cachectl.h
index 458c00d..6cc6f28 100644
--- a/libc/kernel/arch-mips/asm/cachectl.h
+++ b/libc/kernel/arch-mips/asm/cachectl.h
@@ -18,11 +18,11 @@
  ****************************************************************************/
 #ifndef _ASM_CACHECTL
 #define _ASM_CACHECTL
-#define ICACHE (1<<0)  
-#define DCACHE (1<<1)  
+#define ICACHE (1<<0)
+#define DCACHE (1<<1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BCACHE (ICACHE|DCACHE)  
-#define CACHEABLE 0  
-#define UNCACHEABLE 1  
+#define BCACHE (ICACHE|DCACHE)
+#define CACHEABLE 0
+#define UNCACHEABLE 1
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-mips/asm/cpu-info.h b/libc/kernel/arch-mips/asm/cpu-info.h
index d8bd122..f2ff85a 100644
--- a/libc/kernel/arch-mips/asm/cpu-info.h
+++ b/libc/kernel/arch-mips/asm/cpu-info.h
@@ -31,12 +31,12 @@
 };
 #define MIPS_CACHE_NOT_PRESENT 0x00000001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MIPS_CACHE_VTAG 0x00000002  
-#define MIPS_CACHE_ALIASES 0x00000004  
-#define MIPS_CACHE_IC_F_DC 0x00000008  
-#define MIPS_IC_SNOOPS_REMOTE 0x00000010  
+#define MIPS_CACHE_VTAG 0x00000002
+#define MIPS_CACHE_ALIASES 0x00000004
+#define MIPS_CACHE_IC_F_DC 0x00000008
+#define MIPS_IC_SNOOPS_REMOTE 0x00000010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MIPS_CACHE_PINDEX 0x00000020  
+#define MIPS_CACHE_PINDEX 0x00000020
 struct cpuinfo_mips {
  unsigned long udelay_val;
  unsigned long asid_cache;
diff --git a/libc/kernel/arch-mips/asm/cpu.h b/libc/kernel/arch-mips/asm/cpu.h
index 7b4b2d3..cbd4147 100644
--- a/libc/kernel/arch-mips/asm/cpu.h
+++ b/libc/kernel/arch-mips/asm/cpu.h
@@ -34,9 +34,9 @@
 #define PRID_IMP_R2000 0x0100
 #define PRID_IMP_AU1_REV1 0x0100
 #define PRID_IMP_AU1_REV2 0x0200
-#define PRID_IMP_R3000 0x0200  
+#define PRID_IMP_R3000 0x0200
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PRID_IMP_R6000 0x0300  
+#define PRID_IMP_R6000 0x0300
 #define PRID_IMP_R4000 0x0400
 #define PRID_IMP_R6000A 0x0600
 #define PRID_IMP_R10000 0x0900
@@ -53,7 +53,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PRID_IMP_TX39 0x2200
 #define PRID_IMP_R4640 0x2200
-#define PRID_IMP_R4650 0x2200  
+#define PRID_IMP_R4650 0x2200
 #define PRID_IMP_R5000 0x2300
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PRID_IMP_TX49 0x2d00
@@ -61,7 +61,7 @@
 #define PRID_IMP_MAGIC 0x2500
 #define PRID_IMP_RM7000 0x2700
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PRID_IMP_NEVADA 0x2800  
+#define PRID_IMP_NEVADA 0x2800
 #define PRID_IMP_RM9000 0x3400
 #define PRID_IMP_LOONGSON1 0x4200
 #define PRID_IMP_R5432 0x5400
@@ -108,11 +108,11 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PRID_REV_TX3927 0x0040
 #define PRID_REV_VR4111 0x0050
-#define PRID_REV_VR4181 0x0050  
+#define PRID_REV_VR4181 0x0050
 #define PRID_REV_VR4121 0x0060
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PRID_REV_VR4122 0x0070
-#define PRID_REV_VR4181A 0x0070  
+#define PRID_REV_VR4181A 0x0070
 #define PRID_REV_VR4130 0x0080
 #define PRID_REV_34K_V1_0_2 0x0022
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -157,39 +157,39 @@
 #define MIPS_CPU_ISA_32BIT (MIPS_CPU_ISA_I | MIPS_CPU_ISA_II |   MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M32R2 )
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MIPS_CPU_ISA_64BIT (MIPS_CPU_ISA_III | MIPS_CPU_ISA_IV |   MIPS_CPU_ISA_V | MIPS_CPU_ISA_M64R1 | MIPS_CPU_ISA_M64R2)
-#define MIPS_CPU_TLB 0x00000001  
-#define MIPS_CPU_4KEX 0x00000002  
-#define MIPS_CPU_3K_CACHE 0x00000004  
+#define MIPS_CPU_TLB 0x00000001
+#define MIPS_CPU_4KEX 0x00000002
+#define MIPS_CPU_3K_CACHE 0x00000004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MIPS_CPU_4K_CACHE 0x00000008  
-#define MIPS_CPU_TX39_CACHE 0x00000010  
-#define MIPS_CPU_FPU 0x00000020  
-#define MIPS_CPU_32FPR 0x00000040  
+#define MIPS_CPU_4K_CACHE 0x00000008
+#define MIPS_CPU_TX39_CACHE 0x00000010
+#define MIPS_CPU_FPU 0x00000020
+#define MIPS_CPU_32FPR 0x00000040
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MIPS_CPU_COUNTER 0x00000080  
-#define MIPS_CPU_WATCH 0x00000100  
-#define MIPS_CPU_DIVEC 0x00000200  
-#define MIPS_CPU_VCE 0x00000400  
+#define MIPS_CPU_COUNTER 0x00000080
+#define MIPS_CPU_WATCH 0x00000100
+#define MIPS_CPU_DIVEC 0x00000200
+#define MIPS_CPU_VCE 0x00000400
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MIPS_CPU_CACHE_CDEX_P 0x00000800  
-#define MIPS_CPU_CACHE_CDEX_S 0x00001000  
-#define MIPS_CPU_MCHECK 0x00002000  
-#define MIPS_CPU_EJTAG 0x00004000  
+#define MIPS_CPU_CACHE_CDEX_P 0x00000800
+#define MIPS_CPU_CACHE_CDEX_S 0x00001000
+#define MIPS_CPU_MCHECK 0x00002000
+#define MIPS_CPU_EJTAG 0x00004000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MIPS_CPU_NOFPUEX 0x00008000  
-#define MIPS_CPU_LLSC 0x00010000  
-#define MIPS_CPU_INCLUSIVE_CACHES 0x00020000  
-#define MIPS_CPU_PREFETCH 0x00040000  
+#define MIPS_CPU_NOFPUEX 0x00008000
+#define MIPS_CPU_LLSC 0x00010000
+#define MIPS_CPU_INCLUSIVE_CACHES 0x00020000
+#define MIPS_CPU_PREFETCH 0x00040000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MIPS_CPU_VINT 0x00080000  
-#define MIPS_CPU_VEIC 0x00100000  
-#define MIPS_CPU_ULRI 0x00200000  
-#define MIPS_ASE_MIPS16 0x00000001  
+#define MIPS_CPU_VINT 0x00080000
+#define MIPS_CPU_VEIC 0x00100000
+#define MIPS_CPU_ULRI 0x00200000
+#define MIPS_ASE_MIPS16 0x00000001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MIPS_ASE_MDMX 0x00000002  
-#define MIPS_ASE_MIPS3D 0x00000004  
-#define MIPS_ASE_SMARTMIPS 0x00000008  
-#define MIPS_ASE_DSP 0x00000010  
+#define MIPS_ASE_MDMX 0x00000002
+#define MIPS_ASE_MIPS3D 0x00000004
+#define MIPS_ASE_SMARTMIPS 0x00000008
+#define MIPS_ASE_DSP 0x00000010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MIPS_ASE_MIPSMT 0x00000020  
+#define MIPS_ASE_MIPSMT 0x00000020
 #endif
diff --git a/libc/kernel/arch-mips/asm/dec/ecc.h b/libc/kernel/arch-mips/asm/dec/ecc.h
index 51342a5..8fe30a6 100644
--- a/libc/kernel/arch-mips/asm/dec/ecc.h
+++ b/libc/kernel/arch-mips/asm/dec/ecc.h
@@ -18,23 +18,23 @@
  ****************************************************************************/
 #ifndef __ASM_MIPS_DEC_ECC_H
 #define __ASM_MIPS_DEC_ECC_H
-#define KN0X_EAR_VALID (1<<31)  
-#define KN0X_EAR_CPU (1<<30)  
+#define KN0X_EAR_VALID (1<<31)
+#define KN0X_EAR_CPU (1<<30)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KN0X_EAR_WRITE (1<<29)  
-#define KN0X_EAR_ECCERR (1<<28)  
-#define KN0X_EAR_RES_27 (1<<27)  
-#define KN0X_EAR_ADDRESS (0x7ffffff<<0)  
+#define KN0X_EAR_WRITE (1<<29)
+#define KN0X_EAR_ECCERR (1<<28)
+#define KN0X_EAR_RES_27 (1<<27)
+#define KN0X_EAR_ADDRESS (0x7ffffff<<0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KN0X_ESR_VLDHI (1<<31)  
-#define KN0X_ESR_CHKHI (0x7f<<24)  
-#define KN0X_ESR_SNGHI (1<<23)  
-#define KN0X_ESR_SYNHI (0x7f<<16)  
+#define KN0X_ESR_VLDHI (1<<31)
+#define KN0X_ESR_CHKHI (0x7f<<24)
+#define KN0X_ESR_SNGHI (1<<23)
+#define KN0X_ESR_SYNHI (0x7f<<16)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KN0X_ESR_VLDLO (1<<15)  
-#define KN0X_ESR_CHKLO (0x7f<<8)  
-#define KN0X_ESR_SNGLO (1<<7)  
-#define KN0X_ESR_SYNLO (0x7f<<0)  
+#define KN0X_ESR_VLDLO (1<<15)
+#define KN0X_ESR_CHKLO (0x7f<<8)
+#define KN0X_ESR_SNGLO (1<<7)
+#define KN0X_ESR_SYNLO (0x7f<<0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifndef __ASSEMBLY__
 #include <linux/interrupt.h>
diff --git a/libc/kernel/arch-mips/asm/dec/ioasic_addrs.h b/libc/kernel/arch-mips/asm/dec/ioasic_addrs.h
index 99774a1..7249f2d 100644
--- a/libc/kernel/arch-mips/asm/dec/ioasic_addrs.h
+++ b/libc/kernel/arch-mips/asm/dec/ioasic_addrs.h
@@ -19,106 +19,106 @@
 #ifndef __ASM_MIPS_DEC_IOASIC_ADDRS_H
 #define __ASM_MIPS_DEC_IOASIC_ADDRS_H
 #define IOASIC_SLOT_SIZE 0x00040000
-#define IOASIC_SYS_ROM (0*IOASIC_SLOT_SIZE)  
+#define IOASIC_SYS_ROM (0*IOASIC_SLOT_SIZE)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IOASIC_IOCTL (1*IOASIC_SLOT_SIZE)  
-#define IOASIC_ESAR (2*IOASIC_SLOT_SIZE)  
-#define IOASIC_LANCE (3*IOASIC_SLOT_SIZE)  
-#define IOASIC_SCC0 (4*IOASIC_SLOT_SIZE)  
+#define IOASIC_IOCTL (1*IOASIC_SLOT_SIZE)
+#define IOASIC_ESAR (2*IOASIC_SLOT_SIZE)
+#define IOASIC_LANCE (3*IOASIC_SLOT_SIZE)
+#define IOASIC_SCC0 (4*IOASIC_SLOT_SIZE)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IOASIC_VDAC_HI (5*IOASIC_SLOT_SIZE)  
-#define IOASIC_SCC1 (6*IOASIC_SLOT_SIZE)  
-#define IOASIC_VDAC_LO (7*IOASIC_SLOT_SIZE)  
-#define IOASIC_TOY (8*IOASIC_SLOT_SIZE)  
+#define IOASIC_VDAC_HI (5*IOASIC_SLOT_SIZE)
+#define IOASIC_SCC1 (6*IOASIC_SLOT_SIZE)
+#define IOASIC_VDAC_LO (7*IOASIC_SLOT_SIZE)
+#define IOASIC_TOY (8*IOASIC_SLOT_SIZE)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IOASIC_ISDN (9*IOASIC_SLOT_SIZE)  
-#define IOASIC_ERRADDR (9*IOASIC_SLOT_SIZE)  
-#define IOASIC_CHKSYN (10*IOASIC_SLOT_SIZE)  
-#define IOASIC_ACC_BUS (10*IOASIC_SLOT_SIZE)  
+#define IOASIC_ISDN (9*IOASIC_SLOT_SIZE)
+#define IOASIC_ERRADDR (9*IOASIC_SLOT_SIZE)
+#define IOASIC_CHKSYN (10*IOASIC_SLOT_SIZE)
+#define IOASIC_ACC_BUS (10*IOASIC_SLOT_SIZE)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IOASIC_MCR (11*IOASIC_SLOT_SIZE)  
-#define IOASIC_FLOPPY (11*IOASIC_SLOT_SIZE)  
-#define IOASIC_SCSI (12*IOASIC_SLOT_SIZE)  
-#define IOASIC_FDC_DMA (13*IOASIC_SLOT_SIZE)  
+#define IOASIC_MCR (11*IOASIC_SLOT_SIZE)
+#define IOASIC_FLOPPY (11*IOASIC_SLOT_SIZE)
+#define IOASIC_SCSI (12*IOASIC_SLOT_SIZE)
+#define IOASIC_FDC_DMA (13*IOASIC_SLOT_SIZE)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IOASIC_SCSI_DMA (14*IOASIC_SLOT_SIZE)  
-#define IOASIC_RES_15 (15*IOASIC_SLOT_SIZE)  
-#define IO_REG_SCSI_DMA_P 0x00  
-#define IO_REG_SCSI_DMA_BP 0x10  
+#define IOASIC_SCSI_DMA (14*IOASIC_SLOT_SIZE)
+#define IOASIC_RES_15 (15*IOASIC_SLOT_SIZE)
+#define IO_REG_SCSI_DMA_P 0x00
+#define IO_REG_SCSI_DMA_BP 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IO_REG_LANCE_DMA_P 0x20  
-#define IO_REG_SCC0A_T_DMA_P 0x30  
-#define IO_REG_SCC0A_R_DMA_P 0x40  
-#define IO_REG_SCC1A_T_DMA_P 0x50  
+#define IO_REG_LANCE_DMA_P 0x20
+#define IO_REG_SCC0A_T_DMA_P 0x30
+#define IO_REG_SCC0A_R_DMA_P 0x40
+#define IO_REG_SCC1A_T_DMA_P 0x50
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IO_REG_SCC1A_R_DMA_P 0x60  
-#define IO_REG_AB_T_DMA_P 0x50  
-#define IO_REG_AB_R_DMA_P 0x60  
-#define IO_REG_FLOPPY_DMA_P 0x70  
+#define IO_REG_SCC1A_R_DMA_P 0x60
+#define IO_REG_AB_T_DMA_P 0x50
+#define IO_REG_AB_R_DMA_P 0x60
+#define IO_REG_FLOPPY_DMA_P 0x70
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IO_REG_ISDN_T_DMA_P 0x80  
-#define IO_REG_ISDN_T_DMA_BP 0x90  
-#define IO_REG_ISDN_R_DMA_P 0xa0  
-#define IO_REG_ISDN_R_DMA_BP 0xb0  
+#define IO_REG_ISDN_T_DMA_P 0x80
+#define IO_REG_ISDN_T_DMA_BP 0x90
+#define IO_REG_ISDN_R_DMA_P 0xa0
+#define IO_REG_ISDN_R_DMA_BP 0xb0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IO_REG_DATA_0 0xc0  
-#define IO_REG_DATA_1 0xd0  
-#define IO_REG_DATA_2 0xe0  
-#define IO_REG_DATA_3 0xf0  
+#define IO_REG_DATA_0 0xc0
+#define IO_REG_DATA_1 0xd0
+#define IO_REG_DATA_2 0xe0
+#define IO_REG_DATA_3 0xf0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IO_REG_SSR 0x100  
-#define IO_REG_SIR 0x110  
-#define IO_REG_SIMR 0x120  
-#define IO_REG_SAR 0x130  
+#define IO_REG_SSR 0x100
+#define IO_REG_SIR 0x110
+#define IO_REG_SIMR 0x120
+#define IO_REG_SAR 0x130
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IO_REG_ISDN_T_DATA 0x140  
-#define IO_REG_ISDN_R_DATA 0x150  
-#define IO_REG_LANCE_SLOT 0x160  
-#define IO_REG_SCSI_SLOT 0x170  
+#define IO_REG_ISDN_T_DATA 0x140
+#define IO_REG_ISDN_R_DATA 0x150
+#define IO_REG_LANCE_SLOT 0x160
+#define IO_REG_SCSI_SLOT 0x170
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IO_REG_SCC0A_SLOT 0x180  
-#define IO_REG_SCC1A_SLOT 0x190  
-#define IO_REG_AB_SLOT 0x190  
-#define IO_REG_FLOPPY_SLOT 0x1a0  
+#define IO_REG_SCC0A_SLOT 0x180
+#define IO_REG_SCC1A_SLOT 0x190
+#define IO_REG_AB_SLOT 0x190
+#define IO_REG_FLOPPY_SLOT 0x1a0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IO_REG_SCSI_SCR 0x1b0  
-#define IO_REG_SCSI_SDR0 0x1c0  
-#define IO_REG_SCSI_SDR1 0x1d0  
-#define IO_REG_FCTR 0x1e0  
+#define IO_REG_SCSI_SCR 0x1b0
+#define IO_REG_SCSI_SDR0 0x1c0
+#define IO_REG_SCSI_SDR1 0x1d0
+#define IO_REG_FCTR 0x1e0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IO_REG_RES_31 0x1f0  
-#define IO_SSR_SCC0A_TX_DMA_EN (1<<31)  
-#define IO_SSR_SCC0A_RX_DMA_EN (1<<30)  
-#define IO_SSR_RES_27 (1<<27)  
+#define IO_REG_RES_31 0x1f0
+#define IO_SSR_SCC0A_TX_DMA_EN (1<<31)
+#define IO_SSR_SCC0A_RX_DMA_EN (1<<30)
+#define IO_SSR_RES_27 (1<<27)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IO_SSR_RES_26 (1<<26)  
-#define IO_SSR_RES_25 (1<<25)  
-#define IO_SSR_RES_24 (1<<24)  
-#define IO_SSR_RES_23 (1<<23)  
+#define IO_SSR_RES_26 (1<<26)
+#define IO_SSR_RES_25 (1<<25)
+#define IO_SSR_RES_24 (1<<24)
+#define IO_SSR_RES_23 (1<<23)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IO_SSR_SCSI_DMA_DIR (1<<18)  
-#define IO_SSR_SCSI_DMA_EN (1<<17)  
-#define IO_SSR_LANCE_DMA_EN (1<<16)  
-#define IO_SSR_SCC1A_TX_DMA_EN (1<<29)  
+#define IO_SSR_SCSI_DMA_DIR (1<<18)
+#define IO_SSR_SCSI_DMA_EN (1<<17)
+#define IO_SSR_LANCE_DMA_EN (1<<16)
+#define IO_SSR_SCC1A_TX_DMA_EN (1<<29)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IO_SSR_SCC1A_RX_DMA_EN (1<<28)  
-#define IO_SSR_RES_22 (1<<22)  
-#define IO_SSR_RES_21 (1<<21)  
-#define IO_SSR_RES_20 (1<<20)  
+#define IO_SSR_SCC1A_RX_DMA_EN (1<<28)
+#define IO_SSR_RES_22 (1<<22)
+#define IO_SSR_RES_21 (1<<21)
+#define IO_SSR_RES_20 (1<<20)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IO_SSR_RES_19 (1<<19)  
-#define IO_SSR_AB_TX_DMA_EN (1<<29)  
-#define IO_SSR_AB_RX_DMA_EN (1<<28)  
-#define IO_SSR_FLOPPY_DMA_DIR (1<<22)  
+#define IO_SSR_RES_19 (1<<19)
+#define IO_SSR_AB_TX_DMA_EN (1<<29)
+#define IO_SSR_AB_RX_DMA_EN (1<<28)
+#define IO_SSR_FLOPPY_DMA_DIR (1<<22)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IO_SSR_FLOPPY_DMA_EN (1<<21)  
-#define IO_SSR_ISDN_TX_DMA_EN (1<<20)  
-#define IO_SSR_ISDN_RX_DMA_EN (1<<19)  
-#define KN0X_IO_SSR_DIAGDN (1<<15)  
+#define IO_SSR_FLOPPY_DMA_EN (1<<21)
+#define IO_SSR_ISDN_TX_DMA_EN (1<<20)
+#define IO_SSR_ISDN_RX_DMA_EN (1<<19)
+#define KN0X_IO_SSR_DIAGDN (1<<15)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KN0X_IO_SSR_SCC_RST (1<<11)  
-#define KN0X_IO_SSR_RTC_RST (1<<10)  
-#define KN0X_IO_SSR_ASC_RST (1<<9)  
-#define KN0X_IO_SSR_LANCE_RST (1<<8)  
+#define KN0X_IO_SSR_SCC_RST (1<<11)
+#define KN0X_IO_SSR_RTC_RST (1<<10)
+#define KN0X_IO_SSR_ASC_RST (1<<9)
+#define KN0X_IO_SSR_LANCE_RST (1<<8)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/arch-mips/asm/dec/kn02xa.h b/libc/kernel/arch-mips/asm/dec/kn02xa.h
index 6078c8b..0272514 100644
--- a/libc/kernel/arch-mips/asm/dec/kn02xa.h
+++ b/libc/kernel/arch-mips/asm/dec/kn02xa.h
@@ -21,38 +21,38 @@
 #include <asm/dec/ioasic_addrs.h>
 #define KN02XA_SLOT_BASE 0x1c000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KN02XA_MER 0x0c400000  
-#define KN02XA_MSR 0x0c800000  
-#define KN02XA_MEM_CONF 0x0e000000  
-#define KN02XA_EAR 0x0e000004  
+#define KN02XA_MER 0x0c400000
+#define KN02XA_MSR 0x0c800000
+#define KN02XA_MEM_CONF 0x0e000000
+#define KN02XA_EAR 0x0e000004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KN02XA_BOOT0 0x0e000008  
-#define KN02XA_MEM_INTR 0x0e00000c  
-#define KN02XA_MER_RES_28 (0xf<<28)  
-#define KN02XA_MER_RES_17 (0x3ff<<17)  
+#define KN02XA_BOOT0 0x0e000008
+#define KN02XA_MEM_INTR 0x0e00000c
+#define KN02XA_MER_RES_28 (0xf<<28)
+#define KN02XA_MER_RES_17 (0x3ff<<17)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KN02XA_MER_PAGERR (1<<16)  
-#define KN02XA_MER_TRANSERR (1<<15)  
-#define KN02XA_MER_PARDIS (1<<14)  
-#define KN02XA_MER_SIZE (1<<13)  
+#define KN02XA_MER_PAGERR (1<<16)
+#define KN02XA_MER_TRANSERR (1<<15)
+#define KN02XA_MER_PARDIS (1<<14)
+#define KN02XA_MER_SIZE (1<<13)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KN02XA_MER_RES_12 (1<<12)  
-#define KN02XA_MER_BYTERR (0xf<<8)  
-#define KN02XA_MER_BYTERR_3 (0x8<<8)  
-#define KN02XA_MER_BYTERR_2 (0x4<<8)  
+#define KN02XA_MER_RES_12 (1<<12)
+#define KN02XA_MER_BYTERR (0xf<<8)
+#define KN02XA_MER_BYTERR_3 (0x8<<8)
+#define KN02XA_MER_BYTERR_2 (0x4<<8)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KN02XA_MER_BYTERR_1 (0x2<<8)  
-#define KN02XA_MER_BYTERR_0 (0x1<<8)  
-#define KN02XA_MER_RES_0 (0xff<<0)  
-#define KN02XA_MSR_RES_27 (0x1f<<27)  
+#define KN02XA_MER_BYTERR_1 (0x2<<8)
+#define KN02XA_MER_BYTERR_0 (0x1<<8)
+#define KN02XA_MER_RES_0 (0xff<<0)
+#define KN02XA_MSR_RES_27 (0x1f<<27)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KN02XA_MSR_RES_14 (0x7<<14)  
-#define KN02XA_MSR_SIZE (1<<13)  
-#define KN02XA_MSR_RES_0 (0x1fff<<0)  
-#define KN02XA_EAR_RES_29 (0x7<<29)  
+#define KN02XA_MSR_RES_14 (0x7<<14)
+#define KN02XA_MSR_SIZE (1<<13)
+#define KN02XA_MSR_RES_0 (0x1fff<<0)
+#define KN02XA_EAR_RES_29 (0x7<<29)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KN02XA_EAR_ADDRESS (0x7ffffff<<2)  
-#define KN02XA_EAR_RES_0 (0x3<<0)  
+#define KN02XA_EAR_ADDRESS (0x7ffffff<<2)
+#define KN02XA_EAR_RES_0 (0x3<<0)
 #ifndef __ASSEMBLY__
 #include <linux/interrupt.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-mips/asm/dma.h b/libc/kernel/arch-mips/asm/dma.h
index aedb5dd..e9ab7b2 100644
--- a/libc/kernel/arch-mips/asm/dma.h
+++ b/libc/kernel/arch-mips/asm/dma.h
@@ -18,8 +18,8 @@
  ****************************************************************************/
 #ifndef _ASM_DMA_H
 #define _ASM_DMA_H
-#include <asm/io.h>  
-#include <linux/spinlock.h>  
+#include <asm/io.h>
+#include <linux/spinlock.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <linux/delay.h>
 #include <asm/system.h>
@@ -36,34 +36,34 @@
 #define MAX_DMA_PFN PFN_DOWN(virt_to_phys((void *)MAX_DMA_ADDRESS))
 #define MAX_DMA32_PFN (1UL << (32 - PAGE_SHIFT))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IO_DMA1_BASE 0x00  
-#define IO_DMA2_BASE 0xC0  
-#define DMA1_CMD_REG 0x08  
-#define DMA1_STAT_REG 0x08  
+#define IO_DMA1_BASE 0x00
+#define IO_DMA2_BASE 0xC0
+#define DMA1_CMD_REG 0x08
+#define DMA1_STAT_REG 0x08
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DMA1_REQ_REG 0x09  
-#define DMA1_MASK_REG 0x0A  
-#define DMA1_MODE_REG 0x0B  
-#define DMA1_CLEAR_FF_REG 0x0C  
+#define DMA1_REQ_REG 0x09
+#define DMA1_MASK_REG 0x0A
+#define DMA1_MODE_REG 0x0B
+#define DMA1_CLEAR_FF_REG 0x0C
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DMA1_TEMP_REG 0x0D  
-#define DMA1_RESET_REG 0x0D  
-#define DMA1_CLR_MASK_REG 0x0E  
-#define DMA1_MASK_ALL_REG 0x0F  
+#define DMA1_TEMP_REG 0x0D
+#define DMA1_RESET_REG 0x0D
+#define DMA1_CLR_MASK_REG 0x0E
+#define DMA1_MASK_ALL_REG 0x0F
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DMA2_CMD_REG 0xD0  
-#define DMA2_STAT_REG 0xD0  
-#define DMA2_REQ_REG 0xD2  
-#define DMA2_MASK_REG 0xD4  
+#define DMA2_CMD_REG 0xD0
+#define DMA2_STAT_REG 0xD0
+#define DMA2_REQ_REG 0xD2
+#define DMA2_MASK_REG 0xD4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DMA2_MODE_REG 0xD6  
-#define DMA2_CLEAR_FF_REG 0xD8  
-#define DMA2_TEMP_REG 0xDA  
-#define DMA2_RESET_REG 0xDA  
+#define DMA2_MODE_REG 0xD6
+#define DMA2_CLEAR_FF_REG 0xD8
+#define DMA2_TEMP_REG 0xDA
+#define DMA2_RESET_REG 0xDA
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DMA2_CLR_MASK_REG 0xDC  
-#define DMA2_MASK_ALL_REG 0xDE  
-#define DMA_ADDR_0 0x00  
+#define DMA2_CLR_MASK_REG 0xDC
+#define DMA2_MASK_ALL_REG 0xDE
+#define DMA_ADDR_0 0x00
 #define DMA_ADDR_1 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DMA_ADDR_2 0x04
@@ -73,7 +73,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DMA_ADDR_6 0xC8
 #define DMA_ADDR_7 0xCC
-#define DMA_CNT_0 0x01  
+#define DMA_CNT_0 0x01
 #define DMA_CNT_1 0x03
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DMA_CNT_2 0x05
@@ -83,7 +83,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DMA_CNT_6 0xCA
 #define DMA_CNT_7 0xCE
-#define DMA_PAGE_0 0x87  
+#define DMA_PAGE_0 0x87
 #define DMA_PAGE_1 0x83
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DMA_PAGE_2 0x81
@@ -92,9 +92,9 @@
 #define DMA_PAGE_6 0x89
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DMA_PAGE_7 0x8A
-#define DMA_MODE_READ 0x44  
-#define DMA_MODE_WRITE 0x48  
-#define DMA_MODE_CASCADE 0xC0  
+#define DMA_MODE_READ 0x44
+#define DMA_MODE_WRITE 0x48
+#define DMA_MODE_CASCADE 0xC0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DMA_AUTOINIT 0x10
 #define isa_dma_bridge_buggy (0)
diff --git a/libc/kernel/arch-mips/asm/elf.h b/libc/kernel/arch-mips/asm/elf.h
deleted file mode 100644
index 6f79694..0000000
--- a/libc/kernel/arch-mips/asm/elf.h
+++ /dev/null
@@ -1,218 +0,0 @@
-/****************************************************************************
- ****************************************************************************
- ***
- ***   This header was automatically generated from a Linux kernel header
- ***   of the same name, to make information necessary for userspace to
- ***   call into the kernel available to libc.  It contains only constants,
- ***   structures, and macros generated from the original header, and thus,
- ***   contains no copyrightable information.
- ***
- ***   To edit the content of this header, modify the corresponding
- ***   source file (e.g. under external/kernel-headers/original/) then
- ***   run bionic/libc/kernel/tools/update_all.py
- ***
- ***   Any manual change here will be lost the next time this script will
- ***   be run. You've been warned!
- ***
- ****************************************************************************
- ****************************************************************************/
-#ifndef _ASM_ELF_H
-#define _ASM_ELF_H
-#define EF_MIPS_ARCH_1 0x00000000  
-#define EF_MIPS_ARCH_2 0x10000000  
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EF_MIPS_ARCH_3 0x20000000  
-#define EF_MIPS_ARCH_4 0x30000000  
-#define EF_MIPS_ARCH_5 0x40000000  
-#define EF_MIPS_ARCH_32 0x50000000  
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EF_MIPS_ARCH_64 0x60000000  
-#define EF_MIPS_ARCH_32R2 0x70000000  
-#define EF_MIPS_ARCH_64R2 0x80000000  
-#define EF_MIPS_ABI_O32 0x00001000  
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EF_MIPS_ABI_O64 0x00002000  
-#define PT_MIPS_REGINFO 0x70000000
-#define PT_MIPS_RTPROC 0x70000001
-#define PT_MIPS_OPTIONS 0x70000002
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EF_MIPS_NOREORDER 0x00000001
-#define EF_MIPS_PIC 0x00000002
-#define EF_MIPS_CPIC 0x00000004
-#define EF_MIPS_ABI2 0x00000020
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EF_MIPS_OPTIONS_FIRST 0x00000080
-#define EF_MIPS_32BITMODE 0x00000100
-#define EF_MIPS_ABI 0x0000f000
-#define EF_MIPS_ARCH 0xf0000000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DT_MIPS_RLD_VERSION 0x70000001
-#define DT_MIPS_TIME_STAMP 0x70000002
-#define DT_MIPS_ICHECKSUM 0x70000003
-#define DT_MIPS_IVERSION 0x70000004
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DT_MIPS_FLAGS 0x70000005
-#define RHF_NONE 0x00000000
-#define RHF_HARDWAY 0x00000001
-#define RHF_NOTPOT 0x00000002
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RHF_SGI_ONLY 0x00000010
-#define DT_MIPS_BASE_ADDRESS 0x70000006
-#define DT_MIPS_CONFLICT 0x70000008
-#define DT_MIPS_LIBLIST 0x70000009
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DT_MIPS_LOCAL_GOTNO 0x7000000a
-#define DT_MIPS_CONFLICTNO 0x7000000b
-#define DT_MIPS_LIBLISTNO 0x70000010
-#define DT_MIPS_SYMTABNO 0x70000011
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DT_MIPS_UNREFEXTNO 0x70000012
-#define DT_MIPS_GOTSYM 0x70000013
-#define DT_MIPS_HIPAGENO 0x70000014
-#define DT_MIPS_RLD_MAP 0x70000016
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R_MIPS_NONE 0
-#define R_MIPS_16 1
-#define R_MIPS_32 2
-#define R_MIPS_REL32 3
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R_MIPS_26 4
-#define R_MIPS_HI16 5
-#define R_MIPS_LO16 6
-#define R_MIPS_GPREL16 7
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R_MIPS_LITERAL 8
-#define R_MIPS_GOT16 9
-#define R_MIPS_PC16 10
-#define R_MIPS_CALL16 11
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R_MIPS_GPREL32 12
-#define R_MIPS_UNUSED1 13
-#define R_MIPS_UNUSED2 14
-#define R_MIPS_UNUSED3 15
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R_MIPS_SHIFT5 16
-#define R_MIPS_SHIFT6 17
-#define R_MIPS_64 18
-#define R_MIPS_GOT_DISP 19
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R_MIPS_GOT_PAGE 20
-#define R_MIPS_GOT_OFST 21
-#define R_MIPS_GOTHI16 22
-#define R_MIPS_GOTLO16 23
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R_MIPS_SUB 24
-#define R_MIPS_INSERT_A 25
-#define R_MIPS_INSERT_B 26
-#define R_MIPS_DELETE 27
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R_MIPS_HIGHER 28
-#define R_MIPS_HIGHEST 29
-#define R_MIPS_CALLHI16 30
-#define R_MIPS_CALLLO16 31
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R_MIPS_LOVENDOR 100
-#define R_MIPS_HIVENDOR 127
-#define SHN_MIPS_ACCOMON 0xff00  
-#define SHN_MIPS_TEXT 0xff01  
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHN_MIPS_DATA 0xff02  
-#define SHN_MIPS_SCOMMON 0xff03  
-#define SHN_MIPS_SUNDEFINED 0xff04  
-#define SHT_MIPS_LIST 0x70000000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHT_MIPS_CONFLICT 0x70000002
-#define SHT_MIPS_GPTAB 0x70000003
-#define SHT_MIPS_UCODE 0x70000004
-#define SHT_MIPS_DEBUG 0x70000005
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHT_MIPS_REGINFO 0x70000006
-#define SHT_MIPS_PACKAGE 0x70000007
-#define SHT_MIPS_PACKSYM 0x70000008
-#define SHT_MIPS_RELD 0x70000009
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHT_MIPS_IFACE 0x7000000b
-#define SHT_MIPS_CONTENT 0x7000000c
-#define SHT_MIPS_OPTIONS 0x7000000d
-#define SHT_MIPS_SHDR 0x70000010
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHT_MIPS_FDESC 0x70000011
-#define SHT_MIPS_EXTSYM 0x70000012
-#define SHT_MIPS_DENSE 0x70000013
-#define SHT_MIPS_PDESC 0x70000014
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHT_MIPS_LOCSYM 0x70000015
-#define SHT_MIPS_AUXSYM 0x70000016
-#define SHT_MIPS_OPTSYM 0x70000017
-#define SHT_MIPS_LOCSTR 0x70000018
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHT_MIPS_LINE 0x70000019
-#define SHT_MIPS_RFDESC 0x7000001a
-#define SHT_MIPS_DELTASYM 0x7000001b
-#define SHT_MIPS_DELTAINST 0x7000001c
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHT_MIPS_DELTACLASS 0x7000001d
-#define SHT_MIPS_DWARF 0x7000001e
-#define SHT_MIPS_DELTADECL 0x7000001f
-#define SHT_MIPS_SYMBOL_LIB 0x70000020
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHT_MIPS_EVENTS 0x70000021
-#define SHT_MIPS_TRANSLATE 0x70000022
-#define SHT_MIPS_PIXIE 0x70000023
-#define SHT_MIPS_XLATE 0x70000024
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHT_MIPS_XLATE_DEBUG 0x70000025
-#define SHT_MIPS_WHIRL 0x70000026
-#define SHT_MIPS_EH_REGION 0x70000027
-#define SHT_MIPS_XLATE_OLD 0x70000028
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHT_MIPS_PDR_EXCEPTION 0x70000029
-#define SHF_MIPS_GPREL 0x10000000
-#define SHF_MIPS_MERGE 0x20000000
-#define SHF_MIPS_ADDR 0x40000000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHF_MIPS_STRING 0x80000000
-#define SHF_MIPS_NOSTRIP 0x08000000
-#define SHF_MIPS_LOCAL 0x04000000
-#define SHF_MIPS_NAMES 0x02000000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHF_MIPS_NODUPES 0x01000000
-#ifndef ELF_ARCH
-#define ELF_NGREG 45
-#define ELF_NFPREG 33
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-typedef unsigned long elf_greg_t;
-typedef elf_greg_t elf_gregset_t[ELF_NGREG];
-typedef double elf_fpreg_t;
-typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define elf_check_arch(hdr)  ({   int __res = 1;   struct elfhdr *__h = (hdr);     if (__h->e_machine != EM_MIPS)   __res = 0;   if (__h->e_ident[EI_CLASS] != ELFCLASS32)   __res = 0;   if ((__h->e_flags & EF_MIPS_ABI2) != 0)   __res = 0;   if (((__h->e_flags & EF_MIPS_ABI) != 0) &&   ((__h->e_flags & EF_MIPS_ABI) != EF_MIPS_ABI_O32))   __res = 0;     __res;  })
-#define ELF_CLASS ELFCLASS32
-#ifdef __MIPSEB__
-#define ELF_DATA ELFDATA2MSB
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#elif __MIPSEL__
-#define ELF_DATA ELFDATA2LSB
-#endif
-#define ELF_ARCH EM_MIPS
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
-struct mips_abi;
-#define SET_PERSONALITY(ex, ibcs2)  do {   if (ibcs2)   set_personality(PER_SVR4);   set_personality(PER_LINUX);     current->thread.abi = &mips_abi;  } while (0)
-struct task_struct;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ELF_CORE_COPY_REGS(elf_regs, regs)   elf_dump_regs((elf_greg_t *)&(elf_regs), regs);
-#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)
-#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs)   dump_task_fpu(tsk, elf_fpregs)
-#define USE_ELF_CORE_DUMP
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ELF_EXEC_PAGESIZE PAGE_SIZE
-#define ELF_HWCAP (0)
-#define ELF_PLATFORM (NULL)
-#define ELF_PLAT_INIT(_r, load_addr) do {   _r->regs[1] = _r->regs[2] = _r->regs[3] = _r->regs[4] = 0;   _r->regs[5] = _r->regs[6] = _r->regs[7] = _r->regs[8] = 0;   _r->regs[9] = _r->regs[10] = _r->regs[11] = _r->regs[12] = 0;   _r->regs[13] = _r->regs[14] = _r->regs[15] = _r->regs[16] = 0;   _r->regs[17] = _r->regs[18] = _r->regs[19] = _r->regs[20] = 0;   _r->regs[21] = _r->regs[22] = _r->regs[23] = _r->regs[24] = 0;   _r->regs[25] = _r->regs[26] = _r->regs[27] = _r->regs[28] = 0;   _r->regs[30] = _r->regs[31] = 0;  } while (0)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#ifndef ELF_ET_DYN_BASE
-#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
-#endif
-#endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-mips/asm/errno.h b/libc/kernel/arch-mips/asm/errno.h
index f8ba438..437293d 100644
--- a/libc/kernel/arch-mips/asm/errno.h
+++ b/libc/kernel/arch-mips/asm/errno.h
@@ -19,128 +19,128 @@
 #ifndef _ASM_ERRNO_H
 #define _ASM_ERRNO_H
 #include <asm-generic/errno-base.h>
-#define ENOMSG 35  
+#define ENOMSG 35
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EIDRM 36  
-#define ECHRNG 37  
-#define EL2NSYNC 38  
-#define EL3HLT 39  
+#define EIDRM 36
+#define ECHRNG 37
+#define EL2NSYNC 38
+#define EL3HLT 39
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EL3RST 40  
-#define ELNRNG 41  
-#define EUNATCH 42  
-#define ENOCSI 43  
+#define EL3RST 40
+#define ELNRNG 41
+#define EUNATCH 42
+#define ENOCSI 43
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EL2HLT 44  
-#define EDEADLK 45  
-#define ENOLCK 46  
-#define EBADE 50  
+#define EL2HLT 44
+#define EDEADLK 45
+#define ENOLCK 46
+#define EBADE 50
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EBADR 51  
-#define EXFULL 52  
-#define ENOANO 53  
-#define EBADRQC 54  
+#define EBADR 51
+#define EXFULL 52
+#define ENOANO 53
+#define EBADRQC 54
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EBADSLT 55  
-#define EDEADLOCK 56  
-#define EBFONT 59  
-#define ENOSTR 60  
+#define EBADSLT 55
+#define EDEADLOCK 56
+#define EBFONT 59
+#define ENOSTR 60
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ENODATA 61  
-#define ETIME 62  
-#define ENOSR 63  
-#define ENONET 64  
+#define ENODATA 61
+#define ETIME 62
+#define ENOSR 63
+#define ENONET 64
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ENOPKG 65  
-#define EREMOTE 66  
-#define ENOLINK 67  
-#define EADV 68  
+#define ENOPKG 65
+#define EREMOTE 66
+#define ENOLINK 67
+#define EADV 68
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ESRMNT 69  
-#define ECOMM 70  
-#define EPROTO 71  
-#define EDOTDOT 73  
+#define ESRMNT 69
+#define ECOMM 70
+#define EPROTO 71
+#define EDOTDOT 73
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EMULTIHOP 74  
-#define EBADMSG 77  
-#define ENAMETOOLONG 78  
-#define EOVERFLOW 79  
+#define EMULTIHOP 74
+#define EBADMSG 77
+#define ENAMETOOLONG 78
+#define EOVERFLOW 79
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ENOTUNIQ 80  
-#define EBADFD 81  
-#define EREMCHG 82  
-#define ELIBACC 83  
+#define ENOTUNIQ 80
+#define EBADFD 81
+#define EREMCHG 82
+#define ELIBACC 83
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ELIBBAD 84  
-#define ELIBSCN 85  
-#define ELIBMAX 86  
-#define ELIBEXEC 87  
+#define ELIBBAD 84
+#define ELIBSCN 85
+#define ELIBMAX 86
+#define ELIBEXEC 87
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EILSEQ 88  
-#define ENOSYS 89  
-#define ELOOP 90  
-#define ERESTART 91  
+#define EILSEQ 88
+#define ENOSYS 89
+#define ELOOP 90
+#define ERESTART 91
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ESTRPIPE 92  
-#define ENOTEMPTY 93  
-#define EUSERS 94  
-#define ENOTSOCK 95  
+#define ESTRPIPE 92
+#define ENOTEMPTY 93
+#define EUSERS 94
+#define ENOTSOCK 95
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EDESTADDRREQ 96  
-#define EMSGSIZE 97  
-#define EPROTOTYPE 98  
-#define ENOPROTOOPT 99  
+#define EDESTADDRREQ 96
+#define EMSGSIZE 97
+#define EPROTOTYPE 98
+#define ENOPROTOOPT 99
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EPROTONOSUPPORT 120  
-#define ESOCKTNOSUPPORT 121  
-#define EOPNOTSUPP 122  
-#define EPFNOSUPPORT 123  
+#define EPROTONOSUPPORT 120
+#define ESOCKTNOSUPPORT 121
+#define EOPNOTSUPP 122
+#define EPFNOSUPPORT 123
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EAFNOSUPPORT 124  
-#define EADDRINUSE 125  
-#define EADDRNOTAVAIL 126  
-#define ENETDOWN 127  
+#define EAFNOSUPPORT 124
+#define EADDRINUSE 125
+#define EADDRNOTAVAIL 126
+#define ENETDOWN 127
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ENETUNREACH 128  
-#define ENETRESET 129  
-#define ECONNABORTED 130  
-#define ECONNRESET 131  
+#define ENETUNREACH 128
+#define ENETRESET 129
+#define ECONNABORTED 130
+#define ECONNRESET 131
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ENOBUFS 132  
-#define EISCONN 133  
-#define ENOTCONN 134  
-#define EUCLEAN 135  
+#define ENOBUFS 132
+#define EISCONN 133
+#define ENOTCONN 134
+#define EUCLEAN 135
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ENOTNAM 137  
-#define ENAVAIL 138  
-#define EISNAM 139  
-#define EREMOTEIO 140  
+#define ENOTNAM 137
+#define ENAVAIL 138
+#define EISNAM 139
+#define EREMOTEIO 140
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EINIT 141  
-#define EREMDEV 142  
-#define ESHUTDOWN 143  
-#define ETOOMANYREFS 144  
+#define EINIT 141
+#define EREMDEV 142
+#define ESHUTDOWN 143
+#define ETOOMANYREFS 144
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETIMEDOUT 145  
-#define ECONNREFUSED 146  
-#define EHOSTDOWN 147  
-#define EHOSTUNREACH 148  
+#define ETIMEDOUT 145
+#define ECONNREFUSED 146
+#define EHOSTDOWN 147
+#define EHOSTUNREACH 148
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EWOULDBLOCK EAGAIN  
-#define EALREADY 149  
-#define EINPROGRESS 150  
-#define ESTALE 151  
+#define EWOULDBLOCK EAGAIN
+#define EALREADY 149
+#define EINPROGRESS 150
+#define ESTALE 151
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ECANCELED 158  
-#define ENOMEDIUM 159  
-#define EMEDIUMTYPE 160  
-#define ENOKEY 161  
+#define ECANCELED 158
+#define ENOMEDIUM 159
+#define EMEDIUMTYPE 160
+#define ENOKEY 161
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EKEYEXPIRED 162  
-#define EKEYREVOKED 163  
-#define EKEYREJECTED 164  
-#define EOWNERDEAD 165  
+#define EKEYEXPIRED 162
+#define EKEYREVOKED 163
+#define EKEYREJECTED 164
+#define EOWNERDEAD 165
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ENOTRECOVERABLE 166  
-#define EDQUOT 1133  
+#define ENOTRECOVERABLE 166
+#define EDQUOT 1133
 #endif
diff --git a/libc/kernel/arch-mips/asm/fcntl.h b/libc/kernel/arch-mips/asm/fcntl.h
index 73de4ad..57d96be 100644
--- a/libc/kernel/arch-mips/asm/fcntl.h
+++ b/libc/kernel/arch-mips/asm/fcntl.h
@@ -22,23 +22,23 @@
 #define O_SYNC 0x0010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define O_NONBLOCK 0x0080
-#define O_CREAT 0x0100  
-#define O_TRUNC 0x0200  
-#define O_EXCL 0x0400  
+#define O_CREAT 0x0100
+#define O_TRUNC 0x0200
+#define O_EXCL 0x0400
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define O_NOCTTY 0x0800  
-#define FASYNC 0x1000  
-#define O_LARGEFILE 0x2000  
-#define O_DIRECT 0x8000  
+#define O_NOCTTY 0x0800
+#define FASYNC 0x1000
+#define O_LARGEFILE 0x2000
+#define O_DIRECT 0x8000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define F_GETLK 14
 #define F_SETLK 6
 #define F_SETLKW 7
-#define F_SETOWN 24  
+#define F_SETOWN 24
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define F_GETOWN 23  
+#define F_GETOWN 23
 #ifndef __mips64
-#define F_GETLK64 33  
+#define F_GETLK64 33
 #define F_SETLK64 34
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define F_SETLKW64 35
@@ -47,8 +47,8 @@
  short l_type;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  short l_whence;
- off_t l_start;
- off_t l_len;
+ __kernel_off_t l_start;
+ __kernel_off_t l_len;
  long l_sysid;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __kernel_pid_t l_pid;
diff --git a/libc/kernel/arch-mips/asm/floppy.h b/libc/kernel/arch-mips/asm/floppy.h
index 769b3f9..39b61da 100644
--- a/libc/kernel/arch-mips/asm/floppy.h
+++ b/libc/kernel/arch-mips/asm/floppy.h
@@ -24,7 +24,7 @@
 #define FLOPPY0_TYPE fd_drive_type(0)
 #define FLOPPY1_TYPE fd_drive_type(1)
 #define FDC1 fd_getfdaddr1();
-#define N_FDC 1  
+#define N_FDC 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define N_DRIVE 8
 #define CROSS_64KB(a, s) ((unsigned long)(a)/K_64 != ((unsigned long)(a) + (s) - 1) / K_64)
diff --git a/libc/kernel/arch-mips/asm/fpregdef.h b/libc/kernel/arch-mips/asm/fpregdef.h
index 046f750..b6d3351 100644
--- a/libc/kernel/arch-mips/asm/fpregdef.h
+++ b/libc/kernel/arch-mips/asm/fpregdef.h
@@ -21,17 +21,17 @@
 #include <asm/sgidefs.h>
 #if _MIPS_SIM == _MIPS_SIM_ABI32
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define fv0 $f0  
+#define fv0 $f0
 #define fv0f $f1
 #define fv1 $f2
 #define fv1f $f3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define fa0 $f12  
+#define fa0 $f12
 #define fa0f $f13
 #define fa1 $f14
 #define fa1f $f15
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ft0 $f4  
+#define ft0 $f4
 #define ft0f $f5
 #define ft1 $f6
 #define ft1f $f7
@@ -46,7 +46,7 @@
 #define ft5 $f18
 #define ft5f $f19
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define fs0 $f20  
+#define fs0 $f20
 #define fs0f $f21
 #define fs1 $f22
 #define fs1f $f23
@@ -61,13 +61,13 @@
 #define fs5 $f30
 #define fs5f $f31
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define fcr31 $31  
+#define fcr31 $31
 #endif
 #if _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32
-#define fv0 $f0  
+#define fv0 $f0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define fv1 $f2
-#define fa0 $f12  
+#define fa0 $f12
 #define fa1 $f13
 #define fa2 $f14
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -77,7 +77,7 @@
 #define fa6 $f18
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define fa7 $f19
-#define ft0 $f4  
+#define ft0 $f4
 #define ft1 $f5
 #define ft2 $f6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -94,7 +94,7 @@
 #define ft11 $f23
 #define ft12 $f1
 #define ft13 $f3
-#define fs0 $f24  
+#define fs0 $f24
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define fs1 $f25
 #define fs2 $f26
diff --git a/libc/kernel/arch-mips/asm/gt64120.h b/libc/kernel/arch-mips/asm/gt64120.h
index d4cda0d..d3de168 100644
--- a/libc/kernel/arch-mips/asm/gt64120.h
+++ b/libc/kernel/arch-mips/asm/gt64120.h
@@ -69,10 +69,10 @@
 #define GT_PCI1M1REMAP_OFS 0x118
 #define GT_CPUERR_ADDRLO_OFS 0x070
 #define GT_CPUERR_ADDRHI_OFS 0x078
-#define GT_CPUERR_DATALO_OFS 0x128  
+#define GT_CPUERR_DATALO_OFS 0x128
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define GT_CPUERR_DATAHI_OFS 0x130  
-#define GT_CPUERR_PARITY_OFS 0x138  
+#define GT_CPUERR_DATAHI_OFS 0x130
+#define GT_CPUERR_PARITY_OFS 0x138
 #define GT_PCI0SYNC_OFS 0x0c0
 #define GT_PCI1SYNC_OFS 0x0c8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -116,12 +116,12 @@
 #define GT_DEV_B3_OFS 0x468
 #define GT_DEV_BOOT_OFS 0x46c
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define GT_ECC_ERRDATALO 0x480  
-#define GT_ECC_ERRDATAHI 0x484  
-#define GT_ECC_MEM 0x488  
-#define GT_ECC_CALC 0x48c  
+#define GT_ECC_ERRDATALO 0x480
+#define GT_ECC_ERRDATAHI 0x484
+#define GT_ECC_MEM 0x488
+#define GT_ECC_CALC 0x48c
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define GT_ECC_ERRADDR 0x490  
+#define GT_ECC_ERRADDR 0x490
 #define GT_DMA0_CNT_OFS 0x800
 #define GT_DMA1_CNT_OFS 0x804
 #define GT_DMA2_CNT_OFS 0x808
@@ -518,8 +518,8 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define GT_DEF_PCI0_MEM0_SIZE 0x02000000UL
 #define GT_DEF_BASE 0x14000000UL
-#define GT_MAX_BANKSIZE (256 * 1024 * 1024)  
-#define GT_LATTIM_MIN 6  
+#define GT_MAX_BANKSIZE (256 * 1024 * 1024)
+#define GT_LATTIM_MIN 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <mach-gt64120.h>
 #define __GT_READ(ofs)   (*(volatile u32 *)(GT64120_BASE+(ofs)))
diff --git a/libc/kernel/arch-mips/asm/hardirq.h b/libc/kernel/arch-mips/asm/hardirq.h
index f3a05b4..e7b70a7 100644
--- a/libc/kernel/arch-mips/asm/hardirq.h
+++ b/libc/kernel/arch-mips/asm/hardirq.h
@@ -24,6 +24,6 @@
 typedef struct {
  unsigned int __softirq_pending;
 } ____cacheline_aligned irq_cpustat_t;
-#include <linux/irq_cpustat.h>  
+#include <linux/irq_cpustat.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/arch-mips/asm/io.h b/libc/kernel/arch-mips/asm/io.h
index b30e51a..ab56e50 100644
--- a/libc/kernel/arch-mips/asm/io.h
+++ b/libc/kernel/arch-mips/asm/io.h
@@ -77,7 +77,7 @@
 #define __BUILD_IOPORT_SINGLE(pfx, bwlq, type, p, slow)    static inline void pfx##out##bwlq##p(type val, unsigned long port)  {   volatile type *__addr;   type __val;     __addr = (void *)__swizzle_addr_##bwlq(mips_io_port_base + port);     __val = pfx##ioswab##bwlq(__addr, val);         BUILD_BUG_ON(sizeof(type) > sizeof(unsigned long));     *__addr = __val;   slow;  }    static inline type pfx##in##bwlq##p(unsigned long port)  {   volatile type *__addr;   type __val;     __addr = (void *)__swizzle_addr_##bwlq(mips_io_port_base + port);     BUILD_BUG_ON(sizeof(type) > sizeof(unsigned long));     __val = *__addr;   slow;     return pfx##ioswab##bwlq(__addr, __val);  }
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __BUILD_MEMORY_PFX(bus, bwlq, type)    __BUILD_MEMORY_SINGLE(bus, bwlq, type, 1)
-#define BUILDIO_MEM(bwlq, type)    __BUILD_MEMORY_PFX(__raw_, bwlq, type)  __BUILD_MEMORY_PFX(, bwlq, type)  __BUILD_MEMORY_PFX(__mem_, bwlq, type)  
+#define BUILDIO_MEM(bwlq, type)    __BUILD_MEMORY_PFX(__raw_, bwlq, type)  __BUILD_MEMORY_PFX(, bwlq, type)  __BUILD_MEMORY_PFX(__mem_, bwlq, type)
 #define __BUILD_IOPORT_PFX(bus, bwlq, type)   __BUILD_IOPORT_SINGLE(bus, bwlq, type, ,)   __BUILD_IOPORT_SINGLE(bus, bwlq, type, _p, SLOW_DOWN_IO)
 #define BUILDIO_IOPORT(bwlq, type)   __BUILD_IOPORT_PFX(, bwlq, type)   __BUILD_IOPORT_PFX(__mem_, bwlq, type)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-mips/asm/ioctls.h b/libc/kernel/arch-mips/asm/ioctls.h
index 20a02e8..38d42f9 100644
--- a/libc/kernel/arch-mips/asm/ioctls.h
+++ b/libc/kernel/arch-mips/asm/ioctls.h
@@ -21,7 +21,7 @@
 #include <asm/ioctl.h>
 #define TCGETA 0x5401
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TCSETA 0x5402  
+#define TCSETA 0x5402
 #define TCSETAW 0x5403
 #define TCSETAF 0x5404
 #define TCSBRK 0x5405
@@ -33,30 +33,30 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCSETSW 0x540f
 #define TCSETSF 0x5410
-#define TIOCEXCL 0x740d  
-#define TIOCNXCL 0x740e  
+#define TIOCEXCL 0x740d
+#define TIOCNXCL 0x740e
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCOUTQ 0x7472  
-#define TIOCSTI 0x5472  
-#define TIOCMGET 0x741d  
-#define TIOCMBIS 0x741b  
+#define TIOCOUTQ 0x7472
+#define TIOCSTI 0x5472
+#define TIOCMGET 0x741d
+#define TIOCMBIS 0x741b
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCMBIC 0x741c  
-#define TIOCMSET 0x741a  
-#define TIOCPKT 0x5470  
-#define TIOCPKT_DATA 0x00  
+#define TIOCMBIC 0x741c
+#define TIOCMSET 0x741a
+#define TIOCPKT 0x5470
+#define TIOCPKT_DATA 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCPKT_FLUSHREAD 0x01  
-#define TIOCPKT_FLUSHWRITE 0x02  
-#define TIOCPKT_STOP 0x04  
-#define TIOCPKT_START 0x08  
+#define TIOCPKT_FLUSHREAD 0x01
+#define TIOCPKT_FLUSHWRITE 0x02
+#define TIOCPKT_STOP 0x04
+#define TIOCPKT_START 0x08
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCPKT_NOSTOP 0x10  
-#define TIOCPKT_DOSTOP 0x20  
-#define TIOCSWINSZ _IOW('t', 103, struct winsize)  
-#define TIOCGWINSZ _IOR('t', 104, struct winsize)  
+#define TIOCPKT_NOSTOP 0x10
+#define TIOCPKT_DOSTOP 0x20
+#define TIOCSWINSZ _IOW('t', 103, struct winsize)
+#define TIOCGWINSZ _IOR('t', 104, struct winsize)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCNOTTY 0x5471  
+#define TIOCNOTTY 0x5471
 #define TIOCSETD 0x7401
 #define TIOCGETD 0x7400
 #define FIOCLEX 0x6601
@@ -66,30 +66,30 @@
 #define FIONBIO 0x667e
 #define FIOQSIZE 0x667f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCGLTC 0x7474  
-#define TIOCSLTC 0x7475  
-#define TIOCSPGRP _IOW('t', 118, int)  
-#define TIOCGPGRP _IOR('t', 119, int)  
+#define TIOCGLTC 0x7474
+#define TIOCSLTC 0x7475
+#define TIOCSPGRP _IOW('t', 118, int)
+#define TIOCGPGRP _IOR('t', 119, int)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCCONS _IOW('t', 120, int)  
+#define TIOCCONS _IOW('t', 120, int)
 #define FIONREAD 0x467f
 #define TIOCINQ FIONREAD
 #define TIOCGETP 0x7408
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TIOCSETP 0x7409
-#define TIOCSETN 0x740a  
-#define TIOCSBRK 0x5427  
-#define TIOCCBRK 0x5428  
+#define TIOCSETN 0x740a
+#define TIOCSBRK 0x5427
+#define TIOCCBRK 0x5428
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCGSID 0x7416  
+#define TIOCGSID 0x7416
 #define TCGETS2 _IOR('T', 0x2A, struct termios2)
 #define TCSETS2 _IOW('T', 0x2B, struct termios2)
 #define TCSETSW2 _IOW('T', 0x2C, struct termios2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCSETSF2 _IOW('T', 0x2D, struct termios2)
-#define TIOCGPTN _IOR('T', 0x30, unsigned int)  
-#define TIOCSPTLCK _IOW('T', 0x31, int)  
-#define TIOCSCTTY 0x5480  
+#define TIOCGPTN _IOR('T', 0x30, unsigned int)
+#define TIOCSPTLCK _IOW('T', 0x31, int)
+#define TIOCSCTTY 0x5480
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TIOCGSOFTCAR 0x5481
 #define TIOCSSOFTCAR 0x5482
@@ -97,22 +97,22 @@
 #define TIOCGSERIAL 0x5484
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TIOCSSERIAL 0x5485
-#define TCSBRKP 0x5486  
+#define TCSBRKP 0x5486
 #define TIOCSERCONFIG 0x5488
 #define TIOCSERGWILD 0x5489
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TIOCSERSWILD 0x548a
 #define TIOCGLCKTRMIOS 0x548b
 #define TIOCSLCKTRMIOS 0x548c
-#define TIOCSERGSTRUCT 0x548d  
+#define TIOCSERGSTRUCT 0x548d
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCSERGETLSR 0x548e  
-#define TIOCSERGETMULTI 0x548f  
-#define TIOCSERSETMULTI 0x5490  
-#define TIOCMIWAIT 0x5491  
+#define TIOCSERGETLSR 0x548e
+#define TIOCSERGETMULTI 0x548f
+#define TIOCSERSETMULTI 0x5490
+#define TIOCMIWAIT 0x5491
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCGICOUNT 0x5492  
-#define TIOCGHAYESESP 0x5493  
-#define TIOCSHAYESESP 0x5494  
+#define TIOCGICOUNT 0x5492
+#define TIOCGHAYESESP 0x5493
+#define TIOCSHAYESESP 0x5494
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-mips/asm/ip32/crime.h b/libc/kernel/arch-mips/asm/ip32/crime.h
index a979708..bcf036a 100644
--- a/libc/kernel/arch-mips/asm/ip32/crime.h
+++ b/libc/kernel/arch-mips/asm/ip32/crime.h
@@ -18,7 +18,7 @@
  ****************************************************************************/
 #ifndef __ASM_CRIME_H__
 #define __ASM_CRIME_H__
-#define CRIME_BASE 0x14000000  
+#define CRIME_BASE 0x14000000
 struct sgi_crime {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  volatile unsigned long id;
@@ -108,13 +108,13 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CRIME_DOG_VALUE 0x00007fff
  volatile unsigned long timer;
-#define CRIME_MASTER_FREQ 66666500  
-#define CRIME_NS_PER_TICK 15  
+#define CRIME_MASTER_FREQ 66666500
+#define CRIME_NS_PER_TICK 15
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  volatile unsigned long cpu_error_addr;
 #define CRIME_CPU_ERROR_ADDR_MASK 0x3ffffffff
  volatile unsigned long cpu_error_stat;
-#define CRIME_CPU_ERROR_MASK 0x7  
+#define CRIME_CPU_ERROR_MASK 0x7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CRIME_CPU_ERROR_CPU_ILL_ADDR 0x4
 #define CRIME_CPU_ERROR_VICE_WRT_PRTY 0x2
@@ -123,16 +123,16 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  volatile unsigned long mc_ctrl;
  volatile unsigned long bank_ctrl[8];
-#define CRIME_MEM_BANK_CONTROL_MASK 0x11f  
+#define CRIME_MEM_BANK_CONTROL_MASK 0x11f
 #define CRIME_MEM_BANK_CONTROL_ADDR 0x01f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CRIME_MEM_BANK_CONTROL_SDRAM_SIZE 0x100
 #define CRIME_MAXBANKS 8
  volatile unsigned long mem_ref_counter;
-#define CRIME_MEM_REF_COUNTER_MASK 0x3ff  
+#define CRIME_MEM_REF_COUNTER_MASK 0x3ff
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  volatile unsigned long mem_error_stat;
-#define CRIME_MEM_ERROR_STAT_MASK 0x0ff7ffff  
+#define CRIME_MEM_ERROR_STAT_MASK 0x0ff7ffff
 #define CRIME_MEM_ERROR_MACE_ID 0x0000007f
 #define CRIME_MEM_ERROR_MACE_ACCESS 0x00000080
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -167,5 +167,5 @@
 #define CRIME_MEM_ERROR_ECC_REPL_MASK 0xffffffff
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define CRIME_HI_MEM_BASE 0x40000000  
+#define CRIME_HI_MEM_BASE 0x40000000
 #endif
diff --git a/libc/kernel/arch-mips/asm/ip32/mace.h b/libc/kernel/arch-mips/asm/ip32/mace.h
index c2c149d..759c863 100644
--- a/libc/kernel/arch-mips/asm/ip32/mace.h
+++ b/libc/kernel/arch-mips/asm/ip32/mace.h
@@ -18,7 +18,7 @@
  ****************************************************************************/
 #ifndef __ASM_MACE_H__
 #define __ASM_MACE_H__
-#define MACE_BASE 0x1f000000  
+#define MACE_BASE 0x1f000000
 struct mace_pci {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  volatile unsigned int error_addr;
@@ -182,13 +182,13 @@
 #define MACEISA_RINGBUFFERS_SIZE (8 * 4096)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  volatile unsigned long misc;
-#define MACEISA_FLASH_WE BIT(0)  
-#define MACEISA_PWD_CLEAR BIT(1)  
+#define MACEISA_FLASH_WE BIT(0)
+#define MACEISA_PWD_CLEAR BIT(1)
 #define MACEISA_NIC_DEASSERT BIT(2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MACEISA_NIC_DATA BIT(3)
-#define MACEISA_LED_RED BIT(4)  
-#define MACEISA_LED_GREEN BIT(5)  
+#define MACEISA_LED_RED BIT(4)
+#define MACEISA_LED_GREEN BIT(5)
 #define MACEISA_DP_RAM_ENABLE BIT(6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  volatile unsigned long istat;
diff --git a/libc/kernel/arch-mips/asm/irq.h b/libc/kernel/arch-mips/asm/irq.h
index 042c951..a896605 100644
--- a/libc/kernel/arch-mips/asm/irq.h
+++ b/libc/kernel/arch-mips/asm/irq.h
@@ -22,7 +22,7 @@
 #include <asm/mipsmtregs.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <irq.h>
-#define irq_canonicalize(irq) (irq)  
+#define irq_canonicalize(irq) (irq)
 #define IRQ_AFFINITY_HOOK(irq) do { } while (0)
 #define __DO_IRQ_SMTC_HOOK(irq)  do {   IRQ_AFFINITY_HOOK(irq);  } while (0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-mips/asm/jazz.h b/libc/kernel/arch-mips/asm/jazz.h
index 5e6ea8f..4fd61d5 100644
--- a/libc/kernel/arch-mips/asm/jazz.h
+++ b/libc/kernel/arch-mips/asm/jazz.h
@@ -128,35 +128,35 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define JAZZ_SERIAL2_IRQ (JAZZ_IRQ_START + 9)
 #define JAZZ_TIMER_IRQ (MIPS_CPU_IRQ_BASE+6)
-#define JAZZ_SCSI_DMA 0  
-#define JAZZ_FLOPPY_DMA 1  
+#define JAZZ_SCSI_DMA 0
+#define JAZZ_FLOPPY_DMA 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define JAZZ_AUDIOL_DMA 2  
-#define JAZZ_AUDIOR_DMA 3  
-#define JAZZ_R4030_CONFIG 0xE0000000  
-#define JAZZ_R4030_REVISION 0xE0000008  
+#define JAZZ_AUDIOL_DMA 2
+#define JAZZ_AUDIOR_DMA 3
+#define JAZZ_R4030_CONFIG 0xE0000000
+#define JAZZ_R4030_REVISION 0xE0000008
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define JAZZ_R4030_INV_ADDR 0xE0000010  
-#define JAZZ_R4030_TRSTBL_BASE 0xE0000018  
-#define JAZZ_R4030_TRSTBL_LIM 0xE0000020  
-#define JAZZ_R4030_TRSTBL_INV 0xE0000028  
+#define JAZZ_R4030_INV_ADDR 0xE0000010
+#define JAZZ_R4030_TRSTBL_BASE 0xE0000018
+#define JAZZ_R4030_TRSTBL_LIM 0xE0000020
+#define JAZZ_R4030_TRSTBL_INV 0xE0000028
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define JAZZ_R4030_CACHE_MTNC 0xE0000030  
-#define JAZZ_R4030_R_FAIL_ADDR 0xE0000038  
-#define JAZZ_R4030_M_FAIL_ADDR 0xE0000040  
-#define JAZZ_R4030_CACHE_PTAG 0xE0000048  
+#define JAZZ_R4030_CACHE_MTNC 0xE0000030
+#define JAZZ_R4030_R_FAIL_ADDR 0xE0000038
+#define JAZZ_R4030_M_FAIL_ADDR 0xE0000040
+#define JAZZ_R4030_CACHE_PTAG 0xE0000048
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define JAZZ_R4030_CACHE_LTAG 0xE0000050  
-#define JAZZ_R4030_CACHE_BMASK 0xE0000058  
-#define JAZZ_R4030_CACHE_BWIN 0xE0000060  
-#define JAZZ_R4030_REM_SPEED 0xE0000070  
+#define JAZZ_R4030_CACHE_LTAG 0xE0000050
+#define JAZZ_R4030_CACHE_BMASK 0xE0000058
+#define JAZZ_R4030_CACHE_BWIN 0xE0000060
+#define JAZZ_R4030_REM_SPEED 0xE0000070
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define JAZZ_R4030_IRQ_ENABLE 0xE00000E8  
-#define JAZZ_R4030_INVAL_ADDR 0xE0000010  
-#define JAZZ_R4030_IRQ_SOURCE 0xE0000200  
-#define JAZZ_R4030_I386_ERROR 0xE0000208  
+#define JAZZ_R4030_IRQ_ENABLE 0xE00000E8
+#define JAZZ_R4030_INVAL_ADDR 0xE0000010
+#define JAZZ_R4030_IRQ_SOURCE 0xE0000200
+#define JAZZ_R4030_I386_ERROR 0xE0000208
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define JAZZ_EISA_IRQ_ACK 0xE0000238  
+#define JAZZ_EISA_IRQ_ACK 0xE0000238
 #ifndef __ASSEMBLY__
 #endif
 #define JAZZ_FDC_BASE 0xe0003000
diff --git a/libc/kernel/arch-mips/asm/jazzdma.h b/libc/kernel/arch-mips/asm/jazzdma.h
index 7426807..9744d82 100644
--- a/libc/kernel/arch-mips/asm/jazzdma.h
+++ b/libc/kernel/arch-mips/asm/jazzdma.h
@@ -32,18 +32,18 @@
  unsigned int owner;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } VDMA_PGTBL_ENTRY;
-#define JAZZ_R4030_CHNL_MODE 0xE0000100  
-#define JAZZ_R4030_CHNL_ENABLE 0xE0000108  
-#define JAZZ_R4030_CHNL_COUNT 0xE0000110  
+#define JAZZ_R4030_CHNL_MODE 0xE0000100
+#define JAZZ_R4030_CHNL_ENABLE 0xE0000108
+#define JAZZ_R4030_CHNL_COUNT 0xE0000110
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define JAZZ_R4030_CHNL_ADDR 0xE0000118  
+#define JAZZ_R4030_CHNL_ADDR 0xE0000118
 #define R4030_CHNL_ENABLE (1<<0)
 #define R4030_CHNL_WRITE (1<<1)
 #define R4030_TC_INTR (1<<8)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R4030_MEM_INTR (1<<9)
 #define R4030_ADDR_INTR (1<<10)
-#define R4030_MODE_ATIME_40 (0)  
+#define R4030_MODE_ATIME_40 (0)
 #define R4030_MODE_ATIME_80 (1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R4030_MODE_ATIME_120 (2)
@@ -53,12 +53,12 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R4030_MODE_ATIME_280 (6)
 #define R4030_MODE_ATIME_320 (7)
-#define R4030_MODE_WIDTH_8 (1<<3)  
+#define R4030_MODE_WIDTH_8 (1<<3)
 #define R4030_MODE_WIDTH_16 (2<<3)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R4030_MODE_WIDTH_32 (3<<3)
 #define R4030_MODE_INTR_EN (1<<5)
-#define R4030_MODE_BURST (1<<6)  
-#define R4030_MODE_FAST_ACK (1<<7)  
+#define R4030_MODE_BURST (1<<6)
+#define R4030_MODE_FAST_ACK (1<<7)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/arch-mips/asm/lasat/lasat.h b/libc/kernel/arch-mips/asm/lasat/lasat.h
index aa255f6..d930114 100644
--- a/libc/kernel/arch-mips/asm/lasat/lasat.h
+++ b/libc/kernel/arch-mips/asm/lasat/lasat.h
@@ -131,7 +131,7 @@
 #define LASAT_BMID_SAFEPIPE1000 7
 #define LASAT_BMID_UNKNOWN 0xf
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define LASAT_MAX_BMID_NAMES 9  
+#define LASAT_MAX_BMID_NAMES 9
 #define LASAT_HAS_EDHAC (1 << 0)
 #define LASAT_EDHAC_FAST (1 << 1)
 #define LASAT_HAS_EADI (1 << 2)
diff --git a/libc/kernel/arch-mips/asm/local.h b/libc/kernel/arch-mips/asm/local.h
index 9d2172b..3d88f63 100644
--- a/libc/kernel/arch-mips/asm/local.h
+++ b/libc/kernel/arch-mips/asm/local.h
@@ -57,7 +57,7 @@
 #define __local_sub(i, l) ((l)->a.counter-=(i))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define cpu_local_wrap_v(l)   ({ local_t res__;   preempt_disable();   res__ = (l);   preempt_enable();   res__; })
-#define cpu_local_wrap(l)   ({ preempt_disable();   l;   preempt_enable(); })  
+#define cpu_local_wrap(l)   ({ preempt_disable();   l;   preempt_enable(); })
 #define cpu_local_read(l) cpu_local_wrap_v(local_read(&__get_cpu_var(l)))
 #define cpu_local_set(l, i) cpu_local_wrap(local_set(&__get_cpu_var(l), (i)))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-mips/asm/mach-au1x00/au1000.h b/libc/kernel/arch-mips/asm/mach-au1x00/au1000.h
index c331879..df56aef 100644
--- a/libc/kernel/arch-mips/asm/mach-au1x00/au1000.h
+++ b/libc/kernel/arch-mips/asm/mach-au1x00/au1000.h
@@ -132,7 +132,7 @@
 #define AU1000_INTC1_INT_LAST (AU1000_INTC1_INT_BASE + 31)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AU1000_MAX_INTR AU1000_INTC1_INT_LAST
-#define INTX 0xFF  
+#define INTX 0xFF
 #define SYS_BASE 0xB1900000
 #define SYS_COUNTER_CNTRL (SYS_BASE + 0x14)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -403,86 +403,86 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define UART_BASE UART0_ADDR
 #define UART_DEBUG_BASE UART3_ADDR
-#define UART_RX 0  
-#define UART_TX 4  
+#define UART_RX 0
+#define UART_TX 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_IER 8  
-#define UART_IIR 0xC  
-#define UART_FCR 0x10  
-#define UART_LCR 0x14  
+#define UART_IER 8
+#define UART_IIR 0xC
+#define UART_FCR 0x10
+#define UART_LCR 0x14
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_MCR 0x18  
-#define UART_LSR 0x1C  
-#define UART_MSR 0x20  
-#define UART_CLK 0x28  
+#define UART_MCR 0x18
+#define UART_LSR 0x1C
+#define UART_MSR 0x20
+#define UART_CLK 0x28
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_MOD_CNTRL 0x100  
-#define UART_FCR_ENABLE_FIFO 0x01  
-#define UART_FCR_CLEAR_RCVR 0x02  
-#define UART_FCR_CLEAR_XMIT 0x04  
+#define UART_MOD_CNTRL 0x100
+#define UART_FCR_ENABLE_FIFO 0x01
+#define UART_FCR_CLEAR_RCVR 0x02
+#define UART_FCR_CLEAR_XMIT 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_FCR_DMA_SELECT 0x08  
-#define UART_FCR_TRIGGER_MASK 0xF0  
-#define UART_FCR_R_TRIGGER_1 0x00  
-#define UART_FCR_R_TRIGGER_4 0x40  
+#define UART_FCR_DMA_SELECT 0x08
+#define UART_FCR_TRIGGER_MASK 0xF0
+#define UART_FCR_R_TRIGGER_1 0x00
+#define UART_FCR_R_TRIGGER_4 0x40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_FCR_R_TRIGGER_8 0x80  
-#define UART_FCR_R_TRIGGER_14 0xA0  
-#define UART_FCR_T_TRIGGER_0 0x00  
-#define UART_FCR_T_TRIGGER_4 0x10  
+#define UART_FCR_R_TRIGGER_8 0x80
+#define UART_FCR_R_TRIGGER_14 0xA0
+#define UART_FCR_T_TRIGGER_0 0x00
+#define UART_FCR_T_TRIGGER_4 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_FCR_T_TRIGGER_8 0x20  
-#define UART_FCR_T_TRIGGER_12 0x30  
-#define UART_LCR_SBC 0x40  
-#define UART_LCR_SPAR 0x20  
+#define UART_FCR_T_TRIGGER_8 0x20
+#define UART_FCR_T_TRIGGER_12 0x30
+#define UART_LCR_SBC 0x40
+#define UART_LCR_SPAR 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_LCR_EPAR 0x10  
-#define UART_LCR_PARITY 0x08  
-#define UART_LCR_STOP 0x04  
-#define UART_LCR_WLEN5 0x00  
+#define UART_LCR_EPAR 0x10
+#define UART_LCR_PARITY 0x08
+#define UART_LCR_STOP 0x04
+#define UART_LCR_WLEN5 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_LCR_WLEN6 0x01  
-#define UART_LCR_WLEN7 0x02  
-#define UART_LCR_WLEN8 0x03  
-#define UART_LSR_TEMT 0x40  
+#define UART_LCR_WLEN6 0x01
+#define UART_LCR_WLEN7 0x02
+#define UART_LCR_WLEN8 0x03
+#define UART_LSR_TEMT 0x40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_LSR_THRE 0x20  
-#define UART_LSR_BI 0x10  
-#define UART_LSR_FE 0x08  
-#define UART_LSR_PE 0x04  
+#define UART_LSR_THRE 0x20
+#define UART_LSR_BI 0x10
+#define UART_LSR_FE 0x08
+#define UART_LSR_PE 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_LSR_OE 0x02  
-#define UART_LSR_DR 0x01  
-#define UART_IIR_NO_INT 0x01  
-#define UART_IIR_ID 0x06  
+#define UART_LSR_OE 0x02
+#define UART_LSR_DR 0x01
+#define UART_IIR_NO_INT 0x01
+#define UART_IIR_ID 0x06
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_IIR_MSI 0x00  
-#define UART_IIR_THRI 0x02  
-#define UART_IIR_RDI 0x04  
-#define UART_IIR_RLSI 0x06  
+#define UART_IIR_MSI 0x00
+#define UART_IIR_THRI 0x02
+#define UART_IIR_RDI 0x04
+#define UART_IIR_RLSI 0x06
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_IER_MSI 0x08  
-#define UART_IER_RLSI 0x04  
-#define UART_IER_THRI 0x02  
-#define UART_IER_RDI 0x01  
+#define UART_IER_MSI 0x08
+#define UART_IER_RLSI 0x04
+#define UART_IER_THRI 0x02
+#define UART_IER_RDI 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_MCR_LOOP 0x10  
-#define UART_MCR_OUT2 0x08  
-#define UART_MCR_OUT1 0x04  
-#define UART_MCR_RTS 0x02  
+#define UART_MCR_LOOP 0x10
+#define UART_MCR_OUT2 0x08
+#define UART_MCR_OUT1 0x04
+#define UART_MCR_RTS 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_MCR_DTR 0x01  
-#define UART_MSR_DCD 0x80  
-#define UART_MSR_RI 0x40  
-#define UART_MSR_DSR 0x20  
+#define UART_MCR_DTR 0x01
+#define UART_MSR_DCD 0x80
+#define UART_MSR_RI 0x40
+#define UART_MSR_DSR 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_MSR_CTS 0x10  
-#define UART_MSR_DDCD 0x08  
-#define UART_MSR_TERI 0x04  
-#define UART_MSR_DDSR 0x02  
+#define UART_MSR_CTS 0x10
+#define UART_MSR_DDCD 0x08
+#define UART_MSR_TERI 0x04
+#define UART_MSR_DDSR 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_MSR_DCTS 0x01  
-#define UART_MSR_ANY_DELTA 0x0F  
+#define UART_MSR_DCTS 0x01
+#define UART_MSR_ANY_DELTA 0x0F
 #define SSI0_STATUS 0xB1600000
 #define SSI_STATUS_BF (1 << 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -628,31 +628,31 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IR_INTERFACE_CONFIG (IRDA_BASE + 0x40)
 #define SYS_PINFUNC 0xB190002C
-#define SYS_PF_USB (1 << 15)  
-#define SYS_PF_U3 (1 << 14)  
+#define SYS_PF_USB (1 << 15)
+#define SYS_PF_U3 (1 << 14)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SYS_PF_U2 (1 << 13)  
-#define SYS_PF_U1 (1 << 12)  
-#define SYS_PF_SRC (1 << 11)  
-#define SYS_PF_CK5 (1 << 10)  
+#define SYS_PF_U2 (1 << 13)
+#define SYS_PF_U1 (1 << 12)
+#define SYS_PF_SRC (1 << 11)
+#define SYS_PF_CK5 (1 << 10)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SYS_PF_CK4 (1 << 9)  
-#define SYS_PF_IRF (1 << 8)  
-#define SYS_PF_UR3 (1 << 7)  
-#define SYS_PF_I2D (1 << 6)  
+#define SYS_PF_CK4 (1 << 9)
+#define SYS_PF_IRF (1 << 8)
+#define SYS_PF_UR3 (1 << 7)
+#define SYS_PF_I2D (1 << 6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SYS_PF_I2S (1 << 5)  
-#define SYS_PF_NI2 (1 << 4)  
-#define SYS_PF_U0 (1 << 3)  
-#define SYS_PF_RD (1 << 2)  
+#define SYS_PF_I2S (1 << 5)
+#define SYS_PF_NI2 (1 << 4)
+#define SYS_PF_U0 (1 << 3)
+#define SYS_PF_RD (1 << 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SYS_PF_A97 (1 << 1)  
-#define SYS_PF_S0 (1 << 0)  
-#define SYS_PF_PC (1 << 18)  
-#define SYS_PF_LCD (1 << 17)  
+#define SYS_PF_A97 (1 << 1)
+#define SYS_PF_S0 (1 << 0)
+#define SYS_PF_PC (1 << 18)
+#define SYS_PF_LCD (1 << 17)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SYS_PF_CS (1 << 16)  
-#define SYS_PF_EX0 (1 << 9)  
+#define SYS_PF_CS (1 << 16)
+#define SYS_PF_EX0 (1 << 9)
 #define SYS_PF_PSC2_MASK (7 << 17)
 #define SYS_PF_PSC2_AC97 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-mips/asm/mips-boards/msc01_pci.h b/libc/kernel/arch-mips/asm/mips-boards/msc01_pci.h
index 6235847..4f40273 100644
--- a/libc/kernel/arch-mips/asm/mips-boards/msc01_pci.h
+++ b/libc/kernel/arch-mips/asm/mips-boards/msc01_pci.h
@@ -36,25 +36,25 @@
 #define MSC01_PCI_CFGDATA_OFS 0x0618
 #define MSC01_PCI_IACK_OFS 0x0620
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSC01_PCI_HEAD0_OFS 0x2000  
-#define MSC01_PCI_HEAD1_OFS 0x2008  
-#define MSC01_PCI_HEAD2_OFS 0x2010  
-#define MSC01_PCI_HEAD3_OFS 0x2018  
+#define MSC01_PCI_HEAD0_OFS 0x2000
+#define MSC01_PCI_HEAD1_OFS 0x2008
+#define MSC01_PCI_HEAD2_OFS 0x2010
+#define MSC01_PCI_HEAD3_OFS 0x2018
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSC01_PCI_HEAD4_OFS 0x2020  
-#define MSC01_PCI_HEAD5_OFS 0x2028  
-#define MSC01_PCI_HEAD6_OFS 0x2030  
-#define MSC01_PCI_HEAD7_OFS 0x2038  
+#define MSC01_PCI_HEAD4_OFS 0x2020
+#define MSC01_PCI_HEAD5_OFS 0x2028
+#define MSC01_PCI_HEAD6_OFS 0x2030
+#define MSC01_PCI_HEAD7_OFS 0x2038
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSC01_PCI_HEAD8_OFS 0x2040  
-#define MSC01_PCI_HEAD9_OFS 0x2048  
-#define MSC01_PCI_HEAD10_OFS 0x2050  
-#define MSC01_PCI_HEAD11_OFS 0x2058  
+#define MSC01_PCI_HEAD8_OFS 0x2040
+#define MSC01_PCI_HEAD9_OFS 0x2048
+#define MSC01_PCI_HEAD10_OFS 0x2050
+#define MSC01_PCI_HEAD11_OFS 0x2058
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSC01_PCI_HEAD12_OFS 0x2060  
-#define MSC01_PCI_HEAD13_OFS 0x2068  
-#define MSC01_PCI_HEAD14_OFS 0x2070  
-#define MSC01_PCI_HEAD15_OFS 0x2078  
+#define MSC01_PCI_HEAD12_OFS 0x2060
+#define MSC01_PCI_HEAD13_OFS 0x2068
+#define MSC01_PCI_HEAD14_OFS 0x2070
+#define MSC01_PCI_HEAD15_OFS 0x2078
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSC01_PCI_BAR0_OFS 0x2220
 #define MSC01_PCI_CFG_OFS 0x2380
diff --git a/libc/kernel/arch-mips/asm/mipsregs.h b/libc/kernel/arch-mips/asm/mipsregs.h
index 0976939..9cb27aa 100644
--- a/libc/kernel/arch-mips/asm/mipsregs.h
+++ b/libc/kernel/arch-mips/asm/mipsregs.h
@@ -89,25 +89,25 @@
 #define CP0_S1_DERRADDR0 $26
 #define CP0_S1_DERRADDR1 $27
 #define CP0_S1_INTCONTROL $20
-#define CP0_S2_SRSCTL $12  
+#define CP0_S2_SRSCTL $12
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CP0_S3_SRSMAP $12  
+#define CP0_S3_SRSMAP $12
 #define CP0_TX39_CACHE $7
 #define CP1_REVISION $0
 #define CP1_STATUS $31
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FPU_CSR_FLUSH 0x01000000  
-#define FPU_CSR_COND 0x00800000  
-#define FPU_CSR_COND0 0x00800000  
-#define FPU_CSR_COND1 0x02000000  
+#define FPU_CSR_FLUSH 0x01000000
+#define FPU_CSR_COND 0x00800000
+#define FPU_CSR_COND0 0x00800000
+#define FPU_CSR_COND1 0x02000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FPU_CSR_COND2 0x04000000  
-#define FPU_CSR_COND3 0x08000000  
-#define FPU_CSR_COND4 0x10000000  
-#define FPU_CSR_COND5 0x20000000  
+#define FPU_CSR_COND2 0x04000000
+#define FPU_CSR_COND3 0x08000000
+#define FPU_CSR_COND4 0x10000000
+#define FPU_CSR_COND5 0x20000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FPU_CSR_COND6 0x40000000  
-#define FPU_CSR_COND7 0x80000000  
+#define FPU_CSR_COND6 0x40000000
+#define FPU_CSR_COND7 0x80000000
 #define FPU_CSR_ALL_X 0x0003f000
 #define FPU_CSR_UNI_X 0x00020000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -132,11 +132,11 @@
 #define FPU_CSR_UDF_S 0x00000008
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FPU_CSR_INE_S 0x00000004
-#define FPU_CSR_RN 0x0  
-#define FPU_CSR_RZ 0x1  
-#define FPU_CSR_RU 0x2  
+#define FPU_CSR_RN 0x0
+#define FPU_CSR_RZ 0x1
+#define FPU_CSR_RU 0x2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FPU_CSR_RD 0x3  
+#define FPU_CSR_RD 0x3
 #define PM_4K 0x00000000
 #define PM_16K 0x00006000
 #define PM_64K 0x0001e000
@@ -302,7 +302,7 @@
 #define ST0_CU2 0x40000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ST0_CU3 0x80000000
-#define ST0_XX 0x80000000  
+#define ST0_XX 0x80000000
 #define CAUSEB_EXCCODE 2
 #define CAUSEF_EXCCODE (_ULCAST_(31) << 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -411,7 +411,7 @@
 #define R30XX_CONF_LOCK (_ULCAST_(1) << 31)
 #define TX49_CONF_DC (_ULCAST_(1) << 16)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TX49_CONF_IC (_ULCAST_(1) << 17)  
+#define TX49_CONF_IC (_ULCAST_(1) << 17)
 #define TX49_CONF_HALT (_ULCAST_(1) << 18)
 #define TX49_CONF_CWFON (_ULCAST_(1) << 27)
 #define MIPS_CONF_MT (_ULCAST_(7) << 7)
@@ -512,27 +512,27 @@
 #define write_c0_wired(val) __write_32bit_c0_register($6, 0, val)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define read_c0_info() __read_32bit_c0_register($7, 0)
-#define read_c0_cache() __read_32bit_c0_register($7, 0)  
+#define read_c0_cache() __read_32bit_c0_register($7, 0)
 #define write_c0_cache(val) __write_32bit_c0_register($7, 0, val)
 #define read_c0_badvaddr() __read_ulong_c0_register($8, 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define write_c0_badvaddr(val) __write_ulong_c0_register($8, 0, val)
 #define read_c0_count() __read_32bit_c0_register($9, 0)
 #define write_c0_count(val) __write_32bit_c0_register($9, 0, val)
-#define read_c0_count2() __read_32bit_c0_register($9, 6)  
+#define read_c0_count2() __read_32bit_c0_register($9, 6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define write_c0_count2(val) __write_32bit_c0_register($9, 6, val)
-#define read_c0_count3() __read_32bit_c0_register($9, 7)  
+#define read_c0_count3() __read_32bit_c0_register($9, 7)
 #define write_c0_count3(val) __write_32bit_c0_register($9, 7, val)
 #define read_c0_entryhi() __read_ulong_c0_register($10, 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define write_c0_entryhi(val) __write_ulong_c0_register($10, 0, val)
 #define read_c0_compare() __read_32bit_c0_register($11, 0)
 #define write_c0_compare(val) __write_32bit_c0_register($11, 0, val)
-#define read_c0_compare2() __read_32bit_c0_register($11, 6)  
+#define read_c0_compare2() __read_32bit_c0_register($11, 6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define write_c0_compare2(val) __write_32bit_c0_register($11, 6, val)
-#define read_c0_compare3() __read_32bit_c0_register($11, 7)  
+#define read_c0_compare3() __read_32bit_c0_register($11, 7)
 #define write_c0_compare3(val) __write_32bit_c0_register($11, 7, val)
 #define read_c0_status() __read_32bit_c0_register($12, 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-mips/asm/mman.h b/libc/kernel/arch-mips/asm/mman.h
index cb42c6a..43ee3dc 100644
--- a/libc/kernel/arch-mips/asm/mman.h
+++ b/libc/kernel/arch-mips/asm/mman.h
@@ -18,62 +18,62 @@
  ****************************************************************************/
 #ifndef _ASM_MMAN_H
 #define _ASM_MMAN_H
-#define PROT_NONE 0x00  
-#define PROT_READ 0x01  
+#define PROT_NONE 0x00
+#define PROT_READ 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PROT_WRITE 0x02  
-#define PROT_EXEC 0x04  
-#define PROT_SEM 0x10  
-#define PROT_GROWSDOWN 0x01000000  
+#define PROT_WRITE 0x02
+#define PROT_EXEC 0x04
+#define PROT_SEM 0x10
+#define PROT_GROWSDOWN 0x01000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PROT_GROWSUP 0x02000000  
-#define MAP_SHARED 0x001  
-#define MAP_PRIVATE 0x002  
-#define MAP_TYPE 0x00f  
+#define PROT_GROWSUP 0x02000000
+#define MAP_SHARED 0x001
+#define MAP_PRIVATE 0x002
+#define MAP_TYPE 0x00f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MAP_FIXED 0x010  
-#define MAP_RENAME 0x020  
-#define MAP_AUTOGROW 0x040  
-#define MAP_LOCAL 0x080  
+#define MAP_FIXED 0x010
+#define MAP_RENAME 0x020
+#define MAP_AUTOGROW 0x040
+#define MAP_LOCAL 0x080
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MAP_AUTORSRV 0x100  
-#define MAP_NORESERVE 0x0400  
-#define MAP_ANONYMOUS 0x0800  
-#define MAP_GROWSDOWN 0x1000  
+#define MAP_AUTORSRV 0x100
+#define MAP_NORESERVE 0x0400
+#define MAP_ANONYMOUS 0x0800
+#define MAP_GROWSDOWN 0x1000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MAP_DENYWRITE 0x2000  
-#define MAP_EXECUTABLE 0x4000  
-#define MAP_LOCKED 0x8000  
-#define MAP_POPULATE 0x10000  
+#define MAP_DENYWRITE 0x2000
+#define MAP_EXECUTABLE 0x4000
+#define MAP_LOCKED 0x8000
+#define MAP_POPULATE 0x10000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MAP_NONBLOCK 0x20000  
-#define MAP_STACK 0x40000  
-#define MAP_HUGETLB 0x80000  
-#define MS_ASYNC 0x0001  
+#define MAP_NONBLOCK 0x20000
+#define MAP_STACK 0x40000
+#define MAP_HUGETLB 0x80000
+#define MS_ASYNC 0x0001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MS_INVALIDATE 0x0002  
-#define MS_SYNC 0x0004  
-#define MCL_CURRENT 1  
-#define MCL_FUTURE 2  
+#define MS_INVALIDATE 0x0002
+#define MS_SYNC 0x0004
+#define MCL_CURRENT 1
+#define MCL_FUTURE 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MADV_NORMAL 0  
-#define MADV_RANDOM 1  
-#define MADV_SEQUENTIAL 2  
-#define MADV_WILLNEED 3  
+#define MADV_NORMAL 0
+#define MADV_RANDOM 1
+#define MADV_SEQUENTIAL 2
+#define MADV_WILLNEED 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MADV_DONTNEED 4  
-#define MADV_REMOVE 9  
-#define MADV_DONTFORK 10  
-#define MADV_DOFORK 11  
+#define MADV_DONTNEED 4
+#define MADV_REMOVE 9
+#define MADV_DONTFORK 10
+#define MADV_DOFORK 11
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MADV_MERGEABLE 12  
-#define MADV_UNMERGEABLE 13  
-#define MADV_HWPOISON 100  
-#define MADV_HUGEPAGE 14  
+#define MADV_MERGEABLE 12
+#define MADV_UNMERGEABLE 13
+#define MADV_HWPOISON 100
+#define MADV_HUGEPAGE 14
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MADV_NOHUGEPAGE 15  
-#define MADV_DONTDUMP 16  
-#define MADV_DODUMP 17  
+#define MADV_NOHUGEPAGE 15
+#define MADV_DONTDUMP 16
+#define MADV_DODUMP 17
 #define MAP_FILE 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/arch-mips/asm/pci/bridge.h b/libc/kernel/arch-mips/asm/pci/bridge.h
index cd2fde4..3f421e3 100644
--- a/libc/kernel/arch-mips/asm/pci/bridge.h
+++ b/libc/kernel/arch-mips/asm/pci/bridge.h
@@ -21,24 +21,24 @@
 #include <linux/types.h>
 #include <linux/pci.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#include <asm/xtalk/xwidget.h>  
+#include <asm/xtalk/xwidget.h>
 #include <asm/sn/types.h>
-#define IOPFNSHIFT 12  
+#define IOPFNSHIFT 12
 #define IOPGSIZE (1 << IOPFNSHIFT)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IOPG(x) ((x) >> IOPFNSHIFT)
 #define IOPGOFF(x) ((x) & (IOPGSIZE-1))
-#define BRIDGE_ATE_RAM_SIZE 0x00000400  
+#define BRIDGE_ATE_RAM_SIZE 0x00000400
 #define BRIDGE_CONFIG_BASE 0x20000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BRIDGE_CONFIG1_BASE 0x28000
 #define BRIDGE_CONFIG_END 0x30000
 #define BRIDGE_CONFIG_SLOT_SIZE 0x1000
-#define BRIDGE_SSRAM_512K 0x00080000  
+#define BRIDGE_SSRAM_512K 0x00080000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BRIDGE_SSRAM_128K 0x00020000  
-#define BRIDGE_SSRAM_64K 0x00010000  
-#define BRIDGE_SSRAM_0K 0x00000000  
+#define BRIDGE_SSRAM_128K 0x00020000
+#define BRIDGE_SSRAM_64K 0x00010000
+#define BRIDGE_SSRAM_0K 0x00000000
 #ifndef __ASSEMBLY__
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef u32 bridgereg_t;
@@ -138,8 +138,8 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  bridgereg_t reg;
  } b_rrb_map[2];
-#define b_even_resp b_rrb_map[0].reg  
-#define b_odd_resp b_rrb_map[1].reg  
+#define b_even_resp b_rrb_map[0].reg
+#define b_odd_resp b_rrb_map[1].reg
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  bridgereg_t _pad_000290;
  bridgereg_t b_resp_status;
@@ -256,68 +256,68 @@
 #define BRIDGE_WID_LLP WIDGET_LLP_CFG
 #define BRIDGE_WID_TFLUSH WIDGET_TFLUSH
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BRIDGE_WID_AUX_ERR 0x00005C  
-#define BRIDGE_WID_RESP_UPPER 0x000064  
-#define BRIDGE_WID_RESP_LOWER 0x00006C  
-#define BRIDGE_WID_TST_PIN_CTRL 0x000074  
+#define BRIDGE_WID_AUX_ERR 0x00005C
+#define BRIDGE_WID_RESP_UPPER 0x000064
+#define BRIDGE_WID_RESP_LOWER 0x00006C
+#define BRIDGE_WID_TST_PIN_CTRL 0x000074
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BRIDGE_DIR_MAP 0x000084  
-#define BRIDGE_RAM_PERR 0x000094  
-#define BRIDGE_ARB 0x0000A4  
-#define BRIDGE_NIC 0x0000B4  
+#define BRIDGE_DIR_MAP 0x000084
+#define BRIDGE_RAM_PERR 0x000094
+#define BRIDGE_ARB 0x0000A4
+#define BRIDGE_NIC 0x0000B4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BRIDGE_BUS_TIMEOUT 0x0000C4  
+#define BRIDGE_BUS_TIMEOUT 0x0000C4
 #define BRIDGE_PCI_BUS_TIMEOUT BRIDGE_BUS_TIMEOUT
-#define BRIDGE_PCI_CFG 0x0000CC  
-#define BRIDGE_PCI_ERR_UPPER 0x0000D4  
+#define BRIDGE_PCI_CFG 0x0000CC
+#define BRIDGE_PCI_ERR_UPPER 0x0000D4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BRIDGE_PCI_ERR_LOWER 0x0000DC  
-#define BRIDGE_INT_STATUS 0x000104  
-#define BRIDGE_INT_ENABLE 0x00010C  
-#define BRIDGE_INT_RST_STAT 0x000114  
+#define BRIDGE_PCI_ERR_LOWER 0x0000DC
+#define BRIDGE_INT_STATUS 0x000104
+#define BRIDGE_INT_ENABLE 0x00010C
+#define BRIDGE_INT_RST_STAT 0x000114
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BRIDGE_INT_MODE 0x00011C  
-#define BRIDGE_INT_DEVICE 0x000124  
-#define BRIDGE_INT_HOST_ERR 0x00012C  
-#define BRIDGE_INT_ADDR0 0x000134  
+#define BRIDGE_INT_MODE 0x00011C
+#define BRIDGE_INT_DEVICE 0x000124
+#define BRIDGE_INT_HOST_ERR 0x00012C
+#define BRIDGE_INT_ADDR0 0x000134
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BRIDGE_INT_ADDR_OFF 0x000008  
+#define BRIDGE_INT_ADDR_OFF 0x000008
 #define BRIDGE_INT_ADDR(x) (BRIDGE_INT_ADDR0+(x)*BRIDGE_INT_ADDR_OFF)
-#define BRIDGE_DEVICE0 0x000204  
-#define BRIDGE_DEVICE_OFF 0x000008  
+#define BRIDGE_DEVICE0 0x000204
+#define BRIDGE_DEVICE_OFF 0x000008
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BRIDGE_DEVICE(x) (BRIDGE_DEVICE0+(x)*BRIDGE_DEVICE_OFF)
-#define BRIDGE_WR_REQ_BUF0 0x000244  
-#define BRIDGE_WR_REQ_BUF_OFF 0x000008  
+#define BRIDGE_WR_REQ_BUF0 0x000244
+#define BRIDGE_WR_REQ_BUF_OFF 0x000008
 #define BRIDGE_WR_REQ_BUF(x) (BRIDGE_WR_REQ_BUF0+(x)*BRIDGE_WR_REQ_BUF_OFF)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BRIDGE_EVEN_RESP 0x000284  
-#define BRIDGE_ODD_RESP 0x00028C  
-#define BRIDGE_RESP_STATUS 0x000294  
-#define BRIDGE_RESP_CLEAR 0x00029C  
+#define BRIDGE_EVEN_RESP 0x000284
+#define BRIDGE_ODD_RESP 0x00028C
+#define BRIDGE_RESP_STATUS 0x000294
+#define BRIDGE_RESP_CLEAR 0x00029C
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BRIDGE_ATE_RAM 0x00010000  
-#define BRIDGE_TYPE0_CFG_DEV0 0x00020000  
-#define BRIDGE_TYPE0_CFG_SLOT_OFF 0x00001000  
-#define BRIDGE_TYPE0_CFG_FUNC_OFF 0x00000100  
+#define BRIDGE_ATE_RAM 0x00010000
+#define BRIDGE_TYPE0_CFG_DEV0 0x00020000
+#define BRIDGE_TYPE0_CFG_SLOT_OFF 0x00001000
+#define BRIDGE_TYPE0_CFG_FUNC_OFF 0x00000100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BRIDGE_TYPE0_CFG_DEV(s) (BRIDGE_TYPE0_CFG_DEV0+  (s)*BRIDGE_TYPE0_CFG_SLOT_OFF)
 #define BRIDGE_TYPE0_CFG_DEVF(s, f) (BRIDGE_TYPE0_CFG_DEV0+  (s)*BRIDGE_TYPE0_CFG_SLOT_OFF+  (f)*BRIDGE_TYPE0_CFG_FUNC_OFF)
-#define BRIDGE_TYPE1_CFG 0x00028000  
-#define BRIDGE_PCI_IACK 0x00030000  
+#define BRIDGE_TYPE1_CFG 0x00028000
+#define BRIDGE_PCI_IACK 0x00030000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BRIDGE_EXT_SSRAM 0x00080000  
-#define BRIDGE_DEV_CNT 8  
-#define BRIDGE_DEVIO0 0x00200000  
-#define BRIDGE_DEVIO1 0x00400000  
+#define BRIDGE_EXT_SSRAM 0x00080000
+#define BRIDGE_DEV_CNT 8
+#define BRIDGE_DEVIO0 0x00200000
+#define BRIDGE_DEVIO1 0x00400000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BRIDGE_DEVIO2 0x00600000  
-#define BRIDGE_DEVIO_OFF 0x00100000  
-#define BRIDGE_DEVIO_2MB 0x00200000  
-#define BRIDGE_DEVIO_1MB 0x00100000  
+#define BRIDGE_DEVIO2 0x00600000
+#define BRIDGE_DEVIO_OFF 0x00100000
+#define BRIDGE_DEVIO_2MB 0x00200000
+#define BRIDGE_DEVIO_1MB 0x00100000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BRIDGE_DEVIO(x) ((x)<=1 ? BRIDGE_DEVIO0+(x)*BRIDGE_DEVIO_2MB : BRIDGE_DEVIO2+((x)-2)*BRIDGE_DEVIO_1MB)
-#define BRIDGE_EXTERNAL_FLASH 0x00C00000  
+#define BRIDGE_EXTERNAL_FLASH 0x00C00000
 #define BRIDGE_WIDGET_PART_NUM 0xc002
 #define XBRIDGE_WIDGET_PART_NUM 0xd002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -384,7 +384,7 @@
 #define BRIDGE_DIRMAP_RMF_64 (0x1 << 18)
 #define BRIDGE_DIRMAP_ADD512 (0x1 << 17)
 #define BRIDGE_DIRMAP_OFF (0x1ffff << 0)
-#define BRIDGE_DIRMAP_OFF_ADDRSHFT (31)  
+#define BRIDGE_DIRMAP_OFF_ADDRSHFT (31)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BRIDGE_ARB_REQ_WAIT_TICK(x) ((x) << 16)
 #define BRIDGE_ARB_REQ_WAIT_TICK_MASK BRIDGE_ARB_REQ_WAIT_TICK(0x3)
@@ -544,9 +544,9 @@
 #define BRIDGE_DEV_PMU_BITS (BRIDGE_DEV_PMU_WRGA_EN |   BRIDGE_DEV_SWAP_PMU)
 #define BRIDGE_DEV_D32_BITS (BRIDGE_DEV_DIR_WRGA_EN |   BRIDGE_DEV_SWAP_DIR |   BRIDGE_DEV_PREF |   BRIDGE_DEV_PRECISE |   BRIDGE_DEV_COH |   BRIDGE_DEV_BARRIER)
 #define BRIDGE_DEV_D64_BITS (BRIDGE_DEV_DIR_WRGA_EN |   BRIDGE_DEV_SWAP_DIR |   BRIDGE_DEV_COH |   BRIDGE_DEV_BARRIER)
-#define BRIDGE_ERRUPPR_DEVMASTER (0x1 << 20)  
+#define BRIDGE_ERRUPPR_DEVMASTER (0x1 << 20)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BRIDGE_ERRUPPR_PCIVDEV (0x1 << 19)  
+#define BRIDGE_ERRUPPR_PCIVDEV (0x1 << 19)
 #define BRIDGE_ERRUPPR_DEVNUM_SHFT (16)
 #define BRIDGE_ERRUPPR_DEVNUM_MASK (0x7 << BRIDGE_ERRUPPR_DEVNUM_SHFT)
 #define BRIDGE_ERRUPPR_DEVICE(err) (((err) >> BRIDGE_ERRUPPR_DEVNUM_SHFT) & 0x7)
@@ -554,20 +554,20 @@
 #define BRIDGE_ERRUPPR_ADDRMASK (0xFFFF)
 #define BRIDGE_INTMODE_CLR_PKT_EN(x) (0x1 << (x))
 #define BRIDGE_CREDIT 3
-#define BRIDGE_RRB_EN 0x8  
+#define BRIDGE_RRB_EN 0x8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BRIDGE_RRB_DEV 0x7  
-#define BRIDGE_RRB_VDEV 0x4  
-#define BRIDGE_RRB_PDEV 0x3  
+#define BRIDGE_RRB_DEV 0x7
+#define BRIDGE_RRB_VDEV 0x4
+#define BRIDGE_RRB_PDEV 0x3
 #define BRIDGE_RRB_VALID(r) (0x00010000<<(r))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BRIDGE_RRB_INUSE(r) (0x00000001<<(r))
 #define BRIDGE_RRB_CLEAR(r) (0x00000001<<(r))
 #define XBOX_BRIDGE_WID 8
-#define FLASH_PROM1_BASE 0xE00000  
+#define FLASH_PROM1_BASE 0xE00000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define XBOX_RPS_EXISTS 1 << 6  
-#define XBOX_RPS_FAIL 1 << 4  
+#define XBOX_RPS_EXISTS 1 << 6
+#define XBOX_RPS_FAIL 1 << 4
 #define BRIDGE_PIO32_XTALK_ALIAS_BASE 0x000040000000L
 #define BRIDGE_PIO32_XTALK_ALIAS_LIMIT 0x00007FFFFFFFL
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -576,9 +576,9 @@
 #define BRIDGE_PCIIO_XTALK_ALIAS_BASE 0x000100000000L
 #define BRIDGE_PCIIO_XTALK_ALIAS_LIMIT 0x0001FFFFFFFFL
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BRIDGE_MIN_PIO_ADDR_MEM 0x00000000  
+#define BRIDGE_MIN_PIO_ADDR_MEM 0x00000000
 #define BRIDGE_MAX_PIO_ADDR_MEM 0x3fffffff
-#define BRIDGE_MIN_PIO_ADDR_IO 0x00000000  
+#define BRIDGE_MIN_PIO_ADDR_IO 0x00000000
 #define BRIDGE_MAX_PIO_ADDR_IO 0xffffffff
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BRIDGE_PCI_MEM32_BASE BRIDGE_PIO32_XTALK_ALIAS_BASE
@@ -591,9 +591,9 @@
 #define BRIDGE_LOCAL_BASE 0
 #define BRIDGE_DMA_MAPPED_BASE 0x40000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BRIDGE_DMA_MAPPED_SIZE 0x40000000  
+#define BRIDGE_DMA_MAPPED_SIZE 0x40000000
 #define BRIDGE_DMA_DIRECT_BASE 0x80000000
-#define BRIDGE_DMA_DIRECT_SIZE 0x80000000  
+#define BRIDGE_DMA_DIRECT_SIZE 0x80000000
 #define PCI32_LOCAL_BASE BRIDGE_LOCAL_BASE
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI32_MAPPED_BASE BRIDGE_DMA_MAPPED_BASE
diff --git a/libc/kernel/arch-mips/asm/pgtable-32.h b/libc/kernel/arch-mips/asm/pgtable-32.h
new file mode 100644
index 0000000..f005083
--- /dev/null
+++ b/libc/kernel/arch-mips/asm/pgtable-32.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ***   To edit the content of this header, modify the corresponding
+ ***   source file (e.g. under external/kernel-headers/original/) then
+ ***   run bionic/libc/kernel/tools/update_all.py
+ ***
+ ***   Any manual change here will be lost the next time this script will
+ ***   be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_PGTABLE_32_H
+#define _ASM_PGTABLE_32_H
+#include <asm/addrspace.h>
+#include <asm/page.h>
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#include <linux/linkage.h>
+#include <asm/cachectl.h>
+#include <asm/fixmap.h>
+#include <asm-generic/pgtable-nopmd.h>
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PGDIR_SHIFT (2 * PAGE_SHIFT + PTE_ORDER - PTE_T_LOG2)
+#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
+#define PGDIR_MASK (~(PGDIR_SIZE-1))
+#define __PGD_ORDER (32 - 3 * PAGE_SHIFT + PGD_T_LOG2 + PTE_T_LOG2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PGD_ORDER (__PGD_ORDER >= 0 ? __PGD_ORDER : 0)
+#define PUD_ORDER aieeee_attempt_to_allocate_pud
+#define PMD_ORDER 1
+#define PTE_ORDER 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PTRS_PER_PGD (USER_PTRS_PER_PGD * 2)
+#define PTRS_PER_PTE ((PAGE_SIZE << PTE_ORDER) / sizeof(pte_t))
+#define USER_PTRS_PER_PGD (0x80000000UL/PGDIR_SIZE)
+#define FIRST_USER_ADDRESS 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VMALLOC_START MAP_BASE
+#define PKMAP_BASE (0xfe000000UL)
+#define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE)
+#define pte_ERROR(e)   printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define pgd_ERROR(e)   printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
+#define pmd_bad(pmd) (pmd_val(pmd) & ~PAGE_MASK)
+#define pte_page(x) pfn_to_page(pte_pfn(x))
+#define pte_pfn(x) ((unsigned long)((x).pte >> _PFN_SHIFT))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define pfn_pte(pfn, prot) __pte(((unsigned long long)(pfn) << _PFN_SHIFT) | pgprot_val(prot))
+#define __pgd_offset(address) pgd_index(address)
+#define __pud_offset(address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
+#define __pmd_offset(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define pgd_offset_k(address) pgd_offset(&init_mm, address)
+#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
+#define pgd_offset(mm, addr) ((mm)->pgd + pgd_index(addr))
+#define __pte_offset(address)   (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define pte_offset(dir, address)   ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
+#define pte_offset_kernel(dir, address)   ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
+#define pte_offset_map(dir, address)   ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
+#define pte_unmap(pte) ((void)(pte))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __swp_type(x) (((x).val >> 8) & 0x1f)
+#define __swp_offset(x) ((x).val >> 13)
+#define __swp_entry(type,offset)   ((swp_entry_t) { ((type) << 8) | ((offset) << 13) })
+#define PTE_FILE_MAX_BITS 28
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define pte_to_pgoff(_pte) ((((_pte).pte >> 1) & 0x7) |   (((_pte).pte >> 2) & 0x8) |   (((_pte).pte >> 8) << 4))
+#define pgoff_to_pte(off) ((pte_t) { (((off) & 0x7) << 1) |   (((off) & 0x8) << 2) |   (((off) >> 4) << 8) |   _PAGE_FILE })
+#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
+#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
diff --git a/libc/kernel/arch-mips/asm/pgtable-bits.h b/libc/kernel/arch-mips/asm/pgtable-bits.h
index 3df2c3d..ecd620c 100644
--- a/libc/kernel/arch-mips/asm/pgtable-bits.h
+++ b/libc/kernel/arch-mips/asm/pgtable-bits.h
@@ -18,35 +18,35 @@
  ****************************************************************************/
 #ifndef _ASM_PGTABLE_BITS_H
 #define _ASM_PGTABLE_BITS_H
-#define _PAGE_PRESENT (1<<0)  
-#define _PAGE_READ (1<<1)  
+#define _PAGE_PRESENT (1<<0)
+#define _PAGE_READ (1<<1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define _PAGE_WRITE (1<<2)  
-#define _PAGE_ACCESSED (1<<3)  
-#define _PAGE_MODIFIED (1<<4)  
-#define _PAGE_FILE (1<<4)  
+#define _PAGE_WRITE (1<<2)
+#define _PAGE_ACCESSED (1<<3)
+#define _PAGE_MODIFIED (1<<4)
+#define _PAGE_FILE (1<<4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define _PAGE_R4KBUG (1<<5)  
+#define _PAGE_R4KBUG (1<<5)
 #define _PAGE_GLOBAL (1<<6)
 #define _PAGE_VALID (1<<7)
-#define _PAGE_SILENT_READ (1<<7)  
+#define _PAGE_SILENT_READ (1<<7)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define _PAGE_DIRTY (1<<8)  
+#define _PAGE_DIRTY (1<<8)
 #define _PAGE_SILENT_WRITE (1<<8)
 #define _CACHE_SHIFT 9
 #define _CACHE_MASK (7<<9)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define _CACHE_CACHABLE_NO_WA (0<<_CACHE_SHIFT)  
-#define _CACHE_CACHABLE_WA (1<<_CACHE_SHIFT)  
-#define _CACHE_UNCACHED (2<<_CACHE_SHIFT)  
-#define _CACHE_CACHABLE_NONCOHERENT (3<<_CACHE_SHIFT)  
+#define _CACHE_CACHABLE_NO_WA (0<<_CACHE_SHIFT)
+#define _CACHE_CACHABLE_WA (1<<_CACHE_SHIFT)
+#define _CACHE_UNCACHED (2<<_CACHE_SHIFT)
+#define _CACHE_CACHABLE_NONCOHERENT (3<<_CACHE_SHIFT)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define _CACHE_CACHABLE_CE (4<<_CACHE_SHIFT)  
-#define _CACHE_CACHABLE_COW (5<<_CACHE_SHIFT)  
-#define _CACHE_CACHABLE_COHERENT (5<<_CACHE_SHIFT)  
-#define _CACHE_CACHABLE_CUW (6<<_CACHE_SHIFT)  
+#define _CACHE_CACHABLE_CE (4<<_CACHE_SHIFT)
+#define _CACHE_CACHABLE_COW (5<<_CACHE_SHIFT)
+#define _CACHE_CACHABLE_COHERENT (5<<_CACHE_SHIFT)
+#define _CACHE_CACHABLE_CUW (6<<_CACHE_SHIFT)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define _CACHE_UNCACHED_ACCELERATED (7<<_CACHE_SHIFT)  
+#define _CACHE_UNCACHED_ACCELERATED (7<<_CACHE_SHIFT)
 #define __READABLE (_PAGE_READ | _PAGE_SILENT_READ | _PAGE_ACCESSED)
 #define __WRITEABLE (_PAGE_WRITE | _PAGE_SILENT_WRITE | _PAGE_MODIFIED)
 #define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_MODIFIED | _CACHE_MASK)
diff --git a/libc/kernel/arch-mips/asm/ptrace.h b/libc/kernel/arch-mips/asm/ptrace.h
index 43cfcf1..d971c7e 100644
--- a/libc/kernel/arch-mips/asm/ptrace.h
+++ b/libc/kernel/arch-mips/asm/ptrace.h
@@ -28,7 +28,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FPC_CSR 69
 #define FPC_EIR 70
-#define DSP_BASE 71  
+#define DSP_BASE 71
 #define DSP_CONTROL 77
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ACX 78
diff --git a/libc/kernel/arch-mips/asm/regdef.h b/libc/kernel/arch-mips/asm/regdef.h
index 12d9c42..8700325 100644
--- a/libc/kernel/arch-mips/asm/regdef.h
+++ b/libc/kernel/arch-mips/asm/regdef.h
@@ -21,17 +21,17 @@
 #include <asm/sgidefs.h>
 #if _MIPS_SIM == _MIPS_SIM_ABI32
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define zero $0  
-#define AT $1  
-#define v0 $2  
+#define zero $0
+#define AT $1
+#define v0 $2
 #define v1 $3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define a0 $4  
+#define a0 $4
 #define a1 $5
 #define a2 $6
 #define a3 $7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define t0 $8  
+#define t0 $8
 #define t1 $9
 #define t2 $10
 #define t3 $11
@@ -41,7 +41,7 @@
 #define t6 $14
 #define t7 $15
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define s0 $16  
+#define s0 $16
 #define s1 $17
 #define s2 $18
 #define s3 $19
@@ -51,32 +51,32 @@
 #define s6 $22
 #define s7 $23
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define t8 $24  
+#define t8 $24
 #define t9 $25
-#define jp $25  
-#define k0 $26  
+#define jp $25
+#define k0 $26
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define k1 $27
-#define gp $28  
-#define sp $29  
-#define fp $30  
+#define gp $28
+#define sp $29
+#define fp $30
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define s8 $30  
-#define ra $31  
+#define s8 $30
+#define ra $31
 #endif
 #if _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define zero $0  
-#define AT $at  
-#define v0 $2  
+#define zero $0
+#define AT $at
+#define v0 $2
 #define v1 $3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define a0 $4  
+#define a0 $4
 #define a1 $5
 #define a2 $6
 #define a3 $7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define a4 $8  
+#define a4 $8
 #define ta0 $8
 #define a5 $9
 #define ta1 $9
@@ -86,12 +86,12 @@
 #define a7 $11
 #define ta3 $11
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define t0 $12  
+#define t0 $12
 #define t1 $13
 #define t2 $14
 #define t3 $15
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define s0 $16  
+#define s0 $16
 #define s1 $17
 #define s2 $18
 #define s3 $19
@@ -101,18 +101,18 @@
 #define s6 $22
 #define s7 $23
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define t8 $24  
-#define t9 $25  
-#define jp $25  
-#define k0 $26  
+#define t8 $24
+#define t9 $25
+#define jp $25
+#define k0 $26
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define k1 $27
-#define gp $28  
-#define sp $29  
-#define fp $30  
+#define gp $28
+#define sp $29
+#define fp $30
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define s8 $30  
-#define ra $31  
+#define s8 $30
+#define ra $31
 #endif
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-mips/asm/resource.h b/libc/kernel/arch-mips/asm/resource.h
index 1374d7d..8761697 100644
--- a/libc/kernel/arch-mips/asm/resource.h
+++ b/libc/kernel/arch-mips/asm/resource.h
@@ -18,12 +18,12 @@
  ****************************************************************************/
 #ifndef _ASM_RESOURCE_H
 #define _ASM_RESOURCE_H
-#define RLIMIT_NOFILE 5  
-#define RLIMIT_AS 6  
+#define RLIMIT_NOFILE 5
+#define RLIMIT_AS 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RLIMIT_RSS 7  
-#define RLIMIT_NPROC 8  
-#define RLIMIT_MEMLOCK 9  
+#define RLIMIT_RSS 7
+#define RLIMIT_NPROC 8
+#define RLIMIT_MEMLOCK 9
 #define RLIM_INFINITY 0x7fffffffUL
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <asm-generic/resource.h>
diff --git a/libc/kernel/arch-mips/asm/sgi/hpc3.h b/libc/kernel/arch-mips/asm/sgi/hpc3.h
index d4f4280..d64fc6f 100644
--- a/libc/kernel/arch-mips/asm/sgi/hpc3.h
+++ b/libc/kernel/arch-mips/asm/sgi/hpc3.h
@@ -24,19 +24,19 @@
 struct hpc_dma_desc {
  u32 pbuf;
  u32 cntinfo;
-#define HPCDMA_EOX 0x80000000  
+#define HPCDMA_EOX 0x80000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPCDMA_EOR 0x80000000  
-#define HPCDMA_EOXP 0x40000000  
-#define HPCDMA_EORP 0x40000000  
-#define HPCDMA_XIE 0x20000000  
+#define HPCDMA_EOR 0x80000000
+#define HPCDMA_EOXP 0x40000000
+#define HPCDMA_EORP 0x40000000
+#define HPCDMA_XIE 0x20000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPCDMA_XIU 0x01000000  
-#define HPCDMA_EIPC 0x00ff0000  
-#define HPCDMA_ETXD 0x00008000  
-#define HPCDMA_OWN 0x00004000  
+#define HPCDMA_XIU 0x01000000
+#define HPCDMA_EIPC 0x00ff0000
+#define HPCDMA_ETXD 0x00008000
+#define HPCDMA_OWN 0x00004000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPCDMA_BCNT 0x00003fff  
+#define HPCDMA_BCNT 0x00003fff
  u32 pnext;
 };
 struct hpc3_pbus_dmacregs {
@@ -46,19 +46,19 @@
  u32 _unused0[0x1000/4 - 2];
  volatile u32 pbdma_ctrl;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_PDMACTRL_INT 0x00000001  
-#define HPC3_PDMACTRL_ISACT 0x00000002  
-#define HPC3_PDMACTRL_SEL 0x00000002  
-#define HPC3_PDMACTRL_RCV 0x00000004  
+#define HPC3_PDMACTRL_INT 0x00000001
+#define HPC3_PDMACTRL_ISACT 0x00000002
+#define HPC3_PDMACTRL_SEL 0x00000002
+#define HPC3_PDMACTRL_RCV 0x00000004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_PDMACTRL_FLSH 0x00000008  
-#define HPC3_PDMACTRL_ACT 0x00000010  
-#define HPC3_PDMACTRL_LD 0x00000020  
-#define HPC3_PDMACTRL_RT 0x00000040  
+#define HPC3_PDMACTRL_FLSH 0x00000008
+#define HPC3_PDMACTRL_ACT 0x00000010
+#define HPC3_PDMACTRL_LD 0x00000020
+#define HPC3_PDMACTRL_RT 0x00000040
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_PDMACTRL_HW 0x0000ff00  
-#define HPC3_PDMACTRL_FB 0x003f0000  
-#define HPC3_PDMACTRL_FE 0x3f000000  
+#define HPC3_PDMACTRL_HW 0x0000ff00
+#define HPC3_PDMACTRL_FB 0x003f0000
+#define HPC3_PDMACTRL_FE 0x3f000000
  u32 _unused1[0x1000/4 - 1];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
@@ -68,48 +68,48 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  u32 _unused0[0x1000/4 - 2];
  volatile u32 bcd;
-#define HPC3_SBCD_BCNTMSK 0x00003fff  
-#define HPC3_SBCD_XIE 0x00004000  
+#define HPC3_SBCD_BCNTMSK 0x00003fff
+#define HPC3_SBCD_XIE 0x00004000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_SBCD_EOX 0x00008000  
+#define HPC3_SBCD_EOX 0x00008000
  volatile u32 ctrl;
-#define HPC3_SCTRL_IRQ 0x01  
-#define HPC3_SCTRL_ENDIAN 0x02  
+#define HPC3_SCTRL_IRQ 0x01
+#define HPC3_SCTRL_ENDIAN 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_SCTRL_DIR 0x04  
-#define HPC3_SCTRL_FLUSH 0x08  
-#define HPC3_SCTRL_ACTIVE 0x10  
-#define HPC3_SCTRL_AMASK 0x20  
+#define HPC3_SCTRL_DIR 0x04
+#define HPC3_SCTRL_FLUSH 0x08
+#define HPC3_SCTRL_ACTIVE 0x10
+#define HPC3_SCTRL_AMASK 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_SCTRL_CRESET 0x40  
-#define HPC3_SCTRL_PERR 0x80  
+#define HPC3_SCTRL_CRESET 0x40
+#define HPC3_SCTRL_PERR 0x80
  volatile u32 gfptr;
  volatile u32 dfptr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  volatile u32 dconfig;
-#define HPC3_SDCFG_HCLK 0x00001  
-#define HPC3_SDCFG_D1 0x00006  
-#define HPC3_SDCFG_D2 0x00038  
+#define HPC3_SDCFG_HCLK 0x00001
+#define HPC3_SDCFG_D1 0x00006
+#define HPC3_SDCFG_D2 0x00038
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_SDCFG_D3 0x001c0  
-#define HPC3_SDCFG_HWAT 0x00e00  
-#define HPC3_SDCFG_HW 0x01000  
-#define HPC3_SDCFG_SWAP 0x02000  
+#define HPC3_SDCFG_D3 0x001c0
+#define HPC3_SDCFG_HWAT 0x00e00
+#define HPC3_SDCFG_HW 0x01000
+#define HPC3_SDCFG_SWAP 0x02000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_SDCFG_EPAR 0x04000  
-#define HPC3_SDCFG_POLL 0x08000  
-#define HPC3_SDCFG_ERLY 0x30000  
+#define HPC3_SDCFG_EPAR 0x04000
+#define HPC3_SDCFG_POLL 0x08000
+#define HPC3_SDCFG_ERLY 0x30000
  volatile u32 pconfig;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_SPCFG_P3 0x0003  
-#define HPC3_SPCFG_P2W 0x001c  
-#define HPC3_SPCFG_P2R 0x01e0  
-#define HPC3_SPCFG_P1 0x0e00  
+#define HPC3_SPCFG_P3 0x0003
+#define HPC3_SPCFG_P2W 0x001c
+#define HPC3_SPCFG_P2R 0x01e0
+#define HPC3_SPCFG_P1 0x0e00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_SPCFG_HW 0x1000  
-#define HPC3_SPCFG_SWAP 0x2000  
-#define HPC3_SPCFG_EPAR 0x4000  
-#define HPC3_SPCFG_FUJI 0x8000  
+#define HPC3_SPCFG_HW 0x1000
+#define HPC3_SPCFG_SWAP 0x2000
+#define HPC3_SPCFG_EPAR 0x4000
+#define HPC3_SPCFG_FUJI 0x8000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  u32 _unused1[0x1000/4 - 6];
 };
@@ -119,46 +119,46 @@
  volatile u32 rx_ndptr;
  u32 _unused0[0x1000/4 - 2];
  volatile u32 rx_bcd;
-#define HPC3_ERXBCD_BCNTMSK 0x00003fff  
+#define HPC3_ERXBCD_BCNTMSK 0x00003fff
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_ERXBCD_XIE 0x20000000  
-#define HPC3_ERXBCD_EOX 0x80000000  
+#define HPC3_ERXBCD_XIE 0x20000000
+#define HPC3_ERXBCD_EOX 0x80000000
  volatile u32 rx_ctrl;
-#define HPC3_ERXCTRL_STAT50 0x0000003f  
+#define HPC3_ERXCTRL_STAT50 0x0000003f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_ERXCTRL_STAT6 0x00000040  
-#define HPC3_ERXCTRL_STAT7 0x00000080  
-#define HPC3_ERXCTRL_ENDIAN 0x00000100  
-#define HPC3_ERXCTRL_ACTIVE 0x00000200  
+#define HPC3_ERXCTRL_STAT6 0x00000040
+#define HPC3_ERXCTRL_STAT7 0x00000080
+#define HPC3_ERXCTRL_ENDIAN 0x00000100
+#define HPC3_ERXCTRL_ACTIVE 0x00000200
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_ERXCTRL_AMASK 0x00000400  
-#define HPC3_ERXCTRL_RBO 0x00000800  
+#define HPC3_ERXCTRL_AMASK 0x00000400
+#define HPC3_ERXCTRL_RBO 0x00000800
  volatile u32 rx_gfptr;
  volatile u32 rx_dfptr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  u32 _unused1;
  volatile u32 reset;
-#define HPC3_ERST_CRESET 0x1  
-#define HPC3_ERST_CLRIRQ 0x2  
+#define HPC3_ERST_CRESET 0x1
+#define HPC3_ERST_CLRIRQ 0x2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_ERST_LBACK 0x4  
+#define HPC3_ERST_LBACK 0x4
  volatile u32 dconfig;
-#define HPC3_EDCFG_D1 0x0000f  
-#define HPC3_EDCFG_D2 0x000f0  
+#define HPC3_EDCFG_D1 0x0000f
+#define HPC3_EDCFG_D2 0x000f0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_EDCFG_D3 0x00f00  
-#define HPC3_EDCFG_WCTRL 0x01000  
-#define HPC3_EDCFG_FRXDC 0x02000  
-#define HPC3_EDCFG_FEOP 0x04000  
+#define HPC3_EDCFG_D3 0x00f00
+#define HPC3_EDCFG_WCTRL 0x01000
+#define HPC3_EDCFG_FRXDC 0x02000
+#define HPC3_EDCFG_FEOP 0x04000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_EDCFG_FIRQ 0x08000  
-#define HPC3_EDCFG_PTO 0x30000  
+#define HPC3_EDCFG_FIRQ 0x08000
+#define HPC3_EDCFG_PTO 0x30000
  volatile u32 pconfig;
-#define HPC3_EPCFG_P1 0x000f  
+#define HPC3_EPCFG_P1 0x000f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_EPCFG_P2 0x00f0  
-#define HPC3_EPCFG_P3 0x0f00  
-#define HPC3_EPCFG_TST 0x1000  
+#define HPC3_EPCFG_P2 0x00f0
+#define HPC3_EPCFG_P3 0x0f00
+#define HPC3_EPCFG_TST 0x1000
  u32 _unused2[0x1000/4 - 8];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  volatile u32 tx_cbptr;
@@ -166,20 +166,20 @@
  u32 _unused3[0x1000/4 - 2];
  volatile u32 tx_bcd;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_ETXBCD_BCNTMSK 0x00003fff  
-#define HPC3_ETXBCD_ESAMP 0x10000000  
-#define HPC3_ETXBCD_XIE 0x20000000  
-#define HPC3_ETXBCD_EOP 0x40000000  
+#define HPC3_ETXBCD_BCNTMSK 0x00003fff
+#define HPC3_ETXBCD_ESAMP 0x10000000
+#define HPC3_ETXBCD_XIE 0x20000000
+#define HPC3_ETXBCD_EOP 0x40000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_ETXBCD_EOX 0x80000000  
+#define HPC3_ETXBCD_EOX 0x80000000
  volatile u32 tx_ctrl;
-#define HPC3_ETXCTRL_STAT30 0x0000000f  
-#define HPC3_ETXCTRL_STAT4 0x00000010  
+#define HPC3_ETXCTRL_STAT30 0x0000000f
+#define HPC3_ETXCTRL_STAT4 0x00000010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_ETXCTRL_STAT75 0x000000e0  
-#define HPC3_ETXCTRL_ENDIAN 0x00000100  
-#define HPC3_ETXCTRL_ACTIVE 0x00000200  
-#define HPC3_ETXCTRL_AMASK 0x00000400  
+#define HPC3_ETXCTRL_STAT75 0x000000e0
+#define HPC3_ETXCTRL_ENDIAN 0x00000100
+#define HPC3_ETXCTRL_ACTIVE 0x00000200
+#define HPC3_ETXCTRL_AMASK 0x00000400
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  volatile u32 tx_gfptr;
  volatile u32 tx_dfptr;
@@ -193,28 +193,28 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  u32 _unused0[0x18000/4];
  volatile u32 istat0;
-#define HPC3_ISTAT_PBIMASK 0x0ff  
-#define HPC3_ISTAT_SC0MASK 0x100  
+#define HPC3_ISTAT_PBIMASK 0x0ff
+#define HPC3_ISTAT_SC0MASK 0x100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_ISTAT_SC1MASK 0x200  
+#define HPC3_ISTAT_SC1MASK 0x200
  volatile u32 gio_misc;
-#define HPC3_GIOMISC_ERTIME 0x1  
-#define HPC3_GIOMISC_DENDIAN 0x2  
+#define HPC3_GIOMISC_ERTIME 0x1
+#define HPC3_GIOMISC_DENDIAN 0x2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  u32 eeprom;
-#define HPC3_EEPROM_EPROT 0x01  
-#define HPC3_EEPROM_CSEL 0x02  
-#define HPC3_EEPROM_ECLK 0x04  
+#define HPC3_EEPROM_EPROT 0x01
+#define HPC3_EEPROM_CSEL 0x02
+#define HPC3_EEPROM_ECLK 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_EEPROM_DATO 0x08  
-#define HPC3_EEPROM_DATI 0x10  
+#define HPC3_EEPROM_DATO 0x08
+#define HPC3_EEPROM_DATI 0x10
  volatile u32 istat1;
  volatile u32 bestat;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_BESTAT_BLMASK 0x000ff  
-#define HPC3_BESTAT_CTYPE 0x00100  
+#define HPC3_BESTAT_BLMASK 0x000ff
+#define HPC3_BESTAT_CTYPE 0x00100
 #define HPC3_BESTAT_PIDSHIFT 9
-#define HPC3_BESTAT_PIDMASK 0x3f700  
+#define HPC3_BESTAT_PIDMASK 0x3f700
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  u32 _unused1[0x14000/4 - 5];
  volatile u32 scsi0_ext[256];
@@ -269,22 +269,22 @@
 #define HPC3_PIOCFG_DS16 0x40000
 #define HPC3_PIOCFG_EVENHI 0x80000
  volatile u32 pbus_promwe;
-#define HPC3_PROM_WENAB 0x1  
+#define HPC3_PROM_WENAB 0x1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  u32 _unused5[0x0800/4 - 1];
  volatile u32 pbus_promswap;
-#define HPC3_PROM_SWAP 0x1  
+#define HPC3_PROM_SWAP 0x1
  u32 _unused6[0x0800/4 - 1];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  volatile u32 pbus_gout;
-#define HPC3_PROM_STAT 0x1  
+#define HPC3_PROM_STAT 0x1
  u32 _unused7[0x1000/4 - 1];
  volatile u32 rtcregs[14];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  u32 _unused8[50];
  volatile u32 bbram[8192-50-14];
 };
-#define HPC3_CHIP0_BASE 0x1fb80000  
+#define HPC3_CHIP0_BASE 0x1fb80000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HPC3_CHIP1_BASE 0x1fb00000  
+#define HPC3_CHIP1_BASE 0x1fb00000
 #endif
diff --git a/libc/kernel/arch-mips/asm/sgi/ioc.h b/libc/kernel/arch-mips/asm/sgi/ioc.h
index db75b20..3fc19a9 100644
--- a/libc/kernel/arch-mips/asm/sgi/ioc.h
+++ b/libc/kernel/arch-mips/asm/sgi/ioc.h
@@ -98,27 +98,27 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  u8 _tcword[3];
  volatile u8 tcword;
-#define SGINT_TCWORD_BCD 0x01  
-#define SGINT_TCWORD_MMASK 0x0e  
+#define SGINT_TCWORD_BCD 0x01
+#define SGINT_TCWORD_MMASK 0x0e
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SGINT_TCWORD_MITC 0x00  
-#define SGINT_TCWORD_MOS 0x02  
-#define SGINT_TCWORD_MRGEN 0x04  
-#define SGINT_TCWORD_MSWGEN 0x06  
+#define SGINT_TCWORD_MITC 0x00
+#define SGINT_TCWORD_MOS 0x02
+#define SGINT_TCWORD_MRGEN 0x04
+#define SGINT_TCWORD_MSWGEN 0x06
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SGINT_TCWORD_MSWST 0x08  
-#define SGINT_TCWORD_MHWST 0x0a  
-#define SGINT_TCWORD_CMASK 0x30  
-#define SGINT_TCWORD_CLAT 0x00  
+#define SGINT_TCWORD_MSWST 0x08
+#define SGINT_TCWORD_MHWST 0x0a
+#define SGINT_TCWORD_CMASK 0x30
+#define SGINT_TCWORD_CLAT 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SGINT_TCWORD_CLSB 0x10  
-#define SGINT_TCWORD_CMSB 0x20  
-#define SGINT_TCWORD_CALL 0x30  
-#define SGINT_TCWORD_CNT0 0x00  
+#define SGINT_TCWORD_CLSB 0x10
+#define SGINT_TCWORD_CMSB 0x20
+#define SGINT_TCWORD_CALL 0x30
+#define SGINT_TCWORD_CNT0 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SGINT_TCWORD_CNT1 0x40  
-#define SGINT_TCWORD_CNT2 0x80  
-#define SGINT_TCWORD_CRBCK 0xc0  
+#define SGINT_TCWORD_CNT1 0x40
+#define SGINT_TCWORD_CNT2 0x80
+#define SGINT_TCWORD_CRBCK 0xc0
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SGINT_TIMER_CLOCK 1000000
@@ -159,52 +159,52 @@
  u32 _unused3;
  u8 _dmasel[3];
  volatile u8 dmasel;
-#define SGIOC_DMASEL_SCLK10MHZ 0x00  
+#define SGIOC_DMASEL_SCLK10MHZ 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SGIOC_DMASEL_ISDNB 0x01  
-#define SGIOC_DMASEL_ISDNA 0x02  
-#define SGIOC_DMASEL_PPORT 0x04  
-#define SGIOC_DMASEL_SCLK667MHZ 0x10  
+#define SGIOC_DMASEL_ISDNB 0x01
+#define SGIOC_DMASEL_ISDNA 0x02
+#define SGIOC_DMASEL_PPORT 0x04
+#define SGIOC_DMASEL_SCLK667MHZ 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SGIOC_DMASEL_SCLKEXT 0x20  
+#define SGIOC_DMASEL_SCLKEXT 0x20
  u32 _unused4;
  u8 _reset[3];
  volatile u8 reset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SGIOC_RESET_PPORT 0x01  
-#define SGIOC_RESET_KBDMOUSE 0x02  
-#define SGIOC_RESET_EISA 0x04  
-#define SGIOC_RESET_ISDN 0x08  
+#define SGIOC_RESET_PPORT 0x01
+#define SGIOC_RESET_KBDMOUSE 0x02
+#define SGIOC_RESET_EISA 0x04
+#define SGIOC_RESET_ISDN 0x08
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SGIOC_RESET_LC0OFF 0x10  
-#define SGIOC_RESET_LC1OFF 0x20  
+#define SGIOC_RESET_LC0OFF 0x10
+#define SGIOC_RESET_LC1OFF 0x20
  u32 _unused5;
  u8 _write[3];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  volatile u8 write;
-#define SGIOC_WRITE_NTHRESH 0x01  
-#define SGIOC_WRITE_TPSPEED 0x02  
-#define SGIOC_WRITE_EPSEL 0x04  
+#define SGIOC_WRITE_NTHRESH 0x01
+#define SGIOC_WRITE_TPSPEED 0x02
+#define SGIOC_WRITE_EPSEL 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SGIOC_WRITE_EASEL 0x08  
-#define SGIOC_WRITE_U1AMODE 0x10  
-#define SGIOC_WRITE_U0AMODE 0x20  
-#define SGIOC_WRITE_MLO 0x40  
+#define SGIOC_WRITE_EASEL 0x08
+#define SGIOC_WRITE_U1AMODE 0x10
+#define SGIOC_WRITE_U0AMODE 0x20
+#define SGIOC_WRITE_MLO 0x40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SGIOC_WRITE_MHI 0x80  
+#define SGIOC_WRITE_MHI 0x80
  u32 _unused6;
  struct sgint_regs int3;
  u32 _unused7[16];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  volatile u32 extio;
-#define EXTIO_S0_IRQ_3 0x8000  
-#define EXTIO_S0_IRQ_2 0x4000  
-#define EXTIO_S0_IRQ_1 0x2000  
+#define EXTIO_S0_IRQ_3 0x8000
+#define EXTIO_S0_IRQ_2 0x4000
+#define EXTIO_S0_IRQ_1 0x2000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EXTIO_S0_RETRACE 0x1000
-#define EXTIO_SG_IRQ_3 0x0800  
-#define EXTIO_SG_IRQ_2 0x0400  
-#define EXTIO_SG_IRQ_1 0x0200  
+#define EXTIO_SG_IRQ_3 0x0800
+#define EXTIO_SG_IRQ_2 0x0400
+#define EXTIO_SG_IRQ_1 0x0200
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EXTIO_SG_RETRACE 0x0100
 #define EXTIO_GIO_33MHZ 0x0080
diff --git a/libc/kernel/arch-mips/asm/sgi/pi1.h b/libc/kernel/arch-mips/asm/sgi/pi1.h
index 1aa0438..dd53237 100644
--- a/libc/kernel/arch-mips/asm/sgi/pi1.h
+++ b/libc/kernel/arch-mips/asm/sgi/pi1.h
@@ -36,8 +36,8 @@
  u8 _status[3];
  volatile u8 status;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI1_STAT_DEVID 0x03  
-#define PI1_STAT_NOINK 0x04  
+#define PI1_STAT_DEVID 0x03
+#define PI1_STAT_NOINK 0x04
 #define PI1_STAT_ERROR 0x08
 #define PI1_STAT_ONLINE 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -47,18 +47,18 @@
  u8 _dmactrl[3];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  volatile u8 dmactrl;
-#define PI1_DMACTRL_FIFO_EMPTY 0x01  
-#define PI1_DMACTRL_ABORT 0x02  
-#define PI1_DMACTRL_STDMODE 0x00  
+#define PI1_DMACTRL_FIFO_EMPTY 0x01
+#define PI1_DMACTRL_ABORT 0x02
+#define PI1_DMACTRL_STDMODE 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI1_DMACTRL_SGIMODE 0x04  
-#define PI1_DMACTRL_RICOHMODE 0x08  
-#define PI1_DMACTRL_HPMODE 0x0c  
-#define PI1_DMACTRL_BLKMODE 0x10  
+#define PI1_DMACTRL_SGIMODE 0x04
+#define PI1_DMACTRL_RICOHMODE 0x08
+#define PI1_DMACTRL_HPMODE 0x0c
+#define PI1_DMACTRL_BLKMODE 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI1_DMACTRL_FIFO_CLEAR 0x20  
-#define PI1_DMACTRL_READ 0x40  
-#define PI1_DMACTRL_RUN 0x80  
+#define PI1_DMACTRL_FIFO_CLEAR 0x20
+#define PI1_DMACTRL_READ 0x40
+#define PI1_DMACTRL_RUN 0x80
  u8 _intstat[3];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  volatile u8 intstat;
diff --git a/libc/kernel/arch-mips/asm/sgiarcs.h b/libc/kernel/arch-mips/asm/sgiarcs.h
index 5fe0d47..b9fff3f 100644
--- a/libc/kernel/arch-mips/asm/sgiarcs.h
+++ b/libc/kernel/arch-mips/asm/sgiarcs.h
@@ -291,13 +291,13 @@
 #define SGIPROM_STDIN 0
 #define SGIPROM_STDOUT 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SGIPROM_ROFILE 0x01  
-#define SGIPROM_HFILE 0x02  
-#define SGIPROM_SFILE 0x04  
-#define SGIPROM_AFILE 0x08  
+#define SGIPROM_ROFILE 0x01
+#define SGIPROM_HFILE 0x02
+#define SGIPROM_SFILE 0x04
+#define SGIPROM_AFILE 0x08
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SGIPROM_DFILE 0x10  
-#define SGIPROM_DELFILE 0x20  
+#define SGIPROM_DFILE 0x10
+#define SGIPROM_DELFILE 0x20
 struct sgi_partition {
  unsigned char flag;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-mips/asm/shmparam.h b/libc/kernel/arch-mips/asm/shmparam.h
index d5ec78f..912ae04 100644
--- a/libc/kernel/arch-mips/asm/shmparam.h
+++ b/libc/kernel/arch-mips/asm/shmparam.h
@@ -19,6 +19,6 @@
 #ifndef _ASM_SHMPARAM_H
 #define _ASM_SHMPARAM_H
 #define __ARCH_FORCE_SHMLBA 1
-#define SHMLBA 0x40000  
+#define SHMLBA 0x40000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/arch-mips/asm/sibyte/bcm1480_int.h b/libc/kernel/arch-mips/asm/sibyte/bcm1480_int.h
index b14f1ca..276e569 100644
--- a/libc/kernel/arch-mips/asm/sibyte/bcm1480_int.h
+++ b/libc/kernel/arch-mips/asm/sibyte/bcm1480_int.h
@@ -244,7 +244,7 @@
 #define M_BCM1480_INT_GPIO_13 _BCM1480_INT_MASK1(K_BCM1480_INT_GPIO_13)
 #define M_BCM1480_INT_GPIO_14 _BCM1480_INT_MASK1(K_BCM1480_INT_GPIO_14)
 #define M_BCM1480_INT_GPIO_15 _BCM1480_INT_MASK1(K_BCM1480_INT_GPIO_15)
-#define K_BCM1480_INT_MAP_I0 0  
+#define K_BCM1480_INT_MAP_I0 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define K_BCM1480_INT_MAP_I1 1
 #define K_BCM1480_INT_MAP_I2 2
@@ -252,8 +252,8 @@
 #define K_BCM1480_INT_MAP_I4 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define K_BCM1480_INT_MAP_I5 5
-#define K_BCM1480_INT_MAP_NMI 6  
-#define K_BCM1480_INT_MAP_DINT 7  
+#define K_BCM1480_INT_MAP_NMI 6
+#define K_BCM1480_INT_MAP_DINT 7
 #define S_BCM1480_INT_HT_INTMSG 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define M_BCM1480_INT_HT_INTMSG _SB_MAKEMASK(3, S_BCM1480_INT_HT_INTMSG)
diff --git a/libc/kernel/arch-mips/asm/sibyte/bcm1480_scd.h b/libc/kernel/arch-mips/asm/sibyte/bcm1480_scd.h
index 250aca8..c70b282 100644
--- a/libc/kernel/arch-mips/asm/sibyte/bcm1480_scd.h
+++ b/libc/kernel/arch-mips/asm/sibyte/bcm1480_scd.h
@@ -104,7 +104,7 @@
 #define M_BCM1480_SCD_WDOG_RESET_TYPE _SB_MAKEMASK(5, S_BCM1480_SCD_WDOG_RESET_TYPE)
 #define V_BCM1480_SCD_WDOG_RESET_TYPE(x) _SB_MAKEVALUE(x, S_BCM1480_SCD_WDOG_RESET_TYPE)
 #define G_BCM1480_SCD_WDOG_RESET_TYPE(x) _SB_GETVALUE(x, S_BCM1480_SCD_WDOG_RESET_TYPE, M_BCM1480_SCD_WDOG_RESET_TYPE)
-#define K_BCM1480_SCD_WDOG_RESET_FULL 0  
+#define K_BCM1480_SCD_WDOG_RESET_FULL 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define K_BCM1480_SCD_WDOG_RESET_SOFT 1
 #define K_BCM1480_SCD_WDOG_RESET_CPU0 3
diff --git a/libc/kernel/arch-mips/asm/sibyte/sb1250_int.h b/libc/kernel/arch-mips/asm/sibyte/sb1250_int.h
index 0b01b75..8ffd35c 100644
--- a/libc/kernel/arch-mips/asm/sibyte/sb1250_int.h
+++ b/libc/kernel/arch-mips/asm/sibyte/sb1250_int.h
@@ -192,16 +192,16 @@
 #define M_INT_MAC_2_CH1 _SB_MAKEMASK1(K_INT_MAC_2_CH1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-#define K_INT_MAP_I0 0  
+#define K_INT_MAP_I0 0
 #define K_INT_MAP_I1 1
 #define K_INT_MAP_I2 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define K_INT_MAP_I3 3
 #define K_INT_MAP_I4 4
 #define K_INT_MAP_I5 5
-#define K_INT_MAP_NMI 6  
+#define K_INT_MAP_NMI 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define K_INT_MAP_DINT 7  
+#define K_INT_MAP_DINT 7
 #define S_INT_LDT_INTMSG 0
 #define M_INT_LDT_INTMSG _SB_MAKEMASK(3, S_INT_LDT_INTMSG)
 #define V_INT_LDT_INTMSG(x) _SB_MAKEVALUE(x, S_INT_LDT_INTMSG)
diff --git a/libc/kernel/arch-mips/asm/sibyte/sb1250_scd.h b/libc/kernel/arch-mips/asm/sibyte/sb1250_scd.h
index 55e4a5a..1e77979 100644
--- a/libc/kernel/arch-mips/asm/sibyte/sb1250_scd.h
+++ b/libc/kernel/arch-mips/asm/sibyte/sb1250_scd.h
@@ -28,13 +28,13 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define K_SYS_REVISION_BCM1250_PASS1 0x01
 #define K_SYS_REVISION_BCM1250_PASS2 0x03
-#define K_SYS_REVISION_BCM1250_A1 0x03  
-#define K_SYS_REVISION_BCM1250_A2 0x04  
+#define K_SYS_REVISION_BCM1250_A1 0x03
+#define K_SYS_REVISION_BCM1250_A2 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define K_SYS_REVISION_BCM1250_A3 0x05  
-#define K_SYS_REVISION_BCM1250_A4 0x06  
-#define K_SYS_REVISION_BCM1250_A6 0x07  
-#define K_SYS_REVISION_BCM1250_A8 0x0b  
+#define K_SYS_REVISION_BCM1250_A3 0x05
+#define K_SYS_REVISION_BCM1250_A4 0x06
+#define K_SYS_REVISION_BCM1250_A6 0x07
+#define K_SYS_REVISION_BCM1250_A8 0x0b
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define K_SYS_REVISION_BCM1250_A9 0x08
 #define K_SYS_REVISION_BCM1250_A10 K_SYS_REVISION_BCM1250_A8
@@ -107,11 +107,11 @@
 #define K_SYS_SOC_TYPE_BCM1250 0x0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define K_SYS_SOC_TYPE_BCM1120 0x1
-#define K_SYS_SOC_TYPE_BCM1250_ALT 0x2  
+#define K_SYS_SOC_TYPE_BCM1250_ALT 0x2
 #define K_SYS_SOC_TYPE_BCM1125 0x3
 #define K_SYS_SOC_TYPE_BCM1125H 0x4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define K_SYS_SOC_TYPE_BCM1250_ALT2 0x5  
+#define K_SYS_SOC_TYPE_BCM1250_ALT2 0x5
 #define K_SYS_SOC_TYPE_BCM1x80 0x6
 #define K_SYS_SOC_TYPE_BCM1x55 0x7
 #ifdef __ASSEMBLER__
@@ -262,7 +262,7 @@
 #define V_SCD_WDOG_RESET_TYPE(x) _SB_MAKEVALUE(x, S_SCD_WDOG_RESET_TYPE)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define G_SCD_WDOG_RESET_TYPE(x) _SB_GETVALUE(x, S_SCD_WDOG_RESET_TYPE, M_SCD_WDOG_RESET_TYPE)
-#define K_SCD_WDOG_RESET_FULL 0  
+#define K_SCD_WDOG_RESET_FULL 0
 #define K_SCD_WDOG_RESET_SOFT 1
 #define K_SCD_WDOG_RESET_CPU0 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-mips/asm/siginfo.h b/libc/kernel/arch-mips/asm/siginfo.h
index 8fdbf77..8412ac1 100644
--- a/libc/kernel/arch-mips/asm/siginfo.h
+++ b/libc/kernel/arch-mips/asm/siginfo.h
@@ -19,7 +19,7 @@
 #ifndef _ASM_SIGINFO_H
 #define _ASM_SIGINFO_H
 #define __ARCH_SIGEV_PREAMBLE_SIZE (sizeof(long) + 2*sizeof(int))
-#undef __ARCH_SI_TRAPNO  
+#undef __ARCH_SI_TRAPNO
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HAVE_ARCH_SIGINFO_T
 #define HAVE_ARCH_COPY_SIGINFO
@@ -91,8 +91,8 @@
 #undef SI_TIMER
 #undef SI_MESGQ
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SI_ASYNCIO -2  
-#define SI_TIMER __SI_CODE(__SI_TIMER, -3)  
-#define SI_MESGQ __SI_CODE(__SI_MESGQ, -4)  
+#define SI_ASYNCIO -2
+#define SI_TIMER __SI_CODE(__SI_TIMER, -3)
+#define SI_MESGQ __SI_CODE(__SI_MESGQ, -4)
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-mips/asm/signal.h b/libc/kernel/arch-mips/asm/signal.h
index 5f5ac77..5362d4a 100644
--- a/libc/kernel/arch-mips/asm/signal.h
+++ b/libc/kernel/arch-mips/asm/signal.h
@@ -29,49 +29,49 @@
  unsigned long sig[_NSIG_WORDS];
 } sigset_t;
 typedef unsigned long old_sigset_t;
-#define SIGHUP 1  
+#define SIGHUP 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIGINT 2  
-#define SIGQUIT 3  
-#define SIGILL 4  
-#define SIGTRAP 5  
+#define SIGINT 2
+#define SIGQUIT 3
+#define SIGILL 4
+#define SIGTRAP 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIGIOT 6  
-#define SIGABRT SIGIOT  
+#define SIGIOT 6
+#define SIGABRT SIGIOT
 #define SIGEMT 7
-#define SIGFPE 8  
+#define SIGFPE 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIGKILL 9  
-#define SIGBUS 10  
-#define SIGSEGV 11  
+#define SIGKILL 9
+#define SIGBUS 10
+#define SIGSEGV 11
 #define SIGSYS 12
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIGPIPE 13  
-#define SIGALRM 14  
-#define SIGTERM 15  
-#define SIGUSR1 16  
+#define SIGPIPE 13
+#define SIGALRM 14
+#define SIGTERM 15
+#define SIGUSR1 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIGUSR2 17  
-#define SIGCHLD 18  
-#define SIGCLD SIGCHLD  
-#define SIGPWR 19  
+#define SIGUSR2 17
+#define SIGCHLD 18
+#define SIGCLD SIGCHLD
+#define SIGPWR 19
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIGWINCH 20  
-#define SIGURG 21  
-#define SIGIO 22  
-#define SIGPOLL SIGIO  
+#define SIGWINCH 20
+#define SIGURG 21
+#define SIGIO 22
+#define SIGPOLL SIGIO
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIGSTOP 23  
-#define SIGTSTP 24  
-#define SIGCONT 25  
-#define SIGTTIN 26  
+#define SIGSTOP 23
+#define SIGTSTP 24
+#define SIGCONT 25
+#define SIGTTIN 26
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIGTTOU 27  
-#define SIGVTALRM 28  
-#define SIGPROF 29  
-#define SIGXCPU 30  
+#define SIGTTOU 27
+#define SIGVTALRM 28
+#define SIGPROF 29
+#define SIGXCPU 30
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIGXFSZ 31  
+#define SIGXFSZ 31
 #define SIGRTMIN 32
 #define SIGRTMAX _NSIG
 #define SA_ONSTACK 0x08000000
@@ -86,17 +86,17 @@
 #define SA_NOMASK SA_NODEFER
 #define SA_ONESHOT SA_RESETHAND
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SA_RESTORER 0x04000000  
+#define SA_RESTORER 0x04000000
 #define SS_ONSTACK 1
 #define SS_DISABLE 2
 #define MINSIGSTKSZ 2048
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SIGSTKSZ 8192
 struct siginfo;
-#define SIG_BLOCK 1  
-#define SIG_UNBLOCK 2  
+#define SIG_BLOCK 1
+#define SIG_UNBLOCK 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIG_SETMASK 3  
+#define SIG_SETMASK 3
 #include <asm-generic/signal.h>
 struct sigaction {
  unsigned int sa_flags;
diff --git a/libc/kernel/arch-mips/asm/smp.h b/libc/kernel/arch-mips/asm/smp.h
index 87eea88..f753e4f 100644
--- a/libc/kernel/arch-mips/asm/smp.h
+++ b/libc/kernel/arch-mips/asm/smp.h
@@ -31,7 +31,7 @@
 #define cpu_logical_map(cpu) __cpu_logical_map[cpu]
 #define NO_PROC_ID (-1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SMP_RESCHEDULE_YOURSELF 0x1  
+#define SMP_RESCHEDULE_YOURSELF 0x1
 #define SMP_CALL_FUNCTION 0x2
 #define cpu_possible_map phys_cpu_present_map
 #endif
diff --git a/libc/kernel/arch-mips/asm/sn/addrs.h b/libc/kernel/arch-mips/asm/sn/addrs.h
index d243613..543c7d5 100644
--- a/libc/kernel/arch-mips/asm/sn/addrs.h
+++ b/libc/kernel/arch-mips/asm/sn/addrs.h
@@ -68,12 +68,12 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NODE_SWIN_ADDR(nasid, addr)   (((addr) >= NODE_SWIN_BASE(nasid, 0)) &&   ((addr) < (NODE_SWIN_BASE(nasid, HUB_NUM_WIDGET) + SWIN_SIZE)  ))
 #define UALIAS_BASE HSPEC_BASE
-#define UALIAS_SIZE 0x10000000  
+#define UALIAS_SIZE 0x10000000
 #define UALIAS_LIMIT (UALIAS_BASE + UALIAS_SIZE)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HUB_REGISTER_WIDGET 1
 #define IALIAS_BASE NODE_SWIN_BASE(0, HUB_REGISTER_WIDGET)
-#define IALIAS_SIZE 0x800000  
+#define IALIAS_SIZE 0x800000
 #define IS_IALIAS(_a) (((_a) >= IALIAS_BASE) &&   ((_a) < (IALIAS_BASE + IALIAS_SIZE)))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NODE_BDOOR_BASE(_n) (NODE_HSPEC_BASE(_n) + (NODE_ADDRSPACE_SIZE/2))
@@ -116,7 +116,7 @@
 #define KLDIR_ADDR(nasid)   TO_NODE_UNCAC((nasid), KLDIR_OFFSET)
 #define KLDIR_SIZE 0x0400
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KLI_LAUNCH 0  
+#define KLI_LAUNCH 0
 #define KLI_KLCONFIG 1
 #define KLI_NMI 2
 #define KLI_GDA 3
diff --git a/libc/kernel/arch-mips/asm/sn/io.h b/libc/kernel/arch-mips/asm/sn/io.h
index 2b8a101..a3c3e17 100644
--- a/libc/kernel/arch-mips/asm/sn/io.h
+++ b/libc/kernel/arch-mips/asm/sn/io.h
@@ -18,23 +18,23 @@
  ****************************************************************************/
 #ifndef _ASM_SN_IO_H
 #define _ASM_SN_IO_H
-#define IIO_ITTE_BASE 0x400160  
+#define IIO_ITTE_BASE 0x400160
 #define IIO_ITTE(bigwin) (IIO_ITTE_BASE + 8*(bigwin))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_ITTE_OFFSET_BITS 5  
+#define IIO_ITTE_OFFSET_BITS 5
 #define IIO_ITTE_OFFSET_MASK ((1<<IIO_ITTE_OFFSET_BITS)-1)
 #define IIO_ITTE_OFFSET_SHIFT 0
-#define IIO_ITTE_WIDGET_BITS 4  
+#define IIO_ITTE_WIDGET_BITS 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IIO_ITTE_WIDGET_MASK ((1<<IIO_ITTE_WIDGET_BITS)-1)
 #define IIO_ITTE_WIDGET_SHIFT 8
-#define IIO_ITTE_IOSP 1  
+#define IIO_ITTE_IOSP 1
 #define IIO_ITTE_IOSP_MASK 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IIO_ITTE_IOSP_SHIFT 12
 #define HUB_PIO_MAP_TO_MEM 0
 #define HUB_PIO_MAP_TO_IO 1
-#define IIO_ITTE_INVALID_WIDGET 3  
+#define IIO_ITTE_INVALID_WIDGET 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IIO_ITTE_PUT(nasid, bigwin, io_or_mem, widget, addr)   REMOTE_HUB_S((nasid), IIO_ITTE(bigwin),   (((((addr) >> BWIN_SIZE_BITS) &   IIO_ITTE_OFFSET_MASK) << IIO_ITTE_OFFSET_SHIFT) |   (io_or_mem << IIO_ITTE_IOSP_SHIFT) |   (((widget) & IIO_ITTE_WIDGET_MASK) << IIO_ITTE_WIDGET_SHIFT)))
 #define IIO_ITTE_DISABLE(nasid, bigwin)   IIO_ITTE_PUT((nasid), HUB_PIO_MAP_TO_MEM,   (bigwin), IIO_ITTE_INVALID_WIDGET, 0)
diff --git a/libc/kernel/arch-mips/asm/sn/ioc3.h b/libc/kernel/arch-mips/asm/sn/ioc3.h
index 9771304..46ba4dd 100644
--- a/libc/kernel/arch-mips/asm/sn/ioc3.h
+++ b/libc/kernel/arch-mips/asm/sn/ioc3.h
@@ -193,21 +193,21 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ERXBUF_BYTECNT_SHIFT 16
 #define ERXBUF_V 0x80000000
-#define ERXBUF_CRCERR 0x00000001  
-#define ERXBUF_FRAMERR 0x00000002  
+#define ERXBUF_CRCERR 0x00000001
+#define ERXBUF_FRAMERR 0x00000002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ERXBUF_CODERR 0x00000004  
-#define ERXBUF_INVPREAMB 0x00000008  
-#define ERXBUF_LOLEN 0x00007000  
-#define ERXBUF_HILEN 0x03ff0000  
+#define ERXBUF_CODERR 0x00000004
+#define ERXBUF_INVPREAMB 0x00000008
+#define ERXBUF_LOLEN 0x00007000
+#define ERXBUF_HILEN 0x03ff0000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ERXBUF_MULTICAST 0x04000000  
-#define ERXBUF_BROADCAST 0x08000000  
-#define ERXBUF_LONGEVENT 0x10000000  
-#define ERXBUF_BADPKT 0x20000000  
+#define ERXBUF_MULTICAST 0x04000000
+#define ERXBUF_BROADCAST 0x08000000
+#define ERXBUF_LONGEVENT 0x10000000
+#define ERXBUF_BADPKT 0x20000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ERXBUF_GOODPKT 0x40000000  
-#define ERXBUF_CARRIER 0x80000000  
+#define ERXBUF_GOODPKT 0x40000000
+#define ERXBUF_CARRIER 0x80000000
 #define ETXD_DATALEN 104
 struct ioc3_etxd {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -218,15 +218,15 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  u8 data[ETXD_DATALEN];
 };
-#define ETXD_BYTECNT_MASK 0x000007ff  
-#define ETXD_INTWHENDONE 0x00001000  
+#define ETXD_BYTECNT_MASK 0x000007ff
+#define ETXD_INTWHENDONE 0x00001000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETXD_D0V 0x00010000  
-#define ETXD_B1V 0x00020000  
-#define ETXD_B2V 0x00040000  
-#define ETXD_DOCHECKSUM 0x00080000  
+#define ETXD_D0V 0x00010000
+#define ETXD_B1V 0x00020000
+#define ETXD_B2V 0x00040000
+#define ETXD_DOCHECKSUM 0x00080000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETXD_CHKOFF_MASK 0x07f00000  
+#define ETXD_CHKOFF_MASK 0x07f00000
 #define ETXD_CHKOFF_SHIFT 20
 #define ETXD_D0CNT_MASK 0x0000007f
 #define ETXD_B1CNT_MASK 0x0007ff00
@@ -241,22 +241,22 @@
 #define IOC3_BYTEBUS_DEV3 0xe0000L
 #define IOC3_SIO_BASE 0x20000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IOC3_SIO_UARTC (IOC3_SIO_BASE+0x141)  
-#define IOC3_SIO_KBDCG (IOC3_SIO_BASE+0x142)  
-#define IOC3_SIO_PP_BASE (IOC3_SIO_BASE+PP_BASE)  
-#define IOC3_SIO_RTC_BASE (IOC3_SIO_BASE+0x168)  
+#define IOC3_SIO_UARTC (IOC3_SIO_BASE+0x141)
+#define IOC3_SIO_KBDCG (IOC3_SIO_BASE+0x142)
+#define IOC3_SIO_PP_BASE (IOC3_SIO_BASE+PP_BASE)
+#define IOC3_SIO_RTC_BASE (IOC3_SIO_BASE+0x168)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IOC3_SIO_UB_BASE (IOC3_SIO_BASE+UARTB_BASE)  
-#define IOC3_SIO_UA_BASE (IOC3_SIO_BASE+UARTA_BASE)  
-#define IOC3_SSRAM IOC3_RAM_OFF  
-#define IOC3_SSRAM_LEN 0x40000  
+#define IOC3_SIO_UB_BASE (IOC3_SIO_BASE+UARTB_BASE)
+#define IOC3_SIO_UA_BASE (IOC3_SIO_BASE+UARTA_BASE)
+#define IOC3_SSRAM IOC3_RAM_OFF
+#define IOC3_SSRAM_LEN 0x40000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IOC3_SSRAM_DM 0x0000ffff  
-#define IOC3_SSRAM_PM 0x00010000  
-#define PCI_SCR_PAR_RESP_EN 0x00000040  
-#define PCI_SCR_SERR_EN 0x00000100  
+#define IOC3_SSRAM_DM 0x0000ffff
+#define IOC3_SSRAM_PM 0x00010000
+#define PCI_SCR_PAR_RESP_EN 0x00000040
+#define PCI_SCR_SERR_EN 0x00000100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_SCR_DROP_MODE_EN 0x00008000  
+#define PCI_SCR_DROP_MODE_EN 0x00008000
 #define PCI_SCR_RX_SERR (0x1 << 16)
 #define PCI_SCR_DROP_MODE (0x1 << 17)
 #define PCI_SCR_SIG_PAR_ERR (0x1 << 24)
@@ -267,158 +267,158 @@
 #define PCI_SCR_SIG_SERR (0x1 << 30)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_SCR_PAR_ERR (0x1 << 31)
-#define KM_CSR_K_WRT_PEND 0x00000001  
-#define KM_CSR_M_WRT_PEND 0x00000002  
-#define KM_CSR_K_LCB 0x00000004  
+#define KM_CSR_K_WRT_PEND 0x00000001
+#define KM_CSR_M_WRT_PEND 0x00000002
+#define KM_CSR_K_LCB 0x00000004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KM_CSR_M_LCB 0x00000008  
-#define KM_CSR_K_DATA 0x00000010  
-#define KM_CSR_K_CLK 0x00000020  
-#define KM_CSR_K_PULL_DATA 0x00000040  
+#define KM_CSR_M_LCB 0x00000008
+#define KM_CSR_K_DATA 0x00000010
+#define KM_CSR_K_CLK 0x00000020
+#define KM_CSR_K_PULL_DATA 0x00000040
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KM_CSR_K_PULL_CLK 0x00000080  
-#define KM_CSR_M_DATA 0x00000100  
-#define KM_CSR_M_CLK 0x00000200  
-#define KM_CSR_M_PULL_DATA 0x00000400  
+#define KM_CSR_K_PULL_CLK 0x00000080
+#define KM_CSR_M_DATA 0x00000100
+#define KM_CSR_M_CLK 0x00000200
+#define KM_CSR_M_PULL_DATA 0x00000400
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KM_CSR_M_PULL_CLK 0x00000800  
-#define KM_CSR_EMM_MODE 0x00001000  
-#define KM_CSR_SIM_MODE 0x00002000  
-#define KM_CSR_K_SM_IDLE 0x00004000  
+#define KM_CSR_M_PULL_CLK 0x00000800
+#define KM_CSR_EMM_MODE 0x00001000
+#define KM_CSR_SIM_MODE 0x00002000
+#define KM_CSR_K_SM_IDLE 0x00004000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KM_CSR_M_SM_IDLE 0x00008000  
-#define KM_CSR_K_TO 0x00010000  
-#define KM_CSR_M_TO 0x00020000  
-#define KM_CSR_K_TO_EN 0x00040000  
+#define KM_CSR_M_SM_IDLE 0x00008000
+#define KM_CSR_K_TO 0x00010000
+#define KM_CSR_M_TO 0x00020000
+#define KM_CSR_K_TO_EN 0x00040000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KM_CSR_M_TO_EN 0x00080000  
-#define KM_CSR_K_CLAMP_ONE 0x00100000  
-#define KM_CSR_M_CLAMP_ONE 0x00200000  
-#define KM_CSR_K_CLAMP_THREE 0x00400000  
+#define KM_CSR_M_TO_EN 0x00080000
+#define KM_CSR_K_CLAMP_ONE 0x00100000
+#define KM_CSR_M_CLAMP_ONE 0x00200000
+#define KM_CSR_K_CLAMP_THREE 0x00400000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KM_CSR_M_CLAMP_THREE 0x00800000  
-#define KM_RD_DATA_2 0x000000ff  
+#define KM_CSR_M_CLAMP_THREE 0x00800000
+#define KM_RD_DATA_2 0x000000ff
 #define KM_RD_DATA_2_SHIFT 0
-#define KM_RD_DATA_1 0x0000ff00  
+#define KM_RD_DATA_1 0x0000ff00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KM_RD_DATA_1_SHIFT 8
-#define KM_RD_DATA_0 0x00ff0000  
+#define KM_RD_DATA_0 0x00ff0000
 #define KM_RD_DATA_0_SHIFT 16
-#define KM_RD_FRAME_ERR_2 0x01000000  
+#define KM_RD_FRAME_ERR_2 0x01000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KM_RD_FRAME_ERR_1 0x02000000  
-#define KM_RD_FRAME_ERR_0 0x04000000  
-#define KM_RD_KBD_MSE 0x08000000  
-#define KM_RD_OFLO 0x10000000  
+#define KM_RD_FRAME_ERR_1 0x02000000
+#define KM_RD_FRAME_ERR_0 0x04000000
+#define KM_RD_KBD_MSE 0x08000000
+#define KM_RD_OFLO 0x10000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KM_RD_VALID_2 0x20000000  
-#define KM_RD_VALID_1 0x40000000  
-#define KM_RD_VALID_0 0x80000000  
+#define KM_RD_VALID_2 0x20000000
+#define KM_RD_VALID_1 0x40000000
+#define KM_RD_VALID_0 0x80000000
 #define KM_RD_VALID_ALL (KM_RD_VALID_0|KM_RD_VALID_1|KM_RD_VALID_2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KM_WD_WRT_DATA 0x000000ff  
+#define KM_WD_WRT_DATA 0x000000ff
 #define KM_WD_WRT_DATA_SHIFT 0
-#define RXSB_OVERRUN 0x01  
-#define RXSB_PAR_ERR 0x02  
+#define RXSB_OVERRUN 0x01
+#define RXSB_PAR_ERR 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RXSB_FRAME_ERR 0x04  
-#define RXSB_BREAK 0x08  
-#define RXSB_CTS 0x10  
-#define RXSB_DCD 0x20  
+#define RXSB_FRAME_ERR 0x04
+#define RXSB_BREAK 0x08
+#define RXSB_CTS 0x10
+#define RXSB_DCD 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RXSB_MODEM_VALID 0x40  
-#define RXSB_DATA_VALID 0x80  
-#define TXCB_INT_WHEN_DONE 0x20  
-#define TXCB_INVALID 0x00  
+#define RXSB_MODEM_VALID 0x40
+#define RXSB_DATA_VALID 0x80
+#define TXCB_INT_WHEN_DONE 0x20
+#define TXCB_INVALID 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TXCB_VALID 0x40  
-#define TXCB_MCR 0x80  
-#define TXCB_DELAY 0xc0  
-#define SBBR_L_SIZE 0x00000001  
+#define TXCB_VALID 0x40
+#define TXCB_MCR 0x80
+#define TXCB_DELAY 0xc0
+#define SBBR_L_SIZE 0x00000001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SBBR_L_BASE 0xfffff000  
-#define SSCR_RX_THRESHOLD 0x000001ff  
-#define SSCR_TX_TIMER_BUSY 0x00010000  
-#define SSCR_HFC_EN 0x00020000  
+#define SBBR_L_BASE 0xfffff000
+#define SSCR_RX_THRESHOLD 0x000001ff
+#define SSCR_TX_TIMER_BUSY 0x00010000
+#define SSCR_HFC_EN 0x00020000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SSCR_RX_RING_DCD 0x00040000  
-#define SSCR_RX_RING_CTS 0x00080000  
-#define SSCR_HIGH_SPD 0x00100000  
-#define SSCR_DIAG 0x00200000  
+#define SSCR_RX_RING_DCD 0x00040000
+#define SSCR_RX_RING_CTS 0x00080000
+#define SSCR_HIGH_SPD 0x00100000
+#define SSCR_DIAG 0x00200000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SSCR_RX_DRAIN 0x08000000  
-#define SSCR_DMA_EN 0x10000000  
-#define SSCR_DMA_PAUSE 0x20000000  
-#define SSCR_PAUSE_STATE 0x40000000  
+#define SSCR_RX_DRAIN 0x08000000
+#define SSCR_DMA_EN 0x10000000
+#define SSCR_DMA_PAUSE 0x20000000
+#define SSCR_PAUSE_STATE 0x40000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SSCR_RESET 0x80000000  
-#define PROD_CONS_PTR_4K 0x00000ff8  
-#define PROD_CONS_PTR_1K 0x000003f8  
+#define SSCR_RESET 0x80000000
+#define PROD_CONS_PTR_4K 0x00000ff8
+#define PROD_CONS_PTR_1K 0x000003f8
 #define PROD_CONS_PTR_OFF 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SRCIR_ARM 0x80000000  
-#define SRPIR_BYTE_CNT 0x07000000  
+#define SRCIR_ARM 0x80000000
+#define SRPIR_BYTE_CNT 0x07000000
 #define SRPIR_BYTE_CNT_SHIFT 24
-#define STCIR_BYTE_CNT 0x0f000000  
+#define STCIR_BYTE_CNT 0x0f000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define STCIR_BYTE_CNT_SHIFT 24
-#define SHADOW_DR 0x00000001  
-#define SHADOW_OE 0x00000002  
-#define SHADOW_PE 0x00000004  
+#define SHADOW_DR 0x00000001
+#define SHADOW_OE 0x00000002
+#define SHADOW_PE 0x00000004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHADOW_FE 0x00000008  
-#define SHADOW_BI 0x00000010  
-#define SHADOW_THRE 0x00000020  
-#define SHADOW_TEMT 0x00000040  
+#define SHADOW_FE 0x00000008
+#define SHADOW_BI 0x00000010
+#define SHADOW_THRE 0x00000020
+#define SHADOW_TEMT 0x00000040
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHADOW_RFCE 0x00000080  
-#define SHADOW_DCTS 0x00010000  
-#define SHADOW_DDCD 0x00080000  
-#define SHADOW_CTS 0x00100000  
+#define SHADOW_RFCE 0x00000080
+#define SHADOW_DCTS 0x00010000
+#define SHADOW_DDCD 0x00080000
+#define SHADOW_CTS 0x00100000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHADOW_DCD 0x00800000  
-#define SHADOW_DTR 0x01000000  
-#define SHADOW_RTS 0x02000000  
-#define SHADOW_OUT1 0x04000000  
+#define SHADOW_DCD 0x00800000
+#define SHADOW_DTR 0x01000000
+#define SHADOW_RTS 0x02000000
+#define SHADOW_OUT1 0x04000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHADOW_OUT2 0x08000000  
-#define SHADOW_LOOP 0x10000000  
-#define SRTR_CNT 0x00000fff  
-#define SRTR_CNT_VAL 0x0fff0000  
+#define SHADOW_OUT2 0x08000000
+#define SHADOW_LOOP 0x10000000
+#define SRTR_CNT 0x00000fff
+#define SRTR_CNT_VAL 0x0fff0000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SRTR_CNT_VAL_SHIFT 16
-#define SRTR_HZ 16000  
-#define SIO_IR_SA_TX_MT 0x00000001  
-#define SIO_IR_SA_RX_FULL 0x00000002  
+#define SRTR_HZ 16000
+#define SIO_IR_SA_TX_MT 0x00000001
+#define SIO_IR_SA_RX_FULL 0x00000002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIO_IR_SA_RX_HIGH 0x00000004  
-#define SIO_IR_SA_RX_TIMER 0x00000008  
-#define SIO_IR_SA_DELTA_DCD 0x00000010  
-#define SIO_IR_SA_DELTA_CTS 0x00000020  
+#define SIO_IR_SA_RX_HIGH 0x00000004
+#define SIO_IR_SA_RX_TIMER 0x00000008
+#define SIO_IR_SA_DELTA_DCD 0x00000010
+#define SIO_IR_SA_DELTA_CTS 0x00000020
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIO_IR_SA_INT 0x00000040  
-#define SIO_IR_SA_TX_EXPLICIT 0x00000080  
-#define SIO_IR_SA_MEMERR 0x00000100  
-#define SIO_IR_SB_TX_MT 0x00000200  
+#define SIO_IR_SA_INT 0x00000040
+#define SIO_IR_SA_TX_EXPLICIT 0x00000080
+#define SIO_IR_SA_MEMERR 0x00000100
+#define SIO_IR_SB_TX_MT 0x00000200
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIO_IR_SB_RX_FULL 0x00000400  
-#define SIO_IR_SB_RX_HIGH 0x00000800  
-#define SIO_IR_SB_RX_TIMER 0x00001000  
-#define SIO_IR_SB_DELTA_DCD 0x00002000  
+#define SIO_IR_SB_RX_FULL 0x00000400
+#define SIO_IR_SB_RX_HIGH 0x00000800
+#define SIO_IR_SB_RX_TIMER 0x00001000
+#define SIO_IR_SB_DELTA_DCD 0x00002000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIO_IR_SB_DELTA_CTS 0x00004000  
-#define SIO_IR_SB_INT 0x00008000  
-#define SIO_IR_SB_TX_EXPLICIT 0x00010000  
-#define SIO_IR_SB_MEMERR 0x00020000  
+#define SIO_IR_SB_DELTA_CTS 0x00004000
+#define SIO_IR_SB_INT 0x00008000
+#define SIO_IR_SB_TX_EXPLICIT 0x00010000
+#define SIO_IR_SB_MEMERR 0x00020000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIO_IR_PP_INT 0x00040000  
-#define SIO_IR_PP_INTA 0x00080000  
-#define SIO_IR_PP_INTB 0x00100000  
-#define SIO_IR_PP_MEMERR 0x00200000  
+#define SIO_IR_PP_INT 0x00040000
+#define SIO_IR_PP_INTA 0x00080000
+#define SIO_IR_PP_INTB 0x00100000
+#define SIO_IR_PP_MEMERR 0x00200000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIO_IR_KBD_INT 0x00400000  
-#define SIO_IR_RT_INT 0x08000000  
-#define SIO_IR_GEN_INT1 0x10000000  
+#define SIO_IR_KBD_INT 0x00400000
+#define SIO_IR_RT_INT 0x08000000
+#define SIO_IR_GEN_INT1 0x10000000
 #define SIO_IR_GEN_INT_SHIFT 28
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SIO_IR_SA (SIO_IR_SA_TX_MT | SIO_IR_SA_RX_FULL |   SIO_IR_SA_RX_HIGH | SIO_IR_SA_RX_TIMER |   SIO_IR_SA_DELTA_DCD | SIO_IR_SA_DELTA_CTS |   SIO_IR_SA_INT | SIO_IR_SA_TX_EXPLICIT |   SIO_IR_SA_MEMERR)
@@ -427,61 +427,61 @@
 #define SIO_IR_RT (SIO_IR_RT_INT | SIO_IR_GEN_INT1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IOC3_PENDING_INTRS(mem) (PCI_INW(&((mem)->sio_ir)) &   PCI_INW(&((mem)->sio_ies_ro)))
-#define SIO_CR_SIO_RESET 0x00000001  
-#define SIO_CR_SER_A_BASE 0x000000fe  
+#define SIO_CR_SIO_RESET 0x00000001
+#define SIO_CR_SER_A_BASE 0x000000fe
 #define SIO_CR_SER_A_BASE_SHIFT 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIO_CR_SER_B_BASE 0x00007f00  
+#define SIO_CR_SER_B_BASE 0x00007f00
 #define SIO_CR_SER_B_BASE_SHIFT 8
-#define SIO_SR_CMD_PULSE 0x00078000  
+#define SIO_SR_CMD_PULSE 0x00078000
 #define SIO_CR_CMD_PULSE_SHIFT 15
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIO_CR_ARB_DIAG 0x00380000  
+#define SIO_CR_ARB_DIAG 0x00380000
 #define SIO_CR_ARB_DIAG_TXA 0x00000000
 #define SIO_CR_ARB_DIAG_RXA 0x00080000
 #define SIO_CR_ARB_DIAG_TXB 0x00100000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SIO_CR_ARB_DIAG_RXB 0x00180000
 #define SIO_CR_ARB_DIAG_PP 0x00200000
-#define SIO_CR_ARB_DIAG_IDLE 0x00400000  
-#define INT_OUT_COUNT 0x0000ffff  
+#define SIO_CR_ARB_DIAG_IDLE 0x00400000
+#define INT_OUT_COUNT 0x0000ffff
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define INT_OUT_MODE 0x00070000  
-#define INT_OUT_MODE_0 0x00000000  
-#define INT_OUT_MODE_1 0x00040000  
-#define INT_OUT_MODE_1PULSE 0x00050000  
+#define INT_OUT_MODE 0x00070000
+#define INT_OUT_MODE_0 0x00000000
+#define INT_OUT_MODE_1 0x00040000
+#define INT_OUT_MODE_1PULSE 0x00050000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define INT_OUT_MODE_PULSES 0x00060000  
-#define INT_OUT_MODE_SQW 0x00070000  
-#define INT_OUT_DIAG 0x40000000  
-#define INT_OUT_INT_OUT 0x80000000  
+#define INT_OUT_MODE_PULSES 0x00060000
+#define INT_OUT_MODE_SQW 0x00070000
+#define INT_OUT_DIAG 0x40000000
+#define INT_OUT_INT_OUT 0x80000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define INT_OUT_NS_PER_TICK (30 * 260)  
-#define INT_OUT_TICKS_PER_PULSE 3  
+#define INT_OUT_NS_PER_TICK (30 * 260)
+#define INT_OUT_TICKS_PER_PULSE 3
 #define INT_OUT_US_TO_COUNT(x)     (((x) * 10 + INT_OUT_NS_PER_TICK / 200) *   100 / INT_OUT_NS_PER_TICK - 1)
 #define INT_OUT_COUNT_TO_US(x)     (((x) + 1) * INT_OUT_NS_PER_TICK / 1000)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define INT_OUT_MIN_TICKS 3  
-#define INT_OUT_MAX_TICKS INT_OUT_COUNT  
-#define GPCR_DIR 0x000000ff  
-#define GPCR_DIR_PIN(x) (1<<(x))  
+#define INT_OUT_MIN_TICKS 3
+#define INT_OUT_MAX_TICKS INT_OUT_COUNT
+#define GPCR_DIR 0x000000ff
+#define GPCR_DIR_PIN(x) (1<<(x))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define GPCR_EDGE 0x000f0000  
-#define GPCR_EDGE_PIN(x) (1<<((x)+15))  
-#define GPCR_INT_OUT_EN 0x00100000  
-#define GPCR_MLAN_EN 0x00200000  
+#define GPCR_EDGE 0x000f0000
+#define GPCR_EDGE_PIN(x) (1<<((x)+15))
+#define GPCR_INT_OUT_EN 0x00100000
+#define GPCR_MLAN_EN 0x00200000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define GPCR_DIR_SERA_XCVR 0x00000080  
-#define GPCR_DIR_SERB_XCVR 0x00000040  
-#define GPCR_DIR_PHY_RST 0x00000020  
-#define GPCR_PHY_RESET 0x20  
+#define GPCR_DIR_SERA_XCVR 0x00000080
+#define GPCR_DIR_SERB_XCVR 0x00000040
+#define GPCR_DIR_PHY_RST 0x00000020
+#define GPCR_PHY_RESET 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define GPCR_UARTB_MODESEL 0x40  
-#define GPCR_UARTA_MODESEL 0x80  
-#define GPPR_PHY_RESET_PIN 5  
-#define GPPR_UARTB_MODESEL_PIN 6  
+#define GPCR_UARTB_MODESEL 0x40
+#define GPCR_UARTA_MODESEL 0x80
+#define GPPR_PHY_RESET_PIN 5
+#define GPPR_UARTB_MODESEL_PIN 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define GPPR_UARTA_MODESEL_PIN 7  
+#define GPPR_UARTA_MODESEL_PIN 7
 #define EMCR_DUPLEX 0x00000001
 #define EMCR_PROMISC 0x00000002
 #define EMCR_PADEN 0x00000004
@@ -523,10 +523,10 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EISR_TXMEMERR 0x02000000
 #define EISR_TXPARERR 0x04000000
-#define ERCSR_THRESH_MASK 0x000001ff  
-#define ERCSR_RX_TMR 0x40000000  
+#define ERCSR_THRESH_MASK 0x000001ff
+#define ERCSR_RX_TMR 0x40000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ERCSR_DIAG_OFLO 0x80000000  
+#define ERCSR_DIAG_OFLO 0x80000000
 #define ERBR_ALIGNMENT 4096
 #define ERBR_L_RXRINGBASE_MASK 0xfffff000
 #define ERBAR_BARRIER_BIT 0x0100
@@ -581,29 +581,29 @@
 #define ERXBUF_BYTECNT_SHIFT 16
 #define ERXBUF_V 0x80000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ERXBUF_CRCERR 0x00000001  
-#define ERXBUF_FRAMERR 0x00000002  
-#define ERXBUF_CODERR 0x00000004  
-#define ERXBUF_INVPREAMB 0x00000008  
+#define ERXBUF_CRCERR 0x00000001
+#define ERXBUF_FRAMERR 0x00000002
+#define ERXBUF_CODERR 0x00000004
+#define ERXBUF_INVPREAMB 0x00000008
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ERXBUF_LOLEN 0x00007000  
-#define ERXBUF_HILEN 0x03ff0000  
-#define ERXBUF_MULTICAST 0x04000000  
-#define ERXBUF_BROADCAST 0x08000000  
+#define ERXBUF_LOLEN 0x00007000
+#define ERXBUF_HILEN 0x03ff0000
+#define ERXBUF_MULTICAST 0x04000000
+#define ERXBUF_BROADCAST 0x08000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ERXBUF_LONGEVENT 0x10000000  
-#define ERXBUF_BADPKT 0x20000000  
-#define ERXBUF_GOODPKT 0x40000000  
-#define ERXBUF_CARRIER 0x80000000  
+#define ERXBUF_LONGEVENT 0x10000000
+#define ERXBUF_BADPKT 0x20000000
+#define ERXBUF_GOODPKT 0x40000000
+#define ERXBUF_CARRIER 0x80000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETXD_BYTECNT_MASK 0x000007ff  
-#define ETXD_INTWHENDONE 0x00001000  
-#define ETXD_D0V 0x00010000  
-#define ETXD_B1V 0x00020000  
+#define ETXD_BYTECNT_MASK 0x000007ff
+#define ETXD_INTWHENDONE 0x00001000
+#define ETXD_D0V 0x00010000
+#define ETXD_B1V 0x00020000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETXD_B2V 0x00040000  
-#define ETXD_DOCHECKSUM 0x00080000  
-#define ETXD_CHKOFF_MASK 0x07f00000  
+#define ETXD_B2V 0x00040000
+#define ETXD_DOCHECKSUM 0x00080000
+#define ETXD_CHKOFF_MASK 0x07f00000
 #define ETXD_CHKOFF_SHIFT 20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETXD_D0CNT_MASK 0x0000007f
diff --git a/libc/kernel/arch-mips/asm/sn/kldir.h b/libc/kernel/arch-mips/asm/sn/kldir.h
index 6c663ca..ef41013 100644
--- a/libc/kernel/arch-mips/asm/sn/kldir.h
+++ b/libc/kernel/arch-mips/asm/sn/kldir.h
@@ -79,7 +79,7 @@
 #ifndef __ASSEMBLY__
 typedef struct kldir_ent_s {
  u64 magic;
- off_t offset;
+ __kernel_off_t offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long pointer;
  size_t size;
diff --git a/libc/kernel/arch-mips/asm/sn/sn0/addrs.h b/libc/kernel/arch-mips/asm/sn/sn0/addrs.h
index 5c056ed..8e29419 100644
--- a/libc/kernel/arch-mips/asm/sn/sn0/addrs.h
+++ b/libc/kernel/arch-mips/asm/sn/sn0/addrs.h
@@ -119,15 +119,15 @@
 #define IO6DPROM_SIZE 0x200000
 #define NODEBUGUNIX_ADDR PHYS_TO_K0(0x00019000)
 #define DEBUGUNIX_ADDR PHYS_TO_K0(0x00100000)
-#define IP27PROM_INT_LAUNCH 10  
+#define IP27PROM_INT_LAUNCH 10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IP27PROM_INT_NETUART 12  
+#define IP27PROM_INT_NETUART 12
 #endif
 #define IP27PROM_ELSC_SHFT 10
 #define IP27PROM_ELSC_SIZE (1 << IP27PROM_ELSC_SHFT)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FREEMEM_BASE PHYS_TO_K0(0x2000000)
-#define IO6PROM_STACK_SHFT 14  
+#define IO6PROM_STACK_SHFT 14
 #define IO6PROM_STACK_SIZE (1 << IO6PROM_STACK_SHFT)
 #define IP27PROM_ENTRY PHYS_TO_COMPATK1(0x1fc00000)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -142,11 +142,11 @@
 #define IP27PROM_WAITSLAVE PHYS_TO_COMPATK1(0x1fc00040)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IP27PROM_POLLSLAVE PHYS_TO_COMPATK1(0x1fc00048)
-#define KL_UART_BASE LOCAL_HUB_ADDR(MD_UREG0_0)  
-#define KL_UART_CMD LOCAL_HUB_ADDR(MD_UREG0_0)  
-#define KL_UART_DATA LOCAL_HUB_ADDR(MD_UREG0_1)  
+#define KL_UART_BASE LOCAL_HUB_ADDR(MD_UREG0_0)
+#define KL_UART_CMD LOCAL_HUB_ADDR(MD_UREG0_0)
+#define KL_UART_DATA LOCAL_HUB_ADDR(MD_UREG0_1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KL_I2C_REG MD_UREG0_0  
+#define KL_I2C_REG MD_UREG0_0
 #ifndef __ASSEMBLY__
 #ifdef HUB_ERR_STS_WAR
 #define CACHE_ERR_EFRAME 0x480
@@ -156,7 +156,7 @@
 #endif
 #define CACHE_ERR_ECCFRAME (CACHE_ERR_EFRAME + EF_SIZE)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CACHE_ERR_SP_PTR (0x1000 - 32)  
+#define CACHE_ERR_SP_PTR (0x1000 - 32)
 #define CACHE_ERR_IBASE_PTR (0x1000 - 40)
 #define CACHE_ERR_SP (CACHE_ERR_SP_PTR - 16)
 #define CACHE_ERR_AREA_SIZE (ARCS_SPB_OFFSET - CACHE_ERR_EFRAME)
diff --git a/libc/kernel/arch-mips/asm/sn/sn0/hubio.h b/libc/kernel/arch-mips/asm/sn/sn0/hubio.h
index f593233..eadbea9 100644
--- a/libc/kernel/arch-mips/asm/sn/sn0/hubio.h
+++ b/libc/kernel/arch-mips/asm/sn/sn0/hubio.h
@@ -18,41 +18,41 @@
  ****************************************************************************/
 #ifndef _ASM_SGI_SN_SN0_HUBIO_H
 #define _ASM_SGI_SN_SN0_HUBIO_H
-#define IIO_WIDGET IIO_WID  
-#define IIO_WIDGET_STAT IIO_WSTAT  
+#define IIO_WIDGET IIO_WID
+#define IIO_WIDGET_STAT IIO_WSTAT
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_WIDGET_CTRL IIO_WCR  
-#define IIO_WIDGET_TOUT IIO_WRTO  
-#define IIO_WIDGET_FLUSH IIO_WTFR  
-#define IIO_PROTECT IIO_ILAPR  
+#define IIO_WIDGET_CTRL IIO_WCR
+#define IIO_WIDGET_TOUT IIO_WRTO
+#define IIO_WIDGET_FLUSH IIO_WTFR
+#define IIO_PROTECT IIO_ILAPR
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_PROTECT_OVRRD IIO_ILAPO  
-#define IIO_OUTWIDGET_ACCESS IIO_IOWA  
-#define IIO_INWIDGET_ACCESS IIO_IIWA  
-#define IIO_INDEV_ERR_MASK IIO_IIDEM  
+#define IIO_PROTECT_OVRRD IIO_ILAPO
+#define IIO_OUTWIDGET_ACCESS IIO_IOWA
+#define IIO_INWIDGET_ACCESS IIO_IIWA
+#define IIO_INDEV_ERR_MASK IIO_IIDEM
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_LLP_CSR IIO_ILCSR  
-#define IIO_LLP_LOG IIO_ILLR  
-#define IIO_XTALKCC_TOUT IIO_IXCC  
-#define IIO_XTALKTT_TOUT IIO_IXTT  
+#define IIO_LLP_CSR IIO_ILCSR
+#define IIO_LLP_LOG IIO_ILLR
+#define IIO_XTALKCC_TOUT IIO_IXCC
+#define IIO_XTALKTT_TOUT IIO_IXTT
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_IO_ERR_CLR IIO_IECLR  
-#define IIO_BTE_CRB_CNT IIO_IBCN  
+#define IIO_IO_ERR_CLR IIO_IECLR
+#define IIO_BTE_CRB_CNT IIO_IBCN
 #define IIO_LLP_CSR_IS_UP 0x00002000
 #define IIO_LLP_CSR_LLP_STAT_MASK 0x00003000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IIO_LLP_CSR_LLP_STAT_SHFT 12
-#define IIO_PROTECT_OVRRD_KEY 0x53474972756c6573ull  
-#define IIO_BTE_STAT_0 IIO_IBLS_0  
-#define IIO_BTE_SRC_0 IIO_IBSA_0  
+#define IIO_PROTECT_OVRRD_KEY 0x53474972756c6573ull
+#define IIO_BTE_STAT_0 IIO_IBLS_0
+#define IIO_BTE_SRC_0 IIO_IBSA_0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_BTE_DEST_0 IIO_IBDA_0  
-#define IIO_BTE_CTRL_0 IIO_IBCT_0  
-#define IIO_BTE_NOTIFY_0 IIO_IBNA_0  
-#define IIO_BTE_INT_0 IIO_IBIA_0  
+#define IIO_BTE_DEST_0 IIO_IBDA_0
+#define IIO_BTE_CTRL_0 IIO_IBCT_0
+#define IIO_BTE_NOTIFY_0 IIO_IBNA_0
+#define IIO_BTE_INT_0 IIO_IBIA_0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_BTE_OFF_0 0  
-#define IIO_BTE_OFF_1 IIO_IBLS_1 - IIO_IBLS_0  
+#define IIO_BTE_OFF_0 0
+#define IIO_BTE_OFF_1 IIO_IBLS_1 - IIO_IBLS_0
 #define BTEOFF_STAT 0
 #define BTEOFF_SRC (IIO_BTE_SRC_0 - IIO_BTE_STAT_0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -68,27 +68,27 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IIO_PERF_CNT 0x430008
 #define IO_PERF_SETS 32
-#define IIO_WID 0x400000  
-#define IIO_WSTAT 0x400008  
+#define IIO_WID 0x400000
+#define IIO_WSTAT 0x400008
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_WCR 0x400020  
-#define IIO_WSTAT_ECRAZY (1ULL << 32)  
-#define IIO_WSTAT_TXRETRY (1ULL << 9)  
+#define IIO_WCR 0x400020
+#define IIO_WSTAT_ECRAZY (1ULL << 32)
+#define IIO_WSTAT_TXRETRY (1ULL << 9)
 #define IIO_WSTAT_TXRETRY_MASK (0x7F)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IIO_WSTAT_TXRETRY_SHFT (16)
 #define IIO_WSTAT_TXRETRY_CNT(w) (((w) >> IIO_WSTAT_TXRETRY_SHFT) &   IIO_WSTAT_TXRETRY_MASK)
-#define IIO_ILAPR 0x400100  
-#define IIO_ILAPO 0x400108  
+#define IIO_ILAPR 0x400100
+#define IIO_ILAPO 0x400108
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_IOWA 0x400110  
-#define IIO_IIWA 0x400118  
-#define IIO_IIDEM 0x400120  
-#define IIO_ILCSR 0x400128  
+#define IIO_IOWA 0x400110
+#define IIO_IIWA 0x400118
+#define IIO_IIDEM 0x400120
+#define IIO_ILCSR 0x400128
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_ILLR 0x400130  
-#define IIO_IIDSR 0x400138  
-#define IIO_IIBUSERR 0x1400208  
+#define IIO_ILLR 0x400130
+#define IIO_IIDSR 0x400138
+#define IIO_IIBUSERR 0x1400208
 #define IIO_IIDSR_SENT_SHIFT 28
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IIO_IIDSR_SENT_MASK 0x10000000
@@ -99,21 +99,21 @@
 #define IIO_IIDSR_NODE_MASK 0x0000ff00
 #define IIO_IIDSR_LVL_SHIFT 0
 #define IIO_IIDSR_LVL_MASK 0x0000003f
-#define IIO_IGFX_0 0x400140  
+#define IIO_IGFX_0 0x400140
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_IGFX_1 0x400148  
-#define IIO_IGFX_W_NUM_BITS 4  
+#define IIO_IGFX_1 0x400148
+#define IIO_IGFX_W_NUM_BITS 4
 #define IIO_IGFX_W_NUM_MASK ((1<<IIO_IGFX_W_NUM_BITS)-1)
 #define IIO_IGFX_W_NUM_SHIFT 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_IGFX_N_NUM_BITS 9  
+#define IIO_IGFX_N_NUM_BITS 9
 #define IIO_IGFX_N_NUM_MASK ((1<<IIO_IGFX_N_NUM_BITS)-1)
 #define IIO_IGFX_N_NUM_SHIFT 4
-#define IIO_IGFX_P_NUM_BITS 1  
+#define IIO_IGFX_P_NUM_BITS 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IIO_IGFX_P_NUM_MASK ((1<<IIO_IGFX_P_NUM_BITS)-1)
 #define IIO_IGFX_P_NUM_SHIFT 16
-#define IIO_IGFX_VLD_BITS 1  
+#define IIO_IGFX_VLD_BITS 1
 #define IIO_IGFX_VLD_MASK ((1<<IIO_IGFX_VLD_BITS)-1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IIO_IGFX_VLD_SHIFT 20
@@ -136,7 +136,7 @@
 #define IIO_SCRATCH_BIT0_9 0x0000000000001000
 #define IIO_SCRATCH_BIT0_R 0x0000000000000fff
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_NUM_ITTES 7  
+#define IIO_NUM_ITTES 7
 #define HUB_NUM_BIG_WINDOW IIO_NUM_ITTES - 1
 #define SWIN0_BIGWIN HUB_NUM_BIG_WINDOW
 #define ILCSR_WARM_RESET 0x100
@@ -272,46 +272,46 @@
 #define IIO_LLP_SN_MAX 0xffff
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IIO_NUM_IPRBS (9)
-#define IIO_IOPRB_0 0x400198  
-#define IIO_IOPRB_8 0x4001a0  
-#define IIO_IOPRB_9 0x4001a8  
+#define IIO_IOPRB_0 0x400198
+#define IIO_IOPRB_8 0x4001a0
+#define IIO_IOPRB_9 0x4001a8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_IOPRB_A 0x4001b0  
-#define IIO_IOPRB_B 0x4001b8  
-#define IIO_IOPRB_C 0x4001c0  
-#define IIO_IOPRB_D 0x4001c8  
+#define IIO_IOPRB_A 0x4001b0
+#define IIO_IOPRB_B 0x4001b8
+#define IIO_IOPRB_C 0x4001c0
+#define IIO_IOPRB_D 0x4001c8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_IOPRB_E 0x4001d0  
-#define IIO_IOPRB_F 0x4001d8  
-#define IIO_IXCC 0x4001e0  
+#define IIO_IOPRB_E 0x4001d0
+#define IIO_IOPRB_F 0x4001d8
+#define IIO_IXCC 0x4001e0
 #define IIO_IXTCC IIO_IXCC
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_IMEM 0x4001e8  
-#define IIO_IXTT 0x4001f0  
-#define IIO_IECLR 0x4001f8  
-#define IIO_IBCN 0x400200  
+#define IIO_IMEM 0x4001e8
+#define IIO_IXTT 0x4001f0
+#define IIO_IECLR 0x4001f8
+#define IIO_IBCN 0x400200
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_IMEM_W0ESD 0x1  
-#define IIO_IMEM_B0ESD (1 << 4)  
-#define IIO_IMEM_B1ESD (1 << 8)  
-#define IIO_IPCA 0x400300  
+#define IIO_IMEM_W0ESD 0x1
+#define IIO_IMEM_B0ESD (1 << 4)
+#define IIO_IMEM_B1ESD (1 << 8)
+#define IIO_IPCA 0x400300
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_NUM_PRTES 8  
-#define IIO_PRTE_0 0x400308  
+#define IIO_NUM_PRTES 8
+#define IIO_PRTE_0 0x400308
 #define IIO_PRTE(_x) (IIO_PRTE_0 + (8 * (_x)))
-#define IIO_WIDPRTE(x) IIO_PRTE(((x) - 8))  
+#define IIO_WIDPRTE(x) IIO_PRTE(((x) - 8))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_IPDR 0x400388  
-#define IIO_ICDR 0x400390  
-#define IIO_IFDR 0x400398  
-#define IIO_IIAP 0x4003a0  
+#define IIO_IPDR 0x400388
+#define IIO_ICDR 0x400390
+#define IIO_IFDR 0x400398
+#define IIO_IIAP 0x4003a0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IIO_IMMR IIO_IIAP
-#define IIO_ICMR 0x4003a8  
-#define IIO_ICCR 0x4003b0  
-#define IIO_ICTO 0x4003b8  
+#define IIO_ICMR 0x4003a8
+#define IIO_ICCR 0x4003b0
+#define IIO_ICTO 0x4003b8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_ICTP 0x4003c0  
+#define IIO_ICTP 0x4003c0
 #define IIO_ICMR_PC_VLD_SHFT 36
 #define IIO_ICMR_PC_VLD_MASK (0x7fffUL << IIO_ICMR_PC_VLD_SHFT)
 #define IIO_ICMR_CRB_VLD_SHFT 20
@@ -334,16 +334,16 @@
 #define IIO_ICCR_PENDING (0x10000)
 #define IIO_ICCR_CMD_MASK (0xFF)
 #define IIO_ICCR_CMD_SHFT (7)
-#define IIO_ICCR_CMD_NOP (0x0)  
+#define IIO_ICCR_CMD_NOP (0x0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_ICCR_CMD_WAKE (0x100)  
-#define IIO_ICCR_CMD_TIMEOUT (0x200)  
-#define IIO_ICCR_CMD_EJECT (0x400)  
+#define IIO_ICCR_CMD_WAKE (0x100)
+#define IIO_ICCR_CMD_TIMEOUT (0x200)
+#define IIO_ICCR_CMD_EJECT (0x400)
 #define IIO_ICCR_CMD_FLUSH (0x800)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_NUM_CRBS 15  
-#define IIO_NUM_NORMAL_CRBS 12  
-#define IIO_NUM_PC_CRBS 4  
+#define IIO_NUM_CRBS 15
+#define IIO_NUM_NORMAL_CRBS 12
+#define IIO_NUM_PC_CRBS 4
 #define IIO_ICRB_OFFSET 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IIO_ICRB_0 0x400400
@@ -401,17 +401,17 @@
 #define ICRBN_A_ERR_MASK 0x3ff
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_ICRB_ADDR_SHFT 2  
-#define IIO_ICRB_ECODE_DERR 0  
-#define IIO_ICRB_ECODE_PERR 1  
-#define IIO_ICRB_ECODE_WERR 2  
+#define IIO_ICRB_ADDR_SHFT 2
+#define IIO_ICRB_ECODE_DERR 0
+#define IIO_ICRB_ECODE_PERR 1
+#define IIO_ICRB_ECODE_WERR 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_ICRB_ECODE_AERR 3  
-#define IIO_ICRB_ECODE_PWERR 4  
-#define IIO_ICRB_ECODE_PRERR 5  
-#define IIO_ICRB_ECODE_TOUT 6  
+#define IIO_ICRB_ECODE_AERR 3
+#define IIO_ICRB_ECODE_PWERR 4
+#define IIO_ICRB_ECODE_PRERR 5
+#define IIO_ICRB_ECODE_TOUT 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_ICRB_ECODE_XTERR 7  
+#define IIO_ICRB_ECODE_XTERR 7
 #ifndef __ASSEMBLY__
 typedef union icrbb_u {
  u64 reg_value;
@@ -496,44 +496,44 @@
 #define b_initiator icrbb_field_s.initiator
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_ICRB_XTSIZE_DW 0  
-#define IIO_ICRB_XTSIZE_32 1  
-#define IIO_ICRB_XTSIZE_128 2  
-#define IIO_ICRB_PROC0 0  
+#define IIO_ICRB_XTSIZE_DW 0
+#define IIO_ICRB_XTSIZE_32 1
+#define IIO_ICRB_XTSIZE_128 2
+#define IIO_ICRB_PROC0 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_ICRB_PROC1 1  
-#define IIO_ICRB_GB_REQ 2  
-#define IIO_ICRB_IO_REQ 3  
-#define IIO_ICRB_IMSGT_XTALK 0  
+#define IIO_ICRB_PROC1 1
+#define IIO_ICRB_GB_REQ 2
+#define IIO_ICRB_IO_REQ 3
+#define IIO_ICRB_IMSGT_XTALK 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_ICRB_IMSGT_BTE 1  
-#define IIO_ICRB_IMSGT_SN0NET 2  
-#define IIO_ICRB_IMSGT_CRB 3  
-#define IIO_ICRB_INIT_XTALK 0  
+#define IIO_ICRB_IMSGT_BTE 1
+#define IIO_ICRB_IMSGT_SN0NET 2
+#define IIO_ICRB_IMSGT_CRB 3
+#define IIO_ICRB_INIT_XTALK 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_ICRB_INIT_BTE0 0x1  
-#define IIO_ICRB_INIT_SN0NET 0x2  
-#define IIO_ICRB_INIT_CRB 0x3  
-#define IIO_ICRB_INIT_BTE1 0x5  
+#define IIO_ICRB_INIT_BTE0 0x1
+#define IIO_ICRB_INIT_SN0NET 0x2
+#define IIO_ICRB_INIT_CRB 0x3
+#define IIO_ICRB_INIT_BTE1 0x5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_ICRB_REQ_DWRD 0  
-#define IIO_ICRB_REQ_QCLRD 1  
-#define IIO_ICRB_REQ_BLKRD 2  
-#define IIO_ICRB_REQ_RSHU 6  
+#define IIO_ICRB_REQ_DWRD 0
+#define IIO_ICRB_REQ_QCLRD 1
+#define IIO_ICRB_REQ_BLKRD 2
+#define IIO_ICRB_REQ_RSHU 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_ICRB_REQ_REXU 7  
-#define IIO_ICRB_REQ_RDEX 8  
-#define IIO_ICRB_REQ_WINC 9  
-#define IIO_ICRB_REQ_BWINV 10  
+#define IIO_ICRB_REQ_REXU 7
+#define IIO_ICRB_REQ_RDEX 8
+#define IIO_ICRB_REQ_WINC 9
+#define IIO_ICRB_REQ_BWINV 10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_ICRB_REQ_PIORD 11  
-#define IIO_ICRB_REQ_PIOWR 12  
-#define IIO_ICRB_REQ_PRDM 13  
-#define IIO_ICRB_REQ_PWRM 14  
+#define IIO_ICRB_REQ_PIORD 11
+#define IIO_ICRB_REQ_PIOWR 12
+#define IIO_ICRB_REQ_PRDM 13
+#define IIO_ICRB_REQ_PWRM 14
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_ICRB_REQ_PTPWR 15  
-#define IIO_ICRB_REQ_WB 16  
-#define IIO_ICRB_REQ_DEX 17  
+#define IIO_ICRB_REQ_PTPWR 15
+#define IIO_ICRB_REQ_WB 16
+#define IIO_ICRB_REQ_DEX 17
 #ifndef __ASSEMBLY__
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef union icrbc_s {
@@ -558,8 +558,8 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define c_pripsc icrbc_field_s.pripsc
 #define c_bteop icrbc_field_s.bteop
-#define c_bteaddr icrbc_field_s.push_be  
-#define c_benable icrbc_field_s.push_be  
+#define c_bteaddr icrbc_field_s.push_be
+#define c_benable icrbc_field_s.push_be
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define c_suppl icrbc_field_s.suppl
 #define c_barrop icrbc_field_s.barrop
@@ -598,41 +598,41 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } hubii_ifdr_t;
 #endif
-#define IIO_IBLS_0 0x410000  
-#define IIO_IBSA_0 0x410008  
+#define IIO_IBLS_0 0x410000
+#define IIO_IBSA_0 0x410008
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_IBDA_0 0x410010  
-#define IIO_IBCT_0 0x410018  
-#define IIO_IBNA_0 0x410020  
+#define IIO_IBDA_0 0x410010
+#define IIO_IBCT_0 0x410018
+#define IIO_IBNA_0 0x410020
 #define IIO_IBNR_0 IIO_IBNA_0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_IBIA_0 0x410028  
-#define IIO_IBLS_1 0x420000  
-#define IIO_IBSA_1 0x420008  
-#define IIO_IBDA_1 0x420010  
+#define IIO_IBIA_0 0x410028
+#define IIO_IBLS_1 0x420000
+#define IIO_IBSA_1 0x420008
+#define IIO_IBDA_1 0x420010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_IBCT_1 0x420018  
-#define IIO_IBNA_1 0x420020  
+#define IIO_IBCT_1 0x420018
+#define IIO_IBNA_1 0x420020
 #define IIO_IBNR_1 IIO_IBNA_1
-#define IIO_IBIA_1 0x420028  
+#define IIO_IBIA_1 0x420028
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_IPCR 0x430000  
-#define IIO_IPPR 0x430008  
-#define IECLR_BTE1 (1 << 18)  
-#define IECLR_BTE0 (1 << 17)  
+#define IIO_IPCR 0x430000
+#define IIO_IPPR 0x430008
+#define IECLR_BTE1 (1 << 18)
+#define IECLR_BTE0 (1 << 17)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IECLR_CRAZY (1 << 16)  
-#define IECLR_PRB_F (1 << 15)  
-#define IECLR_PRB_E (1 << 14)  
-#define IECLR_PRB_D (1 << 13)  
+#define IECLR_CRAZY (1 << 16)
+#define IECLR_PRB_F (1 << 15)
+#define IECLR_PRB_E (1 << 14)
+#define IECLR_PRB_D (1 << 13)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IECLR_PRB_C (1 << 12)  
-#define IECLR_PRB_B (1 << 11)  
-#define IECLR_PRB_A (1 << 10)  
-#define IECLR_PRB_9 (1 << 9)  
+#define IECLR_PRB_C (1 << 12)
+#define IECLR_PRB_B (1 << 11)
+#define IECLR_PRB_A (1 << 10)
+#define IECLR_PRB_9 (1 << 9)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IECLR_PRB_8 (1 << 8)  
-#define IECLR_PRB_0 (1 << 0)  
+#define IECLR_PRB_8 (1 << 8)
+#define IECLR_PRB_0 (1 << 0)
 #ifndef __ASSEMBLY__
 typedef union iprte_a {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -692,9 +692,9 @@
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IPRB_MODE_NORMAL (0)
-#define IPRB_MODE_COLLECT_A (1)  
-#define IPRB_MODE_SERVICE_A (2)  
-#define IPRB_MODE_SERVICE_B (3)  
+#define IPRB_MODE_COLLECT_A (1)
+#define IPRB_MODE_SERVICE_A (2)
+#define IPRB_MODE_SERVICE_B (3)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifndef __ASSEMBLY__
 typedef union icrbp_a {
@@ -781,7 +781,7 @@
 #define MAX_HUBS_PER_XBOW 2
 #define IIO_WCR_WID_GET(nasid) (REMOTE_HUB_L(nasid, III_WCR) & 0xf)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IIO_WST_ERROR_MASK (UINT64_CAST 1 << 32)  
+#define IIO_WST_ERROR_MASK (UINT64_CAST 1 << 32)
 #define HUBII_XBOW_CREDIT 3
 #define HUBII_XBOW_REV2_CREDIT 4
 #endif
diff --git a/libc/kernel/arch-mips/asm/sn/sn0/hubmd.h b/libc/kernel/arch-mips/asm/sn/sn0/hubmd.h
index 9f0893f..9825009 100644
--- a/libc/kernel/arch-mips/asm/sn/sn0/hubmd.h
+++ b/libc/kernel/arch-mips/asm/sn/sn0/hubmd.h
@@ -18,106 +18,106 @@
  ****************************************************************************/
 #ifndef _ASM_SN_SN0_HUBMD_H
 #define _ASM_SN_SN0_HUBMD_H
-#define CACHE_SLINE_SIZE 128  
+#define CACHE_SLINE_SIZE 128
 #define MAX_REGIONS 64
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_PAGE_SIZE 4096  
-#define MD_PAGE_NUM_SHFT 12  
+#define MD_PAGE_SIZE 4096
+#define MD_PAGE_NUM_SHFT 12
 #define MD_BASE 0x200000
 #define MD_BASE_PERF 0x210000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MD_BASE_JUNK 0x220000
-#define MD_IO_PROTECT 0x200000  
-#define MD_IO_PROT_OVRRD 0x200008  
-#define MD_HSPEC_PROTECT 0x200010  
+#define MD_IO_PROTECT 0x200000
+#define MD_IO_PROT_OVRRD 0x200008
+#define MD_HSPEC_PROTECT 0x200010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_MEMORY_CONFIG 0x200018  
-#define MD_REFRESH_CONTROL 0x200020  
-#define MD_FANDOP_CAC_STAT 0x200028  
-#define MD_MIG_DIFF_THRESH 0x200030  
+#define MD_MEMORY_CONFIG 0x200018
+#define MD_REFRESH_CONTROL 0x200020
+#define MD_FANDOP_CAC_STAT 0x200028
+#define MD_MIG_DIFF_THRESH 0x200030
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_MIG_VALUE_THRESH 0x200038  
-#define MD_MIG_CANDIDATE 0x200040  
-#define MD_MIG_CANDIDATE_CLR 0x200048  
-#define MD_DIR_ERROR 0x200050  
+#define MD_MIG_VALUE_THRESH 0x200038
+#define MD_MIG_CANDIDATE 0x200040
+#define MD_MIG_CANDIDATE_CLR 0x200048
+#define MD_DIR_ERROR 0x200050
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_DIR_ERROR_CLR 0x200058  
-#define MD_PROTOCOL_ERROR 0x200060  
-#define MD_PROTOCOL_ERROR_CLR 0x200068  
-#define MD_MEM_ERROR 0x200070  
+#define MD_DIR_ERROR_CLR 0x200058
+#define MD_PROTOCOL_ERROR 0x200060
+#define MD_PROTOCOL_ERROR_CLR 0x200068
+#define MD_MEM_ERROR 0x200070
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_MEM_ERROR_CLR 0x200078  
-#define MD_MISC_ERROR 0x200080  
-#define MD_MISC_ERROR_CLR 0x200088  
-#define MD_MEM_DIMM_INIT 0x200090  
+#define MD_MEM_ERROR_CLR 0x200078
+#define MD_MISC_ERROR 0x200080
+#define MD_MISC_ERROR_CLR 0x200088
+#define MD_MEM_DIMM_INIT 0x200090
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_DIR_DIMM_INIT 0x200098  
-#define MD_MOQ_SIZE 0x2000a0  
-#define MD_MLAN_CTL 0x2000a8  
-#define MD_PERF_SEL 0x210000  
+#define MD_DIR_DIMM_INIT 0x200098
+#define MD_MOQ_SIZE 0x2000a0
+#define MD_MLAN_CTL 0x2000a8
+#define MD_PERF_SEL 0x210000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_PERF_CNT0 0x210010  
-#define MD_PERF_CNT1 0x210018  
-#define MD_PERF_CNT2 0x210020  
-#define MD_PERF_CNT3 0x210028  
+#define MD_PERF_CNT0 0x210010
+#define MD_PERF_CNT1 0x210018
+#define MD_PERF_CNT2 0x210020
+#define MD_PERF_CNT3 0x210028
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_PERF_CNT4 0x210030  
-#define MD_PERF_CNT5 0x210038  
-#define MD_UREG0_0 0x220000  
-#define MD_UREG0_1 0x220008  
+#define MD_PERF_CNT4 0x210030
+#define MD_PERF_CNT5 0x210038
+#define MD_UREG0_0 0x220000
+#define MD_UREG0_1 0x220008
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_UREG0_2 0x220010  
-#define MD_UREG0_3 0x220018  
-#define MD_UREG0_4 0x220020  
-#define MD_UREG0_5 0x220028  
+#define MD_UREG0_2 0x220010
+#define MD_UREG0_3 0x220018
+#define MD_UREG0_4 0x220020
+#define MD_UREG0_5 0x220028
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_UREG0_6 0x220030  
-#define MD_UREG0_7 0x220038  
-#define MD_SLOTID_USTAT 0x220048  
-#define MD_LED0 0x220050  
+#define MD_UREG0_6 0x220030
+#define MD_UREG0_7 0x220038
+#define MD_SLOTID_USTAT 0x220048
+#define MD_LED0 0x220050
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_LED1 0x220058  
-#define MD_UREG1_0 0x220080  
-#define MD_UREG1_1 0x220088  
-#define MD_UREG1_2 0x220090  
+#define MD_LED1 0x220058
+#define MD_UREG1_0 0x220080
+#define MD_UREG1_1 0x220088
+#define MD_UREG1_2 0x220090
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_UREG1_3 0x220098  
-#define MD_UREG1_4 0x2200a0  
-#define MD_UREG1_5 0x2200a8  
-#define MD_UREG1_6 0x2200b0  
+#define MD_UREG1_3 0x220098
+#define MD_UREG1_4 0x2200a0
+#define MD_UREG1_5 0x2200a8
+#define MD_UREG1_6 0x2200b0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_UREG1_7 0x2200b8  
-#define MD_UREG1_8 0x2200c0  
-#define MD_UREG1_9 0x2200c8  
-#define MD_UREG1_10 0x2200d0  
+#define MD_UREG1_7 0x2200b8
+#define MD_UREG1_8 0x2200c0
+#define MD_UREG1_9 0x2200c8
+#define MD_UREG1_10 0x2200d0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_UREG1_11 0x2200d8  
-#define MD_UREG1_12 0x2200e0  
-#define MD_UREG1_13 0x2200e8  
-#define MD_UREG1_14 0x2200f0  
+#define MD_UREG1_11 0x2200d8
+#define MD_UREG1_12 0x2200e0
+#define MD_UREG1_13 0x2200e8
+#define MD_UREG1_14 0x2200f0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_UREG1_15 0x2200f8  
-#define MD_MEM_BANKS 8  
-#define MD_SIZE_EMPTY 0  
+#define MD_UREG1_15 0x2200f8
+#define MD_MEM_BANKS 8
+#define MD_SIZE_EMPTY 0
 #define MD_SIZE_8MB 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MD_SIZE_16MB 2
-#define MD_SIZE_32MB 3  
-#define MD_SIZE_64MB 4  
-#define MD_SIZE_128MB 5  
+#define MD_SIZE_32MB 3
+#define MD_SIZE_64MB 4
+#define MD_SIZE_128MB 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MD_SIZE_256MB 6
-#define MD_SIZE_512MB 7  
+#define MD_SIZE_512MB 7
 #define MD_SIZE_1GB 8
 #define MD_SIZE_2GB 9
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MD_SIZE_4GB 10
 #define MD_SIZE_BYTES(size) ((size) == 0 ? 0 : 0x400000L << (size))
 #define MD_SIZE_MBYTES(size) ((size) == 0 ? 0 : 4 << (size))
-#define MMC_FPROM_CYC_SHFT 49  
+#define MMC_FPROM_CYC_SHFT 49
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MMC_FPROM_CYC_MASK (UINT64_CAST 31 << 49)  
-#define MMC_FPROM_WR_SHFT 44  
+#define MMC_FPROM_CYC_MASK (UINT64_CAST 31 << 49)
+#define MMC_FPROM_WR_SHFT 44
 #define MMC_FPROM_WR_MASK (UINT64_CAST 31 << 44)
 #define MMC_UCTLR_CYC_SHFT 39
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -191,27 +191,27 @@
 #define MLAN_RD_DATA (UINT64_CAST 0x01)
 #define MLAN_RESET_DEFAULTS (UINT64_CAST 0x31 << MLAN_PHI1_SHFT |   UINT64_CAST 0x31 << MLAN_PHI0_SHFT)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSU_CORECLK_TST_SHFT 7  
+#define MSU_CORECLK_TST_SHFT 7
 #define MSU_CORECLK_TST_MASK (UINT64_CAST 1 << 7)
 #define MSU_CORECLK_TST (UINT64_CAST 1 << 7)
-#define MSU_CORECLK_SHFT 6  
+#define MSU_CORECLK_SHFT 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSU_CORECLK_MASK (UINT64_CAST 1 << 6)
 #define MSU_CORECLK (UINT64_CAST 1 << 6)
-#define MSU_NETSYNC_SHFT 5  
+#define MSU_NETSYNC_SHFT 5
 #define MSU_NETSYNC_MASK (UINT64_CAST 1 << 5)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSU_NETSYNC (UINT64_CAST 1 << 5)
-#define MSU_FPROMRDY_SHFT 4  
+#define MSU_FPROMRDY_SHFT 4
 #define MSU_FPROMRDY_MASK (UINT64_CAST 1 << 4)
 #define MSU_FPROMRDY (UINT64_CAST 1 << 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSU_I2CINTR_SHFT 3  
+#define MSU_I2CINTR_SHFT 3
 #define MSU_I2CINTR_MASK (UINT64_CAST 1 << 3)
 #define MSU_I2CINTR (UINT64_CAST 1 << 3)
 #define MSU_SLOTID_MASK 0xff
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSU_SN0_SLOTID_SHFT 0  
+#define MSU_SN0_SLOTID_SHFT 0
 #define MSU_SN0_SLOTID_MASK (UINT64_CAST 7)
 #define MSU_SN00_SLOTID_SHFT 7
 #define MSU_SN00_SLOTID_MASK (UINT64_CAST 0x80)
@@ -239,55 +239,55 @@
 #define MD_MIG_CANDIDATE_NODEID_MASK (UINT64_CAST 0x1ff << 20)
 #define MD_MIG_CANDIDATE_NODEID_SHFT 20
 #define MD_MIG_CANDIDATE_ADDR_MASK (UINT64_CAST 0x3ffff)
-#define MD_MIG_CANDIDATE_ADDR_SHFT 14  
+#define MD_MIG_CANDIDATE_ADDR_SHFT 14
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_BANK_SHFT 29  
+#define MD_BANK_SHFT 29
 #define MD_BANK_MASK (UINT64_CAST 7 << 29)
-#define MD_BANK_SIZE (UINT64_CAST 1 << MD_BANK_SHFT)  
+#define MD_BANK_SIZE (UINT64_CAST 1 << MD_BANK_SHFT)
 #define MD_BANK_OFFSET(_b) (UINT64_CAST (_b) << MD_BANK_SHFT)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_DIR_SHARED (UINT64_CAST 0x0)  
-#define MD_DIR_POISONED (UINT64_CAST 0x1)  
-#define MD_DIR_EXCLUSIVE (UINT64_CAST 0x2)  
-#define MD_DIR_BUSY_SHARED (UINT64_CAST 0x3)  
+#define MD_DIR_SHARED (UINT64_CAST 0x0)
+#define MD_DIR_POISONED (UINT64_CAST 0x1)
+#define MD_DIR_EXCLUSIVE (UINT64_CAST 0x2)
+#define MD_DIR_BUSY_SHARED (UINT64_CAST 0x3)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_DIR_BUSY_EXCL (UINT64_CAST 0x4)  
-#define MD_DIR_WAIT (UINT64_CAST 0x5)  
-#define MD_DIR_UNOWNED (UINT64_CAST 0x7)  
+#define MD_DIR_BUSY_EXCL (UINT64_CAST 0x4)
+#define MD_DIR_WAIT (UINT64_CAST 0x5)
+#define MD_DIR_UNOWNED (UINT64_CAST 0x7)
 #define MD_DIR_FORCE_ECC (UINT64_CAST 1 << 63)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_PDIR_MASK 0xffffffffffff  
-#define MD_PDIR_ECC_SHFT 0  
+#define MD_PDIR_MASK 0xffffffffffff
+#define MD_PDIR_ECC_SHFT 0
 #define MD_PDIR_ECC_MASK 0x7f
-#define MD_PDIR_PRIO_SHFT 8  
+#define MD_PDIR_PRIO_SHFT 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MD_PDIR_PRIO_MASK (0xf << 8)
-#define MD_PDIR_AX_SHFT 7  
+#define MD_PDIR_AX_SHFT 7
 #define MD_PDIR_AX_MASK (1 << 7)
 #define MD_PDIR_AX (1 << 7)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_PDIR_FINE_SHFT 12  
+#define MD_PDIR_FINE_SHFT 12
 #define MD_PDIR_FINE_MASK (1 << 12)
 #define MD_PDIR_FINE (1 << 12)
-#define MD_PDIR_OCT_SHFT 13  
+#define MD_PDIR_OCT_SHFT 13
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MD_PDIR_OCT_MASK (7 << 13)
-#define MD_PDIR_STATE_SHFT 13  
+#define MD_PDIR_STATE_SHFT 13
 #define MD_PDIR_STATE_MASK (7 << 13)
-#define MD_PDIR_ONECNT_SHFT 16  
+#define MD_PDIR_ONECNT_SHFT 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MD_PDIR_ONECNT_MASK (0x3f << 16)
-#define MD_PDIR_PTR_SHFT 22  
+#define MD_PDIR_PTR_SHFT 22
 #define MD_PDIR_PTR_MASK (UINT64_CAST 0x7ff << 22)
-#define MD_PDIR_VECMSB_SHFT 22  
+#define MD_PDIR_VECMSB_SHFT 22
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MD_PDIR_VECMSB_BITMASK 0x3ffffff
 #define MD_PDIR_VECMSB_BITSHFT 27
 #define MD_PDIR_VECMSB_MASK (UINT64_CAST MD_PDIR_VECMSB_BITMASK << 22)
-#define MD_PDIR_CWOFF_SHFT 7  
+#define MD_PDIR_CWOFF_SHFT 7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MD_PDIR_CWOFF_MASK (7 << 7)
-#define MD_PDIR_VECLSB_SHFT 10  
+#define MD_PDIR_VECLSB_SHFT 10
 #define MD_PDIR_VECLSB_BITMASK (UINT64_CAST 0x3fffffffff)
 #define MD_PDIR_VECLSB_BITSHFT 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -296,29 +296,29 @@
 #define MD_PDIR_INIT_HI 0
 #define MD_PDIR_INIT_PROT (MD_PROT_RW << MD_PPROT_IO_SHFT |   MD_PROT_RW << MD_PPROT_SHFT)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_SDIR_MASK 0xffff  
-#define MD_SDIR_ECC_SHFT 0  
+#define MD_SDIR_MASK 0xffff
+#define MD_SDIR_ECC_SHFT 0
 #define MD_SDIR_ECC_MASK 0x1f
-#define MD_SDIR_PRIO_SHFT 6  
+#define MD_SDIR_PRIO_SHFT 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MD_SDIR_PRIO_MASK (1 << 6)
-#define MD_SDIR_AX_SHFT 5  
+#define MD_SDIR_AX_SHFT 5
 #define MD_SDIR_AX_MASK (1 << 5)
 #define MD_SDIR_AX (1 << 5)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_SDIR_STATE_SHFT 7  
+#define MD_SDIR_STATE_SHFT 7
 #define MD_SDIR_STATE_MASK (7 << 7)
-#define MD_SDIR_PTR_SHFT 10  
+#define MD_SDIR_PTR_SHFT 10
 #define MD_SDIR_PTR_MASK (0x3f << 10)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_SDIR_CWOFF_SHFT 5  
+#define MD_SDIR_CWOFF_SHFT 5
 #define MD_SDIR_CWOFF_MASK (7 << 5)
-#define MD_SDIR_VECMSB_SHFT 11  
+#define MD_SDIR_VECMSB_SHFT 11
 #define MD_SDIR_VECMSB_BITMASK 0x1f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MD_SDIR_VECMSB_BITSHFT 7
 #define MD_SDIR_VECMSB_MASK (MD_SDIR_VECMSB_BITMASK << 11)
-#define MD_SDIR_VECLSB_SHFT 5  
+#define MD_SDIR_VECLSB_SHFT 5
 #define MD_SDIR_VECLSB_BITMASK 0x7ff
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MD_SDIR_VECLSB_BITSHFT 0
@@ -332,23 +332,23 @@
 #define MD_PROT_NO (UINT64_CAST 0x0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MD_PROT_BAD (UINT64_CAST 0x5)
-#define MD_PPROT_SHFT 0  
+#define MD_PPROT_SHFT 0
 #define MD_PPROT_MASK 7
-#define MD_PPROT_MIGMD_SHFT 3  
+#define MD_PPROT_MIGMD_SHFT 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MD_PPROT_MIGMD_MASK (3 << 3)
-#define MD_PPROT_REFCNT_SHFT 5  
+#define MD_PPROT_REFCNT_SHFT 5
 #define MD_PPROT_REFCNT_WIDTH 0x7ffff
 #define MD_PPROT_REFCNT_MASK (MD_PPROT_REFCNT_WIDTH << 5)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_PPROT_IO_SHFT 45  
+#define MD_PPROT_IO_SHFT 45
 #define MD_PPROT_IO_MASK (UINT64_CAST 7 << 45)
-#define MD_SPROT_SHFT 0  
+#define MD_SPROT_SHFT 0
 #define MD_SPROT_MASK 7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_SPROT_MIGMD_SHFT 3  
+#define MD_SPROT_MIGMD_SHFT 3
 #define MD_SPROT_MIGMD_MASK (3 << 3)
-#define MD_SPROT_REFCNT_SHFT 5  
+#define MD_SPROT_REFCNT_SHFT 5
 #define MD_SPROT_REFCNT_WIDTH 0x7ff
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MD_SPROT_REFCNT_MASK (MD_SPROT_REFCNT_WIDTH << 5)
diff --git a/libc/kernel/arch-mips/asm/sn/sn0/hubni.h b/libc/kernel/arch-mips/asm/sn/sn0/hubni.h
index cb3658d..8d330f1 100644
--- a/libc/kernel/arch-mips/asm/sn/sn0/hubni.h
+++ b/libc/kernel/arch-mips/asm/sn/sn0/hubni.h
@@ -24,47 +24,47 @@
 #endif
 #define NI_BASE 0x600000
 #define NI_BASE_TABLES 0x630000
-#define NI_STATUS_REV_ID 0x600000  
+#define NI_STATUS_REV_ID 0x600000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NI_PORT_RESET 0x600008  
-#define NI_PROTECTION 0x600010  
-#define NI_GLOBAL_PARMS 0x600018  
-#define NI_SCRATCH_REG0 0x600100  
+#define NI_PORT_RESET 0x600008
+#define NI_PROTECTION 0x600010
+#define NI_GLOBAL_PARMS 0x600018
+#define NI_SCRATCH_REG0 0x600100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NI_SCRATCH_REG1 0x600108  
-#define NI_DIAG_PARMS 0x600110  
-#define NI_VECTOR_PARMS 0x600200  
-#define NI_VECTOR 0x600208  
+#define NI_SCRATCH_REG1 0x600108
+#define NI_DIAG_PARMS 0x600110
+#define NI_VECTOR_PARMS 0x600200
+#define NI_VECTOR 0x600208
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NI_VECTOR_DATA 0x600210  
-#define NI_VECTOR_STATUS 0x600300  
-#define NI_RETURN_VECTOR 0x600308  
-#define NI_VECTOR_READ_DATA 0x600310  
+#define NI_VECTOR_DATA 0x600210
+#define NI_VECTOR_STATUS 0x600300
+#define NI_RETURN_VECTOR 0x600308
+#define NI_VECTOR_READ_DATA 0x600310
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NI_VECTOR_CLEAR 0x600380  
-#define NI_IO_PROTECT 0x600400  
-#define NI_IO_PROT_OVRRD 0x600408  
-#define NI_AGE_CPU0_MEMORY 0x600500  
+#define NI_VECTOR_CLEAR 0x600380
+#define NI_IO_PROTECT 0x600400
+#define NI_IO_PROT_OVRRD 0x600408
+#define NI_AGE_CPU0_MEMORY 0x600500
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NI_AGE_CPU0_PIO 0x600508  
-#define NI_AGE_CPU1_MEMORY 0x600510  
-#define NI_AGE_CPU1_PIO 0x600518  
-#define NI_AGE_GBR_MEMORY 0x600520  
+#define NI_AGE_CPU0_PIO 0x600508
+#define NI_AGE_CPU1_MEMORY 0x600510
+#define NI_AGE_CPU1_PIO 0x600518
+#define NI_AGE_GBR_MEMORY 0x600520
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NI_AGE_GBR_PIO 0x600528  
-#define NI_AGE_IO_MEMORY 0x600530  
-#define NI_AGE_IO_PIO 0x600538  
+#define NI_AGE_GBR_PIO 0x600528
+#define NI_AGE_IO_MEMORY 0x600530
+#define NI_AGE_IO_PIO 0x600538
 #define NI_AGE_REG_MIN NI_AGE_CPU0_MEMORY
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NI_AGE_REG_MAX NI_AGE_IO_PIO
-#define NI_PORT_PARMS 0x608000  
-#define NI_PORT_ERROR 0x608008  
-#define NI_PORT_ERROR_CLEAR 0x608088  
+#define NI_PORT_PARMS 0x608000
+#define NI_PORT_ERROR 0x608008
+#define NI_PORT_ERROR_CLEAR 0x608088
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NI_META_TABLE0 0x638000  
+#define NI_META_TABLE0 0x638000
 #define NI_META_TABLE(_x) (NI_META_TABLE0 + (8 * (_x)))
 #define NI_META_ENTRIES 32
-#define NI_LOCAL_TABLE0 0x638100  
+#define NI_LOCAL_TABLE0 0x638100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NI_LOCAL_TABLE(_x) (NI_LOCAL_TABLE0 + (8 * (_x)))
 #define NI_LOCAL_ENTRIES 16
@@ -73,55 +73,55 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NSRI_LINKUP_SHFT 29
 #define NSRI_LINKUP_MASK (UINT64_CAST 0x1 << 29)
-#define NSRI_DOWNREASON_SHFT 28  
-#define NSRI_DOWNREASON_MASK (UINT64_CAST 0x1 << 28)  
+#define NSRI_DOWNREASON_SHFT 28
+#define NSRI_DOWNREASON_MASK (UINT64_CAST 0x1 << 28)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NSRI_MORENODES_SHFT 18
-#define NSRI_MORENODES_MASK (UINT64_CAST 1 << 18)  
+#define NSRI_MORENODES_MASK (UINT64_CAST 1 << 18)
 #define MORE_MEMORY 0
 #define MORE_NODES 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NSRI_REGIONSIZE_SHFT 17
-#define NSRI_REGIONSIZE_MASK (UINT64_CAST 1 << 17)  
+#define NSRI_REGIONSIZE_MASK (UINT64_CAST 1 << 17)
 #define REGIONSIZE_FINE 1
 #define REGIONSIZE_COARSE 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NSRI_NODEID_SHFT 8
-#define NSRI_NODEID_MASK (UINT64_CAST 0x1ff << 8) 
+#define NSRI_NODEID_MASK (UINT64_CAST 0x1ff << 8)
 #define NSRI_REV_SHFT 4
-#define NSRI_REV_MASK (UINT64_CAST 0xf << 4)  
+#define NSRI_REV_MASK (UINT64_CAST 0xf << 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NSRI_CHIPID_SHFT 0
-#define NSRI_CHIPID_MASK (UINT64_CAST 0xf)  
+#define NSRI_CHIPID_MASK (UINT64_CAST 0xf)
 #define NASID_TO_FINEREG_SHFT 0
 #define NASID_TO_COARSEREG_SHFT 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NPR_PORTRESET (UINT64_CAST 1 << 7)  
-#define NPR_LINKRESET (UINT64_CAST 1 << 1)  
-#define NPR_LOCALRESET (UINT64_CAST 1)  
+#define NPR_PORTRESET (UINT64_CAST 1 << 7)
+#define NPR_LINKRESET (UINT64_CAST 1 << 1)
+#define NPR_LOCALRESET (UINT64_CAST 1)
 #define NPROT_RESETOK (UINT64_CAST 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NGP_MAXRETRY_SHFT 48  
+#define NGP_MAXRETRY_SHFT 48
 #define NGP_MAXRETRY_MASK (UINT64_CAST 0x3ff << 48)
-#define NGP_TAILTOWRAP_SHFT 32  
+#define NGP_TAILTOWRAP_SHFT 32
 #define NGP_TAILTOWRAP_MASK (UINT64_CAST 0xffff << 32)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NGP_CREDITTOVAL_SHFT 16  
+#define NGP_CREDITTOVAL_SHFT 16
 #define NGP_CREDITTOVAL_MASK (UINT64_CAST 0xf << 16)
-#define NGP_TAILTOVAL_SHFT 4  
+#define NGP_TAILTOVAL_SHFT 4
 #define NGP_TAILTOVAL_MASK (UINT64_CAST 0xf << 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NDP_PORTTORESET (UINT64_CAST 1 << 18)  
-#define NDP_LLP8BITMODE (UINT64_CAST 1 << 12)  
-#define NDP_PORTDISABLE (UINT64_CAST 1 << 6)  
-#define NDP_SENDERROR (UINT64_CAST 1)  
+#define NDP_PORTTORESET (UINT64_CAST 1 << 18)
+#define NDP_LLP8BITMODE (UINT64_CAST 1 << 12)
+#define NDP_PORTDISABLE (UINT64_CAST 1 << 6)
+#define NDP_SENDERROR (UINT64_CAST 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NVP_PIOID_SHFT 40
 #define NVP_PIOID_MASK (UINT64_CAST 0x3ff << 40)
 #define NVP_WRITEID_SHFT 32
 #define NVP_WRITEID_MASK (UINT64_CAST 0xff << 32)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NVP_ADDRESS_MASK (UINT64_CAST 0xffff8)  
+#define NVP_ADDRESS_MASK (UINT64_CAST 0xffff8)
 #define NVP_TYPE_SHFT 0
 #define NVP_TYPE_MASK (UINT64_CAST 0x3)
 #define NVS_VALID (UINT64_CAST 1 << 63)
@@ -134,21 +134,21 @@
 #define NVS_PIOID_MASK (UINT64_CAST 0x3ff << 40)
 #define NVS_WRITEID_SHFT 32
 #define NVS_WRITEID_MASK (UINT64_CAST 0xff << 32)
-#define NVS_ADDRESS_MASK (UINT64_CAST 0xfffffff8)  
+#define NVS_ADDRESS_MASK (UINT64_CAST 0xfffffff8)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NVS_TYPE_SHFT 0
 #define NVS_TYPE_MASK (UINT64_CAST 0x7)
-#define NVS_ERROR_MASK (UINT64_CAST 0x4)  
-#define PIOTYPE_READ 0  
+#define NVS_ERROR_MASK (UINT64_CAST 0x4)
+#define PIOTYPE_READ 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PIOTYPE_WRITE 1  
-#define PIOTYPE_UNDEFINED 2  
-#define PIOTYPE_EXCHANGE 3  
-#define PIOTYPE_ADDR_ERR 4  
+#define PIOTYPE_WRITE 1
+#define PIOTYPE_UNDEFINED 2
+#define PIOTYPE_EXCHANGE 3
+#define PIOTYPE_ADDR_ERR 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PIOTYPE_CMD_ERR 5  
-#define PIOTYPE_PROT_ERR 6  
-#define PIOTYPE_UNKNOWN 7  
+#define PIOTYPE_CMD_ERR 5
+#define PIOTYPE_PROT_ERR 6
+#define PIOTYPE_UNKNOWN 7
 #define NAGE_VCH_SHFT 10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NAGE_VCH_MASK (UINT64_CAST 3 << 10)
diff --git a/libc/kernel/arch-mips/asm/sn/sn0/hubpi.h b/libc/kernel/arch-mips/asm/sn/sn0/hubpi.h
index 922c480..7efab8b 100644
--- a/libc/kernel/arch-mips/asm/sn/sn0/hubpi.h
+++ b/libc/kernel/arch-mips/asm/sn/sn0/hubpi.h
@@ -21,15 +21,15 @@
 #include <linux/types.h>
 #define PI_BASE 0x000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_CPU_PROTECT 0x000000  
-#define PI_PROT_OVERRD 0x000008  
-#define PI_IO_PROTECT 0x000010  
-#define PI_REGION_PRESENT 0x000018  
+#define PI_CPU_PROTECT 0x000000
+#define PI_PROT_OVERRD 0x000008
+#define PI_IO_PROTECT 0x000010
+#define PI_REGION_PRESENT 0x000018
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_CPU_NUM 0x000020  
-#define PI_CALIAS_SIZE 0x000028  
-#define PI_MAX_CRB_TIMEOUT 0x000030  
-#define PI_CRB_SFACTOR 0x000038  
+#define PI_CPU_NUM 0x000020
+#define PI_CALIAS_SIZE 0x000028
+#define PI_MAX_CRB_TIMEOUT 0x000030
+#define PI_CRB_SFACTOR 0x000038
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PI_CALIAS_SIZE_0 0
 #define PI_CALIAS_SIZE_4K 1
@@ -51,143 +51,143 @@
 #define PI_CALIAS_SIZE_32M 14
 #define PI_CALIAS_SIZE_64M 15
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_CPU_PRESENT_A 0x000040  
-#define PI_CPU_PRESENT_B 0x000048  
-#define PI_CPU_ENABLE_A 0x000050  
-#define PI_CPU_ENABLE_B 0x000058  
+#define PI_CPU_PRESENT_A 0x000040
+#define PI_CPU_PRESENT_B 0x000048
+#define PI_CPU_ENABLE_A 0x000050
+#define PI_CPU_ENABLE_B 0x000058
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_REPLY_LEVEL 0x000060  
-#define PI_HARDRESET_BIT 0x020068  
-#define PI_NMI_A 0x000070  
-#define PI_NMI_B 0x000078  
+#define PI_REPLY_LEVEL 0x000060
+#define PI_HARDRESET_BIT 0x020068
+#define PI_NMI_A 0x000070
+#define PI_NMI_B 0x000078
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PI_NMI_OFFSET (PI_NMI_B - PI_NMI_A)
-#define PI_SOFTRESET 0x000080  
-#define PI_INT_PEND_MOD 0x000090  
-#define PI_INT_PEND0 0x000098  
+#define PI_SOFTRESET 0x000080
+#define PI_INT_PEND_MOD 0x000090
+#define PI_INT_PEND0 0x000098
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_INT_PEND1 0x0000a0  
-#define PI_INT_MASK0_A 0x0000a8  
-#define PI_INT_MASK1_A 0x0000b0  
-#define PI_INT_MASK0_B 0x0000b8  
+#define PI_INT_PEND1 0x0000a0
+#define PI_INT_MASK0_A 0x0000a8
+#define PI_INT_MASK1_A 0x0000b0
+#define PI_INT_MASK0_B 0x0000b8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_INT_MASK1_B 0x0000c0  
-#define PI_INT_MASK_OFFSET 0x10  
-#define PI_CC_PEND_SET_A 0x0000c8  
-#define PI_CC_PEND_SET_B 0x0000d0  
+#define PI_INT_MASK1_B 0x0000c0
+#define PI_INT_MASK_OFFSET 0x10
+#define PI_CC_PEND_SET_A 0x0000c8
+#define PI_CC_PEND_SET_B 0x0000d0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_CC_PEND_CLR_A 0x0000d8  
-#define PI_CC_PEND_CLR_B 0x0000e0  
-#define PI_CC_MASK 0x0000e8  
-#define PI_INT_SET_OFFSET 0x08  
+#define PI_CC_PEND_CLR_A 0x0000d8
+#define PI_CC_PEND_CLR_B 0x0000e0
+#define PI_CC_MASK 0x0000e8
+#define PI_INT_SET_OFFSET 0x08
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_RT_COUNT 0x030100  
-#define PI_RT_COMPARE_A 0x000108  
-#define PI_RT_COMPARE_B 0x000110  
-#define PI_PROFILE_COMPARE 0x000118  
+#define PI_RT_COUNT 0x030100
+#define PI_RT_COMPARE_A 0x000108
+#define PI_RT_COMPARE_B 0x000110
+#define PI_PROFILE_COMPARE 0x000118
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_RT_PEND_A 0x000120  
-#define PI_RT_PEND_B 0x000128  
-#define PI_PROF_PEND_A 0x000130  
-#define PI_PROF_PEND_B 0x000138  
+#define PI_RT_PEND_A 0x000120
+#define PI_RT_PEND_B 0x000128
+#define PI_PROF_PEND_A 0x000130
+#define PI_PROF_PEND_B 0x000138
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_RT_EN_A 0x000140  
-#define PI_RT_EN_B 0x000148  
-#define PI_PROF_EN_A 0x000150  
-#define PI_PROF_EN_B 0x000158  
+#define PI_RT_EN_A 0x000140
+#define PI_RT_EN_B 0x000148
+#define PI_PROF_EN_A 0x000150
+#define PI_PROF_EN_B 0x000158
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_RT_LOCAL_CTRL 0x000160  
-#define PI_RT_FILTER_CTRL 0x000168  
-#define PI_COUNT_OFFSET 0x08  
-#define PI_BIST_WRITE_DATA 0x000200  
+#define PI_RT_LOCAL_CTRL 0x000160
+#define PI_RT_FILTER_CTRL 0x000168
+#define PI_COUNT_OFFSET 0x08
+#define PI_BIST_WRITE_DATA 0x000200
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_BIST_READ_DATA 0x000208  
-#define PI_BIST_COUNT_TARG 0x000210  
-#define PI_BIST_READY 0x000218  
-#define PI_BIST_SHIFT_LOAD 0x000220  
+#define PI_BIST_READ_DATA 0x000208
+#define PI_BIST_COUNT_TARG 0x000210
+#define PI_BIST_READY 0x000218
+#define PI_BIST_SHIFT_LOAD 0x000220
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_BIST_SHIFT_UNLOAD 0x000228  
-#define PI_BIST_ENTER_RUN 0x000230  
-#define PI_GFX_PAGE_A 0x000300  
-#define PI_GFX_CREDIT_CNTR_A 0x000308  
+#define PI_BIST_SHIFT_UNLOAD 0x000228
+#define PI_BIST_ENTER_RUN 0x000230
+#define PI_GFX_PAGE_A 0x000300
+#define PI_GFX_CREDIT_CNTR_A 0x000308
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_GFX_BIAS_A 0x000310  
-#define PI_GFX_INT_CNTR_A 0x000318  
-#define PI_GFX_INT_CMP_A 0x000320  
-#define PI_GFX_PAGE_B 0x000328  
+#define PI_GFX_BIAS_A 0x000310
+#define PI_GFX_INT_CNTR_A 0x000318
+#define PI_GFX_INT_CMP_A 0x000320
+#define PI_GFX_PAGE_B 0x000328
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_GFX_CREDIT_CNTR_B 0x000330  
-#define PI_GFX_BIAS_B 0x000338  
-#define PI_GFX_INT_CNTR_B 0x000340  
-#define PI_GFX_INT_CMP_B 0x000348  
+#define PI_GFX_CREDIT_CNTR_B 0x000330
+#define PI_GFX_BIAS_B 0x000338
+#define PI_GFX_INT_CNTR_B 0x000340
+#define PI_GFX_INT_CMP_B 0x000348
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PI_GFX_OFFSET (PI_GFX_PAGE_B - PI_GFX_PAGE_A)
 #define PI_GFX_PAGE_ENABLE 0x0000010000000000LL
-#define PI_ERR_INT_PEND 0x000400  
-#define PI_ERR_INT_MASK_A 0x000408  
+#define PI_ERR_INT_PEND 0x000400
+#define PI_ERR_INT_MASK_A 0x000408
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_ERR_INT_MASK_B 0x000410  
-#define PI_ERR_STACK_ADDR_A 0x000418  
-#define PI_ERR_STACK_ADDR_B 0x000420  
-#define PI_ERR_STACK_SIZE 0x000428  
+#define PI_ERR_INT_MASK_B 0x000410
+#define PI_ERR_STACK_ADDR_A 0x000418
+#define PI_ERR_STACK_ADDR_B 0x000420
+#define PI_ERR_STACK_SIZE 0x000428
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_ERR_STATUS0_A 0x000430  
-#define PI_ERR_STATUS0_A_RCLR 0x000438  
-#define PI_ERR_STATUS1_A 0x000440  
-#define PI_ERR_STATUS1_A_RCLR 0x000448  
+#define PI_ERR_STATUS0_A 0x000430
+#define PI_ERR_STATUS0_A_RCLR 0x000438
+#define PI_ERR_STATUS1_A 0x000440
+#define PI_ERR_STATUS1_A_RCLR 0x000448
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_ERR_STATUS0_B 0x000450  
-#define PI_ERR_STATUS0_B_RCLR 0x000458  
-#define PI_ERR_STATUS1_B 0x000460  
-#define PI_ERR_STATUS1_B_RCLR 0x000468  
+#define PI_ERR_STATUS0_B 0x000450
+#define PI_ERR_STATUS0_B_RCLR 0x000458
+#define PI_ERR_STATUS1_B 0x000460
+#define PI_ERR_STATUS1_B_RCLR 0x000468
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_SPOOL_CMP_A 0x000470  
-#define PI_SPOOL_CMP_B 0x000478  
-#define PI_CRB_TIMEOUT_A 0x000480  
-#define PI_CRB_TIMEOUT_B 0x000488  
+#define PI_SPOOL_CMP_A 0x000470
+#define PI_SPOOL_CMP_B 0x000478
+#define PI_CRB_TIMEOUT_A 0x000480
+#define PI_CRB_TIMEOUT_B 0x000488
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_SYSAD_ERRCHK_EN 0x000490  
-#define PI_BAD_CHECK_BIT_A 0x000498  
-#define PI_BAD_CHECK_BIT_B 0x0004a0  
-#define PI_NACK_CNT_A 0x0004a8  
+#define PI_SYSAD_ERRCHK_EN 0x000490
+#define PI_BAD_CHECK_BIT_A 0x000498
+#define PI_BAD_CHECK_BIT_B 0x0004a0
+#define PI_NACK_CNT_A 0x0004a8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_NACK_CNT_B 0x0004b0  
-#define PI_NACK_CMP 0x0004b8  
+#define PI_NACK_CNT_B 0x0004b0
+#define PI_NACK_CMP 0x0004b8
 #define PI_STACKADDR_OFFSET (PI_ERR_STACK_ADDR_B - PI_ERR_STACK_ADDR_A)
 #define PI_ERRSTAT_OFFSET (PI_ERR_STATUS0_B - PI_ERR_STATUS0_A)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PI_RDCLR_OFFSET (PI_ERR_STATUS0_A_RCLR - PI_ERR_STATUS0_A)
-#define PI_ERR_SPOOL_CMP_B 0x00000001  
+#define PI_ERR_SPOOL_CMP_B 0x00000001
 #define PI_ERR_SPOOL_CMP_A 0x00000002
-#define PI_ERR_SPUR_MSG_B 0x00000004  
+#define PI_ERR_SPUR_MSG_B 0x00000004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PI_ERR_SPUR_MSG_A 0x00000008
-#define PI_ERR_WRB_TERR_B 0x00000010  
+#define PI_ERR_WRB_TERR_B 0x00000010
 #define PI_ERR_WRB_TERR_A 0x00000020
-#define PI_ERR_WRB_WERR_B 0x00000040  
+#define PI_ERR_WRB_WERR_B 0x00000040
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PI_ERR_WRB_WERR_A 0x00000080
-#define PI_ERR_SYSSTATE_B 0x00000100  
+#define PI_ERR_SYSSTATE_B 0x00000100
 #define PI_ERR_SYSSTATE_A 0x00000200
-#define PI_ERR_SYSAD_DATA_B 0x00000400  
+#define PI_ERR_SYSAD_DATA_B 0x00000400
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PI_ERR_SYSAD_DATA_A 0x00000800
-#define PI_ERR_SYSAD_ADDR_B 0x00001000  
+#define PI_ERR_SYSAD_ADDR_B 0x00001000
 #define PI_ERR_SYSAD_ADDR_A 0x00002000
-#define PI_ERR_SYSCMD_DATA_B 0x00004000  
+#define PI_ERR_SYSCMD_DATA_B 0x00004000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PI_ERR_SYSCMD_DATA_A 0x00008000
-#define PI_ERR_SYSCMD_ADDR_B 0x00010000  
+#define PI_ERR_SYSCMD_ADDR_B 0x00010000
 #define PI_ERR_SYSCMD_ADDR_A 0x00020000
-#define PI_ERR_BAD_SPOOL_B 0x00040000  
+#define PI_ERR_BAD_SPOOL_B 0x00040000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PI_ERR_BAD_SPOOL_A 0x00080000
-#define PI_ERR_UNCAC_UNCORR_B 0x00100000  
+#define PI_ERR_UNCAC_UNCORR_B 0x00100000
 #define PI_ERR_UNCAC_UNCORR_A 0x00200000
-#define PI_ERR_SYSSTATE_TAG_B 0x00400000  
+#define PI_ERR_SYSSTATE_TAG_B 0x00400000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PI_ERR_SYSSTATE_TAG_A 0x00800000
-#define PI_ERR_MD_UNCORR 0x01000000  
+#define PI_ERR_MD_UNCORR 0x01000000
 #define PI_ERR_CLEAR_ALL_A 0x00aaaaaa
 #define PI_ERR_CLEAR_ALL_B 0x00555555
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -266,8 +266,8 @@
 #define ERR_STK_ADDR_SHFT 7
 #define ERR_STAT0_ADDR_SHFT 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_MIN_STACK_SIZE 4096  
-#define PI_STACK_SIZE_SHFT 12  
+#define PI_MIN_STACK_SIZE 4096
+#define PI_STACK_SIZE_SHFT 12
 #define ERR_STACK_SIZE_BYTES(_sz)   ((_sz) ? (PI_MIN_STACK_SIZE << ((_sz) - 1)) : 0)
 #ifndef __ASSEMBLY__
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -323,15 +323,15 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef u64 rtc_time_t;
 #endif
-#define PI_SYSAD_ERRCHK_ECCGEN 0x01  
-#define PI_SYSAD_ERRCHK_QUALGEN 0x02  
+#define PI_SYSAD_ERRCHK_ECCGEN 0x01
+#define PI_SYSAD_ERRCHK_QUALGEN 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_SYSAD_ERRCHK_SADP 0x04  
-#define PI_SYSAD_ERRCHK_CMDP 0x08  
-#define PI_SYSAD_ERRCHK_STATE 0x10  
-#define PI_SYSAD_ERRCHK_QUAL 0x20  
+#define PI_SYSAD_ERRCHK_SADP 0x04
+#define PI_SYSAD_ERRCHK_CMDP 0x08
+#define PI_SYSAD_ERRCHK_STATE 0x10
+#define PI_SYSAD_ERRCHK_QUAL 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PI_SYSAD_CHECK_ALL 0x3f  
+#define PI_SYSAD_CHECK_ALL 0x3f
 #define HUB_IP_PEND0 0x0400
 #define HUB_IP_PEND1_CC 0x0800
 #define HUB_IP_RT 0x1000
diff --git a/libc/kernel/arch-mips/asm/socket.h b/libc/kernel/arch-mips/asm/socket.h
index 4dbbe85..02cf29e 100644
--- a/libc/kernel/arch-mips/asm/socket.h
+++ b/libc/kernel/arch-mips/asm/socket.h
@@ -21,29 +21,29 @@
 #include <asm/sockios.h>
 #define SOL_SOCKET 0xffff
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SO_DEBUG 0x0001  
-#define SO_REUSEADDR 0x0004  
-#define SO_KEEPALIVE 0x0008  
-#define SO_DONTROUTE 0x0010  
+#define SO_DEBUG 0x0001
+#define SO_REUSEADDR 0x0004
+#define SO_KEEPALIVE 0x0008
+#define SO_DONTROUTE 0x0010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SO_BROADCAST 0x0020  
-#define SO_LINGER 0x0080  
-#define SO_OOBINLINE 0x0100  
-#define SO_TYPE 0x1008  
+#define SO_BROADCAST 0x0020
+#define SO_LINGER 0x0080
+#define SO_OOBINLINE 0x0100
+#define SO_TYPE 0x1008
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SO_STYLE SO_TYPE  
-#define SO_ERROR 0x1007  
-#define SO_SNDBUF 0x1001  
-#define SO_RCVBUF 0x1002  
+#define SO_STYLE SO_TYPE
+#define SO_ERROR 0x1007
+#define SO_SNDBUF 0x1001
+#define SO_RCVBUF 0x1002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SO_SNDLOWAT 0x1003  
-#define SO_RCVLOWAT 0x1004  
-#define SO_SNDTIMEO 0x1005  
-#define SO_RCVTIMEO 0x1006  
+#define SO_SNDLOWAT 0x1003
+#define SO_RCVLOWAT 0x1004
+#define SO_SNDTIMEO 0x1005
+#define SO_RCVTIMEO 0x1006
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_ACCEPTCONN 0x1009
-#define SO_PROTOCOL 0x1028  
-#define SO_DOMAIN 0x1029  
+#define SO_PROTOCOL 0x1028
+#define SO_DOMAIN 0x1029
 #define SO_NO_CHECK 11
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_PRIORITY 12
diff --git a/libc/kernel/arch-mips/asm/sockios.h b/libc/kernel/arch-mips/asm/sockios.h
index 0e5a4ac..c3b3334 100644
--- a/libc/kernel/arch-mips/asm/sockios.h
+++ b/libc/kernel/arch-mips/asm/sockios.h
@@ -26,6 +26,6 @@
 #define SIOCSPGRP _IOW('s', 8, pid_t)
 #define SIOCGPGRP _IOR('s', 9, pid_t)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCGSTAMP 0x8906  
-#define SIOCGSTAMPNS 0x8907  
+#define SIOCGSTAMP 0x8906
+#define SIOCGSTAMPNS 0x8907
 #endif
diff --git a/libc/kernel/arch-mips/asm/stat.h b/libc/kernel/arch-mips/asm/stat.h
index a8fee78..0b581b2 100644
--- a/libc/kernel/arch-mips/asm/stat.h
+++ b/libc/kernel/arch-mips/asm/stat.h
@@ -34,7 +34,7 @@
  gid_t st_gid;
  unsigned st_rdev;
  long st_pad2[2];
- off_t st_size;
+ __kernel_off_t st_size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  long st_pad3;
  time_t st_atime;
@@ -91,7 +91,7 @@
  unsigned int st_rdev;
  unsigned int st_pad1[3];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- off_t st_size;
+ __kernel_off_t st_size;
  unsigned int st_atime;
  unsigned int st_atime_nsec;
  unsigned int st_mtime;
diff --git a/libc/kernel/arch-mips/asm/sysmips.h b/libc/kernel/arch-mips/asm/sysmips.h
index 665f67f..96b18b8 100644
--- a/libc/kernel/arch-mips/asm/sysmips.h
+++ b/libc/kernel/arch-mips/asm/sysmips.h
@@ -18,11 +18,11 @@
  ****************************************************************************/
 #ifndef _ASM_SYSMIPS_H
 #define _ASM_SYSMIPS_H
-#define SETNAME 1  
-#define FLUSH_CACHE 3  
+#define SETNAME 1
+#define FLUSH_CACHE 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MIPS_FIXADE 7  
-#define MIPS_RDNVRAM 10  
-#define MIPS_ATOMIC_SET 2001  
+#define MIPS_FIXADE 7
+#define MIPS_RDNVRAM 10
+#define MIPS_ATOMIC_SET 2001
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-mips/asm/termbits.h b/libc/kernel/arch-mips/asm/termbits.h
index 6a0add7..cf6eb10 100644
--- a/libc/kernel/arch-mips/asm/termbits.h
+++ b/libc/kernel/arch-mips/asm/termbits.h
@@ -59,51 +59,51 @@
  speed_t c_ispeed;
  speed_t c_ospeed;
 };
-#define VINTR 0  
+#define VINTR 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VQUIT 1  
-#define VERASE 2  
-#define VKILL 3  
-#define VMIN 4  
+#define VQUIT 1
+#define VERASE 2
+#define VKILL 3
+#define VMIN 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VTIME 5  
-#define VEOL2 6  
-#define VSWTC 7  
+#define VTIME 5
+#define VEOL2 6
+#define VSWTC 7
 #define VSWTCH VSWTC
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VSTART 8  
-#define VSTOP 9  
-#define VSUSP 10  
-#define VREPRINT 12  
+#define VSTART 8
+#define VSTOP 9
+#define VSUSP 10
+#define VREPRINT 12
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VDISCARD 13  
-#define VWERASE 14  
-#define VLNEXT 15  
-#define VEOF 16  
+#define VDISCARD 13
+#define VWERASE 14
+#define VLNEXT 15
+#define VEOF 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VEOL 17  
-#define IGNBRK 0000001  
-#define BRKINT 0000002  
-#define IGNPAR 0000004  
+#define VEOL 17
+#define IGNBRK 0000001
+#define BRKINT 0000002
+#define IGNPAR 0000004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PARMRK 0000010  
-#define INPCK 0000020  
-#define ISTRIP 0000040  
-#define INLCR 0000100  
+#define PARMRK 0000010
+#define INPCK 0000020
+#define ISTRIP 0000040
+#define INLCR 0000100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IGNCR 0000200  
-#define ICRNL 0000400  
-#define IUCLC 0001000  
-#define IXON 0002000  
+#define IGNCR 0000200
+#define ICRNL 0000400
+#define IUCLC 0001000
+#define IXON 0002000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IXANY 0004000  
-#define IXOFF 0010000  
-#define IMAXBEL 0020000  
-#define IUTF8 0040000  
+#define IXANY 0004000
+#define IXOFF 0010000
+#define IMAXBEL 0020000
+#define IUTF8 0040000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OPOST 0000001  
-#define OLCUC 0000002  
-#define ONLCR 0000004  
+#define OPOST 0000001
+#define OLCUC 0000002
+#define ONLCR 0000004
 #define OCRNL 0000010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ONOCR 0000020
@@ -141,7 +141,7 @@
 #define FF1 0100000
 #define CBAUD 0010017
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define B0 0000000  
+#define B0 0000000
 #define B50 0000001
 #define B75 0000002
 #define B110 0000003
@@ -163,20 +163,20 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EXTA B19200
 #define EXTB B38400
-#define CSIZE 0000060  
-#define CS5 0000000  
+#define CSIZE 0000060
+#define CS5 0000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CS6 0000020  
-#define CS7 0000040  
-#define CS8 0000060  
-#define CSTOPB 0000100  
+#define CS6 0000020
+#define CS7 0000040
+#define CS8 0000060
+#define CSTOPB 0000100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CREAD 0000200  
-#define PARENB 0000400  
-#define PARODD 0001000  
-#define HUPCL 0002000  
+#define CREAD 0000200
+#define PARENB 0000400
+#define PARODD 0001000
+#define HUPCL 0002000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CLOCAL 0004000  
+#define CLOCAL 0004000
 #define CBAUDEX 0010000
 #define BOTHER 0010000
 #define B57600 0010001
@@ -198,43 +198,43 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define B3500000 0010016
 #define B4000000 0010017
-#define CIBAUD 002003600000  
-#define CMSPAR 010000000000  
+#define CIBAUD 002003600000
+#define CMSPAR 010000000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CRTSCTS 020000000000  
-#define IBSHIFT 16  
-#define ISIG 0000001  
-#define ICANON 0000002  
+#define CRTSCTS 020000000000
+#define IBSHIFT 16
+#define ISIG 0000001
+#define ICANON 0000002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define XCASE 0000004
-#define ECHO 0000010  
-#define ECHOE 0000020  
-#define ECHOK 0000040  
+#define ECHO 0000010
+#define ECHOE 0000020
+#define ECHOK 0000040
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ECHONL 0000100  
-#define NOFLSH 0000200  
-#define IEXTEN 0000400  
-#define ECHOCTL 0001000  
+#define ECHONL 0000100
+#define NOFLSH 0000200
+#define IEXTEN 0000400
+#define ECHOCTL 0001000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ECHOPRT 0002000  
-#define ECHOKE 0004000  
+#define ECHOPRT 0002000
+#define ECHOKE 0004000
 #define FLUSHO 0020000
-#define PENDIN 0040000  
+#define PENDIN 0040000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TOSTOP 0100000  
+#define TOSTOP 0100000
 #define ITOSTOP TOSTOP
-#define TIOCSER_TEMT 0x01  
-#define TCOOFF 0  
+#define TIOCSER_TEMT 0x01
+#define TCOOFF 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TCOON 1  
-#define TCIOFF 2  
-#define TCION 3  
-#define TCIFLUSH 0  
+#define TCOON 1
+#define TCIOFF 2
+#define TCION 3
+#define TCIFLUSH 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TCOFLUSH 1  
-#define TCIOFLUSH 2  
-#define TCSANOW TCSETS  
-#define TCSADRAIN TCSETSW  
+#define TCOFLUSH 1
+#define TCIOFLUSH 2
+#define TCSANOW TCSETS
+#define TCSADRAIN TCSETSW
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TCSAFLUSH TCSETSF  
+#define TCSAFLUSH TCSETSF
 #endif
diff --git a/libc/kernel/arch-mips/asm/termios.h b/libc/kernel/arch-mips/asm/termios.h
index d6f230e..e17acd8 100644
--- a/libc/kernel/arch-mips/asm/termios.h
+++ b/libc/kernel/arch-mips/asm/termios.h
@@ -68,20 +68,20 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned char c_cc[NCCS];
 };
-#define TIOCM_LE 0x001  
-#define TIOCM_DTR 0x002  
+#define TIOCM_LE 0x001
+#define TIOCM_DTR 0x002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCM_RTS 0x004  
-#define TIOCM_ST 0x010  
-#define TIOCM_SR 0x020  
-#define TIOCM_CTS 0x040  
+#define TIOCM_RTS 0x004
+#define TIOCM_ST 0x010
+#define TIOCM_SR 0x020
+#define TIOCM_CTS 0x040
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCM_CAR 0x100  
+#define TIOCM_CAR 0x100
 #define TIOCM_CD TIOCM_CAR
-#define TIOCM_RNG 0x200  
+#define TIOCM_RNG 0x200
 #define TIOCM_RI TIOCM_RNG
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCM_DSR 0x400  
+#define TIOCM_DSR 0x400
 #define TIOCM_OUT1 0x2000
 #define TIOCM_OUT2 0x4000
 #define TIOCM_LOOP 0x8000
diff --git a/libc/kernel/arch-mips/asm/unistd.h b/libc/kernel/arch-mips/asm/unistd.h
index 4a8744f..fda1b72 100644
--- a/libc/kernel/arch-mips/asm/unistd.h
+++ b/libc/kernel/arch-mips/asm/unistd.h
@@ -193,7 +193,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sysfs (__NR_Linux + 135)
 #define __NR_personality (__NR_Linux + 136)
-#define __NR_afs_syscall (__NR_Linux + 137)  
+#define __NR_afs_syscall (__NR_Linux + 137)
 #define __NR_setfsuid (__NR_Linux + 138)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setfsgid (__NR_Linux + 139)
diff --git a/libc/kernel/arch-mips/asm/vr41xx/irq.h b/libc/kernel/arch-mips/asm/vr41xx/irq.h
index 1c54b66..ecc74fc 100644
--- a/libc/kernel/arch-mips/asm/vr41xx/irq.h
+++ b/libc/kernel/arch-mips/asm/vr41xx/irq.h
@@ -59,7 +59,7 @@
 #define HSP_IRQ SYSINT2_IRQ(2)
 #define TCLOCK_IRQ SYSINT2_IRQ(3)
 #define FIR_IRQ SYSINT2_IRQ(4)
-#define CEU_IRQ SYSINT2_IRQ(4)  
+#define CEU_IRQ SYSINT2_IRQ(4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DSIU_IRQ SYSINT2_IRQ(5)
 #define PCI_IRQ SYSINT2_IRQ(6)
@@ -71,7 +71,7 @@
 #define SYSINT2_IRQ_LAST ETHERNET_IRQ
 #define GIU_IRQ_BASE 40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define GIU_IRQ(x) (GIU_IRQ_BASE + (x))  
+#define GIU_IRQ(x) (GIU_IRQ_BASE + (x))
 #define GIU_IRQ_LAST GIU_IRQ(31)
 #define VRC4173_IRQ_BASE 72
 #define VRC4173_IRQ(x) (VRC4173_IRQ_BASE + (x))
diff --git a/libc/kernel/arch-x86/asm/apicdef_32.h b/libc/kernel/arch-x86/asm/apicdef_32.h
index 1f1bb2f..e73ff21 100644
--- a/libc/kernel/arch-x86/asm/apicdef_32.h
+++ b/libc/kernel/arch-x86/asm/apicdef_32.h
@@ -36,7 +36,7 @@
 #define APIC_PROCPRI 0xA0
 #define APIC_EOI 0xB0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define APIC_EIO_ACK 0x0  
+#define APIC_EIO_ACK 0x0
 #define APIC_RRR 0xC0
 #define APIC_LDR 0xD0
 #define APIC_LDR_MASK (0xFF<<24)
@@ -53,7 +53,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define APIC_SPIV_APIC_ENABLED (1<<8)
 #define APIC_ISR 0x100
-#define APIC_ISR_NR 0x8  
+#define APIC_ISR_NR 0x8
 #define APIC_TMR 0x180
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define APIC_IRR 0x200
diff --git a/libc/kernel/arch-x86/asm/auxvec.h b/libc/kernel/arch-x86/asm/auxvec.h
index d3cffec..6a5978e 100644
--- a/libc/kernel/arch-x86/asm/auxvec.h
+++ b/libc/kernel/arch-x86/asm/auxvec.h
@@ -21,4 +21,5 @@
 #define AT_SYSINFO 32
 #define AT_SYSINFO_EHDR 33
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AT_VECTOR_SIZE_ARCH 2
 #endif
diff --git a/libc/kernel/arch-x86/asm/cmpxchg_32.h b/libc/kernel/arch-x86/asm/cmpxchg_32.h
index 0da9b38..588a0f1 100644
--- a/libc/kernel/arch-x86/asm/cmpxchg_32.h
+++ b/libc/kernel/arch-x86/asm/cmpxchg_32.h
@@ -18,7 +18,7 @@
  ****************************************************************************/
 #ifndef __ASM_CMPXCHG_H
 #define __ASM_CMPXCHG_H
-#include <linux/bitops.h>  
+#include <linux/bitops.h>
 #define xchg(ptr,v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr))))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct __xchg_dummy { unsigned long a[100]; };
diff --git a/libc/kernel/arch-x86/asm/cpufeature_32.h b/libc/kernel/arch-x86/asm/cpufeature_32.h
index d3caa6f..786836b 100644
--- a/libc/kernel/arch-x86/asm/cpufeature_32.h
+++ b/libc/kernel/arch-x86/asm/cpufeature_32.h
@@ -23,105 +23,105 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #include <asm/required-features.h>
-#define NCAPINTS 8  
-#define X86_FEATURE_FPU (0*32+ 0)  
+#define NCAPINTS 8
+#define X86_FEATURE_FPU (0*32+ 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_FEATURE_VME (0*32+ 1)  
-#define X86_FEATURE_DE (0*32+ 2)  
-#define X86_FEATURE_PSE (0*32+ 3)  
-#define X86_FEATURE_TSC (0*32+ 4)  
+#define X86_FEATURE_VME (0*32+ 1)
+#define X86_FEATURE_DE (0*32+ 2)
+#define X86_FEATURE_PSE (0*32+ 3)
+#define X86_FEATURE_TSC (0*32+ 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_FEATURE_MSR (0*32+ 5)  
-#define X86_FEATURE_PAE (0*32+ 6)  
-#define X86_FEATURE_MCE (0*32+ 7)  
-#define X86_FEATURE_CX8 (0*32+ 8)  
+#define X86_FEATURE_MSR (0*32+ 5)
+#define X86_FEATURE_PAE (0*32+ 6)
+#define X86_FEATURE_MCE (0*32+ 7)
+#define X86_FEATURE_CX8 (0*32+ 8)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_FEATURE_APIC (0*32+ 9)  
-#define X86_FEATURE_SEP (0*32+11)  
-#define X86_FEATURE_MTRR (0*32+12)  
-#define X86_FEATURE_PGE (0*32+13)  
+#define X86_FEATURE_APIC (0*32+ 9)
+#define X86_FEATURE_SEP (0*32+11)
+#define X86_FEATURE_MTRR (0*32+12)
+#define X86_FEATURE_PGE (0*32+13)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_FEATURE_MCA (0*32+14)  
-#define X86_FEATURE_CMOV (0*32+15)  
-#define X86_FEATURE_PAT (0*32+16)  
-#define X86_FEATURE_PSE36 (0*32+17)  
+#define X86_FEATURE_MCA (0*32+14)
+#define X86_FEATURE_CMOV (0*32+15)
+#define X86_FEATURE_PAT (0*32+16)
+#define X86_FEATURE_PSE36 (0*32+17)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_FEATURE_PN (0*32+18)  
-#define X86_FEATURE_CLFLSH (0*32+19)  
-#define X86_FEATURE_DS (0*32+21)  
-#define X86_FEATURE_ACPI (0*32+22)  
+#define X86_FEATURE_PN (0*32+18)
+#define X86_FEATURE_CLFLSH (0*32+19)
+#define X86_FEATURE_DS (0*32+21)
+#define X86_FEATURE_ACPI (0*32+22)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_FEATURE_MMX (0*32+23)  
-#define X86_FEATURE_FXSR (0*32+24)  
-#define X86_FEATURE_XMM (0*32+25)  
-#define X86_FEATURE_XMM2 (0*32+26)  
+#define X86_FEATURE_MMX (0*32+23)
+#define X86_FEATURE_FXSR (0*32+24)
+#define X86_FEATURE_XMM (0*32+25)
+#define X86_FEATURE_XMM2 (0*32+26)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_FEATURE_SELFSNOOP (0*32+27)  
-#define X86_FEATURE_HT (0*32+28)  
-#define X86_FEATURE_ACC (0*32+29)  
-#define X86_FEATURE_IA64 (0*32+30)  
+#define X86_FEATURE_SELFSNOOP (0*32+27)
+#define X86_FEATURE_HT (0*32+28)
+#define X86_FEATURE_ACC (0*32+29)
+#define X86_FEATURE_IA64 (0*32+30)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_FEATURE_SYSCALL (1*32+11)  
-#define X86_FEATURE_MP (1*32+19)  
-#define X86_FEATURE_NX (1*32+20)  
-#define X86_FEATURE_MMXEXT (1*32+22)  
+#define X86_FEATURE_SYSCALL (1*32+11)
+#define X86_FEATURE_MP (1*32+19)
+#define X86_FEATURE_NX (1*32+20)
+#define X86_FEATURE_MMXEXT (1*32+22)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_FEATURE_RDTSCP (1*32+27)  
-#define X86_FEATURE_LM (1*32+29)  
-#define X86_FEATURE_3DNOWEXT (1*32+30)  
-#define X86_FEATURE_3DNOW (1*32+31)  
+#define X86_FEATURE_RDTSCP (1*32+27)
+#define X86_FEATURE_LM (1*32+29)
+#define X86_FEATURE_3DNOWEXT (1*32+30)
+#define X86_FEATURE_3DNOW (1*32+31)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_FEATURE_RECOVERY (2*32+ 0)  
-#define X86_FEATURE_LONGRUN (2*32+ 1)  
-#define X86_FEATURE_LRTI (2*32+ 3)  
-#define X86_FEATURE_CXMMX (3*32+ 0)  
+#define X86_FEATURE_RECOVERY (2*32+ 0)
+#define X86_FEATURE_LONGRUN (2*32+ 1)
+#define X86_FEATURE_LRTI (2*32+ 3)
+#define X86_FEATURE_CXMMX (3*32+ 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_FEATURE_K6_MTRR (3*32+ 1)  
-#define X86_FEATURE_CYRIX_ARR (3*32+ 2)  
-#define X86_FEATURE_CENTAUR_MCR (3*32+ 3)  
-#define X86_FEATURE_K8 (3*32+ 4)  
+#define X86_FEATURE_K6_MTRR (3*32+ 1)
+#define X86_FEATURE_CYRIX_ARR (3*32+ 2)
+#define X86_FEATURE_CENTAUR_MCR (3*32+ 3)
+#define X86_FEATURE_K8 (3*32+ 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_FEATURE_K7 (3*32+ 5)  
-#define X86_FEATURE_P3 (3*32+ 6)  
-#define X86_FEATURE_P4 (3*32+ 7)  
-#define X86_FEATURE_CONSTANT_TSC (3*32+ 8)  
+#define X86_FEATURE_K7 (3*32+ 5)
+#define X86_FEATURE_P3 (3*32+ 6)
+#define X86_FEATURE_P4 (3*32+ 7)
+#define X86_FEATURE_CONSTANT_TSC (3*32+ 8)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_FEATURE_UP (3*32+ 9)  
-#define X86_FEATURE_FXSAVE_LEAK (3*32+10)  
-#define X86_FEATURE_ARCH_PERFMON (3*32+11)  
-#define X86_FEATURE_PEBS (3*32+12)  
+#define X86_FEATURE_UP (3*32+ 9)
+#define X86_FEATURE_FXSAVE_LEAK (3*32+10)
+#define X86_FEATURE_ARCH_PERFMON (3*32+11)
+#define X86_FEATURE_PEBS (3*32+12)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_FEATURE_BTS (3*32+13)  
-#define X86_FEATURE_SYNC_RDTSC (3*32+15)  
-#define X86_FEATURE_REP_GOOD (3*32+16)  
-#define X86_FEATURE_XMM3 (4*32+ 0)  
+#define X86_FEATURE_BTS (3*32+13)
+#define X86_FEATURE_SYNC_RDTSC (3*32+15)
+#define X86_FEATURE_REP_GOOD (3*32+16)
+#define X86_FEATURE_XMM3 (4*32+ 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_FEATURE_MWAIT (4*32+ 3)  
-#define X86_FEATURE_DSCPL (4*32+ 4)  
-#define X86_FEATURE_EST (4*32+ 7)  
-#define X86_FEATURE_TM2 (4*32+ 8)  
+#define X86_FEATURE_MWAIT (4*32+ 3)
+#define X86_FEATURE_DSCPL (4*32+ 4)
+#define X86_FEATURE_EST (4*32+ 7)
+#define X86_FEATURE_TM2 (4*32+ 8)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_FEATURE_CID (4*32+10)  
-#define X86_FEATURE_CX16 (4*32+13)  
-#define X86_FEATURE_XTPR (4*32+14)  
-#define X86_FEATURE_DCA (4*32+18)  
+#define X86_FEATURE_CID (4*32+10)
+#define X86_FEATURE_CX16 (4*32+13)
+#define X86_FEATURE_XTPR (4*32+14)
+#define X86_FEATURE_DCA (4*32+18)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_FEATURE_XSTORE (5*32+ 2)  
-#define X86_FEATURE_XSTORE_EN (5*32+ 3)  
-#define X86_FEATURE_XCRYPT (5*32+ 6)  
-#define X86_FEATURE_XCRYPT_EN (5*32+ 7)  
+#define X86_FEATURE_XSTORE (5*32+ 2)
+#define X86_FEATURE_XSTORE_EN (5*32+ 3)
+#define X86_FEATURE_XCRYPT (5*32+ 6)
+#define X86_FEATURE_XCRYPT_EN (5*32+ 7)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_FEATURE_ACE2 (5*32+ 8)  
-#define X86_FEATURE_ACE2_EN (5*32+ 9)  
-#define X86_FEATURE_PHE (5*32+ 10)  
-#define X86_FEATURE_PHE_EN (5*32+ 11)  
+#define X86_FEATURE_ACE2 (5*32+ 8)
+#define X86_FEATURE_ACE2_EN (5*32+ 9)
+#define X86_FEATURE_PHE (5*32+ 10)
+#define X86_FEATURE_PHE_EN (5*32+ 11)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_FEATURE_PMM (5*32+ 12)  
-#define X86_FEATURE_PMM_EN (5*32+ 13)  
-#define X86_FEATURE_LAHF_LM (6*32+ 0)  
-#define X86_FEATURE_CMP_LEGACY (6*32+ 1)  
+#define X86_FEATURE_PMM (5*32+ 12)
+#define X86_FEATURE_PMM_EN (5*32+ 13)
+#define X86_FEATURE_LAHF_LM (6*32+ 0)
+#define X86_FEATURE_CMP_LEGACY (6*32+ 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_FEATURE_IDA (7*32+ 0)  
+#define X86_FEATURE_IDA (7*32+ 0)
 #define cpu_has(c, bit)   (__builtin_constant_p(bit) &&   ( (((bit)>>5)==0 && (1UL<<((bit)&31) & REQUIRED_MASK0)) ||   (((bit)>>5)==1 && (1UL<<((bit)&31) & REQUIRED_MASK1)) ||   (((bit)>>5)==2 && (1UL<<((bit)&31) & REQUIRED_MASK2)) ||   (((bit)>>5)==3 && (1UL<<((bit)&31) & REQUIRED_MASK3)) ||   (((bit)>>5)==4 && (1UL<<((bit)&31) & REQUIRED_MASK4)) ||   (((bit)>>5)==5 && (1UL<<((bit)&31) & REQUIRED_MASK5)) ||   (((bit)>>5)==6 && (1UL<<((bit)&31) & REQUIRED_MASK6)) ||   (((bit)>>5)==7 && (1UL<<((bit)&31) & REQUIRED_MASK7)) )   ? 1 :   test_bit(bit, (c)->x86_capability))
 #define boot_cpu_has(bit) cpu_has(&boot_cpu_data, bit)
 #define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU)
diff --git a/libc/kernel/arch-x86/asm/desc_32.h b/libc/kernel/arch-x86/asm/desc_32.h
index bb98242..38cce3d 100644
--- a/libc/kernel/arch-x86/asm/desc_32.h
+++ b/libc/kernel/arch-x86/asm/desc_32.h
@@ -38,15 +38,15 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  struct desc_struct gdt[GDT_ENTRIES];
 } __attribute__((aligned(PAGE_SIZE)));
-#define DESCTYPE_LDT 0x82  
-#define DESCTYPE_TSS 0x89  
+#define DESCTYPE_LDT 0x82
+#define DESCTYPE_TSS 0x89
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DESCTYPE_TASK 0x85  
-#define DESCTYPE_INT 0x8e  
-#define DESCTYPE_TRAP 0x8f  
-#define DESCTYPE_DPL3 0x60  
+#define DESCTYPE_TASK 0x85
+#define DESCTYPE_INT 0x8e
+#define DESCTYPE_TRAP 0x8f
+#define DESCTYPE_DPL3 0x60
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DESCTYPE_S 0x10  
+#define DESCTYPE_S 0x10
 #define load_TR_desc() native_load_tr_desc()
 #define load_gdt(dtr) native_load_gdt(dtr)
 #define load_idt(dtr) native_load_idt(dtr)
diff --git a/libc/kernel/arch-x86/asm/dma_32.h b/libc/kernel/arch-x86/asm/dma_32.h
index 8b77878..ac6d193 100644
--- a/libc/kernel/arch-x86/asm/dma_32.h
+++ b/libc/kernel/arch-x86/asm/dma_32.h
@@ -18,8 +18,8 @@
  ****************************************************************************/
 #ifndef _ASM_DMA_H
 #define _ASM_DMA_H
-#include <linux/spinlock.h>  
-#include <asm/io.h>  
+#include <linux/spinlock.h>
+#include <asm/io.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <linux/delay.h>
 #ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER
@@ -32,34 +32,34 @@
 #define MAX_DMA_CHANNELS 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MAX_DMA_ADDRESS (PAGE_OFFSET+0x1000000)
-#define IO_DMA1_BASE 0x00  
-#define IO_DMA2_BASE 0xC0  
-#define DMA1_CMD_REG 0x08  
+#define IO_DMA1_BASE 0x00
+#define IO_DMA2_BASE 0xC0
+#define DMA1_CMD_REG 0x08
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DMA1_STAT_REG 0x08  
-#define DMA1_REQ_REG 0x09  
-#define DMA1_MASK_REG 0x0A  
-#define DMA1_MODE_REG 0x0B  
+#define DMA1_STAT_REG 0x08
+#define DMA1_REQ_REG 0x09
+#define DMA1_MASK_REG 0x0A
+#define DMA1_MODE_REG 0x0B
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DMA1_CLEAR_FF_REG 0x0C  
-#define DMA1_TEMP_REG 0x0D  
-#define DMA1_RESET_REG 0x0D  
-#define DMA1_CLR_MASK_REG 0x0E  
+#define DMA1_CLEAR_FF_REG 0x0C
+#define DMA1_TEMP_REG 0x0D
+#define DMA1_RESET_REG 0x0D
+#define DMA1_CLR_MASK_REG 0x0E
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DMA1_MASK_ALL_REG 0x0F  
-#define DMA2_CMD_REG 0xD0  
-#define DMA2_STAT_REG 0xD0  
-#define DMA2_REQ_REG 0xD2  
+#define DMA1_MASK_ALL_REG 0x0F
+#define DMA2_CMD_REG 0xD0
+#define DMA2_STAT_REG 0xD0
+#define DMA2_REQ_REG 0xD2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DMA2_MASK_REG 0xD4  
-#define DMA2_MODE_REG 0xD6  
-#define DMA2_CLEAR_FF_REG 0xD8  
-#define DMA2_TEMP_REG 0xDA  
+#define DMA2_MASK_REG 0xD4
+#define DMA2_MODE_REG 0xD6
+#define DMA2_CLEAR_FF_REG 0xD8
+#define DMA2_TEMP_REG 0xDA
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DMA2_RESET_REG 0xDA  
-#define DMA2_CLR_MASK_REG 0xDC  
-#define DMA2_MASK_ALL_REG 0xDE  
-#define DMA_ADDR_0 0x00  
+#define DMA2_RESET_REG 0xDA
+#define DMA2_CLR_MASK_REG 0xDC
+#define DMA2_MASK_ALL_REG 0xDE
+#define DMA_ADDR_0 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DMA_ADDR_1 0x02
 #define DMA_ADDR_2 0x04
@@ -69,7 +69,7 @@
 #define DMA_ADDR_5 0xC4
 #define DMA_ADDR_6 0xC8
 #define DMA_ADDR_7 0xCC
-#define DMA_CNT_0 0x01  
+#define DMA_CNT_0 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DMA_CNT_1 0x03
 #define DMA_CNT_2 0x05
@@ -79,7 +79,7 @@
 #define DMA_CNT_5 0xC6
 #define DMA_CNT_6 0xCA
 #define DMA_CNT_7 0xCE
-#define DMA_PAGE_0 0x87  
+#define DMA_PAGE_0 0x87
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DMA_PAGE_1 0x83
 #define DMA_PAGE_2 0x81
@@ -88,10 +88,10 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DMA_PAGE_6 0x89
 #define DMA_PAGE_7 0x8A
-#define DMA_MODE_READ 0x44  
-#define DMA_MODE_WRITE 0x48  
+#define DMA_MODE_READ 0x44
+#define DMA_MODE_WRITE 0x48
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DMA_MODE_CASCADE 0xC0  
+#define DMA_MODE_CASCADE 0xC0
 #define DMA_AUTOINIT 0x10
 #define isa_dma_bridge_buggy (0)
 #endif
diff --git a/libc/kernel/arch-x86/asm/e820.h b/libc/kernel/arch-x86/asm/e820.h
index 08d5af9..76ffbbd 100644
--- a/libc/kernel/arch-x86/asm/e820.h
+++ b/libc/kernel/arch-x86/asm/e820.h
@@ -18,10 +18,10 @@
  ****************************************************************************/
 #ifndef __ASM_E820_H
 #define __ASM_E820_H
-#define E820MAP 0x2d0  
-#define E820MAX 128  
+#define E820MAP 0x2d0
+#define E820MAX 128
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define E820NR 0x1e8  
+#define E820NR 0x1e8
 #define E820_RAM 1
 #define E820_RESERVED 2
 #define E820_ACPI 3
diff --git a/libc/kernel/arch-x86/asm/elf.h b/libc/kernel/arch-x86/asm/elf.h
deleted file mode 100644
index 2d1edfd..0000000
--- a/libc/kernel/arch-x86/asm/elf.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/****************************************************************************
- ****************************************************************************
- ***
- ***   This header was automatically generated from a Linux kernel header
- ***   of the same name, to make information necessary for userspace to
- ***   call into the kernel available to libc.  It contains only constants,
- ***   structures, and macros generated from the original header, and thus,
- ***   contains no copyrightable information.
- ***
- ***   To edit the content of this header, modify the corresponding
- ***   source file (e.g. under external/kernel-headers/original/) then
- ***   run bionic/libc/kernel/tools/update_all.py
- ***
- ***   Any manual change here will be lost the next time this script will
- ***   be run. You've been warned!
- ***
- ****************************************************************************
- ****************************************************************************/
-#ifndef _ASM_X86_ELF_H
-#define _ASM_X86_ELF_H
-#include <asm/ptrace.h>
-#include <asm/user.h>
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#include <asm/auxvec.h>
-typedef unsigned long elf_greg_t;
-#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
-typedef elf_greg_t elf_gregset_t[ELF_NGREG];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-typedef struct user_i387_struct elf_fpregset_t;
-typedef struct user_fxsr_struct elf_fpxregset_t;
-#define R_386_NONE 0
-#define R_386_32 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R_386_PC32 2
-#define R_386_GOT32 3
-#define R_386_PLT32 4
-#define R_386_COPY 5
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R_386_GLOB_DAT 6
-#define R_386_JMP_SLOT 7
-#define R_386_RELATIVE 8
-#define R_386_GOTOFF 9
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R_386_GOTPC 10
-#define R_386_NUM 11
-#define ELF_CLASS ELFCLASS32
-#define ELF_DATA ELFDATA2LSB
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ELF_ARCH EM_386
-#endif
diff --git a/libc/kernel/arch-x86/asm/io_32.h b/libc/kernel/arch-x86/asm/io_32.h
index e0615be..bb9e6f1 100644
--- a/libc/kernel/arch-x86/asm/io_32.h
+++ b/libc/kernel/arch-x86/asm/io_32.h
@@ -23,7 +23,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IO_SPACE_LIMIT 0xffff
 #define XQUAD_PORTIO_BASE 0xfe400000
-#define XQUAD_PORTIO_QUAD 0x40000  
+#define XQUAD_PORTIO_QUAD 0x40000
 #ifdef REALLY_SLOW_IO
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/arch-x86/asm/ioctls.h b/libc/kernel/arch-x86/asm/ioctls.h
index 9eccb2b..2178519 100644
--- a/libc/kernel/arch-x86/asm/ioctls.h
+++ b/libc/kernel/arch-x86/asm/ioctls.h
@@ -21,7 +21,7 @@
 #include <asm/ioctl.h>
 #define TCGETS 0x5401
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TCSETS 0x5402  
+#define TCSETS 0x5402
 #define TCSETSW 0x5403
 #define TCSETSF 0x5404
 #define TCGETA 0x5405
@@ -66,18 +66,18 @@
 #define TIOCSETD 0x5423
 #define TIOCGETD 0x5424
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TCSBRKP 0x5425  
-#define TIOCSBRK 0x5427  
-#define TIOCCBRK 0x5428  
-#define TIOCGSID 0x5429  
+#define TCSBRKP 0x5425
+#define TIOCSBRK 0x5427
+#define TIOCCBRK 0x5428
+#define TIOCGSID 0x5429
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCGETS2 _IOR('T',0x2A, struct termios2)
 #define TCSETS2 _IOW('T',0x2B, struct termios2)
 #define TCSETSW2 _IOW('T',0x2C, struct termios2)
 #define TCSETSF2 _IOW('T',0x2D, struct termios2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCGPTN _IOR('T',0x30, unsigned int)  
-#define TIOCSPTLCK _IOW('T',0x31, int)  
+#define TIOCGPTN _IOR('T',0x30, unsigned int)
+#define TIOCSPTLCK _IOW('T',0x31, int)
 #define FIONCLEX 0x5450
 #define FIOCLEX 0x5451
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -88,16 +88,16 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TIOCGLCKTRMIOS 0x5456
 #define TIOCSLCKTRMIOS 0x5457
-#define TIOCSERGSTRUCT 0x5458  
-#define TIOCSERGETLSR 0x5459  
+#define TIOCSERGSTRUCT 0x5458
+#define TIOCSERGETLSR 0x5459
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCSERGETMULTI 0x545A  
-#define TIOCSERSETMULTI 0x545B  
-#define TIOCMIWAIT 0x545C  
-#define TIOCGICOUNT 0x545D  
+#define TIOCSERGETMULTI 0x545A
+#define TIOCSERSETMULTI 0x545B
+#define TIOCMIWAIT 0x545C
+#define TIOCGICOUNT 0x545D
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCGHAYESESP 0x545E  
-#define TIOCSHAYESESP 0x545F  
+#define TIOCGHAYESESP 0x545E
+#define TIOCSHAYESESP 0x545F
 #define FIOQSIZE 0x5460
 #define TIOCPKT_DATA 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -108,6 +108,6 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TIOCPKT_NOSTOP 16
 #define TIOCPKT_DOSTOP 32
-#define TIOCSER_TEMT 0x01  
+#define TIOCSER_TEMT 0x01
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-x86/asm/local_32.h b/libc/kernel/arch-x86/asm/local_32.h
index 9c4c2b2..8c5b322 100644
--- a/libc/kernel/arch-x86/asm/local_32.h
+++ b/libc/kernel/arch-x86/asm/local_32.h
@@ -44,7 +44,7 @@
 #define __local_add(i,l) local_add((i),(l))
 #define __local_sub(i,l) local_sub((i),(l))
 #define cpu_local_wrap_v(l)   ({ local_t res__;   preempt_disable();   res__ = (l);   preempt_enable();   res__; })
-#define cpu_local_wrap(l)   ({ preempt_disable();   l;   preempt_enable(); })  
+#define cpu_local_wrap(l)   ({ preempt_disable();   l;   preempt_enable(); })
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define cpu_local_read(l) cpu_local_wrap_v(local_read(&__get_cpu_var(l)))
 #define cpu_local_set(l, i) cpu_local_wrap(local_set(&__get_cpu_var(l), (i)))
diff --git a/libc/kernel/arch-x86/asm/mc146818rtc_32.h b/libc/kernel/arch-x86/asm/mc146818rtc_32.h
index b6af33a..eff8581 100644
--- a/libc/kernel/arch-x86/asm/mc146818rtc_32.h
+++ b/libc/kernel/arch-x86/asm/mc146818rtc_32.h
@@ -26,7 +26,7 @@
 #ifndef RTC_PORT
 #define RTC_PORT(x) (0x70 + (x))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RTC_ALWAYS_BCD 1  
+#define RTC_ALWAYS_BCD 1
 #endif
 #ifdef __HAVE_ARCH_CMPXCHG
 #include <linux/smp.h>
diff --git a/libc/kernel/arch-x86/asm/mman.h b/libc/kernel/arch-x86/asm/mman.h
index b0b4e1d..6f1d71e 100644
--- a/libc/kernel/arch-x86/asm/mman.h
+++ b/libc/kernel/arch-x86/asm/mman.h
@@ -19,17 +19,17 @@
 #ifndef _ASM_X86_MMAN_H
 #define _ASM_X86_MMAN_H
 #include <asm-generic/mman.h>
-#define MAP_32BIT 0x40  
+#define MAP_32BIT 0x40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MAP_GROWSDOWN 0x0100  
-#define MAP_DENYWRITE 0x0800  
-#define MAP_EXECUTABLE 0x1000  
-#define MAP_LOCKED 0x2000  
+#define MAP_GROWSDOWN 0x0100
+#define MAP_DENYWRITE 0x0800
+#define MAP_EXECUTABLE 0x1000
+#define MAP_LOCKED 0x2000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MAP_NORESERVE 0x4000  
-#define MAP_POPULATE 0x8000  
-#define MAP_NONBLOCK 0x10000  
-#define MCL_CURRENT 1  
+#define MAP_NORESERVE 0x4000
+#define MAP_POPULATE 0x8000
+#define MAP_NONBLOCK 0x10000
+#define MCL_CURRENT 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MCL_FUTURE 2  
+#define MCL_FUTURE 2
 #endif
diff --git a/libc/kernel/arch-x86/asm/mpspec_def.h b/libc/kernel/arch-x86/asm/mpspec_def.h
index f9bb33a..f65ea9b 100644
--- a/libc/kernel/arch-x86/asm/mpspec_def.h
+++ b/libc/kernel/arch-x86/asm/mpspec_def.h
@@ -63,7 +63,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MP_INTSRC 3
 #define MP_LINTSRC 4
-#define MP_TRANSLATION 192  
+#define MP_TRANSLATION 192
 struct mpc_config_processor
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 {
@@ -72,8 +72,8 @@
  unsigned char mpc_apicver;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned char mpc_cpuflag;
-#define CPU_ENABLED 1  
-#define CPU_BOOTPROCESSOR 2  
+#define CPU_ENABLED 1
+#define CPU_BOOTPROCESSOR 2
  unsigned long mpc_cpufeature;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CPU_STEPPING_MASK 0x0F
@@ -93,10 +93,10 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BUSTYPE_EISA "EISA"
 #define BUSTYPE_ISA "ISA"
-#define BUSTYPE_INTERN "INTERN"  
+#define BUSTYPE_INTERN "INTERN"
 #define BUSTYPE_MCA "MCA"
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BUSTYPE_VL "VL"  
+#define BUSTYPE_VL "VL"
 #define BUSTYPE_PCI "PCI"
 #define BUSTYPE_PCMCIA "PCMCIA"
 #define BUSTYPE_CBUS "CBUS"
diff --git a/libc/kernel/arch-x86/asm/msr-index.h b/libc/kernel/arch-x86/asm/msr-index.h
index 2336f82..10b2726 100644
--- a/libc/kernel/arch-x86/asm/msr-index.h
+++ b/libc/kernel/arch-x86/asm/msr-index.h
@@ -18,21 +18,21 @@
  ****************************************************************************/
 #ifndef __ASM_MSR_INDEX_H
 #define __ASM_MSR_INDEX_H
-#define MSR_EFER 0xc0000080  
-#define MSR_STAR 0xc0000081  
+#define MSR_EFER 0xc0000080
+#define MSR_STAR 0xc0000081
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_LSTAR 0xc0000082  
-#define MSR_CSTAR 0xc0000083  
-#define MSR_SYSCALL_MASK 0xc0000084  
-#define MSR_FS_BASE 0xc0000100  
+#define MSR_LSTAR 0xc0000082
+#define MSR_CSTAR 0xc0000083
+#define MSR_SYSCALL_MASK 0xc0000084
+#define MSR_FS_BASE 0xc0000100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_GS_BASE 0xc0000101  
-#define MSR_KERNEL_GS_BASE 0xc0000102  
-#define _EFER_SCE 0  
-#define _EFER_LME 8  
+#define MSR_GS_BASE 0xc0000101
+#define MSR_KERNEL_GS_BASE 0xc0000102
+#define _EFER_SCE 0
+#define _EFER_LME 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define _EFER_LMA 10  
-#define _EFER_NX 11  
+#define _EFER_LMA 10
+#define _EFER_NX 11
 #define EFER_SCE (1<<_EFER_SCE)
 #define EFER_LME (1<<_EFER_LME)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -107,9 +107,9 @@
 #define MSR_K8_HWCR 0xc0010015
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSR_K8_ENABLE_C1E 0xc0010055
-#define K8_MTRRFIXRANGE_DRAM_ENABLE 0x00040000  
-#define K8_MTRRFIXRANGE_DRAM_MODIFY 0x00080000  
-#define K8_MTRR_RDMEM_WRMEM_MASK 0x18181818  
+#define K8_MTRRFIXRANGE_DRAM_ENABLE 0x00040000
+#define K8_MTRRFIXRANGE_DRAM_MODIFY 0x00080000
+#define K8_MTRR_RDMEM_WRMEM_MASK 0x18181818
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSR_K7_EVNTSEL0 0xc0010000
 #define MSR_K7_PERFCTR0 0xc0010004
@@ -294,7 +294,7 @@
 #define MSR_P4_SAAT_ESCR0 0x000003ae
 #define MSR_P4_SAAT_ESCR1 0x000003af
 #define MSR_P4_SSU_ESCR0 0x000003be
-#define MSR_P4_SSU_ESCR1 0x000003bf  
+#define MSR_P4_SSU_ESCR1 0x000003bf
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSR_P4_TBPU_ESCR0 0x000003c2
 #define MSR_P4_TBPU_ESCR1 0x000003c3
diff --git a/libc/kernel/arch-x86/asm/pgalloc_32.h b/libc/kernel/arch-x86/asm/pgalloc_32.h
index 022ca61..2490473 100644
--- a/libc/kernel/arch-x86/asm/pgalloc_32.h
+++ b/libc/kernel/arch-x86/asm/pgalloc_32.h
@@ -19,7 +19,7 @@
 #ifndef _I386_PGALLOC_H
 #define _I386_PGALLOC_H
 #include <linux/threads.h>
-#include <linux/mm.h>  
+#include <linux/mm.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define paravirt_alloc_pt(mm, pfn) do { } while (0)
 #define paravirt_alloc_pd(pfn) do { } while (0)
diff --git a/libc/kernel/arch-x86/asm/pgtable_32.h b/libc/kernel/arch-x86/asm/pgtable_32.h
index 4740571..64b6978 100644
--- a/libc/kernel/arch-x86/asm/pgtable_32.h
+++ b/libc/kernel/arch-x86/asm/pgtable_32.h
@@ -58,10 +58,10 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define _PAGE_BIT_ACCESSED 5
 #define _PAGE_BIT_DIRTY 6
-#define _PAGE_BIT_PSE 7  
-#define _PAGE_BIT_GLOBAL 8  
+#define _PAGE_BIT_PSE 7
+#define _PAGE_BIT_GLOBAL 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define _PAGE_BIT_UNUSED1 9  
+#define _PAGE_BIT_UNUSED1 9
 #define _PAGE_BIT_UNUSED2 10
 #define _PAGE_BIT_UNUSED3 11
 #define _PAGE_BIT_NX 63
@@ -74,15 +74,15 @@
 #define _PAGE_PCD 0x010
 #define _PAGE_ACCESSED 0x020
 #define _PAGE_DIRTY 0x040
-#define _PAGE_PSE 0x080  
+#define _PAGE_PSE 0x080
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define _PAGE_GLOBAL 0x100  
-#define _PAGE_UNUSED1 0x200  
+#define _PAGE_GLOBAL 0x100
+#define _PAGE_UNUSED1 0x200
 #define _PAGE_UNUSED2 0x400
 #define _PAGE_UNUSED3 0x800
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define _PAGE_FILE 0x040  
-#define _PAGE_PROTNONE 0x080  
+#define _PAGE_FILE 0x040
+#define _PAGE_PROTNONE 0x080
 #define _PAGE_NX 0
 #define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-x86/asm/processor-flags.h b/libc/kernel/arch-x86/asm/processor-flags.h
index ab46527..edea6e9 100644
--- a/libc/kernel/arch-x86/asm/processor-flags.h
+++ b/libc/kernel/arch-x86/asm/processor-flags.h
@@ -18,60 +18,60 @@
  ****************************************************************************/
 #ifndef __ASM_I386_PROCESSOR_FLAGS_H
 #define __ASM_I386_PROCESSOR_FLAGS_H
-#define X86_EFLAGS_CF 0x00000001  
-#define X86_EFLAGS_PF 0x00000004  
+#define X86_EFLAGS_CF 0x00000001
+#define X86_EFLAGS_PF 0x00000004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_EFLAGS_AF 0x00000010  
-#define X86_EFLAGS_ZF 0x00000040  
-#define X86_EFLAGS_SF 0x00000080  
-#define X86_EFLAGS_TF 0x00000100  
+#define X86_EFLAGS_AF 0x00000010
+#define X86_EFLAGS_ZF 0x00000040
+#define X86_EFLAGS_SF 0x00000080
+#define X86_EFLAGS_TF 0x00000100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_EFLAGS_IF 0x00000200  
-#define X86_EFLAGS_DF 0x00000400  
-#define X86_EFLAGS_OF 0x00000800  
-#define X86_EFLAGS_IOPL 0x00003000  
+#define X86_EFLAGS_IF 0x00000200
+#define X86_EFLAGS_DF 0x00000400
+#define X86_EFLAGS_OF 0x00000800
+#define X86_EFLAGS_IOPL 0x00003000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_EFLAGS_NT 0x00004000  
-#define X86_EFLAGS_RF 0x00010000  
-#define X86_EFLAGS_VM 0x00020000  
-#define X86_EFLAGS_AC 0x00040000  
+#define X86_EFLAGS_NT 0x00004000
+#define X86_EFLAGS_RF 0x00010000
+#define X86_EFLAGS_VM 0x00020000
+#define X86_EFLAGS_AC 0x00040000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_EFLAGS_VIF 0x00080000  
-#define X86_EFLAGS_VIP 0x00100000  
-#define X86_EFLAGS_ID 0x00200000  
-#define X86_CR0_PE 0x00000001  
+#define X86_EFLAGS_VIF 0x00080000
+#define X86_EFLAGS_VIP 0x00100000
+#define X86_EFLAGS_ID 0x00200000
+#define X86_CR0_PE 0x00000001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_CR0_MP 0x00000002  
-#define X86_CR0_EM 0x00000004  
-#define X86_CR0_TS 0x00000008  
-#define X86_CR0_ET 0x00000010  
+#define X86_CR0_MP 0x00000002
+#define X86_CR0_EM 0x00000004
+#define X86_CR0_TS 0x00000008
+#define X86_CR0_ET 0x00000010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_CR0_NE 0x00000020  
-#define X86_CR0_WP 0x00010000  
-#define X86_CR0_AM 0x00040000  
-#define X86_CR0_NW 0x20000000  
+#define X86_CR0_NE 0x00000020
+#define X86_CR0_WP 0x00010000
+#define X86_CR0_AM 0x00040000
+#define X86_CR0_NW 0x20000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_CR0_CD 0x40000000  
-#define X86_CR0_PG 0x80000000  
-#define X86_CR3_PWT 0x00000008  
-#define X86_CR3_PCD 0x00000010  
+#define X86_CR0_CD 0x40000000
+#define X86_CR0_PG 0x80000000
+#define X86_CR3_PWT 0x00000008
+#define X86_CR3_PCD 0x00000010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_CR4_VME 0x00000001  
-#define X86_CR4_PVI 0x00000002  
-#define X86_CR4_TSD 0x00000004  
-#define X86_CR4_DE 0x00000008  
+#define X86_CR4_VME 0x00000001
+#define X86_CR4_PVI 0x00000002
+#define X86_CR4_TSD 0x00000004
+#define X86_CR4_DE 0x00000008
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_CR4_PSE 0x00000010  
-#define X86_CR4_PAE 0x00000020  
-#define X86_CR4_MCE 0x00000040  
-#define X86_CR4_PGE 0x00000080  
+#define X86_CR4_PSE 0x00000010
+#define X86_CR4_PAE 0x00000020
+#define X86_CR4_MCE 0x00000040
+#define X86_CR4_PGE 0x00000080
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_CR4_PCE 0x00000100  
-#define X86_CR4_OSFXSR 0x00000200  
-#define X86_CR4_OSXMMEXCPT 0x00000400  
-#define X86_CR4_VMXE 0x00002000  
+#define X86_CR4_PCE 0x00000100
+#define X86_CR4_OSFXSR 0x00000200
+#define X86_CR4_OSXMMEXCPT 0x00000400
+#define X86_CR4_VMXE 0x00002000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define X86_CR8_TPR 0x0000000F  
+#define X86_CR8_TPR 0x0000000F
 #define CX86_PCR0 0x20
 #define CX86_GCR 0xb8
 #define CX86_CCR0 0xc0
diff --git a/libc/kernel/arch-x86/asm/processor_32.h b/libc/kernel/arch-x86/asm/processor_32.h
index c759016..beb3075 100644
--- a/libc/kernel/arch-x86/asm/processor_32.h
+++ b/libc/kernel/arch-x86/asm/processor_32.h
@@ -297,17 +297,17 @@
 #define GENERIC_NOP8 GENERIC_NOP1 GENERIC_NOP7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define K8_NOP1 GENERIC_NOP1
-#define K8_NOP2 ".byte 0x66,0x90\n" 
-#define K8_NOP3 ".byte 0x66,0x66,0x90\n" 
-#define K8_NOP4 ".byte 0x66,0x66,0x66,0x90\n" 
+#define K8_NOP2 ".byte 0x66,0x90\n"
+#define K8_NOP3 ".byte 0x66,0x66,0x90\n"
+#define K8_NOP4 ".byte 0x66,0x66,0x66,0x90\n"
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define K8_NOP5 K8_NOP3 K8_NOP2 
+#define K8_NOP5 K8_NOP3 K8_NOP2
 #define K8_NOP6 K8_NOP3 K8_NOP3
 #define K8_NOP7 K8_NOP4 K8_NOP3
 #define K8_NOP8 K8_NOP4 K8_NOP4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define K7_NOP1 GENERIC_NOP1
-#define K7_NOP2 ".byte 0x8b,0xc0\n" 
+#define K7_NOP2 ".byte 0x8b,0xc0\n"
 #define K7_NOP3 ".byte 0x8d,0x04,0x20\n"
 #define K7_NOP4 ".byte 0x8d,0x44,0x20,0x00\n"
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-x86/asm/ptrace.h b/libc/kernel/arch-x86/asm/ptrace.h
index 95d381e..2914411 100644
--- a/libc/kernel/arch-x86/asm/ptrace.h
+++ b/libc/kernel/arch-x86/asm/ptrace.h
@@ -18,7 +18,7 @@
  ****************************************************************************/
 #ifndef _ASM_X86_PTRACE_H
 #define _ASM_X86_PTRACE_H
-#include <linux/compiler.h>  
+#include <linux/compiler.h>
 #include <asm/ptrace-abi.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifndef __ASSEMBLY__
diff --git a/libc/kernel/arch-x86/asm/segment_32.h b/libc/kernel/arch-x86/asm/segment_32.h
index 5d7d0f9..a9b18ec 100644
--- a/libc/kernel/arch-x86/asm/segment_32.h
+++ b/libc/kernel/arch-x86/asm/segment_32.h
@@ -59,12 +59,12 @@
 #define GDT_ENTRY_PNPBIOS_DS (GDT_ENTRY_PNPBIOS_BASE + 2)
 #define GDT_ENTRY_PNPBIOS_TS1 (GDT_ENTRY_PNPBIOS_BASE + 3)
 #define GDT_ENTRY_PNPBIOS_TS2 (GDT_ENTRY_PNPBIOS_BASE + 4)
-#define PNP_CS32 (GDT_ENTRY_PNPBIOS_CS32 * 8)  
+#define PNP_CS32 (GDT_ENTRY_PNPBIOS_CS32 * 8)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PNP_CS16 (GDT_ENTRY_PNPBIOS_CS16 * 8)  
-#define PNP_DS (GDT_ENTRY_PNPBIOS_DS * 8)  
-#define PNP_TS1 (GDT_ENTRY_PNPBIOS_TS1 * 8)  
-#define PNP_TS2 (GDT_ENTRY_PNPBIOS_TS2 * 8)  
+#define PNP_CS16 (GDT_ENTRY_PNPBIOS_CS16 * 8)
+#define PNP_DS (GDT_ENTRY_PNPBIOS_DS * 8)
+#define PNP_TS1 (GDT_ENTRY_PNPBIOS_TS1 * 8)
+#define PNP_TS2 (GDT_ENTRY_PNPBIOS_TS2 * 8)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IDT_ENTRIES 256
 #define SEGMENT_RPL_MASK 0x3
diff --git a/libc/kernel/arch-x86/asm/shmparam.h b/libc/kernel/arch-x86/asm/shmparam.h
index 43fd83e..f761606 100644
--- a/libc/kernel/arch-x86/asm/shmparam.h
+++ b/libc/kernel/arch-x86/asm/shmparam.h
@@ -18,6 +18,6 @@
  ****************************************************************************/
 #ifndef _ASM_X86_SHMPARAM_H
 #define _ASM_X86_SHMPARAM_H
-#define SHMLBA PAGE_SIZE  
+#define SHMLBA PAGE_SIZE
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-x86/asm/smp_32.h b/libc/kernel/arch-x86/asm/smp_32.h
index e428b7b..3bc64f6 100644
--- a/libc/kernel/arch-x86/asm/smp_32.h
+++ b/libc/kernel/arch-x86/asm/smp_32.h
@@ -28,7 +28,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define safe_smp_processor_id() 0
 #define cpu_physical_id(cpu) boot_cpu_physical_apicid
-#define NO_PROC_ID 0xFF  
+#define NO_PROC_ID 0xFF
 #ifndef __ASSEMBLY__
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define hard_smp_processor_id() 0
diff --git a/libc/kernel/arch-x86/asm/sockios.h b/libc/kernel/arch-x86/asm/sockios.h
index d8bd1a3..d0829db 100644
--- a/libc/kernel/arch-x86/asm/sockios.h
+++ b/libc/kernel/arch-x86/asm/sockios.h
@@ -24,7 +24,7 @@
 #define FIOGETOWN 0x8903
 #define SIOCGPGRP 0x8904
 #define SIOCATMARK 0x8905
-#define SIOCGSTAMP 0x8906  
+#define SIOCGSTAMP 0x8906
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCGSTAMPNS 0x8907  
+#define SIOCGSTAMPNS 0x8907
 #endif
diff --git a/libc/kernel/arch-x86/asm/termbits.h b/libc/kernel/arch-x86/asm/termbits.h
index 0d03ddd..fce7bac 100644
--- a/libc/kernel/arch-x86/asm/termbits.h
+++ b/libc/kernel/arch-x86/asm/termbits.h
@@ -139,7 +139,7 @@
 #define FF0 0000000
 #define FF1 0100000
 #define CBAUD 0010017
-#define B0 0000000  
+#define B0 0000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define B50 0000001
 #define B75 0000002
@@ -177,7 +177,7 @@
 #define CLOCAL 0004000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CBAUDEX 0010000
-#define BOTHER 0010000  
+#define BOTHER 0010000
 #define B57600 0010001
 #define B115200 0010002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -197,11 +197,11 @@
 #define B3500000 0010016
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define B4000000 0010017
-#define CIBAUD 002003600000  
-#define CMSPAR 010000000000  
-#define CRTSCTS 020000000000  
+#define CIBAUD 002003600000
+#define CMSPAR 010000000000
+#define CRTSCTS 020000000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IBSHIFT 16  
+#define IBSHIFT 16
 #define ISIG 0000001
 #define ICANON 0000002
 #define XCASE 0000004
diff --git a/libc/kernel/arch-x86/asm/termios.h b/libc/kernel/arch-x86/asm/termios.h
index 2aca2fc..25e0b6d 100644
--- a/libc/kernel/arch-x86/asm/termios.h
+++ b/libc/kernel/arch-x86/asm/termios.h
@@ -84,17 +84,17 @@
 #define N_PPP 3
 #define N_STRIP 4
 #define N_AX25 5
-#define N_X25 6  
+#define N_X25 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define N_6PACK 7
-#define N_MASC 8  
-#define N_R3964 9  
-#define N_PROFIBUS_FDL 10  
+#define N_MASC 8
+#define N_R3964 9
+#define N_PROFIBUS_FDL 10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define N_IRDA 11  
-#define N_SMSBLOCK 12  
-#define N_HDLC 13  
+#define N_IRDA 11
+#define N_SMSBLOCK 12
+#define N_HDLC 13
 #define N_SYNC_PPP 14
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define N_HCI 15  
+#define N_HCI 15
 #endif
diff --git a/libc/kernel/arch-x86/asm/tsc.h b/libc/kernel/arch-x86/asm/tsc.h
index e99a1a5..e34f6d1 100644
--- a/libc/kernel/arch-x86/asm/tsc.h
+++ b/libc/kernel/arch-x86/asm/tsc.h
@@ -19,8 +19,8 @@
 #ifndef _ASM_X86_TSC_H
 #define _ASM_X86_TSC_H
 #include <asm/processor.h>
-#define NS_SCALE 10  
+#define NS_SCALE 10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define US_SCALE 32  
+#define US_SCALE 32
 typedef unsigned long long cycles_t;
 #endif
diff --git a/libc/kernel/arch-x86/asm/ucontext.h b/libc/kernel/arch-x86/asm/ucontext.h
index e2326e5..9ceffac 100644
--- a/libc/kernel/arch-x86/asm/ucontext.h
+++ b/libc/kernel/arch-x86/asm/ucontext.h
@@ -18,7 +18,7 @@
  ****************************************************************************/
 #ifndef _ASM_X86_UCONTEXT_H
 #define _ASM_X86_UCONTEXT_H
-#define UC_FP_XSTATE 0x1  
+#define UC_FP_XSTATE 0x1
 #include <asm-generic/ucontext.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/arch-x86/asm/unistd_32.h b/libc/kernel/arch-x86/asm/unistd_32.h
index b2193a2..5c1a108 100644
--- a/libc/kernel/arch-x86/asm/unistd_32.h
+++ b/libc/kernel/arch-x86/asm/unistd_32.h
@@ -113,7 +113,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sethostname 74
 #define __NR_setrlimit 75
-#define __NR_getrlimit 76  
+#define __NR_getrlimit 76
 #define __NR_getrusage 77
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_gettimeofday 78
@@ -189,7 +189,7 @@
 #define __NR_bdflush 134
 #define __NR_sysfs 135
 #define __NR_personality 136
-#define __NR_afs_syscall 137  
+#define __NR_afs_syscall 137
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setfsuid 138
 #define __NR_setfsgid 139
@@ -253,11 +253,11 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sigaltstack 186
 #define __NR_sendfile 187
-#define __NR_getpmsg 188  
-#define __NR_putpmsg 189  
+#define __NR_getpmsg 188
+#define __NR_putpmsg 189
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_vfork 190
-#define __NR_ugetrlimit 191  
+#define __NR_ugetrlimit 191
 #define __NR_mmap2 192
 #define __NR_truncate64 193
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -293,7 +293,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mincore 218
 #define __NR_madvise 219
-#define __NR_madvise1 219  
+#define __NR_madvise1 219
 #define __NR_getdents64 220
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fcntl64 221
diff --git a/libc/kernel/arch-x86/asm/vm86.h b/libc/kernel/arch-x86/asm/vm86.h
index 222a11e..9568930 100644
--- a/libc/kernel/arch-x86/asm/vm86.h
+++ b/libc/kernel/arch-x86/asm/vm86.h
@@ -23,11 +23,11 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IOPL_MASK 0x00003000
 #define NT_MASK 0x00004000
-#define VM_MASK 0  
+#define VM_MASK 0
 #define AC_MASK 0x00040000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VIF_MASK 0x00080000  
-#define VIP_MASK 0x00100000  
+#define VIF_MASK 0x00080000
+#define VIP_MASK 0x00100000
 #define ID_MASK 0x00200000
 #define BIOSSEG 0x0f000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -41,13 +41,13 @@
 #define VM86_TYPE(retval) ((retval) & 0xff)
 #define VM86_ARG(retval) ((retval) >> 8)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VM86_SIGNAL 0  
-#define VM86_UNKNOWN 1  
-#define VM86_INTx 2  
-#define VM86_STI 3  
+#define VM86_SIGNAL 0
+#define VM86_UNKNOWN 1
+#define VM86_INTx 2
+#define VM86_STI 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VM86_PICRETURN 4  
-#define VM86_TRAP 6  
+#define VM86_PICRETURN 4
+#define VM86_TRAP 6
 #define VM86_PLUS_INSTALL_CHECK 0
 #define VM86_ENTER 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-x86/asm/voyager.h b/libc/kernel/arch-x86/asm/voyager.h
index 364b211..da973b3 100644
--- a/libc/kernel/arch-x86/asm/voyager.h
+++ b/libc/kernel/arch-x86/asm/voyager.h
@@ -171,15 +171,15 @@
  __u16 jtag_offset;
 } __attribute__((packed)) voyager_at_t;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VOYAGER_WCBIC0 0x41  
-#define VOYAGER_WCBIC1 0x49  
-#define VOYAGER_WCBIC2 0x51  
-#define VOYAGER_WCBIC3 0x59  
+#define VOYAGER_WCBIC0 0x41
+#define VOYAGER_WCBIC1 0x49
+#define VOYAGER_WCBIC2 0x51
+#define VOYAGER_WCBIC3 0x59
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VOYAGER_WCBIC4 0x61  
-#define VOYAGER_WCBIC5 0x69  
-#define VOYAGER_WCBIC6 0x71  
-#define VOYAGER_WCBIC7 0x79  
+#define VOYAGER_WCBIC4 0x61
+#define VOYAGER_WCBIC5 0x69
+#define VOYAGER_WCBIC6 0x71
+#define VOYAGER_WCBIC7 0x79
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VOYAGER_WCBIC_TOM_L 0x4
 #define VOYAGER_WCBIC_TOM_H 0x5
@@ -292,11 +292,11 @@
 #define NUMBER_OF_MC_BUSSES 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SLOTS_PER_MC_BUS 8
-#define MAX_CPUS 16  
-#define MAX_PROCESSOR_BOARDS 4  
-#define MAX_CACHE_LEVELS 4  
+#define MAX_CPUS 16
+#define MAX_PROCESSOR_BOARDS 4
+#define MAX_CACHE_LEVELS 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MAX_SHARED_CPUS 4  
+#define MAX_SHARED_CPUS 4
 #define NUMBER_OF_POS_REGS 8
 typedef struct {
  __u8 MC_Slot;
diff --git a/libc/kernel/common/asm-generic/errno-base.h b/libc/kernel/common/asm-generic/errno-base.h
index 82c5a0e..a26bf75 100644
--- a/libc/kernel/common/asm-generic/errno-base.h
+++ b/libc/kernel/common/asm-generic/errno-base.h
@@ -18,47 +18,47 @@
  ****************************************************************************/
 #ifndef _ASM_GENERIC_ERRNO_BASE_H
 #define _ASM_GENERIC_ERRNO_BASE_H
-#define EPERM 1  
-#define ENOENT 2  
+#define EPERM 1
+#define ENOENT 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ESRCH 3  
-#define EINTR 4  
-#define EIO 5  
-#define ENXIO 6  
+#define ESRCH 3
+#define EINTR 4
+#define EIO 5
+#define ENXIO 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define E2BIG 7  
-#define ENOEXEC 8  
-#define EBADF 9  
-#define ECHILD 10  
+#define E2BIG 7
+#define ENOEXEC 8
+#define EBADF 9
+#define ECHILD 10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EAGAIN 11  
-#define ENOMEM 12  
-#define EACCES 13  
-#define EFAULT 14  
+#define EAGAIN 11
+#define ENOMEM 12
+#define EACCES 13
+#define EFAULT 14
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ENOTBLK 15  
-#define EBUSY 16  
-#define EEXIST 17  
-#define EXDEV 18  
+#define ENOTBLK 15
+#define EBUSY 16
+#define EEXIST 17
+#define EXDEV 18
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ENODEV 19  
-#define ENOTDIR 20  
-#define EISDIR 21  
-#define EINVAL 22  
+#define ENODEV 19
+#define ENOTDIR 20
+#define EISDIR 21
+#define EINVAL 22
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ENFILE 23  
-#define EMFILE 24  
-#define ENOTTY 25  
-#define ETXTBSY 26  
+#define ENFILE 23
+#define EMFILE 24
+#define ENOTTY 25
+#define ETXTBSY 26
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EFBIG 27  
-#define ENOSPC 28  
-#define ESPIPE 29  
-#define EROFS 30  
+#define EFBIG 27
+#define ENOSPC 28
+#define ESPIPE 29
+#define EROFS 30
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EMLINK 31  
-#define EPIPE 32  
-#define EDOM 33  
-#define ERANGE 34  
+#define EMLINK 31
+#define EPIPE 32
+#define EDOM 33
+#define ERANGE 34
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/common/asm-generic/errno.h b/libc/kernel/common/asm-generic/errno.h
index 1ef9ba9..2ca94f2 100644
--- a/libc/kernel/common/asm-generic/errno.h
+++ b/libc/kernel/common/asm-generic/errno.h
@@ -19,126 +19,126 @@
 #ifndef _ASM_GENERIC_ERRNO_H
 #define _ASM_GENERIC_ERRNO_H
 #include <asm-generic/errno-base.h>
-#define EDEADLK 35  
+#define EDEADLK 35
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ENAMETOOLONG 36  
-#define ENOLCK 37  
-#define ENOSYS 38  
-#define ENOTEMPTY 39  
+#define ENAMETOOLONG 36
+#define ENOLCK 37
+#define ENOSYS 38
+#define ENOTEMPTY 39
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ELOOP 40  
-#define EWOULDBLOCK EAGAIN  
-#define ENOMSG 42  
-#define EIDRM 43  
+#define ELOOP 40
+#define EWOULDBLOCK EAGAIN
+#define ENOMSG 42
+#define EIDRM 43
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ECHRNG 44  
-#define EL2NSYNC 45  
-#define EL3HLT 46  
-#define EL3RST 47  
+#define ECHRNG 44
+#define EL2NSYNC 45
+#define EL3HLT 46
+#define EL3RST 47
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ELNRNG 48  
-#define EUNATCH 49  
-#define ENOCSI 50  
-#define EL2HLT 51  
+#define ELNRNG 48
+#define EUNATCH 49
+#define ENOCSI 50
+#define EL2HLT 51
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EBADE 52  
-#define EBADR 53  
-#define EXFULL 54  
-#define ENOANO 55  
+#define EBADE 52
+#define EBADR 53
+#define EXFULL 54
+#define ENOANO 55
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EBADRQC 56  
-#define EBADSLT 57  
+#define EBADRQC 56
+#define EBADSLT 57
 #define EDEADLOCK EDEADLK
-#define EBFONT 59  
+#define EBFONT 59
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ENOSTR 60  
-#define ENODATA 61  
-#define ETIME 62  
-#define ENOSR 63  
+#define ENOSTR 60
+#define ENODATA 61
+#define ETIME 62
+#define ENOSR 63
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ENONET 64  
-#define ENOPKG 65  
-#define EREMOTE 66  
-#define ENOLINK 67  
+#define ENONET 64
+#define ENOPKG 65
+#define EREMOTE 66
+#define ENOLINK 67
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EADV 68  
-#define ESRMNT 69  
-#define ECOMM 70  
-#define EPROTO 71  
+#define EADV 68
+#define ESRMNT 69
+#define ECOMM 70
+#define EPROTO 71
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EMULTIHOP 72  
-#define EDOTDOT 73  
-#define EBADMSG 74  
-#define EOVERFLOW 75  
+#define EMULTIHOP 72
+#define EDOTDOT 73
+#define EBADMSG 74
+#define EOVERFLOW 75
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ENOTUNIQ 76  
-#define EBADFD 77  
-#define EREMCHG 78  
-#define ELIBACC 79  
+#define ENOTUNIQ 76
+#define EBADFD 77
+#define EREMCHG 78
+#define ELIBACC 79
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ELIBBAD 80  
-#define ELIBSCN 81  
-#define ELIBMAX 82  
-#define ELIBEXEC 83  
+#define ELIBBAD 80
+#define ELIBSCN 81
+#define ELIBMAX 82
+#define ELIBEXEC 83
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EILSEQ 84  
-#define ERESTART 85  
-#define ESTRPIPE 86  
-#define EUSERS 87  
+#define EILSEQ 84
+#define ERESTART 85
+#define ESTRPIPE 86
+#define EUSERS 87
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ENOTSOCK 88  
-#define EDESTADDRREQ 89  
-#define EMSGSIZE 90  
-#define EPROTOTYPE 91  
+#define ENOTSOCK 88
+#define EDESTADDRREQ 89
+#define EMSGSIZE 90
+#define EPROTOTYPE 91
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ENOPROTOOPT 92  
-#define EPROTONOSUPPORT 93  
-#define ESOCKTNOSUPPORT 94  
-#define EOPNOTSUPP 95  
+#define ENOPROTOOPT 92
+#define EPROTONOSUPPORT 93
+#define ESOCKTNOSUPPORT 94
+#define EOPNOTSUPP 95
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EPFNOSUPPORT 96  
-#define EAFNOSUPPORT 97  
-#define EADDRINUSE 98  
-#define EADDRNOTAVAIL 99  
+#define EPFNOSUPPORT 96
+#define EAFNOSUPPORT 97
+#define EADDRINUSE 98
+#define EADDRNOTAVAIL 99
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ENETDOWN 100  
-#define ENETUNREACH 101  
-#define ENETRESET 102  
-#define ECONNABORTED 103  
+#define ENETDOWN 100
+#define ENETUNREACH 101
+#define ENETRESET 102
+#define ECONNABORTED 103
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ECONNRESET 104  
-#define ENOBUFS 105  
-#define EISCONN 106  
-#define ENOTCONN 107  
+#define ECONNRESET 104
+#define ENOBUFS 105
+#define EISCONN 106
+#define ENOTCONN 107
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ESHUTDOWN 108  
-#define ETOOMANYREFS 109  
-#define ETIMEDOUT 110  
-#define ECONNREFUSED 111  
+#define ESHUTDOWN 108
+#define ETOOMANYREFS 109
+#define ETIMEDOUT 110
+#define ECONNREFUSED 111
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EHOSTDOWN 112  
-#define EHOSTUNREACH 113  
-#define EALREADY 114  
-#define EINPROGRESS 115  
+#define EHOSTDOWN 112
+#define EHOSTUNREACH 113
+#define EALREADY 114
+#define EINPROGRESS 115
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ESTALE 116  
-#define EUCLEAN 117  
-#define ENOTNAM 118  
-#define ENAVAIL 119  
+#define ESTALE 116
+#define EUCLEAN 117
+#define ENOTNAM 118
+#define ENAVAIL 119
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EISNAM 120  
-#define EREMOTEIO 121  
-#define EDQUOT 122  
-#define ENOMEDIUM 123  
+#define EISNAM 120
+#define EREMOTEIO 121
+#define EDQUOT 122
+#define ENOMEDIUM 123
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EMEDIUMTYPE 124  
-#define ECANCELED 125  
-#define ENOKEY 126  
-#define EKEYEXPIRED 127  
+#define EMEDIUMTYPE 124
+#define ECANCELED 125
+#define ENOKEY 126
+#define EKEYEXPIRED 127
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EKEYREVOKED 128  
-#define EKEYREJECTED 129  
-#define EOWNERDEAD 130  
-#define ENOTRECOVERABLE 131  
+#define EKEYREVOKED 128
+#define EKEYREJECTED 129
+#define EOWNERDEAD 130
+#define ENOTRECOVERABLE 131
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/common/asm-generic/fcntl.h b/libc/kernel/common/asm-generic/fcntl.h
index be03cdf..8e96f80 100644
--- a/libc/kernel/common/asm-generic/fcntl.h
+++ b/libc/kernel/common/asm-generic/fcntl.h
@@ -26,18 +26,18 @@
 #define O_RDWR 00000002
 #ifndef O_CREAT
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define O_CREAT 00000100  
+#define O_CREAT 00000100
 #endif
 #ifndef O_EXCL
-#define O_EXCL 00000200  
+#define O_EXCL 00000200
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #ifndef O_NOCTTY
-#define O_NOCTTY 00000400  
+#define O_NOCTTY 00000400
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifndef O_TRUNC
-#define O_TRUNC 00001000  
+#define O_TRUNC 00001000
 #endif
 #ifndef O_APPEND
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -48,33 +48,33 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #ifndef O_DSYNC
-#define O_DSYNC 00010000  
+#define O_DSYNC 00010000
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifndef FASYNC
-#define FASYNC 00020000  
+#define FASYNC 00020000
 #endif
 #ifndef O_DIRECT
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define O_DIRECT 00040000  
+#define O_DIRECT 00040000
 #endif
 #ifndef O_LARGEFILE
 #define O_LARGEFILE 00100000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #ifndef O_DIRECTORY
-#define O_DIRECTORY 00200000  
+#define O_DIRECTORY 00200000
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifndef O_NOFOLLOW
-#define O_NOFOLLOW 00400000  
+#define O_NOFOLLOW 00400000
 #endif
 #ifndef O_NOATIME
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define O_NOATIME 01000000
 #endif
 #ifndef O_CLOEXEC
-#define O_CLOEXEC 02000000  
+#define O_CLOEXEC 02000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #ifndef O_SYNC
@@ -89,12 +89,12 @@
 #ifndef O_NDELAY
 #define O_NDELAY O_NONBLOCK
 #endif
-#define F_DUPFD 0  
+#define F_DUPFD 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define F_GETFD 1  
-#define F_SETFD 2  
-#define F_GETFL 3  
-#define F_SETFL 4  
+#define F_GETFD 1
+#define F_SETFD 2
+#define F_GETFL 3
+#define F_SETFL 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifndef F_GETLK
 #define F_GETLK 5
@@ -103,17 +103,17 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #ifndef F_SETOWN
-#define F_SETOWN 8  
-#define F_GETOWN 9  
+#define F_SETOWN 8
+#define F_GETOWN 9
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #ifndef F_SETSIG
-#define F_SETSIG 10  
-#define F_GETSIG 11  
+#define F_SETSIG 10
+#define F_GETSIG 11
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #ifndef F_GETLK64
-#define F_GETLK64 12  
+#define F_GETLK64 12
 #define F_SETLK64 13
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define F_SETLKW64 14
@@ -132,7 +132,7 @@
  __kernel_pid_t pid;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define FD_CLOEXEC 1  
+#define FD_CLOEXEC 1
 #ifndef F_RDLCK
 #define F_RDLCK 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -141,19 +141,19 @@
 #endif
 #ifndef F_EXLCK
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define F_EXLCK 4  
-#define F_SHLCK 8  
+#define F_EXLCK 4
+#define F_SHLCK 8
 #endif
-#define LOCK_SH 1  
+#define LOCK_SH 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define LOCK_EX 2  
-#define LOCK_NB 4  
-#define LOCK_UN 8  
-#define LOCK_MAND 32  
+#define LOCK_EX 2
+#define LOCK_NB 4
+#define LOCK_UN 8
+#define LOCK_MAND 32
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define LOCK_READ 64  
-#define LOCK_WRITE 128  
-#define LOCK_RW 192  
+#define LOCK_READ 64
+#define LOCK_WRITE 128
+#define LOCK_RW 192
 #define F_LINUX_SPECIFIC_BASE 1024
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifndef HAVE_ARCH_STRUCT_FLOCK
@@ -189,4 +189,3 @@
 };
 #endif
 #endif
-
diff --git a/libc/kernel/common/asm-generic/mman-common.h b/libc/kernel/common/asm-generic/mman-common.h
index 157353b..0dbb503 100644
--- a/libc/kernel/common/asm-generic/mman-common.h
+++ b/libc/kernel/common/asm-generic/mman-common.h
@@ -18,43 +18,43 @@
  ****************************************************************************/
 #ifndef __ASM_GENERIC_MMAN_COMMON_H
 #define __ASM_GENERIC_MMAN_COMMON_H
-#define PROT_READ 0x1  
-#define PROT_WRITE 0x2  
+#define PROT_READ 0x1
+#define PROT_WRITE 0x2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PROT_EXEC 0x4  
-#define PROT_SEM 0x8  
-#define PROT_NONE 0x0  
-#define PROT_GROWSDOWN 0x01000000  
+#define PROT_EXEC 0x4
+#define PROT_SEM 0x8
+#define PROT_NONE 0x0
+#define PROT_GROWSDOWN 0x01000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PROT_GROWSUP 0x02000000  
-#define MAP_SHARED 0x01  
-#define MAP_PRIVATE 0x02  
-#define MAP_TYPE 0x0f  
+#define PROT_GROWSUP 0x02000000
+#define MAP_SHARED 0x01
+#define MAP_PRIVATE 0x02
+#define MAP_TYPE 0x0f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MAP_FIXED 0x10  
-#define MAP_ANONYMOUS 0x20  
-#define MAP_UNINITIALIZED 0x0  
-#define MS_ASYNC 1  
+#define MAP_FIXED 0x10
+#define MAP_ANONYMOUS 0x20
+#define MAP_UNINITIALIZED 0x0
+#define MS_ASYNC 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MS_INVALIDATE 2  
-#define MS_SYNC 4  
-#define MADV_NORMAL 0  
-#define MADV_RANDOM 1  
+#define MS_INVALIDATE 2
+#define MS_SYNC 4
+#define MADV_NORMAL 0
+#define MADV_RANDOM 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MADV_SEQUENTIAL 2  
-#define MADV_WILLNEED 3  
-#define MADV_DONTNEED 4  
-#define MADV_REMOVE 9  
+#define MADV_SEQUENTIAL 2
+#define MADV_WILLNEED 3
+#define MADV_DONTNEED 4
+#define MADV_REMOVE 9
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MADV_DONTFORK 10  
-#define MADV_DOFORK 11  
-#define MADV_HWPOISON 100  
-#define MADV_SOFT_OFFLINE 101  
+#define MADV_DONTFORK 10
+#define MADV_DOFORK 11
+#define MADV_HWPOISON 100
+#define MADV_SOFT_OFFLINE 101
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MADV_MERGEABLE 12  
-#define MADV_UNMERGEABLE 13  
-#define MADV_HUGEPAGE 14  
-#define MADV_NOHUGEPAGE 15  
+#define MADV_MERGEABLE 12
+#define MADV_UNMERGEABLE 13
+#define MADV_HUGEPAGE 14
+#define MADV_NOHUGEPAGE 15
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MAP_FILE 0
 #endif
diff --git a/libc/kernel/common/asm-generic/mman.h b/libc/kernel/common/asm-generic/mman.h
index 6eaf900..5a0242a 100644
--- a/libc/kernel/common/asm-generic/mman.h
+++ b/libc/kernel/common/asm-generic/mman.h
@@ -19,18 +19,18 @@
 #ifndef __ASM_GENERIC_MMAN_H
 #define __ASM_GENERIC_MMAN_H
 #include <asm-generic/mman-common.h>
-#define MAP_GROWSDOWN 0x0100  
+#define MAP_GROWSDOWN 0x0100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MAP_DENYWRITE 0x0800  
-#define MAP_EXECUTABLE 0x1000  
-#define MAP_LOCKED 0x2000  
-#define MAP_NORESERVE 0x4000  
+#define MAP_DENYWRITE 0x0800
+#define MAP_EXECUTABLE 0x1000
+#define MAP_LOCKED 0x2000
+#define MAP_NORESERVE 0x4000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MAP_POPULATE 0x8000  
-#define MAP_NONBLOCK 0x10000  
-#define MAP_STACK 0x20000  
-#define MAP_HUGETLB 0x40000  
+#define MAP_POPULATE 0x8000
+#define MAP_NONBLOCK 0x10000
+#define MAP_STACK 0x20000
+#define MAP_HUGETLB 0x40000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MCL_CURRENT 1  
-#define MCL_FUTURE 2  
+#define MCL_CURRENT 1
+#define MCL_FUTURE 2
 #endif
diff --git a/libc/kernel/common/asm-generic/pgtable-nopmd.h b/libc/kernel/common/asm-generic/pgtable-nopmd.h
new file mode 100644
index 0000000..ac3f40c
--- /dev/null
+++ b/libc/kernel/common/asm-generic/pgtable-nopmd.h
@@ -0,0 +1,48 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ***   To edit the content of this header, modify the corresponding
+ ***   source file (e.g. under external/kernel-headers/original/) then
+ ***   run bionic/libc/kernel/tools/update_all.py
+ ***
+ ***   Any manual change here will be lost the next time this script will
+ ***   be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _PGTABLE_NOPMD_H
+#define _PGTABLE_NOPMD_H
+#ifndef __ASSEMBLY__
+#include <asm-generic/pgtable-nopud.h>
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct mm_struct;
+#define __PAGETABLE_PMD_FOLDED
+typedef struct { pud_t pud; } pmd_t;
+#define PMD_SHIFT PUD_SHIFT
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PTRS_PER_PMD 1
+#define PMD_SIZE (1UL << PMD_SHIFT)
+#define PMD_MASK (~(PMD_SIZE-1))
+#define pmd_ERROR(pmd) (pud_ERROR((pmd).pud))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define pud_populate(mm, pmd, pte) do { } while (0)
+#define set_pud(pudptr, pudval) set_pmd((pmd_t *)(pudptr), (pmd_t) { pudval })
+#define pmd_val(x) (pud_val((x).pud))
+#define __pmd(x) ((pmd_t) { __pud(x) } )
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define pud_page(pud) (pmd_page((pmd_t){ pud }))
+#define pud_page_vaddr(pud) (pmd_page_vaddr((pmd_t){ pud }))
+#define pmd_alloc_one(mm, address) NULL
+#define __pmd_free_tlb(tlb, x, a) do { } while (0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#undef pmd_addr_end
+#define pmd_addr_end(addr, end) (end)
+#endif
+#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/asm-generic/resource.h b/libc/kernel/common/asm-generic/resource.h
index c49b476..aa6078f 100644
--- a/libc/kernel/common/asm-generic/resource.h
+++ b/libc/kernel/common/asm-generic/resource.h
@@ -18,38 +18,38 @@
  ****************************************************************************/
 #ifndef _ASM_GENERIC_RESOURCE_H
 #define _ASM_GENERIC_RESOURCE_H
-#define RLIMIT_CPU 0  
-#define RLIMIT_FSIZE 1  
+#define RLIMIT_CPU 0
+#define RLIMIT_FSIZE 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RLIMIT_DATA 2  
-#define RLIMIT_STACK 3  
-#define RLIMIT_CORE 4  
+#define RLIMIT_DATA 2
+#define RLIMIT_STACK 3
+#define RLIMIT_CORE 4
 #ifndef RLIMIT_RSS
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RLIMIT_RSS 5  
+#define RLIMIT_RSS 5
 #endif
 #ifndef RLIMIT_NPROC
-#define RLIMIT_NPROC 6  
+#define RLIMIT_NPROC 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #ifndef RLIMIT_NOFILE
-#define RLIMIT_NOFILE 7  
+#define RLIMIT_NOFILE 7
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifndef RLIMIT_MEMLOCK
-#define RLIMIT_MEMLOCK 8  
+#define RLIMIT_MEMLOCK 8
 #endif
 #ifndef RLIMIT_AS
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RLIMIT_AS 9  
+#define RLIMIT_AS 9
 #endif
-#define RLIMIT_LOCKS 10  
-#define RLIMIT_SIGPENDING 11  
+#define RLIMIT_LOCKS 10
+#define RLIMIT_SIGPENDING 11
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RLIMIT_MSGQUEUE 12  
-#define RLIMIT_NICE 13  
-#define RLIMIT_RTPRIO 14  
-#define RLIMIT_RTTIME 15  
+#define RLIMIT_MSGQUEUE 12
+#define RLIMIT_NICE 13
+#define RLIMIT_RTPRIO 14
+#define RLIMIT_RTTIME 15
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RLIM_NLIMITS 16
 #ifndef RLIM_INFINITY
diff --git a/libc/kernel/common/asm-generic/siginfo.h b/libc/kernel/common/asm-generic/siginfo.h
index 6ba48a0..6157ebc 100644
--- a/libc/kernel/common/asm-generic/siginfo.h
+++ b/libc/kernel/common/asm-generic/siginfo.h
@@ -127,77 +127,77 @@
 #define __SI_MESGQ 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __SI_CODE(T,N) (N)
-#define SI_USER 0  
-#define SI_KERNEL 0x80  
-#define SI_QUEUE -1  
+#define SI_USER 0
+#define SI_KERNEL 0x80
+#define SI_QUEUE -1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SI_TIMER __SI_CODE(__SI_TIMER,-2)  
-#define SI_MESGQ __SI_CODE(__SI_MESGQ,-3)  
-#define SI_ASYNCIO -4  
-#define SI_SIGIO -5  
+#define SI_TIMER __SI_CODE(__SI_TIMER,-2)
+#define SI_MESGQ __SI_CODE(__SI_MESGQ,-3)
+#define SI_ASYNCIO -4
+#define SI_SIGIO -5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SI_TKILL -6  
-#define SI_DETHREAD -7  
+#define SI_TKILL -6
+#define SI_DETHREAD -7
 #define SI_FROMUSER(siptr) ((siptr)->si_code <= 0)
 #define SI_FROMKERNEL(siptr) ((siptr)->si_code > 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ILL_ILLOPC (__SI_FAULT|1)  
-#define ILL_ILLOPN (__SI_FAULT|2)  
-#define ILL_ILLADR (__SI_FAULT|3)  
-#define ILL_ILLTRP (__SI_FAULT|4)  
+#define ILL_ILLOPC (__SI_FAULT|1)
+#define ILL_ILLOPN (__SI_FAULT|2)
+#define ILL_ILLADR (__SI_FAULT|3)
+#define ILL_ILLTRP (__SI_FAULT|4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ILL_PRVOPC (__SI_FAULT|5)  
-#define ILL_PRVREG (__SI_FAULT|6)  
-#define ILL_COPROC (__SI_FAULT|7)  
-#define ILL_BADSTK (__SI_FAULT|8)  
+#define ILL_PRVOPC (__SI_FAULT|5)
+#define ILL_PRVREG (__SI_FAULT|6)
+#define ILL_COPROC (__SI_FAULT|7)
+#define ILL_BADSTK (__SI_FAULT|8)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NSIGILL 8
-#define FPE_INTDIV (__SI_FAULT|1)  
-#define FPE_INTOVF (__SI_FAULT|2)  
-#define FPE_FLTDIV (__SI_FAULT|3)  
+#define FPE_INTDIV (__SI_FAULT|1)
+#define FPE_INTOVF (__SI_FAULT|2)
+#define FPE_FLTDIV (__SI_FAULT|3)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FPE_FLTOVF (__SI_FAULT|4)  
-#define FPE_FLTUND (__SI_FAULT|5)  
-#define FPE_FLTRES (__SI_FAULT|6)  
-#define FPE_FLTINV (__SI_FAULT|7)  
+#define FPE_FLTOVF (__SI_FAULT|4)
+#define FPE_FLTUND (__SI_FAULT|5)
+#define FPE_FLTRES (__SI_FAULT|6)
+#define FPE_FLTINV (__SI_FAULT|7)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FPE_FLTSUB (__SI_FAULT|8)  
+#define FPE_FLTSUB (__SI_FAULT|8)
 #define NSIGFPE 8
-#define SEGV_MAPERR (__SI_FAULT|1)  
-#define SEGV_ACCERR (__SI_FAULT|2)  
+#define SEGV_MAPERR (__SI_FAULT|1)
+#define SEGV_ACCERR (__SI_FAULT|2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NSIGSEGV 2
-#define BUS_ADRALN (__SI_FAULT|1)  
-#define BUS_ADRERR (__SI_FAULT|2)  
-#define BUS_OBJERR (__SI_FAULT|3)  
+#define BUS_ADRALN (__SI_FAULT|1)
+#define BUS_ADRERR (__SI_FAULT|2)
+#define BUS_OBJERR (__SI_FAULT|3)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NSIGBUS 3
-#define TRAP_BRKPT (__SI_FAULT|1)  
-#define TRAP_TRACE (__SI_FAULT|2)  
+#define TRAP_BRKPT (__SI_FAULT|1)
+#define TRAP_TRACE (__SI_FAULT|2)
 #define NSIGTRAP 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CLD_EXITED (__SI_CHLD|1)  
-#define CLD_KILLED (__SI_CHLD|2)  
-#define CLD_DUMPED (__SI_CHLD|3)  
-#define CLD_TRAPPED (__SI_CHLD|4)  
+#define CLD_EXITED (__SI_CHLD|1)
+#define CLD_KILLED (__SI_CHLD|2)
+#define CLD_DUMPED (__SI_CHLD|3)
+#define CLD_TRAPPED (__SI_CHLD|4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CLD_STOPPED (__SI_CHLD|5)  
-#define CLD_CONTINUED (__SI_CHLD|6)  
+#define CLD_STOPPED (__SI_CHLD|5)
+#define CLD_CONTINUED (__SI_CHLD|6)
 #define NSIGCHLD 6
-#define POLL_IN (__SI_POLL|1)  
+#define POLL_IN (__SI_POLL|1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define POLL_OUT (__SI_POLL|2)  
-#define POLL_MSG (__SI_POLL|3)  
-#define POLL_ERR (__SI_POLL|4)  
-#define POLL_PRI (__SI_POLL|5)  
+#define POLL_OUT (__SI_POLL|2)
+#define POLL_MSG (__SI_POLL|3)
+#define POLL_ERR (__SI_POLL|4)
+#define POLL_PRI (__SI_POLL|5)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define POLL_HUP (__SI_POLL|6)  
+#define POLL_HUP (__SI_POLL|6)
 #define NSIGPOLL 6
-#define SIGEV_SIGNAL 0  
-#define SIGEV_NONE 1  
+#define SIGEV_SIGNAL 0
+#define SIGEV_NONE 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIGEV_THREAD 2  
-#define SIGEV_THREAD_ID 4  
+#define SIGEV_THREAD 2
+#define SIGEV_THREAD_ID 4
 #ifndef __ARCH_SIGEV_PREAMBLE_SIZE
 #define __ARCH_SIGEV_PREAMBLE_SIZE (sizeof(int) * 2 + sizeof(sigval_t))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/asm-generic/signal.h b/libc/kernel/common/asm-generic/signal.h
index f106b38..7f24717 100644
--- a/libc/kernel/common/asm-generic/signal.h
+++ b/libc/kernel/common/asm-generic/signal.h
@@ -21,14 +21,14 @@
 #include <linux/compiler.h>
 #ifndef SIG_BLOCK
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIG_BLOCK 0  
+#define SIG_BLOCK 0
 #endif
 #ifndef SIG_UNBLOCK
-#define SIG_UNBLOCK 1  
+#define SIG_UNBLOCK 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #ifndef SIG_SETMASK
-#define SIG_SETMASK 2  
+#define SIG_SETMASK 2
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifndef __ASSEMBLY__
@@ -37,9 +37,9 @@
 typedef void __restorefn_t(void);
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef __restorefn_t __user *__sigrestore_t;
-#define SIG_DFL ((__force __sighandler_t)0)  
-#define SIG_IGN ((__force __sighandler_t)1)  
-#define SIG_ERR ((__force __sighandler_t)-1)  
+#define SIG_DFL ((__force __sighandler_t)0)
+#define SIG_IGN ((__force __sighandler_t)1)
+#define SIG_ERR ((__force __sighandler_t)-1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #endif
diff --git a/libc/kernel/common/linux/a.out.h b/libc/kernel/common/linux/a.out.h
index 87c5b19..9112045 100644
--- a/libc/kernel/common/linux/a.out.h
+++ b/libc/kernel/common/linux/a.out.h
@@ -193,12 +193,12 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #define N_INDR 0xa
-#define N_SETA 0x14  
-#define N_SETT 0x16  
+#define N_SETA 0x14
+#define N_SETT 0x16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define N_SETD 0x18  
-#define N_SETB 0x1A  
-#define N_SETV 0x1C  
+#define N_SETD 0x18
+#define N_SETB 0x1A
+#define N_SETV 0x1C
 #ifndef N_RELOCATION_INFO_DECLARED
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct relocation_info
diff --git a/libc/kernel/common/linux/akm8973.h b/libc/kernel/common/linux/akm8973.h
index 0721803..4d9640a 100644
--- a/libc/kernel/common/linux/akm8973.h
+++ b/libc/kernel/common/linux/akm8973.h
@@ -44,8 +44,8 @@
 #define ECS_IOCTL_APP_RESET_PEDOMETER _IO(AKMIO, 0x17)
 #define ECS_IOCTL_APP_SET_DELAY _IOW(AKMIO, 0x18, short)
 #define ECS_IOCTL_APP_GET_DELAY ECS_IOCTL_GET_DELAY
-#define ECS_IOCTL_APP_SET_MVFLAG _IOW(AKMIO, 0x19, short)  
+#define ECS_IOCTL_APP_SET_MVFLAG _IOW(AKMIO, 0x19, short)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ECS_IOCTL_APP_GET_MVFLAG _IOR(AKMIO, 0x1A, short)  
+#define ECS_IOCTL_APP_GET_MVFLAG _IOR(AKMIO, 0x1A, short)
 #define ECS_IOCTL_SET_STEP_CNT _IOW(AKMIO, 0x20, short)
 #endif
diff --git a/libc/kernel/common/linux/akm8975.h b/libc/kernel/common/linux/akm8975.h
index 3e68ab5..324c40d 100644
--- a/libc/kernel/common/linux/akm8975.h
+++ b/libc/kernel/common/linux/akm8975.h
@@ -24,7 +24,7 @@
 #define AK8975_MODE_SELF_TEST 0x08
 #define AK8975_MODE_FUSE_ACCESS 0x0F
 #define AK8975_MODE_POWER_DOWN 0x00
-#define RBUFF_SIZE 8  
+#define RBUFF_SIZE 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AK8975_REG_WIA 0x00
 #define AK8975_REG_INFO 0x01
@@ -67,8 +67,8 @@
 #define ECS_IOCTL_APP_SET_DELAY _IOW(AKMIO, 0x18, short)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ECS_IOCTL_APP_GET_DELAY ECS_IOCTL_GET_DELAY
-#define ECS_IOCTL_APP_SET_MVFLAG _IOW(AKMIO, 0x19, short)  
-#define ECS_IOCTL_APP_GET_MVFLAG _IOR(AKMIO, 0x1A, short)  
+#define ECS_IOCTL_APP_SET_MVFLAG _IOW(AKMIO, 0x19, short)
+#define ECS_IOCTL_APP_GET_MVFLAG _IOR(AKMIO, 0x1A, short)
 #define ECS_IOCTL_APP_SET_TFLAG _IOR(AKMIO, 0x15, short)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ECS_INTR 140
diff --git a/libc/kernel/common/linux/akm8976.h b/libc/kernel/common/linux/akm8976.h
index 84ac803..e19179e 100644
--- a/libc/kernel/common/linux/akm8976.h
+++ b/libc/kernel/common/linux/akm8976.h
@@ -19,26 +19,26 @@
 #ifndef AKM8976_H
 #define AKM8976_H
 #include <linux/ioctl.h>
-#define AKECS_MODE_MEASURE 0x00  
+#define AKECS_MODE_MEASURE 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define AKECS_MODE_PFFD 0x01  
-#define AKECS_MODE_E2P_READ 0x02  
-#define AKECS_MODE_POWERDOWN 0x03  
-#define AKECS_MODE_MEASURE_SNG 0x10  
+#define AKECS_MODE_PFFD 0x01
+#define AKECS_MODE_E2P_READ 0x02
+#define AKECS_MODE_POWERDOWN 0x03
+#define AKECS_MODE_MEASURE_SNG 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define AKECS_MODE_MEASURE_SEQ 0x11  
-#define CSPEC_AINT 0x01  
-#define CSPEC_SNG_NUM 0x01  
-#define CSPEC_SEQ_NUM 0x02  
+#define AKECS_MODE_MEASURE_SEQ 0x11
+#define CSPEC_AINT 0x01
+#define CSPEC_SNG_NUM 0x01
+#define CSPEC_SEQ_NUM 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CSPEC_SFRQ_32 0x00  
-#define CSPEC_SFRQ_64 0x01  
-#define CSPEC_MCS 0x07  
-#define CSPEC_MKS 0x01  
+#define CSPEC_SFRQ_32 0x00
+#define CSPEC_SFRQ_64 0x01
+#define CSPEC_MCS 0x07
+#define CSPEC_MKS 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CSPEC_INTEN 0x01  
-#define RBUFF_SIZE 31  
-#define MAX_CALI_SIZE 0x1000U  
+#define CSPEC_INTEN 0x01
+#define RBUFF_SIZE 31
+#define MAX_CALI_SIZE 0x1000U
 #define AKECS_REG_ST 0xC0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AKECS_REG_TMPS 0xC1
@@ -79,14 +79,14 @@
 #define ECS_IOCTL_APP_RESET_PEDOMETER _IO(AKMIO, 0x17)
 #define ECS_IOCTL_APP_SET_DELAY _IOW(AKMIO, 0x18, short)
 #define ECS_IOCTL_APP_GET_DELAY ECS_IOCTL_GET_DELAY
-#define ECS_IOCTL_APP_SET_MVFLAG _IOW(AKMIO, 0x19, short)  
+#define ECS_IOCTL_APP_SET_MVFLAG _IOW(AKMIO, 0x19, short)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ECS_IOCTL_APP_GET_MVFLAG _IOR(AKMIO, 0x1A, short)  
+#define ECS_IOCTL_APP_GET_MVFLAG _IOR(AKMIO, 0x1A, short)
 #define ECS_IOCTL_SET_STEP_CNT _IOW(AKMIO, 0x20, short)
-#define ECS_RST 146  
-#define ECS_CLK_ON 155  
+#define ECS_RST 146
+#define ECS_CLK_ON 155
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ECS_INTR 161  
+#define ECS_INTR 161
 struct akm8976_platform_data {
  int reset;
  int clk_on;
diff --git a/libc/kernel/common/linux/android_alarm.h b/libc/kernel/common/linux/android_alarm.h
index 015acf4..b02e37b 100644
--- a/libc/kernel/common/linux/android_alarm.h
+++ b/libc/kernel/common/linux/android_alarm.h
@@ -41,9 +41,9 @@
  ANDROID_ALARM_TIME_CHANGE_MASK = 1U << 16
 } android_alarm_return_flags_t;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ANDROID_ALARM_CLEAR(type) _IO('a', 0 | ((type) << 4)) 
-#define ANDROID_ALARM_WAIT _IO('a', 1) 
-#define ANDROID_ALARM_SET(type) _IOW('a', 2 | ((type) << 4), struct timespec) 
+#define ANDROID_ALARM_CLEAR(type) _IO('a', 0 | ((type) << 4))
+#define ANDROID_ALARM_WAIT _IO('a', 1)
+#define ANDROID_ALARM_SET(type) _IOW('a', 2 | ((type) << 4), struct timespec)
 #define ANDROID_ALARM_SET_AND_WAIT(type) _IOW('a', 3 | ((type) << 4), struct timespec)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ANDROID_ALARM_GET_TIME(type) _IOW('a', 4 | ((type) << 4), struct timespec)
diff --git a/libc/kernel/common/linux/apm_bios.h b/libc/kernel/common/linux/apm_bios.h
index 63fe95a..64e2c06 100644
--- a/libc/kernel/common/linux/apm_bios.h
+++ b/libc/kernel/common/linux/apm_bios.h
@@ -92,13 +92,13 @@
 #define APM_CAP_GLOBAL_STANDBY 0x0001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define APM_CAP_GLOBAL_SUSPEND 0x0002
-#define APM_CAP_RESUME_STANDBY_TIMER 0x0004  
-#define APM_CAP_RESUME_SUSPEND_TIMER 0x0008  
-#define APM_CAP_RESUME_STANDBY_RING 0x0010  
+#define APM_CAP_RESUME_STANDBY_TIMER 0x0004
+#define APM_CAP_RESUME_SUSPEND_TIMER 0x0008
+#define APM_CAP_RESUME_STANDBY_RING 0x0010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define APM_CAP_RESUME_SUSPEND_RING 0x0020  
-#define APM_CAP_RESUME_STANDBY_PCMCIA 0x0040  
-#define APM_CAP_RESUME_SUSPEND_PCMCIA 0x0080  
+#define APM_CAP_RESUME_SUSPEND_RING 0x0020
+#define APM_CAP_RESUME_STANDBY_PCMCIA 0x0040
+#define APM_CAP_RESUME_SUSPEND_PCMCIA 0x0080
 #include <linux/ioctl.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define APM_IOC_STANDBY _IO('A', 1)
diff --git a/libc/kernel/common/linux/atm.h b/libc/kernel/common/linux/atm.h
index 47155a2..ec6a8df 100644
--- a/libc/kernel/common/linux/atm.h
+++ b/libc/kernel/common/linux/atm.h
@@ -23,27 +23,27 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <linux/atmsap.h>
 #include <linux/atmioc.h>
-#define ATM_CELL_SIZE 53  
-#define ATM_CELL_PAYLOAD 48  
+#define ATM_CELL_SIZE 53
+#define ATM_CELL_PAYLOAD 48
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_AAL0_SDU 52  
-#define ATM_MAX_AAL34_PDU 65535  
-#define ATM_AAL5_TRAILER 8  
-#define ATM_MAX_AAL5_PDU 65535  
+#define ATM_AAL0_SDU 52
+#define ATM_MAX_AAL34_PDU 65535
+#define ATM_AAL5_TRAILER 8
+#define ATM_MAX_AAL5_PDU 65535
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_MAX_CDV 9999  
-#define ATM_NOT_RSV_VCI 32  
-#define ATM_MAX_VPI 255  
-#define ATM_MAX_VPI_NNI 4096  
+#define ATM_MAX_CDV 9999
+#define ATM_NOT_RSV_VCI 32
+#define ATM_MAX_VPI 255
+#define ATM_MAX_VPI_NNI 4096
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_MAX_VCI 65535  
-#define ATM_NO_AAL 0  
-#define ATM_AAL0 13  
-#define ATM_AAL1 1  
+#define ATM_MAX_VCI 65535
+#define ATM_NO_AAL 0
+#define ATM_AAL0 13
+#define ATM_AAL1 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_AAL2 2  
-#define ATM_AAL34 3  
-#define ATM_AAL5 5  
+#define ATM_AAL2 2
+#define ATM_AAL34 3
+#define ATM_AAL5 5
 #define __SO_ENCODE(l,n,t) ((((l) & 0x1FF) << 22) | ((n) << 16) |   sizeof(t))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __SO_LEVEL_MATCH(c,m) (((c) >> 22) == ((m) & 0x1FF))
@@ -68,25 +68,25 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ATM_HDR_PTI_SHIFT 1
 #define ATM_HDR_CLP 0x00000001
-#define ATM_PTI_US0 0  
-#define ATM_PTI_US1 1  
+#define ATM_PTI_US0 0
+#define ATM_PTI_US1 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_PTI_UCES0 2  
-#define ATM_PTI_UCES1 3  
-#define ATM_PTI_SEGF5 4  
-#define ATM_PTI_E2EF5 5  
+#define ATM_PTI_UCES0 2
+#define ATM_PTI_UCES1 3
+#define ATM_PTI_SEGF5 4
+#define ATM_PTI_E2EF5 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_PTI_RSV_RM 6  
-#define ATM_PTI_RSV 7  
-#define ATM_NONE 0  
+#define ATM_PTI_RSV_RM 6
+#define ATM_PTI_RSV 7
+#define ATM_NONE 0
 #define ATM_UBR 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ATM_CBR 2
 #define ATM_VBR 3
 #define ATM_ABR 4
-#define ATM_ANYCLASS 5  
+#define ATM_ANYCLASS 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_MAX_PCR -1  
+#define ATM_MAX_PCR -1
 struct atm_trafprm {
  unsigned char traffic_class;
  int max_pcr;
@@ -121,7 +121,7 @@
  unsigned char aal __ATM_API_ALIGN;
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_ITF_ANY -1  
+#define ATM_ITF_ANY -1
 #define ATM_VPI_ANY -1
 #define ATM_VCI_ANY -1
 #define ATM_VPI_UNSPEC -2
@@ -137,23 +137,23 @@
  } sap_addr __ATM_API_ALIGN;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define ATM_ESA_LEN 20  
-#define ATM_E164_LEN 12  
-#define ATM_AFI_DCC 0x39  
+#define ATM_ESA_LEN 20
+#define ATM_E164_LEN 12
+#define ATM_AFI_DCC 0x39
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_AFI_ICD 0x47  
-#define ATM_AFI_E164 0x45  
-#define ATM_AFI_LOCAL 0x49   
-#define ATM_AFI_DCC_GROUP 0xBD  
+#define ATM_AFI_ICD 0x47
+#define ATM_AFI_E164 0x45
+#define ATM_AFI_LOCAL 0x49
+#define ATM_AFI_DCC_GROUP 0xBD
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_AFI_ICD_GROUP 0xC5  
-#define ATM_AFI_E164_GROUP 0xC3  
-#define ATM_AFI_LOCAL_GROUP 0xC7  
-#define ATM_LIJ_NONE 0  
+#define ATM_AFI_ICD_GROUP 0xC5
+#define ATM_AFI_E164_GROUP 0xC3
+#define ATM_AFI_LOCAL_GROUP 0xC7
+#define ATM_LIJ_NONE 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_LIJ 1  
-#define ATM_LIJ_RPJ 2  
-#define ATM_LIJ_NJ 3  
+#define ATM_LIJ 1
+#define ATM_LIJ_RPJ 2
+#define ATM_LIJ_NJ 3
 struct sockaddr_atmsvc {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned short sas_family;
diff --git a/libc/kernel/common/linux/atmdev.h b/libc/kernel/common/linux/atmdev.h
index 5a07c12..454ad09 100644
--- a/libc/kernel/common/linux/atmdev.h
+++ b/libc/kernel/common/linux/atmdev.h
@@ -28,7 +28,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ATM_OC12_PCR (622080000/1080*1040/8/53)
 #define ATM_DS3_PCR (8000*12)
-#define __AAL_STAT_ITEMS   __HANDLE_ITEM(tx);     __HANDLE_ITEM(tx_err);     __HANDLE_ITEM(rx);     __HANDLE_ITEM(rx_err);     __HANDLE_ITEM(rx_drop);  
+#define __AAL_STAT_ITEMS   __HANDLE_ITEM(tx);     __HANDLE_ITEM(tx_err);     __HANDLE_ITEM(rx);     __HANDLE_ITEM(rx_err);     __HANDLE_ITEM(rx_drop);
 struct atm_aal_stats {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __HANDLE_ITEM(i) int i
@@ -73,23 +73,23 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ATM_ADDPARTY _IOW('a', ATMIOC_SPECIAL+4,struct atm_iobuf)
 #define ATM_DROPPARTY _IOW('a', ATMIOC_SPECIAL+5,int)
-#define ATM_BACKEND_RAW 0 
-#define ATM_BACKEND_PPP 1  
+#define ATM_BACKEND_RAW 0
+#define ATM_BACKEND_PPP 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_BACKEND_BR2684 2  
-#define ATM_ITFTYP_LEN 8  
-#define __ATM_LM_NONE 0  
-#define __ATM_LM_AAL 1  
+#define ATM_BACKEND_BR2684 2
+#define ATM_ITFTYP_LEN 8
+#define __ATM_LM_NONE 0
+#define __ATM_LM_AAL 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define __ATM_LM_ATM 2  
-#define __ATM_LM_PHY 8  
-#define __ATM_LM_ANALOG 16  
-#define __ATM_LM_MKLOC(n) ((n))  
+#define __ATM_LM_ATM 2
+#define __ATM_LM_PHY 8
+#define __ATM_LM_ANALOG 16
+#define __ATM_LM_MKLOC(n) ((n))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define __ATM_LM_MKRMT(n) ((n) << 8)  
+#define __ATM_LM_MKRMT(n) ((n) << 8)
 #define __ATM_LM_XTLOC(n) ((n) & 0xff)
 #define __ATM_LM_XTRMT(n) (((n) >> 8) & 0xff)
-#define ATM_LM_NONE 0  
+#define ATM_LM_NONE 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ATM_LM_LOC_AAL __ATM_LM_MKLOC(__ATM_LM_AAL)
 #define ATM_LM_LOC_ATM __ATM_LM_MKLOC(__ATM_LM_ATM)
@@ -106,32 +106,32 @@
  void __user *buffer;
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_CI_MAX -1  
+#define ATM_CI_MAX -1
 struct atm_cirange {
  signed char vpi_bits;
  signed char vci_bits;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define ATM_SC_RX 1024  
-#define ATM_SC_TX 2048  
-#define ATM_BACKLOG_DEFAULT 32  
+#define ATM_SC_RX 1024
+#define ATM_SC_TX 2048
+#define ATM_BACKLOG_DEFAULT 32
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_MF_IMMED 1  
-#define ATM_MF_INC_RSV 2  
-#define ATM_MF_INC_SHP 4  
-#define ATM_MF_DEC_RSV 8  
+#define ATM_MF_IMMED 1
+#define ATM_MF_INC_RSV 2
+#define ATM_MF_INC_SHP 4
+#define ATM_MF_DEC_RSV 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_MF_DEC_SHP 16  
-#define ATM_MF_BWD 32  
+#define ATM_MF_DEC_SHP 16
+#define ATM_MF_BWD 32
 #define ATM_MF_SET (ATM_MF_INC_RSV | ATM_MF_INC_SHP | ATM_MF_DEC_RSV |   ATM_MF_DEC_SHP | ATM_MF_BWD)
-#define ATM_VS_IDLE 0  
+#define ATM_VS_IDLE 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_VS_CONNECTED 1  
-#define ATM_VS_CLOSING 2  
-#define ATM_VS_LISTEN 3  
-#define ATM_VS_INUSE 4  
+#define ATM_VS_CONNECTED 1
+#define ATM_VS_CLOSING 2
+#define ATM_VS_LISTEN 3
+#define ATM_VS_INUSE 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_VS_BOUND 5  
+#define ATM_VS_BOUND 5
 #define ATM_VS2TXT_MAP   "IDLE", "CONNECTED", "CLOSING", "LISTEN", "INUSE", "BOUND"
 #define ATM_VF2TXT_MAP   "ADDR", "READY", "PARTIAL", "REGIS",   "RELEASED", "HASQOS", "LISTEN", "META",   "256", "512", "1024", "2048",   "SESSION", "HASSAP", "BOUND", "CLOSE"
 #endif
diff --git a/libc/kernel/common/linux/atmioc.h b/libc/kernel/common/linux/atmioc.h
index cad0b8a..147b7cc 100644
--- a/libc/kernel/common/linux/atmioc.h
+++ b/libc/kernel/common/linux/atmioc.h
@@ -19,31 +19,31 @@
 #ifndef _LINUX_ATMIOC_H
 #define _LINUX_ATMIOC_H
 #include <asm/ioctl.h>
-#define ATMIOC_PHYCOM 0x00  
+#define ATMIOC_PHYCOM 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ATMIOC_PHYCOM_END 0x0f
-#define ATMIOC_PHYTYP 0x10  
+#define ATMIOC_PHYTYP 0x10
 #define ATMIOC_PHYTYP_END 0x2f
-#define ATMIOC_PHYPRV 0x30  
+#define ATMIOC_PHYPRV 0x30
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ATMIOC_PHYPRV_END 0x4f
-#define ATMIOC_SARCOM 0x50  
+#define ATMIOC_SARCOM 0x50
 #define ATMIOC_SARCOM_END 0x50
-#define ATMIOC_SARPRV 0x60  
+#define ATMIOC_SARPRV 0x60
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ATMIOC_SARPRV_END 0x7f
-#define ATMIOC_ITF 0x80  
+#define ATMIOC_ITF 0x80
 #define ATMIOC_ITF_END 0x8f
-#define ATMIOC_BACKEND 0x90  
+#define ATMIOC_BACKEND 0x90
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ATMIOC_BACKEND_END 0xaf
-#define ATMIOC_AREQUIPA 0xc0  
-#define ATMIOC_LANE 0xd0  
-#define ATMIOC_MPOA 0xd8  
+#define ATMIOC_AREQUIPA 0xc0
+#define ATMIOC_LANE 0xd0
+#define ATMIOC_MPOA 0xd8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATMIOC_CLIP 0xe0  
+#define ATMIOC_CLIP 0xe0
 #define ATMIOC_CLIP_END 0xef
-#define ATMIOC_SPECIAL 0xf0  
+#define ATMIOC_SPECIAL 0xf0
 #define ATMIOC_SPECIAL_END 0xff
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/common/linux/atmsap.h b/libc/kernel/common/linux/atmsap.h
index eae4bcf..85e8020 100644
--- a/libc/kernel/common/linux/atmsap.h
+++ b/libc/kernel/common/linux/atmsap.h
@@ -19,60 +19,60 @@
 #ifndef _LINUX_ATMSAP_H
 #define _LINUX_ATMSAP_H
 #include <linux/atmapi.h>
-#define ATM_L2_NONE 0  
+#define ATM_L2_NONE 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_L2_ISO1745 0x01  
-#define ATM_L2_Q291 0x02  
-#define ATM_L2_X25_LL 0x06  
-#define ATM_L2_X25_ML 0x07  
+#define ATM_L2_ISO1745 0x01
+#define ATM_L2_Q291 0x02
+#define ATM_L2_X25_LL 0x06
+#define ATM_L2_X25_ML 0x07
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_L2_LAPB 0x08  
-#define ATM_L2_HDLC_ARM 0x09  
-#define ATM_L2_HDLC_NRM 0x0a  
-#define ATM_L2_HDLC_ABM 0x0b  
+#define ATM_L2_LAPB 0x08
+#define ATM_L2_HDLC_ARM 0x09
+#define ATM_L2_HDLC_NRM 0x0a
+#define ATM_L2_HDLC_ABM 0x0b
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_L2_ISO8802 0x0c  
-#define ATM_L2_X75 0x0d  
-#define ATM_L2_Q922 0x0e  
-#define ATM_L2_USER 0x10  
+#define ATM_L2_ISO8802 0x0c
+#define ATM_L2_X75 0x0d
+#define ATM_L2_Q922 0x0e
+#define ATM_L2_USER 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_L2_ISO7776 0x11  
-#define ATM_L3_NONE 0  
-#define ATM_L3_X25 0x06  
-#define ATM_L3_ISO8208 0x07  
+#define ATM_L2_ISO7776 0x11
+#define ATM_L3_NONE 0
+#define ATM_L3_X25 0x06
+#define ATM_L3_ISO8208 0x07
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_L3_X223 0x08  
-#define ATM_L3_ISO8473 0x09  
-#define ATM_L3_T70 0x0a  
-#define ATM_L3_TR9577 0x0b  
+#define ATM_L3_X223 0x08
+#define ATM_L3_ISO8473 0x09
+#define ATM_L3_T70 0x0a
+#define ATM_L3_TR9577 0x0b
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_L3_H310 0x0c  
-#define ATM_L3_H321 0x0d  
-#define ATM_L3_USER 0x10  
-#define ATM_HL_NONE 0  
+#define ATM_L3_H310 0x0c
+#define ATM_L3_H321 0x0d
+#define ATM_L3_USER 0x10
+#define ATM_HL_NONE 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_HL_ISO 0x01  
-#define ATM_HL_USER 0x02  
-#define ATM_HL_HLP 0x03  
-#define ATM_HL_VENDOR 0x04  
+#define ATM_HL_ISO 0x01
+#define ATM_HL_USER 0x02
+#define ATM_HL_HLP 0x03
+#define ATM_HL_VENDOR 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_IMD_NONE 0  
-#define ATM_IMD_NORMAL 1  
-#define ATM_IMD_EXTENDED 2  
-#define ATM_TT_NONE 0  
+#define ATM_IMD_NONE 0
+#define ATM_IMD_NORMAL 1
+#define ATM_IMD_EXTENDED 2
+#define ATM_TT_NONE 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_TT_RX 1  
-#define ATM_TT_TX 2  
-#define ATM_TT_RXTX 3  
-#define ATM_MC_NONE 0  
+#define ATM_TT_RX 1
+#define ATM_TT_TX 2
+#define ATM_TT_RXTX 3
+#define ATM_MC_NONE 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_MC_TS 1  
-#define ATM_MC_TS_FEC 2  
-#define ATM_MC_PS 3  
-#define ATM_MC_PS_FEC 4  
+#define ATM_MC_TS 1
+#define ATM_MC_TS_FEC 2
+#define ATM_MC_PS 3
+#define ATM_MC_PS_FEC 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_MC_H221 5  
-#define ATM_MAX_HLI 8  
+#define ATM_MC_H221 5
+#define ATM_MAX_HLI 8
 struct atm_blli {
  unsigned char l2_proto;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -114,7 +114,7 @@
  unsigned char hl_length;
  unsigned char hl_info[ATM_MAX_HLI];
 };
-#define ATM_MAX_BLLI 3  
+#define ATM_MAX_BLLI 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct atm_sap {
  struct atm_bhli bhli;
diff --git a/libc/kernel/common/linux/audit.h b/libc/kernel/common/linux/audit.h
new file mode 100644
index 0000000..cbea684
--- /dev/null
+++ b/libc/kernel/common/linux/audit.h
@@ -0,0 +1,361 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ***   To edit the content of this header, modify the corresponding
+ ***   source file (e.g. under external/kernel-headers/original/) then
+ ***   run bionic/libc/kernel/tools/update_all.py
+ ***
+ ***   Any manual change here will be lost the next time this script will
+ ***   be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _LINUX_AUDIT_H_
+#define _LINUX_AUDIT_H_
+#include <linux/types.h>
+#include <linux/elf-em.h>
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#include <linux/ptrace.h>
+#define AUDIT_GET 1000
+#define AUDIT_SET 1001
+#define AUDIT_LIST 1002
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_ADD 1003
+#define AUDIT_DEL 1004
+#define AUDIT_USER 1005
+#define AUDIT_LOGIN 1006
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_WATCH_INS 1007
+#define AUDIT_WATCH_REM 1008
+#define AUDIT_WATCH_LIST 1009
+#define AUDIT_SIGNAL_INFO 1010
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_ADD_RULE 1011
+#define AUDIT_DEL_RULE 1012
+#define AUDIT_LIST_RULES 1013
+#define AUDIT_TRIM 1014
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_MAKE_EQUIV 1015
+#define AUDIT_TTY_GET 1016
+#define AUDIT_TTY_SET 1017
+#define AUDIT_FIRST_USER_MSG 1100
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_USER_AVC 1107
+#define AUDIT_USER_TTY 1124
+#define AUDIT_LAST_USER_MSG 1199
+#define AUDIT_FIRST_USER_MSG2 2100
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_LAST_USER_MSG2 2999
+#define AUDIT_DAEMON_START 1200
+#define AUDIT_DAEMON_END 1201
+#define AUDIT_DAEMON_ABORT 1202
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_DAEMON_CONFIG 1203
+#define AUDIT_SYSCALL 1300
+#define AUDIT_PATH 1302
+#define AUDIT_IPC 1303
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_SOCKETCALL 1304
+#define AUDIT_CONFIG_CHANGE 1305
+#define AUDIT_SOCKADDR 1306
+#define AUDIT_CWD 1307
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_EXECVE 1309
+#define AUDIT_IPC_SET_PERM 1311
+#define AUDIT_MQ_OPEN 1312
+#define AUDIT_MQ_SENDRECV 1313
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_MQ_NOTIFY 1314
+#define AUDIT_MQ_GETSETATTR 1315
+#define AUDIT_KERNEL_OTHER 1316
+#define AUDIT_FD_PAIR 1317
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_OBJ_PID 1318
+#define AUDIT_TTY 1319
+#define AUDIT_EOE 1320
+#define AUDIT_BPRM_FCAPS 1321
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_CAPSET 1322
+#define AUDIT_MMAP 1323
+#define AUDIT_NETFILTER_PKT 1324
+#define AUDIT_NETFILTER_CFG 1325
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_AVC 1400
+#define AUDIT_SELINUX_ERR 1401
+#define AUDIT_AVC_PATH 1402
+#define AUDIT_MAC_POLICY_LOAD 1403
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_MAC_STATUS 1404
+#define AUDIT_MAC_CONFIG_CHANGE 1405
+#define AUDIT_MAC_UNLBL_ALLOW 1406
+#define AUDIT_MAC_CIPSOV4_ADD 1407
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_MAC_CIPSOV4_DEL 1408
+#define AUDIT_MAC_MAP_ADD 1409
+#define AUDIT_MAC_MAP_DEL 1410
+#define AUDIT_MAC_IPSEC_ADDSA 1411
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_MAC_IPSEC_DELSA 1412
+#define AUDIT_MAC_IPSEC_ADDSPD 1413
+#define AUDIT_MAC_IPSEC_DELSPD 1414
+#define AUDIT_MAC_IPSEC_EVENT 1415
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_MAC_UNLBL_STCADD 1416
+#define AUDIT_MAC_UNLBL_STCDEL 1417
+#define AUDIT_FIRST_KERN_ANOM_MSG 1700
+#define AUDIT_LAST_KERN_ANOM_MSG 1799
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_ANOM_PROMISCUOUS 1700
+#define AUDIT_ANOM_ABEND 1701
+#define AUDIT_INTEGRITY_DATA 1800
+#define AUDIT_INTEGRITY_METADATA 1801
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_INTEGRITY_STATUS 1802
+#define AUDIT_INTEGRITY_HASH 1803
+#define AUDIT_INTEGRITY_PCR 1804
+#define AUDIT_INTEGRITY_RULE 1805
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_KERNEL 2000
+#define AUDIT_FILTER_USER 0x00
+#define AUDIT_FILTER_TASK 0x01
+#define AUDIT_FILTER_ENTRY 0x02
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_FILTER_WATCH 0x03
+#define AUDIT_FILTER_EXIT 0x04
+#define AUDIT_FILTER_TYPE 0x05
+#define AUDIT_NR_FILTERS 6
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_FILTER_PREPEND 0x10
+#define AUDIT_NEVER 0
+#define AUDIT_POSSIBLE 1
+#define AUDIT_ALWAYS 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_MAX_FIELDS 64
+#define AUDIT_MAX_KEY_LEN 256
+#define AUDIT_BITMASK_SIZE 64
+#define AUDIT_WORD(nr) ((__u32)((nr)/32))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_BIT(nr) (1 << ((nr) - AUDIT_WORD(nr)*32))
+#define AUDIT_SYSCALL_CLASSES 16
+#define AUDIT_CLASS_DIR_WRITE 0
+#define AUDIT_CLASS_DIR_WRITE_32 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_CLASS_CHATTR 2
+#define AUDIT_CLASS_CHATTR_32 3
+#define AUDIT_CLASS_READ 4
+#define AUDIT_CLASS_READ_32 5
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_CLASS_WRITE 6
+#define AUDIT_CLASS_WRITE_32 7
+#define AUDIT_CLASS_SIGNAL 8
+#define AUDIT_CLASS_SIGNAL_32 9
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_UNUSED_BITS 0x07FFFC00
+#define AUDIT_COMPARE_UID_TO_OBJ_UID 1
+#define AUDIT_COMPARE_GID_TO_OBJ_GID 2
+#define AUDIT_COMPARE_EUID_TO_OBJ_UID 3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_COMPARE_EGID_TO_OBJ_GID 4
+#define AUDIT_COMPARE_AUID_TO_OBJ_UID 5
+#define AUDIT_COMPARE_SUID_TO_OBJ_UID 6
+#define AUDIT_COMPARE_SGID_TO_OBJ_GID 7
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_COMPARE_FSUID_TO_OBJ_UID 8
+#define AUDIT_COMPARE_FSGID_TO_OBJ_GID 9
+#define AUDIT_COMPARE_UID_TO_AUID 10
+#define AUDIT_COMPARE_UID_TO_EUID 11
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_COMPARE_UID_TO_FSUID 12
+#define AUDIT_COMPARE_UID_TO_SUID 13
+#define AUDIT_COMPARE_AUID_TO_FSUID 14
+#define AUDIT_COMPARE_AUID_TO_SUID 15
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_COMPARE_AUID_TO_EUID 16
+#define AUDIT_COMPARE_EUID_TO_SUID 17
+#define AUDIT_COMPARE_EUID_TO_FSUID 18
+#define AUDIT_COMPARE_SUID_TO_FSUID 19
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_COMPARE_GID_TO_EGID 20
+#define AUDIT_COMPARE_GID_TO_FSGID 21
+#define AUDIT_COMPARE_GID_TO_SGID 22
+#define AUDIT_COMPARE_EGID_TO_FSGID 23
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_COMPARE_EGID_TO_SGID 24
+#define AUDIT_COMPARE_SGID_TO_FSGID 25
+#define AUDIT_MAX_FIELD_COMPARE AUDIT_COMPARE_SGID_TO_FSGID
+#define AUDIT_PID 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_UID 1
+#define AUDIT_EUID 2
+#define AUDIT_SUID 3
+#define AUDIT_FSUID 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_GID 5
+#define AUDIT_EGID 6
+#define AUDIT_SGID 7
+#define AUDIT_FSGID 8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_LOGINUID 9
+#define AUDIT_PERS 10
+#define AUDIT_ARCH 11
+#define AUDIT_MSGTYPE 12
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_SUBJ_USER 13
+#define AUDIT_SUBJ_ROLE 14
+#define AUDIT_SUBJ_TYPE 15
+#define AUDIT_SUBJ_SEN 16
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_SUBJ_CLR 17
+#define AUDIT_PPID 18
+#define AUDIT_OBJ_USER 19
+#define AUDIT_OBJ_ROLE 20
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_OBJ_TYPE 21
+#define AUDIT_OBJ_LEV_LOW 22
+#define AUDIT_OBJ_LEV_HIGH 23
+#define AUDIT_DEVMAJOR 100
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_DEVMINOR 101
+#define AUDIT_INODE 102
+#define AUDIT_EXIT 103
+#define AUDIT_SUCCESS 104
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_WATCH 105
+#define AUDIT_PERM 106
+#define AUDIT_DIR 107
+#define AUDIT_FILETYPE 108
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_OBJ_UID 109
+#define AUDIT_OBJ_GID 110
+#define AUDIT_FIELD_COMPARE 111
+#define AUDIT_ARG0 200
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_ARG1 (AUDIT_ARG0+1)
+#define AUDIT_ARG2 (AUDIT_ARG0+2)
+#define AUDIT_ARG3 (AUDIT_ARG0+3)
+#define AUDIT_FILTERKEY 210
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_NEGATE 0x80000000
+#define AUDIT_BIT_MASK 0x08000000
+#define AUDIT_LESS_THAN 0x10000000
+#define AUDIT_GREATER_THAN 0x20000000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_NOT_EQUAL 0x30000000
+#define AUDIT_EQUAL 0x40000000
+#define AUDIT_BIT_TEST (AUDIT_BIT_MASK|AUDIT_EQUAL)
+#define AUDIT_LESS_THAN_OR_EQUAL (AUDIT_LESS_THAN|AUDIT_EQUAL)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_GREATER_THAN_OR_EQUAL (AUDIT_GREATER_THAN|AUDIT_EQUAL)
+#define AUDIT_OPERATORS (AUDIT_EQUAL|AUDIT_NOT_EQUAL|AUDIT_BIT_MASK)
+enum {
+ Audit_equal,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ Audit_not_equal,
+ Audit_bitmask,
+ Audit_bittest,
+ Audit_lt,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ Audit_gt,
+ Audit_le,
+ Audit_ge,
+ Audit_bad
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+#define AUDIT_STATUS_ENABLED 0x0001
+#define AUDIT_STATUS_FAILURE 0x0002
+#define AUDIT_STATUS_PID 0x0004
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_STATUS_RATE_LIMIT 0x0008
+#define AUDIT_STATUS_BACKLOG_LIMIT 0x0010
+#define AUDIT_FAIL_SILENT 0
+#define AUDIT_FAIL_PRINTK 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_FAIL_PANIC 2
+#define __AUDIT_ARCH_64BIT 0x80000000
+#define __AUDIT_ARCH_LE 0x40000000
+#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_ARMEB (EM_ARM)
+#define AUDIT_ARCH_CRIS (EM_CRIS|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_FRV (EM_FRV)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_ARCH_H8300 (EM_H8_300)
+#define AUDIT_ARCH_I386 (EM_386|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_IA64 (EM_IA_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_M32R (EM_M32R)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_ARCH_M68K (EM_68K)
+#define AUDIT_ARCH_MIPS (EM_MIPS)
+#define AUDIT_ARCH_MIPSEL (EM_MIPS|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_MIPS64 (EM_MIPS|__AUDIT_ARCH_64BIT)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_ARCH_MIPSEL64 (EM_MIPS|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_PARISC (EM_PARISC)
+#define AUDIT_ARCH_PARISC64 (EM_PARISC|__AUDIT_ARCH_64BIT)
+#define AUDIT_ARCH_PPC (EM_PPC)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_ARCH_PPC64 (EM_PPC64|__AUDIT_ARCH_64BIT)
+#define AUDIT_ARCH_S390 (EM_S390)
+#define AUDIT_ARCH_S390X (EM_S390|__AUDIT_ARCH_64BIT)
+#define AUDIT_ARCH_SH (EM_SH)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_ARCH_SHEL (EM_SH|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_SH64 (EM_SH|__AUDIT_ARCH_64BIT)
+#define AUDIT_ARCH_SHEL64 (EM_SH|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_SPARC (EM_SPARC)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_ARCH_SPARC64 (EM_SPARCV9|__AUDIT_ARCH_64BIT)
+#define AUDIT_ARCH_X86_64 (EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
+#define AUDIT_PERM_EXEC 1
+#define AUDIT_PERM_WRITE 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_PERM_READ 4
+#define AUDIT_PERM_ATTR 8
+struct audit_status {
+ __u32 mask;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ __u32 enabled;
+ __u32 failure;
+ __u32 pid;
+ __u32 rate_limit;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ __u32 backlog_limit;
+ __u32 lost;
+ __u32 backlog;
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct audit_tty_status {
+ __u32 enabled;
+};
+struct audit_rule_data {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ __u32 flags;
+ __u32 action;
+ __u32 field_count;
+ __u32 mask[AUDIT_BITMASK_SIZE];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ __u32 fields[AUDIT_MAX_FIELDS];
+ __u32 values[AUDIT_MAX_FIELDS];
+ __u32 fieldflags[AUDIT_MAX_FIELDS];
+ __u32 buflen;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ char buf[0];
+};
+struct audit_rule {
+ __u32 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ __u32 action;
+ __u32 field_count;
+ __u32 mask[AUDIT_BITMASK_SIZE];
+ __u32 fields[AUDIT_MAX_FIELDS];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ __u32 values[AUDIT_MAX_FIELDS];
+};
+#endif
diff --git a/libc/kernel/common/linux/auto_fs.h b/libc/kernel/common/linux/auto_fs.h
index 8520585..5917dfd 100644
--- a/libc/kernel/common/linux/auto_fs.h
+++ b/libc/kernel/common/linux/auto_fs.h
@@ -29,9 +29,9 @@
 #else
 typedef unsigned long autofs_wqt_t;
 #endif
-#define autofs_ptype_missing 0  
+#define autofs_ptype_missing 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define autofs_ptype_expire 1  
+#define autofs_ptype_expire 1
 struct autofs_packet_hdr {
  int proto_version;
  int type;
diff --git a/libc/kernel/common/linux/auxvec.h b/libc/kernel/common/linux/auxvec.h
index a6dcec9..80d1022 100644
--- a/libc/kernel/common/linux/auxvec.h
+++ b/libc/kernel/common/linux/auxvec.h
@@ -18,31 +18,7 @@
  ****************************************************************************/
 #ifndef _LINUX_AUXVEC_H
 #define _LINUX_AUXVEC_H
-#include <asm/auxvec.h>
-#define AT_NULL 0  
+#include <uapi/linux/auxvec.h>
+#define AT_VECTOR_SIZE_BASE 19
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define AT_IGNORE 1  
-#define AT_EXECFD 2  
-#define AT_PHDR 3  
-#define AT_PHENT 4  
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define AT_PHNUM 5  
-#define AT_PAGESZ 6  
-#define AT_BASE 7  
-#define AT_FLAGS 8  
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define AT_ENTRY 9  
-#define AT_NOTELF 10  
-#define AT_UID 11  
-#define AT_EUID 12  
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define AT_GID 13  
-#define AT_EGID 14  
-#define AT_PLATFORM 15  
-#define AT_HWCAP 16  
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define AT_CLKTCK 17  
-#define AT_SECURE 23  
-#define AT_VECTOR_SIZE 44  
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/backing-dev.h b/libc/kernel/common/linux/backing-dev.h
index 553cca7..2024bdc 100644
--- a/libc/kernel/common/linux/backing-dev.h
+++ b/libc/kernel/common/linux/backing-dev.h
@@ -39,15 +39,15 @@
  void (*unplug_io_fn)(struct backing_dev_info *, struct page *);
  void *unplug_io_data;
 };
-#define BDI_CAP_NO_ACCT_DIRTY 0x00000001  
+#define BDI_CAP_NO_ACCT_DIRTY 0x00000001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BDI_CAP_NO_WRITEBACK 0x00000002  
-#define BDI_CAP_MAP_COPY 0x00000004  
-#define BDI_CAP_MAP_DIRECT 0x00000008  
-#define BDI_CAP_READ_MAP 0x00000010  
+#define BDI_CAP_NO_WRITEBACK 0x00000002
+#define BDI_CAP_MAP_COPY 0x00000004
+#define BDI_CAP_MAP_DIRECT 0x00000008
+#define BDI_CAP_READ_MAP 0x00000010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BDI_CAP_WRITE_MAP 0x00000020  
-#define BDI_CAP_EXEC_MAP 0x00000040  
+#define BDI_CAP_WRITE_MAP 0x00000020
+#define BDI_CAP_EXEC_MAP 0x00000040
 #define BDI_CAP_VMFLAGS   (BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP)
 #if defined(VM_MAYREAD) && BDI_CAP_READ_MAP != (VM_MAYREAD || BDI_CAP_WRITE_MAP != (VM_MAYWRITE || BDI_CAP_EXEC_MAP != VM_MAYEXEC))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/bio.h b/libc/kernel/common/linux/bio.h
index 1de8e70..bf83a66 100644
--- a/libc/kernel/common/linux/bio.h
+++ b/libc/kernel/common/linux/bio.h
@@ -83,22 +83,22 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  bio_destructor_t *bi_destructor;
 };
-#define BIO_UPTODATE 0  
-#define BIO_RW_BLOCK 1  
+#define BIO_UPTODATE 0
+#define BIO_RW_BLOCK 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BIO_EOF 2  
-#define BIO_SEG_VALID 3  
-#define BIO_CLONED 4  
-#define BIO_BOUNCED 5  
+#define BIO_EOF 2
+#define BIO_SEG_VALID 3
+#define BIO_CLONED 4
+#define BIO_BOUNCED 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BIO_USER_MAPPED 6  
-#define BIO_EOPNOTSUPP 7  
+#define BIO_USER_MAPPED 6
+#define BIO_EOPNOTSUPP 7
 #define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag)))
 #define BIO_POOL_BITS (4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BIO_POOL_OFFSET (BITS_PER_LONG - BIO_POOL_BITS)
 #define BIO_POOL_MASK (1UL << BIO_POOL_OFFSET)
-#define BIO_POOL_IDX(bio) ((bio)->bi_flags >> BIO_POOL_OFFSET) 
+#define BIO_POOL_IDX(bio) ((bio)->bi_flags >> BIO_POOL_OFFSET)
 #define BIO_RW 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BIO_RW_AHEAD 1
diff --git a/libc/kernel/common/linux/blkdev.h b/libc/kernel/common/linux/blkdev.h
index 9a92850..221b47b 100644
--- a/libc/kernel/common/linux/blkdev.h
+++ b/libc/kernel/common/linux/blkdev.h
@@ -44,7 +44,7 @@
 struct request_pm_state;
 struct blk_trace;
 #define BLKDEV_MIN_RQ 4
-#define BLKDEV_MAX_RQ 128  
+#define BLKDEV_MAX_RQ 128
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct as_io_context {
  spinlock_t lock;
@@ -354,17 +354,17 @@
 };
 #define RQ_INACTIVE (-1)
 #define RQ_ACTIVE 1
-#define QUEUE_FLAG_CLUSTER 0  
+#define QUEUE_FLAG_CLUSTER 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define QUEUE_FLAG_QUEUED 1  
-#define QUEUE_FLAG_STOPPED 2  
-#define QUEUE_FLAG_READFULL 3  
-#define QUEUE_FLAG_WRITEFULL 4  
+#define QUEUE_FLAG_QUEUED 1
+#define QUEUE_FLAG_STOPPED 2
+#define QUEUE_FLAG_READFULL 3
+#define QUEUE_FLAG_WRITEFULL 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define QUEUE_FLAG_DEAD 5  
-#define QUEUE_FLAG_REENTER 6  
-#define QUEUE_FLAG_PLUGGED 7  
-#define QUEUE_FLAG_ELVSWITCH 8  
+#define QUEUE_FLAG_DEAD 5
+#define QUEUE_FLAG_REENTER 6
+#define QUEUE_FLAG_PLUGGED 7
+#define QUEUE_FLAG_ELVSWITCH 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
  QUEUE_ORDERED_NONE = 0x00,
@@ -418,10 +418,10 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define rq_mergeable(rq)   (!((rq)->flags & RQ_NOMERGE_FLAGS) && blk_fs_request((rq)))
 #define blk_queue_headactive(q, head_active)
-#define BLKPREP_OK 0  
-#define BLKPREP_KILL 1  
+#define BLKPREP_OK 0
+#define BLKPREP_KILL 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BLKPREP_DEFER 2  
+#define BLKPREP_DEFER 2
 #define BLK_BOUNCE_HIGH ((u64)blk_max_low_pfn << PAGE_SHIFT)
 #define BLK_BOUNCE_ANY ((u64)blk_max_pfn << PAGE_SHIFT)
 #define BLK_BOUNCE_ISA (ISA_DMA_THRESHOLD)
diff --git a/libc/kernel/common/linux/bmp085.h b/libc/kernel/common/linux/bmp085.h
index 0f88567..5b55912 100644
--- a/libc/kernel/common/linux/bmp085.h
+++ b/libc/kernel/common/linux/bmp085.h
@@ -18,7 +18,7 @@
  ****************************************************************************/
 #ifndef __BMP085_H__
 #define __BMP085_H__
-#include <linux/ioctl.h>  
+#include <linux/ioctl.h>
 #define BMP085_NAME "bmp085"
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BMP085_IOCTL_BASE 78
diff --git a/libc/kernel/common/linux/can.h b/libc/kernel/common/linux/can.h
index 36d3f42..7ff9cf9 100644
--- a/libc/kernel/common/linux/can.h
+++ b/libc/kernel/common/linux/can.h
@@ -21,13 +21,13 @@
 #include <linux/types.h>
 #include <linux/socket.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAN_EFF_FLAG 0x80000000U  
-#define CAN_RTR_FLAG 0x40000000U  
-#define CAN_ERR_FLAG 0x20000000U  
-#define CAN_SFF_MASK 0x000007FFU  
+#define CAN_EFF_FLAG 0x80000000U
+#define CAN_RTR_FLAG 0x40000000U
+#define CAN_ERR_FLAG 0x20000000U
+#define CAN_SFF_MASK 0x000007FFU
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAN_EFF_MASK 0x1FFFFFFFU  
-#define CAN_ERR_MASK 0x1FFFFFFFU  
+#define CAN_EFF_MASK 0x1FFFFFFFU
+#define CAN_ERR_MASK 0x1FFFFFFFU
 typedef __u32 canid_t;
 typedef __u32 can_err_mask_t;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -37,13 +37,13 @@
  __u8 data[8] __attribute__((aligned(8)));
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define CAN_RAW 1  
-#define CAN_BCM 2  
-#define CAN_TP16 3  
+#define CAN_RAW 1
+#define CAN_BCM 2
+#define CAN_TP16 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAN_TP20 4  
-#define CAN_MCNET 5  
-#define CAN_ISOTP 6  
+#define CAN_TP20 4
+#define CAN_MCNET 5
+#define CAN_ISOTP 6
 #define CAN_NPROTO 7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SOL_CAN_BASE 100
@@ -61,5 +61,5 @@
  canid_t can_mask;
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAN_INV_FILTER 0x20000000U  
+#define CAN_INV_FILTER 0x20000000U
 #endif
diff --git a/libc/kernel/common/linux/can/error.h b/libc/kernel/common/linux/can/error.h
index 6caaf8b..2436ace 100644
--- a/libc/kernel/common/linux/can/error.h
+++ b/libc/kernel/common/linux/can/error.h
@@ -18,76 +18,76 @@
  ****************************************************************************/
 #ifndef CAN_ERROR_H
 #define CAN_ERROR_H
-#define CAN_ERR_DLC 8  
-#define CAN_ERR_TX_TIMEOUT 0x00000001U  
+#define CAN_ERR_DLC 8
+#define CAN_ERR_TX_TIMEOUT 0x00000001U
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAN_ERR_LOSTARB 0x00000002U  
-#define CAN_ERR_CRTL 0x00000004U  
-#define CAN_ERR_PROT 0x00000008U  
-#define CAN_ERR_TRX 0x00000010U  
+#define CAN_ERR_LOSTARB 0x00000002U
+#define CAN_ERR_CRTL 0x00000004U
+#define CAN_ERR_PROT 0x00000008U
+#define CAN_ERR_TRX 0x00000010U
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAN_ERR_ACK 0x00000020U  
-#define CAN_ERR_BUSOFF 0x00000040U  
-#define CAN_ERR_BUSERROR 0x00000080U  
-#define CAN_ERR_RESTARTED 0x00000100U  
+#define CAN_ERR_ACK 0x00000020U
+#define CAN_ERR_BUSOFF 0x00000040U
+#define CAN_ERR_BUSERROR 0x00000080U
+#define CAN_ERR_RESTARTED 0x00000100U
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAN_ERR_LOSTARB_UNSPEC 0x00  
-#define CAN_ERR_CRTL_UNSPEC 0x00  
-#define CAN_ERR_CRTL_RX_OVERFLOW 0x01  
-#define CAN_ERR_CRTL_TX_OVERFLOW 0x02  
+#define CAN_ERR_LOSTARB_UNSPEC 0x00
+#define CAN_ERR_CRTL_UNSPEC 0x00
+#define CAN_ERR_CRTL_RX_OVERFLOW 0x01
+#define CAN_ERR_CRTL_TX_OVERFLOW 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAN_ERR_CRTL_RX_WARNING 0x04  
-#define CAN_ERR_CRTL_TX_WARNING 0x08  
-#define CAN_ERR_CRTL_RX_PASSIVE 0x10  
-#define CAN_ERR_CRTL_TX_PASSIVE 0x20  
+#define CAN_ERR_CRTL_RX_WARNING 0x04
+#define CAN_ERR_CRTL_TX_WARNING 0x08
+#define CAN_ERR_CRTL_RX_PASSIVE 0x10
+#define CAN_ERR_CRTL_TX_PASSIVE 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAN_ERR_PROT_UNSPEC 0x00  
-#define CAN_ERR_PROT_BIT 0x01  
-#define CAN_ERR_PROT_FORM 0x02  
-#define CAN_ERR_PROT_STUFF 0x04  
+#define CAN_ERR_PROT_UNSPEC 0x00
+#define CAN_ERR_PROT_BIT 0x01
+#define CAN_ERR_PROT_FORM 0x02
+#define CAN_ERR_PROT_STUFF 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAN_ERR_PROT_BIT0 0x08  
-#define CAN_ERR_PROT_BIT1 0x10  
-#define CAN_ERR_PROT_OVERLOAD 0x20  
-#define CAN_ERR_PROT_ACTIVE 0x40  
+#define CAN_ERR_PROT_BIT0 0x08
+#define CAN_ERR_PROT_BIT1 0x10
+#define CAN_ERR_PROT_OVERLOAD 0x20
+#define CAN_ERR_PROT_ACTIVE 0x40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAN_ERR_PROT_TX 0x80  
-#define CAN_ERR_PROT_LOC_UNSPEC 0x00  
-#define CAN_ERR_PROT_LOC_SOF 0x03  
-#define CAN_ERR_PROT_LOC_ID28_21 0x02  
+#define CAN_ERR_PROT_TX 0x80
+#define CAN_ERR_PROT_LOC_UNSPEC 0x00
+#define CAN_ERR_PROT_LOC_SOF 0x03
+#define CAN_ERR_PROT_LOC_ID28_21 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAN_ERR_PROT_LOC_ID20_18 0x06  
-#define CAN_ERR_PROT_LOC_SRTR 0x04  
-#define CAN_ERR_PROT_LOC_IDE 0x05  
-#define CAN_ERR_PROT_LOC_ID17_13 0x07  
+#define CAN_ERR_PROT_LOC_ID20_18 0x06
+#define CAN_ERR_PROT_LOC_SRTR 0x04
+#define CAN_ERR_PROT_LOC_IDE 0x05
+#define CAN_ERR_PROT_LOC_ID17_13 0x07
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAN_ERR_PROT_LOC_ID12_05 0x0F  
-#define CAN_ERR_PROT_LOC_ID04_00 0x0E  
-#define CAN_ERR_PROT_LOC_RTR 0x0C  
-#define CAN_ERR_PROT_LOC_RES1 0x0D  
+#define CAN_ERR_PROT_LOC_ID12_05 0x0F
+#define CAN_ERR_PROT_LOC_ID04_00 0x0E
+#define CAN_ERR_PROT_LOC_RTR 0x0C
+#define CAN_ERR_PROT_LOC_RES1 0x0D
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAN_ERR_PROT_LOC_RES0 0x09  
-#define CAN_ERR_PROT_LOC_DLC 0x0B  
-#define CAN_ERR_PROT_LOC_DATA 0x0A  
-#define CAN_ERR_PROT_LOC_CRC_SEQ 0x08  
+#define CAN_ERR_PROT_LOC_RES0 0x09
+#define CAN_ERR_PROT_LOC_DLC 0x0B
+#define CAN_ERR_PROT_LOC_DATA 0x0A
+#define CAN_ERR_PROT_LOC_CRC_SEQ 0x08
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAN_ERR_PROT_LOC_CRC_DEL 0x18  
-#define CAN_ERR_PROT_LOC_ACK 0x19  
-#define CAN_ERR_PROT_LOC_ACK_DEL 0x1B  
-#define CAN_ERR_PROT_LOC_EOF 0x1A  
+#define CAN_ERR_PROT_LOC_CRC_DEL 0x18
+#define CAN_ERR_PROT_LOC_ACK 0x19
+#define CAN_ERR_PROT_LOC_ACK_DEL 0x1B
+#define CAN_ERR_PROT_LOC_EOF 0x1A
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAN_ERR_PROT_LOC_INTERM 0x12  
-#define CAN_ERR_TRX_UNSPEC 0x00  
-#define CAN_ERR_TRX_CANH_NO_WIRE 0x04  
-#define CAN_ERR_TRX_CANH_SHORT_TO_BAT 0x05  
+#define CAN_ERR_PROT_LOC_INTERM 0x12
+#define CAN_ERR_TRX_UNSPEC 0x00
+#define CAN_ERR_TRX_CANH_NO_WIRE 0x04
+#define CAN_ERR_TRX_CANH_SHORT_TO_BAT 0x05
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAN_ERR_TRX_CANH_SHORT_TO_VCC 0x06  
-#define CAN_ERR_TRX_CANH_SHORT_TO_GND 0x07  
-#define CAN_ERR_TRX_CANL_NO_WIRE 0x40  
-#define CAN_ERR_TRX_CANL_SHORT_TO_BAT 0x50  
+#define CAN_ERR_TRX_CANH_SHORT_TO_VCC 0x06
+#define CAN_ERR_TRX_CANH_SHORT_TO_GND 0x07
+#define CAN_ERR_TRX_CANL_NO_WIRE 0x40
+#define CAN_ERR_TRX_CANL_SHORT_TO_BAT 0x50
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAN_ERR_TRX_CANL_SHORT_TO_VCC 0x60  
-#define CAN_ERR_TRX_CANL_SHORT_TO_GND 0x70  
-#define CAN_ERR_TRX_CANL_SHORT_TO_CANH 0x80  
+#define CAN_ERR_TRX_CANL_SHORT_TO_VCC 0x60
+#define CAN_ERR_TRX_CANL_SHORT_TO_GND 0x70
+#define CAN_ERR_TRX_CANL_SHORT_TO_CANH 0x80
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/can/gw.h b/libc/kernel/common/linux/can/gw.h
index 2aacd2d..8e9a8a7 100644
--- a/libc/kernel/common/linux/can/gw.h
+++ b/libc/kernel/common/linux/can/gw.h
@@ -57,12 +57,12 @@
 #define CGW_FLAGS_CAN_ECHO 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CGW_FLAGS_CAN_SRC_TSTAMP 0x02
-#define CGW_MOD_FUNCS 4  
+#define CGW_MOD_FUNCS 4
 #define CGW_MOD_ID 0x01
 #define CGW_MOD_DLC 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CGW_MOD_DATA 0x04
-#define CGW_FRAME_MODS 3  
+#define CGW_FRAME_MODS 3
 #define MAX_MODFUNCTIONS (CGW_MOD_FUNCS * CGW_FRAME_MODS)
 struct cgw_frame_mod {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/can/netlink.h b/libc/kernel/common/linux/can/netlink.h
index a6006d3..df8a19c 100644
--- a/libc/kernel/common/linux/can/netlink.h
+++ b/libc/kernel/common/linux/can/netlink.h
@@ -71,12 +71,12 @@
  __u32 flags;
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAN_CTRLMODE_LOOPBACK 0x01  
-#define CAN_CTRLMODE_LISTENONLY 0x02  
-#define CAN_CTRLMODE_3_SAMPLES 0x04  
-#define CAN_CTRLMODE_ONE_SHOT 0x08  
+#define CAN_CTRLMODE_LOOPBACK 0x01
+#define CAN_CTRLMODE_LISTENONLY 0x02
+#define CAN_CTRLMODE_3_SAMPLES 0x04
+#define CAN_CTRLMODE_ONE_SHOT 0x08
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAN_CTRLMODE_BERR_REPORTING 0x10  
+#define CAN_CTRLMODE_BERR_REPORTING 0x10
 struct can_device_stats {
  __u32 bus_error;
  __u32 error_warning;
diff --git a/libc/kernel/common/linux/capability.h b/libc/kernel/common/linux/capability.h
index 7350e7c..68a6e0d 100644
--- a/libc/kernel/common/linux/capability.h
+++ b/libc/kernel/common/linux/capability.h
@@ -23,7 +23,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define _LINUX_CAPABILITY_VERSION_1 0x19980330
 #define _LINUX_CAPABILITY_U32S_1 1
-#define _LINUX_CAPABILITY_VERSION_2 0x20071026  
+#define _LINUX_CAPABILITY_VERSION_2 0x20071026
 #define _LINUX_CAPABILITY_U32S_2 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define _LINUX_CAPABILITY_VERSION_3 0x20080522
@@ -114,7 +114,7 @@
 #define CAP_WAKE_ALARM 35
 #define CAP_LAST_CAP CAP_WAKE_ALARM
 #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
-#define CAP_TO_INDEX(x) ((x) >> 5)  
+#define CAP_TO_INDEX(x) ((x) >> 5)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAP_TO_MASK(x) (1 << ((x) & 31))  
+#define CAP_TO_MASK(x) (1 << ((x) & 31))
 #endif
diff --git a/libc/kernel/common/linux/capi.h b/libc/kernel/common/linux/capi.h
index 6ca9935..4ed5369 100644
--- a/libc/kernel/common/linux/capi.h
+++ b/libc/kernel/common/linux/capi.h
@@ -31,7 +31,7 @@
 #define CAPI_REGISTER _IOW('C',0x01,struct capi_register_params)
 #define CAPI_MANUFACTURER_LEN 64
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CAPI_GET_MANUFACTURER _IOWR('C',0x06,int)  
+#define CAPI_GET_MANUFACTURER _IOWR('C',0x06,int)
 typedef struct capi_version {
  __u32 majorversion;
  __u32 minorversion;
@@ -42,7 +42,7 @@
 #define CAPI_GET_VERSION _IOWR('C',0x07,struct capi_version)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CAPI_SERIAL_LEN 8
-#define CAPI_GET_SERIAL _IOWR('C',0x08,int)  
+#define CAPI_GET_SERIAL _IOWR('C',0x08,int)
 typedef struct capi_profile {
  __u16 ncontroller;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/cdrom.h b/libc/kernel/common/linux/cdrom.h
index ca51fa9..abec13f 100644
--- a/libc/kernel/common/linux/cdrom.h
+++ b/libc/kernel/common/linux/cdrom.h
@@ -21,63 +21,63 @@
 #include <asm/byteorder.h>
 #define EDRIVE_CANT_DO_THIS EOPNOTSUPP
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CDROMPAUSE 0x5301   
-#define CDROMRESUME 0x5302  
-#define CDROMPLAYMSF 0x5303  
-#define CDROMPLAYTRKIND 0x5304  
+#define CDROMPAUSE 0x5301
+#define CDROMRESUME 0x5302
+#define CDROMPLAYMSF 0x5303
+#define CDROMPLAYTRKIND 0x5304
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CDROMREADTOCHDR 0x5305  
-#define CDROMREADTOCENTRY 0x5306  
-#define CDROMSTOP 0x5307  
-#define CDROMSTART 0x5308  
+#define CDROMREADTOCHDR 0x5305
+#define CDROMREADTOCENTRY 0x5306
+#define CDROMSTOP 0x5307
+#define CDROMSTART 0x5308
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CDROMEJECT 0x5309  
-#define CDROMVOLCTRL 0x530a  
-#define CDROMSUBCHNL 0x530b  
-#define CDROMREADMODE2 0x530c  
+#define CDROMEJECT 0x5309
+#define CDROMVOLCTRL 0x530a
+#define CDROMSUBCHNL 0x530b
+#define CDROMREADMODE2 0x530c
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CDROMREADMODE1 0x530d  
-#define CDROMREADAUDIO 0x530e  
-#define CDROMEJECT_SW 0x530f  
-#define CDROMMULTISESSION 0x5310  
+#define CDROMREADMODE1 0x530d
+#define CDROMREADAUDIO 0x530e
+#define CDROMEJECT_SW 0x530f
+#define CDROMMULTISESSION 0x5310
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CDROM_GET_MCN 0x5311  
-#define CDROM_GET_UPC CDROM_GET_MCN  
-#define CDROMRESET 0x5312  
-#define CDROMVOLREAD 0x5313  
+#define CDROM_GET_MCN 0x5311
+#define CDROM_GET_UPC CDROM_GET_MCN
+#define CDROMRESET 0x5312
+#define CDROMVOLREAD 0x5313
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CDROMREADRAW 0x5314  
-#define CDROMREADCOOKED 0x5315  
-#define CDROMSEEK 0x5316  
-#define CDROMPLAYBLK 0x5317  
+#define CDROMREADRAW 0x5314
+#define CDROMREADCOOKED 0x5315
+#define CDROMSEEK 0x5316
+#define CDROMPLAYBLK 0x5317
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CDROMREADALL 0x5318  
+#define CDROMREADALL 0x5318
 #define CDROMGETSPINDOWN 0x531d
 #define CDROMSETSPINDOWN 0x531e
-#define CDROMCLOSETRAY 0x5319  
+#define CDROMCLOSETRAY 0x5319
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CDROM_SET_OPTIONS 0x5320  
-#define CDROM_CLEAR_OPTIONS 0x5321  
-#define CDROM_SELECT_SPEED 0x5322  
-#define CDROM_SELECT_DISC 0x5323  
+#define CDROM_SET_OPTIONS 0x5320
+#define CDROM_CLEAR_OPTIONS 0x5321
+#define CDROM_SELECT_SPEED 0x5322
+#define CDROM_SELECT_DISC 0x5323
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CDROM_MEDIA_CHANGED 0x5325  
-#define CDROM_DRIVE_STATUS 0x5326  
-#define CDROM_DISC_STATUS 0x5327  
-#define CDROM_CHANGER_NSLOTS 0x5328  
+#define CDROM_MEDIA_CHANGED 0x5325
+#define CDROM_DRIVE_STATUS 0x5326
+#define CDROM_DISC_STATUS 0x5327
+#define CDROM_CHANGER_NSLOTS 0x5328
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CDROM_LOCKDOOR 0x5329  
-#define CDROM_DEBUG 0x5330  
-#define CDROM_GET_CAPABILITY 0x5331  
-#define CDROMAUDIOBUFSIZ 0x5382  
+#define CDROM_LOCKDOOR 0x5329
+#define CDROM_DEBUG 0x5330
+#define CDROM_GET_CAPABILITY 0x5331
+#define CDROMAUDIOBUFSIZ 0x5382
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DVD_READ_STRUCT 0x5390  
-#define DVD_WRITE_STRUCT 0x5391  
-#define DVD_AUTH 0x5392  
-#define CDROM_SEND_PACKET 0x5393  
+#define DVD_READ_STRUCT 0x5390
+#define DVD_WRITE_STRUCT 0x5391
+#define DVD_AUTH 0x5392
+#define CDROM_SEND_PACKET 0x5393
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CDROM_NEXT_WRITABLE 0x5394  
-#define CDROM_LAST_WRITTEN 0x5395  
+#define CDROM_NEXT_WRITABLE 0x5394
+#define CDROM_LAST_WRITTEN 0x5395
 struct cdrom_msf0
 {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -208,72 +208,72 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  void __user *reserved[1];
 };
-#define CD_MINS 74  
-#define CD_SECS 60  
+#define CD_MINS 74
+#define CD_SECS 60
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CD_FRAMES 75  
-#define CD_SYNC_SIZE 12  
-#define CD_MSF_OFFSET 150  
-#define CD_CHUNK_SIZE 24  
+#define CD_FRAMES 75
+#define CD_SYNC_SIZE 12
+#define CD_MSF_OFFSET 150
+#define CD_CHUNK_SIZE 24
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CD_NUM_OF_CHUNKS 98  
-#define CD_FRAMESIZE_SUB 96  
-#define CD_HEAD_SIZE 4  
-#define CD_SUBHEAD_SIZE 8  
+#define CD_NUM_OF_CHUNKS 98
+#define CD_FRAMESIZE_SUB 96
+#define CD_HEAD_SIZE 4
+#define CD_SUBHEAD_SIZE 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CD_EDC_SIZE 4  
-#define CD_ZERO_SIZE 8  
-#define CD_ECC_SIZE 276  
-#define CD_FRAMESIZE 2048  
+#define CD_EDC_SIZE 4
+#define CD_ZERO_SIZE 8
+#define CD_ECC_SIZE 276
+#define CD_FRAMESIZE 2048
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CD_FRAMESIZE_RAW 2352  
-#define CD_FRAMESIZE_RAWER 2646   
-#define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE)  
-#define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE)  
+#define CD_FRAMESIZE_RAW 2352
+#define CD_FRAMESIZE_RAWER 2646
+#define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE)
+#define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CD_XA_HEAD (CD_HEAD_SIZE+CD_SUBHEAD_SIZE)  
-#define CD_XA_TAIL (CD_EDC_SIZE+CD_ECC_SIZE)  
-#define CD_XA_SYNC_HEAD (CD_SYNC_SIZE+CD_XA_HEAD)  
-#define CDROM_LBA 0x01  
+#define CD_XA_HEAD (CD_HEAD_SIZE+CD_SUBHEAD_SIZE)
+#define CD_XA_TAIL (CD_EDC_SIZE+CD_ECC_SIZE)
+#define CD_XA_SYNC_HEAD (CD_SYNC_SIZE+CD_XA_HEAD)
+#define CDROM_LBA 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CDROM_MSF 0x02  
+#define CDROM_MSF 0x02
 #define CDROM_DATA_TRACK 0x04
 #define CDROM_LEADOUT 0xAA
-#define CDROM_AUDIO_INVALID 0x00  
+#define CDROM_AUDIO_INVALID 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CDROM_AUDIO_PLAY 0x11  
-#define CDROM_AUDIO_PAUSED 0x12  
-#define CDROM_AUDIO_COMPLETED 0x13  
-#define CDROM_AUDIO_ERROR 0x14  
+#define CDROM_AUDIO_PLAY 0x11
+#define CDROM_AUDIO_PAUSED 0x12
+#define CDROM_AUDIO_COMPLETED 0x13
+#define CDROM_AUDIO_ERROR 0x14
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CDROM_AUDIO_NO_STATUS 0x15  
-#define CDC_CLOSE_TRAY 0x1  
-#define CDC_OPEN_TRAY 0x2  
-#define CDC_LOCK 0x4  
+#define CDROM_AUDIO_NO_STATUS 0x15
+#define CDC_CLOSE_TRAY 0x1
+#define CDC_OPEN_TRAY 0x2
+#define CDC_LOCK 0x4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CDC_SELECT_SPEED 0x8  
-#define CDC_SELECT_DISC 0x10  
-#define CDC_MULTI_SESSION 0x20  
-#define CDC_MCN 0x40  
+#define CDC_SELECT_SPEED 0x8
+#define CDC_SELECT_DISC 0x10
+#define CDC_MULTI_SESSION 0x20
+#define CDC_MCN 0x40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CDC_MEDIA_CHANGED 0x80  
-#define CDC_PLAY_AUDIO 0x100  
-#define CDC_RESET 0x200  
-#define CDC_DRIVE_STATUS 0x800  
+#define CDC_MEDIA_CHANGED 0x80
+#define CDC_PLAY_AUDIO 0x100
+#define CDC_RESET 0x200
+#define CDC_DRIVE_STATUS 0x800
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CDC_GENERIC_PACKET 0x1000  
-#define CDC_CD_R 0x2000  
-#define CDC_CD_RW 0x4000  
-#define CDC_DVD 0x8000  
+#define CDC_GENERIC_PACKET 0x1000
+#define CDC_CD_R 0x2000
+#define CDC_CD_RW 0x4000
+#define CDC_DVD 0x8000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CDC_DVD_R 0x10000  
-#define CDC_DVD_RAM 0x20000  
-#define CDC_MO_DRIVE 0x40000  
-#define CDC_MRW 0x80000  
+#define CDC_DVD_R 0x10000
+#define CDC_DVD_RAM 0x20000
+#define CDC_MO_DRIVE 0x40000
+#define CDC_MRW 0x80000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CDC_MRW_W 0x100000  
-#define CDC_RAM 0x200000  
-#define CDS_NO_INFO 0  
+#define CDC_MRW_W 0x100000
+#define CDC_RAM 0x200000
+#define CDS_NO_INFO 0
 #define CDS_NO_DISC 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CDS_TRAY_OPEN 2
@@ -287,12 +287,12 @@
 #define CDS_XA_2_2 104
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CDS_MIXED 105
-#define CDO_AUTO_CLOSE 0x1  
-#define CDO_AUTO_EJECT 0x2  
-#define CDO_USE_FFLAGS 0x4  
+#define CDO_AUTO_CLOSE 0x1
+#define CDO_AUTO_EJECT 0x2
+#define CDO_USE_FFLAGS 0x4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CDO_LOCK 0x8  
-#define CDO_CHECK_TYPE 0x10  
+#define CDO_LOCK 0x8
+#define CDO_CHECK_TYPE 0x10
 #define CDSL_NONE ((int) (~0U>>1)-1)
 #define CDSL_CURRENT ((int) (~0U>>1))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -581,8 +581,8 @@
  __u8 asb[46];
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CDF_RWRT 0x0020  
-#define CDF_HWDM 0x0024  
+#define CDF_RWRT 0x0020
+#define CDF_HWDM 0x0024
 #define CDF_MRW 0x0028
 #define CDM_MRW_NOTMRW 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/coda.h b/libc/kernel/common/linux/coda.h
index ff109e8..d03dc93 100644
--- a/libc/kernel/common/linux/coda.h
+++ b/libc/kernel/common/linux/coda.h
@@ -98,12 +98,12 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define C_M_READ 00400
 #define C_M_WRITE 00200
-#define C_A_C_OK 8  
-#define C_A_R_OK 4  
+#define C_A_C_OK 8
+#define C_A_R_OK 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define C_A_W_OK 2  
-#define C_A_X_OK 1  
-#define C_A_F_OK 0  
+#define C_A_W_OK 2
+#define C_A_X_OK 1
+#define C_A_F_OK 0
 #ifndef _VENUS_DIRENT_T_
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define _VENUS_DIRENT_T_ 1
@@ -206,13 +206,13 @@
 #define CODA_VGET 22
 #define CODA_SIGNAL 23
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CODA_REPLACE 24  
-#define CODA_FLUSH 25  
-#define CODA_PURGEUSER 26  
-#define CODA_ZAPFILE 27  
+#define CODA_REPLACE 24
+#define CODA_FLUSH 25
+#define CODA_PURGEUSER 26
+#define CODA_ZAPFILE 27
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CODA_ZAPDIR 28  
-#define CODA_PURGEFID 30  
+#define CODA_ZAPDIR 28
+#define CODA_PURGEFID 30
 #define CODA_OPEN_BY_PATH 31
 #define CODA_RESOLVE 32
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -224,10 +224,10 @@
 #define CODA_NCALLS 37
 #define DOWNCALL(opcode) (opcode >= CODA_REPLACE && opcode <= CODA_PURGEFID)
 #define VC_MAXDATASIZE 8192
-#define VC_MAXMSGSIZE sizeof(union inputArgs)+sizeof(union outputArgs) +  VC_MAXDATASIZE 
+#define VC_MAXMSGSIZE sizeof(union inputArgs)+sizeof(union outputArgs) +  VC_MAXDATASIZE
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CIOC_KERNEL_VERSION _IOWR('c', 10, size_t)
-#define CODA_KERNEL_VERSION 3  
+#define CODA_KERNEL_VERSION 3
 struct coda_in_hdr {
  u_int32_t opcode;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/compiler.h b/libc/kernel/common/linux/compiler.h
index 9e6dc4b..1d913b7 100644
--- a/libc/kernel/common/linux/compiler.h
+++ b/libc/kernel/common/linux/compiler.h
@@ -39,7 +39,7 @@
 #define __cond_lock(x) (x)
 #endif
 #ifndef __attribute_const__
-#define __attribute_const__  
+#define __attribute_const__
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #endif
diff --git a/libc/kernel/common/linux/ctype.h b/libc/kernel/common/linux/ctype.h
index ca4da81..869af3d 100644
--- a/libc/kernel/common/linux/ctype.h
+++ b/libc/kernel/common/linux/ctype.h
@@ -18,16 +18,16 @@
  ****************************************************************************/
 #ifndef _LINUX_CTYPE_H
 #define _LINUX_CTYPE_H
-#define _U 0x01  
-#define _L 0x02  
+#define _U 0x01
+#define _L 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define _D 0x04  
-#define _C 0x08  
-#define _P 0x10  
-#define _S 0x20  
+#define _D 0x04
+#define _C 0x08
+#define _P 0x10
+#define _S 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define _X 0x40  
-#define _SP 0x80  
+#define _X 0x40
+#define _SP 0x80
 #define __ismask(x) (_ctype[(int)(unsigned char)(x)])
 #define isalnum(c) ((__ismask(c)&(_U|_L|_D)) != 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/device.h b/libc/kernel/common/linux/device.h
index 025b88e..aa5ece6 100644
--- a/libc/kernel/common/linux/device.h
+++ b/libc/kernel/common/linux/device.h
@@ -31,7 +31,7 @@
 #include <asm/atomic.h>
 #define DEVICE_NAME_SIZE 50
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DEVICE_NAME_HALF __stringify(20)  
+#define DEVICE_NAME_HALF __stringify(20)
 #define DEVICE_ID_SIZE 32
 #define BUS_ID_SIZE KOBJ_NAME_LEN
 struct device;
@@ -127,7 +127,7 @@
  ssize_t (*store)(struct class *, const char * buf, size_t count);
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define CLASS_ATTR(_name,_mode,_show,_store)  struct class_attribute class_attr_##_name = __ATTR(_name,_mode,_show,_store) 
+#define CLASS_ATTR(_name,_mode,_show,_store)  struct class_attribute class_attr_##_name = __ATTR(_name,_mode,_show,_store)
 struct class_device_attribute {
  struct attribute attr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/dm-ioctl.h b/libc/kernel/common/linux/dm-ioctl.h
index aa9521f..8d4f28f 100644
--- a/libc/kernel/common/linux/dm-ioctl.h
+++ b/libc/kernel/common/linux/dm-ioctl.h
@@ -19,7 +19,7 @@
 #ifndef _LINUX_DM_IOCTL_V4_H
 #define _LINUX_DM_IOCTL_V4_H
 #include <linux/types.h>
-#define DM_DIR "mapper"  
+#define DM_DIR "mapper"
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DM_MAX_TYPE_NAME 16
 #define DM_NAME_LEN 128
@@ -123,17 +123,17 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DM_VERSION_PATCHLEVEL 0
 #define DM_VERSION_EXTRA "-ioctl (2008-04-23)"
-#define DM_READONLY_FLAG (1 << 0)  
-#define DM_SUSPEND_FLAG (1 << 1)  
+#define DM_READONLY_FLAG (1 << 0)
+#define DM_SUSPEND_FLAG (1 << 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DM_PERSISTENT_DEV_FLAG (1 << 3)  
-#define DM_STATUS_TABLE_FLAG (1 << 4)  
-#define DM_ACTIVE_PRESENT_FLAG (1 << 5)  
-#define DM_INACTIVE_PRESENT_FLAG (1 << 6)  
+#define DM_PERSISTENT_DEV_FLAG (1 << 3)
+#define DM_STATUS_TABLE_FLAG (1 << 4)
+#define DM_ACTIVE_PRESENT_FLAG (1 << 5)
+#define DM_INACTIVE_PRESENT_FLAG (1 << 6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DM_BUFFER_FULL_FLAG (1 << 8)  
-#define DM_SKIP_BDGET_FLAG (1 << 9)  
-#define DM_SKIP_LOCKFS_FLAG (1 << 10)  
-#define DM_NOFLUSH_FLAG (1 << 11)  
+#define DM_BUFFER_FULL_FLAG (1 << 8)
+#define DM_SKIP_BDGET_FLAG (1 << 9)
+#define DM_SKIP_LOCKFS_FLAG (1 << 10)
+#define DM_NOFLUSH_FLAG (1 << 11)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/common/linux/efs_dir.h b/libc/kernel/common/linux/efs_dir.h
index 40991a3..98a5ba7 100644
--- a/libc/kernel/common/linux/efs_dir.h
+++ b/libc/kernel/common/linux/efs_dir.h
@@ -31,7 +31,7 @@
 #define EFS_MAXNAMELEN ((1 << (sizeof(char) * 8)) - 1)
 #define EFS_DIRBLK_HEADERSIZE 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EFS_DIRBLK_MAGIC 0xbeef  
+#define EFS_DIRBLK_MAGIC 0xbeef
 struct efs_dir {
  __be16 magic;
  unsigned char firstused;
diff --git a/libc/kernel/common/linux/elf-em.h b/libc/kernel/common/linux/elf-em.h
index 766dd14..f1e4e47 100644
--- a/libc/kernel/common/linux/elf-em.h
+++ b/libc/kernel/common/linux/elf-em.h
@@ -26,29 +26,29 @@
 #define EM_68K 4
 #define EM_88K 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EM_486 6  
+#define EM_486 6
 #define EM_860 7
-#define EM_MIPS 8  
-#define EM_MIPS_RS3_LE 10  
+#define EM_MIPS 8
+#define EM_MIPS_RS3_LE 10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EM_MIPS_RS4_BE 10  
-#define EM_PARISC 15  
-#define EM_SPARC32PLUS 18  
-#define EM_PPC 20  
+#define EM_MIPS_RS4_BE 10
+#define EM_PARISC 15
+#define EM_SPARC32PLUS 18
+#define EM_PPC 20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EM_PPC64 21  
-#define EM_SH 42  
-#define EM_SPARCV9 43  
-#define EM_IA_64 50  
+#define EM_PPC64 21
+#define EM_SH 42
+#define EM_SPARCV9 43
+#define EM_IA_64 50
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EM_X86_64 62  
-#define EM_S390 22  
-#define EM_CRIS 76  
-#define EM_V850 87  
+#define EM_X86_64 62
+#define EM_S390 22
+#define EM_CRIS 76
+#define EM_V850 87
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EM_M32R 88  
-#define EM_H8_300 46  
-#define EM_FRV 0x5441  
+#define EM_M32R 88
+#define EM_H8_300 46
+#define EM_FRV 0x5441
 #define EM_ALPHA 0x9026
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EM_CYGNUS_V850 0x9080
diff --git a/libc/kernel/common/linux/elf.h b/libc/kernel/common/linux/elf.h
deleted file mode 100644
index d79e3b9..0000000
--- a/libc/kernel/common/linux/elf.h
+++ /dev/null
@@ -1,394 +0,0 @@
-/****************************************************************************
- ****************************************************************************
- ***
- ***   This header was automatically generated from a Linux kernel header
- ***   of the same name, to make information necessary for userspace to
- ***   call into the kernel available to libc.  It contains only constants,
- ***   structures, and macros generated from the original header, and thus,
- ***   contains no copyrightable information.
- ***
- ***   To edit the content of this header, modify the corresponding
- ***   source file (e.g. under external/kernel-headers/original/) then
- ***   run bionic/libc/kernel/tools/update_all.py
- ***
- ***   Any manual change here will be lost the next time this script will
- ***   be run. You've been warned!
- ***
- ****************************************************************************
- ****************************************************************************/
-#ifndef _LINUX_ELF_H
-#define _LINUX_ELF_H
-#include <linux/types.h>
-#include <linux/auxvec.h>
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#include <linux/elf-em.h>
-#include <asm/elf.h>
-#ifndef elf_read_implies_exec
-#define elf_read_implies_exec(ex, have_pt_gnu_stack) 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
-typedef __u32 Elf32_Addr;
-typedef __u16 Elf32_Half;
-typedef __u32 Elf32_Off;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-typedef __s32 Elf32_Sword;
-typedef __u32 Elf32_Word;
-typedef __u64 Elf64_Addr;
-typedef __u16 Elf64_Half;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-typedef __s16 Elf64_SHalf;
-typedef __u64 Elf64_Off;
-typedef __s32 Elf64_Sword;
-typedef __u32 Elf64_Word;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-typedef __u64 Elf64_Xword;
-typedef __s64 Elf64_Sxword;
-#define PT_NULL 0
-#define PT_LOAD 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PT_DYNAMIC 2
-#define PT_INTERP 3
-#define PT_NOTE 4
-#define PT_SHLIB 5
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PT_PHDR 6
-#define PT_TLS 7  
-#define PT_LOOS 0x60000000  
-#define PT_HIOS 0x6fffffff  
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PT_LOPROC 0x70000000
-#define PT_HIPROC 0x7fffffff
-#define PT_GNU_EH_FRAME 0x6474e550
-#define PT_GNU_STACK (PT_LOOS + 0x474e551)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ET_NONE 0
-#define ET_REL 1
-#define ET_EXEC 2
-#define ET_DYN 3
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ET_CORE 4
-#define ET_LOPROC 0xff00
-#define ET_HIPROC 0xffff
-#define DT_NULL 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DT_NEEDED 1
-#define DT_PLTRELSZ 2
-#define DT_PLTGOT 3
-#define DT_HASH 4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DT_STRTAB 5
-#define DT_SYMTAB 6
-#define DT_RELA 7
-#define DT_RELASZ 8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DT_RELAENT 9
-#define DT_STRSZ 10
-#define DT_SYMENT 11
-#define DT_INIT 12
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DT_FINI 13
-#define DT_SONAME 14
-#define DT_RPATH 15
-#define DT_SYMBOLIC 16
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DT_REL 17
-#define DT_RELSZ 18
-#define DT_RELENT 19
-#define DT_PLTREL 20
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DT_DEBUG 21
-#define DT_TEXTREL 22
-#define DT_JMPREL 23
-#define DT_LOPROC 0x70000000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DT_HIPROC 0x7fffffff
-#define STB_LOCAL 0
-#define STB_GLOBAL 1
-#define STB_WEAK 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define STT_NOTYPE 0
-#define STT_OBJECT 1
-#define STT_FUNC 2
-#define STT_SECTION 3
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define STT_FILE 4
-#define STT_COMMON 5
-#define STT_TLS 6
-#define ELF_ST_BIND(x) ((x) >> 4)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ELF_ST_TYPE(x) (((unsigned int) x) & 0xf)
-#define ELF32_ST_BIND(x) ELF_ST_BIND(x)
-#define ELF32_ST_TYPE(x) ELF_ST_TYPE(x)
-#define ELF64_ST_BIND(x) ELF_ST_BIND(x)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ELF64_ST_TYPE(x) ELF_ST_TYPE(x)
-typedef struct dynamic{
- Elf32_Sword d_tag;
- union{
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf32_Sword d_val;
- Elf32_Addr d_ptr;
- } d_un;
-} Elf32_Dyn;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-typedef struct {
- Elf64_Sxword d_tag;
- union {
- Elf64_Xword d_val;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf64_Addr d_ptr;
- } d_un;
-} Elf64_Dyn;
-#define ELF32_R_SYM(x) ((x) >> 8)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ELF32_R_TYPE(x) ((x) & 0xff)
-#define ELF64_R_SYM(i) ((i) >> 32)
-#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
-typedef struct elf32_rel {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf32_Addr r_offset;
- Elf32_Word r_info;
-} Elf32_Rel;
-typedef struct elf64_rel {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf64_Addr r_offset;
- Elf64_Xword r_info;
-} Elf64_Rel;
-typedef struct elf32_rela{
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf32_Addr r_offset;
- Elf32_Word r_info;
- Elf32_Sword r_addend;
-} Elf32_Rela;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-typedef struct elf64_rela {
- Elf64_Addr r_offset;
- Elf64_Xword r_info;
- Elf64_Sxword r_addend;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-} Elf64_Rela;
-typedef struct elf32_sym{
- Elf32_Word st_name;
- Elf32_Addr st_value;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf32_Word st_size;
- unsigned char st_info;
- unsigned char st_other;
- Elf32_Half st_shndx;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-} Elf32_Sym;
-typedef struct elf64_sym {
- Elf64_Word st_name;
- unsigned char st_info;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned char st_other;
- Elf64_Half st_shndx;
- Elf64_Addr st_value;
- Elf64_Xword st_size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-} Elf64_Sym;
-#define EI_NIDENT 16
-typedef struct elf32_hdr{
- unsigned char e_ident[EI_NIDENT];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf32_Half e_type;
- Elf32_Half e_machine;
- Elf32_Word e_version;
- Elf32_Addr e_entry;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf32_Off e_phoff;
- Elf32_Off e_shoff;
- Elf32_Word e_flags;
- Elf32_Half e_ehsize;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf32_Half e_phentsize;
- Elf32_Half e_phnum;
- Elf32_Half e_shentsize;
- Elf32_Half e_shnum;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf32_Half e_shstrndx;
-} Elf32_Ehdr;
-typedef struct elf64_hdr {
- unsigned char e_ident[16];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf64_Half e_type;
- Elf64_Half e_machine;
- Elf64_Word e_version;
- Elf64_Addr e_entry;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf64_Off e_phoff;
- Elf64_Off e_shoff;
- Elf64_Word e_flags;
- Elf64_Half e_ehsize;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf64_Half e_phentsize;
- Elf64_Half e_phnum;
- Elf64_Half e_shentsize;
- Elf64_Half e_shnum;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf64_Half e_shstrndx;
-} Elf64_Ehdr;
-#define PF_R 0x4
-#define PF_W 0x2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PF_X 0x1
-typedef struct elf32_phdr{
- Elf32_Word p_type;
- Elf32_Off p_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf32_Addr p_vaddr;
- Elf32_Addr p_paddr;
- Elf32_Word p_filesz;
- Elf32_Word p_memsz;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf32_Word p_flags;
- Elf32_Word p_align;
-} Elf32_Phdr;
-typedef struct elf64_phdr {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf64_Word p_type;
- Elf64_Word p_flags;
- Elf64_Off p_offset;
- Elf64_Addr p_vaddr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf64_Addr p_paddr;
- Elf64_Xword p_filesz;
- Elf64_Xword p_memsz;
- Elf64_Xword p_align;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-} Elf64_Phdr;
-#define SHT_NULL 0
-#define SHT_PROGBITS 1
-#define SHT_SYMTAB 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHT_STRTAB 3
-#define SHT_RELA 4
-#define SHT_HASH 5
-#define SHT_DYNAMIC 6
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHT_NOTE 7
-#define SHT_NOBITS 8
-#define SHT_REL 9
-#define SHT_SHLIB 10
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHT_DYNSYM 11
-#define SHT_NUM 12
-#define SHT_LOPROC 0x70000000
-#define SHT_HIPROC 0x7fffffff
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHT_LOUSER 0x80000000
-#define SHT_HIUSER 0xffffffff
-#define SHF_WRITE 0x1
-#define SHF_ALLOC 0x2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHF_EXECINSTR 0x4
-#define SHF_MASKPROC 0xf0000000
-#define SHN_UNDEF 0
-#define SHN_LORESERVE 0xff00
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHN_LOPROC 0xff00
-#define SHN_HIPROC 0xff1f
-#define SHN_ABS 0xfff1
-#define SHN_COMMON 0xfff2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHN_HIRESERVE 0xffff
-typedef struct {
- Elf32_Word sh_name;
- Elf32_Word sh_type;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf32_Word sh_flags;
- Elf32_Addr sh_addr;
- Elf32_Off sh_offset;
- Elf32_Word sh_size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf32_Word sh_link;
- Elf32_Word sh_info;
- Elf32_Word sh_addralign;
- Elf32_Word sh_entsize;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-} Elf32_Shdr;
-typedef struct elf64_shdr {
- Elf64_Word sh_name;
- Elf64_Word sh_type;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf64_Xword sh_flags;
- Elf64_Addr sh_addr;
- Elf64_Off sh_offset;
- Elf64_Xword sh_size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf64_Word sh_link;
- Elf64_Word sh_info;
- Elf64_Xword sh_addralign;
- Elf64_Xword sh_entsize;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-} Elf64_Shdr;
-#define EI_MAG0 0  
-#define EI_MAG1 1
-#define EI_MAG2 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EI_MAG3 3
-#define EI_CLASS 4
-#define EI_DATA 5
-#define EI_VERSION 6
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EI_OSABI 7
-#define EI_PAD 8
-#define ELFMAG0 0x7f  
-#define ELFMAG1 'E'
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ELFMAG2 'L'
-#define ELFMAG3 'F'
-#define ELFMAG "\177ELF"
-#define SELFMAG 4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ELFCLASSNONE 0  
-#define ELFCLASS32 1
-#define ELFCLASS64 2
-#define ELFCLASSNUM 3
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ELFDATANONE 0  
-#define ELFDATA2LSB 1
-#define ELFDATA2MSB 2
-#define EV_NONE 0  
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EV_CURRENT 1
-#define EV_NUM 2
-#define ELFOSABI_NONE 0
-#define ELFOSABI_LINUX 3
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#ifndef ELF_OSABI
-#define ELF_OSABI ELFOSABI_NONE
-#endif
-#define NT_PRSTATUS 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NT_PRFPREG 2
-#define NT_PRPSINFO 3
-#define NT_TASKSTRUCT 4
-#define NT_AUXV 6
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NT_PRXFPREG 0x46e62b7f  
-typedef struct elf32_note {
- Elf32_Word n_namesz;
- Elf32_Word n_descsz;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf32_Word n_type;
-} Elf32_Nhdr;
-typedef struct elf64_note {
- Elf64_Word n_namesz;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- Elf64_Word n_descsz;
- Elf64_Word n_type;
-} Elf64_Nhdr;
-#if ELF_CLASS == ELFCLASS32
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define elfhdr elf32_hdr
-#define elf_phdr elf32_phdr
-#define elf_note elf32_note
-#else
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define elfhdr elf64_hdr
-#define elf_phdr elf64_phdr
-#define elf_note elf64_note
-#endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
diff --git a/libc/kernel/common/linux/ethtool.h b/libc/kernel/common/linux/ethtool.h
index 5dc9921..f12d1a8 100644
--- a/libc/kernel/common/linux/ethtool.h
+++ b/libc/kernel/common/linux/ethtool.h
@@ -192,59 +192,59 @@
  __u64 data;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define ETHTOOL_GSET 0x00000001  
-#define ETHTOOL_SSET 0x00000002  
-#define ETHTOOL_GDRVINFO 0x00000003  
+#define ETHTOOL_GSET 0x00000001
+#define ETHTOOL_SSET 0x00000002
+#define ETHTOOL_GDRVINFO 0x00000003
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETHTOOL_GREGS 0x00000004  
-#define ETHTOOL_GWOL 0x00000005  
-#define ETHTOOL_SWOL 0x00000006  
-#define ETHTOOL_GMSGLVL 0x00000007  
+#define ETHTOOL_GREGS 0x00000004
+#define ETHTOOL_GWOL 0x00000005
+#define ETHTOOL_SWOL 0x00000006
+#define ETHTOOL_GMSGLVL 0x00000007
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETHTOOL_SMSGLVL 0x00000008  
-#define ETHTOOL_NWAY_RST 0x00000009  
-#define ETHTOOL_GLINK 0x0000000a  
-#define ETHTOOL_GEEPROM 0x0000000b  
+#define ETHTOOL_SMSGLVL 0x00000008
+#define ETHTOOL_NWAY_RST 0x00000009
+#define ETHTOOL_GLINK 0x0000000a
+#define ETHTOOL_GEEPROM 0x0000000b
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETHTOOL_SEEPROM 0x0000000c  
-#define ETHTOOL_GCOALESCE 0x0000000e  
-#define ETHTOOL_SCOALESCE 0x0000000f  
-#define ETHTOOL_GRINGPARAM 0x00000010  
+#define ETHTOOL_SEEPROM 0x0000000c
+#define ETHTOOL_GCOALESCE 0x0000000e
+#define ETHTOOL_SCOALESCE 0x0000000f
+#define ETHTOOL_GRINGPARAM 0x00000010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETHTOOL_SRINGPARAM 0x00000011  
-#define ETHTOOL_GPAUSEPARAM 0x00000012  
-#define ETHTOOL_SPAUSEPARAM 0x00000013  
-#define ETHTOOL_GRXCSUM 0x00000014  
+#define ETHTOOL_SRINGPARAM 0x00000011
+#define ETHTOOL_GPAUSEPARAM 0x00000012
+#define ETHTOOL_SPAUSEPARAM 0x00000013
+#define ETHTOOL_GRXCSUM 0x00000014
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETHTOOL_SRXCSUM 0x00000015  
-#define ETHTOOL_GTXCSUM 0x00000016  
-#define ETHTOOL_STXCSUM 0x00000017  
-#define ETHTOOL_GSG 0x00000018  
+#define ETHTOOL_SRXCSUM 0x00000015
+#define ETHTOOL_GTXCSUM 0x00000016
+#define ETHTOOL_STXCSUM 0x00000017
+#define ETHTOOL_GSG 0x00000018
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETHTOOL_SSG 0x00000019  
-#define ETHTOOL_TEST 0x0000001a  
-#define ETHTOOL_GSTRINGS 0x0000001b  
-#define ETHTOOL_PHYS_ID 0x0000001c  
+#define ETHTOOL_SSG 0x00000019
+#define ETHTOOL_TEST 0x0000001a
+#define ETHTOOL_GSTRINGS 0x0000001b
+#define ETHTOOL_PHYS_ID 0x0000001c
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETHTOOL_GSTATS 0x0000001d  
-#define ETHTOOL_GTSO 0x0000001e  
-#define ETHTOOL_STSO 0x0000001f  
-#define ETHTOOL_GPERMADDR 0x00000020  
+#define ETHTOOL_GSTATS 0x0000001d
+#define ETHTOOL_GTSO 0x0000001e
+#define ETHTOOL_STSO 0x0000001f
+#define ETHTOOL_GPERMADDR 0x00000020
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETHTOOL_GUFO 0x00000021  
-#define ETHTOOL_SUFO 0x00000022  
-#define ETHTOOL_GGSO 0x00000023  
-#define ETHTOOL_SGSO 0x00000024  
+#define ETHTOOL_GUFO 0x00000021
+#define ETHTOOL_SUFO 0x00000022
+#define ETHTOOL_GGSO 0x00000023
+#define ETHTOOL_SGSO 0x00000024
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETHTOOL_GFLAGS 0x00000025  
-#define ETHTOOL_SFLAGS 0x00000026  
-#define ETHTOOL_GPFLAGS 0x00000027  
-#define ETHTOOL_SPFLAGS 0x00000028  
+#define ETHTOOL_GFLAGS 0x00000025
+#define ETHTOOL_SFLAGS 0x00000026
+#define ETHTOOL_GPFLAGS 0x00000027
+#define ETHTOOL_SPFLAGS 0x00000028
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETHTOOL_GRXFH 0x00000029  
-#define ETHTOOL_SRXFH 0x0000002a  
-#define ETHTOOL_GGRO 0x0000002b  
-#define ETHTOOL_SGRO 0x0000002c  
+#define ETHTOOL_GRXFH 0x00000029
+#define ETHTOOL_SRXFH 0x0000002a
+#define ETHTOOL_GGRO 0x0000002b
+#define ETHTOOL_SGRO 0x0000002c
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SPARC_ETH_GSET ETHTOOL_GSET
 #define SPARC_ETH_SSET ETHTOOL_SSET
@@ -319,7 +319,7 @@
 #define WAKE_BCAST (1 << 3)
 #define WAKE_ARP (1 << 4)
 #define WAKE_MAGIC (1 << 5)
-#define WAKE_MAGICSECURE (1 << 6)  
+#define WAKE_MAGICSECURE (1 << 6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCP_V4_FLOW 0x01
 #define UDP_V4_FLOW 0x02
@@ -338,8 +338,8 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RXH_IP_SRC (1 << 4)
 #define RXH_IP_DST (1 << 5)
-#define RXH_L4_B_0_1 (1 << 6)  
-#define RXH_L4_B_2_3 (1 << 7)  
+#define RXH_L4_B_0_1 (1 << 6)
+#define RXH_L4_B_2_3 (1 << 7)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RXH_DISCARD (1 << 31)
 #endif
diff --git a/libc/kernel/common/linux/ext2_fs.h b/libc/kernel/common/linux/ext2_fs.h
index 3335580..e8c5ba9 100644
--- a/libc/kernel/common/linux/ext2_fs.h
+++ b/libc/kernel/common/linux/ext2_fs.h
@@ -29,14 +29,14 @@
 #ifdef EXT2FS_DEBUG
 #define ext2_debug(f, a...) {   printk ("EXT2-fs DEBUG (%s, %d): %s:",   __FILE__, __LINE__, __FUNCTION__);   printk (f, ## a);   }
 #else
-#define ext2_debug(f, a...)  
+#define ext2_debug(f, a...)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-#define EXT2_BAD_INO 1  
-#define EXT2_ROOT_INO 2  
-#define EXT2_BOOT_LOADER_INO 5  
+#define EXT2_BAD_INO 1
+#define EXT2_ROOT_INO 2
+#define EXT2_BOOT_LOADER_INO 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT2_UNDEL_DIR_INO 6  
+#define EXT2_UNDEL_DIR_INO 6
 #define EXT2_GOOD_OLD_FIRST_INO 11
 #define EXT2_SUPER_MAGIC 0xEF53
 #define EXT2_SB(sb) (sb)
@@ -82,33 +82,33 @@
 #define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
-#define EXT2_SECRM_FL 0x00000001  
-#define EXT2_UNRM_FL 0x00000002  
-#define EXT2_COMPR_FL 0x00000004  
+#define EXT2_SECRM_FL 0x00000001
+#define EXT2_UNRM_FL 0x00000002
+#define EXT2_COMPR_FL 0x00000004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT2_SYNC_FL 0x00000008  
-#define EXT2_IMMUTABLE_FL 0x00000010  
-#define EXT2_APPEND_FL 0x00000020  
-#define EXT2_NODUMP_FL 0x00000040  
+#define EXT2_SYNC_FL 0x00000008
+#define EXT2_IMMUTABLE_FL 0x00000010
+#define EXT2_APPEND_FL 0x00000020
+#define EXT2_NODUMP_FL 0x00000040
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT2_NOATIME_FL 0x00000080  
+#define EXT2_NOATIME_FL 0x00000080
 #define EXT2_DIRTY_FL 0x00000100
-#define EXT2_COMPRBLK_FL 0x00000200  
-#define EXT2_NOCOMP_FL 0x00000400  
+#define EXT2_COMPRBLK_FL 0x00000200
+#define EXT2_NOCOMP_FL 0x00000400
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT2_ECOMPR_FL 0x00000800  
-#define EXT2_BTREE_FL 0x00001000  
-#define EXT2_INDEX_FL 0x00001000  
-#define EXT2_IMAGIC_FL 0x00002000  
+#define EXT2_ECOMPR_FL 0x00000800
+#define EXT2_BTREE_FL 0x00001000
+#define EXT2_INDEX_FL 0x00001000
+#define EXT2_IMAGIC_FL 0x00002000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT2_JOURNAL_DATA_FL 0x00004000  
-#define EXT2_NOTAIL_FL 0x00008000  
-#define EXT2_DIRSYNC_FL 0x00010000  
-#define EXT2_TOPDIR_FL 0x00020000  
+#define EXT2_JOURNAL_DATA_FL 0x00004000
+#define EXT2_NOTAIL_FL 0x00008000
+#define EXT2_DIRSYNC_FL 0x00010000
+#define EXT2_TOPDIR_FL 0x00020000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT2_RESERVED_FL 0x80000000  
-#define EXT2_FL_USER_VISIBLE 0x0003DFFF  
-#define EXT2_FL_USER_MODIFIABLE 0x000380FF  
+#define EXT2_RESERVED_FL 0x80000000
+#define EXT2_FL_USER_VISIBLE 0x0003DFFF
+#define EXT2_FL_USER_MODIFIABLE 0x000380FF
 #define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
@@ -212,37 +212,37 @@
 #define i_reserved2 osd2.masix2.m_i_reserved2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-#define EXT2_VALID_FS 0x0001  
-#define EXT2_ERROR_FS 0x0002  
-#define EXT2_MOUNT_CHECK 0x000001  
+#define EXT2_VALID_FS 0x0001
+#define EXT2_ERROR_FS 0x0002
+#define EXT2_MOUNT_CHECK 0x000001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT2_MOUNT_OLDALLOC 0x000002  
-#define EXT2_MOUNT_GRPID 0x000004  
-#define EXT2_MOUNT_DEBUG 0x000008  
-#define EXT2_MOUNT_ERRORS_CONT 0x000010  
+#define EXT2_MOUNT_OLDALLOC 0x000002
+#define EXT2_MOUNT_GRPID 0x000004
+#define EXT2_MOUNT_DEBUG 0x000008
+#define EXT2_MOUNT_ERRORS_CONT 0x000010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT2_MOUNT_ERRORS_RO 0x000020  
-#define EXT2_MOUNT_ERRORS_PANIC 0x000040  
-#define EXT2_MOUNT_MINIX_DF 0x000080  
-#define EXT2_MOUNT_NOBH 0x000100  
+#define EXT2_MOUNT_ERRORS_RO 0x000020
+#define EXT2_MOUNT_ERRORS_PANIC 0x000040
+#define EXT2_MOUNT_MINIX_DF 0x000080
+#define EXT2_MOUNT_NOBH 0x000100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT2_MOUNT_NO_UID32 0x000200  
-#define EXT2_MOUNT_XATTR_USER 0x004000  
-#define EXT2_MOUNT_POSIX_ACL 0x008000  
-#define EXT2_MOUNT_XIP 0x010000  
+#define EXT2_MOUNT_NO_UID32 0x000200
+#define EXT2_MOUNT_XATTR_USER 0x004000
+#define EXT2_MOUNT_POSIX_ACL 0x008000
+#define EXT2_MOUNT_XIP 0x010000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT2_MOUNT_USRQUOTA 0x020000  
-#define EXT2_MOUNT_GRPQUOTA 0x040000  
+#define EXT2_MOUNT_USRQUOTA 0x020000
+#define EXT2_MOUNT_GRPQUOTA 0x040000
 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
 #define set_opt(o, opt) o |= EXT2_MOUNT_##opt
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt &   EXT2_MOUNT_##opt)
-#define EXT2_DFL_MAX_MNT_COUNT 20  
-#define EXT2_DFL_CHECKINTERVAL 0  
-#define EXT2_ERRORS_CONTINUE 1  
+#define EXT2_DFL_MAX_MNT_COUNT 20
+#define EXT2_DFL_CHECKINTERVAL 0
+#define EXT2_ERRORS_CONTINUE 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT2_ERRORS_RO 2  
-#define EXT2_ERRORS_PANIC 3  
+#define EXT2_ERRORS_RO 2
+#define EXT2_ERRORS_PANIC 3
 #define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
 struct ext2_super_block {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -314,9 +314,9 @@
 #define EXT2_OS_MASIX 2
 #define EXT2_OS_FREEBSD 3
 #define EXT2_OS_LITES 4
-#define EXT2_GOOD_OLD_REV 0  
+#define EXT2_GOOD_OLD_REV 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT2_DYNAMIC_REV 1  
+#define EXT2_DYNAMIC_REV 1
 #define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV
 #define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV
 #define EXT2_GOOD_OLD_INODE_SIZE 128
@@ -368,7 +368,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EXT2_DEFM_ACL 0x0008
 #define EXT2_DEFM_UID16 0x0010
-#define EXT3_DEFM_JMODE 0x0060 
+#define EXT3_DEFM_JMODE 0x0060
 #define EXT3_DEFM_JMODE_DATA 0x0020
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EXT3_DEFM_JMODE_ORDERED 0x0040
diff --git a/libc/kernel/common/linux/ext3_fs.h b/libc/kernel/common/linux/ext3_fs.h
index 9a70d4a..69044fd 100644
--- a/libc/kernel/common/linux/ext3_fs.h
+++ b/libc/kernel/common/linux/ext3_fs.h
@@ -32,13 +32,13 @@
 #define ext3_debug(f, a...) do {} while (0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-#define EXT3_BAD_INO 1  
-#define EXT3_ROOT_INO 2  
-#define EXT3_BOOT_LOADER_INO 5  
+#define EXT3_BAD_INO 1
+#define EXT3_ROOT_INO 2
+#define EXT3_BOOT_LOADER_INO 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT3_UNDEL_DIR_INO 6  
-#define EXT3_RESIZE_INO 7  
-#define EXT3_JOURNAL_INO 8  
+#define EXT3_UNDEL_DIR_INO 6
+#define EXT3_RESIZE_INO 7
+#define EXT3_JOURNAL_INO 8
 #define EXT3_GOOD_OLD_FIRST_INO 11
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EXT3_SUPER_MAGIC 0xEF53
@@ -83,36 +83,36 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EXT3_TIND_BLOCK (EXT3_DIND_BLOCK + 1)
 #define EXT3_N_BLOCKS (EXT3_TIND_BLOCK + 1)
-#define EXT3_SECRM_FL 0x00000001  
-#define EXT3_UNRM_FL 0x00000002  
+#define EXT3_SECRM_FL 0x00000001
+#define EXT3_UNRM_FL 0x00000002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT3_COMPR_FL 0x00000004  
-#define EXT3_SYNC_FL 0x00000008  
-#define EXT3_IMMUTABLE_FL 0x00000010  
-#define EXT3_APPEND_FL 0x00000020  
+#define EXT3_COMPR_FL 0x00000004
+#define EXT3_SYNC_FL 0x00000008
+#define EXT3_IMMUTABLE_FL 0x00000010
+#define EXT3_APPEND_FL 0x00000020
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT3_NODUMP_FL 0x00000040  
-#define EXT3_NOATIME_FL 0x00000080  
+#define EXT3_NODUMP_FL 0x00000040
+#define EXT3_NOATIME_FL 0x00000080
 #define EXT3_DIRTY_FL 0x00000100
-#define EXT3_COMPRBLK_FL 0x00000200  
+#define EXT3_COMPRBLK_FL 0x00000200
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT3_NOCOMPR_FL 0x00000400  
-#define EXT3_ECOMPR_FL 0x00000800  
-#define EXT3_INDEX_FL 0x00001000  
-#define EXT3_IMAGIC_FL 0x00002000  
+#define EXT3_NOCOMPR_FL 0x00000400
+#define EXT3_ECOMPR_FL 0x00000800
+#define EXT3_INDEX_FL 0x00001000
+#define EXT3_IMAGIC_FL 0x00002000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT3_JOURNAL_DATA_FL 0x00004000  
-#define EXT3_NOTAIL_FL 0x00008000  
-#define EXT3_DIRSYNC_FL 0x00010000  
-#define EXT3_TOPDIR_FL 0x00020000  
+#define EXT3_JOURNAL_DATA_FL 0x00004000
+#define EXT3_NOTAIL_FL 0x00008000
+#define EXT3_DIRSYNC_FL 0x00010000
+#define EXT3_TOPDIR_FL 0x00020000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT3_RESERVED_FL 0x80000000  
-#define EXT3_FL_USER_VISIBLE 0x0003DFFF  
-#define EXT3_FL_USER_MODIFIABLE 0x000380FF  
-#define EXT3_STATE_JDATA 0x00000001  
+#define EXT3_RESERVED_FL 0x80000000
+#define EXT3_FL_USER_VISIBLE 0x0003DFFF
+#define EXT3_FL_USER_MODIFIABLE 0x000380FF
+#define EXT3_STATE_JDATA 0x00000001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT3_STATE_NEW 0x00000002  
-#define EXT3_STATE_XATTR 0x00000004  
+#define EXT3_STATE_NEW 0x00000002
+#define EXT3_STATE_XATTR 0x00000004
 struct ext3_new_group_input {
  __u32 group;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -254,40 +254,40 @@
 #define i_fsize osd2.masix2.m_i_fsize
 #define i_reserved2 osd2.masix2.m_i_reserved2
 #endif
-#define EXT3_VALID_FS 0x0001  
+#define EXT3_VALID_FS 0x0001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT3_ERROR_FS 0x0002  
-#define EXT3_ORPHAN_FS 0x0004  
-#define EXT3_MOUNT_CHECK 0x00001  
-#define EXT3_MOUNT_OLDALLOC 0x00002  
+#define EXT3_ERROR_FS 0x0002
+#define EXT3_ORPHAN_FS 0x0004
+#define EXT3_MOUNT_CHECK 0x00001
+#define EXT3_MOUNT_OLDALLOC 0x00002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT3_MOUNT_GRPID 0x00004  
-#define EXT3_MOUNT_DEBUG 0x00008  
-#define EXT3_MOUNT_ERRORS_CONT 0x00010  
-#define EXT3_MOUNT_ERRORS_RO 0x00020  
+#define EXT3_MOUNT_GRPID 0x00004
+#define EXT3_MOUNT_DEBUG 0x00008
+#define EXT3_MOUNT_ERRORS_CONT 0x00010
+#define EXT3_MOUNT_ERRORS_RO 0x00020
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT3_MOUNT_ERRORS_PANIC 0x00040  
-#define EXT3_MOUNT_MINIX_DF 0x00080  
-#define EXT3_MOUNT_NOLOAD 0x00100  
-#define EXT3_MOUNT_ABORT 0x00200  
+#define EXT3_MOUNT_ERRORS_PANIC 0x00040
+#define EXT3_MOUNT_MINIX_DF 0x00080
+#define EXT3_MOUNT_NOLOAD 0x00100
+#define EXT3_MOUNT_ABORT 0x00200
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT3_MOUNT_DATA_FLAGS 0x00C00  
-#define EXT3_MOUNT_JOURNAL_DATA 0x00400  
-#define EXT3_MOUNT_ORDERED_DATA 0x00800  
-#define EXT3_MOUNT_WRITEBACK_DATA 0x00C00  
+#define EXT3_MOUNT_DATA_FLAGS 0x00C00
+#define EXT3_MOUNT_JOURNAL_DATA 0x00400
+#define EXT3_MOUNT_ORDERED_DATA 0x00800
+#define EXT3_MOUNT_WRITEBACK_DATA 0x00C00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT3_MOUNT_UPDATE_JOURNAL 0x01000  
-#define EXT3_MOUNT_NO_UID32 0x02000  
-#define EXT3_MOUNT_XATTR_USER 0x04000  
-#define EXT3_MOUNT_POSIX_ACL 0x08000  
+#define EXT3_MOUNT_UPDATE_JOURNAL 0x01000
+#define EXT3_MOUNT_NO_UID32 0x02000
+#define EXT3_MOUNT_XATTR_USER 0x04000
+#define EXT3_MOUNT_POSIX_ACL 0x08000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT3_MOUNT_RESERVATION 0x10000  
-#define EXT3_MOUNT_BARRIER 0x20000  
-#define EXT3_MOUNT_NOBH 0x40000  
-#define EXT3_MOUNT_QUOTA 0x80000  
+#define EXT3_MOUNT_RESERVATION 0x10000
+#define EXT3_MOUNT_BARRIER 0x20000
+#define EXT3_MOUNT_NOBH 0x40000
+#define EXT3_MOUNT_QUOTA 0x80000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT3_MOUNT_USRQUOTA 0x100000  
-#define EXT3_MOUNT_GRPQUOTA 0x200000  
+#define EXT3_MOUNT_USRQUOTA 0x100000
+#define EXT3_MOUNT_GRPQUOTA 0x200000
 #ifndef _LINUX_EXT2_FS_H
 #define clear_opt(o, opt) o &= ~EXT3_MOUNT_##opt
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -308,12 +308,12 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ext3_find_first_zero_bit ext2_find_first_zero_bit
 #define ext3_find_next_zero_bit ext2_find_next_zero_bit
-#define EXT3_DFL_MAX_MNT_COUNT 20  
-#define EXT3_DFL_CHECKINTERVAL 0  
+#define EXT3_DFL_MAX_MNT_COUNT 20
+#define EXT3_DFL_CHECKINTERVAL 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT3_ERRORS_CONTINUE 1  
-#define EXT3_ERRORS_RO 2  
-#define EXT3_ERRORS_PANIC 3  
+#define EXT3_ERRORS_CONTINUE 1
+#define EXT3_ERRORS_RO 2
+#define EXT3_ERRORS_PANIC 3
 #define EXT3_ERRORS_DEFAULT EXT3_ERRORS_CONTINUE
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ext3_super_block {
@@ -388,8 +388,8 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EXT3_OS_FREEBSD 3
 #define EXT3_OS_LITES 4
-#define EXT3_GOOD_OLD_REV 0  
-#define EXT3_DYNAMIC_REV 1  
+#define EXT3_GOOD_OLD_REV 0
+#define EXT3_DYNAMIC_REV 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EXT3_CURRENT_REV EXT3_GOOD_OLD_REV
 #define EXT3_MAX_SUPP_REV EXT3_DYNAMIC_REV
@@ -419,9 +419,9 @@
 #define EXT3_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
 #define EXT3_FEATURE_INCOMPAT_COMPRESSION 0x0001
 #define EXT3_FEATURE_INCOMPAT_FILETYPE 0x0002
-#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004  
+#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008  
+#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
 #define EXT3_FEATURE_INCOMPAT_META_BG 0x0010
 #define EXT3_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
 #define EXT3_FEATURE_INCOMPAT_SUPP (EXT3_FEATURE_INCOMPAT_FILETYPE|   EXT3_FEATURE_INCOMPAT_RECOVER|   EXT3_FEATURE_INCOMPAT_META_BG)
diff --git a/libc/kernel/common/linux/fadvise.h b/libc/kernel/common/linux/fadvise.h
index efa9e55..3cfa598 100644
--- a/libc/kernel/common/linux/fadvise.h
+++ b/libc/kernel/common/linux/fadvise.h
@@ -18,18 +18,18 @@
  ****************************************************************************/
 #ifndef FADVISE_H_INCLUDED
 #define FADVISE_H_INCLUDED
-#define POSIX_FADV_NORMAL 0  
-#define POSIX_FADV_RANDOM 1  
+#define POSIX_FADV_NORMAL 0
+#define POSIX_FADV_RANDOM 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define POSIX_FADV_SEQUENTIAL 2  
-#define POSIX_FADV_WILLNEED 3  
+#define POSIX_FADV_SEQUENTIAL 2
+#define POSIX_FADV_WILLNEED 3
 #ifdef __s390x__
-#define POSIX_FADV_DONTNEED 6  
+#define POSIX_FADV_DONTNEED 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define POSIX_FADV_NOREUSE 7  
+#define POSIX_FADV_NOREUSE 7
 #else
-#define POSIX_FADV_DONTNEED 4  
-#define POSIX_FADV_NOREUSE 5  
+#define POSIX_FADV_DONTNEED 4
+#define POSIX_FADV_NOREUSE 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #endif
diff --git a/libc/kernel/common/linux/fb.h b/libc/kernel/common/linux/fb.h
index 48eec81..c3676b6 100755
--- a/libc/kernel/common/linux/fb.h
+++ b/libc/kernel/common/linux/fb.h
@@ -21,7 +21,7 @@
 #include <linux/types.h>
 #include <linux/i2c.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_MAX 32  
+#define FB_MAX 32
 #define FBIOGET_VSCREENINFO 0x4600
 #define FBIOPUT_VSCREENINFO 0x4601
 #define FBIOGET_FSCREENINFO 0x4602
@@ -33,7 +33,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FBIOGET_CON2FBMAP 0x460F
 #define FBIOPUT_CON2FBMAP 0x4610
-#define FBIOBLANK 0x4611  
+#define FBIOBLANK 0x4611
 #define FBIOGET_VBLANK _IOR('F', 0x12, struct fb_vblank)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FBIO_ALLOC 0x4613
@@ -44,144 +44,144 @@
 #define FBIOPUT_MODEINFO 0x4617
 #define FBIOGET_DISPINFO 0x4618
 #define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
-#define FB_TYPE_PACKED_PIXELS 0  
+#define FB_TYPE_PACKED_PIXELS 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_TYPE_PLANES 1  
-#define FB_TYPE_INTERLEAVED_PLANES 2  
-#define FB_TYPE_TEXT 3  
-#define FB_TYPE_VGA_PLANES 4  
+#define FB_TYPE_PLANES 1
+#define FB_TYPE_INTERLEAVED_PLANES 2
+#define FB_TYPE_TEXT 3
+#define FB_TYPE_VGA_PLANES 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_TYPE_FOURCC 5  
-#define FB_AUX_TEXT_MDA 0  
-#define FB_AUX_TEXT_CGA 1  
-#define FB_AUX_TEXT_S3_MMIO 2  
+#define FB_TYPE_FOURCC 5
+#define FB_AUX_TEXT_MDA 0
+#define FB_AUX_TEXT_CGA 1
+#define FB_AUX_TEXT_S3_MMIO 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_AUX_TEXT_MGA_STEP16 3  
-#define FB_AUX_TEXT_MGA_STEP8 4  
-#define FB_AUX_TEXT_SVGA_GROUP 8  
-#define FB_AUX_TEXT_SVGA_MASK 7  
+#define FB_AUX_TEXT_MGA_STEP16 3
+#define FB_AUX_TEXT_MGA_STEP8 4
+#define FB_AUX_TEXT_SVGA_GROUP 8
+#define FB_AUX_TEXT_SVGA_MASK 7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_AUX_TEXT_SVGA_STEP2 8  
-#define FB_AUX_TEXT_SVGA_STEP4 9  
-#define FB_AUX_TEXT_SVGA_STEP8 10  
-#define FB_AUX_TEXT_SVGA_STEP16 11  
+#define FB_AUX_TEXT_SVGA_STEP2 8
+#define FB_AUX_TEXT_SVGA_STEP4 9
+#define FB_AUX_TEXT_SVGA_STEP8 10
+#define FB_AUX_TEXT_SVGA_STEP16 11
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_AUX_TEXT_SVGA_LAST 15  
-#define FB_AUX_VGA_PLANES_VGA4 0  
-#define FB_AUX_VGA_PLANES_CFB4 1  
-#define FB_AUX_VGA_PLANES_CFB8 2  
+#define FB_AUX_TEXT_SVGA_LAST 15
+#define FB_AUX_VGA_PLANES_VGA4 0
+#define FB_AUX_VGA_PLANES_CFB4 1
+#define FB_AUX_VGA_PLANES_CFB8 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_VISUAL_MONO01 0  
-#define FB_VISUAL_MONO10 1  
-#define FB_VISUAL_TRUECOLOR 2  
-#define FB_VISUAL_PSEUDOCOLOR 3  
+#define FB_VISUAL_MONO01 0
+#define FB_VISUAL_MONO10 1
+#define FB_VISUAL_TRUECOLOR 2
+#define FB_VISUAL_PSEUDOCOLOR 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_VISUAL_DIRECTCOLOR 4  
-#define FB_VISUAL_STATIC_PSEUDOCOLOR 5  
-#define FB_VISUAL_FOURCC 6  
-#define FB_ACCEL_NONE 0  
+#define FB_VISUAL_DIRECTCOLOR 4
+#define FB_VISUAL_STATIC_PSEUDOCOLOR 5
+#define FB_VISUAL_FOURCC 6
+#define FB_ACCEL_NONE 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_ACCEL_ATARIBLITT 1  
-#define FB_ACCEL_AMIGABLITT 2  
-#define FB_ACCEL_S3_TRIO64 3  
-#define FB_ACCEL_NCR_77C32BLT 4  
+#define FB_ACCEL_ATARIBLITT 1
+#define FB_ACCEL_AMIGABLITT 2
+#define FB_ACCEL_S3_TRIO64 3
+#define FB_ACCEL_NCR_77C32BLT 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_ACCEL_S3_VIRGE 5  
-#define FB_ACCEL_ATI_MACH64GX 6  
-#define FB_ACCEL_DEC_TGA 7  
-#define FB_ACCEL_ATI_MACH64CT 8  
+#define FB_ACCEL_S3_VIRGE 5
+#define FB_ACCEL_ATI_MACH64GX 6
+#define FB_ACCEL_DEC_TGA 7
+#define FB_ACCEL_ATI_MACH64CT 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_ACCEL_ATI_MACH64VT 9  
-#define FB_ACCEL_ATI_MACH64GT 10  
-#define FB_ACCEL_SUN_CREATOR 11  
-#define FB_ACCEL_SUN_CGSIX 12  
+#define FB_ACCEL_ATI_MACH64VT 9
+#define FB_ACCEL_ATI_MACH64GT 10
+#define FB_ACCEL_SUN_CREATOR 11
+#define FB_ACCEL_SUN_CGSIX 12
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_ACCEL_SUN_LEO 13  
-#define FB_ACCEL_IMS_TWINTURBO 14  
-#define FB_ACCEL_3DLABS_PERMEDIA2 15  
-#define FB_ACCEL_MATROX_MGA2064W 16  
+#define FB_ACCEL_SUN_LEO 13
+#define FB_ACCEL_IMS_TWINTURBO 14
+#define FB_ACCEL_3DLABS_PERMEDIA2 15
+#define FB_ACCEL_MATROX_MGA2064W 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_ACCEL_MATROX_MGA1064SG 17  
-#define FB_ACCEL_MATROX_MGA2164W 18  
-#define FB_ACCEL_MATROX_MGA2164W_AGP 19  
-#define FB_ACCEL_MATROX_MGAG100 20  
+#define FB_ACCEL_MATROX_MGA1064SG 17
+#define FB_ACCEL_MATROX_MGA2164W 18
+#define FB_ACCEL_MATROX_MGA2164W_AGP 19
+#define FB_ACCEL_MATROX_MGAG100 20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_ACCEL_MATROX_MGAG200 21  
-#define FB_ACCEL_SUN_CG14 22  
-#define FB_ACCEL_SUN_BWTWO 23  
-#define FB_ACCEL_SUN_CGTHREE 24  
+#define FB_ACCEL_MATROX_MGAG200 21
+#define FB_ACCEL_SUN_CG14 22
+#define FB_ACCEL_SUN_BWTWO 23
+#define FB_ACCEL_SUN_CGTHREE 24
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_ACCEL_SUN_TCX 25  
-#define FB_ACCEL_MATROX_MGAG400 26  
-#define FB_ACCEL_NV3 27  
-#define FB_ACCEL_NV4 28  
+#define FB_ACCEL_SUN_TCX 25
+#define FB_ACCEL_MATROX_MGAG400 26
+#define FB_ACCEL_NV3 27
+#define FB_ACCEL_NV4 28
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_ACCEL_NV5 29  
-#define FB_ACCEL_CT_6555x 30  
-#define FB_ACCEL_3DFX_BANSHEE 31  
-#define FB_ACCEL_ATI_RAGE128 32  
+#define FB_ACCEL_NV5 29
+#define FB_ACCEL_CT_6555x 30
+#define FB_ACCEL_3DFX_BANSHEE 31
+#define FB_ACCEL_ATI_RAGE128 32
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_ACCEL_IGS_CYBER2000 33  
-#define FB_ACCEL_IGS_CYBER2010 34  
-#define FB_ACCEL_IGS_CYBER5000 35  
-#define FB_ACCEL_SIS_GLAMOUR 36  
+#define FB_ACCEL_IGS_CYBER2000 33
+#define FB_ACCEL_IGS_CYBER2010 34
+#define FB_ACCEL_IGS_CYBER5000 35
+#define FB_ACCEL_SIS_GLAMOUR 36
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_ACCEL_3DLABS_PERMEDIA3 37  
-#define FB_ACCEL_ATI_RADEON 38  
-#define FB_ACCEL_I810 39  
-#define FB_ACCEL_SIS_GLAMOUR_2 40  
+#define FB_ACCEL_3DLABS_PERMEDIA3 37
+#define FB_ACCEL_ATI_RADEON 38
+#define FB_ACCEL_I810 39
+#define FB_ACCEL_SIS_GLAMOUR_2 40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_ACCEL_SIS_XABRE 41  
-#define FB_ACCEL_I830 42  
-#define FB_ACCEL_NV_10 43  
-#define FB_ACCEL_NV_20 44  
+#define FB_ACCEL_SIS_XABRE 41
+#define FB_ACCEL_I830 42
+#define FB_ACCEL_NV_10 43
+#define FB_ACCEL_NV_20 44
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_ACCEL_NV_30 45  
-#define FB_ACCEL_NV_40 46  
-#define FB_ACCEL_XGI_VOLARI_V 47  
-#define FB_ACCEL_XGI_VOLARI_Z 48  
+#define FB_ACCEL_NV_30 45
+#define FB_ACCEL_NV_40 46
+#define FB_ACCEL_XGI_VOLARI_V 47
+#define FB_ACCEL_XGI_VOLARI_Z 48
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_ACCEL_OMAP1610 49  
-#define FB_ACCEL_TRIDENT_TGUI 50  
-#define FB_ACCEL_TRIDENT_3DIMAGE 51  
-#define FB_ACCEL_TRIDENT_BLADE3D 52  
+#define FB_ACCEL_OMAP1610 49
+#define FB_ACCEL_TRIDENT_TGUI 50
+#define FB_ACCEL_TRIDENT_3DIMAGE 51
+#define FB_ACCEL_TRIDENT_BLADE3D 52
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_ACCEL_TRIDENT_BLADEXP 53  
-#define FB_ACCEL_CIRRUS_ALPINE 53  
-#define FB_ACCEL_NEOMAGIC_NM2070 90  
-#define FB_ACCEL_NEOMAGIC_NM2090 91  
+#define FB_ACCEL_TRIDENT_BLADEXP 53
+#define FB_ACCEL_CIRRUS_ALPINE 53
+#define FB_ACCEL_NEOMAGIC_NM2070 90
+#define FB_ACCEL_NEOMAGIC_NM2090 91
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_ACCEL_NEOMAGIC_NM2093 92  
-#define FB_ACCEL_NEOMAGIC_NM2097 93  
-#define FB_ACCEL_NEOMAGIC_NM2160 94  
-#define FB_ACCEL_NEOMAGIC_NM2200 95  
+#define FB_ACCEL_NEOMAGIC_NM2093 92
+#define FB_ACCEL_NEOMAGIC_NM2097 93
+#define FB_ACCEL_NEOMAGIC_NM2160 94
+#define FB_ACCEL_NEOMAGIC_NM2200 95
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_ACCEL_NEOMAGIC_NM2230 96  
-#define FB_ACCEL_NEOMAGIC_NM2360 97  
-#define FB_ACCEL_NEOMAGIC_NM2380 98  
-#define FB_ACCEL_PXA3XX 99  
+#define FB_ACCEL_NEOMAGIC_NM2230 96
+#define FB_ACCEL_NEOMAGIC_NM2360 97
+#define FB_ACCEL_NEOMAGIC_NM2380 98
+#define FB_ACCEL_PXA3XX 99
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_ACCEL_SAVAGE4 0x80  
-#define FB_ACCEL_SAVAGE3D 0x81  
-#define FB_ACCEL_SAVAGE3D_MV 0x82  
-#define FB_ACCEL_SAVAGE2000 0x83  
+#define FB_ACCEL_SAVAGE4 0x80
+#define FB_ACCEL_SAVAGE3D 0x81
+#define FB_ACCEL_SAVAGE3D_MV 0x82
+#define FB_ACCEL_SAVAGE2000 0x83
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_ACCEL_SAVAGE_MX_MV 0x84  
-#define FB_ACCEL_SAVAGE_MX 0x85  
-#define FB_ACCEL_SAVAGE_IX_MV 0x86  
-#define FB_ACCEL_SAVAGE_IX 0x87  
+#define FB_ACCEL_SAVAGE_MX_MV 0x84
+#define FB_ACCEL_SAVAGE_MX 0x85
+#define FB_ACCEL_SAVAGE_IX_MV 0x86
+#define FB_ACCEL_SAVAGE_IX 0x87
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_ACCEL_PROSAVAGE_PM 0x88  
-#define FB_ACCEL_PROSAVAGE_KM 0x89  
-#define FB_ACCEL_S3TWISTER_P 0x8a  
-#define FB_ACCEL_S3TWISTER_K 0x8b  
+#define FB_ACCEL_PROSAVAGE_PM 0x88
+#define FB_ACCEL_PROSAVAGE_KM 0x89
+#define FB_ACCEL_S3TWISTER_P 0x8a
+#define FB_ACCEL_S3TWISTER_K 0x8b
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_ACCEL_SUPERSAVAGE 0x8c  
-#define FB_ACCEL_PROSAVAGE_DDR 0x8d  
-#define FB_ACCEL_PROSAVAGE_DDRK 0x8e  
-#define FB_ACCEL_PUV3_UNIGFX 0xa0  
+#define FB_ACCEL_SUPERSAVAGE 0x8c
+#define FB_ACCEL_PROSAVAGE_DDR 0x8d
+#define FB_ACCEL_PROSAVAGE_DDRK 0x8e
+#define FB_ACCEL_PUV3_UNIGFX 0xa0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_CAP_FOURCC 1  
+#define FB_CAP_FOURCC 1
 struct fb_fix_screeninfo {
  char id[16];
  unsigned long smem_start;
@@ -209,39 +209,39 @@
  __u32 length;
  __u32 msb_right;
 };
-#define FB_NONSTD_HAM 1  
+#define FB_NONSTD_HAM 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_NONSTD_REV_PIX_IN_B 2  
-#define FB_ACTIVATE_NOW 0  
-#define FB_ACTIVATE_NXTOPEN 1  
-#define FB_ACTIVATE_TEST 2  
+#define FB_NONSTD_REV_PIX_IN_B 2
+#define FB_ACTIVATE_NOW 0
+#define FB_ACTIVATE_NXTOPEN 1
+#define FB_ACTIVATE_TEST 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FB_ACTIVATE_MASK 15
-#define FB_ACTIVATE_VBL 16  
-#define FB_CHANGE_CMAP_VBL 32  
-#define FB_ACTIVATE_ALL 64  
+#define FB_ACTIVATE_VBL 16
+#define FB_CHANGE_CMAP_VBL 32
+#define FB_ACTIVATE_ALL 64
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_ACTIVATE_FORCE 128  
-#define FB_ACTIVATE_INV_MODE 256  
-#define FB_ACCELF_TEXT 1  
-#define FB_SYNC_HOR_HIGH_ACT 1  
+#define FB_ACTIVATE_FORCE 128
+#define FB_ACTIVATE_INV_MODE 256
+#define FB_ACCELF_TEXT 1
+#define FB_SYNC_HOR_HIGH_ACT 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_SYNC_VERT_HIGH_ACT 2  
-#define FB_SYNC_EXT 4  
-#define FB_SYNC_COMP_HIGH_ACT 8  
-#define FB_SYNC_BROADCAST 16  
+#define FB_SYNC_VERT_HIGH_ACT 2
+#define FB_SYNC_EXT 4
+#define FB_SYNC_COMP_HIGH_ACT 8
+#define FB_SYNC_BROADCAST 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_SYNC_ON_GREEN 32  
-#define FB_VMODE_NONINTERLACED 0  
-#define FB_VMODE_INTERLACED 1  
-#define FB_VMODE_DOUBLE 2  
+#define FB_SYNC_ON_GREEN 32
+#define FB_VMODE_NONINTERLACED 0
+#define FB_VMODE_INTERLACED 1
+#define FB_VMODE_DOUBLE 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_VMODE_ODD_FLD_FIRST 4  
+#define FB_VMODE_ODD_FLD_FIRST 4
 #define FB_VMODE_MASK 255
-#define FB_VMODE_YWRAP 256  
-#define FB_VMODE_SMOOTH_XPAN 512  
+#define FB_VMODE_YWRAP 256
+#define FB_VMODE_SMOOTH_XPAN 512
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_VMODE_CONUPDATE 512  
+#define FB_VMODE_CONUPDATE 512
 #define FB_FLAG_RATIO_4_3 64
 #define FB_FLAG_RATIO_16_9 128
 #define FB_FLAG_PIXEL_REPEAT 256
@@ -323,17 +323,17 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  FB_BLANK_POWERDOWN = VESA_POWERDOWN + 1
 };
-#define FB_VBLANK_VBLANKING 0x001  
-#define FB_VBLANK_HBLANKING 0x002  
+#define FB_VBLANK_VBLANKING 0x001
+#define FB_VBLANK_HBLANKING 0x002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_VBLANK_HAVE_VBLANK 0x004  
-#define FB_VBLANK_HAVE_HBLANK 0x008  
-#define FB_VBLANK_HAVE_COUNT 0x010  
-#define FB_VBLANK_HAVE_VCOUNT 0x020  
+#define FB_VBLANK_HAVE_VBLANK 0x004
+#define FB_VBLANK_HAVE_HBLANK 0x008
+#define FB_VBLANK_HAVE_COUNT 0x010
+#define FB_VBLANK_HAVE_VCOUNT 0x020
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FB_VBLANK_HAVE_HCOUNT 0x040  
-#define FB_VBLANK_VSYNCING 0x080  
-#define FB_VBLANK_HAVE_VSYNC 0x100  
+#define FB_VBLANK_HAVE_HCOUNT 0x040
+#define FB_VBLANK_VSYNCING 0x080
+#define FB_VBLANK_HAVE_VSYNC 0x100
 struct fb_vblank {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __u32 flags;
@@ -403,4 +403,3 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #endif
-
diff --git a/libc/kernel/common/linux/fcntl.h b/libc/kernel/common/linux/fcntl.h
index 5e3fcd6..63d4eb1 100644
--- a/libc/kernel/common/linux/fcntl.h
+++ b/libc/kernel/common/linux/fcntl.h
@@ -23,18 +23,18 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define F_GETLEASE (F_LINUX_SPECIFIC_BASE+1)
 #define F_NOTIFY (F_LINUX_SPECIFIC_BASE+2)
-#define DN_ACCESS 0x00000001  
-#define DN_MODIFY 0x00000002  
+#define DN_ACCESS 0x00000001
+#define DN_MODIFY 0x00000002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DN_CREATE 0x00000004  
-#define DN_DELETE 0x00000008  
-#define DN_RENAME 0x00000010  
-#define DN_ATTRIB 0x00000020  
+#define DN_CREATE 0x00000004
+#define DN_DELETE 0x00000008
+#define DN_RENAME 0x00000010
+#define DN_ATTRIB 0x00000020
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DN_MULTISHOT 0x80000000  
-#define AT_FDCWD -100  
-#define AT_SYMLINK_NOFOLLOW 0x100  
-#define AT_REMOVEDIR 0x200  
+#define DN_MULTISHOT 0x80000000
+#define AT_FDCWD -100
+#define AT_SYMLINK_NOFOLLOW 0x100
+#define AT_REMOVEDIR 0x200
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define AT_SYMLINK_FOLLOW 0x400  
+#define AT_SYMLINK_FOLLOW 0x400
 #endif
diff --git a/libc/kernel/common/linux/fd.h b/libc/kernel/common/linux/fd.h
index d4f38ab..12c714f 100644
--- a/libc/kernel/common/linux/fd.h
+++ b/libc/kernel/common/linux/fd.h
@@ -47,9 +47,9 @@
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FDCLRPRM _IO(2, 0x41)
-#define FDSETPRM _IOW(2, 0x42, struct floppy_struct) 
+#define FDSETPRM _IOW(2, 0x42, struct floppy_struct)
 #define FDSETMEDIAPRM FDSETPRM
-#define FDDEFPRM _IOW(2, 0x43, struct floppy_struct) 
+#define FDDEFPRM _IOW(2, 0x43, struct floppy_struct)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FDGETPRM _IOR(2, 0x04, struct floppy_struct)
 #define FDDEFMEDIAPRM FDDEFPRM
@@ -57,7 +57,7 @@
 #define FDMSGON _IO(2,0x45)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FDMSGOFF _IO(2,0x46)
-#define FD_FILL_BYTE 0xF6  
+#define FD_FILL_BYTE 0xF6
 struct format_descr {
  unsigned int device,head,track;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -108,7 +108,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FD_DEBUG 0x02
 #define FD_SILENT_DCL_CLEAR 0x4
-#define FD_INVERTED_DCL 0x80  
+#define FD_INVERTED_DCL 0x80
  char read_track;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  short autodetect[8];
@@ -207,21 +207,21 @@
 #define FD_RAW_WRITE 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FD_RAW_NO_MOTOR 4
-#define FD_RAW_DISK_CHANGE 4  
-#define FD_RAW_INTR 8  
-#define FD_RAW_SPIN 0x10  
+#define FD_RAW_DISK_CHANGE 4
+#define FD_RAW_INTR 8
+#define FD_RAW_SPIN 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FD_RAW_NO_MOTOR_AFTER 0x20  
-#define FD_RAW_NEED_DISK 0x40  
-#define FD_RAW_NEED_SEEK 0x80  
-#define FD_RAW_MORE 0x100  
+#define FD_RAW_NO_MOTOR_AFTER 0x20
+#define FD_RAW_NEED_DISK 0x40
+#define FD_RAW_NEED_SEEK 0x80
+#define FD_RAW_MORE 0x100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FD_RAW_STOP_IF_FAILURE 0x200  
-#define FD_RAW_STOP_IF_SUCCESS 0x400  
-#define FD_RAW_SOFTFAILURE 0x800  
-#define FD_RAW_FAILURE 0x10000  
+#define FD_RAW_STOP_IF_FAILURE 0x200
+#define FD_RAW_STOP_IF_SUCCESS 0x400
+#define FD_RAW_SOFTFAILURE 0x800
+#define FD_RAW_FAILURE 0x10000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FD_RAW_HARDFAILURE 0x20000  
+#define FD_RAW_HARDFAILURE 0x20000
  void __user *data;
  char *kernel_data;
  struct floppy_raw_cmd *next;
diff --git a/libc/kernel/common/linux/fs.h b/libc/kernel/common/linux/fs.h
index 5d7b365..ebfc634 100644
--- a/libc/kernel/common/linux/fs.h
+++ b/libc/kernel/common/linux/fs.h
@@ -22,14 +22,14 @@
 #include <linux/ioctl.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #undef NR_OPEN
-#define NR_OPEN (1024*1024)  
-#define INR_OPEN 1024  
+#define NR_OPEN (1024*1024)
+#define INR_OPEN 1024
 #define BLOCK_SIZE_BITS 10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
-#define SEEK_SET 0  
-#define SEEK_CUR 1  
-#define SEEK_END 2  
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct files_stat_struct {
  int nr_files;
@@ -43,7 +43,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  int dummy[5];
 };
-#define NR_FILE 8192  
+#define NR_FILE 8192
 #define MAY_EXEC 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MAY_WRITE 2
@@ -54,7 +54,7 @@
 #define FMODE_WRITE 2
 #define FMODE_LSEEK 4
 #define FMODE_PREAD 8
-#define FMODE_PWRITE FMODE_PREAD  
+#define FMODE_PWRITE FMODE_PREAD
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FMODE_EXEC 16
 #define RW_MASK 1
@@ -62,9 +62,9 @@
 #define READ 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define WRITE 1
-#define READA 2  
-#define SWRITE 3  
-#define SPECIAL 4  
+#define READA 2
+#define SWRITE 3
+#define SPECIAL 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define READ_SYNC (READ | (1 << BIO_RW_SYNC))
 #define WRITE_SYNC (WRITE | (1 << BIO_RW_SYNC))
@@ -73,55 +73,55 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SEL_OUT 2
 #define SEL_EX 4
-#define FS_REQUIRES_DEV 1 
+#define FS_REQUIRES_DEV 1
 #define FS_BINARY_MOUNTDATA 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FS_REVAL_DOT 16384  
-#define FS_ODD_RENAME 32768  
-#define MS_RDONLY 1  
-#define MS_NOSUID 2  
+#define FS_REVAL_DOT 16384
+#define FS_ODD_RENAME 32768
+#define MS_RDONLY 1
+#define MS_NOSUID 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MS_NODEV 4  
-#define MS_NOEXEC 8  
-#define MS_SYNCHRONOUS 16  
-#define MS_REMOUNT 32  
+#define MS_NODEV 4
+#define MS_NOEXEC 8
+#define MS_SYNCHRONOUS 16
+#define MS_REMOUNT 32
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MS_MANDLOCK 64  
-#define MS_DIRSYNC 128  
-#define MS_NOATIME 1024  
-#define MS_NODIRATIME 2048  
+#define MS_MANDLOCK 64
+#define MS_DIRSYNC 128
+#define MS_NOATIME 1024
+#define MS_NODIRATIME 2048
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MS_BIND 4096
 #define MS_MOVE 8192
 #define MS_REC 16384
-#define MS_VERBOSE 32768  
+#define MS_VERBOSE 32768
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MS_SILENT 32768
-#define MS_POSIXACL (1<<16)  
-#define MS_UNBINDABLE (1<<17)  
-#define MS_PRIVATE (1<<18)  
+#define MS_POSIXACL (1<<16)
+#define MS_UNBINDABLE (1<<17)
+#define MS_PRIVATE (1<<18)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MS_SLAVE (1<<19)  
-#define MS_SHARED (1<<20)  
+#define MS_SLAVE (1<<19)
+#define MS_SHARED (1<<20)
 #define MS_ACTIVE (1<<30)
 #define MS_NOUSER (1<<31)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK)
 #define MS_MGC_VAL 0xC0ED0000
 #define MS_MGC_MSK 0xffff0000
-#define S_SYNC 1  
+#define S_SYNC 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define S_NOATIME 2  
-#define S_APPEND 4  
-#define S_IMMUTABLE 8  
-#define S_DEAD 16  
+#define S_NOATIME 2
+#define S_APPEND 4
+#define S_IMMUTABLE 8
+#define S_DEAD 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define S_NOQUOTA 32  
-#define S_DIRSYNC 64  
-#define S_NOCMTIME 128  
-#define S_SWAPFILE 256  
+#define S_NOQUOTA 32
+#define S_DIRSYNC 64
+#define S_NOCMTIME 128
+#define S_SWAPFILE 256
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define S_PRIVATE 512  
+#define S_PRIVATE 512
 #define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
 #define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
 #define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) ||   ((inode)->i_flags & S_SYNC))
@@ -138,33 +138,33 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
-#define BLKROSET _IO(0x12,93)  
-#define BLKROGET _IO(0x12,94)  
+#define BLKROSET _IO(0x12,93)
+#define BLKROGET _IO(0x12,94)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BLKRRPART _IO(0x12,95)  
-#define BLKGETSIZE _IO(0x12,96)  
-#define BLKFLSBUF _IO(0x12,97)  
-#define BLKRASET _IO(0x12,98)  
+#define BLKRRPART _IO(0x12,95)
+#define BLKGETSIZE _IO(0x12,96)
+#define BLKFLSBUF _IO(0x12,97)
+#define BLKRASET _IO(0x12,98)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BLKRAGET _IO(0x12,99)  
-#define BLKFRASET _IO(0x12,100) 
-#define BLKFRAGET _IO(0x12,101) 
-#define BLKSECTSET _IO(0x12,102) 
+#define BLKRAGET _IO(0x12,99)
+#define BLKFRASET _IO(0x12,100)
+#define BLKFRAGET _IO(0x12,101)
+#define BLKSECTSET _IO(0x12,102)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BLKSECTGET _IO(0x12,103) 
-#define BLKSSZGET _IO(0x12,104) 
+#define BLKSECTGET _IO(0x12,103)
+#define BLKSSZGET _IO(0x12,104)
 #define BLKBSZGET _IOR(0x12,112,size_t)
 #define BLKBSZSET _IOW(0x12,113,size_t)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BLKGETSIZE64 _IOR(0x12,114,size_t)  
+#define BLKGETSIZE64 _IOR(0x12,114,size_t)
 #define BLKTRACESETUP _IOWR(0x12,115,struct blk_user_trace_setup)
 #define BLKTRACESTART _IO(0x12,116)
 #define BLKTRACESTOP _IO(0x12,117)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BLKTRACETEARDOWN _IO(0x12,118)
-#define BMAP_IOCTL 1  
-#define FIBMAP _IO(0x00,1)  
-#define FIGETBSZ _IO(0x00,2)  
+#define BMAP_IOCTL 1
+#define FIBMAP _IO(0x00,1)
+#define FIGETBSZ _IO(0x00,2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
 #define SYNC_FILE_RANGE_WRITE 2
diff --git a/libc/kernel/common/linux/ftape.h b/libc/kernel/common/linux/ftape.h
index 105a5f3..fa70baa 100644
--- a/libc/kernel/common/linux/ftape.h
+++ b/libc/kernel/common/linux/ftape.h
@@ -22,7 +22,7 @@
 #include <linux/types.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <linux/mtio.h>
-#define FT_SECTOR(x) (x+1)  
+#define FT_SECTOR(x) (x+1)
 #define FT_SECTOR_SIZE 1024
 #define FT_SECTORS_PER_SEGMENT 32
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -37,7 +37,7 @@
 #define FTAPE_SEL_MASK 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FTAPE_SEL(unit) ((unit) & FTAPE_SEL_MASK)
-#define FTAPE_NO_REWIND 4  
+#define FTAPE_NO_REWIND 4
 typedef union {
  struct {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/futex.h b/libc/kernel/common/linux/futex.h
index 7630654..462dc83 100644
--- a/libc/kernel/common/linux/futex.h
+++ b/libc/kernel/common/linux/futex.h
@@ -46,20 +46,20 @@
 #define FUTEX_TID_MASK 0x3fffffff
 #define ROBUST_LIST_LIMIT 2048
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FUTEX_OP_SET 0  
-#define FUTEX_OP_ADD 1  
-#define FUTEX_OP_OR 2  
-#define FUTEX_OP_ANDN 3  
+#define FUTEX_OP_SET 0
+#define FUTEX_OP_ADD 1
+#define FUTEX_OP_OR 2
+#define FUTEX_OP_ANDN 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FUTEX_OP_XOR 4  
-#define FUTEX_OP_OPARG_SHIFT 8  
-#define FUTEX_OP_CMP_EQ 0  
-#define FUTEX_OP_CMP_NE 1  
+#define FUTEX_OP_XOR 4
+#define FUTEX_OP_OPARG_SHIFT 8
+#define FUTEX_OP_CMP_EQ 0
+#define FUTEX_OP_CMP_NE 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FUTEX_OP_CMP_LT 2  
-#define FUTEX_OP_CMP_LE 3  
-#define FUTEX_OP_CMP_GT 4  
-#define FUTEX_OP_CMP_GE 5  
+#define FUTEX_OP_CMP_LT 2
+#define FUTEX_OP_CMP_LE 3
+#define FUTEX_OP_CMP_GT 4
+#define FUTEX_OP_CMP_GE 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FUTEX_OP(op, oparg, cmp, cmparg)   (((op & 0xf) << 28) | ((cmp & 0xf) << 24)   | ((oparg & 0xfff) << 12) | (cmparg & 0xfff))
 #endif
diff --git a/libc/kernel/common/linux/genetlink.h b/libc/kernel/common/linux/genetlink.h
index 10b6504..f86ce05 100644
--- a/libc/kernel/common/linux/genetlink.h
+++ b/libc/kernel/common/linux/genetlink.h
@@ -21,7 +21,7 @@
 #include <linux/types.h>
 #include <linux/netlink.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define GENL_NAMSIZ 16  
+#define GENL_NAMSIZ 16
 #define GENL_MIN_ID NLMSG_MIN_TYPE
 #define GENL_MAX_ID 1023
 struct genlmsghdr {
diff --git a/libc/kernel/common/linux/genlock.h b/libc/kernel/common/linux/genlock.h
index 36a78dc..77f65dc 100644
--- a/libc/kernel/common/linux/genlock.h
+++ b/libc/kernel/common/linux/genlock.h
@@ -43,4 +43,3 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define GENLOCK_IOC_DREADLOCK _IOW(GENLOCK_IOC_MAGIC, 6,   struct genlock_lock)
 #endif
-
diff --git a/libc/kernel/common/linux/gfp.h b/libc/kernel/common/linux/gfp.h
index 258ec08..3a9fc21 100644
--- a/libc/kernel/common/linux/gfp.h
+++ b/libc/kernel/common/linux/gfp.h
@@ -27,29 +27,29 @@
 #define __GFP_HIGHMEM ((__force gfp_t)0x02u)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #if BITS_PER_LONG < 64
-#define __GFP_DMA32 ((__force gfp_t)0x00)  
+#define __GFP_DMA32 ((__force gfp_t)0x00)
 #else
-#define __GFP_DMA32 ((__force gfp_t)0x04)  
+#define __GFP_DMA32 ((__force gfp_t)0x04)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-#define __GFP_WAIT ((__force gfp_t)0x10u)  
-#define __GFP_HIGH ((__force gfp_t)0x20u)  
-#define __GFP_IO ((__force gfp_t)0x40u)  
+#define __GFP_WAIT ((__force gfp_t)0x10u)
+#define __GFP_HIGH ((__force gfp_t)0x20u)
+#define __GFP_IO ((__force gfp_t)0x40u)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define __GFP_FS ((__force gfp_t)0x80u)  
-#define __GFP_COLD ((__force gfp_t)0x100u)  
-#define __GFP_NOWARN ((__force gfp_t)0x200u)  
-#define __GFP_REPEAT ((__force gfp_t)0x400u)  
+#define __GFP_FS ((__force gfp_t)0x80u)
+#define __GFP_COLD ((__force gfp_t)0x100u)
+#define __GFP_NOWARN ((__force gfp_t)0x200u)
+#define __GFP_REPEAT ((__force gfp_t)0x400u)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define __GFP_NOFAIL ((__force gfp_t)0x800u)  
-#define __GFP_NORETRY ((__force gfp_t)0x1000u) 
-#define __GFP_NO_GROW ((__force gfp_t)0x2000u) 
-#define __GFP_COMP ((__force gfp_t)0x4000u) 
+#define __GFP_NOFAIL ((__force gfp_t)0x800u)
+#define __GFP_NORETRY ((__force gfp_t)0x1000u)
+#define __GFP_NO_GROW ((__force gfp_t)0x2000u)
+#define __GFP_COMP ((__force gfp_t)0x4000u)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define __GFP_ZERO ((__force gfp_t)0x8000u) 
-#define __GFP_NOMEMALLOC ((__force gfp_t)0x10000u)  
-#define __GFP_HARDWALL ((__force gfp_t)0x20000u)  
-#define __GFP_BITS_SHIFT 20  
+#define __GFP_ZERO ((__force gfp_t)0x8000u)
+#define __GFP_NOMEMALLOC ((__force gfp_t)0x10000u)
+#define __GFP_HARDWALL ((__force gfp_t)0x20000u)
+#define __GFP_BITS_SHIFT 20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
 #define GFP_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS|   __GFP_COLD|__GFP_NOWARN|__GFP_REPEAT|   __GFP_NOFAIL|__GFP_NORETRY|__GFP_NO_GROW|__GFP_COMP|   __GFP_NOMEMALLOC|__GFP_HARDWALL)
diff --git a/libc/kernel/common/linux/hdreg.h b/libc/kernel/common/linux/hdreg.h
index 155de99..56548f4 100644
--- a/libc/kernel/common/linux/hdreg.h
+++ b/libc/kernel/common/linux/hdreg.h
@@ -138,48 +138,48 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TASKFILE_P_OUT_DMAQ 0x4000
 #define WIN_NOP 0x00
-#define CFA_REQ_EXT_ERROR_CODE 0x03  
-#define WIN_SRST 0x08  
+#define CFA_REQ_EXT_ERROR_CODE 0x03
+#define WIN_SRST 0x08
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define WIN_DEVICE_RESET 0x08
 #define WIN_RECAL 0x10
 #define WIN_RESTORE WIN_RECAL
-#define WIN_READ 0x20  
+#define WIN_READ 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WIN_READ_ONCE 0x21  
-#define WIN_READ_LONG 0x22  
-#define WIN_READ_LONG_ONCE 0x23  
-#define WIN_READ_EXT 0x24  
+#define WIN_READ_ONCE 0x21
+#define WIN_READ_LONG 0x22
+#define WIN_READ_LONG_ONCE 0x23
+#define WIN_READ_EXT 0x24
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WIN_READDMA_EXT 0x25  
-#define WIN_READDMA_QUEUED_EXT 0x26  
-#define WIN_READ_NATIVE_MAX_EXT 0x27  
-#define WIN_MULTREAD_EXT 0x29  
+#define WIN_READDMA_EXT 0x25
+#define WIN_READDMA_QUEUED_EXT 0x26
+#define WIN_READ_NATIVE_MAX_EXT 0x27
+#define WIN_MULTREAD_EXT 0x29
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WIN_WRITE 0x30  
-#define WIN_WRITE_ONCE 0x31  
-#define WIN_WRITE_LONG 0x32  
-#define WIN_WRITE_LONG_ONCE 0x33  
+#define WIN_WRITE 0x30
+#define WIN_WRITE_ONCE 0x31
+#define WIN_WRITE_LONG 0x32
+#define WIN_WRITE_LONG_ONCE 0x33
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WIN_WRITE_EXT 0x34  
-#define WIN_WRITEDMA_EXT 0x35  
-#define WIN_WRITEDMA_QUEUED_EXT 0x36  
-#define WIN_SET_MAX_EXT 0x37  
+#define WIN_WRITE_EXT 0x34
+#define WIN_WRITEDMA_EXT 0x35
+#define WIN_WRITEDMA_QUEUED_EXT 0x36
+#define WIN_SET_MAX_EXT 0x37
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CFA_WRITE_SECT_WO_ERASE 0x38  
-#define WIN_MULTWRITE_EXT 0x39  
-#define WIN_WRITE_VERIFY 0x3C  
-#define WIN_VERIFY 0x40  
+#define CFA_WRITE_SECT_WO_ERASE 0x38
+#define WIN_MULTWRITE_EXT 0x39
+#define WIN_WRITE_VERIFY 0x3C
+#define WIN_VERIFY 0x40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WIN_VERIFY_ONCE 0x41  
-#define WIN_VERIFY_EXT 0x42  
+#define WIN_VERIFY_ONCE 0x41
+#define WIN_VERIFY_EXT 0x42
 #define WIN_FORMAT 0x50
 #define WIN_INIT 0x60
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WIN_SEEK 0x70  
-#define CFA_TRANSLATE_SECTOR 0x87  
+#define WIN_SEEK 0x70
+#define CFA_TRANSLATE_SECTOR 0x87
 #define WIN_DIAGNOSE 0x90
-#define WIN_SPECIFY 0x91  
+#define WIN_SPECIFY 0x91
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define WIN_DOWNLOAD_MICROCODE 0x92
 #define WIN_STANDBYNOW2 0x94
@@ -188,51 +188,51 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define WIN_CHECKPOWERMODE2 0x98
 #define WIN_SLEEPNOW2 0x99
-#define WIN_PACKETCMD 0xA0  
-#define WIN_PIDENTIFY 0xA1  
+#define WIN_PACKETCMD 0xA0
+#define WIN_PIDENTIFY 0xA1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define WIN_QUEUED_SERVICE 0xA2
-#define WIN_SMART 0xB0  
+#define WIN_SMART 0xB0
 #define CFA_ERASE_SECTORS 0xC0
-#define WIN_MULTREAD 0xC4  
+#define WIN_MULTREAD 0xC4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WIN_MULTWRITE 0xC5  
-#define WIN_SETMULT 0xC6  
-#define WIN_READDMA_QUEUED 0xC7  
-#define WIN_READDMA 0xC8  
+#define WIN_MULTWRITE 0xC5
+#define WIN_SETMULT 0xC6
+#define WIN_READDMA_QUEUED 0xC7
+#define WIN_READDMA 0xC8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WIN_READDMA_ONCE 0xC9  
-#define WIN_WRITEDMA 0xCA  
-#define WIN_WRITEDMA_ONCE 0xCB  
-#define WIN_WRITEDMA_QUEUED 0xCC  
+#define WIN_READDMA_ONCE 0xC9
+#define WIN_WRITEDMA 0xCA
+#define WIN_WRITEDMA_ONCE 0xCB
+#define WIN_WRITEDMA_QUEUED 0xCC
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CFA_WRITE_MULTI_WO_ERASE 0xCD  
+#define CFA_WRITE_MULTI_WO_ERASE 0xCD
 #define WIN_GETMEDIASTATUS 0xDA
-#define WIN_ACKMEDIACHANGE 0xDB  
+#define WIN_ACKMEDIACHANGE 0xDB
 #define WIN_POSTBOOT 0xDC
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define WIN_PREBOOT 0xDD
-#define WIN_DOORLOCK 0xDE  
-#define WIN_DOORUNLOCK 0xDF  
+#define WIN_DOORLOCK 0xDE
+#define WIN_DOORUNLOCK 0xDF
 #define WIN_STANDBYNOW1 0xE0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WIN_IDLEIMMEDIATE 0xE1  
-#define WIN_STANDBY 0xE2  
+#define WIN_IDLEIMMEDIATE 0xE1
+#define WIN_STANDBY 0xE2
 #define WIN_SETIDLE1 0xE3
-#define WIN_READ_BUFFER 0xE4  
+#define WIN_READ_BUFFER 0xE4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define WIN_CHECKPOWERMODE1 0xE5
 #define WIN_SLEEPNOW1 0xE6
 #define WIN_FLUSH_CACHE 0xE7
-#define WIN_WRITE_BUFFER 0xE8  
+#define WIN_WRITE_BUFFER 0xE8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WIN_WRITE_SAME 0xE9  
-#define WIN_FLUSH_CACHE_EXT 0xEA  
-#define WIN_IDENTIFY 0xEC  
+#define WIN_WRITE_SAME 0xE9
+#define WIN_FLUSH_CACHE_EXT 0xEA
+#define WIN_IDENTIFY 0xEC
 #define WIN_MEDIAEJECT 0xED
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WIN_IDENTIFY_DMA 0xEE  
-#define WIN_SETFEATURES 0xEF  
+#define WIN_IDENTIFY_DMA 0xEE
+#define WIN_SETFEATURES 0xEF
 #define EXABYTE_ENABLE_NEST 0xF0
 #define WIN_SECURITY_SET_PASS 0xF1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -242,7 +242,7 @@
 #define WIN_SECURITY_FREEZE_LOCK 0xF5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define WIN_SECURITY_DISABLE 0xF6
-#define WIN_READ_NATIVE_MAX 0xF8  
+#define WIN_READ_NATIVE_MAX 0xF8
 #define WIN_SET_MAX 0xF9
 #define DISABLE_SEAGATE 0xFB
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -263,45 +263,45 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SMART_LCYL_PASS 0x4F
 #define SMART_HCYL_PASS 0xC2
-#define SETFEATURES_EN_8BIT 0x01  
-#define SETFEATURES_EN_WCACHE 0x02  
+#define SETFEATURES_EN_8BIT 0x01
+#define SETFEATURES_EN_WCACHE 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SETFEATURES_DIS_DEFECT 0x04  
-#define SETFEATURES_EN_APM 0x05  
-#define SETFEATURES_EN_SAME_R 0x22  
-#define SETFEATURES_DIS_MSN 0x31  
+#define SETFEATURES_DIS_DEFECT 0x04
+#define SETFEATURES_EN_APM 0x05
+#define SETFEATURES_EN_SAME_R 0x22
+#define SETFEATURES_DIS_MSN 0x31
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SETFEATURES_DIS_RETRY 0x33  
-#define SETFEATURES_EN_AAM 0x42  
-#define SETFEATURES_RW_LONG 0x44  
-#define SETFEATURES_SET_CACHE 0x54  
+#define SETFEATURES_DIS_RETRY 0x33
+#define SETFEATURES_EN_AAM 0x42
+#define SETFEATURES_RW_LONG 0x44
+#define SETFEATURES_SET_CACHE 0x54
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SETFEATURES_DIS_RLA 0x55  
-#define SETFEATURES_EN_RI 0x5D  
-#define SETFEATURES_EN_SI 0x5E  
-#define SETFEATURES_DIS_RPOD 0x66  
+#define SETFEATURES_DIS_RLA 0x55
+#define SETFEATURES_EN_RI 0x5D
+#define SETFEATURES_EN_SI 0x5E
+#define SETFEATURES_DIS_RPOD 0x66
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SETFEATURES_DIS_ECC 0x77  
-#define SETFEATURES_DIS_8BIT 0x81  
-#define SETFEATURES_DIS_WCACHE 0x82  
-#define SETFEATURES_EN_DEFECT 0x84  
+#define SETFEATURES_DIS_ECC 0x77
+#define SETFEATURES_DIS_8BIT 0x81
+#define SETFEATURES_DIS_WCACHE 0x82
+#define SETFEATURES_EN_DEFECT 0x84
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SETFEATURES_DIS_APM 0x85  
-#define SETFEATURES_EN_ECC 0x88  
-#define SETFEATURES_EN_MSN 0x95  
-#define SETFEATURES_EN_RETRY 0x99  
+#define SETFEATURES_DIS_APM 0x85
+#define SETFEATURES_EN_ECC 0x88
+#define SETFEATURES_EN_MSN 0x95
+#define SETFEATURES_EN_RETRY 0x99
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SETFEATURES_EN_RLA 0xAA  
-#define SETFEATURES_PREFETCH 0xAB  
-#define SETFEATURES_EN_REST 0xAC  
-#define SETFEATURES_4B_RW_LONG 0xBB  
+#define SETFEATURES_EN_RLA 0xAA
+#define SETFEATURES_PREFETCH 0xAB
+#define SETFEATURES_EN_REST 0xAC
+#define SETFEATURES_4B_RW_LONG 0xBB
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SETFEATURES_DIS_AAM 0xC2  
-#define SETFEATURES_EN_RPOD 0xCC  
-#define SETFEATURES_DIS_RI 0xDD  
-#define SETFEATURES_EN_SAME_M 0xDD  
+#define SETFEATURES_DIS_AAM 0xC2
+#define SETFEATURES_EN_RPOD 0xCC
+#define SETFEATURES_DIS_RI 0xDD
+#define SETFEATURES_EN_SAME_M 0xDD
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SETFEATURES_DIS_SI 0xDE  
+#define SETFEATURES_DIS_SI 0xDE
 #define SECURITY_SET_PASSWORD 0xBA
 #define SECURITY_UNLOCK 0xBB
 #define SECURITY_ERASE_PREPARE 0xBC
@@ -317,52 +317,52 @@
  unsigned long start;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define HDIO_GETGEO 0x0301  
-#define HDIO_GET_UNMASKINTR 0x0302  
-#define HDIO_GET_MULTCOUNT 0x0304  
+#define HDIO_GETGEO 0x0301
+#define HDIO_GET_UNMASKINTR 0x0302
+#define HDIO_GET_MULTCOUNT 0x0304
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HDIO_GET_QDMA 0x0305  
-#define HDIO_SET_XFER 0x0306  
-#define HDIO_OBSOLETE_IDENTITY 0x0307  
-#define HDIO_GET_KEEPSETTINGS 0x0308  
+#define HDIO_GET_QDMA 0x0305
+#define HDIO_SET_XFER 0x0306
+#define HDIO_OBSOLETE_IDENTITY 0x0307
+#define HDIO_GET_KEEPSETTINGS 0x0308
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HDIO_GET_32BIT 0x0309  
-#define HDIO_GET_NOWERR 0x030a  
-#define HDIO_GET_DMA 0x030b  
-#define HDIO_GET_NICE 0x030c  
+#define HDIO_GET_32BIT 0x0309
+#define HDIO_GET_NOWERR 0x030a
+#define HDIO_GET_DMA 0x030b
+#define HDIO_GET_NICE 0x030c
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HDIO_GET_IDENTITY 0x030d  
-#define HDIO_GET_WCACHE 0x030e  
-#define HDIO_GET_ACOUSTIC 0x030f  
-#define HDIO_GET_ADDRESS 0x0310  
+#define HDIO_GET_IDENTITY 0x030d
+#define HDIO_GET_WCACHE 0x030e
+#define HDIO_GET_ACOUSTIC 0x030f
+#define HDIO_GET_ADDRESS 0x0310
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HDIO_GET_BUSSTATE 0x031a  
-#define HDIO_TRISTATE_HWIF 0x031b  
-#define HDIO_DRIVE_RESET 0x031c  
-#define HDIO_DRIVE_TASKFILE 0x031d  
+#define HDIO_GET_BUSSTATE 0x031a
+#define HDIO_TRISTATE_HWIF 0x031b
+#define HDIO_DRIVE_RESET 0x031c
+#define HDIO_DRIVE_TASKFILE 0x031d
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HDIO_DRIVE_TASK 0x031e  
-#define HDIO_DRIVE_CMD 0x031f  
+#define HDIO_DRIVE_TASK 0x031e
+#define HDIO_DRIVE_CMD 0x031f
 #define HDIO_DRIVE_CMD_AEB HDIO_DRIVE_TASK
-#define HDIO_SET_MULTCOUNT 0x0321  
+#define HDIO_SET_MULTCOUNT 0x0321
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HDIO_SET_UNMASKINTR 0x0322  
-#define HDIO_SET_KEEPSETTINGS 0x0323  
-#define HDIO_SET_32BIT 0x0324  
-#define HDIO_SET_NOWERR 0x0325  
+#define HDIO_SET_UNMASKINTR 0x0322
+#define HDIO_SET_KEEPSETTINGS 0x0323
+#define HDIO_SET_32BIT 0x0324
+#define HDIO_SET_NOWERR 0x0325
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HDIO_SET_DMA 0x0326  
-#define HDIO_SET_PIO_MODE 0x0327  
-#define HDIO_SCAN_HWIF 0x0328  
-#define HDIO_SET_NICE 0x0329  
+#define HDIO_SET_DMA 0x0326
+#define HDIO_SET_PIO_MODE 0x0327
+#define HDIO_SCAN_HWIF 0x0328
+#define HDIO_SET_NICE 0x0329
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HDIO_UNREGISTER_HWIF 0x032a  
-#define HDIO_SET_WCACHE 0x032b  
-#define HDIO_SET_ACOUSTIC 0x032c  
-#define HDIO_SET_BUSSTATE 0x032d  
+#define HDIO_UNREGISTER_HWIF 0x032a
+#define HDIO_SET_WCACHE 0x032b
+#define HDIO_SET_ACOUSTIC 0x032c
+#define HDIO_SET_BUSSTATE 0x032d
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HDIO_SET_QDMA 0x032e  
-#define HDIO_SET_ADDRESS 0x032f  
+#define HDIO_SET_QDMA 0x032e
+#define HDIO_SET_ADDRESS 0x032f
 enum {
  BUSSTATE_OFF = 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -472,10 +472,10 @@
  unsigned short integrity_word;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define IDE_NICE_DSC_OVERLAP (0)  
-#define IDE_NICE_ATAPI_OVERLAP (1)  
-#define IDE_NICE_0 (2)  
+#define IDE_NICE_DSC_OVERLAP (0)
+#define IDE_NICE_ATAPI_OVERLAP (1)
+#define IDE_NICE_0 (2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IDE_NICE_1 (3)  
-#define IDE_NICE_2 (4)  
+#define IDE_NICE_1 (3)
+#define IDE_NICE_2 (4)
 #endif
diff --git a/libc/kernel/common/linux/hil.h b/libc/kernel/common/linux/hil.h
index f6017a3..2b1f079 100644
--- a/libc/kernel/common/linux/hil.h
+++ b/libc/kernel/common/linux/hil.h
@@ -23,12 +23,12 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HIL_EK1_CLOCK 30HZ
 #define HIL_EK2_CLOCK 60HZ
-#define HIL_TIMEOUT_DEV 5  
-#define HIL_TIMEOUT_DEVS 10  
+#define HIL_TIMEOUT_DEV 5
+#define HIL_TIMEOUT_DEVS 10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HIL_TIMEOUT_NORESP 10  
-#define HIL_TIMEOUT_DEVS_DATA 16  
-#define HIL_TIMEOUT_SELFTEST 200  
+#define HIL_TIMEOUT_NORESP 10
+#define HIL_TIMEOUT_DEVS_DATA 16
+#define HIL_TIMEOUT_SELFTEST 200
 #define HIL_WIRE_PACKET_LEN 15
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum hil_wire_bitpos {
@@ -92,8 +92,8 @@
  HIL_CTRL_APE = 0x02000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define HIL_DO_ALTER_CTRL 0x40000000  
-#define HIL_CTRL_ONLY 0xc0000000  
+#define HIL_DO_ALTER_CTRL 0x40000000
+#define HIL_CTRL_ONLY 0xc0000000
 typedef u32 hil_packet;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum hil_command {
@@ -151,77 +151,77 @@
  HIL_CMD_DHR = 0xfe,
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HIL_IDD_DID_TYPE_MASK 0xe0  
-#define HIL_IDD_DID_TYPE_KB_INTEGRAL 0xa0  
-#define HIL_IDD_DID_TYPE_KB_ITF 0xc0  
-#define HIL_IDD_DID_TYPE_KB_RSVD 0xe0  
+#define HIL_IDD_DID_TYPE_MASK 0xe0
+#define HIL_IDD_DID_TYPE_KB_INTEGRAL 0xa0
+#define HIL_IDD_DID_TYPE_KB_ITF 0xc0
+#define HIL_IDD_DID_TYPE_KB_RSVD 0xe0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HIL_IDD_DID_TYPE_KB_LANG_MASK 0x1f  
-#define HIL_IDD_DID_KBLANG_USE_ESD 0x00  
-#define HIL_IDD_DID_TYPE_ABS 0x80  
-#define HIL_IDD_DID_ABS_RSVD1_MASK 0xf8  
+#define HIL_IDD_DID_TYPE_KB_LANG_MASK 0x1f
+#define HIL_IDD_DID_KBLANG_USE_ESD 0x00
+#define HIL_IDD_DID_TYPE_ABS 0x80
+#define HIL_IDD_DID_ABS_RSVD1_MASK 0xf8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HIL_IDD_DID_ABS_RSVD1 0x98
-#define HIL_IDD_DID_ABS_TABLET_MASK 0xf8  
+#define HIL_IDD_DID_ABS_TABLET_MASK 0xf8
 #define HIL_IDD_DID_ABS_TABLET 0x90
-#define HIL_IDD_DID_ABS_TSCREEN_MASK 0xfc  
+#define HIL_IDD_DID_ABS_TSCREEN_MASK 0xfc
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HIL_IDD_DID_ABS_TSCREEN 0x8c
-#define HIL_IDD_DID_ABS_RSVD2_MASK 0xfc  
+#define HIL_IDD_DID_ABS_RSVD2_MASK 0xfc
 #define HIL_IDD_DID_ABS_RSVD2 0x88
-#define HIL_IDD_DID_ABS_RSVD3_MASK 0xfc  
+#define HIL_IDD_DID_ABS_RSVD3_MASK 0xfc
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HIL_IDD_DID_ABS_RSVD3 0x80
-#define HIL_IDD_DID_TYPE_REL 0x60  
-#define HIL_IDD_DID_REL_RSVD1_MASK 0xf0  
+#define HIL_IDD_DID_TYPE_REL 0x60
+#define HIL_IDD_DID_REL_RSVD1_MASK 0xf0
 #define HIL_IDD_DID_REL_RSVD1 0x70
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HIL_IDD_DID_REL_RSVD2_MASK 0xfc  
+#define HIL_IDD_DID_REL_RSVD2_MASK 0xfc
 #define HIL_IDD_DID_REL_RSVD2 0x6c
-#define HIL_IDD_DID_REL_MOUSE_MASK 0xfc  
+#define HIL_IDD_DID_REL_MOUSE_MASK 0xfc
 #define HIL_IDD_DID_REL_MOUSE 0x68
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HIL_IDD_DID_REL_QUAD_MASK 0xf8  
+#define HIL_IDD_DID_REL_QUAD_MASK 0xf8
 #define HIL_IDD_DID_REL_QUAD 0x60
-#define HIL_IDD_DID_TYPE_CHAR 0x40  
-#define HIL_IDD_DID_CHAR_BARCODE_MASK 0xfc  
+#define HIL_IDD_DID_TYPE_CHAR 0x40
+#define HIL_IDD_DID_CHAR_BARCODE_MASK 0xfc
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HIL_IDD_DID_CHAR_BARCODE 0x5c
-#define HIL_IDD_DID_CHAR_RSVD1_MASK 0xfc  
+#define HIL_IDD_DID_CHAR_RSVD1_MASK 0xfc
 #define HIL_IDD_DID_CHAR_RSVD1 0x58
-#define HIL_IDD_DID_CHAR_RSVD2_MASK 0xf8  
+#define HIL_IDD_DID_CHAR_RSVD2_MASK 0xf8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HIL_IDD_DID_CHAR_RSVD2 0x50
-#define HIL_IDD_DID_CHAR_RSVD3_MASK 0xf0  
+#define HIL_IDD_DID_CHAR_RSVD3_MASK 0xf0
 #define HIL_IDD_DID_CHAR_RSVD3 0x40
-#define HIL_IDD_DID_TYPE_OTHER 0x20  
+#define HIL_IDD_DID_TYPE_OTHER 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HIL_IDD_DID_OTHER_RSVD1_MASK 0xf0  
+#define HIL_IDD_DID_OTHER_RSVD1_MASK 0xf0
 #define HIL_IDD_DID_OTHER_RSVD1 0x30
-#define HIL_IDD_DID_OTHER_BARCODE_MASK 0xfc  
+#define HIL_IDD_DID_OTHER_BARCODE_MASK 0xfc
 #define HIL_IDD_DID_OTHER_BARCODE 0x2c
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HIL_IDD_DID_OTHER_RSVD2_MASK 0xfc  
+#define HIL_IDD_DID_OTHER_RSVD2_MASK 0xfc
 #define HIL_IDD_DID_OTHER_RSVD2 0x28
-#define HIL_IDD_DID_OTHER_RSVD3_MASK 0xf8  
+#define HIL_IDD_DID_OTHER_RSVD3_MASK 0xf8
 #define HIL_IDD_DID_OTHER_RSVD3 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HIL_IDD_DID_TYPE_KEYPAD 0x00  
-#define HIL_IDD_HEADER_AXSET_MASK 0x03  
-#define HIL_IDD_HEADER_RSC 0x04  
-#define HIL_IDD_HEADER_EXD 0x08  
+#define HIL_IDD_DID_TYPE_KEYPAD 0x00
+#define HIL_IDD_HEADER_AXSET_MASK 0x03
+#define HIL_IDD_HEADER_RSC 0x04
+#define HIL_IDD_HEADER_EXD 0x08
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HIL_IDD_HEADER_IOD 0x10  
-#define HIL_IDD_HEADER_16BIT 0x20  
-#define HIL_IDD_HEADER_ABS 0x40  
-#define HIL_IDD_HEADER_2X_AXIS 0x80  
+#define HIL_IDD_HEADER_IOD 0x10
+#define HIL_IDD_HEADER_16BIT 0x20
+#define HIL_IDD_HEADER_ABS 0x40
+#define HIL_IDD_HEADER_2X_AXIS 0x80
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HIL_IDD_IOD_NBUTTON_MASK 0x07  
-#define HIL_IDD_IOD_PROXIMITY 0x08  
-#define HIL_IDD_IOD_PROMPT_MASK 0x70  
+#define HIL_IDD_IOD_NBUTTON_MASK 0x07
+#define HIL_IDD_IOD_PROXIMITY 0x08
+#define HIL_IDD_IOD_PROMPT_MASK 0x70
 #define HIL_IDD_IOD_PROMPT_SHIFT 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HIL_IDD_IOD_PROMPT 0x80  
+#define HIL_IDD_IOD_PROMPT 0x80
 #define HIL_IDD_NUM_AXES_PER_SET(header_packet)  ((header_packet) & HIL_IDD_HEADER_AXSET_MASK)
 #define HIL_IDD_NUM_AXSETS(header_packet)  (2 - !((header_packet) & HIL_IDD_HEADER_2X_AXIS))
 #define HIL_IDD_LEN(header_packet)  ((4 - !(header_packet & HIL_IDD_HEADER_IOD) -   2 * !(HIL_IDD_NUM_AXES_PER_SET(header_packet))) +   2 * HIL_IDD_NUM_AXES_PER_SET(header_packet) *   !!((header_packet) & HIL_IDD_HEADER_ABS))
@@ -234,15 +234,15 @@
 #define HIL_IDD_HAS_GEN_PROXIMITY(header_ptr)  ((*header_ptr & HIL_IDD_HEADER_IOD) &&   (HIL_IDD_IOD(header_ptr) & HIL_IDD_IOD_PROXIMITY))
 #define HIL_IDD_NUM_BUTTONS(header_ptr)  ((*header_ptr & HIL_IDD_HEADER_IOD) ?   (HIL_IDD_IOD(header_ptr) & HIL_IDD_IOD_NBUTTON_MASK) : 0)
 #define HIL_IDD_NUM_PROMPTS(header_ptr)  ((*header_ptr & HIL_IDD_HEADER_IOD) ?   ((HIL_IDD_IOD(header_ptr) & HIL_IDD_IOD_NPROMPT_MASK)   >> HIL_IDD_IOD_PROMPT_SHIFT) : 0)
-#define HIL_EXD_HEADER_WRG 0x03  
+#define HIL_EXD_HEADER_WRG 0x03
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HIL_EXD_HEADER_WRG_TYPE1 0x01  
-#define HIL_EXD_HEADER_WRG_TYPE2 0x02  
-#define HIL_EXD_HEADER_RRG 0x04  
-#define HIL_EXD_HEADER_RNM 0x10  
+#define HIL_EXD_HEADER_WRG_TYPE1 0x01
+#define HIL_EXD_HEADER_WRG_TYPE2 0x02
+#define HIL_EXD_HEADER_RRG 0x04
+#define HIL_EXD_HEADER_RNM 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HIL_EXD_HEADER_RST 0x20  
-#define HIL_EXD_HEADER_LOCALE 0x40  
+#define HIL_EXD_HEADER_RST 0x20
+#define HIL_EXD_HEADER_LOCALE 0x40
 #define HIL_EXD_NUM_RRG(header_ptr)  ((*header_ptr & HIL_EXD_HEADER_RRG) ?   (*(header_ptr + 1) & HIL_PKT_DATA_MASK) : 0)
 #define HIL_EXD_NUM_WWG(header_ptr)  ((*header_ptr & HIL_EXD_HEADER_WRG) ?   (*(header_ptr + 2 - !(*header_ptr & HIL_EXD_HEADER_RRG)) &   HIL_PKT_DATA_MASK) : 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -251,26 +251,26 @@
 #define HIL_EXD_WRG_TYPE2_LEN(header_ptr)  (!(*header_ptr & HIL_EXD_HEADER_WRG_TYPE2) ? -1 :   (*(header_ptr + HIL_EXD_LEN(header_ptr) - 2 -   !!(*header_ptr & HIL_EXD_HEADER_LOCALE)) & HIL_PKT_DATA_MASK) +   ((*(header_ptr + HIL_EXD_LEN(header_ptr) - 1 -   !!(*header_ptr & HIL_EXD_HEADER_LOCALE)) & HIL_PKT_DATA_MASK) << 8))
 #define HIL_LOCALE_MAX 0x1f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HIL_LOCALE_MAP  "",    "",    "",    "swiss.french",    "portuguese",    "arabic",    "hebrew",    "english.canadian",    "turkish",    "greek",    "thai",    "italian",    "korean",    "dutch",    "swedish",    "german",    "chinese",    "chinese",    "swiss.french",    "spanish",    "swiss.german",    "flemish",    "finnish",    "english.uk",    "french.canadian",    "swiss.german",    "norwegian",    "french",    "danish",    "japanese",    "spanish",   "english.us"    
+#define HIL_LOCALE_MAP  "",    "",    "",    "swiss.french",    "portuguese",    "arabic",    "hebrew",    "english.canadian",    "turkish",    "greek",    "thai",    "italian",    "korean",    "dutch",    "swedish",    "german",    "chinese",    "chinese",    "swiss.french",    "spanish",    "swiss.german",    "flemish",    "finnish",    "english.uk",    "french.canadian",    "swiss.german",    "norwegian",    "french",    "danish",    "japanese",    "spanish",   "english.us"
 #define HIL_KEYCODES_SET1_TBLSIZE 128
 #define HIL_KEYCODES_SET1   KEY_5, KEY_RESERVED, KEY_RIGHTALT, KEY_LEFTALT,   KEY_RIGHTSHIFT, KEY_LEFTSHIFT, KEY_LEFTCTRL, KEY_SYSRQ,   KEY_KP4, KEY_KP8, KEY_KP5, KEY_KP9,   KEY_KP6, KEY_KP7, KEY_KPCOMMA, KEY_KPENTER,   KEY_KP1, KEY_KPSLASH, KEY_KP2, KEY_KPPLUS,   KEY_KP3, KEY_KPASTERISK, KEY_KP0, KEY_KPMINUS,   KEY_B, KEY_V, KEY_C, KEY_X,   KEY_Z, KEY_RESERVED, KEY_RESERVED, KEY_ESC,   KEY_6, KEY_F10, KEY_3, KEY_F11,   KEY_KPDOT, KEY_F9, KEY_TAB  , KEY_F12,   KEY_H, KEY_G, KEY_F, KEY_D,   KEY_S, KEY_A, KEY_RESERVED, KEY_CAPSLOCK,   KEY_U, KEY_Y, KEY_T, KEY_R,   KEY_E, KEY_W, KEY_Q, KEY_TAB,   KEY_7, KEY_6, KEY_5, KEY_4,   KEY_3, KEY_2, KEY_1, KEY_GRAVE,   KEY_F13, KEY_F14, KEY_F15, KEY_F16,   KEY_F17, KEY_F18, KEY_F19, KEY_F20,   KEY_MENU, KEY_F4, KEY_F3, KEY_F2,   KEY_F1, KEY_VOLUMEUP, KEY_STOP, KEY_SENDFILE,   KEY_SYSRQ, KEY_F5, KEY_F6, KEY_F7,   KEY_F8, KEY_VOLUMEDOWN, KEY_DEL_EOL, KEY_DEL_EOS,   KEY_8, KEY_9, KEY_0, KEY_MINUS,   KEY_EQUAL, KEY_BACKSPACE, KEY_INS_LINE, KEY_DEL_LINE,   KEY_I, KEY_O, KEY_P, KEY_LEFTBRACE,   KEY_RIGHTBRACE, KEY_BACKSLASH, KEY_INSERT, KEY_DELETE,   KEY_J, KEY_K, KEY_L, KEY_SEMICOLON,   KEY_APOSTROPHE, KEY_ENTER, KEY_HOME, KEY_PAGEUP,   KEY_M, KEY_COMMA, KEY_DOT, KEY_SLASH,   KEY_BACKSLASH, KEY_SELECT, KEY_102ND, KEY_PAGEDOWN,   KEY_N, KEY_SPACE, KEY_NEXT, KEY_RESERVED,   KEY_LEFT, KEY_DOWN, KEY_UP, KEY_RIGHT
 #define HIL_KEYCODES_SET3_TBLSIZE 128
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HIL_KEYCODES_SET3   KEY_RESERVED, KEY_ESC, KEY_1, KEY_2,   KEY_3, KEY_4, KEY_5, KEY_6,   KEY_7, KEY_8, KEY_9, KEY_0,   KEY_MINUS, KEY_EQUAL, KEY_BACKSPACE, KEY_TAB,   KEY_Q, KEY_W, KEY_E, KEY_R,   KEY_T, KEY_Y, KEY_U, KEY_I,   KEY_O, KEY_P, KEY_LEFTBRACE, KEY_RIGHTBRACE,   KEY_ENTER, KEY_LEFTCTRL, KEY_A, KEY_S,   KEY_D, KEY_F, KEY_G, KEY_H,   KEY_J, KEY_K, KEY_L, KEY_SEMICOLON,   KEY_APOSTROPHE,KEY_GRAVE, KEY_LEFTSHIFT, KEY_BACKSLASH,   KEY_Z, KEY_X, KEY_C, KEY_V,   KEY_B, KEY_N, KEY_M, KEY_COMMA,   KEY_DOT, KEY_SLASH, KEY_RIGHTSHIFT, KEY_KPASTERISK,   KEY_LEFTALT, KEY_SPACE, KEY_CAPSLOCK, KEY_F1,   KEY_F2, KEY_F3, KEY_F4, KEY_F5,   KEY_F6, KEY_F7, KEY_F8, KEY_F9,   KEY_F10, KEY_NUMLOCK, KEY_SCROLLLOCK, KEY_KP7,   KEY_KP8, KEY_KP9, KEY_KPMINUS, KEY_KP4,   KEY_KP5, KEY_KP6, KEY_KPPLUS, KEY_KP1,   KEY_KP2, KEY_KP3, KEY_KP0, KEY_KPDOT,   KEY_SYSRQ, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,   KEY_UP, KEY_LEFT, KEY_DOWN, KEY_RIGHT,   KEY_HOME, KEY_PAGEUP, KEY_END, KEY_PAGEDOWN,   KEY_INSERT, KEY_DELETE, KEY_102ND, KEY_RESERVED,   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,   KEY_F1, KEY_F2, KEY_F3, KEY_F4,   KEY_F5, KEY_F6, KEY_F7, KEY_F8,   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED
-#define HIL_POL_NUM_AXES_MASK 0x03  
-#define HIL_POL_CTS 0x04  
-#define HIL_POL_STATUS_PENDING 0x08  
+#define HIL_POL_NUM_AXES_MASK 0x03
+#define HIL_POL_CTS 0x04
+#define HIL_POL_STATUS_PENDING 0x08
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HIL_POL_CHARTYPE_MASK 0x70  
-#define HIL_POL_CHARTYPE_NONE 0x00  
-#define HIL_POL_CHARTYPE_RSVD1 0x10  
-#define HIL_POL_CHARTYPE_ASCII 0x20  
+#define HIL_POL_CHARTYPE_MASK 0x70
+#define HIL_POL_CHARTYPE_NONE 0x00
+#define HIL_POL_CHARTYPE_RSVD1 0x10
+#define HIL_POL_CHARTYPE_ASCII 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HIL_POL_CHARTYPE_BINARY 0x30  
-#define HIL_POL_CHARTYPE_SET1 0x40  
-#define HIL_POL_CHARTYPE_RSVD2 0x50  
-#define HIL_POL_CHARTYPE_SET2 0x60  
+#define HIL_POL_CHARTYPE_BINARY 0x30
+#define HIL_POL_CHARTYPE_SET1 0x40
+#define HIL_POL_CHARTYPE_RSVD2 0x50
+#define HIL_POL_CHARTYPE_SET2 0x60
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HIL_POL_CHARTYPE_SET3 0x70  
-#define HIL_POL_AXIS_ALT 0x80  
+#define HIL_POL_CHARTYPE_SET3 0x70
+#define HIL_POL_AXIS_ALT 0x80
 #endif
diff --git a/libc/kernel/common/linux/i2c.h b/libc/kernel/common/linux/i2c.h
index f266a97..4902f24 100644
--- a/libc/kernel/common/linux/i2c.h
+++ b/libc/kernel/common/linux/i2c.h
@@ -23,7 +23,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __u16 addr;
  __u16 flags;
-#define I2C_M_TEN 0x10  
+#define I2C_M_TEN 0x10
 #define I2C_M_RD 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I2C_M_NOSTART 0x4000
@@ -37,27 +37,27 @@
 #define I2C_FUNC_I2C 0x00000001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I2C_FUNC_10BIT_ADDR 0x00000002
-#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004  
-#define I2C_FUNC_SMBUS_HWPEC_CALC 0x00000008  
-#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000  
+#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004
+#define I2C_FUNC_SMBUS_HWPEC_CALC 0x00000008
+#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define I2C_FUNC_SMBUS_QUICK 0x00010000 
-#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 
-#define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 
-#define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 
+#define I2C_FUNC_SMBUS_QUICK 0x00010000
+#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000
+#define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000
+#define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 
-#define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 
-#define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 
-#define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 
+#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000
+#define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000
+#define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000
+#define I2C_FUNC_SMBUS_PROC_CALL 0x00800000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 
-#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 
-#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000  
-#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000  
+#define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000
+#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
+#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000
+#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000  
-#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2 0x20000000  
+#define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000
+#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2 0x20000000
 #define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE |   I2C_FUNC_SMBUS_WRITE_BYTE)
 #define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA |   I2C_FUNC_SMBUS_WRITE_BYTE_DATA)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -67,7 +67,7 @@
 #define I2C_FUNC_SMBUS_I2C_BLOCK_2 (I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 |   I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I2C_FUNC_SMBUS_EMUL (I2C_FUNC_SMBUS_QUICK |   I2C_FUNC_SMBUS_BYTE |   I2C_FUNC_SMBUS_BYTE_DATA |   I2C_FUNC_SMBUS_WORD_DATA |   I2C_FUNC_SMBUS_PROC_CALL |   I2C_FUNC_SMBUS_WRITE_BLOCK_DATA |   I2C_FUNC_SMBUS_I2C_BLOCK)
-#define I2C_SMBUS_BLOCK_MAX 32   
+#define I2C_SMBUS_BLOCK_MAX 32
 union i2c_smbus_data {
  __u8 byte;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -79,23 +79,23 @@
 #define I2C_SMBUS_WRITE 0
 #define I2C_SMBUS_QUICK 0
 #define I2C_SMBUS_BYTE 1
-#define I2C_SMBUS_BYTE_DATA 2 
+#define I2C_SMBUS_BYTE_DATA 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I2C_SMBUS_WORD_DATA 3
 #define I2C_SMBUS_PROC_CALL 4
 #define I2C_SMBUS_BLOCK_DATA 5
 #define I2C_SMBUS_I2C_BLOCK_DATA 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define I2C_SMBUS_BLOCK_PROC_CALL 7  
-#define I2C_RETRIES 0x0701  
-#define I2C_TIMEOUT 0x0702  
-#define I2C_SLAVE 0x0703  
+#define I2C_SMBUS_BLOCK_PROC_CALL 7
+#define I2C_RETRIES 0x0701
+#define I2C_TIMEOUT 0x0702
+#define I2C_SLAVE 0x0703
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define I2C_SLAVE_FORCE 0x0706  
-#define I2C_TENBIT 0x0704  
-#define I2C_FUNCS 0x0705  
-#define I2C_RDWR 0x0707  
+#define I2C_SLAVE_FORCE 0x0706
+#define I2C_TENBIT 0x0704
+#define I2C_FUNCS 0x0705
+#define I2C_RDWR 0x0707
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define I2C_PEC 0x0708  
-#define I2C_SMBUS 0x0720  
+#define I2C_PEC 0x0708
+#define I2C_SMBUS 0x0720
 #endif
diff --git a/libc/kernel/common/linux/icmp.h b/libc/kernel/common/linux/icmp.h
index 3a2580e..d166e97 100644
--- a/libc/kernel/common/linux/icmp.h
+++ b/libc/kernel/common/linux/icmp.h
@@ -19,31 +19,31 @@
 #ifndef _LINUX_ICMP_H
 #define _LINUX_ICMP_H
 #include <linux/types.h>
-#define ICMP_ECHOREPLY 0  
+#define ICMP_ECHOREPLY 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ICMP_DEST_UNREACH 3  
-#define ICMP_SOURCE_QUENCH 4  
-#define ICMP_REDIRECT 5  
-#define ICMP_ECHO 8  
+#define ICMP_DEST_UNREACH 3
+#define ICMP_SOURCE_QUENCH 4
+#define ICMP_REDIRECT 5
+#define ICMP_ECHO 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ICMP_TIME_EXCEEDED 11  
-#define ICMP_PARAMETERPROB 12  
-#define ICMP_TIMESTAMP 13  
-#define ICMP_TIMESTAMPREPLY 14  
+#define ICMP_TIME_EXCEEDED 11
+#define ICMP_PARAMETERPROB 12
+#define ICMP_TIMESTAMP 13
+#define ICMP_TIMESTAMPREPLY 14
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ICMP_INFO_REQUEST 15  
-#define ICMP_INFO_REPLY 16  
-#define ICMP_ADDRESS 17  
-#define ICMP_ADDRESSREPLY 18  
+#define ICMP_INFO_REQUEST 15
+#define ICMP_INFO_REPLY 16
+#define ICMP_ADDRESS 17
+#define ICMP_ADDRESSREPLY 18
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NR_ICMP_TYPES 18
-#define ICMP_NET_UNREACH 0  
-#define ICMP_HOST_UNREACH 1  
-#define ICMP_PROT_UNREACH 2  
+#define ICMP_NET_UNREACH 0
+#define ICMP_HOST_UNREACH 1
+#define ICMP_PROT_UNREACH 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ICMP_PORT_UNREACH 3  
-#define ICMP_FRAG_NEEDED 4  
-#define ICMP_SR_FAILED 5  
+#define ICMP_PORT_UNREACH 3
+#define ICMP_FRAG_NEEDED 4
+#define ICMP_SR_FAILED 5
 #define ICMP_NET_UNKNOWN 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ICMP_HOST_UNKNOWN 7
@@ -53,18 +53,18 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ICMP_NET_UNR_TOS 11
 #define ICMP_HOST_UNR_TOS 12
-#define ICMP_PKT_FILTERED 13  
-#define ICMP_PREC_VIOLATION 14  
+#define ICMP_PKT_FILTERED 13
+#define ICMP_PREC_VIOLATION 14
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ICMP_PREC_CUTOFF 15  
-#define NR_ICMP_UNREACH 15  
-#define ICMP_REDIR_NET 0  
-#define ICMP_REDIR_HOST 1  
+#define ICMP_PREC_CUTOFF 15
+#define NR_ICMP_UNREACH 15
+#define ICMP_REDIR_NET 0
+#define ICMP_REDIR_HOST 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ICMP_REDIR_NETTOS 2  
-#define ICMP_REDIR_HOSTTOS 3  
-#define ICMP_EXC_TTL 0  
-#define ICMP_EXC_FRAGTIME 1  
+#define ICMP_REDIR_NETTOS 2
+#define ICMP_REDIR_HOSTTOS 3
+#define ICMP_EXC_TTL 0
+#define ICMP_EXC_FRAGTIME 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct icmphdr {
  __u8 type;
@@ -79,7 +79,7 @@
  } echo;
  __u32 gateway;
  struct {
- __u16 __unused_field;
+ __u16 __linux_unused;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __u16 mtu;
  } frag;
diff --git a/libc/kernel/common/linux/idle_stats_device.h b/libc/kernel/common/linux/idle_stats_device.h
index 0634321..99a96ac 100644
--- a/libc/kernel/common/linux/idle_stats_device.h
+++ b/libc/kernel/common/linux/idle_stats_device.h
@@ -56,4 +56,3 @@
 #define MSM_IDLE_STATS_IOC_WRITE_STATS   _IOWR(MSM_IDLE_STATS_IOC_MAGIC, 2, struct msm_idle_write_stats)
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-
diff --git a/libc/kernel/common/linux/if.h b/libc/kernel/common/linux/if.h
index 87f02e1..8fc6d88 100644
--- a/libc/kernel/common/linux/if.h
+++ b/libc/kernel/common/linux/if.h
@@ -18,83 +18,83 @@
  ****************************************************************************/
 #ifndef _LINUX_IF_H
 #define _LINUX_IF_H
-#include <linux/types.h>  
-#include <linux/socket.h>  
+#include <linux/types.h>
+#include <linux/socket.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#include <linux/compiler.h>  
+#include <linux/compiler.h>
 #define IFNAMSIZ 16
 #define IFALIASZ 256
 #include <linux/hdlc/ioctl.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IFF_UP 0x1  
-#define IFF_BROADCAST 0x2  
-#define IFF_DEBUG 0x4  
-#define IFF_LOOPBACK 0x8  
+#define IFF_UP 0x1
+#define IFF_BROADCAST 0x2
+#define IFF_DEBUG 0x4
+#define IFF_LOOPBACK 0x8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IFF_POINTOPOINT 0x10  
-#define IFF_NOTRAILERS 0x20  
-#define IFF_RUNNING 0x40  
-#define IFF_NOARP 0x80  
+#define IFF_POINTOPOINT 0x10
+#define IFF_NOTRAILERS 0x20
+#define IFF_RUNNING 0x40
+#define IFF_NOARP 0x80
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IFF_PROMISC 0x100  
-#define IFF_ALLMULTI 0x200  
-#define IFF_MASTER 0x400  
-#define IFF_SLAVE 0x800  
+#define IFF_PROMISC 0x100
+#define IFF_ALLMULTI 0x200
+#define IFF_MASTER 0x400
+#define IFF_SLAVE 0x800
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IFF_MULTICAST 0x1000  
-#define IFF_PORTSEL 0x2000  
-#define IFF_AUTOMEDIA 0x4000  
-#define IFF_DYNAMIC 0x8000  
+#define IFF_MULTICAST 0x1000
+#define IFF_PORTSEL 0x2000
+#define IFF_AUTOMEDIA 0x4000
+#define IFF_DYNAMIC 0x8000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IFF_LOWER_UP 0x10000  
-#define IFF_DORMANT 0x20000  
-#define IFF_ECHO 0x40000  
+#define IFF_LOWER_UP 0x10000
+#define IFF_DORMANT 0x20000
+#define IFF_ECHO 0x40000
 #define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_ECHO|  IFF_MASTER|IFF_SLAVE|IFF_RUNNING|IFF_LOWER_UP|IFF_DORMANT)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IFF_802_1Q_VLAN 0x1  
-#define IFF_EBRIDGE 0x2  
-#define IFF_SLAVE_INACTIVE 0x4  
-#define IFF_MASTER_8023AD 0x8  
+#define IFF_802_1Q_VLAN 0x1
+#define IFF_EBRIDGE 0x2
+#define IFF_SLAVE_INACTIVE 0x4
+#define IFF_MASTER_8023AD 0x8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IFF_MASTER_ALB 0x10  
-#define IFF_BONDING 0x20  
-#define IFF_SLAVE_NEEDARP 0x40  
-#define IFF_ISATAP 0x80  
+#define IFF_MASTER_ALB 0x10
+#define IFF_BONDING 0x20
+#define IFF_SLAVE_NEEDARP 0x40
+#define IFF_ISATAP 0x80
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IFF_MASTER_ARPMON 0x100  
-#define IFF_WAN_HDLC 0x200  
-#define IFF_XMIT_DST_RELEASE 0x400  
-#define IFF_DONT_BRIDGE 0x800  
+#define IFF_MASTER_ARPMON 0x100
+#define IFF_WAN_HDLC 0x200
+#define IFF_XMIT_DST_RELEASE 0x400
+#define IFF_DONT_BRIDGE 0x800
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IFF_IN_NETPOLL 0x1000  
-#define IFF_DISABLE_NETPOLL 0x2000  
-#define IF_GET_IFACE 0x0001  
+#define IFF_IN_NETPOLL 0x1000
+#define IFF_DISABLE_NETPOLL 0x2000
+#define IF_GET_IFACE 0x0001
 #define IF_GET_PROTO 0x0002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IF_IFACE_V35 0x1000  
-#define IF_IFACE_V24 0x1001  
-#define IF_IFACE_X21 0x1002  
-#define IF_IFACE_T1 0x1003  
+#define IF_IFACE_V35 0x1000
+#define IF_IFACE_V24 0x1001
+#define IF_IFACE_X21 0x1002
+#define IF_IFACE_T1 0x1003
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IF_IFACE_E1 0x1004  
-#define IF_IFACE_SYNC_SERIAL 0x1005  
-#define IF_IFACE_X21D 0x1006  
-#define IF_PROTO_HDLC 0x2000  
+#define IF_IFACE_E1 0x1004
+#define IF_IFACE_SYNC_SERIAL 0x1005
+#define IF_IFACE_X21D 0x1006
+#define IF_PROTO_HDLC 0x2000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IF_PROTO_PPP 0x2001  
-#define IF_PROTO_CISCO 0x2002  
-#define IF_PROTO_FR 0x2003  
-#define IF_PROTO_FR_ADD_PVC 0x2004  
+#define IF_PROTO_PPP 0x2001
+#define IF_PROTO_CISCO 0x2002
+#define IF_PROTO_FR 0x2003
+#define IF_PROTO_FR_ADD_PVC 0x2004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IF_PROTO_FR_DEL_PVC 0x2005  
-#define IF_PROTO_X25 0x2006  
-#define IF_PROTO_HDLC_ETH 0x2007  
-#define IF_PROTO_FR_ADD_ETH_PVC 0x2008  
+#define IF_PROTO_FR_DEL_PVC 0x2005
+#define IF_PROTO_X25 0x2006
+#define IF_PROTO_HDLC_ETH 0x2007
+#define IF_PROTO_FR_ADD_ETH_PVC 0x2008
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IF_PROTO_FR_DEL_ETH_PVC 0x2009  
-#define IF_PROTO_FR_PVC 0x200A  
+#define IF_PROTO_FR_DEL_ETH_PVC 0x2009
+#define IF_PROTO_FR_PVC 0x200A
 #define IF_PROTO_FR_ETH_PVC 0x200B
-#define IF_PROTO_RAW 0x200C  
+#define IF_PROTO_RAW 0x200C
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
  IF_OPER_UNKNOWN,
@@ -166,27 +166,27 @@
  } ifr_ifru;
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ifr_name ifr_ifrn.ifrn_name  
-#define ifr_hwaddr ifr_ifru.ifru_hwaddr  
-#define ifr_addr ifr_ifru.ifru_addr  
-#define ifr_dstaddr ifr_ifru.ifru_dstaddr  
+#define ifr_name ifr_ifrn.ifrn_name
+#define ifr_hwaddr ifr_ifru.ifru_hwaddr
+#define ifr_addr ifr_ifru.ifru_addr
+#define ifr_dstaddr ifr_ifru.ifru_dstaddr
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ifr_broadaddr ifr_ifru.ifru_broadaddr  
-#define ifr_netmask ifr_ifru.ifru_netmask  
-#define ifr_flags ifr_ifru.ifru_flags  
-#define ifr_metric ifr_ifru.ifru_ivalue  
+#define ifr_broadaddr ifr_ifru.ifru_broadaddr
+#define ifr_netmask ifr_ifru.ifru_netmask
+#define ifr_flags ifr_ifru.ifru_flags
+#define ifr_metric ifr_ifru.ifru_ivalue
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ifr_mtu ifr_ifru.ifru_mtu  
-#define ifr_map ifr_ifru.ifru_map  
-#define ifr_slave ifr_ifru.ifru_slave  
-#define ifr_data ifr_ifru.ifru_data  
+#define ifr_mtu ifr_ifru.ifru_mtu
+#define ifr_map ifr_ifru.ifru_map
+#define ifr_slave ifr_ifru.ifru_slave
+#define ifr_data ifr_ifru.ifru_data
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ifr_ifindex ifr_ifru.ifru_ivalue  
-#define ifr_bandwidth ifr_ifru.ifru_ivalue  
-#define ifr_qlen ifr_ifru.ifru_ivalue  
-#define ifr_newname ifr_ifru.ifru_newname  
+#define ifr_ifindex ifr_ifru.ifru_ivalue
+#define ifr_bandwidth ifr_ifru.ifru_ivalue
+#define ifr_qlen ifr_ifru.ifru_ivalue
+#define ifr_newname ifr_ifru.ifru_newname
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ifr_settings ifr_ifru.ifru_settings  
+#define ifr_settings ifr_ifru.ifru_settings
 struct ifconf {
  int ifc_len;
  union {
@@ -196,6 +196,6 @@
  } ifc_ifcu;
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ifc_buf ifc_ifcu.ifcu_buf  
-#define ifc_req ifc_ifcu.ifcu_req  
+#define ifc_buf ifc_ifcu.ifcu_buf
+#define ifc_req ifc_ifcu.ifcu_req
 #endif
diff --git a/libc/kernel/common/linux/if_arcnet.h b/libc/kernel/common/linux/if_arcnet.h
index ef16fda..afbbae6 100644
--- a/libc/kernel/common/linux/if_arcnet.h
+++ b/libc/kernel/common/linux/if_arcnet.h
@@ -19,24 +19,24 @@
 #ifndef _LINUX_IF_ARCNET_H
 #define _LINUX_IF_ARCNET_H
 #include <linux/if_ether.h>
-#define ARC_P_IP 212  
+#define ARC_P_IP 212
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARC_P_IPV6 196  
-#define ARC_P_ARP 213  
-#define ARC_P_RARP 214  
-#define ARC_P_IPX 250  
+#define ARC_P_IPV6 196
+#define ARC_P_ARP 213
+#define ARC_P_RARP 214
+#define ARC_P_IPX 250
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARC_P_NOVELL_EC 236  
-#define ARC_P_IP_RFC1051 240  
-#define ARC_P_ARP_RFC1051 241  
-#define ARC_P_ETHER 232  
+#define ARC_P_NOVELL_EC 236
+#define ARC_P_IP_RFC1051 240
+#define ARC_P_ARP_RFC1051 241
+#define ARC_P_ETHER 232
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARC_P_DATAPOINT_BOOT 0  
+#define ARC_P_DATAPOINT_BOOT 0
 #define ARC_P_DATAPOINT_MOUNT 1
-#define ARC_P_POWERLAN_BEACON 8  
-#define ARC_P_POWERLAN_BEACON2 243  
+#define ARC_P_POWERLAN_BEACON 8
+#define ARC_P_POWERLAN_BEACON2 243
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARC_P_LANSOFT 251  
+#define ARC_P_LANSOFT 251
 #define ARC_P_ATALK 0xDD
 #define ARCNET_ALEN 1
 struct arc_rfc1201
diff --git a/libc/kernel/common/linux/if_arp.h b/libc/kernel/common/linux/if_arp.h
index 37d20c7..23659f0 100644
--- a/libc/kernel/common/linux/if_arp.h
+++ b/libc/kernel/common/linux/if_arp.h
@@ -19,91 +19,91 @@
 #ifndef _LINUX_IF_ARP_H
 #define _LINUX_IF_ARP_H
 #include <linux/netdevice.h>
-#define ARPHRD_NETROM 0  
+#define ARPHRD_NETROM 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARPHRD_ETHER 1  
-#define ARPHRD_EETHER 2  
-#define ARPHRD_AX25 3  
-#define ARPHRD_PRONET 4  
+#define ARPHRD_ETHER 1
+#define ARPHRD_EETHER 2
+#define ARPHRD_AX25 3
+#define ARPHRD_PRONET 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARPHRD_CHAOS 5  
-#define ARPHRD_IEEE802 6  
-#define ARPHRD_ARCNET 7  
-#define ARPHRD_APPLETLK 8  
+#define ARPHRD_CHAOS 5
+#define ARPHRD_IEEE802 6
+#define ARPHRD_ARCNET 7
+#define ARPHRD_APPLETLK 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARPHRD_DLCI 15  
-#define ARPHRD_ATM 19  
-#define ARPHRD_METRICOM 23  
-#define ARPHRD_IEEE1394 24  
+#define ARPHRD_DLCI 15
+#define ARPHRD_ATM 19
+#define ARPHRD_METRICOM 23
+#define ARPHRD_IEEE1394 24
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARPHRD_EUI64 27  
-#define ARPHRD_INFINIBAND 32  
+#define ARPHRD_EUI64 27
+#define ARPHRD_INFINIBAND 32
 #define ARPHRD_SLIP 256
 #define ARPHRD_CSLIP 257
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ARPHRD_SLIP6 258
 #define ARPHRD_CSLIP6 259
-#define ARPHRD_RSRVD 260  
+#define ARPHRD_RSRVD 260
 #define ARPHRD_ADAPT 264
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ARPHRD_ROSE 270
-#define ARPHRD_X25 271  
-#define ARPHRD_HWX25 272  
-#define ARPHRD_CAN 280  
+#define ARPHRD_X25 271
+#define ARPHRD_HWX25 272
+#define ARPHRD_CAN 280
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ARPHRD_PPP 512
-#define ARPHRD_CISCO 513  
+#define ARPHRD_CISCO 513
 #define ARPHRD_HDLC ARPHRD_CISCO
-#define ARPHRD_LAPB 516  
+#define ARPHRD_LAPB 516
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARPHRD_DDCMP 517  
-#define ARPHRD_RAWHDLC 518  
-#define ARPHRD_TUNNEL 768  
-#define ARPHRD_TUNNEL6 769  
+#define ARPHRD_DDCMP 517
+#define ARPHRD_RAWHDLC 518
+#define ARPHRD_TUNNEL 768
+#define ARPHRD_TUNNEL6 769
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARPHRD_FRAD 770  
-#define ARPHRD_SKIP 771  
-#define ARPHRD_LOOPBACK 772  
-#define ARPHRD_LOCALTLK 773  
+#define ARPHRD_FRAD 770
+#define ARPHRD_SKIP 771
+#define ARPHRD_LOOPBACK 772
+#define ARPHRD_LOCALTLK 773
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARPHRD_FDDI 774  
-#define ARPHRD_BIF 775  
-#define ARPHRD_SIT 776  
-#define ARPHRD_IPDDP 777  
+#define ARPHRD_FDDI 774
+#define ARPHRD_BIF 775
+#define ARPHRD_SIT 776
+#define ARPHRD_IPDDP 777
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARPHRD_IPGRE 778  
-#define ARPHRD_PIMREG 779  
-#define ARPHRD_HIPPI 780  
-#define ARPHRD_ASH 781  
+#define ARPHRD_IPGRE 778
+#define ARPHRD_PIMREG 779
+#define ARPHRD_HIPPI 780
+#define ARPHRD_ASH 781
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARPHRD_ECONET 782  
-#define ARPHRD_IRDA 783  
-#define ARPHRD_FCPP 784  
-#define ARPHRD_FCAL 785  
+#define ARPHRD_ECONET 782
+#define ARPHRD_IRDA 783
+#define ARPHRD_FCPP 784
+#define ARPHRD_FCAL 785
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARPHRD_FCPL 786  
-#define ARPHRD_FCFABRIC 787  
-#define ARPHRD_IEEE802_TR 800  
-#define ARPHRD_IEEE80211 801  
+#define ARPHRD_FCPL 786
+#define ARPHRD_FCFABRIC 787
+#define ARPHRD_IEEE802_TR 800
+#define ARPHRD_IEEE80211 801
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARPHRD_IEEE80211_PRISM 802  
-#define ARPHRD_IEEE80211_RADIOTAP 803  
+#define ARPHRD_IEEE80211_PRISM 802
+#define ARPHRD_IEEE80211_RADIOTAP 803
 #define ARPHRD_IEEE802154 804
-#define ARPHRD_PHONET 820  
+#define ARPHRD_PHONET 820
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARPHRD_PHONET_PIPE 821  
-#define ARPHRD_CAIF 822  
-#define ARPHRD_VOID 0xFFFF  
-#define ARPHRD_NONE 0xFFFE  
+#define ARPHRD_PHONET_PIPE 821
+#define ARPHRD_CAIF 822
+#define ARPHRD_VOID 0xFFFF
+#define ARPHRD_NONE 0xFFFE
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARPOP_REQUEST 1  
-#define ARPOP_REPLY 2  
-#define ARPOP_RREQUEST 3  
-#define ARPOP_RREPLY 4  
+#define ARPOP_REQUEST 1
+#define ARPOP_REPLY 2
+#define ARPOP_RREQUEST 3
+#define ARPOP_RREPLY 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARPOP_InREQUEST 8  
-#define ARPOP_InREPLY 9  
-#define ARPOP_NAK 10  
+#define ARPOP_InREQUEST 8
+#define ARPOP_InREPLY 9
+#define ARPOP_NAK 10
 struct arpreq {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  struct sockaddr arp_pa;
@@ -121,13 +121,13 @@
  struct sockaddr arp_netmask;
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATF_COM 0x02  
-#define ATF_PERM 0x04  
-#define ATF_PUBL 0x08  
-#define ATF_USETRAILERS 0x10  
+#define ATF_COM 0x02
+#define ATF_PERM 0x04
+#define ATF_PUBL 0x08
+#define ATF_USETRAILERS 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATF_NETMASK 0x20  
-#define ATF_DONTPUB 0x40  
+#define ATF_NETMASK 0x20
+#define ATF_DONTPUB 0x40
 struct arphdr {
  __be16 ar_hrd;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/if_ether.h b/libc/kernel/common/linux/if_ether.h
index a82414f..9113b07 100644
--- a/libc/kernel/common/linux/if_ether.h
+++ b/libc/kernel/common/linux/if_ether.h
@@ -19,92 +19,92 @@
 #ifndef _LINUX_IF_ETHER_H
 #define _LINUX_IF_ETHER_H
 #include <linux/types.h>
-#define ETH_ALEN 6  
+#define ETH_ALEN 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETH_HLEN 14  
-#define ETH_ZLEN 60  
-#define ETH_DATA_LEN 1500  
-#define ETH_FRAME_LEN 1514  
+#define ETH_HLEN 14
+#define ETH_ZLEN 60
+#define ETH_DATA_LEN 1500
+#define ETH_FRAME_LEN 1514
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETH_FCS_LEN 4  
-#define ETH_P_LOOP 0x0060  
-#define ETH_P_PUP 0x0200  
-#define ETH_P_PUPAT 0x0201  
+#define ETH_FCS_LEN 4
+#define ETH_P_LOOP 0x0060
+#define ETH_P_PUP 0x0200
+#define ETH_P_PUPAT 0x0201
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETH_P_IP 0x0800  
-#define ETH_P_X25 0x0805  
-#define ETH_P_ARP 0x0806  
-#define ETH_P_BPQ 0x08FF  
+#define ETH_P_IP 0x0800
+#define ETH_P_X25 0x0805
+#define ETH_P_ARP 0x0806
+#define ETH_P_BPQ 0x08FF
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETH_P_IEEEPUP 0x0a00  
-#define ETH_P_IEEEPUPAT 0x0a01  
-#define ETH_P_DEC 0x6000  
-#define ETH_P_DNA_DL 0x6001  
+#define ETH_P_IEEEPUP 0x0a00
+#define ETH_P_IEEEPUPAT 0x0a01
+#define ETH_P_DEC 0x6000
+#define ETH_P_DNA_DL 0x6001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETH_P_DNA_RC 0x6002  
-#define ETH_P_DNA_RT 0x6003  
-#define ETH_P_LAT 0x6004  
-#define ETH_P_DIAG 0x6005  
+#define ETH_P_DNA_RC 0x6002
+#define ETH_P_DNA_RT 0x6003
+#define ETH_P_LAT 0x6004
+#define ETH_P_DIAG 0x6005
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETH_P_CUST 0x6006  
-#define ETH_P_SCA 0x6007  
-#define ETH_P_TEB 0x6558  
-#define ETH_P_RARP 0x8035  
+#define ETH_P_CUST 0x6006
+#define ETH_P_SCA 0x6007
+#define ETH_P_TEB 0x6558
+#define ETH_P_RARP 0x8035
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETH_P_ATALK 0x809B  
-#define ETH_P_AARP 0x80F3  
-#define ETH_P_8021Q 0x8100  
-#define ETH_P_IPX 0x8137  
+#define ETH_P_ATALK 0x809B
+#define ETH_P_AARP 0x80F3
+#define ETH_P_8021Q 0x8100
+#define ETH_P_IPX 0x8137
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETH_P_IPV6 0x86DD  
-#define ETH_P_PAUSE 0x8808  
-#define ETH_P_SLOW 0x8809  
-#define ETH_P_WCCP 0x883E  
+#define ETH_P_IPV6 0x86DD
+#define ETH_P_PAUSE 0x8808
+#define ETH_P_SLOW 0x8809
+#define ETH_P_WCCP 0x883E
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETH_P_PPP_DISC 0x8863  
-#define ETH_P_PPP_SES 0x8864  
-#define ETH_P_MPLS_UC 0x8847  
-#define ETH_P_MPLS_MC 0x8848  
+#define ETH_P_PPP_DISC 0x8863
+#define ETH_P_PPP_SES 0x8864
+#define ETH_P_MPLS_UC 0x8847
+#define ETH_P_MPLS_MC 0x8848
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETH_P_ATMMPOA 0x884c  
-#define ETH_P_ATMFATE 0x8884  
-#define ETH_P_PAE 0x888E  
-#define ETH_P_AOE 0x88A2  
+#define ETH_P_ATMMPOA 0x884c
+#define ETH_P_ATMFATE 0x8884
+#define ETH_P_PAE 0x888E
+#define ETH_P_AOE 0x88A2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETH_P_TIPC 0x88CA  
-#define ETH_P_1588 0x88F7  
-#define ETH_P_FCOE 0x8906  
-#define ETH_P_FIP 0x8914  
+#define ETH_P_TIPC 0x88CA
+#define ETH_P_1588 0x88F7
+#define ETH_P_FCOE 0x8906
+#define ETH_P_FIP 0x8914
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETH_P_EDSA 0xDADA  
-#define ETH_P_802_3 0x0001  
-#define ETH_P_AX25 0x0002  
-#define ETH_P_ALL 0x0003  
+#define ETH_P_EDSA 0xDADA
+#define ETH_P_802_3 0x0001
+#define ETH_P_AX25 0x0002
+#define ETH_P_ALL 0x0003
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETH_P_802_2 0x0004  
-#define ETH_P_SNAP 0x0005  
-#define ETH_P_DDCMP 0x0006  
-#define ETH_P_WAN_PPP 0x0007  
+#define ETH_P_802_2 0x0004
+#define ETH_P_SNAP 0x0005
+#define ETH_P_DDCMP 0x0006
+#define ETH_P_WAN_PPP 0x0007
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETH_P_PPP_MP 0x0008  
-#define ETH_P_LOCALTALK 0x0009  
-#define ETH_P_CAN 0x000C  
-#define ETH_P_PPPTALK 0x0010  
+#define ETH_P_PPP_MP 0x0008
+#define ETH_P_LOCALTALK 0x0009
+#define ETH_P_CAN 0x000C
+#define ETH_P_PPPTALK 0x0010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETH_P_TR_802_2 0x0011  
-#define ETH_P_MOBITEX 0x0015  
-#define ETH_P_CONTROL 0x0016  
-#define ETH_P_IRDA 0x0017  
+#define ETH_P_TR_802_2 0x0011
+#define ETH_P_MOBITEX 0x0015
+#define ETH_P_CONTROL 0x0016
+#define ETH_P_IRDA 0x0017
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETH_P_ECONET 0x0018  
-#define ETH_P_HDLC 0x0019  
-#define ETH_P_ARCNET 0x001A  
-#define ETH_P_DSA 0x001B  
+#define ETH_P_ECONET 0x0018
+#define ETH_P_HDLC 0x0019
+#define ETH_P_ARCNET 0x001A
+#define ETH_P_DSA 0x001B
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ETH_P_TRAILER 0x001C  
-#define ETH_P_PHONET 0x00F5  
-#define ETH_P_IEEE802154 0x00F6  
-#define ETH_P_CAIF 0x00F7  
+#define ETH_P_TRAILER 0x001C
+#define ETH_P_PHONET 0x00F5
+#define ETH_P_IEEE802154 0x00F6
+#define ETH_P_CAIF 0x00F7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ethhdr {
  unsigned char h_dest[ETH_ALEN];
diff --git a/libc/kernel/common/linux/if_fc.h b/libc/kernel/common/linux/if_fc.h
index 8c4152b..fc07ae0 100644
--- a/libc/kernel/common/linux/if_fc.h
+++ b/libc/kernel/common/linux/if_fc.h
@@ -18,10 +18,10 @@
  ****************************************************************************/
 #ifndef _LINUX_IF_FC_H
 #define _LINUX_IF_FC_H
-#define FC_ALEN 6  
+#define FC_ALEN 6
 #define FC_HLEN (sizeof(struct fch_hdr)+sizeof(struct fcllc))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FC_ID_LEN 3  
+#define FC_ID_LEN 3
 #define EXTENDED_SAP 0xAA
 #define UI_CMD 0x03
 struct fch_hdr {
diff --git a/libc/kernel/common/linux/if_fddi.h b/libc/kernel/common/linux/if_fddi.h
index e03e519..fa6c762 100644
--- a/libc/kernel/common/linux/if_fddi.h
+++ b/libc/kernel/common/linux/if_fddi.h
@@ -18,26 +18,26 @@
  ****************************************************************************/
 #ifndef _LINUX_IF_FDDI_H
 #define _LINUX_IF_FDDI_H
-#define FDDI_K_ALEN 6  
-#define FDDI_K_8022_HLEN 16  
+#define FDDI_K_ALEN 6
+#define FDDI_K_8022_HLEN 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FDDI_K_SNAP_HLEN 21  
-#define FDDI_K_8022_ZLEN 16  
-#define FDDI_K_SNAP_ZLEN 21  
-#define FDDI_K_8022_DLEN 4475  
+#define FDDI_K_SNAP_HLEN 21
+#define FDDI_K_8022_ZLEN 16
+#define FDDI_K_SNAP_ZLEN 21
+#define FDDI_K_8022_DLEN 4475
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FDDI_K_SNAP_DLEN 4470  
-#define FDDI_K_LLC_ZLEN 13  
-#define FDDI_K_LLC_LEN 4491  
-#define FDDI_FC_K_VOID 0x00 
+#define FDDI_K_SNAP_DLEN 4470
+#define FDDI_K_LLC_ZLEN 13
+#define FDDI_K_LLC_LEN 4491
+#define FDDI_FC_K_VOID 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FDDI_FC_K_NON_RESTRICTED_TOKEN 0x80 
-#define FDDI_FC_K_RESTRICTED_TOKEN 0xC0 
+#define FDDI_FC_K_NON_RESTRICTED_TOKEN 0x80
+#define FDDI_FC_K_RESTRICTED_TOKEN 0xC0
 #define FDDI_FC_K_SMT_MIN 0x41
 #define FDDI_FC_K_SMT_MAX 0x4F
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FDDI_FC_K_MAC_MIN 0xC1
-#define FDDI_FC_K_MAC_MAX 0xCF 
+#define FDDI_FC_K_MAC_MAX 0xCF
 #define FDDI_FC_K_ASYNC_LLC_MIN 0x50
 #define FDDI_FC_K_ASYNC_LLC_DEF 0x54
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/if_hippi.h b/libc/kernel/common/linux/if_hippi.h
index a25e972..b4596ce 100644
--- a/libc/kernel/common/linux/if_hippi.h
+++ b/libc/kernel/common/linux/if_hippi.h
@@ -19,11 +19,11 @@
 #ifndef _LINUX_IF_HIPPI_H
 #define _LINUX_IF_HIPPI_H
 #include <asm/byteorder.h>
-#define HIPPI_ALEN 6  
+#define HIPPI_ALEN 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HIPPI_HLEN sizeof(struct hippi_hdr)
-#define HIPPI_ZLEN 0  
-#define HIPPI_DATA_LEN 65280  
+#define HIPPI_ZLEN 0
+#define HIPPI_DATA_LEN 65280
 #define HIPPI_FRAME_LEN (HIPPI_DATA_LEN + HIPPI_HLEN)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HIPPI_EXTENDED_SAP 0xAA
diff --git a/libc/kernel/common/linux/if_packet.h b/libc/kernel/common/linux/if_packet.h
index 387c59c..c528cdf 100644
--- a/libc/kernel/common/linux/if_packet.h
+++ b/libc/kernel/common/linux/if_packet.h
@@ -38,15 +38,15 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned char sll_addr[8];
 };
-#define PACKET_HOST 0  
-#define PACKET_BROADCAST 1  
+#define PACKET_HOST 0
+#define PACKET_BROADCAST 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PACKET_MULTICAST 2  
-#define PACKET_OTHERHOST 3  
-#define PACKET_OUTGOING 4  
-#define PACKET_LOOPBACK 5  
+#define PACKET_MULTICAST 2
+#define PACKET_OTHERHOST 3
+#define PACKET_OUTGOING 4
+#define PACKET_LOOPBACK 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PACKET_FASTROUTE 6  
+#define PACKET_FASTROUTE 6
 #define PACKET_ADD_MEMBERSHIP 1
 #define PACKET_DROP_MEMBERSHIP 2
 #define PACKET_RECV_OUTPUT 3
diff --git a/libc/kernel/common/linux/if_ppp.h b/libc/kernel/common/linux/if_ppp.h
index 7237a40..20627c6 100644
--- a/libc/kernel/common/linux/if_ppp.h
+++ b/libc/kernel/common/linux/if_ppp.h
@@ -19,49 +19,49 @@
 #ifndef _IF_PPP_H_
 #define _IF_PPP_H_
 #include <linux/compiler.h>
-#define PPP_MTU 1500  
+#define PPP_MTU 1500
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PPP_MAXMRU 65000  
-#define PROTO_IPX 0x002b  
-#define PROTO_DNA_RT 0x0027  
-#define SC_COMP_PROT 0x00000001  
+#define PPP_MAXMRU 65000
+#define PROTO_IPX 0x002b
+#define PROTO_DNA_RT 0x0027
+#define SC_COMP_PROT 0x00000001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SC_COMP_AC 0x00000002  
-#define SC_COMP_TCP 0x00000004  
-#define SC_NO_TCP_CCID 0x00000008  
-#define SC_REJ_COMP_AC 0x00000010  
+#define SC_COMP_AC 0x00000002
+#define SC_COMP_TCP 0x00000004
+#define SC_NO_TCP_CCID 0x00000008
+#define SC_REJ_COMP_AC 0x00000010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SC_REJ_COMP_TCP 0x00000020  
-#define SC_CCP_OPEN 0x00000040  
-#define SC_CCP_UP 0x00000080  
-#define SC_ENABLE_IP 0x00000100  
+#define SC_REJ_COMP_TCP 0x00000020
+#define SC_CCP_OPEN 0x00000040
+#define SC_CCP_UP 0x00000080
+#define SC_ENABLE_IP 0x00000100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SC_LOOP_TRAFFIC 0x00000200  
-#define SC_MULTILINK 0x00000400  
-#define SC_MP_SHORTSEQ 0x00000800  
-#define SC_COMP_RUN 0x00001000  
+#define SC_LOOP_TRAFFIC 0x00000200
+#define SC_MULTILINK 0x00000400
+#define SC_MP_SHORTSEQ 0x00000800
+#define SC_COMP_RUN 0x00001000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SC_DECOMP_RUN 0x00002000  
-#define SC_MP_XSHORTSEQ 0x00004000  
-#define SC_DEBUG 0x00010000  
-#define SC_LOG_INPKT 0x00020000  
+#define SC_DECOMP_RUN 0x00002000
+#define SC_MP_XSHORTSEQ 0x00004000
+#define SC_DEBUG 0x00010000
+#define SC_LOG_INPKT 0x00020000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SC_LOG_OUTPKT 0x00040000  
-#define SC_LOG_RAWIN 0x00080000  
-#define SC_LOG_FLUSH 0x00100000  
-#define SC_SYNC 0x00200000  
+#define SC_LOG_OUTPKT 0x00040000
+#define SC_LOG_RAWIN 0x00080000
+#define SC_LOG_FLUSH 0x00100000
+#define SC_SYNC 0x00200000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SC_MUST_COMP 0x00400000  
-#define SC_MASK 0x0f600fff  
-#define SC_XMIT_BUSY 0x10000000  
-#define SC_RCV_ODDP 0x08000000  
+#define SC_MUST_COMP 0x00400000
+#define SC_MASK 0x0f600fff
+#define SC_XMIT_BUSY 0x10000000
+#define SC_RCV_ODDP 0x08000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SC_RCV_EVNP 0x04000000  
-#define SC_RCV_B7_1 0x02000000  
-#define SC_RCV_B7_0 0x01000000  
-#define SC_DC_FERROR 0x00800000  
+#define SC_RCV_EVNP 0x04000000
+#define SC_RCV_B7_1 0x02000000
+#define SC_RCV_B7_0 0x01000000
+#define SC_DC_FERROR 0x00800000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SC_DC_ERROR 0x00400000  
+#define SC_DC_ERROR 0x00400000
 struct npioctl {
  int protocol;
  enum NPmode mode;
@@ -86,44 +86,44 @@
 #define ifr__name b.ifr_ifrn.ifrn_name
 #define stats_ptr b.ifr_ifru.ifru_data
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PPPIOCGFLAGS _IOR('t', 90, int)  
-#define PPPIOCSFLAGS _IOW('t', 89, int)  
-#define PPPIOCGASYNCMAP _IOR('t', 88, int)  
-#define PPPIOCSASYNCMAP _IOW('t', 87, int)  
+#define PPPIOCGFLAGS _IOR('t', 90, int)
+#define PPPIOCSFLAGS _IOW('t', 89, int)
+#define PPPIOCGASYNCMAP _IOR('t', 88, int)
+#define PPPIOCSASYNCMAP _IOW('t', 87, int)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PPPIOCGUNIT _IOR('t', 86, int)  
-#define PPPIOCGRASYNCMAP _IOR('t', 85, int)  
-#define PPPIOCSRASYNCMAP _IOW('t', 84, int)  
-#define PPPIOCGMRU _IOR('t', 83, int)  
+#define PPPIOCGUNIT _IOR('t', 86, int)
+#define PPPIOCGRASYNCMAP _IOR('t', 85, int)
+#define PPPIOCSRASYNCMAP _IOW('t', 84, int)
+#define PPPIOCGMRU _IOR('t', 83, int)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PPPIOCSMRU _IOW('t', 82, int)  
-#define PPPIOCSMAXCID _IOW('t', 81, int)  
-#define PPPIOCGXASYNCMAP _IOR('t', 80, ext_accm)  
-#define PPPIOCSXASYNCMAP _IOW('t', 79, ext_accm)  
+#define PPPIOCSMRU _IOW('t', 82, int)
+#define PPPIOCSMAXCID _IOW('t', 81, int)
+#define PPPIOCGXASYNCMAP _IOR('t', 80, ext_accm)
+#define PPPIOCSXASYNCMAP _IOW('t', 79, ext_accm)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PPPIOCXFERUNIT _IO('t', 78)  
+#define PPPIOCXFERUNIT _IO('t', 78)
 #define PPPIOCSCOMPRESS _IOW('t', 77, struct ppp_option_data)
-#define PPPIOCGNPMODE _IOWR('t', 76, struct npioctl)  
-#define PPPIOCSNPMODE _IOW('t', 75, struct npioctl)  
+#define PPPIOCGNPMODE _IOWR('t', 76, struct npioctl)
+#define PPPIOCSNPMODE _IOW('t', 75, struct npioctl)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PPPIOCSPASS _IOW('t', 71, struct sock_fprog)  
-#define PPPIOCSACTIVE _IOW('t', 70, struct sock_fprog)  
-#define PPPIOCGDEBUG _IOR('t', 65, int)  
-#define PPPIOCSDEBUG _IOW('t', 64, int)  
+#define PPPIOCSPASS _IOW('t', 71, struct sock_fprog)
+#define PPPIOCSACTIVE _IOW('t', 70, struct sock_fprog)
+#define PPPIOCGDEBUG _IOR('t', 65, int)
+#define PPPIOCSDEBUG _IOW('t', 64, int)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PPPIOCGIDLE _IOR('t', 63, struct ppp_idle)  
-#define PPPIOCNEWUNIT _IOWR('t', 62, int)  
-#define PPPIOCATTACH _IOW('t', 61, int)  
-#define PPPIOCDETACH _IOW('t', 60, int)  
+#define PPPIOCGIDLE _IOR('t', 63, struct ppp_idle)
+#define PPPIOCNEWUNIT _IOWR('t', 62, int)
+#define PPPIOCATTACH _IOW('t', 61, int)
+#define PPPIOCDETACH _IOW('t', 60, int)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PPPIOCSMRRU _IOW('t', 59, int)  
-#define PPPIOCCONNECT _IOW('t', 58, int)  
-#define PPPIOCDISCONN _IO('t', 57)  
-#define PPPIOCATTCHAN _IOW('t', 56, int)  
+#define PPPIOCSMRRU _IOW('t', 59, int)
+#define PPPIOCCONNECT _IOW('t', 58, int)
+#define PPPIOCDISCONN _IO('t', 57)
+#define PPPIOCATTCHAN _IOW('t', 56, int)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PPPIOCGCHAN _IOR('t', 55, int)  
+#define PPPIOCGCHAN _IOR('t', 55, int)
 #define SIOCGPPPSTATS (SIOCDEVPRIVATE + 0)
-#define SIOCGPPPVER (SIOCDEVPRIVATE + 1)  
+#define SIOCGPPPVER (SIOCDEVPRIVATE + 1)
 #define SIOCGPPPCSTATS (SIOCDEVPRIVATE + 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifndef ifr_mtu
diff --git a/libc/kernel/common/linux/if_pppox.h b/libc/kernel/common/linux/if_pppox.h
index 47ed22e..26534d7 100644
--- a/libc/kernel/common/linux/if_pppox.h
+++ b/libc/kernel/common/linux/if_pppox.h
@@ -42,8 +42,8 @@
  struct in_addr sin_addr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define PX_PROTO_OE 0  
-#define PX_PROTO_OL2TP 1  
+#define PX_PROTO_OE 0
+#define PX_PROTO_OL2TP 1
 #define PX_PROTO_PPTP 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PX_PROTO_OLAC 3
diff --git a/libc/kernel/common/linux/if_tr.h b/libc/kernel/common/linux/if_tr.h
index 7e97d51..4b16c02 100644
--- a/libc/kernel/common/linux/if_tr.h
+++ b/libc/kernel/common/linux/if_tr.h
@@ -18,8 +18,8 @@
  ****************************************************************************/
 #ifndef _LINUX_IF_TR_H
 #define _LINUX_IF_TR_H
-#include <asm/byteorder.h>  
-#define TR_ALEN 6  
+#include <asm/byteorder.h>
+#define TR_ALEN 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TR_HLEN (sizeof(struct trh_hdr)+sizeof(struct trllc))
 #define AC 0x10
@@ -78,8 +78,8 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TR_RCF_DIR_BIT 0x80
 #define TR_RCF_LEN_MASK 0x1f00
-#define TR_RCF_BROADCAST 0x8000  
-#define TR_RCF_LIMITED_BROADCAST 0xC000  
+#define TR_RCF_BROADCAST 0x8000
+#define TR_RCF_LIMITED_BROADCAST 0xC000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TR_RCF_FRAME2K 0x20
 #define TR_RCF_BROADCAST_MASK 0xC000
diff --git a/libc/kernel/common/linux/if_tun.h b/libc/kernel/common/linux/if_tun.h
index c3ee0c0..3b54833 100644
--- a/libc/kernel/common/linux/if_tun.h
+++ b/libc/kernel/common/linux/if_tun.h
@@ -23,7 +23,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <linux/filter.h>
 #define TUN_READQ_SIZE 500
-#define TUN_TUN_DEV 0x0001 
+#define TUN_TUN_DEV 0x0001
 #define TUN_TAP_DEV 0x0002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TUN_TYPE_MASK 0x000f
@@ -32,13 +32,13 @@
 #define TUN_NO_PI 0x0040
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TUN_ONE_QUEUE 0x0080
-#define TUN_PERSIST 0x0100 
+#define TUN_PERSIST 0x0100
 #define TUN_VNET_HDR 0x0200
-#define TUNSETNOCSUM _IOW('T', 200, int) 
+#define TUNSETNOCSUM _IOW('T', 200, int)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TUNSETDEBUG _IOW('T', 201, int) 
-#define TUNSETIFF _IOW('T', 202, int) 
-#define TUNSETPERSIST _IOW('T', 203, int) 
+#define TUNSETDEBUG _IOW('T', 201, int)
+#define TUNSETIFF _IOW('T', 202, int)
+#define TUNSETPERSIST _IOW('T', 203, int)
 #define TUNSETOWNER _IOW('T', 204, int)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TUNSETLINK _IOW('T', 205, int)
@@ -63,12 +63,12 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IFF_VNET_HDR 0x4000
 #define IFF_TUN_EXCL 0x8000
-#define TUN_F_CSUM 0x01  
-#define TUN_F_TSO4 0x02  
+#define TUN_F_CSUM 0x01
+#define TUN_F_TSO4 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TUN_F_TSO6 0x04  
-#define TUN_F_TSO_ECN 0x08  
-#define TUN_F_UFO 0x10  
+#define TUN_F_TSO6 0x04
+#define TUN_F_TSO_ECN 0x08
+#define TUN_F_UFO 0x10
 #define TUN_PKT_STRIP 0x0001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct tun_pi {
@@ -76,7 +76,7 @@
  __be16 proto;
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TUN_FLT_ALLMULTI 0x0001  
+#define TUN_FLT_ALLMULTI 0x0001
 struct tun_filter {
  __u16 flags;
  __u16 count;
diff --git a/libc/kernel/common/linux/in.h b/libc/kernel/common/linux/in.h
index 7fb0cad..f9a9c7f 100644
--- a/libc/kernel/common/linux/in.h
+++ b/libc/kernel/common/linux/in.h
@@ -76,9 +76,9 @@
 #define IP_PASSSEC 18
 #define IP_RECVRETOPTS IP_RETOPTS
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IP_PMTUDISC_DONT 0  
-#define IP_PMTUDISC_WANT 1  
-#define IP_PMTUDISC_DO 2  
+#define IP_PMTUDISC_DONT 0
+#define IP_PMTUDISC_WANT 1
+#define IP_PMTUDISC_DO 2
 #define IP_MULTICAST_IF 32
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IP_MULTICAST_TTL 33
@@ -168,7 +168,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  struct in_addr ipi_addr;
 };
-#define __SOCK_SIZE__ 16  
+#define __SOCK_SIZE__ 16
 struct sockaddr_in {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  sa_family_t sin_family;
@@ -178,7 +178,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  sizeof(unsigned short int) - sizeof(struct in_addr)];
 };
-#define sin_zero __pad  
+#define sin_zero __pad
 #define IN_CLASSA(a) ((((long int) (a)) & 0x80000000) == 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IN_CLASSA_NET 0xff000000
@@ -208,13 +208,13 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define INADDR_NONE ((unsigned long int) 0xffffffff)
 #define IN_LOOPBACKNET 127
-#define INADDR_LOOPBACK 0x7f000001  
+#define INADDR_LOOPBACK 0x7f000001
 #define IN_LOOPBACK(a) ((((long int) (a)) & 0xff000000) == 0x7f000000)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define INADDR_UNSPEC_GROUP 0xe0000000U  
-#define INADDR_ALLHOSTS_GROUP 0xe0000001U  
-#define INADDR_ALLRTRS_GROUP 0xe0000002U  
-#define INADDR_MAX_LOCAL_GROUP 0xe00000ffU  
+#define INADDR_UNSPEC_GROUP 0xe0000000U
+#define INADDR_ALLHOSTS_GROUP 0xe0000001U
+#define INADDR_ALLRTRS_GROUP 0xe0000002U
+#define INADDR_MAX_LOCAL_GROUP 0xe00000ffU
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#include <asm/byteorder.h> 
+#include <asm/byteorder.h>
 #endif
diff --git a/libc/kernel/common/linux/in6.h b/libc/kernel/common/linux/in6.h
index a876669..f785417 100644
--- a/libc/kernel/common/linux/in6.h
+++ b/libc/kernel/common/linux/in6.h
@@ -94,21 +94,21 @@
 #define IPV6_PRIORITY_13 0x0d00
 #define IPV6_PRIORITY_14 0x0e00
 #define IPV6_PRIORITY_15 0x0f00
-#define IPPROTO_HOPOPTS 0  
+#define IPPROTO_HOPOPTS 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IPPROTO_ROUTING 43  
-#define IPPROTO_FRAGMENT 44  
-#define IPPROTO_ICMPV6 58  
-#define IPPROTO_NONE 59  
+#define IPPROTO_ROUTING 43
+#define IPPROTO_FRAGMENT 44
+#define IPPROTO_ICMPV6 58
+#define IPPROTO_NONE 59
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IPPROTO_DSTOPTS 60  
-#define IPPROTO_MH 135  
+#define IPPROTO_DSTOPTS 60
+#define IPPROTO_MH 135
 #define IPV6_TLV_PAD0 0
 #define IPV6_TLV_PADN 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IPV6_TLV_ROUTERALERT 5
 #define IPV6_TLV_JUMBO 194
-#define IPV6_TLV_HAO 201  
+#define IPV6_TLV_HAO 201
 #define IPV6_ADDRFORM 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IPV6_2292PKTINFO 2
@@ -121,7 +121,7 @@
 #define IPV6_2292HOPLIMIT 8
 #define IPV6_NEXTHOP 9
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IPV6_AUTHHDR 10  
+#define IPV6_AUTHHDR 10
 #define IPV6_FLOWINFO 11
 #define IPV6_UNICAST_HOPS 16
 #define IPV6_MULTICAST_IF 17
diff --git a/libc/kernel/common/linux/in_route.h b/libc/kernel/common/linux/in_route.h
index 0c8ca25..50913a9 100644
--- a/libc/kernel/common/linux/in_route.h
+++ b/libc/kernel/common/linux/in_route.h
@@ -23,13 +23,13 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTCF_NOPMTUDISC RTM_F_NOPMTUDISC
 #define RTCF_NOTIFY 0x00010000
-#define RTCF_DIRECTDST 0x00020000  
+#define RTCF_DIRECTDST 0x00020000
 #define RTCF_REDIRECTED 0x00040000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RTCF_TPROXY 0x00080000  
-#define RTCF_FAST 0x00200000  
-#define RTCF_MASQ 0x00400000  
-#define RTCF_SNAT 0x00800000  
+#define RTCF_TPROXY 0x00080000
+#define RTCF_FAST 0x00200000
+#define RTCF_MASQ 0x00400000
+#define RTCF_SNAT 0x00800000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTCF_DOREDIRECT 0x01000000
 #define RTCF_DIRECTSRC 0x04000000
@@ -37,7 +37,7 @@
 #define RTCF_BROADCAST 0x10000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTCF_MULTICAST 0x20000000
-#define RTCF_REJECT 0x40000000  
+#define RTCF_REJECT 0x40000000
 #define RTCF_LOCAL 0x80000000
 #define RTCF_NAT (RTCF_DNAT|RTCF_SNAT)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/init.h b/libc/kernel/common/linux/init.h
index 1fc24e9..4235efb 100644
--- a/libc/kernel/common/linux/init.h
+++ b/libc/kernel/common/linux/init.h
@@ -87,11 +87,11 @@
 #define module_init(initfn)   static inline initcall_t __inittest(void)   { return initfn; }   int init_module(void) __attribute__((alias(#initfn)));
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define module_exit(exitfn)   static inline exitcall_t __exittest(void)   { return exitfn; }   void cleanup_module(void) __attribute__((alias(#exitfn)));
-#define __setup_param(str, unique_id, fn)  
-#define __setup_null_param(str, unique_id)  
-#define __setup(str, func)  
+#define __setup_param(str, unique_id, fn)
+#define __setup_null_param(str, unique_id)
+#define __setup(str, func)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define __obsolete_setup(str)  
+#define __obsolete_setup(str)
 #endif
 #define __nosavedata __attribute__ ((__section__ (".data.nosave")))
 #define __init_or_module __init
diff --git a/libc/kernel/common/linux/inotify.h b/libc/kernel/common/linux/inotify.h
index 860f743..bf5309f 100644
--- a/libc/kernel/common/linux/inotify.h
+++ b/libc/kernel/common/linux/inotify.h
@@ -28,33 +28,33 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  char name[0];
 };
-#define IN_ACCESS 0x00000001  
-#define IN_MODIFY 0x00000002  
+#define IN_ACCESS 0x00000001
+#define IN_MODIFY 0x00000002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IN_ATTRIB 0x00000004  
-#define IN_CLOSE_WRITE 0x00000008  
-#define IN_CLOSE_NOWRITE 0x00000010  
-#define IN_OPEN 0x00000020  
+#define IN_ATTRIB 0x00000004
+#define IN_CLOSE_WRITE 0x00000008
+#define IN_CLOSE_NOWRITE 0x00000010
+#define IN_OPEN 0x00000020
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IN_MOVED_FROM 0x00000040  
-#define IN_MOVED_TO 0x00000080  
-#define IN_CREATE 0x00000100  
-#define IN_DELETE 0x00000200  
+#define IN_MOVED_FROM 0x00000040
+#define IN_MOVED_TO 0x00000080
+#define IN_CREATE 0x00000100
+#define IN_DELETE 0x00000200
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IN_DELETE_SELF 0x00000400  
-#define IN_MOVE_SELF 0x00000800  
-#define IN_UNMOUNT 0x00002000  
-#define IN_Q_OVERFLOW 0x00004000  
+#define IN_DELETE_SELF 0x00000400
+#define IN_MOVE_SELF 0x00000800
+#define IN_UNMOUNT 0x00002000
+#define IN_Q_OVERFLOW 0x00004000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IN_IGNORED 0x00008000  
-#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE)  
-#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO)  
-#define IN_ONLYDIR 0x01000000  
+#define IN_IGNORED 0x00008000
+#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE)
+#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO)
+#define IN_ONLYDIR 0x01000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IN_DONT_FOLLOW 0x02000000  
-#define IN_MASK_ADD 0x20000000  
-#define IN_ISDIR 0x40000000  
-#define IN_ONESHOT 0x80000000  
+#define IN_DONT_FOLLOW 0x02000000
+#define IN_MASK_ADD 0x20000000
+#define IN_ISDIR 0x40000000
+#define IN_ONESHOT 0x80000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IN_ALL_EVENTS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE |   IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM |   IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF |   IN_MOVE_SELF)
 #endif
diff --git a/libc/kernel/common/linux/input.h b/libc/kernel/common/linux/input.h
index 9dc119b..8a76d2a 100644
--- a/libc/kernel/common/linux/input.h
+++ b/libc/kernel/common/linux/input.h
@@ -59,45 +59,45 @@
  __u32 keycode;
  __u8 scancode[32];
 };
-#define EVIOCGVERSION _IOR('E', 0x01, int)  
+#define EVIOCGVERSION _IOR('E', 0x01, int)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EVIOCGID _IOR('E', 0x02, struct input_id)  
-#define EVIOCGREP _IOR('E', 0x03, unsigned int[2])  
-#define EVIOCSREP _IOW('E', 0x03, unsigned int[2])  
-#define EVIOCGKEYCODE _IOR('E', 0x04, unsigned int[2])  
+#define EVIOCGID _IOR('E', 0x02, struct input_id)
+#define EVIOCGREP _IOR('E', 0x03, unsigned int[2])
+#define EVIOCSREP _IOW('E', 0x03, unsigned int[2])
+#define EVIOCGKEYCODE _IOR('E', 0x04, unsigned int[2])
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EVIOCGKEYCODE_V2 _IOR('E', 0x04, struct input_keymap_entry)
-#define EVIOCSKEYCODE _IOW('E', 0x04, unsigned int[2])  
+#define EVIOCSKEYCODE _IOW('E', 0x04, unsigned int[2])
 #define EVIOCSKEYCODE_V2 _IOW('E', 0x04, struct input_keymap_entry)
-#define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len)  
+#define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len)  
-#define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len)  
-#define EVIOCGPROP(len) _IOC(_IOC_READ, 'E', 0x09, len)  
+#define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len)
+#define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len)
+#define EVIOCGPROP(len) _IOC(_IOC_READ, 'E', 0x09, len)
 #define EVIOCGMTSLOTS(len) _IOC(_IOC_READ, 'E', 0x0a, len)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len)  
-#define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len)  
-#define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len)  
-#define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len)  
+#define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len)
+#define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len)
+#define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len)
+#define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + (ev), len)  
-#define EVIOCGABS(abs) _IOR('E', 0x40 + (abs), struct input_absinfo)  
-#define EVIOCSABS(abs) _IOW('E', 0xc0 + (abs), struct input_absinfo)  
-#define EVIOCSFF _IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect))  
+#define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + (ev), len)
+#define EVIOCGABS(abs) _IOR('E', 0x40 + (abs), struct input_absinfo)
+#define EVIOCSABS(abs) _IOW('E', 0xc0 + (abs), struct input_absinfo)
+#define EVIOCSFF _IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EVIOCRMFF _IOW('E', 0x81, int)  
-#define EVIOCGEFFECTS _IOR('E', 0x84, int)  
-#define EVIOCGRAB _IOW('E', 0x90, int)  
-#define EVIOCGSUSPENDBLOCK _IOR('E', 0x91, int)  
+#define EVIOCRMFF _IOW('E', 0x81, int)
+#define EVIOCGEFFECTS _IOR('E', 0x84, int)
+#define EVIOCGRAB _IOW('E', 0x90, int)
+#define EVIOCGSUSPENDBLOCK _IOR('E', 0x91, int)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EVIOCSSUSPENDBLOCK _IOW('E', 0x91, int)  
-#define EVIOCSCLOCKID _IOW('E', 0xa0, int)  
-#define INPUT_PROP_POINTER 0x00  
-#define INPUT_PROP_DIRECT 0x01  
+#define EVIOCSSUSPENDBLOCK _IOW('E', 0x91, int)
+#define EVIOCSCLOCKID _IOW('E', 0xa0, int)
+#define INPUT_PROP_POINTER 0x00
+#define INPUT_PROP_DIRECT 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define INPUT_PROP_BUTTONPAD 0x02  
-#define INPUT_PROP_SEMI_MT 0x03  
+#define INPUT_PROP_BUTTONPAD 0x02
+#define INPUT_PROP_SEMI_MT 0x03
 #define INPUT_PROP_MAX 0x1f
 #define INPUT_PROP_CNT (INPUT_PROP_MAX + 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -267,12 +267,12 @@
 #define KEY_VOLUMEDOWN 114
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_VOLUMEUP 115
-#define KEY_POWER 116  
+#define KEY_POWER 116
 #define KEY_KPEQUAL 117
 #define KEY_KPPLUSMINUS 118
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_PAUSE 119
-#define KEY_SCALE 120  
+#define KEY_SCALE 120
 #define KEY_KPCOMMA 121
 #define KEY_HANGEUL 122
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -283,27 +283,27 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_RIGHTMETA 126
 #define KEY_COMPOSE 127
-#define KEY_STOP 128  
+#define KEY_STOP 128
 #define KEY_AGAIN 129
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_PROPS 130  
-#define KEY_UNDO 131  
+#define KEY_PROPS 130
+#define KEY_UNDO 131
 #define KEY_FRONT 132
-#define KEY_COPY 133  
+#define KEY_COPY 133
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_OPEN 134  
-#define KEY_PASTE 135  
-#define KEY_FIND 136  
-#define KEY_CUT 137  
+#define KEY_OPEN 134
+#define KEY_PASTE 135
+#define KEY_FIND 136
+#define KEY_CUT 137
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_HELP 138  
-#define KEY_MENU 139  
-#define KEY_CALC 140  
+#define KEY_HELP 138
+#define KEY_MENU 139
+#define KEY_CALC 140
 #define KEY_SETUP 141
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_SLEEP 142  
-#define KEY_WAKEUP 143  
-#define KEY_FILE 144  
+#define KEY_SLEEP 142
+#define KEY_WAKEUP 143
+#define KEY_FILE 144
 #define KEY_SENDFILE 145
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_DELETEFILE 146
@@ -311,19 +311,19 @@
 #define KEY_PROG1 148
 #define KEY_PROG2 149
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_WWW 150  
+#define KEY_WWW 150
 #define KEY_MSDOS 151
-#define KEY_COFFEE 152  
+#define KEY_COFFEE 152
 #define KEY_SCREENLOCK KEY_COFFEE
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_DIRECTION 153
 #define KEY_CYCLEWINDOWS 154
 #define KEY_MAIL 155
-#define KEY_BOOKMARKS 156  
+#define KEY_BOOKMARKS 156
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_COMPUTER 157
-#define KEY_BACK 158  
-#define KEY_FORWARD 159  
+#define KEY_BACK 158
+#define KEY_FORWARD 159
 #define KEY_CLOSECD 160
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_EJECTCD 161
@@ -336,13 +336,13 @@
 #define KEY_RECORD 167
 #define KEY_REWIND 168
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_PHONE 169  
+#define KEY_PHONE 169
 #define KEY_ISO 170
-#define KEY_CONFIG 171  
-#define KEY_HOMEPAGE 172  
+#define KEY_CONFIG 171
+#define KEY_HOMEPAGE 172
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_REFRESH 173  
-#define KEY_EXIT 174  
+#define KEY_REFRESH 173
+#define KEY_EXIT 174
 #define KEY_MOVE 175
 #define KEY_EDIT 176
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -351,8 +351,8 @@
 #define KEY_KPLEFTPAREN 179
 #define KEY_KPRIGHTPAREN 180
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_NEW 181  
-#define KEY_REDO 182  
+#define KEY_NEW 181
+#define KEY_REDO 182
 #define KEY_F13 183
 #define KEY_F14 184
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -373,15 +373,15 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_PROG3 202
 #define KEY_PROG4 203
-#define KEY_DASHBOARD 204  
+#define KEY_DASHBOARD 204
 #define KEY_SUSPEND 205
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_CLOSE 206  
+#define KEY_CLOSE 206
 #define KEY_PLAY 207
 #define KEY_FASTFORWARD 208
 #define KEY_BASSBOOST 209
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_PRINT 210  
+#define KEY_PRINT 210
 #define KEY_HP 211
 #define KEY_CAMERA 212
 #define KEY_SOUND 213
@@ -392,26 +392,26 @@
 #define KEY_SEARCH 217
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_CONNECT 218
-#define KEY_FINANCE 219  
+#define KEY_FINANCE 219
 #define KEY_SPORT 220
 #define KEY_SHOP 221
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_ALTERASE 222
-#define KEY_CANCEL 223  
+#define KEY_CANCEL 223
 #define KEY_BRIGHTNESSDOWN 224
 #define KEY_BRIGHTNESSUP 225
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_MEDIA 226
-#define KEY_SWITCHVIDEOMODE 227  
+#define KEY_SWITCHVIDEOMODE 227
 #define KEY_KBDILLUMTOGGLE 228
 #define KEY_KBDILLUMDOWN 229
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_KBDILLUMUP 230
-#define KEY_SEND 231  
-#define KEY_REPLY 232  
-#define KEY_FORWARDMAIL 233  
+#define KEY_SEND 231
+#define KEY_REPLY 232
+#define KEY_FORWARDMAIL 233
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_SAVE 234  
+#define KEY_SAVE 234
 #define KEY_DOCUMENTS 235
 #define KEY_BATTERY 236
 #define KEY_BLUETOOTH 237
@@ -419,16 +419,16 @@
 #define KEY_WLAN 238
 #define KEY_UWB 239
 #define KEY_UNKNOWN 240
-#define KEY_VIDEO_NEXT 241  
+#define KEY_VIDEO_NEXT 241
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_VIDEO_PREV 242  
-#define KEY_BRIGHTNESS_CYCLE 243  
-#define KEY_BRIGHTNESS_ZERO 244  
-#define KEY_DISPLAY_OFF 245  
+#define KEY_VIDEO_PREV 242
+#define KEY_BRIGHTNESS_CYCLE 243
+#define KEY_BRIGHTNESS_ZERO 244
+#define KEY_DISPLAY_OFF 245
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_WIMAX 246
-#define KEY_RFKILL 247  
-#define KEY_MICMUTE 248  
+#define KEY_RFKILL 247
+#define KEY_MICMUTE 248
 #define BTN_MISC 0x100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_0 0x100
@@ -503,7 +503,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TOOL_MOUSE 0x146
 #define BTN_TOOL_LENS 0x147
-#define BTN_TOOL_QUINTTAP 0x148  
+#define BTN_TOOL_QUINTTAP 0x148
 #define BTN_TOUCH 0x14a
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_STYLUS 0x14b
@@ -511,7 +511,7 @@
 #define BTN_TOOL_DOUBLETAP 0x14d
 #define BTN_TOOL_TRIPLETAP 0x14e
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BTN_TOOL_QUADTAP 0x14f  
+#define BTN_TOOL_QUADTAP 0x14f
 #define BTN_WHEEL 0x150
 #define BTN_GEAR_DOWN 0x150
 #define BTN_GEAR_UP 0x151
@@ -523,17 +523,17 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_POWER2 0x164
 #define KEY_OPTION 0x165
-#define KEY_INFO 0x166  
+#define KEY_INFO 0x166
 #define KEY_TIME 0x167
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_VENDOR 0x168
 #define KEY_ARCHIVE 0x169
-#define KEY_PROGRAM 0x16a  
+#define KEY_PROGRAM 0x16a
 #define KEY_CHANNEL 0x16b
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_FAVORITES 0x16c
 #define KEY_EPG 0x16d
-#define KEY_PVR 0x16e  
+#define KEY_PVR 0x16e
 #define KEY_MHP 0x16f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_LANGUAGE 0x170
@@ -546,43 +546,43 @@
 #define KEY_KEYBOARD 0x176
 #define KEY_SCREEN 0x177
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_PC 0x178  
-#define KEY_TV 0x179  
-#define KEY_TV2 0x17a  
-#define KEY_VCR 0x17b  
+#define KEY_PC 0x178
+#define KEY_TV 0x179
+#define KEY_TV2 0x17a
+#define KEY_VCR 0x17b
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_VCR2 0x17c  
-#define KEY_SAT 0x17d  
+#define KEY_VCR2 0x17c
+#define KEY_SAT 0x17d
 #define KEY_SAT2 0x17e
-#define KEY_CD 0x17f  
+#define KEY_CD 0x17f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_TAPE 0x180  
+#define KEY_TAPE 0x180
 #define KEY_RADIO 0x181
-#define KEY_TUNER 0x182  
+#define KEY_TUNER 0x182
 #define KEY_PLAYER 0x183
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_TEXT 0x184
-#define KEY_DVD 0x185  
+#define KEY_DVD 0x185
 #define KEY_AUX 0x186
 #define KEY_MP3 0x187
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_AUDIO 0x188  
-#define KEY_VIDEO 0x189  
+#define KEY_AUDIO 0x188
+#define KEY_VIDEO 0x189
 #define KEY_DIRECTORY 0x18a
 #define KEY_LIST 0x18b
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_MEMO 0x18c  
+#define KEY_MEMO 0x18c
 #define KEY_CALENDAR 0x18d
 #define KEY_RED 0x18e
 #define KEY_GREEN 0x18f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_YELLOW 0x190
 #define KEY_BLUE 0x191
-#define KEY_CHANNELUP 0x192  
-#define KEY_CHANNELDOWN 0x193  
+#define KEY_CHANNELUP 0x192
+#define KEY_CHANNELDOWN 0x193
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_FIRST 0x194
-#define KEY_LAST 0x195  
+#define KEY_LAST 0x195
 #define KEY_AB 0x196
 #define KEY_NEXT 0x197
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -596,39 +596,39 @@
 #define KEY_TEEN 0x19e
 #define KEY_TWEN 0x19f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_VIDEOPHONE 0x1a0  
-#define KEY_GAMES 0x1a1  
-#define KEY_ZOOMIN 0x1a2  
-#define KEY_ZOOMOUT 0x1a3  
+#define KEY_VIDEOPHONE 0x1a0
+#define KEY_GAMES 0x1a1
+#define KEY_ZOOMIN 0x1a2
+#define KEY_ZOOMOUT 0x1a3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_ZOOMRESET 0x1a4  
-#define KEY_WORDPROCESSOR 0x1a5  
-#define KEY_EDITOR 0x1a6  
-#define KEY_SPREADSHEET 0x1a7  
+#define KEY_ZOOMRESET 0x1a4
+#define KEY_WORDPROCESSOR 0x1a5
+#define KEY_EDITOR 0x1a6
+#define KEY_SPREADSHEET 0x1a7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_GRAPHICSEDITOR 0x1a8  
-#define KEY_PRESENTATION 0x1a9  
-#define KEY_DATABASE 0x1aa  
-#define KEY_NEWS 0x1ab  
+#define KEY_GRAPHICSEDITOR 0x1a8
+#define KEY_PRESENTATION 0x1a9
+#define KEY_DATABASE 0x1aa
+#define KEY_NEWS 0x1ab
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_VOICEMAIL 0x1ac  
-#define KEY_ADDRESSBOOK 0x1ad  
-#define KEY_MESSENGER 0x1ae  
-#define KEY_DISPLAYTOGGLE 0x1af  
+#define KEY_VOICEMAIL 0x1ac
+#define KEY_ADDRESSBOOK 0x1ad
+#define KEY_MESSENGER 0x1ae
+#define KEY_DISPLAYTOGGLE 0x1af
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_SPELLCHECK 0x1b0  
-#define KEY_LOGOFF 0x1b1  
+#define KEY_SPELLCHECK 0x1b0
+#define KEY_LOGOFF 0x1b1
 #define KEY_DOLLAR 0x1b2
 #define KEY_EURO 0x1b3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_FRAMEBACK 0x1b4  
+#define KEY_FRAMEBACK 0x1b4
 #define KEY_FRAMEFORWARD 0x1b5
-#define KEY_CONTEXT_MENU 0x1b6  
-#define KEY_MEDIA_REPEAT 0x1b7  
+#define KEY_CONTEXT_MENU 0x1b6
+#define KEY_MEDIA_REPEAT 0x1b7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_10CHANNELSUP 0x1b8  
-#define KEY_10CHANNELSDOWN 0x1b9  
-#define KEY_IMAGES 0x1ba  
+#define KEY_10CHANNELSUP 0x1b8
+#define KEY_10CHANNELSDOWN 0x1b9
+#define KEY_IMAGES 0x1ba
 #define KEY_DEL_EOL 0x1c0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_DEL_EOS 0x1c1
@@ -673,8 +673,8 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_BRL_DOT9 0x1f9
 #define KEY_BRL_DOT10 0x1fa
-#define KEY_NUMERIC_0 0x200  
-#define KEY_NUMERIC_1 0x201  
+#define KEY_NUMERIC_0 0x200
+#define KEY_NUMERIC_1 0x201
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_NUMERIC_2 0x202
 #define KEY_NUMERIC_3 0x203
@@ -689,9 +689,9 @@
 #define KEY_NUMERIC_STAR 0x20a
 #define KEY_NUMERIC_POUND 0x20b
 #define KEY_CAMERA_FOCUS 0x210
-#define KEY_WPS_BUTTON 0x211  
+#define KEY_WPS_BUTTON 0x211
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KEY_TOUCHPAD_TOGGLE 0x212  
+#define KEY_TOUCHPAD_TOGGLE 0x212
 #define KEY_TOUCHPAD_ON 0x213
 #define KEY_TOUCHPAD_OFF 0x214
 #define KEY_CAMERA_ZOOMIN 0x215
@@ -804,44 +804,44 @@
 #define ABS_TOOL_WIDTH 0x1c
 #define ABS_VOLUME 0x20
 #define ABS_MISC 0x28
-#define ABS_MT_SLOT 0x2f  
+#define ABS_MT_SLOT 0x2f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ABS_MT_TOUCH_MAJOR 0x30  
-#define ABS_MT_TOUCH_MINOR 0x31  
-#define ABS_MT_WIDTH_MAJOR 0x32  
-#define ABS_MT_WIDTH_MINOR 0x33  
+#define ABS_MT_TOUCH_MAJOR 0x30
+#define ABS_MT_TOUCH_MINOR 0x31
+#define ABS_MT_WIDTH_MAJOR 0x32
+#define ABS_MT_WIDTH_MINOR 0x33
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ABS_MT_ORIENTATION 0x34  
-#define ABS_MT_POSITION_X 0x35  
-#define ABS_MT_POSITION_Y 0x36  
-#define ABS_MT_TOOL_TYPE 0x37  
+#define ABS_MT_ORIENTATION 0x34
+#define ABS_MT_POSITION_X 0x35
+#define ABS_MT_POSITION_Y 0x36
+#define ABS_MT_TOOL_TYPE 0x37
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ABS_MT_BLOB_ID 0x38  
-#define ABS_MT_TRACKING_ID 0x39  
-#define ABS_MT_PRESSURE 0x3a  
-#define ABS_MT_DISTANCE 0x3b  
+#define ABS_MT_BLOB_ID 0x38
+#define ABS_MT_TRACKING_ID 0x39
+#define ABS_MT_PRESSURE 0x3a
+#define ABS_MT_DISTANCE 0x3b
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_MAX 0x3f
 #define ABS_CNT (ABS_MAX+1)
-#define SW_LID 0x00  
-#define SW_TABLET_MODE 0x01  
+#define SW_LID 0x00
+#define SW_TABLET_MODE 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SW_HEADPHONE_INSERT 0x02  
-#define SW_RFKILL_ALL 0x03  
-#define SW_RADIO SW_RFKILL_ALL  
-#define SW_MICROPHONE_INSERT 0x04  
+#define SW_HEADPHONE_INSERT 0x02
+#define SW_RFKILL_ALL 0x03
+#define SW_RADIO SW_RFKILL_ALL
+#define SW_MICROPHONE_INSERT 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SW_DOCK 0x05  
-#define SW_LINEOUT_INSERT 0x06  
-#define SW_JACK_PHYSICAL_INSERT 0x07  
-#define SW_VIDEOOUT_INSERT 0x08  
+#define SW_DOCK 0x05
+#define SW_LINEOUT_INSERT 0x06
+#define SW_JACK_PHYSICAL_INSERT 0x07
+#define SW_VIDEOOUT_INSERT 0x08
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SW_CAMERA_LENS_COVER 0x09  
-#define SW_KEYPAD_SLIDE 0x0a  
-#define SW_FRONT_PROXIMITY 0x0b  
-#define SW_ROTATE_LOCK 0x0c  
+#define SW_CAMERA_LENS_COVER 0x09
+#define SW_KEYPAD_SLIDE 0x0a
+#define SW_FRONT_PROXIMITY 0x0b
+#define SW_ROTATE_LOCK 0x0c
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SW_LINEIN_INSERT 0x0d  
+#define SW_LINEIN_INSERT 0x0d
 #define SW_MAX 0x0f
 #define SW_CNT (SW_MAX+1)
 #define MSC_SERIAL 0x00
diff --git a/libc/kernel/common/linux/ion.h b/libc/kernel/common/linux/ion.h
index ab4f49f..f18939d 100644
--- a/libc/kernel/common/linux/ion.h
+++ b/libc/kernel/common/linux/ion.h
@@ -33,8 +33,8 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ION_HEAP_SYSTEM_CONTIG_MASK (1 << ION_HEAP_TYPE_SYSTEM_CONTIG)
 #define ION_HEAP_CARVEOUT_MASK (1 << ION_HEAP_TYPE_CARVEOUT)
-#define ION_FLAG_CACHED 1  
-#define ION_FLAG_CACHED_NEEDS_SYNC 2  
+#define ION_FLAG_CACHED 1
+#define ION_FLAG_CACHED_NEEDS_SYNC 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ion_allocation_data {
  size_t len;
@@ -69,4 +69,3 @@
 #define ION_IOC_SYNC _IOWR(ION_IOC_MAGIC, 7, struct ion_fd_data)
 #define ION_IOC_CUSTOM _IOWR(ION_IOC_MAGIC, 6, struct ion_custom_data)
 #endif
-
diff --git a/libc/kernel/common/linux/ioport.h b/libc/kernel/common/linux/ioport.h
index cc9006c..51698d2 100644
--- a/libc/kernel/common/linux/ioport.h
+++ b/libc/kernel/common/linux/ioport.h
@@ -36,13 +36,13 @@
  struct pci_dev *dev;
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IORESOURCE_BITS 0x000000ff  
-#define IORESOURCE_IO 0x00000100  
+#define IORESOURCE_BITS 0x000000ff
+#define IORESOURCE_IO 0x00000100
 #define IORESOURCE_MEM 0x00000200
 #define IORESOURCE_IRQ 0x00000400
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IORESOURCE_DMA 0x00000800
-#define IORESOURCE_PREFETCH 0x00001000  
+#define IORESOURCE_PREFETCH 0x00001000
 #define IORESOURCE_READONLY 0x00002000
 #define IORESOURCE_CACHEABLE 0x00004000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -53,7 +53,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IORESOURCE_UNSET 0x20000000
 #define IORESOURCE_AUTO 0x40000000
-#define IORESOURCE_BUSY 0x80000000  
+#define IORESOURCE_BUSY 0x80000000
 #define IORESOURCE_IRQ_HIGHEDGE (1<<0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IORESOURCE_IRQ_LOWEDGE (1<<1)
@@ -76,9 +76,9 @@
 #define IORESOURCE_DMA_TYPEB (2<<6)
 #define IORESOURCE_DMA_TYPEF (3<<6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IORESOURCE_MEM_WRITEABLE (1<<0)  
-#define IORESOURCE_MEM_CACHEABLE (1<<1)  
-#define IORESOURCE_MEM_RANGELENGTH (1<<2)  
+#define IORESOURCE_MEM_WRITEABLE (1<<0)
+#define IORESOURCE_MEM_CACHEABLE (1<<1)
+#define IORESOURCE_MEM_RANGELENGTH (1<<2)
 #define IORESOURCE_MEM_TYPE_MASK (3<<3)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IORESOURCE_MEM_8BIT (0<<3)
@@ -86,12 +86,12 @@
 #define IORESOURCE_MEM_8AND16BIT (2<<3)
 #define IORESOURCE_MEM_32BIT (3<<3)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IORESOURCE_MEM_SHADOWABLE (1<<5)  
+#define IORESOURCE_MEM_SHADOWABLE (1<<5)
 #define IORESOURCE_MEM_EXPANSIONROM (1<<6)
-#define IORESOURCE_ROM_ENABLE (1<<0)  
-#define IORESOURCE_ROM_SHADOW (1<<1)  
+#define IORESOURCE_ROM_ENABLE (1<<0)
+#define IORESOURCE_ROM_SHADOW (1<<1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IORESOURCE_ROM_COPY (1<<2)  
+#define IORESOURCE_ROM_COPY (1<<2)
 #define request_region(start,n,name) __request_region(&ioport_resource, (start), (n), (name))
 #define request_mem_region(start,n,name) __request_region(&iomem_resource, (start), (n), (name))
 #define rename_region(region, newname) do { (region)->name = (newname); } while (0)
diff --git a/libc/kernel/common/linux/ip.h b/libc/kernel/common/linux/ip.h
index 14c3464..16ecb23 100644
--- a/libc/kernel/common/linux/ip.h
+++ b/libc/kernel/common/linux/ip.h
@@ -78,10 +78,10 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IPOPT_EOL IPOPT_END
 #define IPOPT_TS IPOPT_TIMESTAMP
-#define IPOPT_TS_TSONLY 0  
-#define IPOPT_TS_TSANDADDR 1  
+#define IPOPT_TS_TSONLY 0
+#define IPOPT_TS_TSANDADDR 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IPOPT_TS_PRESPEC 3  
+#define IPOPT_TS_PRESPEC 3
 struct iphdr {
 #ifdef __LITTLE_ENDIAN_BITFIELD
  __u8 ihl:4,
diff --git a/libc/kernel/common/linux/ipc.h b/libc/kernel/common/linux/ipc.h
index 290189c..45cd923 100644
--- a/libc/kernel/common/linux/ipc.h
+++ b/libc/kernel/common/linux/ipc.h
@@ -19,7 +19,7 @@
 #ifndef _LINUX_IPC_H
 #define _LINUX_IPC_H
 #include <linux/types.h>
-#define IPC_PRIVATE ((__kernel_key_t) 0) 
+#define IPC_PRIVATE ((__kernel_key_t) 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ipc_perm
 {
@@ -34,18 +34,18 @@
  unsigned short seq;
 };
 #include <asm/ipcbuf.h>
-#define IPC_CREAT 00001000  
+#define IPC_CREAT 00001000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IPC_EXCL 00002000  
-#define IPC_NOWAIT 00004000  
-#define IPC_DIPC 00010000  
-#define IPC_OWN 00020000  
+#define IPC_EXCL 00002000
+#define IPC_NOWAIT 00004000
+#define IPC_DIPC 00010000
+#define IPC_OWN 00020000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IPC_RMID 0  
-#define IPC_SET 1  
-#define IPC_STAT 2  
-#define IPC_INFO 3  
+#define IPC_RMID 0
+#define IPC_SET 1
+#define IPC_STAT 2
+#define IPC_INFO 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IPC_OLD 0  
-#define IPC_64 0x0100  
+#define IPC_OLD 0
+#define IPC_64 0x0100
 #endif
diff --git a/libc/kernel/common/linux/ipmi_msgdefs.h b/libc/kernel/common/linux/ipmi_msgdefs.h
index 33a372c..e2a1674 100644
--- a/libc/kernel/common/linux/ipmi_msgdefs.h
+++ b/libc/kernel/common/linux/ipmi_msgdefs.h
@@ -42,7 +42,7 @@
 #define IPMI_ADD_SEL_ENTRY_CMD 0x44
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IPMI_BMC_SLAVE_ADDR 0x20
-#define IPMI_MAX_MSG_LENGTH 272  
+#define IPMI_MAX_MSG_LENGTH 272
 #define IPMI_CC_NO_ERROR 0x00
 #define IPMI_NODE_BUSY_ERR 0xc0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/ipv6.h b/libc/kernel/common/linux/ipv6.h
index 80d8c80..1e5f618 100644
--- a/libc/kernel/common/linux/ipv6.h
+++ b/libc/kernel/common/linux/ipv6.h
@@ -39,10 +39,10 @@
  __u32 ifr6_prefixlen;
  int ifr6_ifindex;
 };
-#define IPV6_SRCRT_STRICT 0x01  
+#define IPV6_SRCRT_STRICT 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IPV6_SRCRT_TYPE_0 0  
-#define IPV6_SRCRT_TYPE_2 2  
+#define IPV6_SRCRT_TYPE_0 0
+#define IPV6_SRCRT_TYPE_2 2
 struct ipv6_rt_hdr {
  __u8 nexthdr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/ipv6_route.h b/libc/kernel/common/linux/ipv6_route.h
index b6749dc..5e1eb10 100644
--- a/libc/kernel/common/linux/ipv6_route.h
+++ b/libc/kernel/common/linux/ipv6_route.h
@@ -19,20 +19,20 @@
 #ifndef _LINUX_IPV6_ROUTE_H
 #define _LINUX_IPV6_ROUTE_H
 #include <linux/types.h>
-#define RTF_DEFAULT 0x00010000  
+#define RTF_DEFAULT 0x00010000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RTF_ALLONLINK 0x00020000  
-#define RTF_ADDRCONF 0x00040000  
-#define RTF_PREFIX_RT 0x00080000  
-#define RTF_ANYCAST 0x00100000  
+#define RTF_ALLONLINK 0x00020000
+#define RTF_ADDRCONF 0x00040000
+#define RTF_PREFIX_RT 0x00080000
+#define RTF_ANYCAST 0x00100000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RTF_NONEXTHOP 0x00200000  
+#define RTF_NONEXTHOP 0x00200000
 #define RTF_EXPIRES 0x00400000
-#define RTF_ROUTEINFO 0x00800000  
-#define RTF_CACHE 0x01000000  
+#define RTF_ROUTEINFO 0x00800000
+#define RTF_CACHE 0x01000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RTF_FLOW 0x02000000  
-#define RTF_POLICY 0x04000000  
+#define RTF_FLOW 0x02000000
+#define RTF_POLICY 0x04000000
 #define RTF_PREF(pref) ((pref) << 27)
 #define RTF_PREF_MASK 0x18000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/ipx.h b/libc/kernel/common/linux/ipx.h
index 1396988..0f85e5c 100644
--- a/libc/kernel/common/linux/ipx.h
+++ b/libc/kernel/common/linux/ipx.h
@@ -56,7 +56,7 @@
 #define IPX_FRAME_ETHERII 3
 #define IPX_FRAME_8023 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IPX_FRAME_TR_8022 5  
+#define IPX_FRAME_TR_8022 5
  unsigned char ipx_special;
 #define IPX_SPECIAL_NONE 0
 #define IPX_PRIMARY 1
diff --git a/libc/kernel/common/linux/irq.h b/libc/kernel/common/linux/irq.h
index f56a628..86d726e 100644
--- a/libc/kernel/common/linux/irq.h
+++ b/libc/kernel/common/linux/irq.h
@@ -28,35 +28,35 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <asm/irq.h>
 #include <asm/ptrace.h>
-#define IRQ_TYPE_NONE 0x00000000  
-#define IRQ_TYPE_EDGE_RISING 0x00000001  
+#define IRQ_TYPE_NONE 0x00000000
+#define IRQ_TYPE_EDGE_RISING 0x00000001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IRQ_TYPE_EDGE_FALLING 0x00000002  
+#define IRQ_TYPE_EDGE_FALLING 0x00000002
 #define IRQ_TYPE_EDGE_BOTH (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)
-#define IRQ_TYPE_LEVEL_HIGH 0x00000004  
-#define IRQ_TYPE_LEVEL_LOW 0x00000008  
+#define IRQ_TYPE_LEVEL_HIGH 0x00000004
+#define IRQ_TYPE_LEVEL_LOW 0x00000008
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IRQ_TYPE_SENSE_MASK 0x0000000f  
-#define IRQ_TYPE_PROBE 0x00000010  
-#define IRQ_INPROGRESS 0x00010000  
-#define IRQ_DISABLED 0x00020000  
+#define IRQ_TYPE_SENSE_MASK 0x0000000f
+#define IRQ_TYPE_PROBE 0x00000010
+#define IRQ_INPROGRESS 0x00010000
+#define IRQ_DISABLED 0x00020000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IRQ_PENDING 0x00040000  
-#define IRQ_REPLAY 0x00080000  
-#define IRQ_AUTODETECT 0x00100000  
-#define IRQ_WAITING 0x00200000  
+#define IRQ_PENDING 0x00040000
+#define IRQ_REPLAY 0x00080000
+#define IRQ_AUTODETECT 0x00100000
+#define IRQ_WAITING 0x00200000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IRQ_LEVEL 0x00400000  
-#define IRQ_MASKED 0x00800000  
-#define IRQ_PER_CPU 0x01000000  
+#define IRQ_LEVEL 0x00400000
+#define IRQ_MASKED 0x00800000
+#define IRQ_PER_CPU 0x01000000
 #define CHECK_IRQ_PER_CPU(var) 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IRQ_NOPROBE 0x02000000  
-#define IRQ_NOREQUEST 0x04000000  
-#define IRQ_NOAUTOEN 0x08000000  
-#define IRQ_DELAYED_DISABLE 0x10000000  
+#define IRQ_NOPROBE 0x02000000
+#define IRQ_NOREQUEST 0x04000000
+#define IRQ_NOAUTOEN 0x08000000
+#define IRQ_DELAYED_DISABLE 0x10000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IRQ_WAKEUP 0x20000000  
+#define IRQ_WAKEUP 0x20000000
 struct proc_dir_entry;
 struct irq_chip {
  const char *name;
diff --git a/libc/kernel/common/linux/irq_cpustat.h b/libc/kernel/common/linux/irq_cpustat.h
index 2a568cc..f2683d5 100644
--- a/libc/kernel/common/linux/irq_cpustat.h
+++ b/libc/kernel/common/linux/irq_cpustat.h
@@ -23,6 +23,6 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #define local_softirq_pending()   __IRQ_STAT(smp_processor_id(), __softirq_pending)
-#define nmi_count(cpu) __IRQ_STAT((cpu), __nmi_count)  
+#define nmi_count(cpu) __IRQ_STAT((cpu), __nmi_count)
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/jbd.h b/libc/kernel/common/linux/jbd.h
index 89956d7..20cc733 100644
--- a/libc/kernel/common/linux/jbd.h
+++ b/libc/kernel/common/linux/jbd.h
@@ -26,12 +26,12 @@
 #undef JBD_PARANOID_IOFAIL
 #define JBD_DEFAULT_MAX_COMMIT_AGE 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define jbd_debug(f, a...)  
+#define jbd_debug(f, a...)
 #define jbd_kmalloc(size, flags)   __jbd_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry)
 #define jbd_rep_kmalloc(size, flags)   __jbd_kmalloc(__FUNCTION__, (size), (flags), 1)
 #define JFS_MIN_JOURNAL_BLOCKS 1024
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define JFS_MAGIC_NUMBER 0xc03b3998U  
+#define JFS_MAGIC_NUMBER 0xc03b3998U
 #define JFS_DESCRIPTOR_BLOCK 1
 #define JFS_COMMIT_BLOCK 2
 #define JFS_SUPERBLOCK_V1 3
@@ -58,11 +58,11 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __be32 r_count;
 } journal_revoke_header_t;
-#define JFS_FLAG_ESCAPE 1  
-#define JFS_FLAG_SAME_UUID 2  
+#define JFS_FLAG_ESCAPE 1
+#define JFS_FLAG_SAME_UUID 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define JFS_FLAG_DELETED 4  
-#define JFS_FLAG_LAST_TAG 8  
+#define JFS_FLAG_DELETED 4
+#define JFS_FLAG_LAST_TAG 8
 typedef struct journal_superblock_s
 {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -97,17 +97,17 @@
 #define JFS_KNOWN_ROCOMPAT_FEATURES 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define JFS_KNOWN_INCOMPAT_FEATURES JFS_FEATURE_INCOMPAT_REVOKE
-#define BJ_None 0  
-#define BJ_SyncData 1  
-#define BJ_Metadata 2  
+#define BJ_None 0
+#define BJ_SyncData 1
+#define BJ_Metadata 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BJ_Forget 3  
-#define BJ_IO 4  
-#define BJ_Shadow 5  
-#define BJ_LogCtl 6  
+#define BJ_Forget 3
+#define BJ_IO 4
+#define BJ_Shadow 5
+#define BJ_LogCtl 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BJ_Reserved 7  
-#define BJ_Locked 8  
+#define BJ_Reserved 7
+#define BJ_Locked 8
 #define BJ_Types 9
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/jiffies.h b/libc/kernel/common/linux/jiffies.h
index cdfefcb..c221bf4 100644
--- a/libc/kernel/common/linux/jiffies.h
+++ b/libc/kernel/common/linux/jiffies.h
@@ -24,7 +24,7 @@
 #include <linux/types.h>
 #include <linux/time.h>
 #include <linux/timex.h>
-#include <asm/param.h>  
+#include <asm/param.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #if HZ >= (12 && HZ < 24)
 #define SHIFT_HZ 4
@@ -47,7 +47,7 @@
 #error You lose.
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ)  
+#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ)
 #define LATCH_HPET ((HPET_TICK_RATE + HZ/2) / HZ)
 #define SH_DIV(NOM,DEN,LSH) ( (((NOM) / (DEN)) << (LSH))   + ((((NOM) % (DEN)) << (LSH)) + (DEN) / 2) / (DEN))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/kd.h b/libc/kernel/common/linux/kd.h
index 9d6fea3..08335df 100644
--- a/libc/kernel/common/linux/kd.h
+++ b/libc/kernel/common/linux/kd.h
@@ -21,10 +21,10 @@
 #include <linux/types.h>
 #include <linux/compiler.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define GIO_FONT 0x4B60  
-#define PIO_FONT 0x4B61  
-#define GIO_FONTX 0x4B6B  
-#define PIO_FONTX 0x4B6C  
+#define GIO_FONT 0x4B60
+#define PIO_FONT 0x4B61
+#define GIO_FONTX 0x4B6B
+#define PIO_FONTX 0x4B6C
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct consolefontdesc {
  unsigned short charcount;
@@ -32,47 +32,47 @@
  char __user *chardata;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define PIO_FONTRESET 0x4B6D  
-#define GIO_CMAP 0x4B70  
-#define PIO_CMAP 0x4B71  
+#define PIO_FONTRESET 0x4B6D
+#define GIO_CMAP 0x4B70
+#define PIO_CMAP 0x4B71
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KIOCSOUND 0x4B2F  
-#define KDMKTONE 0x4B30  
-#define KDGETLED 0x4B31  
-#define KDSETLED 0x4B32  
+#define KIOCSOUND 0x4B2F
+#define KDMKTONE 0x4B30
+#define KDGETLED 0x4B31
+#define KDSETLED 0x4B32
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define LED_SCR 0x01  
-#define LED_NUM 0x02  
-#define LED_CAP 0x04  
-#define KDGKBTYPE 0x4B33  
+#define LED_SCR 0x01
+#define LED_NUM 0x02
+#define LED_CAP 0x04
+#define KDGKBTYPE 0x4B33
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KB_84 0x01
-#define KB_101 0x02  
+#define KB_101 0x02
 #define KB_OTHER 0x03
-#define KDADDIO 0x4B34  
+#define KDADDIO 0x4B34
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KDDELIO 0x4B35  
-#define KDENABIO 0x4B36  
-#define KDDISABIO 0x4B37  
-#define KDSETMODE 0x4B3A  
+#define KDDELIO 0x4B35
+#define KDENABIO 0x4B36
+#define KDDISABIO 0x4B37
+#define KDSETMODE 0x4B3A
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KD_TEXT 0x00
 #define KD_GRAPHICS 0x01
-#define KD_TEXT0 0x02  
-#define KD_TEXT1 0x03  
+#define KD_TEXT0 0x02
+#define KD_TEXT1 0x03
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KDGETMODE 0x4B3B  
-#define KDMAPDISP 0x4B3C  
-#define KDUNMAPDISP 0x4B3D  
+#define KDGETMODE 0x4B3B
+#define KDMAPDISP 0x4B3C
+#define KDUNMAPDISP 0x4B3D
 typedef char scrnmap_t;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define E_TABSZ 256
-#define GIO_SCRNMAP 0x4B40  
-#define PIO_SCRNMAP 0x4B41  
-#define GIO_UNISCRNMAP 0x4B69  
+#define GIO_SCRNMAP 0x4B40
+#define PIO_SCRNMAP 0x4B41
+#define GIO_UNISCRNMAP 0x4B69
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PIO_UNISCRNMAP 0x4B6A  
-#define GIO_UNIMAP 0x4B66  
+#define PIO_UNISCRNMAP 0x4B6A
+#define GIO_UNIMAP 0x4B66
 struct unipair {
  unsigned short unicode;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -83,8 +83,8 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  struct unipair __user *entries;
 };
-#define PIO_UNIMAP 0x4B67  
-#define PIO_UNIMAPCLR 0x4B68  
+#define PIO_UNIMAP 0x4B67
+#define PIO_UNIMAPCLR 0x4B68
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct unimapinit {
  unsigned short advised_hashsize;
@@ -92,27 +92,27 @@
  unsigned short advised_hashlevel;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define UNI_DIRECT_BASE 0xF000  
-#define UNI_DIRECT_MASK 0x01FF  
+#define UNI_DIRECT_BASE 0xF000
+#define UNI_DIRECT_MASK 0x01FF
 #define K_RAW 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define K_XLATE 0x01
 #define K_MEDIUMRAW 0x02
 #define K_UNICODE 0x03
-#define KDGKBMODE 0x4B44  
+#define KDGKBMODE 0x4B44
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KDSKBMODE 0x4B45  
+#define KDSKBMODE 0x4B45
 #define K_METABIT 0x03
 #define K_ESCPREFIX 0x04
-#define KDGKBMETA 0x4B62  
+#define KDGKBMETA 0x4B62
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KDSKBMETA 0x4B63  
+#define KDSKBMETA 0x4B63
 #define K_SCROLLLOCK 0x01
 #define K_NUMLOCK 0x02
 #define K_CAPSLOCK 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KDGKBLED 0x4B64  
-#define KDSKBLED 0x4B65  
+#define KDGKBLED 0x4B64
+#define KDSKBLED 0x4B65
 struct kbentry {
  unsigned char kb_table;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -124,16 +124,16 @@
 #define K_SHIFTTAB 0x01
 #define K_ALTTAB 0x02
 #define K_ALTSHIFTTAB 0x03
-#define KDGKBENT 0x4B46  
+#define KDGKBENT 0x4B46
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KDSKBENT 0x4B47  
+#define KDSKBENT 0x4B47
 struct kbsentry {
  unsigned char kb_func;
  unsigned char kb_string[512];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define KDGKBSENT 0x4B48  
-#define KDSKBSENT 0x4B49  
+#define KDGKBSENT 0x4B48
+#define KDSKBSENT 0x4B49
 struct kbdiacr {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned char diacr, base, result;
@@ -143,23 +143,23 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  struct kbdiacr kbdiacr[256];
 };
-#define KDGKBDIACR 0x4B4A  
-#define KDSKBDIACR 0x4B4B  
+#define KDGKBDIACR 0x4B4A
+#define KDSKBDIACR 0x4B4B
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct kbkeycode {
  unsigned int scancode, keycode;
 };
-#define KDGETKEYCODE 0x4B4C  
+#define KDGETKEYCODE 0x4B4C
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KDSETKEYCODE 0x4B4D  
-#define KDSIGACCEPT 0x4B4E  
+#define KDSETKEYCODE 0x4B4D
+#define KDSIGACCEPT 0x4B4E
 struct kbd_repeat {
  int delay;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  int period;
 };
-#define KDKBDREP 0x4B52  
-#define KDFONTOP 0x4B72  
+#define KDKBDREP 0x4B52
+#define KDFONTOP 0x4B72
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct console_font_op {
  unsigned int op;
@@ -176,10 +176,10 @@
  unsigned char *data;
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KD_FONT_OP_SET 0  
-#define KD_FONT_OP_GET 1  
-#define KD_FONT_OP_SET_DEFAULT 2  
-#define KD_FONT_OP_COPY 3  
+#define KD_FONT_OP_SET 0
+#define KD_FONT_OP_GET 1
+#define KD_FONT_OP_SET_DEFAULT 2
+#define KD_FONT_OP_COPY 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KD_FONT_FLAG_DONT_RECALC 1  
+#define KD_FONT_FLAG_DONT_RECALC 1
 #endif
diff --git a/libc/kernel/common/linux/kernelcapi.h b/libc/kernel/common/linux/kernelcapi.h
index 0d48514..925b9bb 100644
--- a/libc/kernel/common/linux/kernelcapi.h
+++ b/libc/kernel/common/linux/kernelcapi.h
@@ -18,8 +18,8 @@
  ****************************************************************************/
 #ifndef __KERNELCAPI_H__
 #define __KERNELCAPI_H__
-#define CAPI_MAXAPPL 240  
-#define CAPI_MAXCONTR 32  
+#define CAPI_MAXAPPL 240
+#define CAPI_MAXCONTR 32
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CAPI_MAXDATAWINDOW 8
 typedef struct kcapi_flagdef {
@@ -37,7 +37,7 @@
 } kcapi_carddef;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KCAPI_CMD_TRACE 10
-#define KCAPI_CMD_ADDCARD 11  
+#define KCAPI_CMD_ADDCARD 11
 #define KCAPI_TRACE_OFF 0
 #define KCAPI_TRACE_SHORT_NO_DATA 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/keyboard.h b/libc/kernel/common/linux/keyboard.h
index dac9983..a4b7e2b 100644
--- a/libc/kernel/common/linux/keyboard.h
+++ b/libc/kernel/common/linux/keyboard.h
@@ -36,10 +36,10 @@
 #define NR_KEYS 256
 #define MAX_NR_KEYMAPS 256
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MAX_NR_OF_USER_KEYMAPS 256  
-#define MAX_NR_FUNC 256  
-#define KT_LATIN 0  
-#define KT_LETTER 11  
+#define MAX_NR_OF_USER_KEYMAPS 256
+#define MAX_NR_FUNC 256
+#define KT_LATIN 0
+#define KT_LETTER 11
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KT_FN 1
 #define KT_SPEC 2
@@ -89,9 +89,9 @@
 #define K_INSERT K(KT_FN,21)
 #define K_REMOVE K(KT_FN,22)
 #define K_SELECT K(KT_FN,23)
-#define K_PGUP K(KT_FN,24)  
+#define K_PGUP K(KT_FN,24)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define K_PGDN K(KT_FN,25)  
+#define K_PGDN K(KT_FN,25)
 #define K_MACRO K(KT_FN,26)
 #define K_HELP K(KT_FN,27)
 #define K_DO K(KT_FN,28)
@@ -404,9 +404,9 @@
 #define K_INCRCONSOLE K(KT_SPEC,17)
 #define K_SPAWNCONSOLE K(KT_SPEC,18)
 #define K_BARENUMLOCK K(KT_SPEC,19)
-#define K_ALLOCATED K(KT_SPEC,126)  
+#define K_ALLOCATED K(KT_SPEC,126)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define K_NOSUCHMAP K(KT_SPEC,127)  
+#define K_NOSUCHMAP K(KT_SPEC,127)
 #define K_P0 K(KT_PAD,0)
 #define K_P1 K(KT_PAD,1)
 #define K_P2 K(KT_PAD,2)
@@ -419,19 +419,19 @@
 #define K_P7 K(KT_PAD,7)
 #define K_P8 K(KT_PAD,8)
 #define K_P9 K(KT_PAD,9)
-#define K_PPLUS K(KT_PAD,10)  
+#define K_PPLUS K(KT_PAD,10)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define K_PMINUS K(KT_PAD,11)  
-#define K_PSTAR K(KT_PAD,12)  
-#define K_PSLASH K(KT_PAD,13)  
-#define K_PENTER K(KT_PAD,14)  
+#define K_PMINUS K(KT_PAD,11)
+#define K_PSTAR K(KT_PAD,12)
+#define K_PSLASH K(KT_PAD,13)
+#define K_PENTER K(KT_PAD,14)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define K_PCOMMA K(KT_PAD,15)  
-#define K_PDOT K(KT_PAD,16)  
-#define K_PPLUSMINUS K(KT_PAD,17)  
-#define K_PPARENL K(KT_PAD,18)  
+#define K_PCOMMA K(KT_PAD,15)
+#define K_PDOT K(KT_PAD,16)
+#define K_PPLUSMINUS K(KT_PAD,17)
+#define K_PPARENL K(KT_PAD,18)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define K_PPARENR K(KT_PAD,19)  
+#define K_PPARENR K(KT_PAD,19)
 #define NR_PAD 20
 #define K_DGRAVE K(KT_DEAD,0)
 #define K_DACUTE K(KT_DEAD,1)
diff --git a/libc/kernel/common/linux/kxtf9.h b/libc/kernel/common/linux/kxtf9.h
index eb17df0..962f501 100644
--- a/libc/kernel/common/linux/kxtf9.h
+++ b/libc/kernel/common/linux/kxtf9.h
@@ -18,7 +18,7 @@
  ****************************************************************************/
 #ifndef __KXTF9_H__
 #define __KXTF9_H__
-#include <linux/ioctl.h>  
+#include <linux/ioctl.h>
 #define KXTF9_IOCTL_BASE 77
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KXTF9_IOCTL_SET_DELAY _IOW(KXTF9_IOCTL_BASE, 0, int)
@@ -39,31 +39,31 @@
 #define KXTF9_G_2G 0x00
 #define KXTF9_G_4G 0x08
 #define KXTF9_G_8G 0x10
-#define TPE 0x01  
+#define TPE 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WUFE 0x02  
-#define TDTE 0x04  
-#define OTP1_6 0x00  
+#define WUFE 0x02
+#define TDTE 0x04
+#define OTP1_6 0x00
 #define OTP6_3 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OTP12_5 0x40
 #define OTP50 0x60
-#define OWUF25 0x00  
+#define OWUF25 0x00
 #define OWUF50 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OWUF100 0x02
 #define OWUF200 0x03
-#define OTDT50 0x00  
+#define OTDT50 0x00
 #define OTDT100 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OTDT200 0x08
 #define OTDT400 0x0C
-#define IEN 0x20  
-#define IEA 0x10  
+#define IEN 0x20
+#define IEA 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IEL 0x08  
-#define IEU 0x04  
-#define ODR800 0x06  
+#define IEL 0x08
+#define IEU 0x04
+#define ODR800 0x06
 #define ODR400 0x05
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ODR200 0x04
diff --git a/libc/kernel/common/linux/l3g4200d.h b/libc/kernel/common/linux/l3g4200d.h
index 210f50b..19ec2c1 100644
--- a/libc/kernel/common/linux/l3g4200d.h
+++ b/libc/kernel/common/linux/l3g4200d.h
@@ -18,7 +18,7 @@
  ****************************************************************************/
 #ifndef __L3G4200D_H__
 #define __L3G4200D_H__
-#include <linux/ioctl.h>  
+#include <linux/ioctl.h>
 #define L3G4200D_NAME "l3g4200d"
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define L3G4200D_IOCTL_BASE 77
diff --git a/libc/kernel/common/linux/limits.h b/libc/kernel/common/linux/limits.h
index 1b17700..c63b2a2 100644
--- a/libc/kernel/common/linux/limits.h
+++ b/libc/kernel/common/linux/limits.h
@@ -19,22 +19,22 @@
 #ifndef _LINUX_LIMITS_H
 #define _LINUX_LIMITS_H
 #define NR_OPEN 1024
-#define NGROUPS_MAX 65536  
+#define NGROUPS_MAX 65536
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARG_MAX 131072  
-#define CHILD_MAX 999  
-#define OPEN_MAX 256  
-#define LINK_MAX 127  
+#define ARG_MAX 131072
+#define CHILD_MAX 999
+#define OPEN_MAX 256
+#define LINK_MAX 127
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MAX_CANON 255  
-#define MAX_INPUT 255  
-#define NAME_MAX 255  
-#define PATH_MAX 4096  
+#define MAX_CANON 255
+#define MAX_INPUT 255
+#define NAME_MAX 255
+#define PATH_MAX 4096
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PIPE_BUF 4096  
-#define XATTR_NAME_MAX 255  
-#define XATTR_SIZE_MAX 65536  
-#define XATTR_LIST_MAX 65536  
+#define PIPE_BUF 4096
+#define XATTR_NAME_MAX 255
+#define XATTR_SIZE_MAX 65536
+#define XATTR_LIST_MAX 65536
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTSIG_MAX 32
 #endif
diff --git a/libc/kernel/common/linux/linkage.h b/libc/kernel/common/linux/linkage.h
index 5f3a027..b2f4b8b 100644
--- a/libc/kernel/common/linux/linkage.h
+++ b/libc/kernel/common/linux/linkage.h
@@ -56,7 +56,7 @@
 #endif
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NORET_TYPE  
+#define NORET_TYPE
 #define ATTRIB_NORET __attribute__((noreturn))
 #define NORET_AND noreturn,
 #ifndef FASTCALL
diff --git a/libc/kernel/common/linux/lis331dlh.h b/libc/kernel/common/linux/lis331dlh.h
index ad381ec..5510546 100644
--- a/libc/kernel/common/linux/lis331dlh.h
+++ b/libc/kernel/common/linux/lis331dlh.h
@@ -18,7 +18,7 @@
  ****************************************************************************/
 #ifndef __LIS331DLH_H__
 #define __LIS331DLH_H__
-#include <linux/ioctl.h>  
+#include <linux/ioctl.h>
 #define LIS331DLH_IOCTL_BASE 77
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define LIS331DLH_IOCTL_SET_DELAY _IOW(LIS331DLH_IOCTL_BASE, 0, int)
diff --git a/libc/kernel/common/linux/lockd/nlm.h b/libc/kernel/common/linux/lockd/nlm.h
index 62f0814..e134c11 100644
--- a/libc/kernel/common/linux/lockd/nlm.h
+++ b/libc/kernel/common/linux/lockd/nlm.h
@@ -51,7 +51,7 @@
 #define NLMPROC_UNLOCK_RES 14
 #define NLMPROC_GRANTED_RES 15
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NLMPROC_NSM_NOTIFY 16  
+#define NLMPROC_NSM_NOTIFY 16
 #define NLMPROC_SHARE 20
 #define NLMPROC_UNSHARE 21
 #define NLMPROC_NM_LOCK 22
diff --git a/libc/kernel/common/linux/loop.h b/libc/kernel/common/linux/loop.h
index 94baeb2..d66f1db 100644
--- a/libc/kernel/common/linux/loop.h
+++ b/libc/kernel/common/linux/loop.h
@@ -26,8 +26,8 @@
  LO_FLAGS_USE_AOPS = 2,
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#include <asm/posix_types.h>  
-#include <asm/types.h>  
+#include <asm/posix_types.h>
+#include <asm/types.h>
 struct loop_info {
  int lo_number;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -68,7 +68,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define LO_CRYPT_XOR 1
 #define LO_CRYPT_DES 2
-#define LO_CRYPT_FISH2 3  
+#define LO_CRYPT_FISH2 3
 #define LO_CRYPT_BLOW 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define LO_CRYPT_CAST128 5
diff --git a/libc/kernel/common/linux/magic.h b/libc/kernel/common/linux/magic.h
index a878ceb..04d4046 100644
--- a/libc/kernel/common/linux/magic.h
+++ b/libc/kernel/common/linux/magic.h
@@ -36,20 +36,20 @@
 #define JFFS2_SUPER_MAGIC 0x72b6
 #define ANON_INODE_FS_MAGIC 0x09041934
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MINIX_SUPER_MAGIC 0x137F  
-#define MINIX_SUPER_MAGIC2 0x138F  
-#define MINIX2_SUPER_MAGIC 0x2468  
-#define MINIX2_SUPER_MAGIC2 0x2478  
+#define MINIX_SUPER_MAGIC 0x137F
+#define MINIX_SUPER_MAGIC2 0x138F
+#define MINIX2_SUPER_MAGIC 0x2468
+#define MINIX2_SUPER_MAGIC2 0x2478
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MINIX3_SUPER_MAGIC 0x4d5a  
-#define MSDOS_SUPER_MAGIC 0x4d44  
-#define NCP_SUPER_MAGIC 0x564c  
+#define MINIX3_SUPER_MAGIC 0x4d5a
+#define MSDOS_SUPER_MAGIC 0x4d44
+#define NCP_SUPER_MAGIC 0x564c
 #define NFS_SUPER_MAGIC 0x6969
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OPENPROM_SUPER_MAGIC 0x9fa1
 #define PROC_SUPER_MAGIC 0x9fa0
-#define QNX4_SUPER_MAGIC 0x002f  
-#define REISERFS_SUPER_MAGIC 0x52654973  
+#define QNX4_SUPER_MAGIC 0x002f
+#define REISERFS_SUPER_MAGIC 0x52654973
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define REISERFS_SUPER_MAGIC_STRING "ReIsErFs"
 #define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs"
diff --git a/libc/kernel/common/linux/major.h b/libc/kernel/common/linux/major.h
index 7cf511e..00e3bcd 100644
--- a/libc/kernel/common/linux/major.h
+++ b/libc/kernel/common/linux/major.h
@@ -41,7 +41,7 @@
 #define MISC_MAJOR 10
 #define SCSI_CDROM_MAJOR 11
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MUX_MAJOR 11  
+#define MUX_MAJOR 11
 #define XT_DISK_MAJOR 13
 #define INPUT_MAJOR 13
 #define SOUND_MAJOR 14
@@ -56,7 +56,7 @@
 #define CYCLADESAUX_MAJOR 20
 #define MITSUMI_X_CDROM_MAJOR 20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MFM_ACORN_MAJOR 21  
+#define MFM_ACORN_MAJOR 21
 #define SCSI_GENERIC_MAJOR 21
 #define IDE1_MAJOR 22
 #define DIGICU_MAJOR 22
@@ -77,28 +77,28 @@
 #define ACSI_MAJOR 28
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AZTECH_CDROM_MAJOR 29
-#define GRAPHDEV_MAJOR 29  
+#define GRAPHDEV_MAJOR 29
 #define CM206_CDROM_MAJOR 32
 #define IDE2_MAJOR 33
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IDE3_MAJOR 34
 #define Z8530_MAJOR 34
-#define XPRAM_MAJOR 35  
+#define XPRAM_MAJOR 35
 #define NETLINK_MAJOR 36
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PS2ESDI_MAJOR 36
 #define IDETAPE_MAJOR 37
 #define Z2RAM_MAJOR 37
-#define APBLOCK_MAJOR 38  
+#define APBLOCK_MAJOR 38
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DDV_MAJOR 39  
-#define NBD_MAJOR 43  
+#define DDV_MAJOR 39
+#define NBD_MAJOR 43
 #define RISCOM8_NORMAL_MAJOR 48
-#define DAC960_MAJOR 48  
+#define DAC960_MAJOR 48
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RISCOM8_CALLOUT_MAJOR 49
 #define MKISS_MAJOR 55
-#define DSP56K_MAJOR 55  
+#define DSP56K_MAJOR 55
 #define IDE4_MAJOR 56
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IDE5_MAJOR 57
@@ -124,9 +124,9 @@
 #define SPECIALIX_NORMAL_MAJOR 75
 #define SPECIALIX_CALLOUT_MAJOR 76
 #define AURORA_MAJOR 79
-#define I2O_MAJOR 80  
+#define I2O_MAJOR 80
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHMIQ_MAJOR 85  
+#define SHMIQ_MAJOR 85
 #define SCSI_CHANGER_MAJOR 86
 #define IDE6_MAJOR 88
 #define IDE7_MAJOR 89
@@ -174,14 +174,14 @@
 #define USB_ACM_MAJOR 166
 #define USB_ACM_AUX_MAJOR 167
 #define USB_CHAR_MAJOR 180
-#define VXVM_MAJOR 199  
+#define VXVM_MAJOR 199
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VXSPEC_MAJOR 200  
-#define VXDMP_MAJOR 201  
+#define VXSPEC_MAJOR 200
+#define VXDMP_MAJOR 201
 #define MSR_MAJOR 202
 #define CPUID_MAJOR 203
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OSST_MAJOR 206  
+#define OSST_MAJOR 206
 #define IBM_TTY3270_MAJOR 227
 #define IBM_FS3270_MAJOR 228
 #define VIOTAPE_MAJOR 230
diff --git a/libc/kernel/common/linux/mc146818rtc.h b/libc/kernel/common/linux/mc146818rtc.h
index d606489..a4a1664 100644
--- a/libc/kernel/common/linux/mc146818rtc.h
+++ b/libc/kernel/common/linux/mc146818rtc.h
@@ -19,9 +19,9 @@
 #ifndef _MC146818RTC_H
 #define _MC146818RTC_H
 #include <asm/io.h>
-#include <linux/rtc.h>  
+#include <linux/rtc.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#include <asm/mc146818rtc.h>  
+#include <asm/mc146818rtc.h>
 #define RTC_SECONDS 0
 #define RTC_SECONDS_ALARM 1
 #define RTC_MINUTES 2
@@ -53,28 +53,28 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTC_RATE_SELECT 0x0F
 #define RTC_CONTROL RTC_REG_B
-#define RTC_SET 0x80  
-#define RTC_PIE 0x40  
+#define RTC_SET 0x80
+#define RTC_PIE 0x40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RTC_AIE 0x20  
-#define RTC_UIE 0x10  
-#define RTC_SQWE 0x08  
-#define RTC_DM_BINARY 0x04  
+#define RTC_AIE 0x20
+#define RTC_UIE 0x10
+#define RTC_SQWE 0x08
+#define RTC_DM_BINARY 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RTC_24H 0x02  
-#define RTC_DST_EN 0x01  
+#define RTC_24H 0x02
+#define RTC_DST_EN 0x01
 #define RTC_INTR_FLAGS RTC_REG_C
-#define RTC_IRQF 0x80  
+#define RTC_IRQF 0x80
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTC_PF 0x40
 #define RTC_AF 0x20
 #define RTC_UF 0x10
 #define RTC_VALID RTC_REG_D
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RTC_VRT 0x80  
+#define RTC_VRT 0x80
 #ifndef ARCH_RTC_LOCATION
 #define RTC_IO_EXTENT 0x8
-#define RTC_IOMAPPED 1  
+#define RTC_IOMAPPED 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #endif
diff --git a/libc/kernel/common/linux/media.h b/libc/kernel/common/linux/media.h
index 94dde3f..e13771d 100644
--- a/libc/kernel/common/linux/media.h
+++ b/libc/kernel/common/linux/media.h
@@ -123,4 +123,3 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc)
 #endif
-
diff --git a/libc/kernel/common/linux/mempolicy.h b/libc/kernel/common/linux/mempolicy.h
index d2ff923..0dfd6d4 100644
--- a/libc/kernel/common/linux/mempolicy.h
+++ b/libc/kernel/common/linux/mempolicy.h
@@ -26,11 +26,11 @@
 #define MPOL_INTERLEAVE 3
 #define MPOL_MAX MPOL_INTERLEAVE
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MPOL_F_NODE (1<<0)  
-#define MPOL_F_ADDR (1<<1)  
-#define MPOL_MF_STRICT (1<<0)  
-#define MPOL_MF_MOVE (1<<1)  
+#define MPOL_F_NODE (1<<0)
+#define MPOL_F_ADDR (1<<1)
+#define MPOL_MF_STRICT (1<<0)
+#define MPOL_MF_MOVE (1<<1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MPOL_MF_MOVE_ALL (1<<2)  
-#define MPOL_MF_INTERNAL (1<<3)  
+#define MPOL_MF_MOVE_ALL (1<<2)
+#define MPOL_MF_INTERNAL (1<<3)
 #endif
diff --git a/libc/kernel/common/linux/mfd/msm-adie-codec.h b/libc/kernel/common/linux/mfd/msm-adie-codec.h
index e4c9e61..63fe193 100644
--- a/libc/kernel/common/linux/mfd/msm-adie-codec.h
+++ b/libc/kernel/common/linux/mfd/msm-adie-codec.h
@@ -107,4 +107,3 @@
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-
diff --git a/libc/kernel/common/linux/mfd/timpani-audio.h b/libc/kernel/common/linux/mfd/timpani-audio.h
index 26995f6..8206be2 100644
--- a/libc/kernel/common/linux/mfd/timpani-audio.h
+++ b/libc/kernel/common/linux/mfd/timpani-audio.h
@@ -4597,4 +4597,3 @@
 #define TIMPANI_CDC_COMP_HALT_COMPANDER_HALT_M 0x1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-
diff --git a/libc/kernel/common/linux/mfd/wcd9xxx/wcd9310_registers.h b/libc/kernel/common/linux/mfd/wcd9xxx/wcd9310_registers.h
index d6e4cc0..803562b 100644
--- a/libc/kernel/common/linux/mfd/wcd9xxx/wcd9310_registers.h
+++ b/libc/kernel/common/linux/mfd/wcd9xxx/wcd9310_registers.h
@@ -1378,4 +1378,3 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TABLA_CODEC_UNPACK_ENTRY(packed, reg, mask, val)   do {   ((reg) = ((packed >> 16) & (0xffff)));   ((mask) = ((packed >> 8) & (0xff)));   ((val) = ((packed) & (0xff)));   } while (0);
 #endif
-
diff --git a/libc/kernel/common/linux/mfd/wcd9xxx/wcd9xxx_registers.h b/libc/kernel/common/linux/mfd/wcd9xxx/wcd9xxx_registers.h
index 04de85d..8da93dd 100644
--- a/libc/kernel/common/linux/mfd/wcd9xxx/wcd9xxx_registers.h
+++ b/libc/kernel/common/linux/mfd/wcd9xxx/wcd9xxx_registers.h
@@ -52,4 +52,3 @@
 #define WCD9XXX_A_LEAKAGE_CTL__POR (0x00000004)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-
diff --git a/libc/kernel/common/linux/miscdevice.h b/libc/kernel/common/linux/miscdevice.h
index eb88387..52b2202 100644
--- a/libc/kernel/common/linux/miscdevice.h
+++ b/libc/kernel/common/linux/miscdevice.h
@@ -29,21 +29,21 @@
 #define SUN_MOUSE_MINOR 6
 #define APOLLO_MOUSE_MINOR 7
 #define PC110PAD_MINOR 9
-#define WATCHDOG_MINOR 130  
+#define WATCHDOG_MINOR 130
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TEMP_MINOR 131  
+#define TEMP_MINOR 131
 #define RTC_MINOR 135
-#define EFI_RTC_MINOR 136  
+#define EFI_RTC_MINOR 136
 #define SUN_OPENPROM_MINOR 139
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DMAPI_MINOR 140  
+#define DMAPI_MINOR 140
 #define NVRAM_MINOR 144
 #define SGI_MMTIMER 153
 #define STORE_QUEUE_MINOR 155
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I2O_MINOR 166
 #define MICROCODE_MINOR 184
-#define MWAVE_MINOR 219  
+#define MWAVE_MINOR 219
 #define MPT_MINOR 220
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MISC_DYNAMIC_MINOR 255
diff --git a/libc/kernel/common/linux/mmc/card.h b/libc/kernel/common/linux/mmc/card.h
index a09b71d..c8cd180 100644
--- a/libc/kernel/common/linux/mmc/card.h
+++ b/libc/kernel/common/linux/mmc/card.h
@@ -67,12 +67,12 @@
  unsigned int rca;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned int state;
-#define MMC_STATE_PRESENT (1<<0)  
-#define MMC_STATE_DEAD (1<<1)  
-#define MMC_STATE_BAD (1<<2)  
+#define MMC_STATE_PRESENT (1<<0)
+#define MMC_STATE_DEAD (1<<1)
+#define MMC_STATE_BAD (1<<2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MMC_STATE_SDCARD (1<<3)  
-#define MMC_STATE_READONLY (1<<4)  
+#define MMC_STATE_SDCARD (1<<3)
+#define MMC_STATE_READONLY (1<<4)
  u32 raw_cid[4];
  u32 raw_csd[4];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/mmc/host.h b/libc/kernel/common/linux/mmc/host.h
index 22f4262..87352e5 100644
--- a/libc/kernel/common/linux/mmc/host.h
+++ b/libc/kernel/common/linux/mmc/host.h
@@ -92,7 +92,7 @@
  u32 ocr_avail;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long caps;
-#define MMC_CAP_4_BIT_DATA (1 << 0)  
+#define MMC_CAP_4_BIT_DATA (1 << 0)
  unsigned int max_seg_size;
  unsigned short max_hw_segs;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/mmc/mmc.h b/libc/kernel/common/linux/mmc/mmc.h
index e99b443..bb90124 100644
--- a/libc/kernel/common/linux/mmc/mmc.h
+++ b/libc/kernel/common/linux/mmc/mmc.h
@@ -33,12 +33,12 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned int flags;
 #define MMC_RSP_PRESENT (1 << 0)
-#define MMC_RSP_136 (1 << 1)  
-#define MMC_RSP_CRC (1 << 2)  
+#define MMC_RSP_136 (1 << 1)
+#define MMC_RSP_CRC (1 << 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MMC_RSP_BUSY (1 << 3)  
-#define MMC_RSP_OPCODE (1 << 4)  
-#define MMC_CMD_MASK (3 << 5)  
+#define MMC_RSP_BUSY (1 << 3)
+#define MMC_RSP_OPCODE (1 << 4)
+#define MMC_CMD_MASK (3 << 5)
 #define MMC_CMD_AC (0 << 5)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MMC_CMD_ADTC (1 << 5)
diff --git a/libc/kernel/common/linux/moduleparam.h b/libc/kernel/common/linux/moduleparam.h
index b46cdd2..a5677aa 100644
--- a/libc/kernel/common/linux/moduleparam.h
+++ b/libc/kernel/common/linux/moduleparam.h
@@ -23,7 +23,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <linux/kernel.h>
 #ifdef MODULE
-#define MODULE_PARAM_PREFIX  
+#define MODULE_PARAM_PREFIX
 #else
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MODULE_PARAM_PREFIX KBUILD_MODNAME "."
diff --git a/libc/kernel/common/linux/mroute6.h b/libc/kernel/common/linux/mroute6.h
index 3d701da..f234a62 100644
--- a/libc/kernel/common/linux/mroute6.h
+++ b/libc/kernel/common/linux/mroute6.h
@@ -22,19 +22,19 @@
 #include <linux/sockios.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MRT6_BASE 200
-#define MRT6_INIT (MRT6_BASE)  
-#define MRT6_DONE (MRT6_BASE+1)  
-#define MRT6_ADD_MIF (MRT6_BASE+2)  
+#define MRT6_INIT (MRT6_BASE)
+#define MRT6_DONE (MRT6_BASE+1)
+#define MRT6_ADD_MIF (MRT6_BASE+2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MRT6_DEL_MIF (MRT6_BASE+3)  
-#define MRT6_ADD_MFC (MRT6_BASE+4)  
-#define MRT6_DEL_MFC (MRT6_BASE+5)  
-#define MRT6_VERSION (MRT6_BASE+6)  
+#define MRT6_DEL_MIF (MRT6_BASE+3)
+#define MRT6_ADD_MFC (MRT6_BASE+4)
+#define MRT6_DEL_MFC (MRT6_BASE+5)
+#define MRT6_VERSION (MRT6_BASE+6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MRT6_ASSERT (MRT6_BASE+7)  
-#define MRT6_PIM (MRT6_BASE+8)  
-#define MRT6_TABLE (MRT6_BASE+9)  
-#define SIOCGETMIFCNT_IN6 SIOCPROTOPRIVATE  
+#define MRT6_ASSERT (MRT6_BASE+7)
+#define MRT6_PIM (MRT6_BASE+8)
+#define MRT6_TABLE (MRT6_BASE+9)
+#define SIOCGETMIFCNT_IN6 SIOCPROTOPRIVATE
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SIOCGETSGCNT_IN6 (SIOCPROTOPRIVATE+1)
 #define SIOCGETRPF (SIOCPROTOPRIVATE+2)
@@ -48,7 +48,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 typedef __u32 if_mask;
-#define NIFBITS (sizeof(if_mask) * 8)  
+#define NIFBITS (sizeof(if_mask) * 8)
 #ifndef DIV_ROUND_UP
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DIV_ROUND_UP(x,y) (((x) + ((y) - 1)) / (y))
@@ -72,7 +72,7 @@
  unsigned int vifc_rate_limit;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define MIFF_REGISTER 0x1  
+#define MIFF_REGISTER 0x1
 struct mf6cctl {
  struct sockaddr_in6 mf6cc_origin;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -102,7 +102,7 @@
 #define MRT6MSG_NOCACHE 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MRT6MSG_WRONGMIF 2
-#define MRT6MSG_WHOLEPKT 3  
+#define MRT6MSG_WHOLEPKT 3
  __u8 im6_mbz;
  __u8 im6_msgtype;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/msdos_fs.h b/libc/kernel/common/linux/msdos_fs.h
index 20be021..d885e52 100644
--- a/libc/kernel/common/linux/msdos_fs.h
+++ b/libc/kernel/common/linux/msdos_fs.h
@@ -21,48 +21,48 @@
 #include <linux/magic.h>
 #include <asm/byteorder.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SECTOR_SIZE 512  
-#define SECTOR_BITS 9  
-#define MSDOS_DPB (MSDOS_DPS)  
-#define MSDOS_DPB_BITS 4  
+#define SECTOR_SIZE 512
+#define SECTOR_BITS 9
+#define MSDOS_DPB (MSDOS_DPS)
+#define MSDOS_DPB_BITS 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSDOS_DPS (SECTOR_SIZE / sizeof(struct msdos_dir_entry))
-#define MSDOS_DPS_BITS 4  
+#define MSDOS_DPS_BITS 4
 #define CF_LE_W(v) le16_to_cpu(v)
 #define CF_LE_L(v) le32_to_cpu(v)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CT_LE_W(v) cpu_to_le16(v)
 #define CT_LE_L(v) cpu_to_le32(v)
-#define MSDOS_ROOT_INO 1  
-#define MSDOS_DIR_BITS 5  
+#define MSDOS_ROOT_INO 1
+#define MSDOS_DIR_BITS 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FAT_MAX_DIR_ENTRIES (65536)
 #define FAT_MAX_DIR_SIZE (FAT_MAX_DIR_ENTRIES << MSDOS_DIR_BITS)
-#define ATTR_NONE 0  
-#define ATTR_RO 1  
+#define ATTR_NONE 0
+#define ATTR_RO 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATTR_HIDDEN 2  
-#define ATTR_SYS 4  
-#define ATTR_VOLUME 8  
-#define ATTR_DIR 16  
+#define ATTR_HIDDEN 2
+#define ATTR_SYS 4
+#define ATTR_VOLUME 8
+#define ATTR_DIR 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATTR_ARCH 32  
+#define ATTR_ARCH 32
 #define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
 #define ATTR_EXT (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME)
-#define CASE_LOWER_BASE 8  
+#define CASE_LOWER_BASE 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CASE_LOWER_EXT 16  
-#define DELETED_FLAG 0xe5  
+#define CASE_LOWER_EXT 16
+#define DELETED_FLAG 0xe5
 #define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG)
 #define MSDOS_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSDOS_MKMODE(a, m) (m & (a & ATTR_RO ? S_IRUGO|S_IXUGO : S_IRWXUGO))
-#define MSDOS_NAME 11  
-#define MSDOS_LONGNAME 256  
-#define MSDOS_SLOTS 21  
+#define MSDOS_NAME 11
+#define MSDOS_LONGNAME 256
+#define MSDOS_SLOTS 21
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSDOS_DOT ".          "  
-#define MSDOS_DOTDOT "..         "  
+#define MSDOS_DOT ".          "
+#define MSDOS_DOTDOT "..         "
 #define FAT_VALID_MEDIA(x) ((0xF8 <= (x) && (x) <= 0xFF) || (x) == 0xF0)
 #define FAT_FIRST_ENT(s, x) ((MSDOS_SB(s)->fat_bits == 32 ? 0x0FFFFF00 :   MSDOS_SB(s)->fat_bits == 16 ? 0xFF00 : 0xF00) | (x))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -93,12 +93,12 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FAT_IOCTL_SET_ATTRIBUTES _IOW('r', 0x11, __u32)
 #define VFAT_IOCTL_GET_VOLUME_ID _IOR('r', 0x12, __u32)
-#define VFAT_SFN_DISPLAY_LOWER 0x0001  
-#define VFAT_SFN_DISPLAY_WIN95 0x0002  
+#define VFAT_SFN_DISPLAY_LOWER 0x0001
+#define VFAT_SFN_DISPLAY_WIN95 0x0002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VFAT_SFN_DISPLAY_WINNT 0x0004  
-#define VFAT_SFN_CREATE_WIN95 0x0100  
-#define VFAT_SFN_CREATE_WINNT 0x0200  
+#define VFAT_SFN_DISPLAY_WINNT 0x0004
+#define VFAT_SFN_CREATE_WIN95 0x0100
+#define VFAT_SFN_CREATE_WINNT 0x0200
 struct fat_boot_sector {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __u8 ignored[3];
@@ -148,8 +148,8 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __u8 type[8];
 };
-#define FAT16_BSX_OFFSET 36  
-#define FAT32_BSX_OFFSET 64  
+#define FAT16_BSX_OFFSET 36
+#define FAT32_BSX_OFFSET 64
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct msdos_dir_entry {
  __u8 name[MSDOS_NAME];
diff --git a/libc/kernel/common/linux/msg.h b/libc/kernel/common/linux/msg.h
index 41c21af..7cb9e36 100644
--- a/libc/kernel/common/linux/msg.h
+++ b/libc/kernel/common/linux/msg.h
@@ -22,8 +22,8 @@
 #define MSG_STAT 11
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSG_INFO 12
-#define MSG_NOERROR 010000  
-#define MSG_EXCEPT 020000  
+#define MSG_NOERROR 010000
+#define MSG_EXCEPT 020000
 struct msqid_ds {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  struct ipc_perm msg_perm;
@@ -62,15 +62,15 @@
  unsigned short msgseg;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define MSGMNI 16    
-#define MSGMAX 8192    
-#define MSGMNB 16384    
+#define MSGMNI 16
+#define MSGMAX 8192
+#define MSGMNB 16384
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSGPOOL (MSGMNI*MSGMNB/1024)  
-#define MSGTQL MSGMNB  
-#define MSGMAP MSGMNB  
-#define MSGSSZ 16  
+#define MSGPOOL (MSGMNI*MSGMNB/1024)
+#define MSGTQL MSGMNB
+#define MSGMAP MSGMNB
+#define MSGSSZ 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define __MSGSEG ((MSGPOOL*1024)/ MSGSSZ)  
+#define __MSGSEG ((MSGPOOL*1024)/ MSGSSZ)
 #define MSGSEG (__MSGSEG <= 0xffff ? __MSGSEG : 0xffff)
 #endif
diff --git a/libc/kernel/common/linux/msm_audio.h b/libc/kernel/common/linux/msm_audio.h
index 2b42efc..4c9a1ab 100644
--- a/libc/kernel/common/linux/msm_audio.h
+++ b/libc/kernel/common/linux/msm_audio.h
@@ -343,4 +343,3 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #endif
-
diff --git a/libc/kernel/common/linux/msm_audio_aac.h b/libc/kernel/common/linux/msm_audio_aac.h
index 2aaa1c4..218ac45 100644
--- a/libc/kernel/common/linux/msm_audio_aac.h
+++ b/libc/kernel/common/linux/msm_audio_aac.h
@@ -77,4 +77,3 @@
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-
diff --git a/libc/kernel/common/linux/msm_audio_acdb.h b/libc/kernel/common/linux/msm_audio_acdb.h
index 831e265..a2d42bf 100644
--- a/libc/kernel/common/linux/msm_audio_acdb.h
+++ b/libc/kernel/common/linux/msm_audio_acdb.h
@@ -68,4 +68,3 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AUDIO_MAX_RTAC_IOCTL (AUDIO_MAX_ACDB_IOCTL+20)
 #endif
-
diff --git a/libc/kernel/common/linux/msm_audio_wma.h b/libc/kernel/common/linux/msm_audio_wma.h
index fc89cb6..8d2e4db 100644
--- a/libc/kernel/common/linux/msm_audio_wma.h
+++ b/libc/kernel/common/linux/msm_audio_wma.h
@@ -46,4 +46,3 @@
 };
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-
diff --git a/libc/kernel/common/linux/msm_audio_wmapro.h b/libc/kernel/common/linux/msm_audio_wmapro.h
index 3e5d7c6..9fb19da 100644
--- a/libc/kernel/common/linux/msm_audio_wmapro.h
+++ b/libc/kernel/common/linux/msm_audio_wmapro.h
@@ -38,4 +38,3 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #endif
-
diff --git a/libc/kernel/common/linux/msm_charm.h b/libc/kernel/common/linux/msm_charm.h
index 171084a..f73a8f1 100644
--- a/libc/kernel/common/linux/msm_charm.h
+++ b/libc/kernel/common/linux/msm_charm.h
@@ -36,4 +36,3 @@
 };
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-
diff --git a/libc/kernel/common/linux/msm_dsps.h b/libc/kernel/common/linux/msm_dsps.h
index 1978328..e56b319 100644
--- a/libc/kernel/common/linux/msm_dsps.h
+++ b/libc/kernel/common/linux/msm_dsps.h
@@ -28,4 +28,3 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DSPS_IOCTL_RESET _IO(DSPS_IOCTL_MAGIC, 5)
 #endif
-
diff --git a/libc/kernel/common/linux/msm_ion.h b/libc/kernel/common/linux/msm_ion.h
index 5e85ea1..c750f12 100644
--- a/libc/kernel/common/linux/msm_ion.h
+++ b/libc/kernel/common/linux/msm_ion.h
@@ -16,90 +16,8 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#ifndef __LINUX_MSM_ION_H__
-#define __LINUX_MSM_ION_H__
+#ifndef _LINUX_MSM_ION_H
+#define _LINUX_MSM_ION_H
 #include <linux/ion.h>
-enum msm_ion_heap_types {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- ION_HEAP_TYPE_IOMMU = ION_HEAP_TYPE_CUSTOM + 1,
- ION_HEAP_TYPE_CP = ION_HEAP_TYPE_CUSTOM + 2,
-};
-enum ion_heap_ids {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- INVALID_HEAP_ID = -1,
- ION_CP_MM_HEAP_ID = 8,
- ION_CP_MFC_HEAP_ID = 12,
- ION_CP_WB_HEAP_ID = 16,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- ION_CAMERA_HEAP_ID = 20,
- ION_SF_HEAP_ID = 24,
- ION_IOMMU_HEAP_ID = 25,
- ION_QSECOM_HEAP_ID = 27,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- ION_AUDIO_HEAP_ID = 28,
- ION_MM_FIRMWARE_HEAP_ID = 29,
- ION_SYSTEM_HEAP_ID = 30,
- ION_HEAP_ID_RESERVED = 31
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-};
-enum ion_fixed_position {
- NOT_FIXED,
- FIXED_LOW,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- FIXED_MIDDLE,
- FIXED_HIGH,
-};
-enum cp_mem_usage {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- VIDEO_BITSTREAM = 0x1,
- VIDEO_PIXEL = 0x2,
- VIDEO_NONPIXEL = 0x3,
- MAX_USAGE = 0x4,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- UNKNOWN = 0x7FFFFFFF,
-};
-#define ION_HEAP_CP_MASK (1 << ION_HEAP_TYPE_CP)
-#define ION_SECURE (1 << ION_HEAP_ID_RESERVED)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ION_HEAP(bit) (1 << (bit))
-#define ION_VMALLOC_HEAP_NAME "vmalloc"
-#define ION_AUDIO_HEAP_NAME "audio"
-#define ION_SF_HEAP_NAME "sf"
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ION_MM_HEAP_NAME "mm"
-#define ION_CAMERA_HEAP_NAME "camera_preview"
-#define ION_IOMMU_HEAP_NAME "iommu"
-#define ION_MFC_HEAP_NAME "mfc"
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ION_WB_HEAP_NAME "wb"
-#define ION_MM_FIRMWARE_HEAP_NAME "mm_fw"
-#define ION_QSECOM_HEAP_NAME "qsecom"
-#define ION_FMEM_HEAP_NAME "fmem"
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CACHED 1
-#define UNCACHED 0
-#define ION_CACHE_SHIFT 0
-#define ION_SET_CACHE(__cache) ((__cache) << ION_CACHE_SHIFT)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ION_IS_CACHED(__flags) ((__flags) & (1 << ION_CACHE_SHIFT))
-struct ion_flush_data {
- struct ion_handle *handle;
- int fd;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- void *vaddr;
- unsigned int offset;
- unsigned int length;
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct ion_flag_data {
- struct ion_handle *handle;
- unsigned long flags;
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ION_IOC_CLEAN_CACHES _IOWR(ION_IOC_MAGIC, 20,   struct ion_flush_data)
-#define ION_IOC_INV_CACHES _IOWR(ION_IOC_MAGIC, 21,   struct ion_flush_data)
-#define ION_IOC_CLEAN_INV_CACHES _IOWR(ION_IOC_MAGIC, 22,   struct ion_flush_data)
-#define ION_IOC_GET_FLAGS _IOWR(ION_IOC_MAGIC, 23,   struct ion_flag_data)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/msm_kgsl.h b/libc/kernel/common/linux/msm_kgsl.h
index 3a20ae2..272fd57 100644
--- a/libc/kernel/common/linux/msm_kgsl.h
+++ b/libc/kernel/common/linux/msm_kgsl.h
@@ -363,4 +363,3 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IOCTL_KGSL_TIMESTAMP_EVENT   _IOWR(KGSL_IOC_TYPE, 0x33, struct kgsl_timestamp_event)
 #endif
-
diff --git a/libc/kernel/common/linux/msm_mdp.h b/libc/kernel/common/linux/msm_mdp.h
index c70bd71..72e9072 100644
--- a/libc/kernel/common/linux/msm_mdp.h
+++ b/libc/kernel/common/linux/msm_mdp.h
@@ -528,4 +528,3 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #endif
-
diff --git a/libc/kernel/common/linux/msm_rmnet.h b/libc/kernel/common/linux/msm_rmnet.h
index 88ddd3a..0ca2dfc 100644
--- a/libc/kernel/common/linux/msm_rmnet.h
+++ b/libc/kernel/common/linux/msm_rmnet.h
@@ -51,4 +51,3 @@
 };
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-
diff --git a/libc/kernel/common/linux/msm_rotator.h b/libc/kernel/common/linux/msm_rotator.h
index 2e57191..d731b76 100644
--- a/libc/kernel/common/linux/msm_rotator.h
+++ b/libc/kernel/common/linux/msm_rotator.h
@@ -73,4 +73,3 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #endif
-
diff --git a/libc/kernel/common/linux/msm_vidc_dec.h b/libc/kernel/common/linux/msm_vidc_dec.h
index 09a7136..074b7c3 100644
--- a/libc/kernel/common/linux/msm_vidc_dec.h
+++ b/libc/kernel/common/linux/msm_vidc_dec.h
@@ -537,4 +537,3 @@
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-
diff --git a/libc/kernel/common/linux/msm_vidc_enc.h b/libc/kernel/common/linux/msm_vidc_enc.h
index 6be027d..29c4cc9 100644
--- a/libc/kernel/common/linux/msm_vidc_enc.h
+++ b/libc/kernel/common/linux/msm_vidc_enc.h
@@ -22,28 +22,28 @@
 #include <linux/ioctl.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VEN_S_BASE 0x00000000
-#define VEN_S_SUCCESS (VEN_S_BASE) 
-#define VEN_S_EFAIL (VEN_S_BASE+1) 
-#define VEN_S_EFATAL (VEN_S_BASE+2) 
+#define VEN_S_SUCCESS (VEN_S_BASE)
+#define VEN_S_EFAIL (VEN_S_BASE+1)
+#define VEN_S_EFATAL (VEN_S_BASE+2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VEN_S_EBADPARAM (VEN_S_BASE+3) 
+#define VEN_S_EBADPARAM (VEN_S_BASE+3)
 #define VEN_S_EINVALSTATE (VEN_S_BASE+4)
-#define VEN_S_ENOSWRES (VEN_S_BASE+5) 
-#define VEN_S_ENOHWRES (VEN_S_BASE+6) 
+#define VEN_S_ENOSWRES (VEN_S_BASE+5)
+#define VEN_S_ENOHWRES (VEN_S_BASE+6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VEN_S_EBUFFREQ (VEN_S_BASE+7) 
-#define VEN_S_EINVALCMD (VEN_S_BASE+8) 
-#define VEN_S_ETIMEOUT (VEN_S_BASE+9) 
+#define VEN_S_EBUFFREQ (VEN_S_BASE+7)
+#define VEN_S_EINVALCMD (VEN_S_BASE+8)
+#define VEN_S_ETIMEOUT (VEN_S_BASE+9)
 #define VEN_S_ENOREATMPT (VEN_S_BASE+10)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VEN_S_ENOPREREQ (VEN_S_BASE+11) 
-#define VEN_S_ECMDQFULL (VEN_S_BASE+12) 
-#define VEN_S_ENOTSUPP (VEN_S_BASE+13) 
-#define VEN_S_ENOTIMPL (VEN_S_BASE+14) 
+#define VEN_S_ENOPREREQ (VEN_S_BASE+11)
+#define VEN_S_ECMDQFULL (VEN_S_BASE+12)
+#define VEN_S_ENOTSUPP (VEN_S_BASE+13)
+#define VEN_S_ENOTIMPL (VEN_S_BASE+14)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VEN_S_ENOTPMEM (VEN_S_BASE+15) 
-#define VEN_S_EFLUSHED (VEN_S_BASE+16) 
-#define VEN_S_EINSUFBUF (VEN_S_BASE+17) 
+#define VEN_S_ENOTPMEM (VEN_S_BASE+15)
+#define VEN_S_EFLUSHED (VEN_S_BASE+16)
+#define VEN_S_EINSUFBUF (VEN_S_BASE+17)
 #define VEN_S_ESAMESTATE (VEN_S_BASE+18)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VEN_S_EINVALTRANS (VEN_S_BASE+19)
@@ -72,71 +72,71 @@
 #define VEN_EXTRADATA_QCOMFILLER 0x002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VEN_EXTRADATA_SLICEINFO 0x100
-#define VEN_FRAME_TYPE_I 1 
-#define VEN_FRAME_TYPE_P 2 
-#define VEN_FRAME_TYPE_B 3 
+#define VEN_FRAME_TYPE_I 1
+#define VEN_FRAME_TYPE_P 2
+#define VEN_FRAME_TYPE_B 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VEN_CODEC_MPEG4 1 
-#define VEN_CODEC_H264 2 
-#define VEN_CODEC_H263 3 
-#define VEN_PROFILE_MPEG4_SP 1 
+#define VEN_CODEC_MPEG4 1
+#define VEN_CODEC_H264 2
+#define VEN_CODEC_H263 3
+#define VEN_PROFILE_MPEG4_SP 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VEN_PROFILE_MPEG4_ASP 2 
-#define VEN_PROFILE_H264_BASELINE 3 
-#define VEN_PROFILE_H264_MAIN 4 
-#define VEN_PROFILE_H264_HIGH 5 
+#define VEN_PROFILE_MPEG4_ASP 2
+#define VEN_PROFILE_H264_BASELINE 3
+#define VEN_PROFILE_H264_MAIN 4
+#define VEN_PROFILE_H264_HIGH 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VEN_PROFILE_H263_BASELINE 6 
-#define VEN_LEVEL_MPEG4_0 0x1 
-#define VEN_LEVEL_MPEG4_1 0x2 
-#define VEN_LEVEL_MPEG4_2 0x3 
+#define VEN_PROFILE_H263_BASELINE 6
+#define VEN_LEVEL_MPEG4_0 0x1
+#define VEN_LEVEL_MPEG4_1 0x2
+#define VEN_LEVEL_MPEG4_2 0x3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VEN_LEVEL_MPEG4_3 0x4 
-#define VEN_LEVEL_MPEG4_4 0x5 
-#define VEN_LEVEL_MPEG4_5 0x6 
-#define VEN_LEVEL_MPEG4_3b 0x7 
+#define VEN_LEVEL_MPEG4_3 0x4
+#define VEN_LEVEL_MPEG4_4 0x5
+#define VEN_LEVEL_MPEG4_5 0x6
+#define VEN_LEVEL_MPEG4_3b 0x7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VEN_LEVEL_MPEG4_6 0x8 
-#define VEN_LEVEL_H264_1 0x9 
-#define VEN_LEVEL_H264_1b 0xA 
-#define VEN_LEVEL_H264_1p1 0xB 
+#define VEN_LEVEL_MPEG4_6 0x8
+#define VEN_LEVEL_H264_1 0x9
+#define VEN_LEVEL_H264_1b 0xA
+#define VEN_LEVEL_H264_1p1 0xB
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VEN_LEVEL_H264_1p2 0xC 
-#define VEN_LEVEL_H264_1p3 0xD 
-#define VEN_LEVEL_H264_2 0xE 
-#define VEN_LEVEL_H264_2p1 0xF 
+#define VEN_LEVEL_H264_1p2 0xC
+#define VEN_LEVEL_H264_1p3 0xD
+#define VEN_LEVEL_H264_2 0xE
+#define VEN_LEVEL_H264_2p1 0xF
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VEN_LEVEL_H264_2p2 0x10 
-#define VEN_LEVEL_H264_3 0x11 
-#define VEN_LEVEL_H264_3p1 0x12 
-#define VEN_LEVEL_H264_3p2 0x13 
+#define VEN_LEVEL_H264_2p2 0x10
+#define VEN_LEVEL_H264_3 0x11
+#define VEN_LEVEL_H264_3p1 0x12
+#define VEN_LEVEL_H264_3p2 0x13
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VEN_LEVEL_H264_4 0x14 
-#define VEN_LEVEL_H263_10 0x15 
-#define VEN_LEVEL_H263_20 0x16 
-#define VEN_LEVEL_H263_30 0x17 
+#define VEN_LEVEL_H264_4 0x14
+#define VEN_LEVEL_H263_10 0x15
+#define VEN_LEVEL_H263_20 0x16
+#define VEN_LEVEL_H263_30 0x17
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VEN_LEVEL_H263_40 0x18 
-#define VEN_LEVEL_H263_45 0x19 
-#define VEN_LEVEL_H263_50 0x1A 
-#define VEN_LEVEL_H263_60 0x1B 
+#define VEN_LEVEL_H263_40 0x18
+#define VEN_LEVEL_H263_45 0x19
+#define VEN_LEVEL_H263_50 0x1A
+#define VEN_LEVEL_H263_60 0x1B
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VEN_LEVEL_H263_70 0x1C 
+#define VEN_LEVEL_H263_70 0x1C
 #define VEN_ENTROPY_MODEL_CAVLC 1
 #define VEN_ENTROPY_MODEL_CABAC 2
-#define VEN_CABAC_MODEL_0 1 
+#define VEN_CABAC_MODEL_0 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VEN_CABAC_MODEL_1 2 
-#define VEN_CABAC_MODEL_2 3 
-#define VEN_DB_DISABLE 1 
-#define VEN_DB_ALL_BLKG_BNDRY 2 
+#define VEN_CABAC_MODEL_1 2
+#define VEN_CABAC_MODEL_2 3
+#define VEN_DB_DISABLE 1
+#define VEN_DB_ALL_BLKG_BNDRY 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VEN_DB_SKIP_SLICE_BNDRY 3 
+#define VEN_DB_SKIP_SLICE_BNDRY 3
 #define VEN_MSLICE_OFF 1
-#define VEN_MSLICE_CNT_MB 2  
-#define VEN_MSLICE_CNT_BYTE 3  
+#define VEN_MSLICE_CNT_MB 2
+#define VEN_MSLICE_CNT_BYTE 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VEN_MSLICE_GOB 4  
+#define VEN_MSLICE_GOB 4
 #define VEN_RC_OFF 1
 #define VEN_RC_VBR_VFR 2
 #define VEN_RC_VBR_CFR 3
@@ -147,14 +147,14 @@
 #define VEN_FLUSH_OUTPUT 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VEN_FLUSH_ALL 3
-#define VEN_INPUTFMT_NV12 1 
-#define VEN_INPUTFMT_NV21 2 
-#define VEN_INPUTFMT_NV12_16M2KA 3 
+#define VEN_INPUTFMT_NV12 1
+#define VEN_INPUTFMT_NV21 2
+#define VEN_INPUTFMT_NV12_16M2KA 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VEN_ROTATION_0 1 
-#define VEN_ROTATION_90 2 
-#define VEN_ROTATION_180 3 
-#define VEN_ROTATION_270 4 
+#define VEN_ROTATION_0 1
+#define VEN_ROTATION_90 2
+#define VEN_ROTATION_180 3
+#define VEN_ROTATION_270 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VEN_TIMEOUT_INFINITE 0xffffffff
 #define VEN_IR_OFF 1
@@ -427,4 +427,3 @@
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-
diff --git a/libc/kernel/common/linux/mt9t013.h b/libc/kernel/common/linux/mt9t013.h
index 6b8b31a..d640dee 100644
--- a/libc/kernel/common/linux/mt9t013.h
+++ b/libc/kernel/common/linux/mt9t013.h
@@ -37,9 +37,9 @@
 #define CAMERA_LENS_POWER_OFF   _IO(MT9T013_I2C_IOCTL_MAGIC, 10)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MT9T013_I2C_IOCTL_CAMIF_APPS_RESET   _IO(MT9T013_I2C_IOCTL_MAGIC, 11)
-#define CAMIO_VFE_MDC_CLK 1  
-#define CAMIO_MDC_CLK 2  
-#define CAMIO_VFE_CLK 3  
+#define CAMIO_VFE_MDC_CLK 1
+#define CAMIO_MDC_CLK 2
+#define CAMIO_VFE_CLK 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MT9T013_I2C_IOCTL_CLK_ENABLE   _IOW(MT9T013_I2C_IOCTL_MAGIC, 12, unsigned)
 #define MT9T013_I2C_IOCTL_CLK_DISABLE   _IOW(MT9T013_I2C_IOCTL_MAGIC, 13, unsigned)
diff --git a/libc/kernel/common/linux/mtd/cfi.h b/libc/kernel/common/linux/mtd/cfi.h
index 944bbfa..20952ca 100644
--- a/libc/kernel/common/linux/mtd/cfi.h
+++ b/libc/kernel/common/linux/mtd/cfi.h
@@ -232,7 +232,7 @@
 #define CFI_MFR_AMD 0x0001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CFI_MFR_ATMEL 0x001F
-#define CFI_MFR_ST 0x0020  
+#define CFI_MFR_ST 0x0020
 typedef int (*varsize_frob_t)(struct map_info *map, struct flchip *chip,
  unsigned long adr, int len, void *thunk);
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/mtd/mtd.h b/libc/kernel/common/linux/mtd/mtd.h
index 90ffcfc..d2472cf 100644
--- a/libc/kernel/common/linux/mtd/mtd.h
+++ b/libc/kernel/common/linux/mtd/mtd.h
@@ -142,10 +142,10 @@
  struct list_head list;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define MTD_DEBUG_LEVEL0 (0)  
-#define MTD_DEBUG_LEVEL1 (1)  
-#define MTD_DEBUG_LEVEL2 (2)  
+#define MTD_DEBUG_LEVEL0 (0)
+#define MTD_DEBUG_LEVEL1 (1)
+#define MTD_DEBUG_LEVEL2 (2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MTD_DEBUG_LEVEL3 (3)  
+#define MTD_DEBUG_LEVEL3 (3)
 #define DEBUG(n, args...) do { } while(0)
 #endif
diff --git a/libc/kernel/common/linux/mtd/nftl.h b/libc/kernel/common/linux/mtd/nftl.h
index 75cdf54..6fc423e 100644
--- a/libc/kernel/common/linux/mtd/nftl.h
+++ b/libc/kernel/common/linux/mtd/nftl.h
@@ -22,11 +22,11 @@
 #include <linux/mtd/blktrans.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <mtd/nftl-user.h>
-#define BLOCK_NIL 0xffff  
-#define BLOCK_FREE 0xfffe  
-#define BLOCK_NOTEXPLORED 0xfffd  
+#define BLOCK_NIL 0xffff
+#define BLOCK_FREE 0xfffe
+#define BLOCK_NOTEXPLORED 0xfffd
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BLOCK_RESERVED 0xfffc  
+#define BLOCK_RESERVED 0xfffc
 struct NFTLrecord {
  struct mtd_blktrans_dev mbd;
  __u16 MediaUnit, SpareMediaUnit;
diff --git a/libc/kernel/common/linux/mtio.h b/libc/kernel/common/linux/mtio.h
index c2901ba..9b43a2d 100644
--- a/libc/kernel/common/linux/mtio.h
+++ b/libc/kernel/common/linux/mtio.h
@@ -27,46 +27,46 @@
  int mt_count;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define MTRESET 0  
-#define MTFSF 1  
-#define MTBSF 2  
+#define MTRESET 0
+#define MTFSF 1
+#define MTBSF 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MTFSR 3  
-#define MTBSR 4  
-#define MTWEOF 5  
-#define MTREW 6  
+#define MTFSR 3
+#define MTBSR 4
+#define MTWEOF 5
+#define MTREW 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MTOFFL 7  
-#define MTNOP 8  
-#define MTRETEN 9  
-#define MTBSFM 10  
+#define MTOFFL 7
+#define MTNOP 8
+#define MTRETEN 9
+#define MTBSFM 10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MTFSFM 11  
-#define MTEOM 12  
-#define MTERASE 13  
-#define MTRAS1 14  
+#define MTFSFM 11
+#define MTEOM 12
+#define MTERASE 13
+#define MTRAS1 14
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MTRAS2 15  
-#define MTRAS3 16  
-#define MTSETBLK 20  
-#define MTSETDENSITY 21  
+#define MTRAS2 15
+#define MTRAS3 16
+#define MTSETBLK 20
+#define MTSETDENSITY 21
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MTSEEK 22  
-#define MTTELL 23  
-#define MTSETDRVBUFFER 24  
-#define MTFSS 25  
+#define MTSEEK 22
+#define MTTELL 23
+#define MTSETDRVBUFFER 24
+#define MTFSS 25
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MTBSS 26  
-#define MTWSM 27  
-#define MTLOCK 28  
-#define MTUNLOCK 29  
+#define MTBSS 26
+#define MTWSM 27
+#define MTLOCK 28
+#define MTUNLOCK 29
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MTLOAD 30  
-#define MTUNLOAD 31  
-#define MTCOMPRESSION 32 
-#define MTSETPART 33  
+#define MTLOAD 30
+#define MTUNLOAD 31
+#define MTCOMPRESSION 32
+#define MTSETPART 33
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MTMKPART 34  
+#define MTMKPART 34
 struct mtget {
  long mt_type;
  long mt_resid;
@@ -79,30 +79,30 @@
  __kernel_daddr_t mt_blkno;
 };
 #define MT_ISUNKNOWN 0x01
-#define MT_ISQIC02 0x02  
+#define MT_ISQIC02 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MT_ISWT5150 0x03  
-#define MT_ISARCHIVE_5945L2 0x04  
-#define MT_ISCMSJ500 0x05  
-#define MT_ISTDC3610 0x06  
+#define MT_ISWT5150 0x03
+#define MT_ISARCHIVE_5945L2 0x04
+#define MT_ISCMSJ500 0x05
+#define MT_ISTDC3610 0x06
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MT_ISARCHIVE_VP60I 0x07  
-#define MT_ISARCHIVE_2150L 0x08  
-#define MT_ISARCHIVE_2060L 0x09  
-#define MT_ISARCHIVESC499 0x0A  
+#define MT_ISARCHIVE_VP60I 0x07
+#define MT_ISARCHIVE_2150L 0x08
+#define MT_ISARCHIVE_2060L 0x09
+#define MT_ISARCHIVESC499 0x0A
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MT_ISQIC02_ALL_FEATURES 0x0F  
-#define MT_ISWT5099EEN24 0x11  
-#define MT_ISTEAC_MT2ST 0x12  
-#define MT_ISEVEREX_FT40A 0x32  
+#define MT_ISQIC02_ALL_FEATURES 0x0F
+#define MT_ISWT5099EEN24 0x11
+#define MT_ISTEAC_MT2ST 0x12
+#define MT_ISEVEREX_FT40A 0x32
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MT_ISDDS1 0x51  
-#define MT_ISDDS2 0x52  
-#define MT_ISONSTREAM_SC 0x61  
-#define MT_ISSCSI1 0x71  
+#define MT_ISDDS1 0x51
+#define MT_ISDDS2 0x52
+#define MT_ISONSTREAM_SC 0x61
+#define MT_ISSCSI1 0x71
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MT_ISSCSI2 0x72  
-#define MT_ISFTAPE_UNKNOWN 0x800000  
+#define MT_ISSCSI2 0x72
+#define MT_ISFTAPE_UNKNOWN 0x800000
 #define MT_ISFTAPE_FLAG 0x800000
 struct mt_tape_info {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -126,10 +126,10 @@
 #define MT_FT_RD_SINGLE 0
 #define MT_FT_RD_AHEAD 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MT_FT_WR_ASYNC 0  
-#define MT_FT_WR_MULTI 1  
-#define MT_FT_WR_SINGLE 2  
-#define MT_FT_WR_DELETE 3  
+#define MT_FT_WR_ASYNC 0
+#define MT_FT_WR_MULTI 1
+#define MT_FT_WR_SINGLE 2
+#define MT_FT_WR_DELETE 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct mtftseg
 {
@@ -144,12 +144,12 @@
  unsigned long mt_capacity;
  unsigned long mt_used;
 };
-#define FTFMT_SET_PARMS 1  
+#define FTFMT_SET_PARMS 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FTFMT_GET_PARMS 2  
-#define FTFMT_FORMAT_TRACK 3  
-#define FTFMT_STATUS 4  
-#define FTFMT_VERIFY 5  
+#define FTFMT_GET_PARMS 2
+#define FTFMT_FORMAT_TRACK 3
+#define FTFMT_STATUS 4
+#define FTFMT_VERIFY 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ftfmtparms {
  unsigned char ft_qicstd;
@@ -199,26 +199,26 @@
  int ft_status;
  int ft_error;
 };
-#define MTIOCTOP _IOW('m', 1, struct mtop)  
+#define MTIOCTOP _IOW('m', 1, struct mtop)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MTIOCGET _IOR('m', 2, struct mtget)  
-#define MTIOCPOS _IOR('m', 3, struct mtpos)  
-#define MTIOCGETCONFIG _IOR('m', 4, struct mtconfiginfo)  
-#define MTIOCSETCONFIG _IOW('m', 5, struct mtconfiginfo)  
+#define MTIOCGET _IOR('m', 2, struct mtget)
+#define MTIOCPOS _IOR('m', 3, struct mtpos)
+#define MTIOCGETCONFIG _IOR('m', 4, struct mtconfiginfo)
+#define MTIOCSETCONFIG _IOW('m', 5, struct mtconfiginfo)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MTIOCRDFTSEG _IOWR('m', 6, struct mtftseg)  
-#define MTIOCWRFTSEG _IOWR('m', 7, struct mtftseg)  
-#define MTIOCVOLINFO _IOR('m', 8, struct mtvolinfo)  
-#define MTIOCGETSIZE _IOR('m', 9, struct mttapesize) 
+#define MTIOCRDFTSEG _IOWR('m', 6, struct mtftseg)
+#define MTIOCWRFTSEG _IOWR('m', 7, struct mtftseg)
+#define MTIOCVOLINFO _IOR('m', 8, struct mtvolinfo)
+#define MTIOCGETSIZE _IOR('m', 9, struct mttapesize)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MTIOCFTFORMAT _IOWR('m', 10, struct mtftformat)  
-#define MTIOCFTCMD _IOWR('m', 11, struct mtftcmd)  
+#define MTIOCFTFORMAT _IOWR('m', 10, struct mtftformat)
+#define MTIOCFTCMD _IOWR('m', 11, struct mtftcmd)
 #define GMT_EOF(x) ((x) & 0x80000000)
 #define GMT_BOT(x) ((x) & 0x40000000)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define GMT_EOT(x) ((x) & 0x20000000)
-#define GMT_SM(x) ((x) & 0x10000000)  
-#define GMT_EOD(x) ((x) & 0x08000000)  
+#define GMT_SM(x) ((x) & 0x10000000)
+#define GMT_EOD(x) ((x) & 0x08000000)
 #define GMT_WR_PROT(x) ((x) & 0x04000000)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define GMT_ONLINE(x) ((x) & 0x01000000)
@@ -226,9 +226,9 @@
 #define GMT_D_1600(x) ((x) & 0x00400000)
 #define GMT_D_800(x) ((x) & 0x00200000)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define GMT_DR_OPEN(x) ((x) & 0x00040000)  
-#define GMT_IM_REP_EN(x) ((x) & 0x00010000)  
-#define GMT_CLN(x) ((x) & 0x00008000)  
+#define GMT_DR_OPEN(x) ((x) & 0x00040000)
+#define GMT_IM_REP_EN(x) ((x) & 0x00010000)
+#define GMT_CLN(x) ((x) & 0x00008000)
 #define MT_ST_BLKSIZE_SHIFT 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MT_ST_BLKSIZE_MASK 0xffffff
diff --git a/libc/kernel/common/linux/ncp_mount.h b/libc/kernel/common/linux/ncp_mount.h
index 76b445d..ee3e84f 100644
--- a/libc/kernel/common/linux/ncp_mount.h
+++ b/libc/kernel/common/linux/ncp_mount.h
@@ -21,17 +21,17 @@
 #include <linux/types.h>
 #include <linux/ncp.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NCP_MOUNT_VERSION 3  
+#define NCP_MOUNT_VERSION 3
 #define NCP_MOUNT_SOFT 0x0001
 #define NCP_MOUNT_INTR 0x0002
-#define NCP_MOUNT_STRONG 0x0004  
+#define NCP_MOUNT_STRONG 0x0004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NCP_MOUNT_NO_OS2 0x0008  
-#define NCP_MOUNT_NO_NFS 0x0010  
+#define NCP_MOUNT_NO_OS2 0x0008
+#define NCP_MOUNT_NO_NFS 0x0010
 #define NCP_MOUNT_EXTRAS 0x0020
-#define NCP_MOUNT_SYMLINKS 0x0040  
+#define NCP_MOUNT_SYMLINKS 0x0040
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NCP_MOUNT_NFS_EXTRAS 0x0080  
+#define NCP_MOUNT_NFS_EXTRAS 0x0080
 struct ncp_mount_data {
  int version;
  unsigned int ncp_fd;
@@ -49,7 +49,7 @@
  __kernel_mode_t file_mode;
  __kernel_mode_t dir_mode;
 };
-#define NCP_MOUNT_VERSION_V4 (4)  
+#define NCP_MOUNT_VERSION_V4 (4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ncp_mount_data_v4 {
  int version;
@@ -67,5 +67,5 @@
  unsigned long dir_mode;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define NCP_MOUNT_VERSION_V5 (5)  
+#define NCP_MOUNT_VERSION_V5 (5)
 #endif
diff --git a/libc/kernel/common/linux/neighbour.h b/libc/kernel/common/linux/neighbour.h
index 90de583..a59e69c 100644
--- a/libc/kernel/common/linux/neighbour.h
+++ b/libc/kernel/common/linux/neighbour.h
@@ -47,7 +47,7 @@
 #define NDA_MAX (__NDA_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NTF_USE 0x01
-#define NTF_PROXY 0x08  
+#define NTF_PROXY 0x08
 #define NTF_ROUTER 0x80
 #define NUD_INCOMPLETE 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/net.h b/libc/kernel/common/linux/net.h
index c9bd9f3..a07de66 100644
--- a/libc/kernel/common/linux/net.h
+++ b/libc/kernel/common/linux/net.h
@@ -23,28 +23,28 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct poll_table_struct;
 struct inode;
-#define NPROTO 32  
-#define SYS_SOCKET 1  
+#define NPROTO 32
+#define SYS_SOCKET 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SYS_BIND 2  
-#define SYS_CONNECT 3  
-#define SYS_LISTEN 4  
-#define SYS_ACCEPT 5  
+#define SYS_BIND 2
+#define SYS_CONNECT 3
+#define SYS_LISTEN 4
+#define SYS_ACCEPT 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SYS_GETSOCKNAME 6  
-#define SYS_GETPEERNAME 7  
-#define SYS_SOCKETPAIR 8  
-#define SYS_SEND 9  
+#define SYS_GETSOCKNAME 6
+#define SYS_GETPEERNAME 7
+#define SYS_SOCKETPAIR 8
+#define SYS_SEND 9
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SYS_RECV 10  
-#define SYS_SENDTO 11  
-#define SYS_RECVFROM 12  
-#define SYS_SHUTDOWN 13  
+#define SYS_RECV 10
+#define SYS_SENDTO 11
+#define SYS_RECVFROM 12
+#define SYS_SHUTDOWN 13
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SYS_SETSOCKOPT 14  
-#define SYS_GETSOCKOPT 15  
-#define SYS_SENDMSG 16  
-#define SYS_RECVMSG 17  
+#define SYS_SETSOCKOPT 14
+#define SYS_GETSOCKOPT 15
+#define SYS_SENDMSG 16
+#define SYS_RECVMSG 17
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef enum {
  SS_FREE = 0,
@@ -54,6 +54,6 @@
  SS_CONNECTED,
  SS_DISCONNECTING
 } socket_state;
-#define __SO_ACCEPTCON (1 << 16)  
+#define __SO_ACCEPTCON (1 << 16)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/common/linux/netdevice.h b/libc/kernel/common/linux/netdevice.h
index 77afa1c..7c63616 100644
--- a/libc/kernel/common/linux/netdevice.h
+++ b/libc/kernel/common/linux/netdevice.h
@@ -22,11 +22,11 @@
 #include <linux/if_ether.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <linux/if_packet.h>
-#define MAX_ADDR_LEN 32  
-#define NETDEV_TX_OK 0  
-#define NETDEV_TX_BUSY 1  
+#define MAX_ADDR_LEN 32
+#define NETDEV_TX_OK 0
+#define NETDEV_TX_BUSY 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NETDEV_TX_LOCKED -1  
+#define NETDEV_TX_LOCKED -1
 #define LL_MAX_HEADER 32
 #define MAX_HEADER LL_MAX_HEADER
 struct net_device_stats
diff --git a/libc/kernel/common/linux/netfilter/nfnetlink_conntrack.h b/libc/kernel/common/linux/netfilter/nfnetlink_conntrack.h
index 3f84fe5..10473ef 100644
--- a/libc/kernel/common/linux/netfilter/nfnetlink_conntrack.h
+++ b/libc/kernel/common/linux/netfilter/nfnetlink_conntrack.h
@@ -46,7 +46,7 @@
  CTA_HELP,
  CTA_NAT_SRC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CTA_NAT CTA_NAT_SRC  
+#define CTA_NAT CTA_NAT_SRC
  CTA_TIMEOUT,
  CTA_MARK,
  CTA_COUNTERS_ORIG,
diff --git a/libc/kernel/common/linux/netfilter/x_tables.h b/libc/kernel/common/linux/netfilter/x_tables.h
index 2439ac8..63b75ea 100644
--- a/libc/kernel/common/linux/netfilter/x_tables.h
+++ b/libc/kernel/common/linux/netfilter/x_tables.h
@@ -88,7 +88,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define XT_STANDARD_TARGET ""
 #define XT_ERROR_TARGET "ERROR"
-#define XT_BASE_CTL 64  
+#define XT_BASE_CTL 64
 #define XT_SO_SET_REPLACE (XT_BASE_CTL)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define XT_SO_SET_ADD_COUNTERS (XT_BASE_CTL + 1)
@@ -114,6 +114,6 @@
  unsigned int num_counters;
  struct xt_counters counters[0];
 };
-#define XT_INV_PROTO 0x40  
+#define XT_INV_PROTO 0x40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/common/linux/netfilter/xt_SECMARK.h b/libc/kernel/common/linux/netfilter/xt_SECMARK.h
index 7060f0b..ead6c95 100644
--- a/libc/kernel/common/linux/netfilter/xt_SECMARK.h
+++ b/libc/kernel/common/linux/netfilter/xt_SECMARK.h
@@ -18,7 +18,7 @@
  ****************************************************************************/
 #ifndef _XT_SECMARK_H_target
 #define _XT_SECMARK_H_target
-#define SECMARK_MODE_SEL 0x01  
+#define SECMARK_MODE_SEL 0x01
 #define SECMARK_SELCTX_MAX 256
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct xt_secmark_target_selinux_info {
diff --git a/libc/kernel/common/linux/netfilter/xt_esp.h b/libc/kernel/common/linux/netfilter/xt_esp.h
index ad76c2e..c2fdb43 100644
--- a/libc/kernel/common/linux/netfilter/xt_esp.h
+++ b/libc/kernel/common/linux/netfilter/xt_esp.h
@@ -24,7 +24,7 @@
  u_int32_t spis[2];
  u_int8_t invflags;
 };
-#define XT_ESP_INV_SPI 0x01  
+#define XT_ESP_INV_SPI 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define XT_ESP_INV_MASK 0x01  
+#define XT_ESP_INV_MASK 0x01
 #endif
diff --git a/libc/kernel/common/linux/netfilter/xt_sctp.h b/libc/kernel/common/linux/netfilter/xt_sctp.h
index 7591375..d9d5f55 100644
--- a/libc/kernel/common/linux/netfilter/xt_sctp.h
+++ b/libc/kernel/common/linux/netfilter/xt_sctp.h
@@ -37,9 +37,9 @@
  u_int16_t spts[2];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  u_int32_t chunkmap[256 / sizeof (u_int32_t)];
-#define SCTP_CHUNK_MATCH_ANY 0x01  
-#define SCTP_CHUNK_MATCH_ALL 0x02  
-#define SCTP_CHUNK_MATCH_ONLY 0x04  
+#define SCTP_CHUNK_MATCH_ANY 0x01
+#define SCTP_CHUNK_MATCH_ALL 0x02
+#define SCTP_CHUNK_MATCH_ONLY 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  u_int32_t chunk_match_type;
  struct xt_sctp_flag_info flag_info[XT_NUM_SCTP_FLAGS];
diff --git a/libc/kernel/common/linux/netfilter/xt_tcpudp.h b/libc/kernel/common/linux/netfilter/xt_tcpudp.h
index 52ec36f..54f67f9 100644
--- a/libc/kernel/common/linux/netfilter/xt_tcpudp.h
+++ b/libc/kernel/common/linux/netfilter/xt_tcpudp.h
@@ -29,12 +29,12 @@
  u_int8_t flg_cmp;
  u_int8_t invflags;
 };
-#define XT_TCP_INV_SRCPT 0x01  
+#define XT_TCP_INV_SRCPT 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define XT_TCP_INV_DSTPT 0x02  
-#define XT_TCP_INV_FLAGS 0x04  
-#define XT_TCP_INV_OPTION 0x08  
-#define XT_TCP_INV_MASK 0x0F  
+#define XT_TCP_INV_DSTPT 0x02
+#define XT_TCP_INV_FLAGS 0x04
+#define XT_TCP_INV_OPTION 0x08
+#define XT_TCP_INV_MASK 0x0F
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct xt_udp
 {
@@ -43,8 +43,8 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  u_int8_t invflags;
 };
-#define XT_UDP_INV_SRCPT 0x01  
-#define XT_UDP_INV_DSTPT 0x02  
+#define XT_UDP_INV_SRCPT 0x01
+#define XT_UDP_INV_DSTPT 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define XT_UDP_INV_MASK 0x03  
+#define XT_UDP_INV_MASK 0x03
 #endif
diff --git a/libc/kernel/common/linux/netfilter_arp/arp_tables.h b/libc/kernel/common/linux/netfilter_arp/arp_tables.h
index e337386..137719d 100644
--- a/libc/kernel/common/linux/netfilter_arp/arp_tables.h
+++ b/libc/kernel/common/linux/netfilter_arp/arp_tables.h
@@ -53,21 +53,21 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define arpt_entry_target xt_entry_target
 #define arpt_standard_target xt_standard_target
-#define ARPT_F_MASK 0x00  
-#define ARPT_INV_VIA_IN 0x0001  
+#define ARPT_F_MASK 0x00
+#define ARPT_INV_VIA_IN 0x0001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARPT_INV_VIA_OUT 0x0002  
-#define ARPT_INV_SRCIP 0x0004  
-#define ARPT_INV_TGTIP 0x0008  
-#define ARPT_INV_SRCDEVADDR 0x0010  
+#define ARPT_INV_VIA_OUT 0x0002
+#define ARPT_INV_SRCIP 0x0004
+#define ARPT_INV_TGTIP 0x0008
+#define ARPT_INV_SRCDEVADDR 0x0010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARPT_INV_TGTDEVADDR 0x0020  
-#define ARPT_INV_ARPOP 0x0040  
-#define ARPT_INV_ARPHRD 0x0080  
-#define ARPT_INV_ARPPRO 0x0100  
+#define ARPT_INV_TGTDEVADDR 0x0020
+#define ARPT_INV_ARPOP 0x0040
+#define ARPT_INV_ARPHRD 0x0080
+#define ARPT_INV_ARPPRO 0x0100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARPT_INV_ARPHLN 0x0200  
-#define ARPT_INV_MASK 0x03FF  
+#define ARPT_INV_ARPHLN 0x0200
+#define ARPT_INV_MASK 0x03FF
 struct arpt_entry
 {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/netfilter_ipv4/ip_queue.h b/libc/kernel/common/linux/netfilter_ipv4/ip_queue.h
index 0fc6b43..bf5a387 100644
--- a/libc/kernel/common/linux/netfilter_ipv4/ip_queue.h
+++ b/libc/kernel/common/linux/netfilter_ipv4/ip_queue.h
@@ -66,10 +66,10 @@
 };
 #define IPQ_COPY_MAX IPQ_COPY_PACKET
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IPQM_BASE 0x10  
-#define IPQM_MODE (IPQM_BASE + 1)  
-#define IPQM_VERDICT (IPQM_BASE + 2)   
-#define IPQM_PACKET (IPQM_BASE + 3)  
+#define IPQM_BASE 0x10
+#define IPQM_MODE (IPQM_BASE + 1)
+#define IPQM_VERDICT (IPQM_BASE + 2)
+#define IPQM_PACKET (IPQM_BASE + 3)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IPQM_MAX (IPQM_BASE + 4)
 #endif
diff --git a/libc/kernel/common/linux/netfilter_ipv4/ip_tables.h b/libc/kernel/common/linux/netfilter_ipv4/ip_tables.h
index 6174ee3..e5e9d66 100644
--- a/libc/kernel/common/linux/netfilter_ipv4/ip_tables.h
+++ b/libc/kernel/common/linux/netfilter_ipv4/ip_tables.h
@@ -46,19 +46,19 @@
 #define ipt_standard_target xt_standard_target
 #define ipt_counters xt_counters
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IPT_F_FRAG 0x01  
-#define IPT_F_GOTO 0x02  
-#define IPT_F_MASK 0x03  
-#define IPT_INV_VIA_IN 0x01  
+#define IPT_F_FRAG 0x01
+#define IPT_F_GOTO 0x02
+#define IPT_F_MASK 0x03
+#define IPT_INV_VIA_IN 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IPT_INV_VIA_OUT 0x02  
-#define IPT_INV_TOS 0x04  
-#define IPT_INV_SRCIP 0x08  
-#define IPT_INV_DSTIP 0x10  
+#define IPT_INV_VIA_OUT 0x02
+#define IPT_INV_TOS 0x04
+#define IPT_INV_SRCIP 0x08
+#define IPT_INV_DSTIP 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IPT_INV_FRAG 0x20  
+#define IPT_INV_FRAG 0x20
 #define IPT_INV_PROTO XT_INV_PROTO
-#define IPT_INV_MASK 0x7F  
+#define IPT_INV_MASK 0x7F
 struct ipt_entry
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 {
@@ -107,7 +107,7 @@
  u_int8_t invflags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define IPT_ICMP_INV 0x01  
+#define IPT_ICMP_INV 0x01
 struct ipt_getinfo
 {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/netfilter_ipv4/ipt_ECN.h b/libc/kernel/common/linux/netfilter_ipv4/ipt_ECN.h
index 5d9e7a9..2a3d652 100644
--- a/libc/kernel/common/linux/netfilter_ipv4/ipt_ECN.h
+++ b/libc/kernel/common/linux/netfilter_ipv4/ipt_ECN.h
@@ -21,9 +21,9 @@
 #include <linux/netfilter_ipv4/ipt_DSCP.h>
 #define IPT_ECN_IP_MASK (~IPT_DSCP_MASK)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IPT_ECN_OP_SET_IP 0x01  
-#define IPT_ECN_OP_SET_ECE 0x10  
-#define IPT_ECN_OP_SET_CWR 0x20  
+#define IPT_ECN_OP_SET_IP 0x01
+#define IPT_ECN_OP_SET_ECE 0x10
+#define IPT_ECN_OP_SET_CWR 0x20
 #define IPT_ECN_OP_MASK 0xce
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ipt_ECN_info {
diff --git a/libc/kernel/common/linux/netfilter_ipv4/ipt_LOG.h b/libc/kernel/common/linux/netfilter_ipv4/ipt_LOG.h
index d2b6607..6653863 100644
--- a/libc/kernel/common/linux/netfilter_ipv4/ipt_LOG.h
+++ b/libc/kernel/common/linux/netfilter_ipv4/ipt_LOG.h
@@ -18,12 +18,12 @@
  ****************************************************************************/
 #ifndef _IPT_LOG_H
 #define _IPT_LOG_H
-#define IPT_LOG_TCPSEQ 0x01  
-#define IPT_LOG_TCPOPT 0x02  
+#define IPT_LOG_TCPSEQ 0x01
+#define IPT_LOG_TCPOPT 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IPT_LOG_IPOPT 0x04  
-#define IPT_LOG_UID 0x08  
-#define IPT_LOG_NFLOG 0x10  
+#define IPT_LOG_IPOPT 0x04
+#define IPT_LOG_UID 0x08
+#define IPT_LOG_NFLOG 0x10
 #define IPT_LOG_MASK 0x1f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ipt_log_info {
diff --git a/libc/kernel/common/linux/netfilter_ipv4/ipt_ah.h b/libc/kernel/common/linux/netfilter_ipv4/ipt_ah.h
index 3d60809..f6a81b8 100644
--- a/libc/kernel/common/linux/netfilter_ipv4/ipt_ah.h
+++ b/libc/kernel/common/linux/netfilter_ipv4/ipt_ah.h
@@ -24,7 +24,7 @@
  u_int32_t spis[2];
  u_int8_t invflags;
 };
-#define IPT_AH_INV_SPI 0x01  
+#define IPT_AH_INV_SPI 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IPT_AH_INV_MASK 0x01  
+#define IPT_AH_INV_MASK 0x01
 #endif
diff --git a/libc/kernel/common/linux/netfilter_ipv4/ipt_dscp_.h b/libc/kernel/common/linux/netfilter_ipv4/ipt_dscp_.h
index e315e35..0aa6f87 100644
--- a/libc/kernel/common/linux/netfilter_ipv4/ipt_dscp_.h
+++ b/libc/kernel/common/linux/netfilter_ipv4/ipt_dscp_.h
@@ -18,10 +18,10 @@
  ****************************************************************************/
 #ifndef _IPT_DSCP_H
 #define _IPT_DSCP_H
-#define IPT_DSCP_MASK 0xfc  
+#define IPT_DSCP_MASK 0xfc
 #define IPT_DSCP_SHIFT 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IPT_DSCP_MAX 0x3f  
+#define IPT_DSCP_MAX 0x3f
 struct ipt_dscp_info {
  u_int8_t dscp;
  u_int8_t invert;
diff --git a/libc/kernel/common/linux/netfilter_ipv4/ipt_iprange.h b/libc/kernel/common/linux/netfilter_ipv4/ipt_iprange.h
index 6ac3b9a..bd2b755 100644
--- a/libc/kernel/common/linux/netfilter_ipv4/ipt_iprange.h
+++ b/libc/kernel/common/linux/netfilter_ipv4/ipt_iprange.h
@@ -18,11 +18,11 @@
  ****************************************************************************/
 #ifndef _IPT_IPRANGE_H
 #define _IPT_IPRANGE_H
-#define IPRANGE_SRC 0x01  
-#define IPRANGE_DST 0x02  
+#define IPRANGE_SRC 0x01
+#define IPRANGE_DST 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IPRANGE_SRC_INV 0x10  
-#define IPRANGE_DST_INV 0x20  
+#define IPRANGE_SRC_INV 0x10
+#define IPRANGE_DST_INV 0x20
 struct ipt_iprange {
  u_int32_t min_ip, max_ip;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/netfilter_ipv4/ipt_sctp.h b/libc/kernel/common/linux/netfilter_ipv4/ipt_sctp.h
index 786c4d2..8a0282b 100644
--- a/libc/kernel/common/linux/netfilter_ipv4/ipt_sctp.h
+++ b/libc/kernel/common/linux/netfilter_ipv4/ipt_sctp.h
@@ -36,9 +36,9 @@
  u_int16_t spts[2];
  u_int32_t chunkmap[256 / sizeof (u_int32_t)];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SCTP_CHUNK_MATCH_ANY 0x01  
-#define SCTP_CHUNK_MATCH_ALL 0x02  
-#define SCTP_CHUNK_MATCH_ONLY 0x04  
+#define SCTP_CHUNK_MATCH_ANY 0x01
+#define SCTP_CHUNK_MATCH_ALL 0x02
+#define SCTP_CHUNK_MATCH_ONLY 0x04
  u_int32_t chunk_match_type;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  struct ipt_sctp_flag_info flag_info[IPT_NUM_SCTP_FLAGS];
diff --git a/libc/kernel/common/linux/netfilter_ipv6/ip6_tables.h b/libc/kernel/common/linux/netfilter_ipv6/ip6_tables.h
index daea636..b8da2a3 100644
--- a/libc/kernel/common/linux/netfilter_ipv6/ip6_tables.h
+++ b/libc/kernel/common/linux/netfilter_ipv6/ip6_tables.h
@@ -47,21 +47,21 @@
 #define ip6t_standard_target xt_standard_target
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ip6t_counters xt_counters
-#define IP6T_F_PROTO 0x01  
-#define IP6T_F_TOS 0x02  
-#define IP6T_F_GOTO 0x04  
+#define IP6T_F_PROTO 0x01
+#define IP6T_F_TOS 0x02
+#define IP6T_F_GOTO 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IP6T_F_MASK 0x07  
-#define IP6T_INV_VIA_IN 0x01  
-#define IP6T_INV_VIA_OUT 0x02  
-#define IP6T_INV_TOS 0x04  
+#define IP6T_F_MASK 0x07
+#define IP6T_INV_VIA_IN 0x01
+#define IP6T_INV_VIA_OUT 0x02
+#define IP6T_INV_TOS 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IP6T_INV_SRCIP 0x08  
-#define IP6T_INV_DSTIP 0x10  
-#define IP6T_INV_FRAG 0x20  
+#define IP6T_INV_SRCIP 0x08
+#define IP6T_INV_DSTIP 0x10
+#define IP6T_INV_FRAG 0x20
 #define IP6T_INV_PROTO XT_INV_PROTO
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IP6T_INV_MASK 0x7F  
+#define IP6T_INV_MASK 0x7F
 struct ip6t_entry
 {
  struct ip6t_ip6 ipv6;
@@ -109,7 +109,7 @@
  u_int8_t code[2];
  u_int8_t invflags;
 };
-#define IP6T_ICMP_INV 0x01  
+#define IP6T_ICMP_INV 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ip6t_getinfo
 {
diff --git a/libc/kernel/common/linux/netfilter_ipv6/ip6t_LOG.h b/libc/kernel/common/linux/netfilter_ipv6/ip6t_LOG.h
index 5664180..b12a38c 100644
--- a/libc/kernel/common/linux/netfilter_ipv6/ip6t_LOG.h
+++ b/libc/kernel/common/linux/netfilter_ipv6/ip6t_LOG.h
@@ -18,12 +18,12 @@
  ****************************************************************************/
 #ifndef _IP6T_LOG_H
 #define _IP6T_LOG_H
-#define IP6T_LOG_TCPSEQ 0x01  
-#define IP6T_LOG_TCPOPT 0x02  
+#define IP6T_LOG_TCPSEQ 0x01
+#define IP6T_LOG_TCPOPT 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IP6T_LOG_IPOPT 0x04  
-#define IP6T_LOG_UID 0x08  
-#define IP6T_LOG_NFLOG 0x10  
+#define IP6T_LOG_IPOPT 0x04
+#define IP6T_LOG_UID 0x08
+#define IP6T_LOG_NFLOG 0x10
 #define IP6T_LOG_MASK 0x1f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ip6t_log_info {
diff --git a/libc/kernel/common/linux/netfilter_ipv6/ip6t_ah.h b/libc/kernel/common/linux/netfilter_ipv6/ip6t_ah.h
index ff1c3dc..b564f02 100644
--- a/libc/kernel/common/linux/netfilter_ipv6/ip6t_ah.h
+++ b/libc/kernel/common/linux/netfilter_ipv6/ip6t_ah.h
@@ -31,8 +31,8 @@
 #define IP6T_AH_LEN 0x02
 #define IP6T_AH_RES 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IP6T_AH_INV_SPI 0x01  
-#define IP6T_AH_INV_LEN 0x02  
-#define IP6T_AH_INV_MASK 0x03  
+#define IP6T_AH_INV_SPI 0x01
+#define IP6T_AH_INV_LEN 0x02
+#define IP6T_AH_INV_MASK 0x03
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/netfilter_ipv6/ip6t_frag.h b/libc/kernel/common/linux/netfilter_ipv6/ip6t_frag.h
index f9f2518..cb0c68d 100644
--- a/libc/kernel/common/linux/netfilter_ipv6/ip6t_frag.h
+++ b/libc/kernel/common/linux/netfilter_ipv6/ip6t_frag.h
@@ -34,8 +34,8 @@
 #define IP6T_FRAG_FST 0x08
 #define IP6T_FRAG_MF 0x10
 #define IP6T_FRAG_NMF 0x20
-#define IP6T_FRAG_INV_IDS 0x01  
+#define IP6T_FRAG_INV_IDS 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IP6T_FRAG_INV_LEN 0x02  
-#define IP6T_FRAG_INV_MASK 0x03  
+#define IP6T_FRAG_INV_LEN 0x02
+#define IP6T_FRAG_INV_MASK 0x03
 #endif
diff --git a/libc/kernel/common/linux/netfilter_ipv6/ip6t_opts.h b/libc/kernel/common/linux/netfilter_ipv6/ip6t_opts.h
index ff2b574..777a2dd 100644
--- a/libc/kernel/common/linux/netfilter_ipv6/ip6t_opts.h
+++ b/libc/kernel/common/linux/netfilter_ipv6/ip6t_opts.h
@@ -33,7 +33,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IP6T_OPTS_OPTS 0x02
 #define IP6T_OPTS_NSTRICT 0x04
-#define IP6T_OPTS_INV_LEN 0x01  
-#define IP6T_OPTS_INV_MASK 0x01  
+#define IP6T_OPTS_INV_LEN 0x01
+#define IP6T_OPTS_INV_MASK 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/common/linux/netfilter_ipv6/ip6t_rt.h b/libc/kernel/common/linux/netfilter_ipv6/ip6t_rt.h
index e1d12a5..4713821 100644
--- a/libc/kernel/common/linux/netfilter_ipv6/ip6t_rt.h
+++ b/libc/kernel/common/linux/netfilter_ipv6/ip6t_rt.h
@@ -41,9 +41,9 @@
 #define IP6T_RT_FST 0x10
 #define IP6T_RT_FST_NSTRICT 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IP6T_RT_INV_TYP 0x01  
-#define IP6T_RT_INV_SGS 0x02  
-#define IP6T_RT_INV_LEN 0x04  
-#define IP6T_RT_INV_MASK 0x07  
+#define IP6T_RT_INV_TYP 0x01
+#define IP6T_RT_INV_SGS 0x02
+#define IP6T_RT_INV_LEN 0x04
+#define IP6T_RT_INV_MASK 0x07
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/common/linux/netlink.h b/libc/kernel/common/linux/netlink.h
index 4c79fcf..b700086 100644
--- a/libc/kernel/common/linux/netlink.h
+++ b/libc/kernel/common/linux/netlink.h
@@ -18,36 +18,36 @@
  ****************************************************************************/
 #ifndef __LINUX_NETLINK_H
 #define __LINUX_NETLINK_H
-#include <linux/socket.h>  
+#include <linux/socket.h>
 #include <linux/types.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NETLINK_ROUTE 0  
-#define NETLINK_UNUSED 1  
-#define NETLINK_USERSOCK 2  
-#define NETLINK_FIREWALL 3  
+#define NETLINK_ROUTE 0
+#define NETLINK_UNUSED 1
+#define NETLINK_USERSOCK 2
+#define NETLINK_FIREWALL 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NETLINK_INET_DIAG 4  
-#define NETLINK_NFLOG 5  
-#define NETLINK_XFRM 6  
-#define NETLINK_SELINUX 7  
+#define NETLINK_INET_DIAG 4
+#define NETLINK_NFLOG 5
+#define NETLINK_XFRM 6
+#define NETLINK_SELINUX 7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NETLINK_ISCSI 8  
-#define NETLINK_AUDIT 9  
-#define NETLINK_FIB_LOOKUP 10 
+#define NETLINK_ISCSI 8
+#define NETLINK_AUDIT 9
+#define NETLINK_FIB_LOOKUP 10
 #define NETLINK_CONNECTOR 11
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NETLINK_NETFILTER 12  
+#define NETLINK_NETFILTER 12
 #define NETLINK_IP6_FW 13
-#define NETLINK_DNRTMSG 14  
-#define NETLINK_KOBJECT_UEVENT 15  
+#define NETLINK_DNRTMSG 14
+#define NETLINK_KOBJECT_UEVENT 15
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NETLINK_GENERIC 16
-#define NETLINK_SCSITRANSPORT 18  
+#define NETLINK_SCSITRANSPORT 18
 #define NETLINK_ECRYPTFS 19
 #define NETLINK_RDMA 20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NETLINK_IDLETIMER 21
-#define MAX_LINKS 32 
+#define MAX_LINKS 32
 struct sockaddr_nl {
  sa_family_t nl_family;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -64,21 +64,21 @@
  __u32 nlmsg_seq;
  __u32 nlmsg_pid;
 };
-#define NLM_F_REQUEST 1  
+#define NLM_F_REQUEST 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NLM_F_MULTI 2  
-#define NLM_F_ACK 4  
-#define NLM_F_ECHO 8  
-#define NLM_F_ROOT 0x100  
+#define NLM_F_MULTI 2
+#define NLM_F_ACK 4
+#define NLM_F_ECHO 8
+#define NLM_F_ROOT 0x100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NLM_F_MATCH 0x200  
-#define NLM_F_ATOMIC 0x400  
+#define NLM_F_MATCH 0x200
+#define NLM_F_ATOMIC 0x400
 #define NLM_F_DUMP (NLM_F_ROOT|NLM_F_MATCH)
-#define NLM_F_REPLACE 0x100  
+#define NLM_F_REPLACE 0x100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NLM_F_EXCL 0x200  
-#define NLM_F_CREATE 0x400  
-#define NLM_F_APPEND 0x800  
+#define NLM_F_EXCL 0x200
+#define NLM_F_CREATE 0x400
+#define NLM_F_APPEND 0x800
 #define NLMSG_ALIGNTO 4U
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) )
@@ -91,12 +91,12 @@
 #define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) &&   (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) &&   (nlh)->nlmsg_len <= (len))
 #define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len)))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NLMSG_NOOP 0x1  
-#define NLMSG_ERROR 0x2  
-#define NLMSG_DONE 0x3  
-#define NLMSG_OVERRUN 0x4  
+#define NLMSG_NOOP 0x1
+#define NLMSG_ERROR 0x2
+#define NLMSG_DONE 0x3
+#define NLMSG_OVERRUN 0x4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NLMSG_MIN_TYPE 0x10  
+#define NLMSG_MIN_TYPE 0x10
 struct nlmsgerr {
  int error;
  struct nlmsghdr msg;
@@ -112,7 +112,7 @@
  __u32 group;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define NET_MAJOR 36  
+#define NET_MAJOR 36
 enum {
  NETLINK_UNCONNECTED = 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/nfs_xdr.h b/libc/kernel/common/linux/nfs_xdr.h
index 865e178..4ddecd7 100644
--- a/libc/kernel/common/linux/nfs_xdr.h
+++ b/libc/kernel/common/linux/nfs_xdr.h
@@ -68,12 +68,12 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long time_start;
 };
-#define NFS_ATTR_WCC 0x0001  
-#define NFS_ATTR_FATTR 0x0002  
+#define NFS_ATTR_WCC 0x0001
+#define NFS_ATTR_FATTR 0x0002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NFS_ATTR_FATTR_V3 0x0004  
-#define NFS_ATTR_FATTR_V4 0x0008  
-#define NFS_ATTR_FATTR_V4_REFERRAL 0x0010  
+#define NFS_ATTR_FATTR_V3 0x0004
+#define NFS_ATTR_FATTR_V4 0x0008
+#define NFS_ATTR_FATTR_V4_REFERRAL 0x0010
 struct nfs_fsinfo {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  struct nfs_fattr *fattr;
diff --git a/libc/kernel/common/linux/nfsd/export.h b/libc/kernel/common/linux/nfsd/export.h
index 7bb5774..bc71b82 100644
--- a/libc/kernel/common/linux/nfsd/export.h
+++ b/libc/kernel/common/linux/nfsd/export.h
@@ -33,12 +33,12 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFSEXP_NOHIDE 0x0200
 #define NFSEXP_NOSUBTREECHECK 0x0400
-#define NFSEXP_NOAUTHNLM 0x0800  
-#define NFSEXP_MSNFS 0x1000  
+#define NFSEXP_NOAUTHNLM 0x0800
+#define NFSEXP_MSNFS 0x1000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFSEXP_FSID 0x2000
 #define NFSEXP_CROSSMOUNT 0x4000
-#define NFSEXP_NOACL 0x8000  
+#define NFSEXP_NOACL 0x8000
 #define NFSEXP_ALLFLAGS 0xFE3F
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/common/linux/nvhdcp.h b/libc/kernel/common/linux/nvhdcp.h
index dadc512..576896a 100644
--- a/libc/kernel/common/linux/nvhdcp.h
+++ b/libc/kernel/common/linux/nvhdcp.h
@@ -27,14 +27,14 @@
 #define TEGRA_NVHDCP_FLAG_AKSV 0x0002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TEGRA_NVHDCP_FLAG_BKSV 0x0004
-#define TEGRA_NVHDCP_FLAG_BSTATUS 0x0008  
-#define TEGRA_NVHDCP_FLAG_CN 0x0010  
-#define TEGRA_NVHDCP_FLAG_CKSV 0x0020  
+#define TEGRA_NVHDCP_FLAG_BSTATUS 0x0008
+#define TEGRA_NVHDCP_FLAG_CN 0x0010
+#define TEGRA_NVHDCP_FLAG_CKSV 0x0020
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TEGRA_NVHDCP_FLAG_DKSV 0x0040  
-#define TEGRA_NVHDCP_FLAG_KP 0x0080  
-#define TEGRA_NVHDCP_FLAG_S 0x0100  
-#define TEGRA_NVHDCP_FLAG_CS 0x0200  
+#define TEGRA_NVHDCP_FLAG_DKSV 0x0040
+#define TEGRA_NVHDCP_FLAG_KP 0x0080
+#define TEGRA_NVHDCP_FLAG_S 0x0100
+#define TEGRA_NVHDCP_FLAG_CS 0x0200
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TEGRA_NVHDCP_FLAG_V 0x0400
 #define TEGRA_NVHDCP_FLAG_MP 0x0800
diff --git a/libc/kernel/common/linux/nvram.h b/libc/kernel/common/linux/nvram.h
index 06aaa9d..8496f79 100644
--- a/libc/kernel/common/linux/nvram.h
+++ b/libc/kernel/common/linux/nvram.h
@@ -19,9 +19,9 @@
 #ifndef _LINUX_NVRAM_H
 #define _LINUX_NVRAM_H
 #include <linux/ioctl.h>
-#define NVRAM_INIT _IO('p', 0x40)  
+#define NVRAM_INIT _IO('p', 0x40)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NVRAM_SETCKS _IO('p', 0x41)  
+#define NVRAM_SETCKS _IO('p', 0x41)
 #define NVRAM_FIRST_BYTE 14
 #define NVRAM_OFFSET(x) ((x)-NVRAM_FIRST_BYTE)
 #endif
diff --git a/libc/kernel/common/linux/pagemap.h b/libc/kernel/common/linux/pagemap.h
index 2a5223a..c91e78b 100644
--- a/libc/kernel/common/linux/pagemap.h
+++ b/libc/kernel/common/linux/pagemap.h
@@ -27,8 +27,8 @@
 #include <asm/uaccess.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <linux/gfp.h>
-#define AS_EIO (__GFP_BITS_SHIFT + 0)  
-#define AS_ENOSPC (__GFP_BITS_SHIFT + 1)  
+#define AS_EIO (__GFP_BITS_SHIFT + 0)
+#define AS_ENOSPC (__GFP_BITS_SHIFT + 1)
 #define PAGE_CACHE_SHIFT PAGE_SHIFT
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PAGE_CACHE_SIZE PAGE_SIZE
diff --git a/libc/kernel/common/linux/pci.h b/libc/kernel/common/linux/pci.h
index cecaf07..48487a8 100644
--- a/libc/kernel/common/linux/pci.h
+++ b/libc/kernel/common/linux/pci.h
@@ -26,9 +26,9 @@
 #define PCI_FUNC(devfn) ((devfn) & 0x07)
 #define PCIIOC_BASE ('P' << 24 | 'C' << 16 | 'I' << 8)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCIIOC_CONTROLLER (PCIIOC_BASE | 0x00)  
-#define PCIIOC_MMAP_IS_IO (PCIIOC_BASE | 0x01)  
-#define PCIIOC_MMAP_IS_MEM (PCIIOC_BASE | 0x02)  
-#define PCIIOC_WRITE_COMBINE (PCIIOC_BASE | 0x03)  
+#define PCIIOC_CONTROLLER (PCIIOC_BASE | 0x00)
+#define PCIIOC_MMAP_IS_IO (PCIIOC_BASE | 0x01)
+#define PCIIOC_MMAP_IS_MEM (PCIIOC_BASE | 0x02)
+#define PCIIOC_WRITE_COMBINE (PCIIOC_BASE | 0x03)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/common/linux/pci_ids.h b/libc/kernel/common/linux/pci_ids.h
index ec37495..651183c 100644
--- a/libc/kernel/common/linux/pci_ids.h
+++ b/libc/kernel/common/linux/pci_ids.h
@@ -512,7 +512,7 @@
 #define PCI_DEVICE_ID_IBM_ICOM_V2_ONE_PORT_RVX_ONE_PORT_MDM 0x0251
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_DEVICE_ID_IBM_ICOM_FOUR_PORT_MODEL 0x252
-#define PCI_VENDOR_ID_COMPEX2 0x101a  
+#define PCI_VENDOR_ID_COMPEX2 0x101a
 #define PCI_DEVICE_ID_COMPEX2_100VG 0x0005
 #define PCI_VENDOR_ID_WD 0x101c
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -634,34 +634,34 @@
 #define PCI_DEVICE_ID_MIRO_DC10PLUS 0x7efe
 #define PCI_DEVICE_ID_MIRO_DC30PLUS 0xd801
 #define PCI_VENDOR_ID_NEC 0x1033
-#define PCI_DEVICE_ID_NEC_CBUS_1 0x0001  
+#define PCI_DEVICE_ID_NEC_CBUS_1 0x0001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_DEVICE_ID_NEC_LOCAL 0x0002  
-#define PCI_DEVICE_ID_NEC_ATM 0x0003  
-#define PCI_DEVICE_ID_NEC_R4000 0x0004  
-#define PCI_DEVICE_ID_NEC_486 0x0005  
+#define PCI_DEVICE_ID_NEC_LOCAL 0x0002
+#define PCI_DEVICE_ID_NEC_ATM 0x0003
+#define PCI_DEVICE_ID_NEC_R4000 0x0004
+#define PCI_DEVICE_ID_NEC_486 0x0005
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_DEVICE_ID_NEC_ACCEL_1 0x0006  
-#define PCI_DEVICE_ID_NEC_UXBUS 0x0007  
-#define PCI_DEVICE_ID_NEC_ACCEL_2 0x0008  
-#define PCI_DEVICE_ID_NEC_GRAPH 0x0009  
+#define PCI_DEVICE_ID_NEC_ACCEL_1 0x0006
+#define PCI_DEVICE_ID_NEC_UXBUS 0x0007
+#define PCI_DEVICE_ID_NEC_ACCEL_2 0x0008
+#define PCI_DEVICE_ID_NEC_GRAPH 0x0009
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_DEVICE_ID_NEC_VL 0x0016  
-#define PCI_DEVICE_ID_NEC_STARALPHA2 0x002c  
-#define PCI_DEVICE_ID_NEC_CBUS_2 0x002d  
-#define PCI_DEVICE_ID_NEC_USB 0x0035  
+#define PCI_DEVICE_ID_NEC_VL 0x0016
+#define PCI_DEVICE_ID_NEC_STARALPHA2 0x002c
+#define PCI_DEVICE_ID_NEC_CBUS_2 0x002d
+#define PCI_DEVICE_ID_NEC_USB 0x0035
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_DEVICE_ID_NEC_CBUS_3 0x003b
 #define PCI_DEVICE_ID_NEC_NAPCCARD 0x003e
-#define PCI_DEVICE_ID_NEC_PCX2 0x0046  
+#define PCI_DEVICE_ID_NEC_PCX2 0x0046
 #define PCI_DEVICE_ID_NEC_NILE4 0x005a
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_DEVICE_ID_NEC_VRC5476 0x009b
 #define PCI_DEVICE_ID_NEC_VRC4173 0x00a5
 #define PCI_DEVICE_ID_NEC_VRC5477_AC97 0x00a6
-#define PCI_DEVICE_ID_NEC_PC9821CS01 0x800c  
+#define PCI_DEVICE_ID_NEC_PC9821CS01 0x800c
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_DEVICE_ID_NEC_PC9821NRB06 0x800d  
+#define PCI_DEVICE_ID_NEC_PC9821NRB06 0x800d
 #define PCI_VENDOR_ID_FD 0x1036
 #define PCI_DEVICE_ID_FD_36C70 0x0000
 #define PCI_VENDOR_ID_SI 0x1039
@@ -1383,10 +1383,10 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI 0x3fc6
 #define PCI_VENDOR_ID_INIT 0x1101
-#define PCI_VENDOR_ID_CREATIVE 0x1102  
+#define PCI_VENDOR_ID_CREATIVE 0x1102
 #define PCI_DEVICE_ID_CREATIVE_EMU10K1 0x0002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_VENDOR_ID_ECTIVA 0x1102  
+#define PCI_VENDOR_ID_ECTIVA 0x1102
 #define PCI_DEVICE_ID_ECTIVA_EV1938 0x8938
 #define PCI_VENDOR_ID_TTI 0x1103
 #define PCI_DEVICE_ID_TTI_HPT343 0x0003
@@ -1397,7 +1397,7 @@
 #define PCI_DEVICE_ID_TTI_HPT371 0x0007
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_DEVICE_ID_TTI_HPT374 0x0008
-#define PCI_DEVICE_ID_TTI_HPT372N 0x0009  
+#define PCI_DEVICE_ID_TTI_HPT372N 0x0009
 #define PCI_VENDOR_ID_VIA 0x1106
 #define PCI_DEVICE_ID_VIA_8763_0 0x0198
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -1678,8 +1678,8 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_DEVICE_ID_RP8J 0x0006
 #define PCI_DEVICE_ID_RP4J 0x0007
-#define PCI_DEVICE_ID_RP8SNI 0x0008 
-#define PCI_DEVICE_ID_RP16SNI 0x0009 
+#define PCI_DEVICE_ID_RP8SNI 0x0008
+#define PCI_DEVICE_ID_RP16SNI 0x0009
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_DEVICE_ID_RPP4 0x000A
 #define PCI_DEVICE_ID_RPP8 0x000B
@@ -1692,9 +1692,9 @@
 #define PCI_DEVICE_ID_URP16INTF 0x0803
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_DEVICE_ID_URP8OCTA 0x0805
-#define PCI_DEVICE_ID_UPCI_RM3_8PORT 0x080C 
+#define PCI_DEVICE_ID_UPCI_RM3_8PORT 0x080C
 #define PCI_DEVICE_ID_UPCI_RM3_4PORT 0x080D
-#define PCI_DEVICE_ID_CRP16INTF 0x0903 
+#define PCI_DEVICE_ID_CRP16INTF 0x0903
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_VENDOR_ID_CYCLADES 0x120e
 #define PCI_DEVICE_ID_CYCLOM_Y_Lo 0x0100
@@ -2002,22 +2002,22 @@
 #define PCI_DEVICE_ID_CMEDIA_CM8738B 0x0112
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_VENDOR_ID_LAVA 0x1407
-#define PCI_DEVICE_ID_LAVA_DSERIAL 0x0100  
-#define PCI_DEVICE_ID_LAVA_QUATRO_A 0x0101  
-#define PCI_DEVICE_ID_LAVA_QUATRO_B 0x0102  
+#define PCI_DEVICE_ID_LAVA_DSERIAL 0x0100
+#define PCI_DEVICE_ID_LAVA_QUATRO_A 0x0101
+#define PCI_DEVICE_ID_LAVA_QUATRO_B 0x0102
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_DEVICE_ID_LAVA_OCTO_A 0x0180  
-#define PCI_DEVICE_ID_LAVA_OCTO_B 0x0181  
-#define PCI_DEVICE_ID_LAVA_PORT_PLUS 0x0200  
-#define PCI_DEVICE_ID_LAVA_QUAD_A 0x0201  
+#define PCI_DEVICE_ID_LAVA_OCTO_A 0x0180
+#define PCI_DEVICE_ID_LAVA_OCTO_B 0x0181
+#define PCI_DEVICE_ID_LAVA_PORT_PLUS 0x0200
+#define PCI_DEVICE_ID_LAVA_QUAD_A 0x0201
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_DEVICE_ID_LAVA_QUAD_B 0x0202  
-#define PCI_DEVICE_ID_LAVA_SSERIAL 0x0500  
-#define PCI_DEVICE_ID_LAVA_PORT_650 0x0600  
+#define PCI_DEVICE_ID_LAVA_QUAD_B 0x0202
+#define PCI_DEVICE_ID_LAVA_SSERIAL 0x0500
+#define PCI_DEVICE_ID_LAVA_PORT_650 0x0600
 #define PCI_DEVICE_ID_LAVA_PARALLEL 0x8000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_DEVICE_ID_LAVA_DUAL_PAR_A 0x8002  
-#define PCI_DEVICE_ID_LAVA_DUAL_PAR_B 0x8003  
+#define PCI_DEVICE_ID_LAVA_DUAL_PAR_A 0x8002
+#define PCI_DEVICE_ID_LAVA_DUAL_PAR_B 0x8003
 #define PCI_DEVICE_ID_LAVA_BOCA_IOPPAR 0x8800
 #define PCI_VENDOR_ID_TIMEDIA 0x1409
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -2152,7 +2152,7 @@
 #define PCI_DEVICE_ID_RASTEL_2PORT 0x2000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_VENDOR_ID_ZOLTRIX 0x15b0
-#define PCI_DEVICE_ID_ZOLTRIX_2BD0 0x2bd0 
+#define PCI_DEVICE_ID_ZOLTRIX_2BD0 0x2bd0
 #define PCI_VENDOR_ID_MELLANOX 0x15b3
 #define PCI_DEVICE_ID_MELLANOX_TAVOR 0x5a44
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -2257,7 +2257,7 @@
 #define PCI_DEVICE_ID_INTEL_82815_CGC 0x1132
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_DEVICE_ID_INTEL_82092AA_0 0x1221
-#define PCI_DEVICE_ID_INTEL_7505_0 0x2550 
+#define PCI_DEVICE_ID_INTEL_7505_0 0x2550
 #define PCI_DEVICE_ID_INTEL_7205_0 0x255d
 #define PCI_DEVICE_ID_INTEL_82437 0x122d
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/pci_regs.h b/libc/kernel/common/linux/pci_regs.h
index fdb6b50..7a3f7e6 100644
--- a/libc/kernel/common/linux/pci_regs.h
+++ b/libc/kernel/common/linux/pci_regs.h
@@ -18,77 +18,77 @@
  ****************************************************************************/
 #ifndef LINUX_PCI_REGS_H
 #define LINUX_PCI_REGS_H
-#define PCI_VENDOR_ID 0x00  
-#define PCI_DEVICE_ID 0x02  
+#define PCI_VENDOR_ID 0x00
+#define PCI_DEVICE_ID 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_COMMAND 0x04  
-#define PCI_COMMAND_IO 0x1  
-#define PCI_COMMAND_MEMORY 0x2  
-#define PCI_COMMAND_MASTER 0x4  
+#define PCI_COMMAND 0x04
+#define PCI_COMMAND_IO 0x1
+#define PCI_COMMAND_MEMORY 0x2
+#define PCI_COMMAND_MASTER 0x4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_COMMAND_SPECIAL 0x8  
-#define PCI_COMMAND_INVALIDATE 0x10  
-#define PCI_COMMAND_VGA_PALETTE 0x20  
-#define PCI_COMMAND_PARITY 0x40  
+#define PCI_COMMAND_SPECIAL 0x8
+#define PCI_COMMAND_INVALIDATE 0x10
+#define PCI_COMMAND_VGA_PALETTE 0x20
+#define PCI_COMMAND_PARITY 0x40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_COMMAND_WAIT 0x80  
-#define PCI_COMMAND_SERR 0x100  
-#define PCI_COMMAND_FAST_BACK 0x200  
-#define PCI_COMMAND_INTX_DISABLE 0x400  
+#define PCI_COMMAND_WAIT 0x80
+#define PCI_COMMAND_SERR 0x100
+#define PCI_COMMAND_FAST_BACK 0x200
+#define PCI_COMMAND_INTX_DISABLE 0x400
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_STATUS 0x06  
-#define PCI_STATUS_CAP_LIST 0x10  
-#define PCI_STATUS_66MHZ 0x20  
-#define PCI_STATUS_UDF 0x40  
+#define PCI_STATUS 0x06
+#define PCI_STATUS_CAP_LIST 0x10
+#define PCI_STATUS_66MHZ 0x20
+#define PCI_STATUS_UDF 0x40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_STATUS_FAST_BACK 0x80  
-#define PCI_STATUS_PARITY 0x100  
-#define PCI_STATUS_DEVSEL_MASK 0x600  
+#define PCI_STATUS_FAST_BACK 0x80
+#define PCI_STATUS_PARITY 0x100
+#define PCI_STATUS_DEVSEL_MASK 0x600
 #define PCI_STATUS_DEVSEL_FAST 0x000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_STATUS_DEVSEL_MEDIUM 0x200
 #define PCI_STATUS_DEVSEL_SLOW 0x400
-#define PCI_STATUS_SIG_TARGET_ABORT 0x800  
-#define PCI_STATUS_REC_TARGET_ABORT 0x1000  
+#define PCI_STATUS_SIG_TARGET_ABORT 0x800
+#define PCI_STATUS_REC_TARGET_ABORT 0x1000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_STATUS_REC_MASTER_ABORT 0x2000  
-#define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000  
-#define PCI_STATUS_DETECTED_PARITY 0x8000  
-#define PCI_CLASS_REVISION 0x08  
+#define PCI_STATUS_REC_MASTER_ABORT 0x2000
+#define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000
+#define PCI_STATUS_DETECTED_PARITY 0x8000
+#define PCI_CLASS_REVISION 0x08
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_REVISION_ID 0x08  
-#define PCI_CLASS_PROG 0x09  
-#define PCI_CLASS_DEVICE 0x0a  
-#define PCI_CACHE_LINE_SIZE 0x0c  
+#define PCI_REVISION_ID 0x08
+#define PCI_CLASS_PROG 0x09
+#define PCI_CLASS_DEVICE 0x0a
+#define PCI_CACHE_LINE_SIZE 0x0c
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_LATENCY_TIMER 0x0d  
-#define PCI_HEADER_TYPE 0x0e  
+#define PCI_LATENCY_TIMER 0x0d
+#define PCI_HEADER_TYPE 0x0e
 #define PCI_HEADER_TYPE_NORMAL 0
 #define PCI_HEADER_TYPE_BRIDGE 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_HEADER_TYPE_CARDBUS 2
-#define PCI_BIST 0x0f  
-#define PCI_BIST_CODE_MASK 0x0f  
-#define PCI_BIST_START 0x40  
+#define PCI_BIST 0x0f
+#define PCI_BIST_CODE_MASK 0x0f
+#define PCI_BIST_START 0x40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_BIST_CAPABLE 0x80  
-#define PCI_BASE_ADDRESS_0 0x10  
-#define PCI_BASE_ADDRESS_1 0x14  
-#define PCI_BASE_ADDRESS_2 0x18  
+#define PCI_BIST_CAPABLE 0x80
+#define PCI_BASE_ADDRESS_0 0x10
+#define PCI_BASE_ADDRESS_1 0x14
+#define PCI_BASE_ADDRESS_2 0x18
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_BASE_ADDRESS_3 0x1c  
-#define PCI_BASE_ADDRESS_4 0x20  
-#define PCI_BASE_ADDRESS_5 0x24  
-#define PCI_BASE_ADDRESS_SPACE 0x01  
+#define PCI_BASE_ADDRESS_3 0x1c
+#define PCI_BASE_ADDRESS_4 0x20
+#define PCI_BASE_ADDRESS_5 0x24
+#define PCI_BASE_ADDRESS_SPACE 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_BASE_ADDRESS_SPACE_IO 0x01
 #define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00
 #define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06
-#define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00  
+#define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02  
-#define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04  
-#define PCI_BASE_ADDRESS_MEM_PREFETCH 0x08  
+#define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02
+#define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04
+#define PCI_BASE_ADDRESS_MEM_PREFETCH 0x08
 #define PCI_BASE_ADDRESS_MEM_MASK (~0x0fUL)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_BASE_ADDRESS_IO_MASK (~0x03UL)
@@ -96,35 +96,35 @@
 #define PCI_SUBSYSTEM_VENDOR_ID 0x2c
 #define PCI_SUBSYSTEM_ID 0x2e
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_ROM_ADDRESS 0x30  
+#define PCI_ROM_ADDRESS 0x30
 #define PCI_ROM_ADDRESS_ENABLE 0x01
 #define PCI_ROM_ADDRESS_MASK (~0x7ffUL)
-#define PCI_CAPABILITY_LIST 0x34  
+#define PCI_CAPABILITY_LIST 0x34
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_INTERRUPT_LINE 0x3c  
-#define PCI_INTERRUPT_PIN 0x3d  
-#define PCI_MIN_GNT 0x3e  
-#define PCI_MAX_LAT 0x3f  
+#define PCI_INTERRUPT_LINE 0x3c
+#define PCI_INTERRUPT_PIN 0x3d
+#define PCI_MIN_GNT 0x3e
+#define PCI_MAX_LAT 0x3f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_PRIMARY_BUS 0x18  
-#define PCI_SECONDARY_BUS 0x19  
-#define PCI_SUBORDINATE_BUS 0x1a  
-#define PCI_SEC_LATENCY_TIMER 0x1b  
+#define PCI_PRIMARY_BUS 0x18
+#define PCI_SECONDARY_BUS 0x19
+#define PCI_SUBORDINATE_BUS 0x1a
+#define PCI_SEC_LATENCY_TIMER 0x1b
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_IO_BASE 0x1c  
+#define PCI_IO_BASE 0x1c
 #define PCI_IO_LIMIT 0x1d
-#define PCI_IO_RANGE_TYPE_MASK 0x0fUL  
+#define PCI_IO_RANGE_TYPE_MASK 0x0fUL
 #define PCI_IO_RANGE_TYPE_16 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_IO_RANGE_TYPE_32 0x01
 #define PCI_IO_RANGE_MASK (~0x0fUL)
-#define PCI_SEC_STATUS 0x1e  
-#define PCI_MEMORY_BASE 0x20  
+#define PCI_SEC_STATUS 0x1e
+#define PCI_MEMORY_BASE 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_MEMORY_LIMIT 0x22
 #define PCI_MEMORY_RANGE_TYPE_MASK 0x0fUL
 #define PCI_MEMORY_RANGE_MASK (~0x0fUL)
-#define PCI_PREF_MEMORY_BASE 0x24  
+#define PCI_PREF_MEMORY_BASE 0x24
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_PREF_MEMORY_LIMIT 0x26
 #define PCI_PREF_RANGE_TYPE_MASK 0x0fUL
@@ -132,29 +132,29 @@
 #define PCI_PREF_RANGE_TYPE_64 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_PREF_RANGE_MASK (~0x0fUL)
-#define PCI_PREF_BASE_UPPER32 0x28  
+#define PCI_PREF_BASE_UPPER32 0x28
 #define PCI_PREF_LIMIT_UPPER32 0x2c
-#define PCI_IO_BASE_UPPER16 0x30  
+#define PCI_IO_BASE_UPPER16 0x30
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_IO_LIMIT_UPPER16 0x32
-#define PCI_ROM_ADDRESS1 0x38  
+#define PCI_ROM_ADDRESS1 0x38
 #define PCI_BRIDGE_CONTROL 0x3e
-#define PCI_BRIDGE_CTL_PARITY 0x01  
+#define PCI_BRIDGE_CTL_PARITY 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_BRIDGE_CTL_SERR 0x02  
-#define PCI_BRIDGE_CTL_NO_ISA 0x04  
-#define PCI_BRIDGE_CTL_VGA 0x08  
-#define PCI_BRIDGE_CTL_MASTER_ABORT 0x20  
+#define PCI_BRIDGE_CTL_SERR 0x02
+#define PCI_BRIDGE_CTL_NO_ISA 0x04
+#define PCI_BRIDGE_CTL_VGA 0x08
+#define PCI_BRIDGE_CTL_MASTER_ABORT 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_BRIDGE_CTL_BUS_RESET 0x40  
-#define PCI_BRIDGE_CTL_FAST_BACK 0x80  
+#define PCI_BRIDGE_CTL_BUS_RESET 0x40
+#define PCI_BRIDGE_CTL_FAST_BACK 0x80
 #define PCI_CB_CAPABILITY_LIST 0x14
-#define PCI_CB_SEC_STATUS 0x16  
+#define PCI_CB_SEC_STATUS 0x16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_CB_PRIMARY_BUS 0x18  
-#define PCI_CB_CARD_BUS 0x19  
-#define PCI_CB_SUBORDINATE_BUS 0x1a  
-#define PCI_CB_LATENCY_TIMER 0x1b  
+#define PCI_CB_PRIMARY_BUS 0x18
+#define PCI_CB_CARD_BUS 0x19
+#define PCI_CB_SUBORDINATE_BUS 0x1a
+#define PCI_CB_LATENCY_TIMER 0x1b
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_CB_MEMORY_BASE_0 0x1c
 #define PCI_CB_MEMORY_LIMIT_0 0x20
@@ -173,230 +173,230 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_CB_IO_RANGE_MASK (~0x03UL)
 #define PCI_CB_BRIDGE_CONTROL 0x3e
-#define PCI_CB_BRIDGE_CTL_PARITY 0x01  
+#define PCI_CB_BRIDGE_CTL_PARITY 0x01
 #define PCI_CB_BRIDGE_CTL_SERR 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_CB_BRIDGE_CTL_ISA 0x04
 #define PCI_CB_BRIDGE_CTL_VGA 0x08
 #define PCI_CB_BRIDGE_CTL_MASTER_ABORT 0x20
-#define PCI_CB_BRIDGE_CTL_CB_RESET 0x40  
+#define PCI_CB_BRIDGE_CTL_CB_RESET 0x40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_CB_BRIDGE_CTL_16BIT_INT 0x80  
-#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM0 0x100  
+#define PCI_CB_BRIDGE_CTL_16BIT_INT 0x80
+#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM0 0x100
 #define PCI_CB_BRIDGE_CTL_PREFETCH_MEM1 0x200
 #define PCI_CB_BRIDGE_CTL_POST_WRITES 0x400
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_CB_SUBSYSTEM_VENDOR_ID 0x40
 #define PCI_CB_SUBSYSTEM_ID 0x42
-#define PCI_CB_LEGACY_MODE_BASE 0x44  
-#define PCI_CAP_LIST_ID 0  
+#define PCI_CB_LEGACY_MODE_BASE 0x44
+#define PCI_CAP_LIST_ID 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_CAP_ID_PM 0x01  
-#define PCI_CAP_ID_AGP 0x02  
-#define PCI_CAP_ID_VPD 0x03  
-#define PCI_CAP_ID_SLOTID 0x04  
+#define PCI_CAP_ID_PM 0x01
+#define PCI_CAP_ID_AGP 0x02
+#define PCI_CAP_ID_VPD 0x03
+#define PCI_CAP_ID_SLOTID 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_CAP_ID_MSI 0x05  
-#define PCI_CAP_ID_CHSWP 0x06  
-#define PCI_CAP_ID_PCIX 0x07  
-#define PCI_CAP_ID_HT_IRQCONF 0x08  
+#define PCI_CAP_ID_MSI 0x05
+#define PCI_CAP_ID_CHSWP 0x06
+#define PCI_CAP_ID_PCIX 0x07
+#define PCI_CAP_ID_HT_IRQCONF 0x08
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_CAP_ID_VNDR 0x09  
-#define PCI_CAP_ID_SHPC 0x0C  
-#define PCI_CAP_ID_EXP 0x10  
-#define PCI_CAP_ID_MSIX 0x11  
+#define PCI_CAP_ID_VNDR 0x09
+#define PCI_CAP_ID_SHPC 0x0C
+#define PCI_CAP_ID_EXP 0x10
+#define PCI_CAP_ID_MSIX 0x11
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_CAP_LIST_NEXT 1  
-#define PCI_CAP_FLAGS 2  
+#define PCI_CAP_LIST_NEXT 1
+#define PCI_CAP_FLAGS 2
 #define PCI_CAP_SIZEOF 4
-#define PCI_PM_PMC 2  
+#define PCI_PM_PMC 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_PM_CAP_VER_MASK 0x0007  
-#define PCI_PM_CAP_PME_CLOCK 0x0008  
-#define PCI_PM_CAP_RESERVED 0x0010  
-#define PCI_PM_CAP_DSI 0x0020  
+#define PCI_PM_CAP_VER_MASK 0x0007
+#define PCI_PM_CAP_PME_CLOCK 0x0008
+#define PCI_PM_CAP_RESERVED 0x0010
+#define PCI_PM_CAP_DSI 0x0020
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_PM_CAP_AUX_POWER 0x01C0  
-#define PCI_PM_CAP_D1 0x0200  
-#define PCI_PM_CAP_D2 0x0400  
-#define PCI_PM_CAP_PME 0x0800  
+#define PCI_PM_CAP_AUX_POWER 0x01C0
+#define PCI_PM_CAP_D1 0x0200
+#define PCI_PM_CAP_D2 0x0400
+#define PCI_PM_CAP_PME 0x0800
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_PM_CAP_PME_MASK 0xF800  
-#define PCI_PM_CAP_PME_D0 0x0800  
-#define PCI_PM_CAP_PME_D1 0x1000  
-#define PCI_PM_CAP_PME_D2 0x2000  
+#define PCI_PM_CAP_PME_MASK 0xF800
+#define PCI_PM_CAP_PME_D0 0x0800
+#define PCI_PM_CAP_PME_D1 0x1000
+#define PCI_PM_CAP_PME_D2 0x2000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_PM_CAP_PME_D3 0x4000  
-#define PCI_PM_CAP_PME_D3cold 0x8000  
-#define PCI_PM_CTRL 4  
-#define PCI_PM_CTRL_STATE_MASK 0x0003  
+#define PCI_PM_CAP_PME_D3 0x4000
+#define PCI_PM_CAP_PME_D3cold 0x8000
+#define PCI_PM_CTRL 4
+#define PCI_PM_CTRL_STATE_MASK 0x0003
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_PM_CTRL_NO_SOFT_RESET 0x0004  
-#define PCI_PM_CTRL_PME_ENABLE 0x0100  
-#define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00  
-#define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000  
+#define PCI_PM_CTRL_NO_SOFT_RESET 0x0004
+#define PCI_PM_CTRL_PME_ENABLE 0x0100
+#define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00
+#define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_PM_CTRL_PME_STATUS 0x8000  
-#define PCI_PM_PPB_EXTENSIONS 6  
-#define PCI_PM_PPB_B2_B3 0x40  
-#define PCI_PM_BPCC_ENABLE 0x80  
+#define PCI_PM_CTRL_PME_STATUS 0x8000
+#define PCI_PM_PPB_EXTENSIONS 6
+#define PCI_PM_PPB_B2_B3 0x40
+#define PCI_PM_BPCC_ENABLE 0x80
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_PM_DATA_REGISTER 7  
+#define PCI_PM_DATA_REGISTER 7
 #define PCI_PM_SIZEOF 8
-#define PCI_AGP_VERSION 2  
-#define PCI_AGP_RFU 3  
+#define PCI_AGP_VERSION 2
+#define PCI_AGP_RFU 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_AGP_STATUS 4  
-#define PCI_AGP_STATUS_RQ_MASK 0xff000000  
-#define PCI_AGP_STATUS_SBA 0x0200  
-#define PCI_AGP_STATUS_64BIT 0x0020  
+#define PCI_AGP_STATUS 4
+#define PCI_AGP_STATUS_RQ_MASK 0xff000000
+#define PCI_AGP_STATUS_SBA 0x0200
+#define PCI_AGP_STATUS_64BIT 0x0020
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_AGP_STATUS_FW 0x0010  
-#define PCI_AGP_STATUS_RATE4 0x0004  
-#define PCI_AGP_STATUS_RATE2 0x0002  
-#define PCI_AGP_STATUS_RATE1 0x0001  
+#define PCI_AGP_STATUS_FW 0x0010
+#define PCI_AGP_STATUS_RATE4 0x0004
+#define PCI_AGP_STATUS_RATE2 0x0002
+#define PCI_AGP_STATUS_RATE1 0x0001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_AGP_COMMAND 8  
-#define PCI_AGP_COMMAND_RQ_MASK 0xff000000  
-#define PCI_AGP_COMMAND_SBA 0x0200  
-#define PCI_AGP_COMMAND_AGP 0x0100  
+#define PCI_AGP_COMMAND 8
+#define PCI_AGP_COMMAND_RQ_MASK 0xff000000
+#define PCI_AGP_COMMAND_SBA 0x0200
+#define PCI_AGP_COMMAND_AGP 0x0100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_AGP_COMMAND_64BIT 0x0020  
-#define PCI_AGP_COMMAND_FW 0x0010  
-#define PCI_AGP_COMMAND_RATE4 0x0004  
-#define PCI_AGP_COMMAND_RATE2 0x0002  
+#define PCI_AGP_COMMAND_64BIT 0x0020
+#define PCI_AGP_COMMAND_FW 0x0010
+#define PCI_AGP_COMMAND_RATE4 0x0004
+#define PCI_AGP_COMMAND_RATE2 0x0002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_AGP_COMMAND_RATE1 0x0001  
+#define PCI_AGP_COMMAND_RATE1 0x0001
 #define PCI_AGP_SIZEOF 12
-#define PCI_VPD_ADDR 2  
-#define PCI_VPD_ADDR_MASK 0x7fff  
+#define PCI_VPD_ADDR 2
+#define PCI_VPD_ADDR_MASK 0x7fff
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_VPD_ADDR_F 0x8000  
-#define PCI_VPD_DATA 4  
-#define PCI_SID_ESR 2  
-#define PCI_SID_ESR_NSLOTS 0x1f  
+#define PCI_VPD_ADDR_F 0x8000
+#define PCI_VPD_DATA 4
+#define PCI_SID_ESR 2
+#define PCI_SID_ESR_NSLOTS 0x1f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_SID_ESR_FIC 0x20  
-#define PCI_SID_CHASSIS_NR 3  
-#define PCI_MSI_FLAGS 2  
-#define PCI_MSI_FLAGS_64BIT 0x80  
+#define PCI_SID_ESR_FIC 0x20
+#define PCI_SID_CHASSIS_NR 3
+#define PCI_MSI_FLAGS 2
+#define PCI_MSI_FLAGS_64BIT 0x80
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_MSI_FLAGS_QSIZE 0x70  
-#define PCI_MSI_FLAGS_QMASK 0x0e  
-#define PCI_MSI_FLAGS_ENABLE 0x01  
-#define PCI_MSI_FLAGS_MASKBIT 0x100  
+#define PCI_MSI_FLAGS_QSIZE 0x70
+#define PCI_MSI_FLAGS_QMASK 0x0e
+#define PCI_MSI_FLAGS_ENABLE 0x01
+#define PCI_MSI_FLAGS_MASKBIT 0x100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_MSI_RFU 3  
-#define PCI_MSI_ADDRESS_LO 4  
-#define PCI_MSI_ADDRESS_HI 8  
-#define PCI_MSI_DATA_32 8  
+#define PCI_MSI_RFU 3
+#define PCI_MSI_ADDRESS_LO 4
+#define PCI_MSI_ADDRESS_HI 8
+#define PCI_MSI_DATA_32 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_MSI_DATA_64 12  
-#define PCI_MSI_MASK_BIT 16  
-#define PCI_CHSWP_CSR 2  
-#define PCI_CHSWP_DHA 0x01  
+#define PCI_MSI_DATA_64 12
+#define PCI_MSI_MASK_BIT 16
+#define PCI_CHSWP_CSR 2
+#define PCI_CHSWP_DHA 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_CHSWP_EIM 0x02  
-#define PCI_CHSWP_PIE 0x04  
-#define PCI_CHSWP_LOO 0x08  
-#define PCI_CHSWP_PI 0x30  
+#define PCI_CHSWP_EIM 0x02
+#define PCI_CHSWP_PIE 0x04
+#define PCI_CHSWP_LOO 0x08
+#define PCI_CHSWP_PI 0x30
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_CHSWP_EXT 0x40  
-#define PCI_CHSWP_INS 0x80  
-#define PCI_X_CMD 2  
-#define PCI_X_CMD_DPERR_E 0x0001  
+#define PCI_CHSWP_EXT 0x40
+#define PCI_CHSWP_INS 0x80
+#define PCI_X_CMD 2
+#define PCI_X_CMD_DPERR_E 0x0001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_X_CMD_ERO 0x0002  
-#define PCI_X_CMD_MAX_READ 0x000c  
-#define PCI_X_CMD_MAX_SPLIT 0x0070  
-#define PCI_X_CMD_VERSION(x) (((x) >> 12) & 3)  
+#define PCI_X_CMD_ERO 0x0002
+#define PCI_X_CMD_MAX_READ 0x000c
+#define PCI_X_CMD_MAX_SPLIT 0x0070
+#define PCI_X_CMD_VERSION(x) (((x) >> 12) & 3)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_X_STATUS 4  
-#define PCI_X_STATUS_DEVFN 0x000000ff  
-#define PCI_X_STATUS_BUS 0x0000ff00  
-#define PCI_X_STATUS_64BIT 0x00010000  
+#define PCI_X_STATUS 4
+#define PCI_X_STATUS_DEVFN 0x000000ff
+#define PCI_X_STATUS_BUS 0x0000ff00
+#define PCI_X_STATUS_64BIT 0x00010000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_X_STATUS_133MHZ 0x00020000  
-#define PCI_X_STATUS_SPL_DISC 0x00040000  
-#define PCI_X_STATUS_UNX_SPL 0x00080000  
-#define PCI_X_STATUS_COMPLEX 0x00100000  
+#define PCI_X_STATUS_133MHZ 0x00020000
+#define PCI_X_STATUS_SPL_DISC 0x00040000
+#define PCI_X_STATUS_UNX_SPL 0x00080000
+#define PCI_X_STATUS_COMPLEX 0x00100000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_X_STATUS_MAX_READ 0x00600000  
-#define PCI_X_STATUS_MAX_SPLIT 0x03800000  
-#define PCI_X_STATUS_MAX_CUM 0x1c000000  
-#define PCI_X_STATUS_SPL_ERR 0x20000000  
+#define PCI_X_STATUS_MAX_READ 0x00600000
+#define PCI_X_STATUS_MAX_SPLIT 0x03800000
+#define PCI_X_STATUS_MAX_CUM 0x1c000000
+#define PCI_X_STATUS_SPL_ERR 0x20000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_X_STATUS_266MHZ 0x40000000  
-#define PCI_X_STATUS_533MHZ 0x80000000  
-#define PCI_EXP_FLAGS 2  
-#define PCI_EXP_FLAGS_VERS 0x000f  
+#define PCI_X_STATUS_266MHZ 0x40000000
+#define PCI_X_STATUS_533MHZ 0x80000000
+#define PCI_EXP_FLAGS 2
+#define PCI_EXP_FLAGS_VERS 0x000f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_EXP_FLAGS_TYPE 0x00f0  
-#define PCI_EXP_TYPE_ENDPOINT 0x0  
-#define PCI_EXP_TYPE_LEG_END 0x1  
-#define PCI_EXP_TYPE_ROOT_PORT 0x4  
+#define PCI_EXP_FLAGS_TYPE 0x00f0
+#define PCI_EXP_TYPE_ENDPOINT 0x0
+#define PCI_EXP_TYPE_LEG_END 0x1
+#define PCI_EXP_TYPE_ROOT_PORT 0x4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_EXP_TYPE_UPSTREAM 0x5  
-#define PCI_EXP_TYPE_DOWNSTREAM 0x6  
-#define PCI_EXP_TYPE_PCI_BRIDGE 0x7  
-#define PCI_EXP_FLAGS_SLOT 0x0100  
+#define PCI_EXP_TYPE_UPSTREAM 0x5
+#define PCI_EXP_TYPE_DOWNSTREAM 0x6
+#define PCI_EXP_TYPE_PCI_BRIDGE 0x7
+#define PCI_EXP_FLAGS_SLOT 0x0100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_EXP_FLAGS_IRQ 0x3e00  
-#define PCI_EXP_DEVCAP 4  
-#define PCI_EXP_DEVCAP_PAYLOAD 0x07  
-#define PCI_EXP_DEVCAP_PHANTOM 0x18  
+#define PCI_EXP_FLAGS_IRQ 0x3e00
+#define PCI_EXP_DEVCAP 4
+#define PCI_EXP_DEVCAP_PAYLOAD 0x07
+#define PCI_EXP_DEVCAP_PHANTOM 0x18
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_EXP_DEVCAP_EXT_TAG 0x20  
-#define PCI_EXP_DEVCAP_L0S 0x1c0  
-#define PCI_EXP_DEVCAP_L1 0xe00  
-#define PCI_EXP_DEVCAP_ATN_BUT 0x1000  
+#define PCI_EXP_DEVCAP_EXT_TAG 0x20
+#define PCI_EXP_DEVCAP_L0S 0x1c0
+#define PCI_EXP_DEVCAP_L1 0xe00
+#define PCI_EXP_DEVCAP_ATN_BUT 0x1000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_EXP_DEVCAP_ATN_IND 0x2000  
-#define PCI_EXP_DEVCAP_PWR_IND 0x4000  
-#define PCI_EXP_DEVCAP_PWR_VAL 0x3fc0000  
-#define PCI_EXP_DEVCAP_PWR_SCL 0xc000000  
+#define PCI_EXP_DEVCAP_ATN_IND 0x2000
+#define PCI_EXP_DEVCAP_PWR_IND 0x4000
+#define PCI_EXP_DEVCAP_PWR_VAL 0x3fc0000
+#define PCI_EXP_DEVCAP_PWR_SCL 0xc000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_EXP_DEVCTL 8  
-#define PCI_EXP_DEVCTL_CERE 0x0001  
-#define PCI_EXP_DEVCTL_NFERE 0x0002  
-#define PCI_EXP_DEVCTL_FERE 0x0004  
+#define PCI_EXP_DEVCTL 8
+#define PCI_EXP_DEVCTL_CERE 0x0001
+#define PCI_EXP_DEVCTL_NFERE 0x0002
+#define PCI_EXP_DEVCTL_FERE 0x0004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_EXP_DEVCTL_URRE 0x0008  
-#define PCI_EXP_DEVCTL_RELAX_EN 0x0010  
-#define PCI_EXP_DEVCTL_PAYLOAD 0x00e0  
-#define PCI_EXP_DEVCTL_EXT_TAG 0x0100  
+#define PCI_EXP_DEVCTL_URRE 0x0008
+#define PCI_EXP_DEVCTL_RELAX_EN 0x0010
+#define PCI_EXP_DEVCTL_PAYLOAD 0x00e0
+#define PCI_EXP_DEVCTL_EXT_TAG 0x0100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_EXP_DEVCTL_PHANTOM 0x0200  
-#define PCI_EXP_DEVCTL_AUX_PME 0x0400  
-#define PCI_EXP_DEVCTL_NOSNOOP_EN 0x0800  
-#define PCI_EXP_DEVCTL_READRQ 0x7000  
+#define PCI_EXP_DEVCTL_PHANTOM 0x0200
+#define PCI_EXP_DEVCTL_AUX_PME 0x0400
+#define PCI_EXP_DEVCTL_NOSNOOP_EN 0x0800
+#define PCI_EXP_DEVCTL_READRQ 0x7000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_EXP_DEVSTA 10  
-#define PCI_EXP_DEVSTA_CED 0x01  
-#define PCI_EXP_DEVSTA_NFED 0x02  
-#define PCI_EXP_DEVSTA_FED 0x04  
+#define PCI_EXP_DEVSTA 10
+#define PCI_EXP_DEVSTA_CED 0x01
+#define PCI_EXP_DEVSTA_NFED 0x02
+#define PCI_EXP_DEVSTA_FED 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_EXP_DEVSTA_URD 0x08  
-#define PCI_EXP_DEVSTA_AUXPD 0x10  
-#define PCI_EXP_DEVSTA_TRPND 0x20  
-#define PCI_EXP_LNKCAP 12  
+#define PCI_EXP_DEVSTA_URD 0x08
+#define PCI_EXP_DEVSTA_AUXPD 0x10
+#define PCI_EXP_DEVSTA_TRPND 0x20
+#define PCI_EXP_LNKCAP 12
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_EXP_LNKCTL 16  
-#define PCI_EXP_LNKSTA 18  
-#define PCI_EXP_SLTCAP 20  
-#define PCI_EXP_SLTCTL 24  
+#define PCI_EXP_LNKCTL 16
+#define PCI_EXP_LNKSTA 18
+#define PCI_EXP_SLTCAP 20
+#define PCI_EXP_SLTCTL 24
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_EXP_SLTSTA 26  
-#define PCI_EXP_RTCTL 28  
-#define PCI_EXP_RTCTL_SECEE 0x01  
-#define PCI_EXP_RTCTL_SENFEE 0x02  
+#define PCI_EXP_SLTSTA 26
+#define PCI_EXP_RTCTL 28
+#define PCI_EXP_RTCTL_SECEE 0x01
+#define PCI_EXP_RTCTL_SENFEE 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_EXP_RTCTL_SEFEE 0x04  
-#define PCI_EXP_RTCTL_PMEIE 0x08  
-#define PCI_EXP_RTCTL_CRSSVE 0x10  
-#define PCI_EXP_RTCAP 30  
+#define PCI_EXP_RTCTL_SEFEE 0x04
+#define PCI_EXP_RTCTL_PMEIE 0x08
+#define PCI_EXP_RTCTL_CRSSVE 0x10
+#define PCI_EXP_RTCAP 30
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_EXP_RTSTA 32  
+#define PCI_EXP_RTSTA 32
 #define PCI_EXT_CAP_ID(header) (header & 0x0000ffff)
 #define PCI_EXT_CAP_VER(header) ((header >> 16) & 0xf)
 #define PCI_EXT_CAP_NEXT(header) ((header >> 20) & 0xffc)
@@ -406,55 +406,55 @@
 #define PCI_EXT_CAP_ID_DSN 3
 #define PCI_EXT_CAP_ID_PWR 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_ERR_UNCOR_STATUS 4  
-#define PCI_ERR_UNC_TRAIN 0x00000001  
-#define PCI_ERR_UNC_DLP 0x00000010  
-#define PCI_ERR_UNC_POISON_TLP 0x00001000  
+#define PCI_ERR_UNCOR_STATUS 4
+#define PCI_ERR_UNC_TRAIN 0x00000001
+#define PCI_ERR_UNC_DLP 0x00000010
+#define PCI_ERR_UNC_POISON_TLP 0x00001000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_ERR_UNC_FCP 0x00002000  
-#define PCI_ERR_UNC_COMP_TIME 0x00004000  
-#define PCI_ERR_UNC_COMP_ABORT 0x00008000  
-#define PCI_ERR_UNC_UNX_COMP 0x00010000  
+#define PCI_ERR_UNC_FCP 0x00002000
+#define PCI_ERR_UNC_COMP_TIME 0x00004000
+#define PCI_ERR_UNC_COMP_ABORT 0x00008000
+#define PCI_ERR_UNC_UNX_COMP 0x00010000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_ERR_UNC_RX_OVER 0x00020000  
-#define PCI_ERR_UNC_MALF_TLP 0x00040000  
-#define PCI_ERR_UNC_ECRC 0x00080000  
-#define PCI_ERR_UNC_UNSUP 0x00100000  
+#define PCI_ERR_UNC_RX_OVER 0x00020000
+#define PCI_ERR_UNC_MALF_TLP 0x00040000
+#define PCI_ERR_UNC_ECRC 0x00080000
+#define PCI_ERR_UNC_UNSUP 0x00100000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_ERR_UNCOR_MASK 8  
-#define PCI_ERR_UNCOR_SEVER 12  
-#define PCI_ERR_COR_STATUS 16  
-#define PCI_ERR_COR_RCVR 0x00000001  
+#define PCI_ERR_UNCOR_MASK 8
+#define PCI_ERR_UNCOR_SEVER 12
+#define PCI_ERR_COR_STATUS 16
+#define PCI_ERR_COR_RCVR 0x00000001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_ERR_COR_BAD_TLP 0x00000040  
-#define PCI_ERR_COR_BAD_DLLP 0x00000080  
-#define PCI_ERR_COR_REP_ROLL 0x00000100  
-#define PCI_ERR_COR_REP_TIMER 0x00001000  
+#define PCI_ERR_COR_BAD_TLP 0x00000040
+#define PCI_ERR_COR_BAD_DLLP 0x00000080
+#define PCI_ERR_COR_REP_ROLL 0x00000100
+#define PCI_ERR_COR_REP_TIMER 0x00001000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_ERR_COR_MASK 20  
-#define PCI_ERR_CAP 24  
-#define PCI_ERR_CAP_FEP(x) ((x) & 31)  
-#define PCI_ERR_CAP_ECRC_GENC 0x00000020  
+#define PCI_ERR_COR_MASK 20
+#define PCI_ERR_CAP 24
+#define PCI_ERR_CAP_FEP(x) ((x) & 31)
+#define PCI_ERR_CAP_ECRC_GENC 0x00000020
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_ERR_CAP_ECRC_GENE 0x00000040  
-#define PCI_ERR_CAP_ECRC_CHKC 0x00000080  
-#define PCI_ERR_CAP_ECRC_CHKE 0x00000100  
-#define PCI_ERR_HEADER_LOG 28  
+#define PCI_ERR_CAP_ECRC_GENE 0x00000040
+#define PCI_ERR_CAP_ECRC_CHKC 0x00000080
+#define PCI_ERR_CAP_ECRC_CHKE 0x00000100
+#define PCI_ERR_HEADER_LOG 28
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_ERR_ROOT_COMMAND 44  
+#define PCI_ERR_ROOT_COMMAND 44
 #define PCI_ERR_ROOT_CMD_COR_EN 0x00000001
 #define PCI_ERR_ROOT_CMD_NONFATAL_EN 0x00000002
 #define PCI_ERR_ROOT_CMD_FATAL_EN 0x00000004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_ERR_ROOT_STATUS 48
-#define PCI_ERR_ROOT_COR_RCV 0x00000001  
+#define PCI_ERR_ROOT_COR_RCV 0x00000001
 #define PCI_ERR_ROOT_MULTI_COR_RCV 0x00000002
 #define PCI_ERR_ROOT_UNCOR_RCV 0x00000004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_ERR_ROOT_MULTI_UNCOR_RCV 0x00000008
-#define PCI_ERR_ROOT_FIRST_FATAL 0x00000010  
-#define PCI_ERR_ROOT_NONFATAL_RCV 0x00000020  
-#define PCI_ERR_ROOT_FATAL_RCV 0x00000040  
+#define PCI_ERR_ROOT_FIRST_FATAL 0x00000010
+#define PCI_ERR_ROOT_NONFATAL_RCV 0x00000020
+#define PCI_ERR_ROOT_FATAL_RCV 0x00000040
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_ERR_ROOT_COR_SRC 52
 #define PCI_ERR_ROOT_SRC 54
@@ -467,17 +467,17 @@
 #define PCI_VC_RES_CTRL 20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PCI_VC_RES_STATUS 26
-#define PCI_PWR_DSR 4  
-#define PCI_PWR_DATA 8  
-#define PCI_PWR_DATA_BASE(x) ((x) & 0xff)  
+#define PCI_PWR_DSR 4
+#define PCI_PWR_DATA 8
+#define PCI_PWR_DATA_BASE(x) ((x) & 0xff)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_PWR_DATA_SCALE(x) (((x) >> 8) & 3)  
-#define PCI_PWR_DATA_PM_SUB(x) (((x) >> 10) & 7)  
-#define PCI_PWR_DATA_PM_STATE(x) (((x) >> 13) & 3)  
-#define PCI_PWR_DATA_TYPE(x) (((x) >> 15) & 7)  
+#define PCI_PWR_DATA_SCALE(x) (((x) >> 8) & 3)
+#define PCI_PWR_DATA_PM_SUB(x) (((x) >> 10) & 7)
+#define PCI_PWR_DATA_PM_STATE(x) (((x) >> 13) & 3)
+#define PCI_PWR_DATA_TYPE(x) (((x) >> 15) & 7)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_PWR_DATA_RAIL(x) (((x) >> 18) & 7)  
-#define PCI_PWR_CAP 12  
-#define PCI_PWR_CAP_BUDGET(x) ((x) & 1)  
+#define PCI_PWR_DATA_RAIL(x) (((x) >> 18) & 7)
+#define PCI_PWR_CAP 12
+#define PCI_PWR_CAP_BUDGET(x) ((x) & 1)
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/percpu.h b/libc/kernel/common/linux/percpu.h
index 9597e29..92c0b6e 100644
--- a/libc/kernel/common/linux/percpu.h
+++ b/libc/kernel/common/linux/percpu.h
@@ -18,11 +18,11 @@
  ****************************************************************************/
 #ifndef __LINUX_PERCPU_H
 #define __LINUX_PERCPU_H
-#include <linux/spinlock.h>  
-#include <linux/slab.h>  
+#include <linux/spinlock.h>
+#include <linux/slab.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <linux/smp.h>
-#include <linux/string.h>  
+#include <linux/string.h>
 #include <asm/percpu.h>
 #ifndef PERCPU_ENOUGH_ROOM
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/perf_event.h b/libc/kernel/common/linux/perf_event.h
index f039a6d..ad5515f 100644
--- a/libc/kernel/common/linux/perf_event.h
+++ b/libc/kernel/common/linux/perf_event.h
@@ -112,7 +112,7 @@
  PERF_FORMAT_MAX = 1U << 4,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define PERF_ATTR_SIZE_VER0 64  
+#define PERF_ATTR_SIZE_VER0 64
 struct perf_event_attr {
  __u32 type;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/pfkeyv2.h b/libc/kernel/common/linux/pfkeyv2.h
index 68e43ce..174f546 100644
--- a/libc/kernel/common/linux/pfkeyv2.h
+++ b/libc/kernel/common/linux/pfkeyv2.h
@@ -279,7 +279,7 @@
 #define SADB_X_AALG_SHA2_384HMAC 6
 #define SADB_X_AALG_SHA2_512HMAC 7
 #define SADB_X_AALG_RIPEMD160HMAC 8
-#define SADB_X_AALG_NULL 251  
+#define SADB_X_AALG_NULL 251
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SADB_AALG_MAX 251
 #define SADB_EALG_NONE 0
@@ -291,9 +291,9 @@
 #define SADB_EALG_NULL 11
 #define SADB_X_EALG_AESCBC 12
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SADB_EALG_MAX 253  
-#define SADB_X_EALG_SERPENTCBC 252  
-#define SADB_X_EALG_TWOFISHCBC 253  
+#define SADB_EALG_MAX 253
+#define SADB_X_EALG_SERPENTCBC 252
+#define SADB_X_EALG_TWOFISHCBC 253
 #define SADB_X_CALG_NONE 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SADB_X_CALG_OUI 1
diff --git a/libc/kernel/common/linux/pkt_sched.h b/libc/kernel/common/linux/pkt_sched.h
index edf5fe5..33c4db6 100644
--- a/libc/kernel/common/linux/pkt_sched.h
+++ b/libc/kernel/common/linux/pkt_sched.h
@@ -229,7 +229,7 @@
 };
 #define TC_HTB_NUMPRIO 8
 #define TC_HTB_MAXDEPTH 8
-#define TC_HTB_PROTOVER 3  
+#define TC_HTB_PROTOVER 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct tc_htb_opt
 {
diff --git a/libc/kernel/common/linux/ppp_defs.h b/libc/kernel/common/linux/ppp_defs.h
index ed115fd..b99dce5 100644
--- a/libc/kernel/common/linux/ppp_defs.h
+++ b/libc/kernel/common/linux/ppp_defs.h
@@ -18,51 +18,51 @@
  ****************************************************************************/
 #ifndef _PPP_DEFS_H_
 #define _PPP_DEFS_H_
-#define PPP_HDRLEN 4  
-#define PPP_FCSLEN 2  
+#define PPP_HDRLEN 4
+#define PPP_FCSLEN 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PPP_MRU 1500  
+#define PPP_MRU 1500
 #define PPP_ADDRESS(p) (((__u8 *)(p))[0])
 #define PPP_CONTROL(p) (((__u8 *)(p))[1])
 #define PPP_PROTOCOL(p) ((((__u8 *)(p))[2] << 8) + ((__u8 *)(p))[3])
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PPP_ALLSTATIONS 0xff  
-#define PPP_UI 0x03  
-#define PPP_FLAG 0x7e  
-#define PPP_ESCAPE 0x7d  
+#define PPP_ALLSTATIONS 0xff
+#define PPP_UI 0x03
+#define PPP_FLAG 0x7e
+#define PPP_ESCAPE 0x7d
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PPP_TRANS 0x20  
-#define PPP_IP 0x21  
-#define PPP_AT 0x29  
-#define PPP_IPX 0x2b  
+#define PPP_TRANS 0x20
+#define PPP_IP 0x21
+#define PPP_AT 0x29
+#define PPP_IPX 0x2b
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PPP_VJC_COMP 0x2d  
-#define PPP_VJC_UNCOMP 0x2f  
-#define PPP_MP 0x3d  
-#define PPP_IPV6 0x57  
+#define PPP_VJC_COMP 0x2d
+#define PPP_VJC_UNCOMP 0x2f
+#define PPP_MP 0x3d
+#define PPP_IPV6 0x57
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PPP_COMPFRAG 0xfb  
-#define PPP_COMP 0xfd  
-#define PPP_MPLS_UC 0x0281  
-#define PPP_MPLS_MC 0x0283  
+#define PPP_COMPFRAG 0xfb
+#define PPP_COMP 0xfd
+#define PPP_MPLS_UC 0x0281
+#define PPP_MPLS_MC 0x0283
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PPP_IPCP 0x8021  
-#define PPP_ATCP 0x8029  
-#define PPP_IPXCP 0x802b  
-#define PPP_IPV6CP 0x8057  
+#define PPP_IPCP 0x8021
+#define PPP_ATCP 0x8029
+#define PPP_IPXCP 0x802b
+#define PPP_IPV6CP 0x8057
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PPP_CCPFRAG 0x80fb  
-#define PPP_CCP 0x80fd  
-#define PPP_MPLSCP 0x80fd  
-#define PPP_LCP 0xc021  
+#define PPP_CCPFRAG 0x80fb
+#define PPP_CCP 0x80fd
+#define PPP_MPLSCP 0x80fd
+#define PPP_LCP 0xc021
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PPP_PAP 0xc023  
-#define PPP_LQR 0xc025  
-#define PPP_CHAP 0xc223  
-#define PPP_CBCP 0xc029  
+#define PPP_PAP 0xc023
+#define PPP_LQR 0xc025
+#define PPP_CHAP 0xc223
+#define PPP_CBCP 0xc029
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PPP_INITFCS 0xffff  
-#define PPP_GOODFCS 0xf0b8  
+#define PPP_INITFCS 0xffff
+#define PPP_GOODFCS 0xf0b8
 typedef __u32 ext_accm[8];
 enum NPmode {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/prctl.h b/libc/kernel/common/linux/prctl.h
index 5e79143..a127b5a 100644
--- a/libc/kernel/common/linux/prctl.h
+++ b/libc/kernel/common/linux/prctl.h
@@ -18,52 +18,52 @@
  ****************************************************************************/
 #ifndef _LINUX_PRCTL_H
 #define _LINUX_PRCTL_H
-#define PR_SET_PDEATHSIG 1  
-#define PR_GET_PDEATHSIG 2  
+#define PR_SET_PDEATHSIG 1
+#define PR_GET_PDEATHSIG 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PR_GET_DUMPABLE 3
 #define PR_SET_DUMPABLE 4
 #define PR_GET_UNALIGN 5
 #define PR_SET_UNALIGN 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PR_UNALIGN_NOPRINT 1  
-#define PR_UNALIGN_SIGBUS 2  
+#define PR_UNALIGN_NOPRINT 1
+#define PR_UNALIGN_SIGBUS 2
 #define PR_GET_KEEPCAPS 7
 #define PR_SET_KEEPCAPS 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PR_GET_FPEMU 9
 #define PR_SET_FPEMU 10
-#define PR_FPEMU_NOPRINT 1  
-#define PR_FPEMU_SIGFPE 2  
+#define PR_FPEMU_NOPRINT 1
+#define PR_FPEMU_SIGFPE 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PR_GET_FPEXC 11
 #define PR_SET_FPEXC 12
-#define PR_FP_EXC_SW_ENABLE 0x80  
-#define PR_FP_EXC_DIV 0x010000  
+#define PR_FP_EXC_SW_ENABLE 0x80
+#define PR_FP_EXC_DIV 0x010000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PR_FP_EXC_OVF 0x020000  
-#define PR_FP_EXC_UND 0x040000  
-#define PR_FP_EXC_RES 0x080000  
-#define PR_FP_EXC_INV 0x100000  
+#define PR_FP_EXC_OVF 0x020000
+#define PR_FP_EXC_UND 0x040000
+#define PR_FP_EXC_RES 0x080000
+#define PR_FP_EXC_INV 0x100000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PR_FP_EXC_DISABLED 0  
-#define PR_FP_EXC_NONRECOV 1  
-#define PR_FP_EXC_ASYNC 2  
-#define PR_FP_EXC_PRECISE 3  
+#define PR_FP_EXC_DISABLED 0
+#define PR_FP_EXC_NONRECOV 1
+#define PR_FP_EXC_ASYNC 2
+#define PR_FP_EXC_PRECISE 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PR_GET_TIMING 13
 #define PR_SET_TIMING 14
-#define PR_TIMING_STATISTICAL 0  
-#define PR_TIMING_TIMESTAMP 1  
+#define PR_TIMING_STATISTICAL 0
+#define PR_TIMING_TIMESTAMP 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PR_SET_NAME 15  
-#define PR_GET_NAME 16  
+#define PR_SET_NAME 15
+#define PR_GET_NAME 16
 #define PR_GET_ENDIAN 19
 #define PR_SET_ENDIAN 20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PR_ENDIAN_BIG 0
-#define PR_ENDIAN_LITTLE 1  
-#define PR_ENDIAN_PPC_LITTLE 2  
+#define PR_ENDIAN_LITTLE 1
+#define PR_ENDIAN_PPC_LITTLE 2
 #define PR_GET_SECCOMP 21
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PR_SET_SECCOMP 22
@@ -72,8 +72,8 @@
 #define PR_GET_TSC 25
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PR_SET_TSC 26
-#define PR_TSC_ENABLE 1  
-#define PR_TSC_SIGSEGV 2  
+#define PR_TSC_ENABLE 1
+#define PR_TSC_SIGSEGV 2
 #define PR_GET_SECUREBITS 27
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PR_SET_SECUREBITS 28
diff --git a/libc/kernel/common/linux/qic117.h b/libc/kernel/common/linux/qic117.h
index 23f599a..11ee60e 100644
--- a/libc/kernel/common/linux/qic117.h
+++ b/libc/kernel/common/linux/qic117.h
@@ -87,16 +87,16 @@
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define QIC117_COMMANDS {         {NULL, 0x00, 0x00, mode, 0, discretional},   {"soft reset", 0x00, 0x00, motion, 1, required},   {"report next bit", 0x00, 0x00, report, 0, required},   {"pause", 0x36, 0x24, motion, 1, required},   {"micro step pause", 0x36, 0x24, motion, 1, required},   {"alternate command timeout", 0x00, 0x00, mode, 0, required},   {"report drive status", 0x00, 0x00, report, 0, required},   {"report error code", 0x01, 0x01, report, 0, required},   {"report drive configuration",0x00, 0x00, report, 0, required},   {"report rom version", 0x00, 0x00, report, 0, required},   {"logical forward", 0x37, 0x25, motion, 0, required},   {"physical reverse", 0x17, 0x05, motion, 0, required},   {"physical forward", 0x17, 0x05, motion, 0, required},   {"seek head to track", 0x37, 0x25, motion, 0, required},   {"seek load point", 0x17, 0x05, motion, 1, required},   {"enter format mode", 0x1f, 0x05, mode, 0, required},   {"write reference burst", 0x1f, 0x05, motion, 1, required},   {"enter verify mode", 0x37, 0x25, mode, 0, required},   {"stop tape", 0x00, 0x00, motion, 1, required},   {"reserved (19)", 0x00, 0x00, unused, 0, discretional},   {"reserved (20)", 0x00, 0x00, unused, 0, discretional},   {"micro step head up", 0x02, 0x00, motion, 0, required},   {"micro step head down", 0x02, 0x00, motion, 0, required},   {"soft select", 0x00, 0x00, mode, 0, discretional},   {"soft deselect", 0x00, 0x00, mode, 0, discretional},   {"skip segments reverse", 0x36, 0x24, motion, 1, required},   {"skip segments forward", 0x36, 0x24, motion, 1, required},   {"select rate or format", 0x03, 0x01, mode, 0, required  },   {"enter diag mode 1", 0x00, 0x00, mode, 0, discretional},   {"enter diag mode 2", 0x00, 0x00, mode, 0, discretional},   {"enter primary mode", 0x00, 0x00, mode, 0, required},   {"vendor unique (31)", 0x00, 0x00, unused, 0, discretional},   {"report vendor id", 0x00, 0x00, report, 0, required},   {"report tape status", 0x04, 0x04, report, 0, ccs1},   {"skip extended reverse", 0x36, 0x24, motion, 1, ccs1},   {"skip extended forward", 0x36, 0x24, motion, 1, ccs1},   {"calibrate tape length", 0x17, 0x05, motion, 1, ccs2},   {"report format segments", 0x17, 0x05, report, 0, ccs2},   {"set format segments", 0x17, 0x05, mode, 0, ccs2},   {"reserved (39)", 0x00, 0x00, unused, 0, discretional},   {"vendor unique (40)", 0x00, 0x00, unused, 0, discretional},   {"vendor unique (41)", 0x00, 0x00, unused, 0, discretional},   {"vendor unique (42)", 0x00, 0x00, unused, 0, discretional},   {"vendor unique (43)", 0x00, 0x00, unused, 0, discretional},   {"vendor unique (44)", 0x00, 0x00, unused, 0, discretional},   {"vendor unique (45)", 0x00, 0x00, unused, 0, discretional},   {"phantom select", 0x00, 0x00, mode, 0, discretional},   {"phantom deselect", 0x00, 0x00, mode, 0, discretional}, }
-#define QIC_STATUS_READY 0x01  
-#define QIC_STATUS_ERROR 0x02  
-#define QIC_STATUS_CARTRIDGE_PRESENT 0x04  
+#define QIC_STATUS_READY 0x01
+#define QIC_STATUS_ERROR 0x02
+#define QIC_STATUS_CARTRIDGE_PRESENT 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define QIC_STATUS_WRITE_PROTECT 0x08  
-#define QIC_STATUS_NEW_CARTRIDGE 0x10  
-#define QIC_STATUS_REFERENCED 0x20  
-#define QIC_STATUS_AT_BOT 0x40  
+#define QIC_STATUS_WRITE_PROTECT 0x08
+#define QIC_STATUS_NEW_CARTRIDGE 0x10
+#define QIC_STATUS_REFERENCED 0x20
+#define QIC_STATUS_AT_BOT 0x40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define QIC_STATUS_AT_EOT 0x80  
+#define QIC_STATUS_AT_EOT 0x80
 #define QIC_CONFIG_RATE_MASK 0x18
 #define QIC_CONFIG_RATE_SHIFT 3
 #define QIC_CONFIG_RATE_250 0
@@ -104,10 +104,10 @@
 #define QIC_CONFIG_RATE_500 2
 #define QIC_CONFIG_RATE_1000 3
 #define QIC_CONFIG_RATE_2000 1
-#define QIC_CONFIG_RATE_4000 0  
+#define QIC_CONFIG_RATE_4000 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define QIC_CONFIG_LONG 0x40  
-#define QIC_CONFIG_80 0x80  
+#define QIC_CONFIG_LONG 0x40
+#define QIC_CONFIG_80 0x80
 #define QIC_TAPE_STD_MASK 0x0f
 #define QIC_TAPE_QIC40 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/quota.h b/libc/kernel/common/linux/quota.h
index 3918bdc..55f6642 100644
--- a/libc/kernel/common/linux/quota.h
+++ b/libc/kernel/common/linux/quota.h
@@ -33,23 +33,23 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define toqb(x) (((x) + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS)
 #define MAXQUOTAS 2
-#define USRQUOTA 0  
-#define GRPQUOTA 1  
+#define USRQUOTA 0
+#define GRPQUOTA 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define INITQFNAMES {   "user",     "group",     "undefined",  };
 #define SUBCMDMASK 0x00ff
 #define SUBCMDSHIFT 8
 #define QCMD(cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define Q_SYNC 0x800001  
-#define Q_QUOTAON 0x800002  
-#define Q_QUOTAOFF 0x800003  
-#define Q_GETFMT 0x800004  
+#define Q_SYNC 0x800001
+#define Q_QUOTAON 0x800002
+#define Q_QUOTAOFF 0x800003
+#define Q_GETFMT 0x800004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define Q_GETINFO 0x800005  
-#define Q_SETINFO 0x800006  
-#define Q_GETQUOTA 0x800007  
-#define Q_SETQUOTA 0x800008  
+#define Q_GETINFO 0x800005
+#define Q_SETINFO 0x800006
+#define Q_GETQUOTA 0x800007
+#define Q_SETQUOTA 0x800008
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define QIF_BLIMITS 1
 #define QIF_SPACE 2
diff --git a/libc/kernel/common/linux/raid/md_k.h b/libc/kernel/common/linux/raid/md_k.h
index 2298b55..7b51694 100644
--- a/libc/kernel/common/linux/raid/md_k.h
+++ b/libc/kernel/common/linux/raid/md_k.h
@@ -29,7 +29,7 @@
 #define MD_THREAD_NAME_MAX 14
 typedef struct mddev_s mddev_t;
 typedef struct mdk_rdev_s mdk_rdev_t;
-#define MAX_MD_DEVS 256  
+#define MAX_MD_DEVS 256
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MAX_CHUNK_SIZE (1<<30)
 struct mdk_rdev_s
@@ -52,11 +52,11 @@
  struct kobject kobj;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long flags;
-#define Faulty 1  
-#define In_sync 2  
-#define WriteMostly 4  
+#define Faulty 1
+#define In_sync 2
+#define WriteMostly 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BarriersNotsupp 5  
+#define BarriersNotsupp 5
  int desc_nr;
  int raid_disk;
  int saved_raid_disk;
diff --git a/libc/kernel/common/linux/raid/md_p.h b/libc/kernel/common/linux/raid/md_p.h
index a30e293..2f80fba 100644
--- a/libc/kernel/common/linux/raid/md_p.h
+++ b/libc/kernel/common/linux/raid/md_p.h
@@ -46,12 +46,12 @@
 #define MD_SB_RESERVED_WORDS (1024 - MD_SB_GENERIC_WORDS - MD_SB_PERSONALITY_WORDS - MD_SB_DISKS_WORDS - MD_SB_DESCRIPTOR_WORDS)
 #define MD_SB_EQUAL_WORDS (MD_SB_GENERIC_WORDS + MD_SB_PERSONALITY_WORDS + MD_SB_DISKS_WORDS)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_DISK_FAULTY 0  
-#define MD_DISK_ACTIVE 1  
-#define MD_DISK_SYNC 2  
-#define MD_DISK_REMOVED 3  
+#define MD_DISK_FAULTY 0
+#define MD_DISK_ACTIVE 1
+#define MD_DISK_SYNC 2
+#define MD_DISK_REMOVED 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_DISK_WRITEMOSTLY 9  
+#define MD_DISK_WRITEMOSTLY 9
 typedef struct mdp_device_descriptor_s {
  __u32 number;
  __u32 major;
@@ -66,7 +66,7 @@
 #define MD_SB_CLEAN 0
 #define MD_SB_ERRORS 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_SB_BITMAP_PRESENT 8  
+#define MD_SB_BITMAP_PRESENT 8
 typedef struct mdp_superblock_s {
  __u32 md_magic;
  __u32 major_version;
@@ -167,7 +167,7 @@
  __u8 device_uuid[16];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __u8 devflags;
-#define WriteMostly1 1  
+#define WriteMostly1 1
  __u8 pad2[64-57];
  __u64 utime;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -181,7 +181,7 @@
 };
 #define MD_FEATURE_BITMAP_OFFSET 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MD_FEATURE_RECOVERY_OFFSET 2  
+#define MD_FEATURE_RECOVERY_OFFSET 2
 #define MD_FEATURE_RESHAPE_ACTIVE 4
 #define MD_FEATURE_ALL (1|2|4)
 #endif
diff --git a/libc/kernel/common/linux/resource.h b/libc/kernel/common/linux/resource.h
index 3b2941f..2b2ed97 100644
--- a/libc/kernel/common/linux/resource.h
+++ b/libc/kernel/common/linux/resource.h
@@ -23,7 +23,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RUSAGE_SELF 0
 #define RUSAGE_CHILDREN (-1)
-#define RUSAGE_BOTH (-2)  
+#define RUSAGE_BOTH (-2)
 struct rusage {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  struct timeval ru_utime;
diff --git a/libc/kernel/common/linux/route.h b/libc/kernel/common/linux/route.h
index 41e5a08..9d8c6d7 100644
--- a/libc/kernel/common/linux/route.h
+++ b/libc/kernel/common/linux/route.h
@@ -37,23 +37,23 @@
  char __user *rt_dev;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long rt_mtu;
-#define rt_mss rt_mtu  
+#define rt_mss rt_mtu
  unsigned long rt_window;
  unsigned short rt_irtt;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define RTF_UP 0x0001  
-#define RTF_GATEWAY 0x0002  
-#define RTF_HOST 0x0004  
+#define RTF_UP 0x0001
+#define RTF_GATEWAY 0x0002
+#define RTF_HOST 0x0004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RTF_REINSTATE 0x0008  
-#define RTF_DYNAMIC 0x0010  
-#define RTF_MODIFIED 0x0020  
-#define RTF_MTU 0x0040  
+#define RTF_REINSTATE 0x0008
+#define RTF_DYNAMIC 0x0010
+#define RTF_MODIFIED 0x0020
+#define RTF_MTU 0x0040
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RTF_MSS RTF_MTU  
-#define RTF_WINDOW 0x0080  
-#define RTF_IRTT 0x0100  
-#define RTF_REJECT 0x0200  
+#define RTF_MSS RTF_MTU
+#define RTF_WINDOW 0x0080
+#define RTF_IRTT 0x0100
+#define RTF_REJECT 0x0200
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/common/linux/rtc.h b/libc/kernel/common/linux/rtc.h
index e437060..e18d239 100644
--- a/libc/kernel/common/linux/rtc.h
+++ b/libc/kernel/common/linux/rtc.h
@@ -49,32 +49,32 @@
  int pll_negmult;
  long pll_clock;
 };
-#define RTC_AIE_ON _IO('p', 0x01)  
+#define RTC_AIE_ON _IO('p', 0x01)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RTC_AIE_OFF _IO('p', 0x02)  
-#define RTC_UIE_ON _IO('p', 0x03)  
-#define RTC_UIE_OFF _IO('p', 0x04)  
-#define RTC_PIE_ON _IO('p', 0x05)  
+#define RTC_AIE_OFF _IO('p', 0x02)
+#define RTC_UIE_ON _IO('p', 0x03)
+#define RTC_UIE_OFF _IO('p', 0x04)
+#define RTC_PIE_ON _IO('p', 0x05)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RTC_PIE_OFF _IO('p', 0x06)  
-#define RTC_WIE_ON _IO('p', 0x0f)  
-#define RTC_WIE_OFF _IO('p', 0x10)  
-#define RTC_ALM_SET _IOW('p', 0x07, struct rtc_time)  
+#define RTC_PIE_OFF _IO('p', 0x06)
+#define RTC_WIE_ON _IO('p', 0x0f)
+#define RTC_WIE_OFF _IO('p', 0x10)
+#define RTC_ALM_SET _IOW('p', 0x07, struct rtc_time)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RTC_ALM_READ _IOR('p', 0x08, struct rtc_time)  
-#define RTC_RD_TIME _IOR('p', 0x09, struct rtc_time)  
-#define RTC_SET_TIME _IOW('p', 0x0a, struct rtc_time)  
-#define RTC_IRQP_READ _IOR('p', 0x0b, unsigned long)  
+#define RTC_ALM_READ _IOR('p', 0x08, struct rtc_time)
+#define RTC_RD_TIME _IOR('p', 0x09, struct rtc_time)
+#define RTC_SET_TIME _IOW('p', 0x0a, struct rtc_time)
+#define RTC_IRQP_READ _IOR('p', 0x0b, unsigned long)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RTC_IRQP_SET _IOW('p', 0x0c, unsigned long)  
-#define RTC_EPOCH_READ _IOR('p', 0x0d, unsigned long)  
-#define RTC_EPOCH_SET _IOW('p', 0x0e, unsigned long)  
-#define RTC_WKALM_SET _IOW('p', 0x0f, struct rtc_wkalrm) 
+#define RTC_IRQP_SET _IOW('p', 0x0c, unsigned long)
+#define RTC_EPOCH_READ _IOR('p', 0x0d, unsigned long)
+#define RTC_EPOCH_SET _IOW('p', 0x0e, unsigned long)
+#define RTC_WKALM_SET _IOW('p', 0x0f, struct rtc_wkalrm)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RTC_WKALM_RD _IOR('p', 0x10, struct rtc_wkalrm) 
-#define RTC_PLL_GET _IOR('p', 0x11, struct rtc_pll_info)  
-#define RTC_PLL_SET _IOW('p', 0x12, struct rtc_pll_info)  
-#define RTC_IRQF 0x80  
+#define RTC_WKALM_RD _IOR('p', 0x10, struct rtc_wkalrm)
+#define RTC_PLL_GET _IOR('p', 0x11, struct rtc_pll_info)
+#define RTC_PLL_SET _IOW('p', 0x12, struct rtc_pll_info)
+#define RTC_IRQF 0x80
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTC_PF 0x40
 #define RTC_AF 0x20
diff --git a/libc/kernel/common/linux/rtnetlink.h b/libc/kernel/common/linux/rtnetlink.h
index 2d04e4e..26805b9 100644
--- a/libc/kernel/common/linux/rtnetlink.h
+++ b/libc/kernel/common/linux/rtnetlink.h
@@ -189,22 +189,22 @@
 };
 #define RTN_MAX (__RTN_MAX - 1)
 #define RTPROT_UNSPEC 0
-#define RTPROT_REDIRECT 1  
+#define RTPROT_REDIRECT 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RTPROT_KERNEL 2  
-#define RTPROT_BOOT 3  
-#define RTPROT_STATIC 4  
-#define RTPROT_GATED 8  
+#define RTPROT_KERNEL 2
+#define RTPROT_BOOT 3
+#define RTPROT_STATIC 4
+#define RTPROT_GATED 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RTPROT_RA 9  
-#define RTPROT_MRT 10  
-#define RTPROT_ZEBRA 11  
-#define RTPROT_BIRD 12  
+#define RTPROT_RA 9
+#define RTPROT_MRT 10
+#define RTPROT_ZEBRA 11
+#define RTPROT_BIRD 12
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RTPROT_DNROUTED 13  
-#define RTPROT_XORP 14  
-#define RTPROT_NTK 15  
-#define RTPROT_DHCP 16  
+#define RTPROT_DNROUTED 13
+#define RTPROT_XORP 14
+#define RTPROT_NTK 15
+#define RTPROT_DHCP 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum rt_scope_t {
  RT_SCOPE_UNIVERSE=0,
@@ -214,11 +214,11 @@
  RT_SCOPE_HOST=254,
  RT_SCOPE_NOWHERE=255
 };
-#define RTM_F_NOTIFY 0x100  
+#define RTM_F_NOTIFY 0x100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RTM_F_CLONED 0x200  
-#define RTM_F_EQUALIZE 0x400  
-#define RTM_F_PREFIX 0x800  
+#define RTM_F_CLONED 0x200
+#define RTM_F_EQUALIZE 0x400
+#define RTM_F_PREFIX 0x800
 enum rt_class_t {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  RT_TABLE_UNSPEC=0,
@@ -266,9 +266,9 @@
  int rtnh_ifindex;
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RTNH_F_DEAD 1  
-#define RTNH_F_PERVASIVE 2  
-#define RTNH_F_ONLINK 4  
+#define RTNH_F_DEAD 1
+#define RTNH_F_PERVASIVE 2
+#define RTNH_F_ONLINK 4
 #define RTNH_ALIGNTO 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNH_ALIGN(len) ( ((len)+RTNH_ALIGNTO-1) & ~(RTNH_ALIGNTO-1) )
@@ -539,7 +539,7 @@
 };
 #define TA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcamsg))))
 #define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg))
-#define TCA_ACT_TAB 1   
+#define TCA_ACT_TAB 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCAA_MAX 1
 #endif
diff --git a/libc/kernel/common/linux/sched.h b/libc/kernel/common/linux/sched.h
index c06b8ec..f41d291 100644
--- a/libc/kernel/common/linux/sched.h
+++ b/libc/kernel/common/linux/sched.h
@@ -18,30 +18,30 @@
  ****************************************************************************/
 #ifndef _LINUX_SCHED_H
 #define _LINUX_SCHED_H
-#include <linux/auxvec.h>  
-#define CSIGNAL 0x000000ff  
+#include <linux/auxvec.h>
+#define CSIGNAL 0x000000ff
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CLONE_VM 0x00000100  
-#define CLONE_FS 0x00000200  
-#define CLONE_FILES 0x00000400  
-#define CLONE_SIGHAND 0x00000800  
+#define CLONE_VM 0x00000100
+#define CLONE_FS 0x00000200
+#define CLONE_FILES 0x00000400
+#define CLONE_SIGHAND 0x00000800
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CLONE_PTRACE 0x00002000  
-#define CLONE_VFORK 0x00004000  
-#define CLONE_PARENT 0x00008000  
-#define CLONE_THREAD 0x00010000  
+#define CLONE_PTRACE 0x00002000
+#define CLONE_VFORK 0x00004000
+#define CLONE_PARENT 0x00008000
+#define CLONE_THREAD 0x00010000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CLONE_NEWNS 0x00020000  
-#define CLONE_SYSVSEM 0x00040000  
-#define CLONE_SETTLS 0x00080000  
-#define CLONE_PARENT_SETTID 0x00100000  
+#define CLONE_NEWNS 0x00020000
+#define CLONE_SYSVSEM 0x00040000
+#define CLONE_SETTLS 0x00080000
+#define CLONE_PARENT_SETTID 0x00100000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CLONE_CHILD_CLEARTID 0x00200000  
-#define CLONE_DETACHED 0x00400000  
-#define CLONE_UNTRACED 0x00800000  
-#define CLONE_CHILD_SETTID 0x01000000  
+#define CLONE_CHILD_CLEARTID 0x00200000
+#define CLONE_DETACHED 0x00400000
+#define CLONE_UNTRACED 0x00800000
+#define CLONE_CHILD_SETTID 0x01000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CLONE_STOPPED 0x02000000  
+#define CLONE_STOPPED 0x02000000
 #define SCHED_NORMAL 0
 #define SCHED_FIFO 1
 #define SCHED_RR 2
diff --git a/libc/kernel/common/linux/seccomp.h b/libc/kernel/common/linux/seccomp.h
index 82a6985..cb1b2b8 100644
--- a/libc/kernel/common/linux/seccomp.h
+++ b/libc/kernel/common/linux/seccomp.h
@@ -21,15 +21,15 @@
 #include <linux/compiler.h>
 #include <linux/types.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SECCOMP_MODE_DISABLED 0  
-#define SECCOMP_MODE_STRICT 1  
-#define SECCOMP_MODE_FILTER 2  
-#define SECCOMP_RET_KILL 0x00000000U  
+#define SECCOMP_MODE_DISABLED 0
+#define SECCOMP_MODE_STRICT 1
+#define SECCOMP_MODE_FILTER 2
+#define SECCOMP_RET_KILL 0x00000000U
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SECCOMP_RET_TRAP 0x00030000U  
-#define SECCOMP_RET_ERRNO 0x00050000U  
-#define SECCOMP_RET_TRACE 0x7ff00000U  
-#define SECCOMP_RET_ALLOW 0x7fff0000U  
+#define SECCOMP_RET_TRAP 0x00030000U
+#define SECCOMP_RET_ERRNO 0x00050000U
+#define SECCOMP_RET_TRACE 0x7ff00000U
+#define SECCOMP_RET_ALLOW 0x7fff0000U
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SECCOMP_RET_ACTION 0x7fff0000U
 #define SECCOMP_RET_DATA 0x0000ffffU
diff --git a/libc/kernel/common/linux/securebits.h b/libc/kernel/common/linux/securebits.h
new file mode 100644
index 0000000..7bde365
--- /dev/null
+++ b/libc/kernel/common/linux/securebits.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ***   To edit the content of this header, modify the corresponding
+ ***   source file (e.g. under external/kernel-headers/original/) then
+ ***   run bionic/libc/kernel/tools/update_all.py
+ ***
+ ***   Any manual change here will be lost the next time this script will
+ ***   be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _LINUX_SECUREBITS_H
+#define _LINUX_SECUREBITS_H 1
+#define issecure_mask(X) (1 << (X))
+#define SECUREBITS_DEFAULT 0x00000000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SECURE_NOROOT 0
+#define SECURE_NOROOT_LOCKED 1
+#define SECBIT_NOROOT (issecure_mask(SECURE_NOROOT))
+#define SECBIT_NOROOT_LOCKED (issecure_mask(SECURE_NOROOT_LOCKED))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SECURE_NO_SETUID_FIXUP 2
+#define SECURE_NO_SETUID_FIXUP_LOCKED 3
+#define SECBIT_NO_SETUID_FIXUP (issecure_mask(SECURE_NO_SETUID_FIXUP))
+#define SECBIT_NO_SETUID_FIXUP_LOCKED   (issecure_mask(SECURE_NO_SETUID_FIXUP_LOCKED))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SECURE_KEEP_CAPS 4
+#define SECURE_KEEP_CAPS_LOCKED 5
+#define SECBIT_KEEP_CAPS (issecure_mask(SECURE_KEEP_CAPS))
+#define SECBIT_KEEP_CAPS_LOCKED (issecure_mask(SECURE_KEEP_CAPS_LOCKED))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SECURE_ALL_BITS (issecure_mask(SECURE_NOROOT) |   issecure_mask(SECURE_NO_SETUID_FIXUP) |   issecure_mask(SECURE_KEEP_CAPS))
+#define SECURE_ALL_LOCKS (SECURE_ALL_BITS << 1)
+#endif
diff --git a/libc/kernel/common/linux/sem.h b/libc/kernel/common/linux/sem.h
index 5c15194..7e1171e 100644
--- a/libc/kernel/common/linux/sem.h
+++ b/libc/kernel/common/linux/sem.h
@@ -19,16 +19,16 @@
 #ifndef _LINUX_SEM_H
 #define _LINUX_SEM_H
 #include <linux/ipc.h>
-#define SEM_UNDO 0x1000  
+#define SEM_UNDO 0x1000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define GETPID 11  
-#define GETVAL 12  
-#define GETALL 13  
-#define GETNCNT 14  
+#define GETPID 11
+#define GETVAL 12
+#define GETALL 13
+#define GETNCNT 14
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define GETZCNT 15  
-#define SETVAL 16  
-#define SETALL 17  
+#define GETZCNT 15
+#define SETVAL 16
+#define SETALL 17
 #define SEM_STAT 18
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SEM_INFO 19
@@ -76,16 +76,16 @@
  int semaem;
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SEMMNI 128  
-#define SEMMSL 250  
-#define SEMMNS (SEMMNI*SEMMSL)  
-#define SEMOPM 32  
+#define SEMMNI 128
+#define SEMMSL 250
+#define SEMMNS (SEMMNI*SEMMSL)
+#define SEMOPM 32
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SEMVMX 32767  
-#define SEMAEM SEMVMX  
-#define SEMUME SEMOPM  
-#define SEMMNU SEMMNS  
+#define SEMVMX 32767
+#define SEMAEM SEMVMX
+#define SEMUME SEMOPM
+#define SEMMNU SEMMNS
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SEMMAP SEMMNS  
-#define SEMUSZ 20  
+#define SEMMAP SEMMNS
+#define SEMUSZ 20
 #endif
diff --git a/libc/kernel/common/linux/serial_core.h b/libc/kernel/common/linux/serial_core.h
index 57b973d..19b0a72 100644
--- a/libc/kernel/common/linux/serial_core.h
+++ b/libc/kernel/common/linux/serial_core.h
@@ -38,7 +38,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PORT_NS16550A 14
 #define PORT_XSCALE 15
-#define PORT_MAX_8250 15  
+#define PORT_MAX_8250 15
 #define PORT_PXA 31
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PORT_AMBA 32
@@ -54,7 +54,7 @@
 #define PORT_DZ 47
 #define PORT_MUX 48
 #define PORT_AT91 49
-#define PORT_MAC_ZILOG 50  
+#define PORT_MAC_ZILOG 50
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PORT_PMAC_ZILOG 51
 #define PORT_SCI 52
diff --git a/libc/kernel/common/linux/serial_reg.h b/libc/kernel/common/linux/serial_reg.h
index f31700b..5df79e1 100644
--- a/libc/kernel/common/linux/serial_reg.h
+++ b/libc/kernel/common/linux/serial_reg.h
@@ -18,31 +18,31 @@
  ****************************************************************************/
 #ifndef _LINUX_SERIAL_REG_H
 #define _LINUX_SERIAL_REG_H
-#define UART_RX 0  
-#define UART_TX 0  
+#define UART_RX 0
+#define UART_TX 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_IER 1  
-#define UART_IER_MSI 0x08  
-#define UART_IER_RLSI 0x04  
-#define UART_IER_THRI 0x02  
+#define UART_IER 1
+#define UART_IER_MSI 0x08
+#define UART_IER_RLSI 0x04
+#define UART_IER_THRI 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_IER_RDI 0x01  
-#define UART_IERX_SLEEP 0x10  
-#define UART_IIR 2  
-#define UART_IIR_NO_INT 0x01  
+#define UART_IER_RDI 0x01
+#define UART_IERX_SLEEP 0x10
+#define UART_IIR 2
+#define UART_IIR_NO_INT 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_IIR_ID 0x06  
-#define UART_IIR_MSI 0x00  
-#define UART_IIR_THRI 0x02  
-#define UART_IIR_RDI 0x04  
+#define UART_IIR_ID 0x06
+#define UART_IIR_MSI 0x00
+#define UART_IIR_THRI 0x02
+#define UART_IIR_RDI 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_IIR_RLSI 0x06  
-#define UART_FCR 2  
-#define UART_FCR_ENABLE_FIFO 0x01  
-#define UART_FCR_CLEAR_RCVR 0x02  
+#define UART_IIR_RLSI 0x06
+#define UART_FCR 2
+#define UART_FCR_ENABLE_FIFO 0x01
+#define UART_FCR_CLEAR_RCVR 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_FCR_CLEAR_XMIT 0x04  
-#define UART_FCR_DMA_SELECT 0x08  
+#define UART_FCR_CLEAR_XMIT 0x04
+#define UART_FCR_DMA_SELECT 0x08
 #define UART_FCR_R_TRIG_00 0x00
 #define UART_FCR_R_TRIG_01 0x40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -53,91 +53,91 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define UART_FCR_T_TRIG_10 0x20
 #define UART_FCR_T_TRIG_11 0x30
-#define UART_FCR_TRIGGER_MASK 0xC0  
-#define UART_FCR_TRIGGER_1 0x00  
+#define UART_FCR_TRIGGER_MASK 0xC0
+#define UART_FCR_TRIGGER_1 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_FCR_TRIGGER_4 0x40  
-#define UART_FCR_TRIGGER_8 0x80  
-#define UART_FCR_TRIGGER_14 0xC0  
-#define UART_FCR6_R_TRIGGER_8 0x00  
+#define UART_FCR_TRIGGER_4 0x40
+#define UART_FCR_TRIGGER_8 0x80
+#define UART_FCR_TRIGGER_14 0xC0
+#define UART_FCR6_R_TRIGGER_8 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_FCR6_R_TRIGGER_16 0x40  
-#define UART_FCR6_R_TRIGGER_24 0x80  
-#define UART_FCR6_R_TRIGGER_28 0xC0  
-#define UART_FCR6_T_TRIGGER_16 0x00  
+#define UART_FCR6_R_TRIGGER_16 0x40
+#define UART_FCR6_R_TRIGGER_24 0x80
+#define UART_FCR6_R_TRIGGER_28 0xC0
+#define UART_FCR6_T_TRIGGER_16 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_FCR6_T_TRIGGER_8 0x10  
-#define UART_FCR6_T_TRIGGER_24 0x20  
-#define UART_FCR6_T_TRIGGER_30 0x30  
-#define UART_FCR7_64BYTE 0x20  
+#define UART_FCR6_T_TRIGGER_8 0x10
+#define UART_FCR6_T_TRIGGER_24 0x20
+#define UART_FCR6_T_TRIGGER_30 0x30
+#define UART_FCR7_64BYTE 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_LCR 3  
-#define UART_LCR_DLAB 0x80  
-#define UART_LCR_SBC 0x40  
-#define UART_LCR_SPAR 0x20  
+#define UART_LCR 3
+#define UART_LCR_DLAB 0x80
+#define UART_LCR_SBC 0x40
+#define UART_LCR_SPAR 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_LCR_EPAR 0x10  
-#define UART_LCR_PARITY 0x08  
-#define UART_LCR_STOP 0x04  
-#define UART_LCR_WLEN5 0x00  
+#define UART_LCR_EPAR 0x10
+#define UART_LCR_PARITY 0x08
+#define UART_LCR_STOP 0x04
+#define UART_LCR_WLEN5 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_LCR_WLEN6 0x01  
-#define UART_LCR_WLEN7 0x02  
-#define UART_LCR_WLEN8 0x03  
-#define UART_MCR 4  
+#define UART_LCR_WLEN6 0x01
+#define UART_LCR_WLEN7 0x02
+#define UART_LCR_WLEN8 0x03
+#define UART_MCR 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_MCR_CLKSEL 0x80  
-#define UART_MCR_TCRTLR 0x40  
-#define UART_MCR_XONANY 0x20  
-#define UART_MCR_AFE 0x20  
+#define UART_MCR_CLKSEL 0x80
+#define UART_MCR_TCRTLR 0x40
+#define UART_MCR_XONANY 0x20
+#define UART_MCR_AFE 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_MCR_LOOP 0x10  
-#define UART_MCR_OUT2 0x08  
-#define UART_MCR_OUT1 0x04  
-#define UART_MCR_RTS 0x02  
+#define UART_MCR_LOOP 0x10
+#define UART_MCR_OUT2 0x08
+#define UART_MCR_OUT1 0x04
+#define UART_MCR_RTS 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_MCR_DTR 0x01  
-#define UART_LSR 5  
-#define UART_LSR_TEMT 0x40  
-#define UART_LSR_THRE 0x20  
+#define UART_MCR_DTR 0x01
+#define UART_LSR 5
+#define UART_LSR_TEMT 0x40
+#define UART_LSR_THRE 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_LSR_BI 0x10  
-#define UART_LSR_FE 0x08  
-#define UART_LSR_PE 0x04  
-#define UART_LSR_OE 0x02  
+#define UART_LSR_BI 0x10
+#define UART_LSR_FE 0x08
+#define UART_LSR_PE 0x04
+#define UART_LSR_OE 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_LSR_DR 0x01  
-#define UART_MSR 6  
-#define UART_MSR_DCD 0x80  
-#define UART_MSR_RI 0x40  
+#define UART_LSR_DR 0x01
+#define UART_MSR 6
+#define UART_MSR_DCD 0x80
+#define UART_MSR_RI 0x40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_MSR_DSR 0x20  
-#define UART_MSR_CTS 0x10  
-#define UART_MSR_DDCD 0x08  
-#define UART_MSR_TERI 0x04  
+#define UART_MSR_DSR 0x20
+#define UART_MSR_CTS 0x10
+#define UART_MSR_DDCD 0x08
+#define UART_MSR_TERI 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_MSR_DDSR 0x02  
-#define UART_MSR_DCTS 0x01  
-#define UART_MSR_ANY_DELTA 0x0F  
-#define UART_SCR 7  
+#define UART_MSR_DDSR 0x02
+#define UART_MSR_DCTS 0x01
+#define UART_MSR_ANY_DELTA 0x0F
+#define UART_SCR 7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_DLL 0  
-#define UART_DLM 1  
-#define UART_EFR 2  
-#define UART_EFR_CTS 0x80  
+#define UART_DLL 0
+#define UART_DLM 1
+#define UART_EFR 2
+#define UART_EFR_CTS 0x80
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_EFR_RTS 0x40  
-#define UART_EFR_SCD 0x20  
-#define UART_EFR_ECB 0x10  
-#define UART_XON1 4  
+#define UART_EFR_RTS 0x40
+#define UART_EFR_SCD 0x20
+#define UART_EFR_ECB 0x10
+#define UART_XON1 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_XON2 5  
-#define UART_XOFF1 6  
-#define UART_XOFF2 7  
-#define UART_TI752_TCR 6  
+#define UART_XON2 5
+#define UART_XOFF1 6
+#define UART_XOFF2 7
+#define UART_TI752_TCR 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_TI752_TLR 7  
-#define UART_TRG 0  
+#define UART_TI752_TLR 7
+#define UART_TRG 0
 #define UART_TRG_1 0x01
 #define UART_TRG_4 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -149,113 +149,113 @@
 #define UART_TRG_96 0x60
 #define UART_TRG_120 0x78
 #define UART_TRG_128 0x80
-#define UART_FCTR 1  
+#define UART_FCTR 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_FCTR_RTS_NODELAY 0x00  
+#define UART_FCTR_RTS_NODELAY 0x00
 #define UART_FCTR_RTS_4DELAY 0x01
 #define UART_FCTR_RTS_6DELAY 0x02
 #define UART_FCTR_RTS_8DELAY 0x03
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_FCTR_IRDA 0x04  
-#define UART_FCTR_TX_INT 0x08  
-#define UART_FCTR_TRGA 0x00  
-#define UART_FCTR_TRGB 0x10  
+#define UART_FCTR_IRDA 0x04
+#define UART_FCTR_TX_INT 0x08
+#define UART_FCTR_TRGA 0x00
+#define UART_FCTR_TRGB 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_FCTR_TRGC 0x20  
-#define UART_FCTR_TRGD 0x30  
-#define UART_FCTR_SCR_SWAP 0x40  
-#define UART_FCTR_RX 0x00  
+#define UART_FCTR_TRGC 0x20
+#define UART_FCTR_TRGD 0x30
+#define UART_FCTR_SCR_SWAP 0x40
+#define UART_FCTR_RX 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_FCTR_TX 0x80  
-#define UART_EMSR 7  
-#define UART_EMSR_FIFO_COUNT 0x01  
-#define UART_EMSR_ALT_COUNT 0x02  
+#define UART_FCTR_TX 0x80
+#define UART_EMSR 7
+#define UART_EMSR_FIFO_COUNT 0x01
+#define UART_EMSR_ALT_COUNT 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_IER_DMAE 0x80  
-#define UART_IER_UUE 0x40  
-#define UART_IER_NRZE 0x20  
-#define UART_IER_RTOIE 0x10  
+#define UART_IER_DMAE 0x80
+#define UART_IER_UUE 0x40
+#define UART_IER_NRZE 0x20
+#define UART_IER_RTOIE 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_IIR_TOD 0x08  
-#define UART_FCR_PXAR1 0x00  
-#define UART_FCR_PXAR8 0x40  
-#define UART_FCR_PXAR16 0x80  
+#define UART_IIR_TOD 0x08
+#define UART_FCR_PXAR1 0x00
+#define UART_FCR_PXAR8 0x40
+#define UART_FCR_PXAR16 0x80
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_FCR_PXAR32 0xc0  
-#define UART_ASR 0x01  
-#define UART_RFL 0x03  
-#define UART_TFL 0x04  
+#define UART_FCR_PXAR32 0xc0
+#define UART_ASR 0x01
+#define UART_RFL 0x03
+#define UART_TFL 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_ICR 0x05  
-#define UART_ACR 0x00  
-#define UART_CPR 0x01  
-#define UART_TCR 0x02  
+#define UART_ICR 0x05
+#define UART_ACR 0x00
+#define UART_CPR 0x01
+#define UART_TCR 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_CKS 0x03  
-#define UART_TTL 0x04  
-#define UART_RTL 0x05  
-#define UART_FCL 0x06  
+#define UART_CKS 0x03
+#define UART_TTL 0x04
+#define UART_RTL 0x05
+#define UART_FCL 0x06
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_FCH 0x07  
-#define UART_ID1 0x08  
-#define UART_ID2 0x09  
-#define UART_ID3 0x0A  
+#define UART_FCH 0x07
+#define UART_ID1 0x08
+#define UART_ID2 0x09
+#define UART_ID3 0x0A
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_REV 0x0B  
-#define UART_CSR 0x0C  
-#define UART_NMR 0x0D  
+#define UART_REV 0x0B
+#define UART_CSR 0x0C
+#define UART_NMR 0x0D
 #define UART_CTR 0xFF
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_ACR_RXDIS 0x01  
-#define UART_ACR_TXDIS 0x02  
-#define UART_ACR_DSRFC 0x04  
-#define UART_ACR_TLENB 0x20  
+#define UART_ACR_RXDIS 0x01
+#define UART_ACR_TXDIS 0x02
+#define UART_ACR_DSRFC 0x04
+#define UART_ACR_TLENB 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_ACR_ICRRD 0x40  
-#define UART_ACR_ASREN 0x80  
+#define UART_ACR_ICRRD 0x40
+#define UART_ACR_ASREN 0x80
 #define UART_RSA_BASE (-8)
-#define UART_RSA_MSR ((UART_RSA_BASE) + 0)  
+#define UART_RSA_MSR ((UART_RSA_BASE) + 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_RSA_MSR_SWAP (1 << 0)  
-#define UART_RSA_MSR_FIFO (1 << 2)  
-#define UART_RSA_MSR_FLOW (1 << 3)  
-#define UART_RSA_MSR_ITYP (1 << 4)  
+#define UART_RSA_MSR_SWAP (1 << 0)
+#define UART_RSA_MSR_FIFO (1 << 2)
+#define UART_RSA_MSR_FLOW (1 << 3)
+#define UART_RSA_MSR_ITYP (1 << 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_RSA_IER ((UART_RSA_BASE) + 1)  
-#define UART_RSA_IER_Rx_FIFO_H (1 << 0)  
-#define UART_RSA_IER_Tx_FIFO_H (1 << 1)  
-#define UART_RSA_IER_Tx_FIFO_E (1 << 2)  
+#define UART_RSA_IER ((UART_RSA_BASE) + 1)
+#define UART_RSA_IER_Rx_FIFO_H (1 << 0)
+#define UART_RSA_IER_Tx_FIFO_H (1 << 1)
+#define UART_RSA_IER_Tx_FIFO_E (1 << 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_RSA_IER_Rx_TOUT (1 << 3)  
-#define UART_RSA_IER_TIMER (1 << 4)  
-#define UART_RSA_SRR ((UART_RSA_BASE) + 2)  
-#define UART_RSA_SRR_Tx_FIFO_NEMP (1 << 0)  
+#define UART_RSA_IER_Rx_TOUT (1 << 3)
+#define UART_RSA_IER_TIMER (1 << 4)
+#define UART_RSA_SRR ((UART_RSA_BASE) + 2)
+#define UART_RSA_SRR_Tx_FIFO_NEMP (1 << 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_RSA_SRR_Tx_FIFO_NHFL (1 << 1)  
-#define UART_RSA_SRR_Tx_FIFO_NFUL (1 << 2)  
-#define UART_RSA_SRR_Rx_FIFO_NEMP (1 << 3)  
-#define UART_RSA_SRR_Rx_FIFO_NHFL (1 << 4)  
+#define UART_RSA_SRR_Tx_FIFO_NHFL (1 << 1)
+#define UART_RSA_SRR_Tx_FIFO_NFUL (1 << 2)
+#define UART_RSA_SRR_Rx_FIFO_NEMP (1 << 3)
+#define UART_RSA_SRR_Rx_FIFO_NHFL (1 << 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_RSA_SRR_Rx_FIFO_NFUL (1 << 5)  
-#define UART_RSA_SRR_Rx_TOUT (1 << 6)  
-#define UART_RSA_SRR_TIMER (1 << 7)  
-#define UART_RSA_FRR ((UART_RSA_BASE) + 2)  
+#define UART_RSA_SRR_Rx_FIFO_NFUL (1 << 5)
+#define UART_RSA_SRR_Rx_TOUT (1 << 6)
+#define UART_RSA_SRR_TIMER (1 << 7)
+#define UART_RSA_FRR ((UART_RSA_BASE) + 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_RSA_TIVSR ((UART_RSA_BASE) + 3)  
-#define UART_RSA_TCR ((UART_RSA_BASE) + 4)  
-#define UART_RSA_TCR_SWITCH (1 << 0)  
+#define UART_RSA_TIVSR ((UART_RSA_BASE) + 3)
+#define UART_RSA_TCR ((UART_RSA_BASE) + 4)
+#define UART_RSA_TCR_SWITCH (1 << 0)
 #define SERIAL_RSA_BAUD_BASE (921600)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SERIAL_RSA_BAUD_BASE_LO (SERIAL_RSA_BAUD_BASE / 8)
-#define UART_OMAP_MDR1 0x08  
-#define UART_OMAP_MDR2 0x09  
-#define UART_OMAP_SCR 0x10  
+#define UART_OMAP_MDR1 0x08
+#define UART_OMAP_MDR2 0x09
+#define UART_OMAP_SCR 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_OMAP_SSR 0x11  
-#define UART_OMAP_EBLR 0x12  
-#define UART_OMAP_OSC_12M_SEL 0x13  
-#define UART_OMAP_MVER 0x14  
+#define UART_OMAP_SSR 0x11
+#define UART_OMAP_EBLR 0x12
+#define UART_OMAP_OSC_12M_SEL 0x13
+#define UART_OMAP_MVER 0x14
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UART_OMAP_SYSC 0x15  
-#define UART_OMAP_SYSS 0x16  
+#define UART_OMAP_SYSC 0x15
+#define UART_OMAP_SYSS 0x16
 #endif
diff --git a/libc/kernel/common/linux/shm.h b/libc/kernel/common/linux/shm.h
index ecee3e8..e9900ca 100644
--- a/libc/kernel/common/linux/shm.h
+++ b/libc/kernel/common/linux/shm.h
@@ -22,12 +22,12 @@
 #include <linux/errno.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <asm/page.h>
-#define SHMMAX 0x2000000  
-#define SHMMIN 1  
-#define SHMMNI 4096  
+#define SHMMAX 0x2000000
+#define SHMMIN 1
+#define SHMMNI 4096
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHMALL (SHMMAX/PAGE_SIZE*(SHMMNI/16))  
-#define SHMSEG SHMMNI  
+#define SHMALL (SHMMAX/PAGE_SIZE*(SHMMNI/16))
+#define SHMSEG SHMMNI
 #include <asm/shmparam.h>
 struct shmid_ds {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -47,13 +47,13 @@
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <asm/shmbuf.h>
-#define SHM_R 0400  
-#define SHM_W 0200  
-#define SHM_RDONLY 010000  
+#define SHM_R 0400
+#define SHM_W 0200
+#define SHM_RDONLY 010000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SHM_RND 020000  
-#define SHM_REMAP 040000  
-#define SHM_EXEC 0100000  
+#define SHM_RND 020000
+#define SHM_REMAP 040000
+#define SHM_EXEC 0100000
 #define SHM_LOCK 11
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SHM_UNLOCK 12
diff --git a/libc/kernel/common/linux/signalfd.h b/libc/kernel/common/linux/signalfd.h
new file mode 100644
index 0000000..a064192
--- /dev/null
+++ b/libc/kernel/common/linux/signalfd.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ***   To edit the content of this header, modify the corresponding
+ ***   source file (e.g. under external/kernel-headers/original/) then
+ ***   run bionic/libc/kernel/tools/update_all.py
+ ***
+ ***   Any manual change here will be lost the next time this script will
+ ***   be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _LINUX_SIGNALFD_H
+#define _LINUX_SIGNALFD_H
+#include <linux/types.h>
+#include <linux/fcntl.h>
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SFD_CLOEXEC O_CLOEXEC
+#define SFD_NONBLOCK O_NONBLOCK
+struct signalfd_siginfo {
+ __u32 ssi_signo;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ __s32 ssi_errno;
+ __s32 ssi_code;
+ __u32 ssi_pid;
+ __u32 ssi_uid;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ __s32 ssi_fd;
+ __u32 ssi_tid;
+ __u32 ssi_band;
+ __u32 ssi_overrun;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ __u32 ssi_trapno;
+ __s32 ssi_status;
+ __s32 ssi_int;
+ __u64 ssi_ptr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ __u64 ssi_utime;
+ __u64 ssi_stime;
+ __u64 ssi_addr;
+ __u16 ssi_addr_lsb;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ __u8 __pad[46];
+};
+#endif
diff --git a/libc/kernel/common/linux/skbuff.h b/libc/kernel/common/linux/skbuff.h
index d52b46c..a35abf9 100644
--- a/libc/kernel/common/linux/skbuff.h
+++ b/libc/kernel/common/linux/skbuff.h
@@ -36,8 +36,8 @@
 #include <net/checksum.h>
 #include <linux/dmaengine.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HAVE_ALLOC_SKB  
-#define HAVE_ALIGNABLE_SKB  
+#define HAVE_ALLOC_SKB
+#define HAVE_ALIGNABLE_SKB
 #define CHECKSUM_NONE 0
 #define CHECKSUM_HW 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/socket.h b/libc/kernel/common/linux/socket.h
index 1037f50..d1cbaf4 100644
--- a/libc/kernel/common/linux/socket.h
+++ b/libc/kernel/common/linux/socket.h
@@ -18,7 +18,7 @@
  ****************************************************************************/
 #ifndef _LINUX_SOCKET_H
 #define _LINUX_SOCKET_H
-#define _K_SS_MAXSIZE 128  
+#define _K_SS_MAXSIZE 128
 #define _K_SS_ALIGNSIZE (__alignof__ (struct sockaddr *))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef unsigned short __kernel_sa_family_t;
diff --git a/libc/kernel/common/linux/sockios.h b/libc/kernel/common/linux/sockios.h
index 0c93e40..cd53981 100644
--- a/libc/kernel/common/linux/sockios.h
+++ b/libc/kernel/common/linux/sockios.h
@@ -22,94 +22,94 @@
 #define SIOCINQ FIONREAD
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SIOCOUTQ TIOCOUTQ
-#define SIOCADDRT 0x890B  
-#define SIOCDELRT 0x890C  
-#define SIOCRTMSG 0x890D  
+#define SIOCADDRT 0x890B
+#define SIOCDELRT 0x890C
+#define SIOCRTMSG 0x890D
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCGIFNAME 0x8910  
-#define SIOCSIFLINK 0x8911  
-#define SIOCGIFCONF 0x8912  
-#define SIOCGIFFLAGS 0x8913  
+#define SIOCGIFNAME 0x8910
+#define SIOCSIFLINK 0x8911
+#define SIOCGIFCONF 0x8912
+#define SIOCGIFFLAGS 0x8913
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCSIFFLAGS 0x8914  
-#define SIOCGIFADDR 0x8915  
-#define SIOCSIFADDR 0x8916  
-#define SIOCGIFDSTADDR 0x8917  
+#define SIOCSIFFLAGS 0x8914
+#define SIOCGIFADDR 0x8915
+#define SIOCSIFADDR 0x8916
+#define SIOCGIFDSTADDR 0x8917
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCSIFDSTADDR 0x8918  
-#define SIOCGIFBRDADDR 0x8919  
-#define SIOCSIFBRDADDR 0x891a  
-#define SIOCGIFNETMASK 0x891b  
+#define SIOCSIFDSTADDR 0x8918
+#define SIOCGIFBRDADDR 0x8919
+#define SIOCSIFBRDADDR 0x891a
+#define SIOCGIFNETMASK 0x891b
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCSIFNETMASK 0x891c  
-#define SIOCGIFMETRIC 0x891d  
-#define SIOCSIFMETRIC 0x891e  
-#define SIOCGIFMEM 0x891f  
+#define SIOCSIFNETMASK 0x891c
+#define SIOCGIFMETRIC 0x891d
+#define SIOCSIFMETRIC 0x891e
+#define SIOCGIFMEM 0x891f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCSIFMEM 0x8920  
-#define SIOCGIFMTU 0x8921  
-#define SIOCSIFMTU 0x8922  
-#define SIOCSIFNAME 0x8923  
+#define SIOCSIFMEM 0x8920
+#define SIOCGIFMTU 0x8921
+#define SIOCSIFMTU 0x8922
+#define SIOCSIFNAME 0x8923
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCSIFHWADDR 0x8924  
-#define SIOCGIFENCAP 0x8925  
-#define SIOCSIFENCAP 0x8926 
-#define SIOCGIFHWADDR 0x8927  
+#define SIOCSIFHWADDR 0x8924
+#define SIOCGIFENCAP 0x8925
+#define SIOCSIFENCAP 0x8926
+#define SIOCGIFHWADDR 0x8927
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCGIFSLAVE 0x8929  
+#define SIOCGIFSLAVE 0x8929
 #define SIOCSIFSLAVE 0x8930
-#define SIOCADDMULTI 0x8931  
+#define SIOCADDMULTI 0x8931
 #define SIOCDELMULTI 0x8932
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCGIFINDEX 0x8933  
-#define SIOGIFINDEX SIOCGIFINDEX  
-#define SIOCSIFPFLAGS 0x8934  
+#define SIOCGIFINDEX 0x8933
+#define SIOGIFINDEX SIOCGIFINDEX
+#define SIOCSIFPFLAGS 0x8934
 #define SIOCGIFPFLAGS 0x8935
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCDIFADDR 0x8936  
-#define SIOCSIFHWBROADCAST 0x8937  
-#define SIOCGIFCOUNT 0x8938  
-#define SIOCKILLADDR 0x8939  
+#define SIOCDIFADDR 0x8936
+#define SIOCSIFHWBROADCAST 0x8937
+#define SIOCGIFCOUNT 0x8938
+#define SIOCKILLADDR 0x8939
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCGIFBR 0x8940  
-#define SIOCSIFBR 0x8941  
-#define SIOCGIFTXQLEN 0x8942  
-#define SIOCSIFTXQLEN 0x8943  
+#define SIOCGIFBR 0x8940
+#define SIOCSIFBR 0x8941
+#define SIOCGIFTXQLEN 0x8942
+#define SIOCSIFTXQLEN 0x8943
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCETHTOOL 0x8946  
-#define SIOCGMIIPHY 0x8947  
-#define SIOCGMIIREG 0x8948  
-#define SIOCSMIIREG 0x8949  
+#define SIOCETHTOOL 0x8946
+#define SIOCGMIIPHY 0x8947
+#define SIOCGMIIREG 0x8948
+#define SIOCSMIIREG 0x8949
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCWANDEV 0x894A  
-#define SIOCDARP 0x8953  
-#define SIOCGARP 0x8954  
-#define SIOCSARP 0x8955  
+#define SIOCWANDEV 0x894A
+#define SIOCDARP 0x8953
+#define SIOCGARP 0x8954
+#define SIOCSARP 0x8955
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCDRARP 0x8960  
-#define SIOCGRARP 0x8961  
-#define SIOCSRARP 0x8962  
-#define SIOCGIFMAP 0x8970  
+#define SIOCDRARP 0x8960
+#define SIOCGRARP 0x8961
+#define SIOCSRARP 0x8962
+#define SIOCGIFMAP 0x8970
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCSIFMAP 0x8971  
-#define SIOCADDDLCI 0x8980  
-#define SIOCDELDLCI 0x8981  
-#define SIOCGIFVLAN 0x8982  
+#define SIOCSIFMAP 0x8971
+#define SIOCADDDLCI 0x8980
+#define SIOCDELDLCI 0x8981
+#define SIOCGIFVLAN 0x8982
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCSIFVLAN 0x8983  
-#define SIOCBONDENSLAVE 0x8990  
-#define SIOCBONDRELEASE 0x8991  
-#define SIOCBONDSETHWADDR 0x8992  
+#define SIOCSIFVLAN 0x8983
+#define SIOCBONDENSLAVE 0x8990
+#define SIOCBONDRELEASE 0x8991
+#define SIOCBONDSETHWADDR 0x8992
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCBONDSLAVEINFOQUERY 0x8993  
-#define SIOCBONDINFOQUERY 0x8994  
-#define SIOCBONDCHANGEACTIVE 0x8995  
-#define SIOCBRADDBR 0x89a0  
+#define SIOCBONDSLAVEINFOQUERY 0x8993
+#define SIOCBONDINFOQUERY 0x8994
+#define SIOCBONDCHANGEACTIVE 0x8995
+#define SIOCBRADDBR 0x89a0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCBRDELBR 0x89a1  
-#define SIOCBRADDIF 0x89a2  
-#define SIOCBRDELIF 0x89a3  
-#define SIOCDEVPRIVATE 0x89F0  
+#define SIOCBRDELBR 0x89a1
+#define SIOCBRADDIF 0x89a2
+#define SIOCBRDELIF 0x89a3
+#define SIOCDEVPRIVATE 0x89F0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCPROTOPRIVATE 0x89E0  
+#define SIOCPROTOPRIVATE 0x89E0
 #endif
diff --git a/libc/kernel/common/linux/soundcard.h b/libc/kernel/common/linux/soundcard.h
index 9093646..7159f62 100644
--- a/libc/kernel/common/linux/soundcard.h
+++ b/libc/kernel/common/linux/soundcard.h
@@ -77,18 +77,18 @@
 #define _SIOWR _IOWR
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #else
-#define SIOCPARM_MASK 0x1fff  
-#define SIOC_VOID 0x00000000  
-#define SIOC_OUT 0x20000000  
+#define SIOCPARM_MASK 0x1fff
+#define SIOC_VOID 0x00000000
+#define SIOC_OUT 0x20000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOC_IN 0x40000000  
+#define SIOC_IN 0x40000000
 #define SIOC_INOUT (SIOC_IN|SIOC_OUT)
 #define _SIO(x,y) ((int)(SIOC_VOID|(x<<8)|y))
 #define _SIOR(x,y,t) ((int)(SIOC_OUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define _SIOW(x,y,t) ((int)(SIOC_IN|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))
 #define _SIOWR(x,y,t) ((int)(SIOC_INOUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))
-#define _SIOC_SIZE(x) ((x>>16)&SIOCPARM_MASK) 
+#define _SIOC_SIZE(x) ((x>>16)&SIOCPARM_MASK)
 #define _SIOC_DIR(x) (x & 0xf0000000)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define _SIOC_NONE SIOC_VOID
@@ -101,12 +101,12 @@
 #define SNDCTL_SEQ_SYNC _SIO ('Q', 1)
 #define SNDCTL_SYNTH_INFO _SIOWR('Q', 2, struct synth_info)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDCTL_SEQ_CTRLRATE _SIOWR('Q', 3, int)  
+#define SNDCTL_SEQ_CTRLRATE _SIOWR('Q', 3, int)
 #define SNDCTL_SEQ_GETOUTCOUNT _SIOR ('Q', 4, int)
 #define SNDCTL_SEQ_GETINCOUNT _SIOR ('Q', 5, int)
 #define SNDCTL_SEQ_PERCMODE _SIOW ('Q', 6, int)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDCTL_FM_LOAD_INSTR _SIOW ('Q', 7, struct sbi_instrument)  
+#define SNDCTL_FM_LOAD_INSTR _SIOW ('Q', 7, struct sbi_instrument)
 #define SNDCTL_SEQ_TESTMIDI _SIOW ('Q', 8, int)
 #define SNDCTL_SEQ_RESETSAMPLES _SIOW ('Q', 9, int)
 #define SNDCTL_SEQ_NRSYNTHS _SIOR ('Q',10, int)
@@ -114,9 +114,9 @@
 #define SNDCTL_SEQ_NRMIDIS _SIOR ('Q',11, int)
 #define SNDCTL_MIDI_INFO _SIOWR('Q',12, struct midi_info)
 #define SNDCTL_SEQ_THRESHOLD _SIOW ('Q',13, int)
-#define SNDCTL_SYNTH_MEMAVL _SIOWR('Q',14, int)  
+#define SNDCTL_SYNTH_MEMAVL _SIOWR('Q',14, int)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDCTL_FM_4OP_ENABLE _SIOW ('Q',15, int)  
+#define SNDCTL_FM_4OP_ENABLE _SIOW ('Q',15, int)
 #define SNDCTL_SEQ_PANIC _SIO ('Q',17)
 #define SNDCTL_SEQ_OUTOFBAND _SIOW ('Q',18, struct seq_event_rec)
 #define SNDCTL_SEQ_GETTIME _SIOR ('Q',19, int)
@@ -184,24 +184,24 @@
  short device_no;
  short instr_no;
  unsigned int mode;
-#define WAVE_16_BITS 0x01  
+#define WAVE_16_BITS 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WAVE_UNSIGNED 0x02  
-#define WAVE_LOOPING 0x04  
-#define WAVE_BIDIR_LOOP 0x08  
-#define WAVE_LOOP_BACK 0x10  
+#define WAVE_UNSIGNED 0x02
+#define WAVE_LOOPING 0x04
+#define WAVE_BIDIR_LOOP 0x08
+#define WAVE_LOOP_BACK 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WAVE_SUSTAIN_ON 0x20  
-#define WAVE_ENVELOPES 0x40  
-#define WAVE_FAST_RELEASE 0x80  
-#define WAVE_VIBRATO 0x00010000  
+#define WAVE_SUSTAIN_ON 0x20
+#define WAVE_ENVELOPES 0x40
+#define WAVE_FAST_RELEASE 0x80
+#define WAVE_VIBRATO 0x00010000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WAVE_TREMOLO 0x00020000  
-#define WAVE_SCALE 0x00040000  
-#define WAVE_FRACTIONS 0x00080000  
-#define WAVE_ROM 0x40000000  
+#define WAVE_TREMOLO 0x00020000
+#define WAVE_SCALE 0x00040000
+#define WAVE_FRACTIONS 0x00080000
+#define WAVE_ROM 0x40000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WAVE_MULAW 0x20000000  
+#define WAVE_MULAW 0x20000000
  int len;
  int loop_start, loop_end;
  unsigned int base_freq;
@@ -243,7 +243,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  };
 #define SEQ_NOTEOFF 0
-#define SEQ_FMNOTEOFF SEQ_NOTEOFF  
+#define SEQ_FMNOTEOFF SEQ_NOTEOFF
 #define SEQ_NOTEON 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SEQ_FMNOTEON SEQ_NOTEON
@@ -253,10 +253,10 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SEQ_SYNCTIMER TMR_START
 #define SEQ_MIDIPUTC 5
-#define SEQ_DRUMON 6  
-#define SEQ_DRUMOFF 7  
+#define SEQ_DRUMON 6
+#define SEQ_DRUMOFF 7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SEQ_ECHO TMR_ECHO  
+#define SEQ_ECHO TMR_ECHO
 #define SEQ_AFTERTOUCH 9
 #define SEQ_CONTROLLER 10
 #define CTL_BANK_SELECT 0x00
@@ -278,8 +278,8 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CTL_GENERAL_PURPOSE4 0x13
 #define CTL_DAMPER_PEDAL 0x40
-#define CTL_SUSTAIN 0x40  
-#define CTL_HOLD 0x40  
+#define CTL_SUSTAIN 0x40
+#define CTL_HOLD 0x40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CTL_PORTAMENTO 0x41
 #define CTL_SOSTENUTO 0x42
@@ -296,7 +296,7 @@
 #define CTL_CHORUS_DEPTH 0x5d
 #define CTL_DETUNE_DEPTH 0x5e
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CTL_CELESTE_DEPTH 0x5e  
+#define CTL_CELESTE_DEPTH 0x5e
 #define CTL_PHASER_DEPTH 0x5f
 #define CTL_DATA_INCREMENT 0x60
 #define CTL_DATA_DECREMENT 0x61
@@ -308,17 +308,17 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CTRL_PITCH_BENDER 255
 #define CTRL_PITCH_BENDER_RANGE 254
-#define CTRL_EXPRESSION 253  
-#define CTRL_MAIN_VOLUME 252  
+#define CTRL_EXPRESSION 253
+#define CTRL_MAIN_VOLUME 252
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SEQ_BALANCE 11
 #define SEQ_VOLMODE 12
 #define VOL_METHOD_ADAGIO 1
 #define VOL_METHOD_LINEAR 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SEQ_FULLSIZE 0xfd  
-#define SEQ_PRIVATE 0xfe  
-#define SEQ_EXTENDED 0xff  
+#define SEQ_FULLSIZE 0xfd
+#define SEQ_PRIVATE 0xfe
+#define SEQ_EXTENDED 0xff
 typedef unsigned char sbi_instr_data[32];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct sbi_instrument {
@@ -338,7 +338,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SYNTH_TYPE_FM 0
 #define SYNTH_TYPE_SAMPLE 1
-#define SYNTH_TYPE_MIDI 2  
+#define SYNTH_TYPE_MIDI 2
  int synth_subtype;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FM_TYPE_ADLIB 0x00
@@ -354,10 +354,10 @@
  int nr_drums;
  int instr_bank_size;
  unsigned int capabilities;
-#define SYNTH_CAP_PERCMODE 0x00000001  
+#define SYNTH_CAP_PERCMODE 0x00000001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SYNTH_CAP_OPL3 0x00000002  
-#define SYNTH_CAP_INPUT 0x00000004  
+#define SYNTH_CAP_OPL3 0x00000002
+#define SYNTH_CAP_INPUT 0x00000004
  int dummies[19];
  };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -366,7 +366,7 @@
  int caps;
  };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MIDI_CAP_MPU401 1  
+#define MIDI_CAP_MPU401 1
 struct midi_info {
  char name[30];
  int device;
@@ -401,23 +401,23 @@
 #define SNDCTL_DSP_SUBDIVIDE _SIOWR('P', 9, int)
 #define SNDCTL_DSP_SETFRAGMENT _SIOWR('P',10, int)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDCTL_DSP_GETFMTS _SIOR ('P',11, int)  
-#define SNDCTL_DSP_SETFMT _SIOWR('P',5, int)  
-#define AFMT_QUERY 0x00000000  
+#define SNDCTL_DSP_GETFMTS _SIOR ('P',11, int)
+#define SNDCTL_DSP_SETFMT _SIOWR('P',5, int)
+#define AFMT_QUERY 0x00000000
 #define AFMT_MU_LAW 0x00000001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AFMT_A_LAW 0x00000002
 #define AFMT_IMA_ADPCM 0x00000004
 #define AFMT_U8 0x00000008
-#define AFMT_S16_LE 0x00000010  
+#define AFMT_S16_LE 0x00000010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define AFMT_S16_BE 0x00000020  
+#define AFMT_S16_BE 0x00000020
 #define AFMT_S8 0x00000040
-#define AFMT_U16_LE 0x00000080  
-#define AFMT_U16_BE 0x00000100  
+#define AFMT_U16_LE 0x00000080
+#define AFMT_U16_BE 0x00000100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define AFMT_MPEG 0x00000200  
-#define AFMT_AC3 0x00000400  
+#define AFMT_MPEG 0x00000200
+#define AFMT_AC3 0x00000400
 typedef struct audio_buf_info {
  int fragments;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -431,17 +431,17 @@
 #define SNDCTL_DSP_NONBLOCK _SIO ('P',14)
 #define SNDCTL_DSP_GETCAPS _SIOR ('P',15, int)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DSP_CAP_REVISION 0x000000ff  
-#define DSP_CAP_DUPLEX 0x00000100  
-#define DSP_CAP_REALTIME 0x00000200  
-#define DSP_CAP_BATCH 0x00000400  
+#define DSP_CAP_REVISION 0x000000ff
+#define DSP_CAP_DUPLEX 0x00000100
+#define DSP_CAP_REALTIME 0x00000200
+#define DSP_CAP_BATCH 0x00000400
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DSP_CAP_COPROC 0x00000800  
-#define DSP_CAP_TRIGGER 0x00001000  
-#define DSP_CAP_MMAP 0x00002000  
-#define DSP_CAP_MULTI 0x00004000  
+#define DSP_CAP_COPROC 0x00000800
+#define DSP_CAP_TRIGGER 0x00001000
+#define DSP_CAP_MMAP 0x00002000
+#define DSP_CAP_MULTI 0x00004000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DSP_CAP_BIND 0x00008000  
+#define DSP_CAP_BIND 0x00008000
 #define SNDCTL_DSP_GETTRIGGER _SIOR ('P',16, int)
 #define SNDCTL_DSP_SETTRIGGER _SIOW ('P',16, int)
 #define PCM_ENABLE_INPUT 0x00000001
@@ -496,9 +496,9 @@
 #define SPDIF_V 0x8000
 #define SNDCTL_DSP_PROFILE _SIOW ('P', 23, int)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define APF_NORMAL 0  
-#define APF_NETWORK 1  
-#define APF_CPUINTENS 2  
+#define APF_NORMAL 0
+#define APF_NETWORK 1
+#define APF_CPUINTENS 2
 #define SOUND_PCM_READ_RATE _SIOR ('P', 2, int)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SOUND_PCM_READ_CHANNELS _SIOR ('P', 6, int)
@@ -534,9 +534,9 @@
  int command;
  int flags;
 #define CPF_NONE 0x0000
-#define CPF_FIRST 0x0001  
+#define CPF_FIRST 0x0001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CPF_LAST 0x0002  
+#define CPF_LAST 0x0002
  int len;
  int offs;
  unsigned char data[4000];
@@ -581,25 +581,25 @@
 #define SOUND_MIXER_MIC 7
 #define SOUND_MIXER_CD 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SOUND_MIXER_IMIX 9  
+#define SOUND_MIXER_IMIX 9
 #define SOUND_MIXER_ALTPCM 10
-#define SOUND_MIXER_RECLEV 11  
-#define SOUND_MIXER_IGAIN 12  
+#define SOUND_MIXER_RECLEV 11
+#define SOUND_MIXER_IGAIN 12
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SOUND_MIXER_OGAIN 13  
-#define SOUND_MIXER_LINE1 14  
-#define SOUND_MIXER_LINE2 15  
-#define SOUND_MIXER_LINE3 16  
+#define SOUND_MIXER_OGAIN 13
+#define SOUND_MIXER_LINE1 14
+#define SOUND_MIXER_LINE2 15
+#define SOUND_MIXER_LINE3 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SOUND_MIXER_DIGITAL1 17  
-#define SOUND_MIXER_DIGITAL2 18  
-#define SOUND_MIXER_DIGITAL3 19  
-#define SOUND_MIXER_PHONEIN 20  
+#define SOUND_MIXER_DIGITAL1 17
+#define SOUND_MIXER_DIGITAL2 18
+#define SOUND_MIXER_DIGITAL3 19
+#define SOUND_MIXER_PHONEIN 20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SOUND_MIXER_PHONEOUT 21  
-#define SOUND_MIXER_VIDEO 22  
-#define SOUND_MIXER_RADIO 23  
-#define SOUND_MIXER_MONITOR 24  
+#define SOUND_MIXER_PHONEOUT 21
+#define SOUND_MIXER_VIDEO 22
+#define SOUND_MIXER_RADIO 23
+#define SOUND_MIXER_MONITOR 24
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SOUND_ONOFF_MIN 28
 #define SOUND_ONOFF_MAX 30
@@ -611,15 +611,15 @@
 #define SOUND_DEVICE_LABELS {"Vol  ", "Bass ", "Trebl", "Synth", "Pcm  ", "Spkr ", "Line ",   "Mic  ", "CD   ", "Mix  ", "Pcm2 ", "Rec  ", "IGain", "OGain",   "Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3",   "PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"}
 #define SOUND_DEVICE_NAMES {"vol", "bass", "treble", "synth", "pcm", "speaker", "line",   "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain",   "line1", "line2", "line3", "dig1", "dig2", "dig3",   "phin", "phout", "video", "radio", "monitor"}
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SOUND_MIXER_RECSRC 0xff  
-#define SOUND_MIXER_DEVMASK 0xfe  
-#define SOUND_MIXER_RECMASK 0xfd  
+#define SOUND_MIXER_RECSRC 0xff
+#define SOUND_MIXER_DEVMASK 0xfe
+#define SOUND_MIXER_RECMASK 0xfd
 #define SOUND_MIXER_CAPS 0xfc
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SOUND_CAP_EXCL_INPUT 0x00000001  
-#define SOUND_MIXER_STEREODEVS 0xfb  
-#define SOUND_MIXER_OUTSRC 0xfa  
-#define SOUND_MIXER_OUTMASK 0xf9  
+#define SOUND_CAP_EXCL_INPUT 0x00000001
+#define SOUND_MIXER_STEREODEVS 0xfb
+#define SOUND_MIXER_OUTSRC 0xfa
+#define SOUND_MIXER_OUTMASK 0xf9
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME)
 #define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS)
@@ -771,18 +771,18 @@
 #define MIDI_PITCH_BEND 0xE0
 #define MIDI_SYSTEM_PREFIX 0xF0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TMR_WAIT_REL 1  
-#define TMR_WAIT_ABS 2  
+#define TMR_WAIT_REL 1
+#define TMR_WAIT_ABS 2
 #define TMR_STOP 3
 #define TMR_START 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TMR_CONTINUE 5
 #define TMR_TEMPO 6
 #define TMR_ECHO 8
-#define TMR_CLOCK 9  
+#define TMR_CLOCK 9
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TMR_SPP 10  
-#define TMR_TIMESIG 11  
+#define TMR_SPP 10
+#define TMR_TIMESIG 11
 #define LOCL_STARTAUDIO 1
 #if !defined(__KERNEL__) && !defined(KERNEL) && !defined(INKERNEL) && !defined(_KERNEL) || defined(USE_SEQ_MACROS)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -811,7 +811,7 @@
 #define SEQ_DUMPBUF seqbuf_dump
 #else
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define _SEQ_NEEDBUF(len)  
+#define _SEQ_NEEDBUF(len)
 #endif
 #endif
 #define SEQ_VOLUME_MODE(dev, mode) {_SEQ_NEEDBUF(8);  _seqbuf[_seqbufptr] = SEQ_EXTENDED;  _seqbuf[_seqbufptr+1] = SEQ_VOLMODE;  _seqbuf[_seqbufptr+2] = (dev);  _seqbuf[_seqbufptr+3] = (mode);  _seqbuf[_seqbufptr+4] = 0;  _seqbuf[_seqbufptr+5] = 0;  _seqbuf[_seqbufptr+6] = 0;  _seqbuf[_seqbufptr+7] = 0;  _SEQ_ADVBUF(8);}
diff --git a/libc/kernel/common/linux/spi/cpcap.h b/libc/kernel/common/linux/spi/cpcap.h
index 8b729b0..9d387e9 100644
--- a/libc/kernel/common/linux/spi/cpcap.h
+++ b/libc/kernel/common/linux/spi/cpcap.h
@@ -28,7 +28,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CPCAP_IRQ_INT4_INDEX 48
 #define CPCAP_IRQ_INT5_INDEX 64
-#define CPCAP_HWCFG_NUM 2  
+#define CPCAP_HWCFG_NUM 2
 #define CPCAP_HWCFG0_SEC_STBY_SW1 0x0001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CPCAP_HWCFG0_SEC_STBY_SW2 0x0002
diff --git a/libc/kernel/common/linux/sunrpc/debug.h b/libc/kernel/common/linux/sunrpc/debug.h
index 4c46190..e7458ea 100644
--- a/libc/kernel/common/linux/sunrpc/debug.h
+++ b/libc/kernel/common/linux/sunrpc/debug.h
@@ -34,7 +34,7 @@
 #define RPCDBG_MISC 0x0400
 #define RPCDBG_CACHE 0x0800
 #define RPCDBG_ALL 0x7fff
-#define CTL_SUNRPC 7249  
+#define CTL_SUNRPC 7249
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
  CTL_RPCDEBUG = 1,
diff --git a/libc/kernel/common/linux/sunrpc/sched.h b/libc/kernel/common/linux/sunrpc/sched.h
index 4ca0c56..de29030 100644
--- a/libc/kernel/common/linux/sunrpc/sched.h
+++ b/libc/kernel/common/linux/sunrpc/sched.h
@@ -102,17 +102,17 @@
  void (*rpc_release)(void *);
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define RPC_TASK_ASYNC 0x0001  
-#define RPC_TASK_SWAPPER 0x0002  
-#define RPC_TASK_CHILD 0x0008  
+#define RPC_TASK_ASYNC 0x0001
+#define RPC_TASK_SWAPPER 0x0002
+#define RPC_TASK_CHILD 0x0008
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RPC_CALL_MAJORSEEN 0x0020  
-#define RPC_TASK_ROOTCREDS 0x0040  
-#define RPC_TASK_DYNAMIC 0x0080  
-#define RPC_TASK_KILLED 0x0100  
+#define RPC_CALL_MAJORSEEN 0x0020
+#define RPC_TASK_ROOTCREDS 0x0040
+#define RPC_TASK_DYNAMIC 0x0080
+#define RPC_TASK_KILLED 0x0100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RPC_TASK_SOFT 0x0200  
-#define RPC_TASK_NOINTR 0x0400  
+#define RPC_TASK_SOFT 0x0200
+#define RPC_TASK_NOINTR 0x0400
 #define RPC_IS_ASYNC(t) ((t)->tk_flags & RPC_TASK_ASYNC)
 #define RPC_IS_CHILD(t) ((t)->tk_flags & RPC_TASK_CHILD)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/swap.h b/libc/kernel/common/linux/swap.h
index 0f8e546..3fb15cc 100644
--- a/libc/kernel/common/linux/swap.h
+++ b/libc/kernel/common/linux/swap.h
@@ -27,7 +27,7 @@
 #include <asm/atomic.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <asm/page.h>
-#define SWAP_FLAG_PREFER 0x8000  
+#define SWAP_FLAG_PREFER 0x8000
 #define SWAP_FLAG_PRIO_MASK 0x7fff
 #define SWAP_FLAG_PRIO_SHIFT 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/sysctl.h b/libc/kernel/common/linux/sysctl.h
index 46e5e67..4e92f5c 100644
--- a/libc/kernel/common/linux/sysctl.h
+++ b/libc/kernel/common/linux/sysctl.h
@@ -24,7 +24,7 @@
 #include <linux/compiler.h>
 struct file;
 struct completion;
-#define CTL_MAXNAME 10  
+#define CTL_MAXNAME 10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct __sysctl_args {
  int __user *name;
@@ -34,7 +34,7 @@
  size_t __user *oldlenp;
  void __user *newval;
  size_t newlen;
- unsigned long __unused[4];
+ unsigned long __linux_unused[4];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum
diff --git a/libc/kernel/common/linux/tcp.h b/libc/kernel/common/linux/tcp.h
index b51824a..3e9d641 100644
--- a/libc/kernel/common/linux/tcp.h
+++ b/libc/kernel/common/linux/tcp.h
@@ -68,7 +68,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __u32 words[5];
 };
-#define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3]) 
+#define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3])
 enum {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  TCP_FLAG_CWR = __constant_htonl(0x00800000),
@@ -84,22 +84,22 @@
  TCP_RESERVED_BITS = __constant_htonl(0x0F000000),
  TCP_DATA_OFFSET = __constant_htonl(0xF0000000)
 };
-#define TCP_NODELAY 1  
+#define TCP_NODELAY 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TCP_MAXSEG 2  
-#define TCP_CORK 3  
-#define TCP_KEEPIDLE 4  
-#define TCP_KEEPINTVL 5  
+#define TCP_MAXSEG 2
+#define TCP_CORK 3
+#define TCP_KEEPIDLE 4
+#define TCP_KEEPINTVL 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TCP_KEEPCNT 6  
-#define TCP_SYNCNT 7  
-#define TCP_LINGER2 8  
-#define TCP_DEFER_ACCEPT 9  
+#define TCP_KEEPCNT 6
+#define TCP_SYNCNT 7
+#define TCP_LINGER2 8
+#define TCP_DEFER_ACCEPT 9
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TCP_WINDOW_CLAMP 10  
-#define TCP_INFO 11  
-#define TCP_QUICKACK 12  
-#define TCP_CONGESTION 13  
+#define TCP_WINDOW_CLAMP 10
+#define TCP_INFO 11
+#define TCP_QUICKACK 12
+#define TCP_CONGESTION 13
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCPI_OPT_TIMESTAMPS 1
 #define TCPI_OPT_SACK 2
diff --git a/libc/kernel/common/linux/tegra_avp.h b/libc/kernel/common/linux/tegra_avp.h
index f3f39b9..dba7f6b 100644
--- a/libc/kernel/common/linux/tegra_avp.h
+++ b/libc/kernel/common/linux/tegra_avp.h
@@ -22,7 +22,7 @@
 #include <linux/types.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TEGRA_AVP_LIB_MAX_NAME 32
-#define TEGRA_AVP_LIB_MAX_ARGS 220  
+#define TEGRA_AVP_LIB_MAX_ARGS 220
 struct tegra_avp_lib {
  char name[TEGRA_AVP_LIB_MAX_NAME];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/timex.h b/libc/kernel/common/linux/timex.h
index a404591..921231f 100644
--- a/libc/kernel/common/linux/timex.h
+++ b/libc/kernel/common/linux/timex.h
@@ -22,22 +22,22 @@
 #include <linux/time.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <asm/param.h>
-#define SHIFT_KG 6  
-#define SHIFT_KF 16  
-#define SHIFT_KH 2  
+#define SHIFT_KG 6
+#define SHIFT_KF 16
+#define SHIFT_KH 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MAXTC 6  
-#define SHIFT_SCALE 22  
-#define SHIFT_UPDATE (SHIFT_KG + MAXTC)  
-#define SHIFT_USEC 16  
+#define MAXTC 6
+#define SHIFT_SCALE 22
+#define SHIFT_UPDATE (SHIFT_KG + MAXTC)
+#define SHIFT_USEC 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FINENSEC (1L << (SHIFT_SCALE - 10))  
-#define MAXPHASE 512000L  
-#define MAXFREQ (512L << SHIFT_USEC)  
-#define MINSEC 16L  
+#define FINENSEC (1L << (SHIFT_SCALE - 10))
+#define MAXPHASE 512000L
+#define MAXFREQ (512L << SHIFT_USEC)
+#define MINSEC 16L
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MAXSEC 1200L  
-#define NTP_PHASE_LIMIT (MAXPHASE << 5)  
+#define MAXSEC 1200L
+#define NTP_PHASE_LIMIT (MAXPHASE << 5)
 struct timex {
  unsigned int modes;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -68,16 +68,16 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  int :32; int :32; int :32; int :32;
 };
-#define ADJ_OFFSET 0x0001  
-#define ADJ_FREQUENCY 0x0002  
+#define ADJ_OFFSET 0x0001
+#define ADJ_FREQUENCY 0x0002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ADJ_MAXERROR 0x0004  
-#define ADJ_ESTERROR 0x0008  
-#define ADJ_STATUS 0x0010  
-#define ADJ_TIMECONST 0x0020  
+#define ADJ_MAXERROR 0x0004
+#define ADJ_ESTERROR 0x0008
+#define ADJ_STATUS 0x0010
+#define ADJ_TIMECONST 0x0020
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ADJ_TICK 0x4000  
-#define ADJ_OFFSET_SINGLESHOT 0x8001  
+#define ADJ_TICK 0x4000
+#define ADJ_OFFSET_SINGLESHOT 0x8001
 #define MOD_OFFSET ADJ_OFFSET
 #define MOD_FREQUENCY ADJ_FREQUENCY
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -87,32 +87,32 @@
 #define MOD_TIMECONST ADJ_TIMECONST
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MOD_CLKB ADJ_TICK
-#define MOD_CLKA ADJ_OFFSET_SINGLESHOT  
-#define STA_PLL 0x0001  
-#define STA_PPSFREQ 0x0002  
+#define MOD_CLKA ADJ_OFFSET_SINGLESHOT
+#define STA_PLL 0x0001
+#define STA_PPSFREQ 0x0002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define STA_PPSTIME 0x0004  
-#define STA_FLL 0x0008  
-#define STA_INS 0x0010  
-#define STA_DEL 0x0020  
+#define STA_PPSTIME 0x0004
+#define STA_FLL 0x0008
+#define STA_INS 0x0010
+#define STA_DEL 0x0020
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define STA_UNSYNC 0x0040  
-#define STA_FREQHOLD 0x0080  
-#define STA_PPSSIGNAL 0x0100  
-#define STA_PPSJITTER 0x0200  
+#define STA_UNSYNC 0x0040
+#define STA_FREQHOLD 0x0080
+#define STA_PPSSIGNAL 0x0100
+#define STA_PPSJITTER 0x0200
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define STA_PPSWANDER 0x0400  
-#define STA_PPSERROR 0x0800  
-#define STA_CLOCKERR 0x1000  
-#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER |   STA_PPSERROR | STA_CLOCKERR)  
+#define STA_PPSWANDER 0x0400
+#define STA_PPSERROR 0x0800
+#define STA_CLOCKERR 0x1000
+#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER |   STA_PPSERROR | STA_CLOCKERR)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIME_OK 0  
-#define TIME_INS 1  
-#define TIME_DEL 2  
-#define TIME_OOP 3  
+#define TIME_OK 0
+#define TIME_INS 1
+#define TIME_DEL 2
+#define TIME_OOP 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIME_WAIT 4  
-#define TIME_ERROR 5  
-#define TIME_BAD TIME_ERROR  
+#define TIME_WAIT 4
+#define TIME_ERROR 5
+#define TIME_BAD TIME_ERROR
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/tiocl.h b/libc/kernel/common/linux/tiocl.h
index 2caa18c..f3818fc 100644
--- a/libc/kernel/common/linux/tiocl.h
+++ b/libc/kernel/common/linux/tiocl.h
@@ -18,16 +18,16 @@
  ****************************************************************************/
 #ifndef _LINUX_TIOCL_H
 #define _LINUX_TIOCL_H
-#define TIOCL_SETSEL 2  
-#define TIOCL_SELCHAR 0  
+#define TIOCL_SETSEL 2
+#define TIOCL_SELCHAR 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCL_SELWORD 1  
-#define TIOCL_SELLINE 2  
-#define TIOCL_SELPOINTER 3  
-#define TIOCL_SELCLEAR 4  
+#define TIOCL_SELWORD 1
+#define TIOCL_SELLINE 2
+#define TIOCL_SELPOINTER 3
+#define TIOCL_SELCLEAR 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCL_SELMOUSEREPORT 16  
-#define TIOCL_SELBUTTONMASK 15  
+#define TIOCL_SELMOUSEREPORT 16
+#define TIOCL_SELBUTTONMASK 15
 struct tiocl_selection {
  unsigned short xs;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -37,19 +37,19 @@
  unsigned short sel_mode;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define TIOCL_PASTESEL 3  
-#define TIOCL_UNBLANKSCREEN 4  
+#define TIOCL_PASTESEL 3
+#define TIOCL_UNBLANKSCREEN 4
 #define TIOCL_SELLOADLUT 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCL_GETSHIFTSTATE 6  
-#define TIOCL_GETMOUSEREPORTING 7  
-#define TIOCL_SETVESABLANK 10  
-#define TIOCL_SETKMSGREDIRECT 11  
+#define TIOCL_GETSHIFTSTATE 6
+#define TIOCL_GETMOUSEREPORTING 7
+#define TIOCL_SETVESABLANK 10
+#define TIOCL_SETKMSGREDIRECT 11
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCL_GETFGCONSOLE 12  
-#define TIOCL_SCROLLCONSOLE 13  
-#define TIOCL_BLANKSCREEN 14  
-#define TIOCL_BLANKEDSCREEN 15  
+#define TIOCL_GETFGCONSOLE 12
+#define TIOCL_SCROLLCONSOLE 13
+#define TIOCL_BLANKSCREEN 14
+#define TIOCL_BLANKEDSCREEN 15
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define TIOCL_GETKMSGREDIRECT 17  
+#define TIOCL_GETKMSGREDIRECT 17
 #endif
diff --git a/libc/kernel/common/linux/tty.h b/libc/kernel/common/linux/tty.h
index c850203..5f5cdcb 100644
--- a/libc/kernel/common/linux/tty.h
+++ b/libc/kernel/common/linux/tty.h
@@ -18,6 +18,6 @@
  ****************************************************************************/
 #ifndef _LINUX_TTY_H
 #define _LINUX_TTY_H
-#define N_CAIF 20  
+#define N_CAIF 20
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/udp.h b/libc/kernel/common/linux/udp.h
index 53a78c4..10d6658 100644
--- a/libc/kernel/common/linux/udp.h
+++ b/libc/kernel/common/linux/udp.h
@@ -27,9 +27,9 @@
  __u16 check;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define UDP_CORK 1  
-#define UDP_ENCAP 100  
-#define UDP_ENCAP_ESPINUDP_NON_IKE 1  
+#define UDP_CORK 1
+#define UDP_ENCAP 100
+#define UDP_ENCAP_ESPINUDP_NON_IKE 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UDP_ENCAP_ESPINUDP 2  
+#define UDP_ENCAP_ESPINUDP 2
 #endif
diff --git a/libc/kernel/common/linux/usb/ch9.h b/libc/kernel/common/linux/usb/ch9.h
index 126f16d..cdfad9d 100644
--- a/libc/kernel/common/linux/usb/ch9.h
+++ b/libc/kernel/common/linux/usb/ch9.h
@@ -18,11 +18,11 @@
  ****************************************************************************/
 #ifndef __LINUX_USB_CH9_H
 #define __LINUX_USB_CH9_H
-#include <linux/types.h>  
-#include <asm/byteorder.h>  
+#include <linux/types.h>
+#include <asm/byteorder.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_DIR_OUT 0  
-#define USB_DIR_IN 0x80  
+#define USB_DIR_OUT 0
+#define USB_DIR_IN 0x80
 #define USB_TYPE_MASK (0x03 << 5)
 #define USB_TYPE_STANDARD (0x00 << 5)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -53,7 +53,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_REQ_SYNCH_FRAME 0x0C
 #define USB_REQ_SET_SEL 0x30
-#define USB_REQ_SET_ENCRYPTION 0x0D  
+#define USB_REQ_SET_ENCRYPTION 0x0D
 #define USB_REQ_GET_ENCRYPTION 0x0E
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_REQ_RPIPE_ABORT 0x0E
@@ -69,17 +69,17 @@
 #define USB_REQ_LOOPBACK_DATA_WRITE 0x15
 #define USB_REQ_LOOPBACK_DATA_READ 0x16
 #define USB_REQ_SET_INTERFACE_DS 0x17
-#define USB_DEVICE_SELF_POWERED 0  
+#define USB_DEVICE_SELF_POWERED 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_DEVICE_REMOTE_WAKEUP 1  
-#define USB_DEVICE_TEST_MODE 2  
-#define USB_DEVICE_BATTERY 2  
-#define USB_DEVICE_B_HNP_ENABLE 3  
+#define USB_DEVICE_REMOTE_WAKEUP 1
+#define USB_DEVICE_TEST_MODE 2
+#define USB_DEVICE_BATTERY 2
+#define USB_DEVICE_B_HNP_ENABLE 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_DEVICE_WUSB_DEVICE 3  
-#define USB_DEVICE_A_HNP_SUPPORT 4  
-#define USB_DEVICE_A_ALT_HNP_SUPPORT 5  
-#define USB_DEVICE_DEBUG_MODE 6  
+#define USB_DEVICE_WUSB_DEVICE 3
+#define USB_DEVICE_A_HNP_SUPPORT 4
+#define USB_DEVICE_A_ALT_HNP_SUPPORT 5
+#define USB_DEVICE_DEBUG_MODE 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TEST_J 1
 #define TEST_K 2
@@ -87,19 +87,19 @@
 #define TEST_PACKET 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TEST_FORCE_EN 5
-#define USB_DEVICE_U1_ENABLE 48  
-#define USB_DEVICE_U2_ENABLE 49  
-#define USB_DEVICE_LTM_ENABLE 50  
+#define USB_DEVICE_U1_ENABLE 48
+#define USB_DEVICE_U2_ENABLE 49
+#define USB_DEVICE_LTM_ENABLE 50
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_INTRF_FUNC_SUSPEND 0  
+#define USB_INTRF_FUNC_SUSPEND 0
 #define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00
 #define USB_INTRF_FUNC_SUSPEND_LP (1 << (8 + 0))
 #define USB_INTRF_FUNC_SUSPEND_RW (1 << (8 + 1))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_ENDPOINT_HALT 0  
-#define USB_DEV_STAT_U1_ENABLED 2  
-#define USB_DEV_STAT_U2_ENABLED 3  
-#define USB_DEV_STAT_LTM_ENABLED 4  
+#define USB_ENDPOINT_HALT 0
+#define USB_DEV_STAT_U1_ENABLED 2
+#define USB_DEV_STAT_U2_ENABLED 3
+#define USB_DEV_STAT_LTM_ENABLED 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct usb_ctrlrequest {
  __u8 bRequestType;
@@ -169,7 +169,7 @@
  __u8 bNumConfigurations;
 } __attribute__ ((packed));
 #define USB_DT_DEVICE_SIZE 18
-#define USB_CLASS_PER_INTERFACE 0  
+#define USB_CLASS_PER_INTERFACE 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_CLASS_AUDIO 1
 #define USB_CLASS_COMM 2
@@ -182,8 +182,8 @@
 #define USB_CLASS_HUB 9
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_CLASS_CDC_DATA 0x0a
-#define USB_CLASS_CSCID 0x0b  
-#define USB_CLASS_CONTENT_SEC 0x0d  
+#define USB_CLASS_CSCID 0x0b
+#define USB_CLASS_CONTENT_SEC 0x0d
 #define USB_CLASS_VIDEO 0x0e
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_CLASS_WIRELESS_CONTROLLER 0xe0
@@ -206,10 +206,10 @@
 } __attribute__ ((packed));
 #define USB_DT_CONFIG_SIZE 9
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_CONFIG_ATT_ONE (1 << 7)  
-#define USB_CONFIG_ATT_SELFPOWER (1 << 6)  
-#define USB_CONFIG_ATT_WAKEUP (1 << 5)  
-#define USB_CONFIG_ATT_BATTERY (1 << 4)  
+#define USB_CONFIG_ATT_ONE (1 << 7)
+#define USB_CONFIG_ATT_SELFPOWER (1 << 6)
+#define USB_CONFIG_ATT_WAKEUP (1 << 5)
+#define USB_CONFIG_ATT_BATTERY (1 << 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct usb_string_descriptor {
  __u8 bLength;
@@ -246,10 +246,10 @@
 } __attribute__ ((packed));
 #define USB_DT_ENDPOINT_SIZE 7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_DT_ENDPOINT_AUDIO_SIZE 9  
-#define USB_ENDPOINT_NUMBER_MASK 0x0f  
+#define USB_DT_ENDPOINT_AUDIO_SIZE 9
+#define USB_ENDPOINT_NUMBER_MASK 0x0f
 #define USB_ENDPOINT_DIR_MASK 0x80
-#define USB_ENDPOINT_XFERTYPE_MASK 0x03  
+#define USB_ENDPOINT_XFERTYPE_MASK 0x03
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_ENDPOINT_XFER_CONTROL 0
 #define USB_ENDPOINT_XFER_ISOC 1
@@ -267,7 +267,7 @@
 #define USB_ENDPOINT_USAGE_DATA 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_ENDPOINT_USAGE_FEEDBACK 0x10
-#define USB_ENDPOINT_USAGE_IMPLICIT_FB 0x20  
+#define USB_ENDPOINT_USAGE_IMPLICIT_FB 0x20
 struct usb_ss_ep_comp_descriptor {
  __u8 bLength;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -301,7 +301,7 @@
 } __attribute__ ((packed));
 #define USB_OTG_SRP (1 << 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_OTG_HNP (1 << 1)  
+#define USB_OTG_HNP (1 << 1)
 struct usb_debug_descriptor {
  __u8 bLength;
  __u8 bDescriptorType;
@@ -344,10 +344,10 @@
  __u8 bDescriptorType;
  __u8 bEncryptionType;
 #define USB_ENC_TYPE_UNSECURE 0
-#define USB_ENC_TYPE_WIRED 1  
+#define USB_ENC_TYPE_WIRED 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_ENC_TYPE_CCM_1 2  
-#define USB_ENC_TYPE_RSA_1 3  
+#define USB_ENC_TYPE_CCM_1 2
+#define USB_ENC_TYPE_RSA_1 3
  __u8 bEncryptionValue;
  __u8 bAuthKeyIndex;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -382,12 +382,12 @@
 #define USB_WIRELESS_BEACON_NONE (3 << 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __le16 wPHYRates;
-#define USB_WIRELESS_PHY_53 (1 << 0)  
+#define USB_WIRELESS_PHY_53 (1 << 0)
 #define USB_WIRELESS_PHY_80 (1 << 1)
-#define USB_WIRELESS_PHY_107 (1 << 2)  
+#define USB_WIRELESS_PHY_107 (1 << 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_WIRELESS_PHY_160 (1 << 3)
-#define USB_WIRELESS_PHY_200 (1 << 4)  
+#define USB_WIRELESS_PHY_200 (1 << 4)
 #define USB_WIRELESS_PHY_320 (1 << 5)
 #define USB_WIRELESS_PHY_400 (1 << 6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -406,7 +406,7 @@
  __u8 bDevCapabilityType;
  __le32 bmAttributes;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_LPM_SUPPORT (1 << 1)  
+#define USB_LPM_SUPPORT (1 << 1)
 } __attribute__((packed));
 #define USB_DT_USB_EXT_CAP_SIZE 7
 #define USB_SS_CAP_TYPE 3
@@ -417,13 +417,13 @@
  __u8 bDevCapabilityType;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __u8 bmAttributes;
-#define USB_LTM_SUPPORT (1 << 1)  
+#define USB_LTM_SUPPORT (1 << 1)
  __le16 wSpeedSupported;
-#define USB_LOW_SPEED_OPERATION (1)  
+#define USB_LOW_SPEED_OPERATION (1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_FULL_SPEED_OPERATION (1 << 1)  
-#define USB_HIGH_SPEED_OPERATION (1 << 2)  
-#define USB_5GBPS_OPERATION (1 << 3)  
+#define USB_FULL_SPEED_OPERATION (1 << 1)
+#define USB_HIGH_SPEED_OPERATION (1 << 2)
+#define USB_5GBPS_OPERATION (1 << 3)
  __u8 bFunctionalitySupport;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __u8 bU1devExitLat;
@@ -453,7 +453,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __u8 bOverTheAirInterval;
  __u8 bmCompAttributes;
-#define USB_ENDPOINT_SWITCH_MASK 0x03  
+#define USB_ENDPOINT_SWITCH_MASK 0x03
 #define USB_ENDPOINT_SWITCH_NO 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_ENDPOINT_SWITCH_SWITCH 1
diff --git a/libc/kernel/common/linux/usb_ch9.h b/libc/kernel/common/linux/usb_ch9.h
index b0265b5..dfdd0cc 100644
--- a/libc/kernel/common/linux/usb_ch9.h
+++ b/libc/kernel/common/linux/usb_ch9.h
@@ -18,10 +18,10 @@
  ****************************************************************************/
 #ifndef __LINUX_USB_CH9_H
 #define __LINUX_USB_CH9_H
-#include <linux/types.h>  
-#define USB_DIR_OUT 0  
+#include <linux/types.h>
+#define USB_DIR_OUT 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_DIR_IN 0x80  
+#define USB_DIR_IN 0x80
 #define USB_TYPE_MASK (0x03 << 5)
 #define USB_TYPE_STANDARD (0x00 << 5)
 #define USB_TYPE_CLASS (0x01 << 5)
@@ -51,7 +51,7 @@
 #define USB_REQ_SET_INTERFACE 0x0B
 #define USB_REQ_SYNCH_FRAME 0x0C
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_REQ_SET_ENCRYPTION 0x0D  
+#define USB_REQ_SET_ENCRYPTION 0x0D
 #define USB_REQ_GET_ENCRYPTION 0x0E
 #define USB_REQ_RPIPE_ABORT 0x0E
 #define USB_REQ_SET_HANDSHAKE 0x0F
@@ -67,18 +67,18 @@
 #define USB_REQ_LOOPBACK_DATA_READ 0x16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_REQ_SET_INTERFACE_DS 0x17
-#define USB_DEVICE_SELF_POWERED 0  
-#define USB_DEVICE_REMOTE_WAKEUP 1  
-#define USB_DEVICE_TEST_MODE 2  
+#define USB_DEVICE_SELF_POWERED 0
+#define USB_DEVICE_REMOTE_WAKEUP 1
+#define USB_DEVICE_TEST_MODE 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_DEVICE_BATTERY 2  
-#define USB_DEVICE_B_HNP_ENABLE 3  
-#define USB_DEVICE_WUSB_DEVICE 3  
-#define USB_DEVICE_A_HNP_SUPPORT 4  
+#define USB_DEVICE_BATTERY 2
+#define USB_DEVICE_B_HNP_ENABLE 3
+#define USB_DEVICE_WUSB_DEVICE 3
+#define USB_DEVICE_A_HNP_SUPPORT 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_DEVICE_A_ALT_HNP_SUPPORT 5  
-#define USB_DEVICE_DEBUG_MODE 6  
-#define USB_ENDPOINT_HALT 0  
+#define USB_DEVICE_A_ALT_HNP_SUPPORT 5
+#define USB_DEVICE_DEBUG_MODE 6
+#define USB_ENDPOINT_HALT 0
 struct usb_ctrlrequest {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __u8 bRequestType;
@@ -144,7 +144,7 @@
  __u8 bNumConfigurations;
 } __attribute__ ((packed));
 #define USB_DT_DEVICE_SIZE 18
-#define USB_CLASS_PER_INTERFACE 0  
+#define USB_CLASS_PER_INTERFACE 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_CLASS_AUDIO 1
 #define USB_CLASS_COMM 2
@@ -157,8 +157,8 @@
 #define USB_CLASS_HUB 9
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_CLASS_CDC_DATA 0x0a
-#define USB_CLASS_CSCID 0x0b  
-#define USB_CLASS_CONTENT_SEC 0x0d  
+#define USB_CLASS_CSCID 0x0b
+#define USB_CLASS_CONTENT_SEC 0x0d
 #define USB_CLASS_VIDEO 0x0e
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_CLASS_WIRELESS_CONTROLLER 0xe0
@@ -178,11 +178,11 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__ ((packed));
 #define USB_DT_CONFIG_SIZE 9
-#define USB_CONFIG_ATT_ONE (1 << 7)  
-#define USB_CONFIG_ATT_SELFPOWER (1 << 6)  
+#define USB_CONFIG_ATT_ONE (1 << 7)
+#define USB_CONFIG_ATT_SELFPOWER (1 << 6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_CONFIG_ATT_WAKEUP (1 << 5)  
-#define USB_CONFIG_ATT_BATTERY (1 << 4)  
+#define USB_CONFIG_ATT_WAKEUP (1 << 5)
+#define USB_CONFIG_ATT_BATTERY (1 << 4)
 struct usb_string_descriptor {
  __u8 bLength;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -218,11 +218,11 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__ ((packed));
 #define USB_DT_ENDPOINT_SIZE 7
-#define USB_DT_ENDPOINT_AUDIO_SIZE 9  
-#define USB_ENDPOINT_NUMBER_MASK 0x0f  
+#define USB_DT_ENDPOINT_AUDIO_SIZE 9
+#define USB_ENDPOINT_NUMBER_MASK 0x0f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_ENDPOINT_DIR_MASK 0x80
-#define USB_ENDPOINT_XFERTYPE_MASK 0x03  
+#define USB_ENDPOINT_XFERTYPE_MASK 0x03
 #define USB_ENDPOINT_XFER_CONTROL 0
 #define USB_ENDPOINT_XFER_ISOC 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -251,7 +251,7 @@
 } __attribute__ ((packed));
 #define USB_OTG_SRP (1 << 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_OTG_HNP (1 << 1)  
+#define USB_OTG_HNP (1 << 1)
 struct usb_debug_descriptor {
  __u8 bLength;
  __u8 bDescriptorType;
@@ -294,10 +294,10 @@
  __u8 bDescriptorType;
  __u8 bEncryptionType;
 #define USB_ENC_TYPE_UNSECURE 0
-#define USB_ENC_TYPE_WIRED 1  
+#define USB_ENC_TYPE_WIRED 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_ENC_TYPE_CCM_1 2  
-#define USB_ENC_TYPE_RSA_1 3  
+#define USB_ENC_TYPE_CCM_1 2
+#define USB_ENC_TYPE_RSA_1 3
  __u8 bEncryptionValue;
  __u8 bAuthKeyIndex;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -331,12 +331,12 @@
 #define USB_WIRELESS_BEACON_NONE (3 << 2)
  __le16 wPHYRates;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_WIRELESS_PHY_53 (1 << 0)  
+#define USB_WIRELESS_PHY_53 (1 << 0)
 #define USB_WIRELESS_PHY_80 (1 << 1)
-#define USB_WIRELESS_PHY_107 (1 << 2)  
+#define USB_WIRELESS_PHY_107 (1 << 2)
 #define USB_WIRELESS_PHY_160 (1 << 3)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_WIRELESS_PHY_200 (1 << 4)  
+#define USB_WIRELESS_PHY_200 (1 << 4)
 #define USB_WIRELESS_PHY_320 (1 << 5)
 #define USB_WIRELESS_PHY_400 (1 << 6)
 #define USB_WIRELESS_PHY_480 (1 << 7)
@@ -358,7 +358,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __u8 bOverTheAirInterval;
  __u8 bmCompAttributes;
-#define USB_ENDPOINT_SWITCH_MASK 0x03  
+#define USB_ENDPOINT_SWITCH_MASK 0x03
 #define USB_ENDPOINT_SWITCH_NO 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_ENDPOINT_SWITCH_SWITCH 1
diff --git a/libc/kernel/common/linux/v4l2-mediabus.h b/libc/kernel/common/linux/v4l2-mediabus.h
index 2c55ee1..0ea38bb 100644
--- a/libc/kernel/common/linux/v4l2-mediabus.h
+++ b/libc/kernel/common/linux/v4l2-mediabus.h
@@ -96,4 +96,3 @@
 };
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-
diff --git a/libc/kernel/common/linux/videodev.h b/libc/kernel/common/linux/videodev.h
index ee55483..5899cad 100644
--- a/libc/kernel/common/linux/videodev.h
+++ b/libc/kernel/common/linux/videodev.h
@@ -22,23 +22,23 @@
 #include <linux/ioctl.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <linux/videodev2.h>
-#define VID_TYPE_CAPTURE 1  
-#define VID_TYPE_TUNER 2  
-#define VID_TYPE_TELETEXT 4  
+#define VID_TYPE_CAPTURE 1
+#define VID_TYPE_TUNER 2
+#define VID_TYPE_TELETEXT 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VID_TYPE_OVERLAY 8  
-#define VID_TYPE_CHROMAKEY 16  
-#define VID_TYPE_CLIPPING 32  
-#define VID_TYPE_FRAMERAM 64  
+#define VID_TYPE_OVERLAY 8
+#define VID_TYPE_CHROMAKEY 16
+#define VID_TYPE_CLIPPING 32
+#define VID_TYPE_FRAMERAM 64
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VID_TYPE_SCALES 128  
-#define VID_TYPE_MONOCHROME 256  
-#define VID_TYPE_SUBCAPTURE 512  
-#define VID_TYPE_MPEG_DECODER 1024  
+#define VID_TYPE_SCALES 128
+#define VID_TYPE_MONOCHROME 256
+#define VID_TYPE_SUBCAPTURE 512
+#define VID_TYPE_MPEG_DECODER 1024
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VID_TYPE_MPEG_ENCODER 2048  
-#define VID_TYPE_MJPEG_DECODER 4096  
-#define VID_TYPE_MJPEG_ENCODER 8192  
+#define VID_TYPE_MPEG_ENCODER 2048
+#define VID_TYPE_MJPEG_DECODER 4096
+#define VID_TYPE_MJPEG_ENCODER 8192
 struct video_capability
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 {
@@ -61,8 +61,8 @@
  int tuners;
  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VIDEO_VC_TUNER 1  
-#define VIDEO_VC_AUDIO 2  
+#define VIDEO_VC_TUNER 1
+#define VIDEO_VC_AUDIO 2
  __u16 type;
 #define VIDEO_TYPE_TV 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -81,12 +81,12 @@
 #define VIDEO_TUNER_NTSC 2
 #define VIDEO_TUNER_SECAM 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VIDEO_TUNER_LOW 8  
-#define VIDEO_TUNER_NORM 16  
-#define VIDEO_TUNER_STEREO_ON 128  
-#define VIDEO_TUNER_RDS_ON 256  
+#define VIDEO_TUNER_LOW 8
+#define VIDEO_TUNER_NORM 16
+#define VIDEO_TUNER_STEREO_ON 128
+#define VIDEO_TUNER_RDS_ON 256
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VIDEO_TUNER_MBS_ON 512  
+#define VIDEO_TUNER_MBS_ON 512
  __u16 mode;
 #define VIDEO_MODE_PAL 0
 #define VIDEO_MODE_NTSC 1
@@ -107,28 +107,28 @@
  __u16 depth;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __u16 palette;
-#define VIDEO_PALETTE_GREY 1  
-#define VIDEO_PALETTE_HI240 2  
-#define VIDEO_PALETTE_RGB565 3  
+#define VIDEO_PALETTE_GREY 1
+#define VIDEO_PALETTE_HI240 2
+#define VIDEO_PALETTE_RGB565 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VIDEO_PALETTE_RGB24 4  
-#define VIDEO_PALETTE_RGB32 5  
-#define VIDEO_PALETTE_RGB555 6  
-#define VIDEO_PALETTE_YUV422 7  
+#define VIDEO_PALETTE_RGB24 4
+#define VIDEO_PALETTE_RGB32 5
+#define VIDEO_PALETTE_RGB555 6
+#define VIDEO_PALETTE_YUV422 7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_PALETTE_YUYV 8
-#define VIDEO_PALETTE_UYVY 9  
+#define VIDEO_PALETTE_UYVY 9
 #define VIDEO_PALETTE_YUV420 10
-#define VIDEO_PALETTE_YUV411 11  
+#define VIDEO_PALETTE_YUV411 11
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VIDEO_PALETTE_RAW 12  
-#define VIDEO_PALETTE_YUV422P 13  
-#define VIDEO_PALETTE_YUV411P 14  
-#define VIDEO_PALETTE_YUV420P 15  
+#define VIDEO_PALETTE_RAW 12
+#define VIDEO_PALETTE_YUV422P 13
+#define VIDEO_PALETTE_YUV411P 14
+#define VIDEO_PALETTE_YUV420P 15
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VIDEO_PALETTE_YUV410P 16  
-#define VIDEO_PALETTE_PLANAR 13  
-#define VIDEO_PALETTE_COMPONENT 7  
+#define VIDEO_PALETTE_YUV410P 16
+#define VIDEO_PALETTE_PLANAR 13
+#define VIDEO_PALETTE_COMPONENT 7
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct video_audio
@@ -176,7 +176,7 @@
  int clipcount;
 #define VIDEO_WINDOW_INTERLACE 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VIDEO_WINDOW_CHROMAKEY 16  
+#define VIDEO_WINDOW_CHROMAKEY 16
 #define VIDEO_CLIP_BITMAP -1
 #define VIDEO_CLIPMAP_SIZE (128 * 625)
 };
@@ -188,7 +188,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __u16 decimation;
  __u16 flags;
-#define VIDEO_CAPTURE_ODD 0  
+#define VIDEO_CAPTURE_ODD 0
 #define VIDEO_CAPTURE_EVEN 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
@@ -242,8 +242,8 @@
  __u32 count[2];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __u32 flags;
-#define VBI_UNSYNC 1  
-#define VBI_INTERLACED 2  
+#define VBI_UNSYNC 1
+#define VBI_INTERLACED 2
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct video_info
@@ -273,43 +273,43 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __u8 *data;
 };
-#define VIDIOCGCAP _IOR('v',1,struct video_capability)  
-#define VIDIOCGCHAN _IOWR('v',2,struct video_channel)  
+#define VIDIOCGCAP _IOR('v',1,struct video_capability)
+#define VIDIOCGCHAN _IOWR('v',2,struct video_channel)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VIDIOCSCHAN _IOW('v',3,struct video_channel)  
-#define VIDIOCGTUNER _IOWR('v',4,struct video_tuner)  
-#define VIDIOCSTUNER _IOW('v',5,struct video_tuner)  
-#define VIDIOCGPICT _IOR('v',6,struct video_picture)  
+#define VIDIOCSCHAN _IOW('v',3,struct video_channel)
+#define VIDIOCGTUNER _IOWR('v',4,struct video_tuner)
+#define VIDIOCSTUNER _IOW('v',5,struct video_tuner)
+#define VIDIOCGPICT _IOR('v',6,struct video_picture)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VIDIOCSPICT _IOW('v',7,struct video_picture)  
-#define VIDIOCCAPTURE _IOW('v',8,int)  
-#define VIDIOCGWIN _IOR('v',9, struct video_window)  
-#define VIDIOCSWIN _IOW('v',10, struct video_window)  
+#define VIDIOCSPICT _IOW('v',7,struct video_picture)
+#define VIDIOCCAPTURE _IOW('v',8,int)
+#define VIDIOCGWIN _IOR('v',9, struct video_window)
+#define VIDIOCSWIN _IOW('v',10, struct video_window)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VIDIOCGFBUF _IOR('v',11, struct video_buffer)  
-#define VIDIOCSFBUF _IOW('v',12, struct video_buffer)  
-#define VIDIOCKEY _IOR('v',13, struct video_key)  
-#define VIDIOCGFREQ _IOR('v',14, unsigned long)  
+#define VIDIOCGFBUF _IOR('v',11, struct video_buffer)
+#define VIDIOCSFBUF _IOW('v',12, struct video_buffer)
+#define VIDIOCKEY _IOR('v',13, struct video_key)
+#define VIDIOCGFREQ _IOR('v',14, unsigned long)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VIDIOCSFREQ _IOW('v',15, unsigned long)  
-#define VIDIOCGAUDIO _IOR('v',16, struct video_audio)  
-#define VIDIOCSAUDIO _IOW('v',17, struct video_audio)  
-#define VIDIOCSYNC _IOW('v',18, int)  
+#define VIDIOCSFREQ _IOW('v',15, unsigned long)
+#define VIDIOCGAUDIO _IOR('v',16, struct video_audio)
+#define VIDIOCSAUDIO _IOW('v',17, struct video_audio)
+#define VIDIOCSYNC _IOW('v',18, int)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VIDIOCMCAPTURE _IOW('v',19, struct video_mmap)  
-#define VIDIOCGMBUF _IOR('v',20, struct video_mbuf)  
-#define VIDIOCGUNIT _IOR('v',21, struct video_unit)  
-#define VIDIOCGCAPTURE _IOR('v',22, struct video_capture)  
+#define VIDIOCMCAPTURE _IOW('v',19, struct video_mmap)
+#define VIDIOCGMBUF _IOR('v',20, struct video_mbuf)
+#define VIDIOCGUNIT _IOR('v',21, struct video_unit)
+#define VIDIOCGCAPTURE _IOR('v',22, struct video_capture)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VIDIOCSCAPTURE _IOW('v',23, struct video_capture)  
-#define VIDIOCSPLAYMODE _IOW('v',24, struct video_play_mode)  
-#define VIDIOCSWRITEMODE _IOW('v',25, int)  
-#define VIDIOCGPLAYINFO _IOR('v',26, struct video_info)  
+#define VIDIOCSCAPTURE _IOW('v',23, struct video_capture)
+#define VIDIOCSPLAYMODE _IOW('v',24, struct video_play_mode)
+#define VIDIOCSWRITEMODE _IOW('v',25, int)
+#define VIDIOCGPLAYINFO _IOR('v',26, struct video_info)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VIDIOCSMICROCODE _IOW('v',27, struct video_code)  
-#define VIDIOCGVBIFMT _IOR('v',28, struct vbi_format)  
-#define VIDIOCSVBIFMT _IOW('v',29, struct vbi_format)  
-#define BASE_VIDIOCPRIVATE 192  
+#define VIDIOCSMICROCODE _IOW('v',27, struct video_code)
+#define VIDIOCGVBIFMT _IOR('v',28, struct vbi_format)
+#define VIDIOCSVBIFMT _IOW('v',29, struct vbi_format)
+#define BASE_VIDIOCPRIVATE 192
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VID_WRITE_MPEG_AUD 0
 #define VID_WRITE_MPEG_VID 1
diff --git a/libc/kernel/common/linux/videodev2.h b/libc/kernel/common/linux/videodev2.h
index 2e8517a..92d8f9e 100644
--- a/libc/kernel/common/linux/videodev2.h
+++ b/libc/kernel/common/linux/videodev2.h
@@ -26,23 +26,23 @@
 #define VIDEO_MAX_FRAME 32
 #define VIDEO_MAX_PLANES 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VID_TYPE_CAPTURE 1  
-#define VID_TYPE_TUNER 2  
-#define VID_TYPE_TELETEXT 4  
-#define VID_TYPE_OVERLAY 8  
+#define VID_TYPE_CAPTURE 1
+#define VID_TYPE_TUNER 2
+#define VID_TYPE_TELETEXT 4
+#define VID_TYPE_OVERLAY 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VID_TYPE_CHROMAKEY 16  
-#define VID_TYPE_CLIPPING 32  
-#define VID_TYPE_FRAMERAM 64  
-#define VID_TYPE_SCALES 128  
+#define VID_TYPE_CHROMAKEY 16
+#define VID_TYPE_CLIPPING 32
+#define VID_TYPE_FRAMERAM 64
+#define VID_TYPE_SCALES 128
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VID_TYPE_MONOCHROME 256  
-#define VID_TYPE_SUBCAPTURE 512  
-#define VID_TYPE_MPEG_DECODER 1024  
-#define VID_TYPE_MPEG_ENCODER 2048  
+#define VID_TYPE_MONOCHROME 256
+#define VID_TYPE_SUBCAPTURE 512
+#define VID_TYPE_MPEG_DECODER 1024
+#define VID_TYPE_MPEG_ENCODER 2048
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VID_TYPE_MJPEG_DECODER 4096  
-#define VID_TYPE_MJPEG_ENCODER 8192  
+#define VID_TYPE_MJPEG_DECODER 4096
+#define VID_TYPE_MJPEG_ENCODER 8192
 #define v4l2_fourcc(a, b, c, d)  ((__u32)(a) | ((__u32)(b) << 8) | ((__u32)(c) << 16) | ((__u32)(d) << 24))
 enum v4l2_field {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -139,32 +139,32 @@
  __u32 device_caps;
  __u32 reserved[3];
 };
-#define V4L2_CAP_VIDEO_CAPTURE 0x00000001  
+#define V4L2_CAP_VIDEO_CAPTURE 0x00000001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_CAP_VIDEO_OUTPUT 0x00000002  
-#define V4L2_CAP_VIDEO_OVERLAY 0x00000004  
-#define V4L2_CAP_VBI_CAPTURE 0x00000010  
-#define V4L2_CAP_VBI_OUTPUT 0x00000020  
+#define V4L2_CAP_VIDEO_OUTPUT 0x00000002
+#define V4L2_CAP_VIDEO_OVERLAY 0x00000004
+#define V4L2_CAP_VBI_CAPTURE 0x00000010
+#define V4L2_CAP_VBI_OUTPUT 0x00000020
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_CAP_SLICED_VBI_CAPTURE 0x00000040  
-#define V4L2_CAP_SLICED_VBI_OUTPUT 0x00000080  
-#define V4L2_CAP_RDS_CAPTURE 0x00000100  
-#define V4L2_CAP_VIDEO_OUTPUT_OVERLAY 0x00000200  
+#define V4L2_CAP_SLICED_VBI_CAPTURE 0x00000040
+#define V4L2_CAP_SLICED_VBI_OUTPUT 0x00000080
+#define V4L2_CAP_RDS_CAPTURE 0x00000100
+#define V4L2_CAP_VIDEO_OUTPUT_OVERLAY 0x00000200
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_CAP_HW_FREQ_SEEK 0x00000400  
-#define V4L2_CAP_RDS_OUTPUT 0x00000800  
+#define V4L2_CAP_HW_FREQ_SEEK 0x00000400
+#define V4L2_CAP_RDS_OUTPUT 0x00000800
 #define V4L2_CAP_VIDEO_CAPTURE_MPLANE 0x00001000
 #define V4L2_CAP_VIDEO_OUTPUT_MPLANE 0x00002000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_CAP_TUNER 0x00010000  
-#define V4L2_CAP_AUDIO 0x00020000  
-#define V4L2_CAP_RADIO 0x00040000  
-#define V4L2_CAP_MODULATOR 0x00080000  
+#define V4L2_CAP_TUNER 0x00010000
+#define V4L2_CAP_AUDIO 0x00020000
+#define V4L2_CAP_RADIO 0x00040000
+#define V4L2_CAP_MODULATOR 0x00080000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_CAP_READWRITE 0x01000000  
-#define V4L2_CAP_ASYNCIO 0x02000000  
-#define V4L2_CAP_STREAMING 0x04000000  
-#define V4L2_CAP_DEVICE_CAPS 0x80000000  
+#define V4L2_CAP_READWRITE 0x01000000
+#define V4L2_CAP_ASYNCIO 0x02000000
+#define V4L2_CAP_STREAMING 0x04000000
+#define V4L2_CAP_DEVICE_CAPS 0x80000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct v4l2_pix_format {
  __u32 width;
@@ -178,132 +178,132 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __u32 priv;
 };
-#define V4L2_PIX_FMT_RGB332 v4l2_fourcc('R', 'G', 'B', '1')  
-#define V4L2_PIX_FMT_RGB444 v4l2_fourcc('R', '4', '4', '4')  
+#define V4L2_PIX_FMT_RGB332 v4l2_fourcc('R', 'G', 'B', '1')
+#define V4L2_PIX_FMT_RGB444 v4l2_fourcc('R', '4', '4', '4')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R', 'G', 'B', 'O')  
-#define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R', 'G', 'B', 'P')  
-#define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R', 'G', 'B', 'Q')  
-#define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R', 'G', 'B', 'R')  
+#define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R', 'G', 'B', 'O')
+#define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R', 'G', 'B', 'P')
+#define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R', 'G', 'B', 'Q')
+#define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R', 'G', 'B', 'R')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_BGR666 v4l2_fourcc('B', 'G', 'R', 'H')  
-#define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B', 'G', 'R', '3')  
-#define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R', 'G', 'B', '3')  
-#define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B', 'G', 'R', '4')  
+#define V4L2_PIX_FMT_BGR666 v4l2_fourcc('B', 'G', 'R', 'H')
+#define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B', 'G', 'R', '3')
+#define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R', 'G', 'B', '3')
+#define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B', 'G', 'R', '4')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R', 'G', 'B', '4')  
-#define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y')  
-#define V4L2_PIX_FMT_Y4 v4l2_fourcc('Y', '0', '4', ' ')  
-#define V4L2_PIX_FMT_Y6 v4l2_fourcc('Y', '0', '6', ' ')  
+#define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R', 'G', 'B', '4')
+#define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y')
+#define V4L2_PIX_FMT_Y4 v4l2_fourcc('Y', '0', '4', ' ')
+#define V4L2_PIX_FMT_Y6 v4l2_fourcc('Y', '0', '6', ' ')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_Y10 v4l2_fourcc('Y', '1', '0', ' ')  
-#define V4L2_PIX_FMT_Y12 v4l2_fourcc('Y', '1', '2', ' ')  
-#define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y', '1', '6', ' ')  
-#define V4L2_PIX_FMT_Y10BPACK v4l2_fourcc('Y', '1', '0', 'B')  
+#define V4L2_PIX_FMT_Y10 v4l2_fourcc('Y', '1', '0', ' ')
+#define V4L2_PIX_FMT_Y12 v4l2_fourcc('Y', '1', '2', ' ')
+#define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y', '1', '6', ' ')
+#define V4L2_PIX_FMT_Y10BPACK v4l2_fourcc('Y', '1', '0', 'B')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P', 'A', 'L', '8')  
-#define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y', 'V', 'U', '9')  
-#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y', 'V', '1', '2')  
-#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V')  
+#define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P', 'A', 'L', '8')
+#define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y', 'V', 'U', '9')
+#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y', 'V', '1', '2')
+#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y', 'Y', 'U', 'V')  
-#define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U')  
-#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y')  
-#define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y')  
+#define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y', 'Y', 'U', 'V')
+#define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U')
+#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y')
+#define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4', '2', '2', 'P')  
-#define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4', '1', '1', 'P')  
-#define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y', '4', '1', 'P')  
-#define V4L2_PIX_FMT_YUV444 v4l2_fourcc('Y', '4', '4', '4')  
+#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4', '2', '2', 'P')
+#define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4', '1', '1', 'P')
+#define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y', '4', '1', 'P')
+#define V4L2_PIX_FMT_YUV444 v4l2_fourcc('Y', '4', '4', '4')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_YUV555 v4l2_fourcc('Y', 'U', 'V', 'O')  
-#define V4L2_PIX_FMT_YUV565 v4l2_fourcc('Y', 'U', 'V', 'P')  
-#define V4L2_PIX_FMT_YUV32 v4l2_fourcc('Y', 'U', 'V', '4')  
-#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9')  
+#define V4L2_PIX_FMT_YUV555 v4l2_fourcc('Y', 'U', 'V', 'O')
+#define V4L2_PIX_FMT_YUV565 v4l2_fourcc('Y', 'U', 'V', 'P')
+#define V4L2_PIX_FMT_YUV32 v4l2_fourcc('Y', 'U', 'V', '4')
+#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y', 'U', '1', '2')  
-#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4')  
-#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H', 'M', '1', '2')  
-#define V4L2_PIX_FMT_M420 v4l2_fourcc('M', '4', '2', '0')  
+#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y', 'U', '1', '2')
+#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4')
+#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H', 'M', '1', '2')
+#define V4L2_PIX_FMT_M420 v4l2_fourcc('M', '4', '2', '0')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2')  
-#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N', 'V', '2', '1')  
-#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6')  
-#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1')  
+#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2')
+#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N', 'V', '2', '1')
+#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6')
+#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_NV24 v4l2_fourcc('N', 'V', '2', '4')  
-#define V4L2_PIX_FMT_NV42 v4l2_fourcc('N', 'V', '4', '2')  
-#define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2')  
-#define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2')  
+#define V4L2_PIX_FMT_NV24 v4l2_fourcc('N', 'V', '2', '4')
+#define V4L2_PIX_FMT_NV42 v4l2_fourcc('N', 'V', '4', '2')
+#define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2')
+#define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_YUV420M v4l2_fourcc('Y', 'M', '1', '2')  
-#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1')  
-#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G')  
-#define V4L2_PIX_FMT_SGRBG8 v4l2_fourcc('G', 'R', 'B', 'G')  
+#define V4L2_PIX_FMT_YUV420M v4l2_fourcc('Y', 'M', '1', '2')
+#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1')
+#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G')
+#define V4L2_PIX_FMT_SGRBG8 v4l2_fourcc('G', 'R', 'B', 'G')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_SRGGB8 v4l2_fourcc('R', 'G', 'G', 'B')  
-#define V4L2_PIX_FMT_SBGGR10 v4l2_fourcc('B', 'G', '1', '0')  
-#define V4L2_PIX_FMT_SGBRG10 v4l2_fourcc('G', 'B', '1', '0')  
-#define V4L2_PIX_FMT_SGRBG10 v4l2_fourcc('B', 'A', '1', '0')  
+#define V4L2_PIX_FMT_SRGGB8 v4l2_fourcc('R', 'G', 'G', 'B')
+#define V4L2_PIX_FMT_SBGGR10 v4l2_fourcc('B', 'G', '1', '0')
+#define V4L2_PIX_FMT_SGBRG10 v4l2_fourcc('G', 'B', '1', '0')
+#define V4L2_PIX_FMT_SGRBG10 v4l2_fourcc('B', 'A', '1', '0')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_SRGGB10 v4l2_fourcc('R', 'G', '1', '0')  
-#define V4L2_PIX_FMT_SBGGR12 v4l2_fourcc('B', 'G', '1', '2')  
-#define V4L2_PIX_FMT_SGBRG12 v4l2_fourcc('G', 'B', '1', '2')  
-#define V4L2_PIX_FMT_SGRBG12 v4l2_fourcc('B', 'A', '1', '2')  
+#define V4L2_PIX_FMT_SRGGB10 v4l2_fourcc('R', 'G', '1', '0')
+#define V4L2_PIX_FMT_SBGGR12 v4l2_fourcc('B', 'G', '1', '2')
+#define V4L2_PIX_FMT_SGBRG12 v4l2_fourcc('G', 'B', '1', '2')
+#define V4L2_PIX_FMT_SGRBG12 v4l2_fourcc('B', 'A', '1', '2')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_SRGGB12 v4l2_fourcc('R', 'G', '1', '2')  
+#define V4L2_PIX_FMT_SRGGB12 v4l2_fourcc('R', 'G', '1', '2')
 #define V4L2_PIX_FMT_SGRBG10DPCM8 v4l2_fourcc('B', 'D', '1', '0')
-#define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2')  
-#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M', 'J', 'P', 'G')  
+#define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2')
+#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M', 'J', 'P', 'G')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_JPEG v4l2_fourcc('J', 'P', 'E', 'G')  
-#define V4L2_PIX_FMT_DV v4l2_fourcc('d', 'v', 's', 'd')  
-#define V4L2_PIX_FMT_MPEG v4l2_fourcc('M', 'P', 'E', 'G')  
-#define V4L2_PIX_FMT_H264 v4l2_fourcc('H', '2', '6', '4')  
+#define V4L2_PIX_FMT_JPEG v4l2_fourcc('J', 'P', 'E', 'G')
+#define V4L2_PIX_FMT_DV v4l2_fourcc('d', 'v', 's', 'd')
+#define V4L2_PIX_FMT_MPEG v4l2_fourcc('M', 'P', 'E', 'G')
+#define V4L2_PIX_FMT_H264 v4l2_fourcc('H', '2', '6', '4')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_H264_NO_SC v4l2_fourcc('A', 'V', 'C', '1')  
-#define V4L2_PIX_FMT_H263 v4l2_fourcc('H', '2', '6', '3')  
-#define V4L2_PIX_FMT_MPEG1 v4l2_fourcc('M', 'P', 'G', '1')  
-#define V4L2_PIX_FMT_MPEG2 v4l2_fourcc('M', 'P', 'G', '2')  
+#define V4L2_PIX_FMT_H264_NO_SC v4l2_fourcc('A', 'V', 'C', '1')
+#define V4L2_PIX_FMT_H263 v4l2_fourcc('H', '2', '6', '3')
+#define V4L2_PIX_FMT_MPEG1 v4l2_fourcc('M', 'P', 'G', '1')
+#define V4L2_PIX_FMT_MPEG2 v4l2_fourcc('M', 'P', 'G', '2')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_MPEG4 v4l2_fourcc('M', 'P', 'G', '4')  
-#define V4L2_PIX_FMT_XVID v4l2_fourcc('X', 'V', 'I', 'D')  
-#define V4L2_PIX_FMT_VC1_ANNEX_G v4l2_fourcc('V', 'C', '1', 'G')  
-#define V4L2_PIX_FMT_VC1_ANNEX_L v4l2_fourcc('V', 'C', '1', 'L')  
+#define V4L2_PIX_FMT_MPEG4 v4l2_fourcc('M', 'P', 'G', '4')
+#define V4L2_PIX_FMT_XVID v4l2_fourcc('X', 'V', 'I', 'D')
+#define V4L2_PIX_FMT_VC1_ANNEX_G v4l2_fourcc('V', 'C', '1', 'G')
+#define V4L2_PIX_FMT_VC1_ANNEX_L v4l2_fourcc('V', 'C', '1', 'L')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_DIVX_311 v4l2_fourcc('D', 'I', 'V', '3')  
-#define V4L2_PIX_FMT_DIVX v4l2_fourcc('D', 'I', 'V', 'X')  
-#define V4L2_PIX_FMT_VP8 v4l2_fourcc('V', 'P', '8', '0')  
-#define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A')  
+#define V4L2_PIX_FMT_DIVX_311 v4l2_fourcc('D', 'I', 'V', '3')
+#define V4L2_PIX_FMT_DIVX v4l2_fourcc('D', 'I', 'V', 'X')
+#define V4L2_PIX_FMT_VP8 v4l2_fourcc('V', 'P', '8', '0')
+#define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_WNVA v4l2_fourcc('W', 'N', 'V', 'A')  
-#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S', '9', '1', '0')  
-#define V4L2_PIX_FMT_SN9C20X_I420 v4l2_fourcc('S', '9', '2', '0')  
-#define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P', 'W', 'C', '1')  
+#define V4L2_PIX_FMT_WNVA v4l2_fourcc('W', 'N', 'V', 'A')
+#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S', '9', '1', '0')
+#define V4L2_PIX_FMT_SN9C20X_I420 v4l2_fourcc('S', '9', '2', '0')
+#define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P', 'W', 'C', '1')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P', 'W', 'C', '2')  
-#define V4L2_PIX_FMT_ET61X251 v4l2_fourcc('E', '6', '2', '5')  
-#define V4L2_PIX_FMT_SPCA501 v4l2_fourcc('S', '5', '0', '1')  
-#define V4L2_PIX_FMT_SPCA505 v4l2_fourcc('S', '5', '0', '5')  
+#define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P', 'W', 'C', '2')
+#define V4L2_PIX_FMT_ET61X251 v4l2_fourcc('E', '6', '2', '5')
+#define V4L2_PIX_FMT_SPCA501 v4l2_fourcc('S', '5', '0', '1')
+#define V4L2_PIX_FMT_SPCA505 v4l2_fourcc('S', '5', '0', '5')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_SPCA508 v4l2_fourcc('S', '5', '0', '8')  
-#define V4L2_PIX_FMT_SPCA561 v4l2_fourcc('S', '5', '6', '1')  
-#define V4L2_PIX_FMT_PAC207 v4l2_fourcc('P', '2', '0', '7')  
-#define V4L2_PIX_FMT_MR97310A v4l2_fourcc('M', '3', '1', '0')  
+#define V4L2_PIX_FMT_SPCA508 v4l2_fourcc('S', '5', '0', '8')
+#define V4L2_PIX_FMT_SPCA561 v4l2_fourcc('S', '5', '6', '1')
+#define V4L2_PIX_FMT_PAC207 v4l2_fourcc('P', '2', '0', '7')
+#define V4L2_PIX_FMT_MR97310A v4l2_fourcc('M', '3', '1', '0')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_JL2005BCD v4l2_fourcc('J', 'L', '2', '0')  
-#define V4L2_PIX_FMT_SN9C2028 v4l2_fourcc('S', 'O', 'N', 'X')  
-#define V4L2_PIX_FMT_SQ905C v4l2_fourcc('9', '0', '5', 'C')  
-#define V4L2_PIX_FMT_PJPG v4l2_fourcc('P', 'J', 'P', 'G')  
+#define V4L2_PIX_FMT_JL2005BCD v4l2_fourcc('J', 'L', '2', '0')
+#define V4L2_PIX_FMT_SN9C2028 v4l2_fourcc('S', 'O', 'N', 'X')
+#define V4L2_PIX_FMT_SQ905C v4l2_fourcc('9', '0', '5', 'C')
+#define V4L2_PIX_FMT_PJPG v4l2_fourcc('P', 'J', 'P', 'G')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_OV511 v4l2_fourcc('O', '5', '1', '1')  
-#define V4L2_PIX_FMT_OV518 v4l2_fourcc('O', '5', '1', '8')  
-#define V4L2_PIX_FMT_STV0680 v4l2_fourcc('S', '6', '8', '0')  
-#define V4L2_PIX_FMT_TM6000 v4l2_fourcc('T', 'M', '6', '0')  
+#define V4L2_PIX_FMT_OV511 v4l2_fourcc('O', '5', '1', '1')
+#define V4L2_PIX_FMT_OV518 v4l2_fourcc('O', '5', '1', '8')
+#define V4L2_PIX_FMT_STV0680 v4l2_fourcc('S', '6', '8', '0')
+#define V4L2_PIX_FMT_TM6000 v4l2_fourcc('T', 'M', '6', '0')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_PIX_FMT_CIT_YYVYUY v4l2_fourcc('C', 'I', 'T', 'V')  
-#define V4L2_PIX_FMT_KONICA420 v4l2_fourcc('K', 'O', 'N', 'I')  
-#define V4L2_PIX_FMT_JPGL v4l2_fourcc('J', 'P', 'G', 'L')  
+#define V4L2_PIX_FMT_CIT_YYVYUY v4l2_fourcc('C', 'I', 'T', 'V')
+#define V4L2_PIX_FMT_KONICA420 v4l2_fourcc('K', 'O', 'N', 'I')
+#define V4L2_PIX_FMT_JPGL v4l2_fourcc('J', 'P', 'G', 'L')
 #define V4L2_PIX_FMT_SE401 v4l2_fourcc('S', '4', '0', '1')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_PIX_FMT_STATS_COMB v4l2_fourcc('S', 'T', 'C', 'M')
@@ -409,7 +409,7 @@
 #define V4L2_TC_TYPE_30FPS 3
 #define V4L2_TC_TYPE_50FPS 4
 #define V4L2_TC_TYPE_60FPS 5
-#define V4L2_TC_FLAG_DROPFRAME 0x0001  
+#define V4L2_TC_FLAG_DROPFRAME 0x0001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_TC_FLAG_COLORFRAME 0x0002
 #define V4L2_TC_USERBITS_field 0x000C
@@ -426,12 +426,12 @@
  char COM_data[60];
  __u32 jpeg_markers;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_JPEG_MARKER_DHT (1<<3)  
-#define V4L2_JPEG_MARKER_DQT (1<<4)  
-#define V4L2_JPEG_MARKER_DRI (1<<5)  
-#define V4L2_JPEG_MARKER_COM (1<<6)  
+#define V4L2_JPEG_MARKER_DHT (1<<3)
+#define V4L2_JPEG_MARKER_DQT (1<<4)
+#define V4L2_JPEG_MARKER_DRI (1<<5)
+#define V4L2_JPEG_MARKER_COM (1<<6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_JPEG_MARKER_APP (1<<7)  
+#define V4L2_JPEG_MARKER_APP (1<<7)
 };
 struct v4l2_requestbuffers {
  __u32 count;
@@ -477,18 +477,18 @@
  __u32 reserved;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define V4L2_BUF_FLAG_MAPPED 0x0001  
-#define V4L2_BUF_FLAG_QUEUED 0x0002  
-#define V4L2_BUF_FLAG_DONE 0x0004  
+#define V4L2_BUF_FLAG_MAPPED 0x0001
+#define V4L2_BUF_FLAG_QUEUED 0x0002
+#define V4L2_BUF_FLAG_DONE 0x0004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_BUF_FLAG_KEYFRAME 0x0008  
-#define V4L2_BUF_FLAG_PFRAME 0x0010  
-#define V4L2_BUF_FLAG_BFRAME 0x0020  
+#define V4L2_BUF_FLAG_KEYFRAME 0x0008
+#define V4L2_BUF_FLAG_PFRAME 0x0010
+#define V4L2_BUF_FLAG_BFRAME 0x0020
 #define V4L2_BUF_FLAG_ERROR 0x0040
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_BUF_FLAG_TIMECODE 0x0100  
-#define V4L2_BUF_FLAG_INPUT 0x0200  
-#define V4L2_BUF_FLAG_PREPARED 0x0400  
+#define V4L2_BUF_FLAG_TIMECODE 0x0100
+#define V4L2_BUF_FLAG_INPUT 0x0200
+#define V4L2_BUF_FLAG_PREPARED 0x0400
 #define V4L2_BUF_FLAG_NO_CACHE_INVALIDATE 0x0800
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_BUF_FLAG_NO_CACHE_CLEAN 0x1000
@@ -546,9 +546,9 @@
  __u32 reserved[4];
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_MODE_HIGHQUALITY 0x0001  
-#define V4L2_CAP_TIMEPERFRAME 0x1000  
-#define V4L2_CAP_QCOM_FRAMESKIP 0x2000  
+#define V4L2_MODE_HIGHQUALITY 0x0001
+#define V4L2_CAP_TIMEPERFRAME 0x1000
+#define V4L2_CAP_QCOM_FRAMESKIP 0x2000
 struct v4l2_qcom_frameskip {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __u64 maxframeinterval;
@@ -612,11 +612,11 @@
 #define V4L2_STD_PAL_Nc ((v4l2_std_id)0x00000400)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_PAL_60 ((v4l2_std_id)0x00000800)
-#define V4L2_STD_NTSC_M ((v4l2_std_id)0x00001000)  
-#define V4L2_STD_NTSC_M_JP ((v4l2_std_id)0x00002000)  
+#define V4L2_STD_NTSC_M ((v4l2_std_id)0x00001000)
+#define V4L2_STD_NTSC_M_JP ((v4l2_std_id)0x00002000)
 #define V4L2_STD_NTSC_443 ((v4l2_std_id)0x00004000)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_STD_NTSC_M_KR ((v4l2_std_id)0x00008000)  
+#define V4L2_STD_NTSC_M_KR ((v4l2_std_id)0x00008000)
 #define V4L2_STD_SECAM_B ((v4l2_std_id)0x00010000)
 #define V4L2_STD_SECAM_D ((v4l2_std_id)0x00020000)
 #define V4L2_STD_SECAM_G ((v4l2_std_id)0x00040000)
@@ -681,28 +681,28 @@
 };
 #define V4L2_DV_INVALID 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_DV_480P59_94 1  
-#define V4L2_DV_576P50 2  
-#define V4L2_DV_720P24 3  
-#define V4L2_DV_720P25 4  
+#define V4L2_DV_480P59_94 1
+#define V4L2_DV_576P50 2
+#define V4L2_DV_720P24 3
+#define V4L2_DV_720P25 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_DV_720P30 5  
-#define V4L2_DV_720P50 6  
-#define V4L2_DV_720P59_94 7  
-#define V4L2_DV_720P60 8  
+#define V4L2_DV_720P30 5
+#define V4L2_DV_720P50 6
+#define V4L2_DV_720P59_94 7
+#define V4L2_DV_720P60 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_DV_1080I29_97 9  
-#define V4L2_DV_1080I30 10  
-#define V4L2_DV_1080I25 11  
-#define V4L2_DV_1080I50 12  
+#define V4L2_DV_1080I29_97 9
+#define V4L2_DV_1080I30 10
+#define V4L2_DV_1080I25 11
+#define V4L2_DV_1080I50 12
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_DV_1080I60 13  
-#define V4L2_DV_1080P24 14  
-#define V4L2_DV_1080P25 15  
-#define V4L2_DV_1080P30 16  
+#define V4L2_DV_1080I60 13
+#define V4L2_DV_1080P24 14
+#define V4L2_DV_1080P25 15
+#define V4L2_DV_1080P30 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_DV_1080P50 17  
-#define V4L2_DV_1080P60 18  
+#define V4L2_DV_1080P50 17
+#define V4L2_DV_1080P60 18
 struct v4l2_bt_timings {
  __u32 width;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -738,7 +738,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  };
 } __attribute__ ((packed));
-#define V4L2_DV_BT_656_1120 0  
+#define V4L2_DV_BT_656_1120 0
 struct v4l2_input {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __u32 index;
@@ -756,25 +756,25 @@
 #define V4L2_INPUT_TYPE_TUNER 1
 #define V4L2_INPUT_TYPE_CAMERA 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_IN_ST_NO_POWER 0x00000001  
+#define V4L2_IN_ST_NO_POWER 0x00000001
 #define V4L2_IN_ST_NO_SIGNAL 0x00000002
 #define V4L2_IN_ST_NO_COLOR 0x00000004
-#define V4L2_IN_ST_HFLIP 0x00000010  
+#define V4L2_IN_ST_HFLIP 0x00000010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_IN_ST_VFLIP 0x00000020  
-#define V4L2_IN_ST_NO_H_LOCK 0x00000100  
-#define V4L2_IN_ST_COLOR_KILL 0x00000200  
-#define V4L2_IN_ST_NO_SYNC 0x00010000  
+#define V4L2_IN_ST_VFLIP 0x00000020
+#define V4L2_IN_ST_NO_H_LOCK 0x00000100
+#define V4L2_IN_ST_COLOR_KILL 0x00000200
+#define V4L2_IN_ST_NO_SYNC 0x00010000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_IN_ST_NO_EQU 0x00020000  
-#define V4L2_IN_ST_NO_CARRIER 0x00040000  
-#define V4L2_IN_ST_MACROVISION 0x01000000  
-#define V4L2_IN_ST_NO_ACCESS 0x02000000  
+#define V4L2_IN_ST_NO_EQU 0x00020000
+#define V4L2_IN_ST_NO_CARRIER 0x00040000
+#define V4L2_IN_ST_MACROVISION 0x01000000
+#define V4L2_IN_ST_NO_ACCESS 0x02000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_IN_ST_VTR 0x04000000  
-#define V4L2_IN_CAP_PRESETS 0x00000001  
-#define V4L2_IN_CAP_CUSTOM_TIMINGS 0x00000002  
-#define V4L2_IN_CAP_STD 0x00000004  
+#define V4L2_IN_ST_VTR 0x04000000
+#define V4L2_IN_CAP_PRESETS 0x00000001
+#define V4L2_IN_CAP_CUSTOM_TIMINGS 0x00000002
+#define V4L2_IN_CAP_STD 0x00000004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct v4l2_output {
  __u32 index;
@@ -792,9 +792,9 @@
 #define V4L2_OUTPUT_TYPE_ANALOG 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3
-#define V4L2_OUT_CAP_PRESETS 0x00000001  
-#define V4L2_OUT_CAP_CUSTOM_TIMINGS 0x00000002  
-#define V4L2_OUT_CAP_STD 0x00000004  
+#define V4L2_OUT_CAP_PRESETS 0x00000001
+#define V4L2_OUT_CAP_CUSTOM_TIMINGS 0x00000002
+#define V4L2_OUT_CAP_STD 0x00000004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct v4l2_control {
  __u32 id;
@@ -822,13 +822,13 @@
  struct v4l2_ext_control *controls;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define V4L2_CTRL_CLASS_USER 0x00980000  
-#define V4L2_CTRL_CLASS_MPEG 0x00990000  
-#define V4L2_CTRL_CLASS_CAMERA 0x009a0000  
+#define V4L2_CTRL_CLASS_USER 0x00980000
+#define V4L2_CTRL_CLASS_MPEG 0x00990000
+#define V4L2_CTRL_CLASS_CAMERA 0x009a0000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_CTRL_CLASS_FM_TX 0x009b0000  
-#define V4L2_CTRL_CLASS_FLASH 0x009c0000  
-#define V4L2_CTRL_CLASS_JPEG 0x009d0000  
+#define V4L2_CTRL_CLASS_FM_TX 0x009b0000
+#define V4L2_CTRL_CLASS_FLASH 0x009c0000
+#define V4L2_CTRL_CLASS_JPEG 0x009d0000
 #define V4L2_CTRL_ID_MASK (0x0fffffff)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL)
@@ -897,14 +897,14 @@
 #define V4L2_CID_AUDIO_MUTE (V4L2_CID_BASE+9)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_CID_AUDIO_LOUDNESS (V4L2_CID_BASE+10)
-#define V4L2_CID_BLACK_LEVEL (V4L2_CID_BASE+11)  
+#define V4L2_CID_BLACK_LEVEL (V4L2_CID_BASE+11)
 #define V4L2_CID_AUTO_WHITE_BALANCE (V4L2_CID_BASE+12)
 #define V4L2_CID_DO_WHITE_BALANCE (V4L2_CID_BASE+13)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_CID_RED_BALANCE (V4L2_CID_BASE+14)
 #define V4L2_CID_BLUE_BALANCE (V4L2_CID_BASE+15)
 #define V4L2_CID_GAMMA (V4L2_CID_BASE+16)
-#define V4L2_CID_WHITENESS (V4L2_CID_GAMMA)  
+#define V4L2_CID_WHITENESS (V4L2_CID_GAMMA)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_CID_EXPOSURE (V4L2_CID_BASE+17)
 #define V4L2_CID_AUTOGAIN (V4L2_CID_BASE+18)
@@ -2041,10 +2041,10 @@
  __u32 reserved[5];
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_CHIP_MATCH_HOST 0  
-#define V4L2_CHIP_MATCH_I2C_DRIVER 1  
-#define V4L2_CHIP_MATCH_I2C_ADDR 2  
-#define V4L2_CHIP_MATCH_AC97 3  
+#define V4L2_CHIP_MATCH_HOST 0
+#define V4L2_CHIP_MATCH_I2C_DRIVER 1
+#define V4L2_CHIP_MATCH_I2C_ADDR 2
+#define V4L2_CHIP_MATCH_AC97 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct v4l2_dbg_match {
  __u32 type;
@@ -2176,6 +2176,5 @@
 #define VIDIOC_DECODER_CMD _IOWR('V', 96, struct v4l2_decoder_cmd)
 #define VIDIOC_TRY_DECODER_CMD _IOWR('V', 97, struct v4l2_decoder_cmd)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BASE_VIDIOC_PRIVATE 192  
+#define BASE_VIDIOC_PRIVATE 192
 #endif
-
diff --git a/libc/kernel/common/linux/vmalloc.h b/libc/kernel/common/linux/vmalloc.h
index 7928ee3..9add232 100644
--- a/libc/kernel/common/linux/vmalloc.h
+++ b/libc/kernel/common/linux/vmalloc.h
@@ -19,17 +19,17 @@
 #ifndef _LINUX_VMALLOC_H
 #define _LINUX_VMALLOC_H
 #include <linux/spinlock.h>
-#include <asm/page.h>  
+#include <asm/page.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct vm_area_struct;
-#define VM_IOREMAP 0x00000001  
-#define VM_ALLOC 0x00000002  
-#define VM_MAP 0x00000004  
+#define VM_IOREMAP 0x00000001
+#define VM_ALLOC 0x00000002
+#define VM_MAP 0x00000004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VM_USERMAP 0x00000008  
-#define VM_VPAGES 0x00000010  
+#define VM_USERMAP 0x00000008
+#define VM_VPAGES 0x00000010
 #ifndef IOREMAP_MAX_ORDER
-#define IOREMAP_MAX_ORDER (7 + PAGE_SHIFT)  
+#define IOREMAP_MAX_ORDER (7 + PAGE_SHIFT)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 struct vm_struct {
diff --git a/libc/kernel/common/linux/vt.h b/libc/kernel/common/linux/vt.h
index b3f9090..bb5418e 100644
--- a/libc/kernel/common/linux/vt.h
+++ b/libc/kernel/common/linux/vt.h
@@ -18,11 +18,11 @@
  ****************************************************************************/
 #ifndef _LINUX_VT_H
 #define _LINUX_VT_H
-#define MIN_NR_CONSOLES 1  
-#define MAX_NR_CONSOLES 63  
+#define MIN_NR_CONSOLES 1
+#define MAX_NR_CONSOLES 63
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MAX_NR_USER_CONSOLES 63  
-#define VT_OPENQRY 0x5600  
+#define MAX_NR_USER_CONSOLES 63
+#define VT_OPENQRY 0x5600
 struct vt_mode {
  char mode;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -32,33 +32,33 @@
  short frsig;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define VT_GETMODE 0x5601  
-#define VT_SETMODE 0x5602  
-#define VT_AUTO 0x00  
+#define VT_GETMODE 0x5601
+#define VT_SETMODE 0x5602
+#define VT_AUTO 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VT_PROCESS 0x01  
-#define VT_ACKACQ 0x02  
+#define VT_PROCESS 0x01
+#define VT_ACKACQ 0x02
 struct vt_stat {
  unsigned short v_active;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned short v_signal;
  unsigned short v_state;
 };
-#define VT_GETSTATE 0x5603  
+#define VT_GETSTATE 0x5603
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VT_SENDSIG 0x5604  
-#define VT_RELDISP 0x5605  
-#define VT_ACTIVATE 0x5606  
-#define VT_WAITACTIVE 0x5607  
+#define VT_SENDSIG 0x5604
+#define VT_RELDISP 0x5605
+#define VT_ACTIVATE 0x5606
+#define VT_WAITACTIVE 0x5607
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VT_DISALLOCATE 0x5608  
+#define VT_DISALLOCATE 0x5608
 struct vt_sizes {
  unsigned short v_rows;
  unsigned short v_cols;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned short v_scrollsize;
 };
-#define VT_RESIZE 0x5609  
+#define VT_RESIZE 0x5609
 struct vt_consize {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned short v_rows;
@@ -69,10 +69,10 @@
  unsigned short v_vcol;
  unsigned short v_ccol;
 };
-#define VT_RESIZEX 0x560A  
+#define VT_RESIZEX 0x560A
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VT_LOCKSWITCH 0x560B  
-#define VT_UNLOCKSWITCH 0x560C  
-#define VT_GETHIFONTMASK 0x560D  
+#define VT_LOCKSWITCH 0x560B
+#define VT_UNLOCKSWITCH 0x560C
+#define VT_GETHIFONTMASK 0x560D
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/wait.h b/libc/kernel/common/linux/wait.h
index 7eb2124..f4688c7 100644
--- a/libc/kernel/common/linux/wait.h
+++ b/libc/kernel/common/linux/wait.h
@@ -24,11 +24,11 @@
 #define WSTOPPED WUNTRACED
 #define WEXITED 0x00000004
 #define WCONTINUED 0x00000008
-#define WNOWAIT 0x01000000  
+#define WNOWAIT 0x01000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define __WNOTHREAD 0x20000000  
-#define __WALL 0x40000000  
-#define __WCLONE 0x80000000  
+#define __WNOTHREAD 0x20000000
+#define __WALL 0x40000000
+#define __WCLONE 0x80000000
 #define P_ALL 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define P_PID 1
diff --git a/libc/kernel/common/linux/wanrouter.h b/libc/kernel/common/linux/wanrouter.h
index b0bd45a..1b8bd32 100644
--- a/libc/kernel/common/linux/wanrouter.h
+++ b/libc/kernel/common/linux/wanrouter.h
@@ -18,12 +18,12 @@
  ****************************************************************************/
 #ifndef _ROUTER_H
 #define _ROUTER_H
-#define ROUTER_NAME "wanrouter"  
-#define ROUTER_VERSION 1  
+#define ROUTER_NAME "wanrouter"
+#define ROUTER_VERSION 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ROUTER_RELEASE 1  
-#define ROUTER_IOCTL 'W'  
-#define ROUTER_MAGIC 0x524D4157L  
+#define ROUTER_RELEASE 1
+#define ROUTER_IOCTL 'W'
+#define ROUTER_MAGIC 0x524D4157L
 enum router_ioctls
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 {
@@ -38,30 +38,30 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  ROUTER_USER_MAX = (ROUTER_IOCTL<<8)+31
 };
-#define PROC_DATA_PORT_0 0x8000  
-#define PROC_DATA_PORT_1 0x8001  
+#define PROC_DATA_PORT_0 0x8000
+#define PROC_DATA_PORT_1 0x8001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NLPID_IP 0xCC  
-#define NLPID_SNAP 0x80  
-#define NLPID_CLNP 0x81  
-#define NLPID_ESIS 0x82  
+#define NLPID_IP 0xCC
+#define NLPID_SNAP 0x80
+#define NLPID_CLNP 0x81
+#define NLPID_ESIS 0x82
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NLPID_ISIS 0x83  
-#define NLPID_Q933 0x08  
-#define WAN_IFNAME_SZ 15  
-#define WAN_DRVNAME_SZ 15  
+#define NLPID_ISIS 0x83
+#define NLPID_Q933 0x08
+#define WAN_IFNAME_SZ 15
+#define WAN_DRVNAME_SZ 15
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WAN_ADDRESS_SZ 31  
-#define USED_BY_FIELD 8  
+#define WAN_ADDRESS_SZ 31
+#define USED_BY_FIELD 8
 #define UDP_PTPIPE_TYPE 0x01
 #define UDP_FPIPE_TYPE 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define UDP_CPIPE_TYPE 0x03
 #define UDP_DRVSTATS_TYPE 0x04
 #define UDP_INVALID_TYPE 0x05
-#define CMD_OK 0  
+#define CMD_OK 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CMD_TIMEOUT 0xFF  
+#define CMD_TIMEOUT 0xFF
 #define UDP_PKT_FRM_STACK 0x00
 #define UDP_PKT_FRM_NETWORK 0x01
 #define MAX_INTR_TEST_COUNTER 100
@@ -204,15 +204,15 @@
  wan_chdlc_conf_t chdlc;
  } u;
 } wandev_conf_t;
-#define WANCONFIG_X25 101  
+#define WANCONFIG_X25 101
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WANCONFIG_FR 102  
-#define WANCONFIG_PPP 103  
-#define WANCONFIG_CHDLC 104  
-#define WANCONFIG_BSC 105  
+#define WANCONFIG_FR 102
+#define WANCONFIG_PPP 103
+#define WANCONFIG_CHDLC 104
+#define WANCONFIG_BSC 105
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WANCONFIG_HDLC 106  
-#define WANCONFIG_MPPP 107  
+#define WANCONFIG_HDLC 106
+#define WANCONFIG_MPPP 107
 #define WANOPT_OFF 0
 #define WANOPT_ON 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -226,8 +226,8 @@
 #define WANOPT_FM0 2
 #define WANOPT_FM1 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WANOPT_POINTTOPOINT 0  
-#define WANOPT_MULTIDROP 1  
+#define WANOPT_POINTTOPOINT 0
+#define WANOPT_MULTIDROP 1
 #define WANOPT_EXTERNAL 0
 #define WANOPT_INTERNAL 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -238,13 +238,13 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define WANOPT_SECONDARY 0
 #define WANOPT_PRIMARY 1
-#define WANOPT_PERMANENT 0  
-#define WANOPT_SWITCHED 1  
+#define WANOPT_PERMANENT 0
+#define WANOPT_SWITCHED 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WANOPT_ONDEMAND 2  
-#define WANOPT_FR_ANSI 1  
-#define WANOPT_FR_Q933 2  
-#define WANOPT_FR_LMI 3  
+#define WANOPT_ONDEMAND 2
+#define WANOPT_FR_ANSI 1
+#define WANOPT_FR_Q933 2
+#define WANOPT_FR_LMI 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define WANOPT_PPP_STATIC 0
 #define WANOPT_PPP_HOST 1
@@ -314,11 +314,11 @@
  WAN_NETMASK_IP,
  WAN_BROADCAST_IP
 };
-#define WAN_MODEM_CTS 0x0001  
+#define WAN_MODEM_CTS 0x0001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WAN_MODEM_DCD 0x0002  
-#define WAN_MODEM_DTR 0x0010  
-#define WAN_MODEM_RTS 0x0020  
+#define WAN_MODEM_DCD 0x0002
+#define WAN_MODEM_DTR 0x0010
+#define WAN_MODEM_RTS 0x0020
 typedef struct wanif_conf
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 {
diff --git a/libc/kernel/common/linux/watchdog.h b/libc/kernel/common/linux/watchdog.h
index 4cbff4b..ecc5d1a 100644
--- a/libc/kernel/common/linux/watchdog.h
+++ b/libc/kernel/common/linux/watchdog.h
@@ -42,24 +42,24 @@
 #define WDIOC_GETPRETIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 9, int)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define WDIOC_GETTIMELEFT _IOR(WATCHDOG_IOCTL_BASE, 10, int)
-#define WDIOF_UNKNOWN -1  
-#define WDIOS_UNKNOWN -1  
-#define WDIOF_OVERHEAT 0x0001  
+#define WDIOF_UNKNOWN -1
+#define WDIOS_UNKNOWN -1
+#define WDIOF_OVERHEAT 0x0001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WDIOF_FANFAULT 0x0002  
-#define WDIOF_EXTERN1 0x0004  
-#define WDIOF_EXTERN2 0x0008  
-#define WDIOF_POWERUNDER 0x0010  
+#define WDIOF_FANFAULT 0x0002
+#define WDIOF_EXTERN1 0x0004
+#define WDIOF_EXTERN2 0x0008
+#define WDIOF_POWERUNDER 0x0010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WDIOF_CARDRESET 0x0020  
-#define WDIOF_POWEROVER 0x0040  
-#define WDIOF_SETTIMEOUT 0x0080  
-#define WDIOF_MAGICCLOSE 0x0100  
+#define WDIOF_CARDRESET 0x0020
+#define WDIOF_POWEROVER 0x0040
+#define WDIOF_SETTIMEOUT 0x0080
+#define WDIOF_MAGICCLOSE 0x0100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WDIOF_PRETIMEOUT 0x0200  
-#define WDIOF_KEEPALIVEPING 0x8000  
-#define WDIOS_DISABLECARD 0x0001  
-#define WDIOS_ENABLECARD 0x0002  
+#define WDIOF_PRETIMEOUT 0x0200
+#define WDIOF_KEEPALIVEPING 0x8000
+#define WDIOS_DISABLECARD 0x0001
+#define WDIOS_ENABLECARD 0x0002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define WDIOS_TEMPPANIC 0x0004  
+#define WDIOS_TEMPPANIC 0x0004
 #endif
diff --git a/libc/kernel/common/linux/wireless.h b/libc/kernel/common/linux/wireless.h
index b81bb81..d70680e 100644
--- a/libc/kernel/common/linux/wireless.h
+++ b/libc/kernel/common/linux/wireless.h
@@ -18,110 +18,110 @@
  ****************************************************************************/
 #ifndef _LINUX_WIRELESS_H
 #define _LINUX_WIRELESS_H
-#include <linux/types.h>  
-#include <linux/socket.h>  
+#include <linux/types.h>
+#include <linux/socket.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#include <linux/if.h>  
+#include <linux/if.h>
 #define WIRELESS_EXT 20
-#define SIOCSIWCOMMIT 0x8B00  
-#define SIOCGIWNAME 0x8B01  
+#define SIOCSIWCOMMIT 0x8B00
+#define SIOCGIWNAME 0x8B01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCSIWNWID 0x8B02  
-#define SIOCGIWNWID 0x8B03  
-#define SIOCSIWFREQ 0x8B04  
-#define SIOCGIWFREQ 0x8B05  
+#define SIOCSIWNWID 0x8B02
+#define SIOCGIWNWID 0x8B03
+#define SIOCSIWFREQ 0x8B04
+#define SIOCGIWFREQ 0x8B05
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCSIWMODE 0x8B06  
-#define SIOCGIWMODE 0x8B07  
-#define SIOCSIWSENS 0x8B08  
-#define SIOCGIWSENS 0x8B09  
+#define SIOCSIWMODE 0x8B06
+#define SIOCGIWMODE 0x8B07
+#define SIOCSIWSENS 0x8B08
+#define SIOCGIWSENS 0x8B09
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCSIWRANGE 0x8B0A  
-#define SIOCGIWRANGE 0x8B0B  
-#define SIOCSIWPRIV 0x8B0C  
-#define SIOCGIWPRIV 0x8B0D  
+#define SIOCSIWRANGE 0x8B0A
+#define SIOCGIWRANGE 0x8B0B
+#define SIOCSIWPRIV 0x8B0C
+#define SIOCGIWPRIV 0x8B0D
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCSIWSTATS 0x8B0E  
-#define SIOCGIWSTATS 0x8B0F  
-#define SIOCSIWSPY 0x8B10  
-#define SIOCGIWSPY 0x8B11  
+#define SIOCSIWSTATS 0x8B0E
+#define SIOCGIWSTATS 0x8B0F
+#define SIOCSIWSPY 0x8B10
+#define SIOCGIWSPY 0x8B11
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCSIWTHRSPY 0x8B12  
-#define SIOCGIWTHRSPY 0x8B13  
-#define SIOCSIWAP 0x8B14  
-#define SIOCGIWAP 0x8B15  
+#define SIOCSIWTHRSPY 0x8B12
+#define SIOCGIWTHRSPY 0x8B13
+#define SIOCSIWAP 0x8B14
+#define SIOCGIWAP 0x8B15
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCGIWAPLIST 0x8B17  
-#define SIOCSIWSCAN 0x8B18  
-#define SIOCGIWSCAN 0x8B19  
-#define SIOCSIWESSID 0x8B1A  
+#define SIOCGIWAPLIST 0x8B17
+#define SIOCSIWSCAN 0x8B18
+#define SIOCGIWSCAN 0x8B19
+#define SIOCSIWESSID 0x8B1A
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCGIWESSID 0x8B1B  
-#define SIOCSIWNICKN 0x8B1C  
-#define SIOCGIWNICKN 0x8B1D  
-#define SIOCSIWRATE 0x8B20  
+#define SIOCGIWESSID 0x8B1B
+#define SIOCSIWNICKN 0x8B1C
+#define SIOCGIWNICKN 0x8B1D
+#define SIOCSIWRATE 0x8B20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCGIWRATE 0x8B21  
-#define SIOCSIWRTS 0x8B22  
-#define SIOCGIWRTS 0x8B23  
-#define SIOCSIWFRAG 0x8B24  
+#define SIOCGIWRATE 0x8B21
+#define SIOCSIWRTS 0x8B22
+#define SIOCGIWRTS 0x8B23
+#define SIOCSIWFRAG 0x8B24
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCGIWFRAG 0x8B25  
-#define SIOCSIWTXPOW 0x8B26  
-#define SIOCGIWTXPOW 0x8B27  
-#define SIOCSIWRETRY 0x8B28  
+#define SIOCGIWFRAG 0x8B25
+#define SIOCSIWTXPOW 0x8B26
+#define SIOCGIWTXPOW 0x8B27
+#define SIOCSIWRETRY 0x8B28
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCGIWRETRY 0x8B29  
-#define SIOCSIWENCODE 0x8B2A  
-#define SIOCGIWENCODE 0x8B2B  
-#define SIOCSIWPOWER 0x8B2C  
+#define SIOCGIWRETRY 0x8B29
+#define SIOCSIWENCODE 0x8B2A
+#define SIOCGIWENCODE 0x8B2B
+#define SIOCSIWPOWER 0x8B2C
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCGIWPOWER 0x8B2D  
-#define SIOCSIWGENIE 0x8B30  
-#define SIOCGIWGENIE 0x8B31  
-#define SIOCSIWMLME 0x8B16  
+#define SIOCGIWPOWER 0x8B2D
+#define SIOCSIWGENIE 0x8B30
+#define SIOCGIWGENIE 0x8B31
+#define SIOCSIWMLME 0x8B16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCSIWAUTH 0x8B32  
-#define SIOCGIWAUTH 0x8B33  
-#define SIOCSIWENCODEEXT 0x8B34  
-#define SIOCGIWENCODEEXT 0x8B35  
+#define SIOCSIWAUTH 0x8B32
+#define SIOCGIWAUTH 0x8B33
+#define SIOCSIWENCODEEXT 0x8B34
+#define SIOCGIWENCODEEXT 0x8B35
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCSIWPMKSA 0x8B36  
+#define SIOCSIWPMKSA 0x8B36
 #define SIOCIWFIRSTPRIV 0x8BE0
 #define SIOCIWLASTPRIV 0x8BFF
 #define SIOCIWFIRST 0x8B00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SIOCIWLAST SIOCIWLASTPRIV  
+#define SIOCIWLAST SIOCIWLASTPRIV
 #define IW_IOCTL_IDX(cmd) ((cmd) - SIOCIWFIRST)
 #define IW_IS_SET(cmd) (!((cmd) & 0x1))
 #define IW_IS_GET(cmd) ((cmd) & 0x1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IWEVTXDROP 0x8C00  
-#define IWEVQUAL 0x8C01  
-#define IWEVCUSTOM 0x8C02  
-#define IWEVREGISTERED 0x8C03  
+#define IWEVTXDROP 0x8C00
+#define IWEVQUAL 0x8C01
+#define IWEVCUSTOM 0x8C02
+#define IWEVREGISTERED 0x8C03
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IWEVEXPIRED 0x8C04  
-#define IWEVGENIE 0x8C05  
-#define IWEVMICHAELMICFAILURE 0x8C06  
-#define IWEVASSOCREQIE 0x8C07  
+#define IWEVEXPIRED 0x8C04
+#define IWEVGENIE 0x8C05
+#define IWEVMICHAELMICFAILURE 0x8C06
+#define IWEVASSOCREQIE 0x8C07
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IWEVASSOCRESPIE 0x8C08  
-#define IWEVPMKIDCAND 0x8C09  
+#define IWEVASSOCRESPIE 0x8C08
+#define IWEVPMKIDCAND 0x8C09
 #define IWEVFIRST 0x8C00
 #define IW_EVENT_IDX(cmd) ((cmd) - IWEVFIRST)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IW_PRIV_TYPE_MASK 0x7000  
+#define IW_PRIV_TYPE_MASK 0x7000
 #define IW_PRIV_TYPE_NONE 0x0000
-#define IW_PRIV_TYPE_BYTE 0x1000  
-#define IW_PRIV_TYPE_CHAR 0x2000  
+#define IW_PRIV_TYPE_BYTE 0x1000
+#define IW_PRIV_TYPE_CHAR 0x2000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IW_PRIV_TYPE_INT 0x4000  
-#define IW_PRIV_TYPE_FLOAT 0x5000  
-#define IW_PRIV_TYPE_ADDR 0x6000  
-#define IW_PRIV_SIZE_FIXED 0x0800  
+#define IW_PRIV_TYPE_INT 0x4000
+#define IW_PRIV_TYPE_FLOAT 0x5000
+#define IW_PRIV_TYPE_ADDR 0x6000
+#define IW_PRIV_SIZE_FIXED 0x0800
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IW_PRIV_SIZE_MASK 0x07FF  
+#define IW_PRIV_SIZE_MASK 0x07FF
 #define IW_MAX_FREQUENCIES 32
 #define IW_MAX_BITRATES 32
 #define IW_MAX_TXPOWER 8
@@ -129,92 +129,92 @@
 #define IW_MAX_SPY 8
 #define IW_MAX_AP 64
 #define IW_ESSID_MAX_SIZE 32
-#define IW_MODE_AUTO 0  
+#define IW_MODE_AUTO 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IW_MODE_ADHOC 1  
-#define IW_MODE_INFRA 2  
-#define IW_MODE_MASTER 3  
-#define IW_MODE_REPEAT 4  
+#define IW_MODE_ADHOC 1
+#define IW_MODE_INFRA 2
+#define IW_MODE_MASTER 3
+#define IW_MODE_REPEAT 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IW_MODE_SECOND 5  
-#define IW_MODE_MONITOR 6  
-#define IW_QUAL_QUAL_UPDATED 0x01  
+#define IW_MODE_SECOND 5
+#define IW_MODE_MONITOR 6
+#define IW_QUAL_QUAL_UPDATED 0x01
 #define IW_QUAL_LEVEL_UPDATED 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IW_QUAL_NOISE_UPDATED 0x04
 #define IW_QUAL_ALL_UPDATED 0x07
-#define IW_QUAL_DBM 0x08  
-#define IW_QUAL_QUAL_INVALID 0x10  
+#define IW_QUAL_DBM 0x08
+#define IW_QUAL_QUAL_INVALID 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IW_QUAL_LEVEL_INVALID 0x20
 #define IW_QUAL_NOISE_INVALID 0x40
 #define IW_QUAL_ALL_INVALID 0x70
-#define IW_FREQ_AUTO 0x00  
+#define IW_FREQ_AUTO 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IW_FREQ_FIXED 0x01  
+#define IW_FREQ_FIXED 0x01
 #define IW_MAX_ENCODING_SIZES 8
-#define IW_ENCODING_TOKEN_MAX 64  
-#define IW_ENCODE_INDEX 0x00FF  
+#define IW_ENCODING_TOKEN_MAX 64
+#define IW_ENCODE_INDEX 0x00FF
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IW_ENCODE_FLAGS 0xFF00  
-#define IW_ENCODE_MODE 0xF000  
-#define IW_ENCODE_DISABLED 0x8000  
-#define IW_ENCODE_ENABLED 0x0000  
+#define IW_ENCODE_FLAGS 0xFF00
+#define IW_ENCODE_MODE 0xF000
+#define IW_ENCODE_DISABLED 0x8000
+#define IW_ENCODE_ENABLED 0x0000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IW_ENCODE_RESTRICTED 0x4000  
-#define IW_ENCODE_OPEN 0x2000  
-#define IW_ENCODE_NOKEY 0x0800  
-#define IW_ENCODE_TEMP 0x0400  
+#define IW_ENCODE_RESTRICTED 0x4000
+#define IW_ENCODE_OPEN 0x2000
+#define IW_ENCODE_NOKEY 0x0800
+#define IW_ENCODE_TEMP 0x0400
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IW_POWER_ON 0x0000  
-#define IW_POWER_TYPE 0xF000  
-#define IW_POWER_PERIOD 0x1000  
-#define IW_POWER_TIMEOUT 0x2000  
+#define IW_POWER_ON 0x0000
+#define IW_POWER_TYPE 0xF000
+#define IW_POWER_PERIOD 0x1000
+#define IW_POWER_TIMEOUT 0x2000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IW_POWER_MODE 0x0F00  
-#define IW_POWER_UNICAST_R 0x0100  
-#define IW_POWER_MULTICAST_R 0x0200  
-#define IW_POWER_ALL_R 0x0300  
+#define IW_POWER_MODE 0x0F00
+#define IW_POWER_UNICAST_R 0x0100
+#define IW_POWER_MULTICAST_R 0x0200
+#define IW_POWER_ALL_R 0x0300
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IW_POWER_FORCE_S 0x0400  
-#define IW_POWER_REPEATER 0x0800  
-#define IW_POWER_MODIFIER 0x000F  
-#define IW_POWER_MIN 0x0001  
+#define IW_POWER_FORCE_S 0x0400
+#define IW_POWER_REPEATER 0x0800
+#define IW_POWER_MODIFIER 0x000F
+#define IW_POWER_MIN 0x0001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IW_POWER_MAX 0x0002  
-#define IW_POWER_RELATIVE 0x0004  
-#define IW_TXPOW_TYPE 0x00FF  
-#define IW_TXPOW_DBM 0x0000  
+#define IW_POWER_MAX 0x0002
+#define IW_POWER_RELATIVE 0x0004
+#define IW_TXPOW_TYPE 0x00FF
+#define IW_TXPOW_DBM 0x0000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IW_TXPOW_MWATT 0x0001  
-#define IW_TXPOW_RELATIVE 0x0002  
-#define IW_TXPOW_RANGE 0x1000  
-#define IW_RETRY_ON 0x0000  
+#define IW_TXPOW_MWATT 0x0001
+#define IW_TXPOW_RELATIVE 0x0002
+#define IW_TXPOW_RANGE 0x1000
+#define IW_RETRY_ON 0x0000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IW_RETRY_TYPE 0xF000  
-#define IW_RETRY_LIMIT 0x1000  
-#define IW_RETRY_LIFETIME 0x2000  
-#define IW_RETRY_MODIFIER 0x000F  
+#define IW_RETRY_TYPE 0xF000
+#define IW_RETRY_LIMIT 0x1000
+#define IW_RETRY_LIFETIME 0x2000
+#define IW_RETRY_MODIFIER 0x000F
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IW_RETRY_MIN 0x0001  
-#define IW_RETRY_MAX 0x0002  
-#define IW_RETRY_RELATIVE 0x0004  
-#define IW_SCAN_DEFAULT 0x0000  
+#define IW_RETRY_MIN 0x0001
+#define IW_RETRY_MAX 0x0002
+#define IW_RETRY_RELATIVE 0x0004
+#define IW_SCAN_DEFAULT 0x0000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IW_SCAN_ALL_ESSID 0x0001  
-#define IW_SCAN_THIS_ESSID 0x0002  
-#define IW_SCAN_ALL_FREQ 0x0004  
-#define IW_SCAN_THIS_FREQ 0x0008  
+#define IW_SCAN_ALL_ESSID 0x0001
+#define IW_SCAN_THIS_ESSID 0x0002
+#define IW_SCAN_ALL_FREQ 0x0004
+#define IW_SCAN_THIS_FREQ 0x0008
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IW_SCAN_ALL_MODE 0x0010  
-#define IW_SCAN_THIS_MODE 0x0020  
-#define IW_SCAN_ALL_RATE 0x0040  
-#define IW_SCAN_THIS_RATE 0x0080  
+#define IW_SCAN_ALL_MODE 0x0010
+#define IW_SCAN_THIS_MODE 0x0020
+#define IW_SCAN_ALL_RATE 0x0040
+#define IW_SCAN_THIS_RATE 0x0080
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IW_SCAN_TYPE_ACTIVE 0
 #define IW_SCAN_TYPE_PASSIVE 1
-#define IW_SCAN_MAX_DATA 4096  
-#define IW_CUSTOM_MAX 256  
+#define IW_SCAN_MAX_DATA 4096
+#define IW_CUSTOM_MAX 256
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IW_GENERIC_IE_MAX 1024
 #define IW_MLME_DEAUTH 0
@@ -252,8 +252,8 @@
 #define IW_AUTH_ALG_SHARED_KEY 0x00000002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IW_AUTH_ALG_LEAP 0x00000004
-#define IW_AUTH_ROAMING_ENABLE 0  
-#define IW_AUTH_ROAMING_DISABLE 1  
+#define IW_AUTH_ROAMING_ENABLE 0
+#define IW_AUTH_ROAMING_DISABLE 1
 #define IW_ENCODE_SEQ_MAX_SIZE 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IW_ENCODE_ALG_NONE 0
@@ -266,12 +266,12 @@
 #define IW_ENCODE_EXT_GROUP_KEY 0x00000004
 #define IW_ENCODE_EXT_SET_TX_KEY 0x00000008
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IW_MICFAILURE_KEY_ID 0x00000003  
+#define IW_MICFAILURE_KEY_ID 0x00000003
 #define IW_MICFAILURE_GROUP 0x00000004
 #define IW_MICFAILURE_PAIRWISE 0x00000008
 #define IW_MICFAILURE_STAKEY 0x00000010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IW_MICFAILURE_COUNT 0x00000060  
+#define IW_MICFAILURE_COUNT 0x00000060
 #define IW_ENC_CAPA_WPA 0x00000001
 #define IW_ENC_CAPA_WPA2 0x00000002
 #define IW_ENC_CAPA_CIPHER_TKIP 0x00000004
@@ -398,7 +398,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __u8 tsc[IW_ENCODE_SEQ_MAX_SIZE];
 };
-#define IW_PMKID_CAND_PREAUTH 0x00000001  
+#define IW_PMKID_CAND_PREAUTH 0x00000001
 struct iw_pmkid_cand
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 {
diff --git a/libc/kernel/common/linux/xattr.h b/libc/kernel/common/linux/xattr.h
index dc239fa..adb3232 100644
--- a/libc/kernel/common/linux/xattr.h
+++ b/libc/kernel/common/linux/xattr.h
@@ -18,8 +18,8 @@
  ****************************************************************************/
 #ifndef _LINUX_XATTR_H
 #define _LINUX_XATTR_H
-#define XATTR_CREATE 0x1  
-#define XATTR_REPLACE 0x2  
+#define XATTR_CREATE 0x1
+#define XATTR_REPLACE 0x2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define XATTR_OS2_PREFIX "os2."
 #define XATTR_OS2_PREFIX_LEN (sizeof (XATTR_OS2_PREFIX) - 1)
@@ -33,16 +33,32 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define XATTR_USER_PREFIX "user."
 #define XATTR_USER_PREFIX_LEN (sizeof (XATTR_USER_PREFIX) - 1)
-struct xattr_handler {
- char *prefix;
+#define XATTR_EVM_SUFFIX "evm"
+#define XATTR_NAME_EVM XATTR_SECURITY_PREFIX XATTR_EVM_SUFFIX
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- size_t (*list)(struct inode *inode, char *list, size_t list_size,
- const char *name, size_t name_len);
- int (*get)(struct inode *inode, const char *name, void *buffer,
- size_t size);
+#define XATTR_SELINUX_SUFFIX "selinux"
+#define XATTR_NAME_SELINUX XATTR_SECURITY_PREFIX XATTR_SELINUX_SUFFIX
+#define XATTR_SMACK_SUFFIX "SMACK64"
+#define XATTR_SMACK_IPIN "SMACK64IPIN"
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- int (*set)(struct inode *inode, const char *name, const void *buffer,
- size_t size, int flags);
-};
+#define XATTR_SMACK_IPOUT "SMACK64IPOUT"
+#define XATTR_SMACK_EXEC "SMACK64EXEC"
+#define XATTR_SMACK_TRANSMUTE "SMACK64TRANSMUTE"
+#define XATTR_SMACK_MMAP "SMACK64MMAP"
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define XATTR_NAME_SMACK XATTR_SECURITY_PREFIX XATTR_SMACK_SUFFIX
+#define XATTR_NAME_SMACKIPIN XATTR_SECURITY_PREFIX XATTR_SMACK_IPIN
+#define XATTR_NAME_SMACKIPOUT XATTR_SECURITY_PREFIX XATTR_SMACK_IPOUT
+#define XATTR_NAME_SMACKEXEC XATTR_SECURITY_PREFIX XATTR_SMACK_EXEC
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define XATTR_NAME_SMACKTRANSMUTE XATTR_SECURITY_PREFIX XATTR_SMACK_TRANSMUTE
+#define XATTR_NAME_SMACKMMAP XATTR_SECURITY_PREFIX XATTR_SMACK_MMAP
+#define XATTR_CAPS_SUFFIX "capability"
+#define XATTR_NAME_CAPS XATTR_SECURITY_PREFIX XATTR_CAPS_SUFFIX
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define XATTR_POSIX_ACL_ACCESS "posix_acl_access"
+#define XATTR_NAME_POSIX_ACL_ACCESS XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_ACCESS
+#define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
+#define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/linux/zconf.h b/libc/kernel/common/linux/zconf.h
index 8534969..86e5a4a 100644
--- a/libc/kernel/common/linux/zconf.h
+++ b/libc/kernel/common/linux/zconf.h
@@ -23,7 +23,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #ifndef MAX_WBITS
-#define MAX_WBITS 15  
+#define MAX_WBITS 15
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifndef DEF_WBITS
diff --git a/libc/kernel/common/linux/zlib.h b/libc/kernel/common/linux/zlib.h
index 0fb085a..5c693f2 100644
--- a/libc/kernel/common/linux/zlib.h
+++ b/libc/kernel/common/linux/zlib.h
@@ -41,13 +41,13 @@
 typedef z_stream *z_streamp;
 #define Z_NO_FLUSH 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define Z_PARTIAL_FLUSH 1  
+#define Z_PARTIAL_FLUSH 1
 #define Z_PACKET_FLUSH 2
 #define Z_SYNC_FLUSH 3
 #define Z_FULL_FLUSH 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define Z_FINISH 5
-#define Z_BLOCK 6  
+#define Z_BLOCK 6
 #define Z_OK 0
 #define Z_STREAM_END 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/media/msm_camera.h b/libc/kernel/common/media/msm_camera.h
index db2d234..332ac8a 100644
--- a/libc/kernel/common/media/msm_camera.h
+++ b/libc/kernel/common/media/msm_camera.h
@@ -524,9 +524,9 @@
 #define MCTL_NODE 1
 #define OUTPUT_1 0
 #define OUTPUT_2 1
-#define OUTPUT_1_AND_2 2  
+#define OUTPUT_1_AND_2 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define OUTPUT_1_AND_3 3  
+#define OUTPUT_1_AND_3 3
 #define CAMIF_TO_AXI_VIA_OUTPUT_2 4
 #define OUTPUT_1_AND_CAMIF_TO_AXI_VIA_OUTPUT_2 5
 #define OUTPUT_2_AND_CAMIF_TO_AXI_VIA_OUTPUT_1 6
@@ -914,7 +914,7 @@
 #define CAMERA_SHARPNESS_LV10 30
 #define CAMERA_SETAE_AVERAGE 0
 #define CAMERA_SETAE_CENWEIGHT 1
-#define CAMERA_WB_AUTO 1  
+#define CAMERA_WB_AUTO 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CAMERA_WB_CUSTOM 2
 #define CAMERA_WB_INCANDESCENT 3
@@ -1868,4 +1868,3 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SET_VIDEO_INST_IDX(handle, data)   (handle |= (0x1 << 7) | (data & 0x7F))
 #endif
-
diff --git a/libc/kernel/common/media/msm_gestures.h b/libc/kernel/common/media/msm_gestures.h
index 47163a7..d1e2c28 100644
--- a/libc/kernel/common/media/msm_gestures.h
+++ b/libc/kernel/common/media/msm_gestures.h
@@ -59,4 +59,3 @@
  int evt_len;
 };
 #endif
-
diff --git a/libc/kernel/common/media/msm_isp.h b/libc/kernel/common/media/msm_isp.h
index 5c99fab..93e2659 100644
--- a/libc/kernel/common/media/msm_isp.h
+++ b/libc/kernel/common/media/msm_isp.h
@@ -312,14 +312,14 @@
 #define VPE_CMD_ZOOM 13
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VPE_CMD_MAX 14
-#define MSM_PP_CMD_TYPE_NOT_USED 0  
-#define MSM_PP_CMD_TYPE_VPE 1  
-#define MSM_PP_CMD_TYPE_MCTL 2  
+#define MSM_PP_CMD_TYPE_NOT_USED 0
+#define MSM_PP_CMD_TYPE_VPE 1
+#define MSM_PP_CMD_TYPE_MCTL 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MCTL_CMD_DUMMY_0 0  
-#define MCTL_CMD_GET_FRAME_BUFFER 1  
-#define MCTL_CMD_PUT_FRAME_BUFFER 2  
-#define MCTL_CMD_DIVERT_FRAME_PP_PATH 3  
+#define MCTL_CMD_DUMMY_0 0
+#define MCTL_CMD_GET_FRAME_BUFFER 1
+#define MCTL_CMD_PUT_FRAME_BUFFER 2
+#define MCTL_CMD_DIVERT_FRAME_PP_PATH 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MCTL_PP_EVENT_NOTUSED 0
 #define MCTL_PP_EVENT_CMD_ACK 1
@@ -427,4 +427,3 @@
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-
diff --git a/libc/kernel/common/media/msm_mercury.h b/libc/kernel/common/media/msm_mercury.h
index 2c11d47..3a4599c 100644
--- a/libc/kernel/common/media/msm_mercury.h
+++ b/libc/kernel/common/media/msm_mercury.h
@@ -21,7 +21,7 @@
 #include <linux/types.h>
 #include <linux/ioctl.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSM_MERCURY_HW_VERSION_REG 0x0004  
+#define MSM_MERCURY_HW_VERSION_REG 0x0004
 #define OUTPUT_H2V1 0
 #define OUTPUT_H2V2 1
 #define OUTPUT_BYTE 6
diff --git a/libc/kernel/common/media/ov5650.h b/libc/kernel/common/media/ov5650.h
index e8cef38..6658783 100644
--- a/libc/kernel/common/media/ov5650.h
+++ b/libc/kernel/common/media/ov5650.h
@@ -18,7 +18,7 @@
  ****************************************************************************/
 #ifndef __OV5650_H__
 #define __OV5650_H__
-#include <linux/ioctl.h>  
+#include <linux/ioctl.h>
 #define OV5650_IOCTL_SET_MODE _IOW('o', 1, struct ov5650_mode)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OV5650_IOCTL_SET_FRAME_LENGTH _IOW('o', 2, __u32)
diff --git a/libc/kernel/common/media/soc2030.h b/libc/kernel/common/media/soc2030.h
index b8402ea..d61be36 100644
--- a/libc/kernel/common/media/soc2030.h
+++ b/libc/kernel/common/media/soc2030.h
@@ -18,7 +18,7 @@
  ****************************************************************************/
 #ifndef __SOC2030_H__
 #define __SOC2030_H__
-#include <linux/ioctl.h>  
+#include <linux/ioctl.h>
 #define SOC2030_IOCTL_SET_MODE _IOWR('o', 1, struct soc2030_mode)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SOC2030_IOCTL_GET_STATUS _IOC(_IOC_READ, 'o', 2, 10)
diff --git a/libc/kernel/common/media/v4l2-mediabus.h b/libc/kernel/common/media/v4l2-mediabus.h
index a7e2019..c8960be 100644
--- a/libc/kernel/common/media/v4l2-mediabus.h
+++ b/libc/kernel/common/media/v4l2-mediabus.h
@@ -62,4 +62,3 @@
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-
diff --git a/libc/kernel/common/mtd/mtd-abi.h b/libc/kernel/common/mtd/mtd-abi.h
index 434e3cc..cbbb1ad 100644
--- a/libc/kernel/common/mtd/mtd-abi.h
+++ b/libc/kernel/common/mtd/mtd-abi.h
@@ -37,22 +37,22 @@
 #define MTD_NANDFLASH 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MTD_DATAFLASH 6
-#define MTD_WRITEABLE 0x400  
-#define MTD_BIT_WRITEABLE 0x800  
-#define MTD_NO_ERASE 0x1000  
+#define MTD_WRITEABLE 0x400
+#define MTD_BIT_WRITEABLE 0x800
+#define MTD_NO_ERASE 0x1000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MTD_STUPID_LOCK 0x2000  
+#define MTD_STUPID_LOCK 0x2000
 #define MTD_CAP_ROM 0
 #define MTD_CAP_RAM (MTD_WRITEABLE | MTD_BIT_WRITEABLE | MTD_NO_ERASE)
 #define MTD_CAP_NORFLASH (MTD_WRITEABLE | MTD_BIT_WRITEABLE)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MTD_CAP_NANDFLASH (MTD_WRITEABLE)
-#define MTD_NANDECC_OFF 0 
-#define MTD_NANDECC_PLACE 1 
-#define MTD_NANDECC_AUTOPLACE 2 
+#define MTD_NANDECC_OFF 0
+#define MTD_NANDECC_PLACE 1
+#define MTD_NANDECC_AUTOPLACE 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MTD_NANDECC_PLACEONLY 3 
-#define MTD_NANDECC_AUTOPL_USR 4 
+#define MTD_NANDECC_PLACEONLY 3
+#define MTD_NANDECC_AUTOPL_USR 4
 #define MTD_OTP_OFF 0
 #define MTD_OTP_FACTORY 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/sound/asound.h b/libc/kernel/common/sound/asound.h
index 10c749c..2802693 100644
--- a/libc/kernel/common/sound/asound.h
+++ b/libc/kernel/common/sound/asound.h
@@ -121,12 +121,12 @@
 };
 typedef int __bitwise snd_pcm_access_t;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_PCM_ACCESS_MMAP_INTERLEAVED ((__force snd_pcm_access_t) 0)  
-#define SNDRV_PCM_ACCESS_MMAP_NONINTERLEAVED ((__force snd_pcm_access_t) 1)  
-#define SNDRV_PCM_ACCESS_MMAP_COMPLEX ((__force snd_pcm_access_t) 2)  
-#define SNDRV_PCM_ACCESS_RW_INTERLEAVED ((__force snd_pcm_access_t) 3)  
+#define SNDRV_PCM_ACCESS_MMAP_INTERLEAVED ((__force snd_pcm_access_t) 0)
+#define SNDRV_PCM_ACCESS_MMAP_NONINTERLEAVED ((__force snd_pcm_access_t) 1)
+#define SNDRV_PCM_ACCESS_MMAP_COMPLEX ((__force snd_pcm_access_t) 2)
+#define SNDRV_PCM_ACCESS_RW_INTERLEAVED ((__force snd_pcm_access_t) 3)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_PCM_ACCESS_RW_NONINTERLEAVED ((__force snd_pcm_access_t) 4)  
+#define SNDRV_PCM_ACCESS_RW_NONINTERLEAVED ((__force snd_pcm_access_t) 4)
 #define SNDRV_PCM_ACCESS_LAST SNDRV_PCM_ACCESS_RW_NONINTERLEAVED
 typedef int __bitwise snd_pcm_format_t;
 #define SNDRV_PCM_FORMAT_S8 ((__force snd_pcm_format_t) 0)
@@ -137,23 +137,23 @@
 #define SNDRV_PCM_FORMAT_U16_LE ((__force snd_pcm_format_t) 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_PCM_FORMAT_U16_BE ((__force snd_pcm_format_t) 5)
-#define SNDRV_PCM_FORMAT_S24_LE ((__force snd_pcm_format_t) 6)  
-#define SNDRV_PCM_FORMAT_S24_BE ((__force snd_pcm_format_t) 7)  
-#define SNDRV_PCM_FORMAT_U24_LE ((__force snd_pcm_format_t) 8)  
+#define SNDRV_PCM_FORMAT_S24_LE ((__force snd_pcm_format_t) 6)
+#define SNDRV_PCM_FORMAT_S24_BE ((__force snd_pcm_format_t) 7)
+#define SNDRV_PCM_FORMAT_U24_LE ((__force snd_pcm_format_t) 8)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_PCM_FORMAT_U24_BE ((__force snd_pcm_format_t) 9)  
+#define SNDRV_PCM_FORMAT_U24_BE ((__force snd_pcm_format_t) 9)
 #define SNDRV_PCM_FORMAT_S32_LE ((__force snd_pcm_format_t) 10)
 #define SNDRV_PCM_FORMAT_S32_BE ((__force snd_pcm_format_t) 11)
 #define SNDRV_PCM_FORMAT_U32_LE ((__force snd_pcm_format_t) 12)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_PCM_FORMAT_U32_BE ((__force snd_pcm_format_t) 13)
-#define SNDRV_PCM_FORMAT_FLOAT_LE ((__force snd_pcm_format_t) 14)  
-#define SNDRV_PCM_FORMAT_FLOAT_BE ((__force snd_pcm_format_t) 15)  
-#define SNDRV_PCM_FORMAT_FLOAT64_LE ((__force snd_pcm_format_t) 16)  
+#define SNDRV_PCM_FORMAT_FLOAT_LE ((__force snd_pcm_format_t) 14)
+#define SNDRV_PCM_FORMAT_FLOAT_BE ((__force snd_pcm_format_t) 15)
+#define SNDRV_PCM_FORMAT_FLOAT64_LE ((__force snd_pcm_format_t) 16)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_PCM_FORMAT_FLOAT64_BE ((__force snd_pcm_format_t) 17)  
-#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE ((__force snd_pcm_format_t) 18)  
-#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE ((__force snd_pcm_format_t) 19)  
+#define SNDRV_PCM_FORMAT_FLOAT64_BE ((__force snd_pcm_format_t) 17)
+#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE ((__force snd_pcm_format_t) 18)
+#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE ((__force snd_pcm_format_t) 19)
 #define SNDRV_PCM_FORMAT_MU_LAW ((__force snd_pcm_format_t) 20)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_PCM_FORMAT_A_LAW ((__force snd_pcm_format_t) 21)
@@ -162,21 +162,21 @@
 #define SNDRV_PCM_FORMAT_GSM ((__force snd_pcm_format_t) 24)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_PCM_FORMAT_SPECIAL ((__force snd_pcm_format_t) 31)
-#define SNDRV_PCM_FORMAT_S24_3LE ((__force snd_pcm_format_t) 32)  
-#define SNDRV_PCM_FORMAT_S24_3BE ((__force snd_pcm_format_t) 33)  
-#define SNDRV_PCM_FORMAT_U24_3LE ((__force snd_pcm_format_t) 34)  
+#define SNDRV_PCM_FORMAT_S24_3LE ((__force snd_pcm_format_t) 32)
+#define SNDRV_PCM_FORMAT_S24_3BE ((__force snd_pcm_format_t) 33)
+#define SNDRV_PCM_FORMAT_U24_3LE ((__force snd_pcm_format_t) 34)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_PCM_FORMAT_U24_3BE ((__force snd_pcm_format_t) 35)  
-#define SNDRV_PCM_FORMAT_S20_3LE ((__force snd_pcm_format_t) 36)  
-#define SNDRV_PCM_FORMAT_S20_3BE ((__force snd_pcm_format_t) 37)  
-#define SNDRV_PCM_FORMAT_U20_3LE ((__force snd_pcm_format_t) 38)  
+#define SNDRV_PCM_FORMAT_U24_3BE ((__force snd_pcm_format_t) 35)
+#define SNDRV_PCM_FORMAT_S20_3LE ((__force snd_pcm_format_t) 36)
+#define SNDRV_PCM_FORMAT_S20_3BE ((__force snd_pcm_format_t) 37)
+#define SNDRV_PCM_FORMAT_U20_3LE ((__force snd_pcm_format_t) 38)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_PCM_FORMAT_U20_3BE ((__force snd_pcm_format_t) 39)  
-#define SNDRV_PCM_FORMAT_S18_3LE ((__force snd_pcm_format_t) 40)  
-#define SNDRV_PCM_FORMAT_S18_3BE ((__force snd_pcm_format_t) 41)  
-#define SNDRV_PCM_FORMAT_U18_3LE ((__force snd_pcm_format_t) 42)  
+#define SNDRV_PCM_FORMAT_U20_3BE ((__force snd_pcm_format_t) 39)
+#define SNDRV_PCM_FORMAT_S18_3LE ((__force snd_pcm_format_t) 40)
+#define SNDRV_PCM_FORMAT_S18_3BE ((__force snd_pcm_format_t) 41)
+#define SNDRV_PCM_FORMAT_U18_3LE ((__force snd_pcm_format_t) 42)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_PCM_FORMAT_U18_3BE ((__force snd_pcm_format_t) 43)  
+#define SNDRV_PCM_FORMAT_U18_3BE ((__force snd_pcm_format_t) 43)
 #define SNDRV_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_U18_3BE
 #ifdef SNDRV_LITTLE_ENDIAN
 #define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_LE
@@ -209,37 +209,37 @@
 typedef int __bitwise snd_pcm_subformat_t;
 #define SNDRV_PCM_SUBFORMAT_STD ((__force snd_pcm_subformat_t) 0)
 #define SNDRV_PCM_SUBFORMAT_LAST SNDRV_PCM_SUBFORMAT_STD
-#define SNDRV_PCM_INFO_MMAP 0x00000001  
+#define SNDRV_PCM_INFO_MMAP 0x00000001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_PCM_INFO_MMAP_VALID 0x00000002  
-#define SNDRV_PCM_INFO_DOUBLE 0x00000004  
-#define SNDRV_PCM_INFO_BATCH 0x00000010  
-#define SNDRV_PCM_INFO_INTERLEAVED 0x00000100  
+#define SNDRV_PCM_INFO_MMAP_VALID 0x00000002
+#define SNDRV_PCM_INFO_DOUBLE 0x00000004
+#define SNDRV_PCM_INFO_BATCH 0x00000010
+#define SNDRV_PCM_INFO_INTERLEAVED 0x00000100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_PCM_INFO_NONINTERLEAVED 0x00000200  
-#define SNDRV_PCM_INFO_COMPLEX 0x00000400  
-#define SNDRV_PCM_INFO_BLOCK_TRANSFER 0x00010000  
-#define SNDRV_PCM_INFO_OVERRANGE 0x00020000  
+#define SNDRV_PCM_INFO_NONINTERLEAVED 0x00000200
+#define SNDRV_PCM_INFO_COMPLEX 0x00000400
+#define SNDRV_PCM_INFO_BLOCK_TRANSFER 0x00010000
+#define SNDRV_PCM_INFO_OVERRANGE 0x00020000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_PCM_INFO_RESUME 0x00040000  
-#define SNDRV_PCM_INFO_PAUSE 0x00080000  
-#define SNDRV_PCM_INFO_HALF_DUPLEX 0x00100000  
-#define SNDRV_PCM_INFO_JOINT_DUPLEX 0x00200000  
+#define SNDRV_PCM_INFO_RESUME 0x00040000
+#define SNDRV_PCM_INFO_PAUSE 0x00080000
+#define SNDRV_PCM_INFO_HALF_DUPLEX 0x00100000
+#define SNDRV_PCM_INFO_JOINT_DUPLEX 0x00200000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_PCM_INFO_SYNC_START 0x00400000  
-#define SNDRV_PCM_INFO_FIFO_IN_FRAMES 0x80000000  
+#define SNDRV_PCM_INFO_SYNC_START 0x00400000
+#define SNDRV_PCM_INFO_FIFO_IN_FRAMES 0x80000000
 typedef int __bitwise snd_pcm_state_t;
-#define SNDRV_PCM_STATE_OPEN ((__force snd_pcm_state_t) 0)  
+#define SNDRV_PCM_STATE_OPEN ((__force snd_pcm_state_t) 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_PCM_STATE_SETUP ((__force snd_pcm_state_t) 1)  
-#define SNDRV_PCM_STATE_PREPARED ((__force snd_pcm_state_t) 2)  
-#define SNDRV_PCM_STATE_RUNNING ((__force snd_pcm_state_t) 3)  
-#define SNDRV_PCM_STATE_XRUN ((__force snd_pcm_state_t) 4)  
+#define SNDRV_PCM_STATE_SETUP ((__force snd_pcm_state_t) 1)
+#define SNDRV_PCM_STATE_PREPARED ((__force snd_pcm_state_t) 2)
+#define SNDRV_PCM_STATE_RUNNING ((__force snd_pcm_state_t) 3)
+#define SNDRV_PCM_STATE_XRUN ((__force snd_pcm_state_t) 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_PCM_STATE_DRAINING ((__force snd_pcm_state_t) 5)  
-#define SNDRV_PCM_STATE_PAUSED ((__force snd_pcm_state_t) 6)  
-#define SNDRV_PCM_STATE_SUSPENDED ((__force snd_pcm_state_t) 7)  
-#define SNDRV_PCM_STATE_DISCONNECTED ((__force snd_pcm_state_t) 8)  
+#define SNDRV_PCM_STATE_DRAINING ((__force snd_pcm_state_t) 5)
+#define SNDRV_PCM_STATE_PAUSED ((__force snd_pcm_state_t) 6)
+#define SNDRV_PCM_STATE_SUSPENDED ((__force snd_pcm_state_t) 7)
+#define SNDRV_PCM_STATE_DISCONNECTED ((__force snd_pcm_state_t) 8)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_PCM_STATE_LAST SNDRV_PCM_STATE_DISCONNECTED
 enum {
@@ -274,31 +274,31 @@
  unsigned char reserved[64];
 };
 typedef int snd_pcm_hw_param_t;
-#define SNDRV_PCM_HW_PARAM_ACCESS 0  
+#define SNDRV_PCM_HW_PARAM_ACCESS 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_PCM_HW_PARAM_FORMAT 1  
-#define SNDRV_PCM_HW_PARAM_SUBFORMAT 2  
+#define SNDRV_PCM_HW_PARAM_FORMAT 1
+#define SNDRV_PCM_HW_PARAM_SUBFORMAT 2
 #define SNDRV_PCM_HW_PARAM_FIRST_MASK SNDRV_PCM_HW_PARAM_ACCESS
 #define SNDRV_PCM_HW_PARAM_LAST_MASK SNDRV_PCM_HW_PARAM_SUBFORMAT
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_PCM_HW_PARAM_SAMPLE_BITS 8  
-#define SNDRV_PCM_HW_PARAM_FRAME_BITS 9  
-#define SNDRV_PCM_HW_PARAM_CHANNELS 10  
-#define SNDRV_PCM_HW_PARAM_RATE 11  
+#define SNDRV_PCM_HW_PARAM_SAMPLE_BITS 8
+#define SNDRV_PCM_HW_PARAM_FRAME_BITS 9
+#define SNDRV_PCM_HW_PARAM_CHANNELS 10
+#define SNDRV_PCM_HW_PARAM_RATE 11
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_PCM_HW_PARAM_PERIOD_TIME 12  
-#define SNDRV_PCM_HW_PARAM_PERIOD_SIZE 13  
-#define SNDRV_PCM_HW_PARAM_PERIOD_BYTES 14  
-#define SNDRV_PCM_HW_PARAM_PERIODS 15  
+#define SNDRV_PCM_HW_PARAM_PERIOD_TIME 12
+#define SNDRV_PCM_HW_PARAM_PERIOD_SIZE 13
+#define SNDRV_PCM_HW_PARAM_PERIOD_BYTES 14
+#define SNDRV_PCM_HW_PARAM_PERIODS 15
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_PCM_HW_PARAM_BUFFER_TIME 16  
-#define SNDRV_PCM_HW_PARAM_BUFFER_SIZE 17  
-#define SNDRV_PCM_HW_PARAM_BUFFER_BYTES 18  
-#define SNDRV_PCM_HW_PARAM_TICK_TIME 19  
+#define SNDRV_PCM_HW_PARAM_BUFFER_TIME 16
+#define SNDRV_PCM_HW_PARAM_BUFFER_SIZE 17
+#define SNDRV_PCM_HW_PARAM_BUFFER_BYTES 18
+#define SNDRV_PCM_HW_PARAM_TICK_TIME 19
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_PCM_HW_PARAM_FIRST_INTERVAL SNDRV_PCM_HW_PARAM_SAMPLE_BITS
 #define SNDRV_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_TICK_TIME
-#define SNDRV_PCM_HW_PARAMS_NORESAMPLE (1<<0)  
+#define SNDRV_PCM_HW_PARAMS_NORESAMPLE (1<<0)
 struct snd_interval {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned int min, max;
@@ -394,10 +394,10 @@
  snd_pcm_uframes_t appl_ptr;
  snd_pcm_uframes_t avail_min;
 };
-#define SNDRV_PCM_SYNC_PTR_HWSYNC (1<<0)  
+#define SNDRV_PCM_SYNC_PTR_HWSYNC (1<<0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_PCM_SYNC_PTR_APPL (1<<1)  
-#define SNDRV_PCM_SYNC_PTR_AVAIL_MIN (1<<2)  
+#define SNDRV_PCM_SYNC_PTR_APPL (1<<1)
+#define SNDRV_PCM_SYNC_PTR_AVAIL_MIN (1<<2)
 struct snd_pcm_sync_ptr {
  unsigned int flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -544,7 +544,7 @@
 #define SNDRV_TIMER_GLOBAL_RTC 1
 #define SNDRV_TIMER_GLOBAL_HPET 2
 #define SNDRV_TIMER_GLOBAL_HRTIMER 3
-#define SNDRV_TIMER_FLG_SLAVE (1<<0)  
+#define SNDRV_TIMER_FLG_SLAVE (1<<0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct snd_timer_id {
  int dev_class;
@@ -603,10 +603,10 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned char reserved[64];
 };
-#define SNDRV_TIMER_PSFLG_AUTO (1<<0)  
-#define SNDRV_TIMER_PSFLG_EXCLUSIVE (1<<1)  
+#define SNDRV_TIMER_PSFLG_AUTO (1<<0)
+#define SNDRV_TIMER_PSFLG_EXCLUSIVE (1<<1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_TIMER_PSFLG_EARLY_EVENT (1<<2)  
+#define SNDRV_TIMER_PSFLG_EARLY_EVENT (1<<2)
 struct snd_timer_params {
  unsigned int flags;
  unsigned int ticks;
@@ -693,52 +693,52 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 typedef int __bitwise snd_ctl_elem_type_t;
-#define SNDRV_CTL_ELEM_TYPE_NONE ((__force snd_ctl_elem_type_t) 0)  
-#define SNDRV_CTL_ELEM_TYPE_BOOLEAN ((__force snd_ctl_elem_type_t) 1)  
+#define SNDRV_CTL_ELEM_TYPE_NONE ((__force snd_ctl_elem_type_t) 0)
+#define SNDRV_CTL_ELEM_TYPE_BOOLEAN ((__force snd_ctl_elem_type_t) 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_CTL_ELEM_TYPE_INTEGER ((__force snd_ctl_elem_type_t) 2)  
-#define SNDRV_CTL_ELEM_TYPE_ENUMERATED ((__force snd_ctl_elem_type_t) 3)  
-#define SNDRV_CTL_ELEM_TYPE_BYTES ((__force snd_ctl_elem_type_t) 4)  
-#define SNDRV_CTL_ELEM_TYPE_IEC958 ((__force snd_ctl_elem_type_t) 5)  
+#define SNDRV_CTL_ELEM_TYPE_INTEGER ((__force snd_ctl_elem_type_t) 2)
+#define SNDRV_CTL_ELEM_TYPE_ENUMERATED ((__force snd_ctl_elem_type_t) 3)
+#define SNDRV_CTL_ELEM_TYPE_BYTES ((__force snd_ctl_elem_type_t) 4)
+#define SNDRV_CTL_ELEM_TYPE_IEC958 ((__force snd_ctl_elem_type_t) 5)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_CTL_ELEM_TYPE_INTEGER64 ((__force snd_ctl_elem_type_t) 6)  
+#define SNDRV_CTL_ELEM_TYPE_INTEGER64 ((__force snd_ctl_elem_type_t) 6)
 #define SNDRV_CTL_ELEM_TYPE_LAST SNDRV_CTL_ELEM_TYPE_INTEGER64
 typedef int __bitwise snd_ctl_elem_iface_t;
-#define SNDRV_CTL_ELEM_IFACE_CARD ((__force snd_ctl_elem_iface_t) 0)  
+#define SNDRV_CTL_ELEM_IFACE_CARD ((__force snd_ctl_elem_iface_t) 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_CTL_ELEM_IFACE_HWDEP ((__force snd_ctl_elem_iface_t) 1)  
-#define SNDRV_CTL_ELEM_IFACE_MIXER ((__force snd_ctl_elem_iface_t) 2)  
-#define SNDRV_CTL_ELEM_IFACE_PCM ((__force snd_ctl_elem_iface_t) 3)  
-#define SNDRV_CTL_ELEM_IFACE_RAWMIDI ((__force snd_ctl_elem_iface_t) 4)  
+#define SNDRV_CTL_ELEM_IFACE_HWDEP ((__force snd_ctl_elem_iface_t) 1)
+#define SNDRV_CTL_ELEM_IFACE_MIXER ((__force snd_ctl_elem_iface_t) 2)
+#define SNDRV_CTL_ELEM_IFACE_PCM ((__force snd_ctl_elem_iface_t) 3)
+#define SNDRV_CTL_ELEM_IFACE_RAWMIDI ((__force snd_ctl_elem_iface_t) 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_CTL_ELEM_IFACE_TIMER ((__force snd_ctl_elem_iface_t) 5)  
-#define SNDRV_CTL_ELEM_IFACE_SEQUENCER ((__force snd_ctl_elem_iface_t) 6)  
+#define SNDRV_CTL_ELEM_IFACE_TIMER ((__force snd_ctl_elem_iface_t) 5)
+#define SNDRV_CTL_ELEM_IFACE_SEQUENCER ((__force snd_ctl_elem_iface_t) 6)
 #define SNDRV_CTL_ELEM_IFACE_LAST SNDRV_CTL_ELEM_IFACE_SEQUENCER
 #define SNDRV_CTL_ELEM_ACCESS_READ (1<<0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_CTL_ELEM_ACCESS_WRITE (1<<1)
 #define SNDRV_CTL_ELEM_ACCESS_READWRITE (SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE)
-#define SNDRV_CTL_ELEM_ACCESS_VOLATILE (1<<2)  
-#define SNDRV_CTL_ELEM_ACCESS_TIMESTAMP (1<<3)  
+#define SNDRV_CTL_ELEM_ACCESS_VOLATILE (1<<2)
+#define SNDRV_CTL_ELEM_ACCESS_TIMESTAMP (1<<3)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_CTL_ELEM_ACCESS_TLV_READ (1<<4)  
-#define SNDRV_CTL_ELEM_ACCESS_TLV_WRITE (1<<5)  
+#define SNDRV_CTL_ELEM_ACCESS_TLV_READ (1<<4)
+#define SNDRV_CTL_ELEM_ACCESS_TLV_WRITE (1<<5)
 #define SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE (SNDRV_CTL_ELEM_ACCESS_TLV_READ|SNDRV_CTL_ELEM_ACCESS_TLV_WRITE)
-#define SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND (1<<6)  
+#define SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND (1<<6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_CTL_ELEM_ACCESS_INACTIVE (1<<8)  
-#define SNDRV_CTL_ELEM_ACCESS_LOCK (1<<9)  
-#define SNDRV_CTL_ELEM_ACCESS_OWNER (1<<10)  
-#define SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK (1<<28)   
+#define SNDRV_CTL_ELEM_ACCESS_INACTIVE (1<<8)
+#define SNDRV_CTL_ELEM_ACCESS_LOCK (1<<9)
+#define SNDRV_CTL_ELEM_ACCESS_OWNER (1<<10)
+#define SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK (1<<28)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_CTL_ELEM_ACCESS_USER (1<<29)  
-#define SNDRV_CTL_POWER_D0 0x0000  
-#define SNDRV_CTL_POWER_D1 0x0100  
-#define SNDRV_CTL_POWER_D2 0x0200  
+#define SNDRV_CTL_ELEM_ACCESS_USER (1<<29)
+#define SNDRV_CTL_POWER_D0 0x0000
+#define SNDRV_CTL_POWER_D1 0x0100
+#define SNDRV_CTL_POWER_D2 0x0200
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_CTL_POWER_D3 0x0300  
-#define SNDRV_CTL_POWER_D3hot (SNDRV_CTL_POWER_D3|0x0000)  
-#define SNDRV_CTL_POWER_D3cold (SNDRV_CTL_POWER_D3|0x0001)  
+#define SNDRV_CTL_POWER_D3 0x0300
+#define SNDRV_CTL_POWER_D3hot (SNDRV_CTL_POWER_D3|0x0000)
+#define SNDRV_CTL_POWER_D3cold (SNDRV_CTL_POWER_D3|0x0001)
 struct snd_ctl_elem_id {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned int numid;
@@ -871,12 +871,12 @@
  SNDRV_CTL_EVENT_LAST = SNDRV_CTL_EVENT_ELEM,
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_CTL_EVENT_MASK_VALUE (1<<0)  
-#define SNDRV_CTL_EVENT_MASK_INFO (1<<1)  
-#define SNDRV_CTL_EVENT_MASK_ADD (1<<2)  
-#define SNDRV_CTL_EVENT_MASK_TLV (1<<3)  
+#define SNDRV_CTL_EVENT_MASK_VALUE (1<<0)
+#define SNDRV_CTL_EVENT_MASK_INFO (1<<1)
+#define SNDRV_CTL_EVENT_MASK_ADD (1<<2)
+#define SNDRV_CTL_EVENT_MASK_TLV (1<<3)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_CTL_EVENT_MASK_REMOVE (~0U)  
+#define SNDRV_CTL_EVENT_MASK_REMOVE (~0U)
 struct snd_ctl_event {
  int type;
  union {
diff --git a/libc/kernel/common/sound/tlv.h b/libc/kernel/common/sound/tlv.h
index 9e8d5b9..33c96d6 100644
--- a/libc/kernel/common/sound/tlv.h
+++ b/libc/kernel/common/sound/tlv.h
@@ -18,13 +18,13 @@
  ****************************************************************************/
 #ifndef __SOUND_TLV_H
 #define __SOUND_TLV_H
-#define SNDRV_CTL_TLVT_CONTAINER 0  
-#define SNDRV_CTL_TLVT_DB_SCALE 1  
+#define SNDRV_CTL_TLVT_CONTAINER 0
+#define SNDRV_CTL_TLVT_DB_SCALE 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SNDRV_CTL_TLVT_DB_LINEAR 2  
-#define SNDRV_CTL_TLVT_DB_RANGE 3  
-#define SNDRV_CTL_TLVT_DB_MINMAX 4  
-#define SNDRV_CTL_TLVT_DB_MINMAX_MUTE 5  
+#define SNDRV_CTL_TLVT_DB_LINEAR 2
+#define SNDRV_CTL_TLVT_DB_RANGE 3
+#define SNDRV_CTL_TLVT_DB_MINMAX 4
+#define SNDRV_CTL_TLVT_DB_MINMAX_MUTE 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TLV_DB_SCALE_MASK 0xffff
 #define TLV_DB_SCALE_MUTE 0x10000
@@ -42,4 +42,3 @@
 #define TLV_DB_GAIN_MUTE -9999999
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-
diff --git a/libc/kernel/common/uapi/linux/auxvec.h b/libc/kernel/common/uapi/linux/auxvec.h
new file mode 100644
index 0000000..54b76e9
--- /dev/null
+++ b/libc/kernel/common/uapi/linux/auxvec.h
@@ -0,0 +1,50 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ***   To edit the content of this header, modify the corresponding
+ ***   source file (e.g. under external/kernel-headers/original/) then
+ ***   run bionic/libc/kernel/tools/update_all.py
+ ***
+ ***   Any manual change here will be lost the next time this script will
+ ***   be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _UAPI_LINUX_AUXVEC_H
+#define _UAPI_LINUX_AUXVEC_H
+#include <asm/auxvec.h>
+#define AT_NULL 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AT_IGNORE 1
+#define AT_EXECFD 2
+#define AT_PHDR 3
+#define AT_PHENT 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AT_PHNUM 5
+#define AT_PAGESZ 6
+#define AT_BASE 7
+#define AT_FLAGS 8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AT_ENTRY 9
+#define AT_NOTELF 10
+#define AT_UID 11
+#define AT_EUID 12
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AT_GID 13
+#define AT_EGID 14
+#define AT_PLATFORM 15
+#define AT_HWCAP 16
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AT_CLKTCK 17
+#define AT_SECURE 23
+#define AT_BASE_PLATFORM 24
+#define AT_RANDOM 25
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AT_EXECFN 31
+#endif
diff --git a/libc/kernel/tools/clean_header.py b/libc/kernel/tools/clean_header.py
index 01569fc..1a5471a 100755
--- a/libc/kernel/tools/clean_header.py
+++ b/libc/kernel/tools/clean_header.py
@@ -66,6 +66,9 @@
     if arch and arch in kernel_default_arch_macros:
         macros.update(kernel_default_arch_macros[arch])
 
+    if arch and arch in kernel_arch_token_replacements:
+        blocks.replaceTokens( kernel_arch_token_replacements[arch] )
+
     blocks.optimizeMacros( macros )
     blocks.optimizeIf01()
     blocks.removeVarsAndFuncs( statics )
diff --git a/libc/kernel/tools/cpp.py b/libc/kernel/tools/cpp.py
index 8e15a67..b8aa775 100644
--- a/libc/kernel/tools/cpp.py
+++ b/libc/kernel/tools/cpp.py
@@ -1676,7 +1676,7 @@
             return left_count
 
         if self.directive:
-            out.write(str(self) + "\n")
+            out.write(str(self).rstrip() + "\n")
             left_count -= 1
             if left_count == 0:
                 out.write(warning)
@@ -1756,7 +1756,7 @@
         for b in self.blocks:
             result += str(b)
             if b.isDirective():
-                result += '\n'
+                result = result.rstrip() + '\n'
         return result
 
     def  optimizeIf01(self):
diff --git a/libc/kernel/tools/defaults.py b/libc/kernel/tools/defaults.py
index 7eeffb4..da02481 100644
--- a/libc/kernel/tools/defaults.py
+++ b/libc/kernel/tools/defaults.py
@@ -48,9 +48,15 @@
     "mips": {"CONFIG_32BIT":"1"},
     }
 
+kernel_arch_token_replacements = {
+    "arm": {},
+    "x86": {},
+    "mips": {"off_t":"__kernel_off_t"},
+    }
 # Replace tokens in the output according to this mapping
 kernel_token_replacements = {
     "asm": "__asm__",
+    "__unused": "__linux_unused", # The kernel usage of __unused conflicts with the macro defined in sys/cdefs.h
     }
 
 # this is the set of known static inline functions that we want to keep
diff --git a/libc/kernel/tools/update_all.py b/libc/kernel/tools/update_all.py
index badef92..3f1d1e6 100755
--- a/libc/kernel/tools/update_all.py
+++ b/libc/kernel/tools/update_all.py
@@ -16,11 +16,6 @@
 
       - the clean headers will be placed in '../arch-<arch>/asm',
         '../common/linux', '../common/asm-generic', etc..
-
-      - if ANDROID_PRODUCT_OUT is defined in your environment, you're
-        using the Android build system, and the program will issue
-        p4 add / edit / delete commands to update the depot for you.
-        (you'll need to p4 submit manually though)
 """ % { "progname" : os.path.basename(sys.argv[0]) }
     sys.exit(0)
 
diff --git a/libc/kernel/tools/utils.py b/libc/kernel/tools/utils.py
index f4cf540..e2820d1 100644
--- a/libc/kernel/tools/utils.py
+++ b/libc/kernel/tools/utils.py
@@ -184,17 +184,6 @@
         fp.close()
 
 
-class Output:
-    def  __init__(self,out=sys.stdout):
-        self.out = out
-
-    def write(self,msg):
-        self.out.write(msg)
-
-    def writeln(self,msg):
-        self.out.write(msg)
-        self.out.write("\n")
-
 class StringOutput:
     def __init__(self):
         self.line = ""
@@ -203,10 +192,6 @@
         self.line += msg
         D2("write '%s'" % msg)
 
-    def writeln(self,msg):
-        self.line += msg + '\n'
-        D2("write '%s\\n'"% msg)
-
     def get(self):
         return self.line
 
@@ -356,11 +341,9 @@
 
         return (adds, deletes, edits)
 
-    def _writeFile(self,dst,data=None):
+    def _writeFile(self,dst):
         if not os.path.exists(os.path.dirname(dst)):
             create_file_path(dst)
-        if data == None:
-            data = self.new_data[dst]
         f = open(dst, "w")
         f.write(self.new_data[dst])
         f.close()
@@ -377,34 +360,6 @@
         for dst in sorted(deletes):
             os.remove(dst)
 
-    def updateP4Files(self):
-        adds, deletes, edits = self.getChanges()
-
-        if len(adds):
-            files = string.join(sorted(adds)," ")
-            D( "%d new files will be p4 add-ed" % len(adds) )
-            for dst in adds:
-                self._writeFile(dst)
-            D2("P4 ADDS: %s" % files)
-            o = commands.getoutput( "p4 add " + files )
-            D2( o )
-
-        if len(edits):
-            files = string.join(sorted(edits)," ")
-            D( "%d files will be p4 edit-ed" % len(edits) )
-            D2("P4 EDITS: %s" % files)
-            o = commands.getoutput( "p4 edit " + files )
-            D2( o )
-            for dst in edits:
-                self._writeFile(dst)
-
-        if len(deletes):
-            files = string.join(sorted(deletes)," ")
-            D( "%d files will be p4 delete-d" % len(deletes) )
-            D2("P4 DELETES: %s" % files)
-            o = commands.getoutput( "p4 delete " + files )
-            D2( o )
-
     def updateGitFiles(self):
         adds, deletes, edits = self.getChanges()
 
diff --git a/libc/netbsd/isc/ev_streams.c b/libc/netbsd/isc/ev_streams.c
deleted file mode 100644
index aeecc3e..0000000
--- a/libc/netbsd/isc/ev_streams.c
+++ /dev/null
@@ -1,311 +0,0 @@
-/*	$NetBSD: ev_streams.c,v 1.2 2004/05/20 19:52:31 christos Exp $	*/
-
-/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1996-1999 by Internet Software Consortium
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/* ev_streams.c - implement asynch stream file IO for the eventlib
- * vix 04mar96 [initial]
- */
-
-#include <sys/cdefs.h>
-#if !defined(LINT) && !defined(CODECENTER) && !defined(lint)
-#ifdef notdef
-static const char rcsid[] = "Id: ev_streams.c,v 1.2.206.2 2004/03/17 00:29:51 marka Exp";
-#else
-__RCSID("$NetBSD: ev_streams.c,v 1.2 2004/05/20 19:52:31 christos Exp $");
-#endif
-#endif
-
-#include <sys/types.h>
-#include <sys/uio.h>
-
-#include <errno.h>
-
-#include <isc/eventlib.h>
-#include "eventlib_p.h"
-
-#ifndef _LIBC
-static int	copyvec(evStream *str, const struct iovec *iov, int iocnt);
-static void	consume(evStream *str, size_t bytes);
-static void	done(evContext opaqueCtx, evStream *str);
-static void	writable(evContext opaqueCtx, void *uap, int fd, int evmask);
-static void	readable(evContext opaqueCtx, void *uap, int fd, int evmask);
-#endif
-
-struct iovec
-evConsIovec(void *buf, size_t cnt) {
-	struct iovec ret;
-
-	memset(&ret, 0xf5, sizeof ret);
-	ret.iov_base = buf;
-	ret.iov_len = cnt;
-	return (ret);
-}
-
-#ifndef _LIBC
-int
-evWrite(evContext opaqueCtx, int fd, const struct iovec *iov, int iocnt,
-	evStreamFunc func, void *uap, evStreamID *id)
-{
-	evContext_p *ctx = opaqueCtx.opaque;
-	evStream *new;
-	int save;
-
-	OKNEW(new);
-	new->func = func;
-	new->uap = uap;
-	new->fd = fd;
-	new->flags = 0;
-	if (evSelectFD(opaqueCtx, fd, EV_WRITE, writable, new, &new->file) < 0)
-		goto free;
-	if (copyvec(new, iov, iocnt) < 0)
-		goto free;
-	new->prevDone = NULL;
-	new->nextDone = NULL;
-	if (ctx->streams != NULL)
-		ctx->streams->prev = new;
-	new->prev = NULL;
-	new->next = ctx->streams;
-	ctx->streams = new;
-	if (id != NULL)
-		id->opaque = new;
-	return (0);
- free:
-	save = errno;
-	FREE(new);
-	errno = save;
-	return (-1);
-}
-
-int
-evRead(evContext opaqueCtx, int fd, const struct iovec *iov, int iocnt,
-       evStreamFunc func, void *uap, evStreamID *id)
-{
-	evContext_p *ctx = opaqueCtx.opaque;
-	evStream *new;
-	int save;
-
-	OKNEW(new);
-	new->func = func;
-	new->uap = uap;
-	new->fd = fd;
-	new->flags = 0;
-	if (evSelectFD(opaqueCtx, fd, EV_READ, readable, new, &new->file) < 0)
-		goto free;
-	if (copyvec(new, iov, iocnt) < 0)
-		goto free;
-	new->prevDone = NULL;
-	new->nextDone = NULL;
-	if (ctx->streams != NULL)
-		ctx->streams->prev = new;
-	new->prev = NULL;
-	new->next = ctx->streams;
-	ctx->streams = new;
-	if (id)
-		id->opaque = new;
-	return (0);
- free:
-	save = errno;
-	FREE(new);
-	errno = save;
-	return (-1);
-}
-
-int
-evTimeRW(evContext opaqueCtx, evStreamID id, evTimerID timer) /*ARGSUSED*/ {
-	evStream *str = id.opaque;
-
-	UNUSED(opaqueCtx);
-
-	str->timer = timer;
-	str->flags |= EV_STR_TIMEROK;
-	return (0);
-}
-
-int
-evUntimeRW(evContext opaqueCtx, evStreamID id) /*ARGSUSED*/ {
-	evStream *str = id.opaque;
-
-	UNUSED(opaqueCtx);
-
-	str->flags &= ~EV_STR_TIMEROK;
-	return (0);
-}
-
-int
-evCancelRW(evContext opaqueCtx, evStreamID id) {
-	evContext_p *ctx = opaqueCtx.opaque;
-	evStream *old = id.opaque;
-
-	/*
-	 * The streams list is doubly threaded.  First, there's ctx->streams
-	 * that's used by evDestroy() to find and cancel all streams.  Second,
-	 * there's ctx->strDone (head) and ctx->strLast (tail) which thread
-	 * through the potentially smaller number of "IO completed" streams,
-	 * used in evGetNext() to avoid scanning the entire list.
-	 */
-
-	/* Unlink from ctx->streams. */
-	if (old->prev != NULL)
-		old->prev->next = old->next;
-	else
-		ctx->streams = old->next;
-	if (old->next != NULL)
-		old->next->prev = old->prev;
-
-	/*
-	 * If 'old' is on the ctx->strDone list, remove it.  Update
-	 * ctx->strLast if necessary.
-	 */
-	if (old->prevDone == NULL && old->nextDone == NULL) {
-		/*
-		 * Either 'old' is the only item on the done list, or it's
-		 * not on the done list.  If the former, then we unlink it
-		 * from the list.  If the latter, we leave the list alone.
-		 */
-		if (ctx->strDone == old) {
-			ctx->strDone = NULL;
-			ctx->strLast = NULL;
-		}
-	} else {
-		if (old->prevDone != NULL)
-			old->prevDone->nextDone = old->nextDone;
-		else
-			ctx->strDone = old->nextDone;
-		if (old->nextDone != NULL)
-			old->nextDone->prevDone = old->prevDone;
-		else
-			ctx->strLast = old->prevDone;
-	}
-
-	/* Deallocate the stream. */
-	if (old->file.opaque)
-		evDeselectFD(opaqueCtx, old->file);
-	memput(old->iovOrig, sizeof (struct iovec) * old->iovOrigCount);
-	FREE(old);
-	return (0);
-}
-
-/* Copy a scatter/gather vector and initialize a stream handler's IO. */
-static int
-copyvec(evStream *str, const struct iovec *iov, int iocnt) {
-	int i;
-
-	str->iovOrig = (struct iovec *)memget(sizeof(struct iovec) * iocnt);
-	if (str->iovOrig == NULL) {
-		errno = ENOMEM;
-		return (-1);
-	}
-	str->ioTotal = 0;
-	for (i = 0; i < iocnt; i++) {
-		str->iovOrig[i] = iov[i];
-		str->ioTotal += iov[i].iov_len;
-	}
-	str->iovOrigCount = iocnt;
-	str->iovCur = str->iovOrig;
-	str->iovCurCount = str->iovOrigCount;
-	str->ioDone = 0;
-	return (0);
-}
-
-/* Pull off or truncate lead iovec(s). */
-static void
-consume(evStream *str, size_t bytes) {
-	while (bytes > 0U) {
-		if (bytes < (size_t)str->iovCur->iov_len) {
-			str->iovCur->iov_len -= bytes;
-			str->iovCur->iov_base = (void *)
-				((u_char *)str->iovCur->iov_base + bytes);
-			str->ioDone += bytes;
-			bytes = 0;
-		} else {
-			bytes -= str->iovCur->iov_len;
-			str->ioDone += str->iovCur->iov_len;
-			str->iovCur++;
-			str->iovCurCount--;
-		}
-	}
-}
-
-/* Add a stream to Done list and deselect the FD. */
-static void
-done(evContext opaqueCtx, evStream *str) {
-	evContext_p *ctx = opaqueCtx.opaque;
-
-	if (ctx->strLast != NULL) {
-		str->prevDone = ctx->strLast;
-		ctx->strLast->nextDone = str;
-		ctx->strLast = str;
-	} else {
-		INSIST(ctx->strDone == NULL);
-		ctx->strDone = ctx->strLast = str;
-	}
-	evDeselectFD(opaqueCtx, str->file);
-	str->file.opaque = NULL;
-	/* evDrop() will call evCancelRW() on us. */
-}
-
-/* Dribble out some bytes on the stream.  (Called by evDispatch().) */
-static void
-writable(evContext opaqueCtx, void *uap, int fd, int evmask) {
-	evStream *str = uap;
-	int bytes;
-
-	UNUSED(evmask);
-
-	bytes = writev(fd, str->iovCur, str->iovCurCount);
-	if (bytes > 0) {
-		if ((str->flags & EV_STR_TIMEROK) != 0)
-			evTouchIdleTimer(opaqueCtx, str->timer);
-		consume(str, bytes);
-	} else {
-		if (bytes < 0 && errno != EINTR) {
-			str->ioDone = -1;
-			str->ioErrno = errno;
-		}
-	}
-	if (str->ioDone == -1 || str->ioDone == str->ioTotal)
-		done(opaqueCtx, str);
-}
-
-/* Scoop up some bytes from the stream.  (Called by evDispatch().) */
-static void
-readable(evContext opaqueCtx, void *uap, int fd, int evmask) {
-	evStream *str = uap;
-	int bytes;
-
-	UNUSED(evmask);
-
-	bytes = readv(fd, str->iovCur, str->iovCurCount);
-	if (bytes > 0) {
-		if ((str->flags & EV_STR_TIMEROK) != 0)
-			evTouchIdleTimer(opaqueCtx, str->timer);
-		consume(str, bytes);
-	} else {
-		if (bytes == 0)
-			str->ioDone = 0;
-		else {
-			if (errno != EINTR) {
-				str->ioDone = -1;
-				str->ioErrno = errno;
-			}
-		}
-	}
-	if (str->ioDone <= 0 || str->ioDone == str->ioTotal)
-		done(opaqueCtx, str);
-}
-#endif
diff --git a/libc/netbsd/isc/ev_timers.c b/libc/netbsd/isc/ev_timers.c
deleted file mode 100644
index a584f99..0000000
--- a/libc/netbsd/isc/ev_timers.c
+++ /dev/null
@@ -1,505 +0,0 @@
-/*	$NetBSD: ev_timers.c,v 1.2 2004/05/20 19:52:31 christos Exp $	*/
-
-/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1995-1999 by Internet Software Consortium
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/* ev_timers.c - implement timers for the eventlib
- * vix 09sep95 [initial]
- */
-
-#include <sys/cdefs.h>
-#if !defined(LINT) && !defined(CODECENTER) && !defined(lint)
-#ifdef notdef
-static const char rcsid[] = "Id: ev_timers.c,v 1.2.2.1.4.5 2004/03/17 02:39:13 marka Exp";
-#else
-__RCSID("$NetBSD: ev_timers.c,v 1.2 2004/05/20 19:52:31 christos Exp $");
-#endif
-#endif
-
-/* Import. */
-
-#include <errno.h>
-#include <time.h>
-
-#include <isc/assertions.h>
-#include <isc/eventlib.h>
-#include "eventlib_p.h"
-
-/* Constants. */
-
-#define	MILLION 1000000
-#define BILLION 1000000000
-
-/* Forward. */
-
-#ifndef _LIBC
-static int due_sooner(void *, void *);
-static void set_index(void *, int);
-static void free_timer(void *, void *);
-static void print_timer(void *, void *);
-static void idle_timeout(evContext, void *, struct timespec, struct timespec);
-
-/* Private type. */
-
-typedef struct {
-	evTimerFunc	func;
-	void *		uap;
-	struct timespec	lastTouched;
-	struct timespec	max_idle;
-	evTimer *	timer;
-} idle_timer;
-#endif
-
-/* Public. */
-
-struct timespec
-evConsTime(time_t sec, long nsec) {
-	struct timespec x;
-
-	x.tv_sec = sec;
-	x.tv_nsec = nsec;
-	return (x);
-}
-
-struct timespec
-evAddTime(struct timespec addend1, struct timespec addend2) {
-	struct timespec x;
-
-	x.tv_sec = addend1.tv_sec + addend2.tv_sec;
-	x.tv_nsec = addend1.tv_nsec + addend2.tv_nsec;
-	if (x.tv_nsec >= BILLION) {
-		x.tv_sec++;
-		x.tv_nsec -= BILLION;
-	}
-	return (x);
-}
-
-struct timespec
-evSubTime(struct timespec minuend, struct timespec subtrahend) {
-	struct timespec x;
-
-	x.tv_sec = minuend.tv_sec - subtrahend.tv_sec;
-	if (minuend.tv_nsec >= subtrahend.tv_nsec)
-		x.tv_nsec = minuend.tv_nsec - subtrahend.tv_nsec;
-	else {
-		x.tv_nsec = BILLION - subtrahend.tv_nsec + minuend.tv_nsec;
-		x.tv_sec--;
-	}
-	return (x);
-}
-
-int
-evCmpTime(struct timespec a, struct timespec b) {
-	long x = a.tv_sec - b.tv_sec;
-
-	if (x == 0L)
-		x = a.tv_nsec - b.tv_nsec;
-	return (x < 0L ? (-1) : x > 0L ? (1) : (0));
-}
-
-struct timespec
-evNowTime() {
-	struct timeval now;
-#ifdef CLOCK_REALTIME
-	struct timespec tsnow;
-	int m = CLOCK_REALTIME;
-
-#ifdef CLOCK_MONOTONIC
-	if (__evOptMonoTime)
-		m = CLOCK_MONOTONIC;
-#endif
-	if (clock_gettime(m, &tsnow) == 0)
-		return (tsnow);
-#endif
-	if (gettimeofday(&now, NULL) < 0)
-		return (evConsTime(0L, 0L));
-	return (evTimeSpec(now));
-}
-
-struct timespec
-evUTCTime(void) {
-	struct timeval now;
-#ifdef CLOCK_REALTIME
-	struct timespec tsnow;
-	if (clock_gettime(CLOCK_REALTIME, &tsnow) == 0)
-		return (tsnow);
-#endif
-	if (gettimeofday(&now, NULL) < 0)
-		return (evConsTime(0L, 0L));
-	return (evTimeSpec(now));
-}
-
-#ifndef _LIBC
-struct timespec
-evLastEventTime(evContext opaqueCtx) {
-	evContext_p *ctx = opaqueCtx.opaque;
-
-	return (ctx->lastEventTime);
-}
-#endif
-
-struct timespec
-evTimeSpec(struct timeval tv) {
-	struct timespec ts;
-
-	ts.tv_sec = tv.tv_sec;
-	ts.tv_nsec = tv.tv_usec * 1000;
-	return (ts);
-}
-
-struct timeval
-evTimeVal(struct timespec ts) {
-	struct timeval tv;
-
-	tv.tv_sec = ts.tv_sec;
-	tv.tv_usec = ts.tv_nsec / 1000;
-	return (tv);
-}
-
-#ifndef _LIBC
-int
-evSetTimer(evContext opaqueCtx,
-	   evTimerFunc func,
-	   void *uap,
-	   struct timespec due,
-	   struct timespec inter,
-	   evTimerID *opaqueID
-) {
-	evContext_p *ctx = opaqueCtx.opaque;
-	evTimer *id;
-
-	printf("evSetTimer(ctx %p, func %p, uap %p, due %ld.%09ld, inter %ld.%09ld)\n",
-		 ctx, func, uap,
-		 (long)due.tv_sec, due.tv_nsec,
-		 (long)inter.tv_sec, inter.tv_nsec);
-
-#ifdef __hpux
-	/*
-	 * tv_sec and tv_nsec are unsigned.
-	 */
-	if (due.tv_nsec >= BILLION)
-		EV_ERR(EINVAL);
-
-	if (inter.tv_nsec >= BILLION)
-		EV_ERR(EINVAL);
-#else
-	if (due.tv_sec < 0 || due.tv_nsec < 0 || due.tv_nsec >= BILLION)
-		EV_ERR(EINVAL);
-
-	if (inter.tv_sec < 0 || inter.tv_nsec < 0 || inter.tv_nsec >= BILLION)
-		EV_ERR(EINVAL);
-#endif
-
-	/* due={0,0} is a magic cookie meaning "now." */
-	if (due.tv_sec == (time_t)0 && due.tv_nsec == 0L)
-		due = evNowTime();
-
-	/* Allocate and fill. */
-	OKNEW(id);
-	id->func = func;
-	id->uap = uap;
-	id->due = due;
-	id->inter = inter;
-
-	if (heap_insert(ctx->timers, id) < 0)
-		return (-1);
-
-	/* Remember the ID if the caller provided us a place for it. */
-	if (opaqueID)
-		opaqueID->opaque = id;
-
-	if (ctx->debug > 7) {
-		printf("timers after evSetTimer:\n");
-		(void) heap_for_each(ctx->timers, print_timer, (void *)ctx);
-	}
-
-	return (0);
-}
-
-int
-evClearTimer(evContext opaqueCtx, evTimerID id) {
-	evContext_p *ctx = opaqueCtx.opaque;
-	evTimer *del = id.opaque;
-
-	if (ctx->cur != NULL &&
-	    ctx->cur->type == Timer &&
-	    ctx->cur->u.timer.this == del) {
-		printf("deferring delete of timer (executing)\n");
-		/*
-		 * Setting the interval to zero ensures that evDrop() will
-		 * clean up the timer.
-		 */
-		del->inter = evConsTime(0, 0);
-		return (0);
-	}
-
-	if (heap_element(ctx->timers, del->index) != del)
-		EV_ERR(ENOENT);
-
-	if (heap_delete(ctx->timers, del->index) < 0)
-		return (-1);
-	FREE(del);
-
-	if (ctx->debug > 7) {
-		printf("timers after evClearTimer:\n");
-		(void) heap_for_each(ctx->timers, print_timer, (void *)ctx);
-	}
-
-	return (0);
-}
-
-int
-evConfigTimer(evContext opaqueCtx,
-	     evTimerID id,
-	     const char *param,
-	     int value
-) {
-	evContext_p *ctx = opaqueCtx.opaque;
-	evTimer *timer = id.opaque;
-	int result=0;
-
-	UNUSED(value);
-
-	if (heap_element(ctx->timers, timer->index) != timer)
-		EV_ERR(ENOENT);
-
-	if (strcmp(param, "rate") == 0)
-		timer->mode |= EV_TMR_RATE;
-	else if (strcmp(param, "interval") == 0)
-		timer->mode &= ~EV_TMR_RATE;
-	else
-		EV_ERR(EINVAL);
-
-	return (result);
-}
-
-int
-evResetTimer(evContext opaqueCtx,
-	     evTimerID id,
-	     evTimerFunc func,
-	     void *uap,
-	     struct timespec due,
-	     struct timespec inter
-) {
-	evContext_p *ctx = opaqueCtx.opaque;
-	evTimer *timer = id.opaque;
-	struct timespec old_due;
-	int result=0;
-
-	if (heap_element(ctx->timers, timer->index) != timer)
-		EV_ERR(ENOENT);
-
-#ifdef __hpux
-	/*
-	 * tv_sec and tv_nsec are unsigned.
-	 */
-	if (due.tv_nsec >= BILLION)
-		EV_ERR(EINVAL);
-
-	if (inter.tv_nsec >= BILLION)
-		EV_ERR(EINVAL);
-#else
-	if (due.tv_sec < 0 || due.tv_nsec < 0 || due.tv_nsec >= BILLION)
-		EV_ERR(EINVAL);
-
-	if (inter.tv_sec < 0 || inter.tv_nsec < 0 || inter.tv_nsec >= BILLION)
-		EV_ERR(EINVAL);
-#endif
-
-	old_due = timer->due;
-
-	timer->func = func;
-	timer->uap = uap;
-	timer->due = due;
-	timer->inter = inter;
-
-	switch (evCmpTime(due, old_due)) {
-	case -1:
-		result = heap_increased(ctx->timers, timer->index);
-		break;
-	case 0:
-		result = 0;
-		break;
-	case 1:
-		result = heap_decreased(ctx->timers, timer->index);
-		break;
-	}
-
-	if (ctx->debug > 7) {
-		printf("timers after evResetTimer:\n");
-		(void) heap_for_each(ctx->timers, print_timer, (void *)ctx);
-	}
-
-	return (result);
-}
-
-int
-evSetIdleTimer(evContext opaqueCtx,
-		evTimerFunc func,
-		void *uap,
-		struct timespec max_idle,
-		evTimerID *opaqueID
-) {
-	evContext_p *ctx = opaqueCtx.opaque;
-	idle_timer *tt;
-
-	/* Allocate and fill. */
-	OKNEW(tt);
-	tt->func = func;
-	tt->uap = uap;
-	tt->lastTouched = ctx->lastEventTime;
-	tt->max_idle = max_idle;
-
-	if (evSetTimer(opaqueCtx, idle_timeout, tt,
-		       evAddTime(ctx->lastEventTime, max_idle),
-		       max_idle, opaqueID) < 0) {
-		FREE(tt);
-		return (-1);
-	}
-
-	tt->timer = opaqueID->opaque;
-
-	return (0);
-}
-
-int
-evClearIdleTimer(evContext opaqueCtx, evTimerID id) {
-	evTimer *del = id.opaque;
-	idle_timer *tt = del->uap;
-
-	FREE(tt);
-	return (evClearTimer(opaqueCtx, id));
-}
-
-int
-evResetIdleTimer(evContext opaqueCtx,
-		 evTimerID opaqueID,
-		 evTimerFunc func,
-		 void *uap,
-		 struct timespec max_idle
-) {
-	evContext_p *ctx = opaqueCtx.opaque;
-	evTimer *timer = opaqueID.opaque;
-	idle_timer *tt = timer->uap;
-
-	tt->func = func;
-	tt->uap = uap;
-	tt->lastTouched = ctx->lastEventTime;
-	tt->max_idle = max_idle;
-
-	return (evResetTimer(opaqueCtx, opaqueID, idle_timeout, tt,
-			     evAddTime(ctx->lastEventTime, max_idle),
-			     max_idle));
-}
-
-int
-evTouchIdleTimer(evContext opaqueCtx, evTimerID id) {
-	evContext_p *ctx = opaqueCtx.opaque;
-	evTimer *t = id.opaque;
-	idle_timer *tt = t->uap;
-
-	tt->lastTouched = ctx->lastEventTime;
-
-	return (0);
-}
-
-/* Public to the rest of eventlib. */
-
-heap_context
-evCreateTimers(const evContext_p *ctx) {
-
-	UNUSED(ctx);
-
-	return (heap_new(due_sooner, set_index, 2048));
-}
-
-void
-evDestroyTimers(const evContext_p *ctx) {
-	(void) heap_for_each(ctx->timers, free_timer, NULL);
-	(void) heap_free(ctx->timers);
-}
-
-/* Private. */
-
-static int
-due_sooner(void *a, void *b) {
-	evTimer *a_timer, *b_timer;
-
-	a_timer = a;
-	b_timer = b;
-	return (evCmpTime(a_timer->due, b_timer->due) < 0);
-}
-
-static void
-set_index(void *what, int idx) {
-	evTimer *timer;
-
-	timer = what;
-	timer->index = idx;
-}
-
-static void
-free_timer(void *what, void *uap) {
-	evTimer *t = what;
-
-	UNUSED(uap);
-
-	FREE(t);
-}
-
-static void
-print_timer(void *what, void *uap) {
-	evTimer *cur = what;
-	evContext_p *ctx = uap;
-
-	cur = what;
-	evPrintf(ctx, 7,
-	    "  func %p, uap %p, due %ld.%09ld, inter %ld.%09ld\n",
-		 cur->func, cur->uap,
-		 (long)cur->due.tv_sec, cur->due.tv_nsec,
-		 (long)cur->inter.tv_sec, cur->inter.tv_nsec);
-}
-
-static void
-idle_timeout(evContext opaqueCtx,
-	     void *uap,
-	     struct timespec due,
-	     struct timespec inter
-) {
-	evContext_p *ctx = opaqueCtx.opaque;
-	idle_timer *this = uap;
-	struct timespec idle;
-
-	UNUSED(due);
-	UNUSED(inter);
-	
-	idle = evSubTime(ctx->lastEventTime, this->lastTouched);
-	if (evCmpTime(idle, this->max_idle) >= 0) {
-		(this->func)(opaqueCtx, this->uap, this->timer->due,
-			     this->max_idle);
-		/*
-		 * Setting the interval to zero will cause the timer to
-		 * be cleaned up in evDrop().
-		 */
-		this->timer->inter = evConsTime(0L, 0L);
-		FREE(this);
-	} else {
-		/* evDrop() will reschedule the timer. */
-		this->timer->inter = evSubTime(this->max_idle, idle);
-	}
-}
-#endif
diff --git a/libc/netbsd/isc/eventlib_p.h b/libc/netbsd/isc/eventlib_p.h
deleted file mode 100644
index 7edc5a0..0000000
--- a/libc/netbsd/isc/eventlib_p.h
+++ /dev/null
@@ -1,233 +0,0 @@
-/*	$NetBSD: eventlib_p.h,v 1.1.1.1 2004/05/20 19:34:32 christos Exp $	*/
-
-/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1995-1999 by Internet Software Consortium
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/* eventlib_p.h - private interfaces for eventlib
- * vix 09sep95 [initial]
- *
- * Id: eventlib_p.h,v 1.3.2.1.4.1 2004/03/09 08:33:43 marka Exp
- */
-
-#ifndef _EVENTLIB_P_H
-#define _EVENTLIB_P_H
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <sys/un.h>
-
-#define EVENTLIB_DEBUG 1
-
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <isc/heap.h>
-#include <isc/list.h>
-#include <isc/memcluster.h>
-
-
-#define	EV_MASK_ALL	(EV_READ | EV_WRITE | EV_EXCEPT)
-#define EV_ERR(e)		return (errno = (e), -1)
-#define OK(x)		if ((x) < 0) EV_ERR(errno); else (void)NULL
-
-
-#if HAVE_MEM_GET_SET
-#define	NEW(p)		if (((p) = memget(sizeof *(p))) != NULL) \
-				FILL(p); \
-			else \
-				(void)NULL;
-#define OKNEW(p)	if (!((p) = memget(sizeof *(p)))) { \
-				errno = ENOMEM; \
-				return (-1); \
-			} else \
-				FILL(p)
-#define FREE(p)		memput((p), sizeof *(p))
-
-#if EVENTLIB_DEBUG
-#define FILL(p)		memset((p), 0xF5, sizeof *(p))
-#else
-#define FILL(p)
-#endif
-
-#else
-
-#define	NEW(p) 	p = malloc(sizeof *(p));
-#define OKNEW(p) if (!((p) = malloc(sizeof *(p)))) { errno = ENOMEM; return (-1); }
-#define FREE(p)	free(p)
-#define FILL(p)
-
-#endif
-
-
-typedef struct evConn {
-	evConnFunc	func;
-	void *		uap;
-	int		fd;
-	int		flags;
-#define EV_CONN_LISTEN		0x0001		/* Connection is a listener. */
-#define EV_CONN_SELECTED	0x0002		/* evSelectFD(conn->file). */
-#define EV_CONN_BLOCK		0x0004		/* Listener fd was blocking. */
-	evFileID	file;
-	struct evConn *	prev;
-	struct evConn *	next;
-} evConn;
-
-typedef struct evAccept {
-	int		fd;
-	union {
-		struct sockaddr		sa;
-		struct sockaddr_in	in;
-#ifndef NO_SOCKADDR_UN
-		struct sockaddr_un	un;
-#endif
-	}		la;
-	socklen_t	lalen;
-	union {
-		struct sockaddr		sa;
-		struct sockaddr_in	in;
-#ifndef NO_SOCKADDR_UN
-		struct sockaddr_un	un;
-#endif
-	}		ra;
-	socklen_t	ralen;
-	int		ioErrno;
-	evConn *	conn;
-	LINK(struct evAccept) link;
-} evAccept;
-
-typedef struct evFile {
-	evFileFunc	func;
-	void *		uap;
-	int		fd;
-	int		eventmask;
-	int		preemptive;
-	struct evFile *	prev;
-	struct evFile *	next;
-	struct evFile *	fdprev;
-	struct evFile *	fdnext;
-} evFile;
-
-typedef struct evStream {
-	evStreamFunc	func;
-	void *		uap;
-	evFileID	file;
-	evTimerID	timer;
-	int		flags;
-#define EV_STR_TIMEROK	0x0001	/* IFF timer valid. */
-	int		fd;
-	struct iovec *	iovOrig;
-	int		iovOrigCount;
-	struct iovec *	iovCur;
-	int		iovCurCount;
-	int		ioTotal;
-	int		ioDone;
-	int		ioErrno;
-	struct evStream	*prevDone, *nextDone;
-	struct evStream	*prev, *next;
-} evStream;
-
-typedef struct evTimer {
-	evTimerFunc	func;
-	void *		uap;
-	struct timespec	due, inter;
-	int		index;
-	int		mode;
-#define EV_TMR_RATE	1
-} evTimer;
-
-typedef struct evWait {
-	evWaitFunc	func;
-	void *		uap;
-	const void *	tag;
-	struct evWait *	next;
-} evWait;
-
-typedef struct evWaitList {
-	evWait *		first;
-	evWait *		last;
-	struct evWaitList *	prev;
-	struct evWaitList *	next;
-} evWaitList;
-
-typedef struct evEvent_p {
-	enum {  Accept, File, Stream, Timer, Wait, Free, Null  } type;
-	union {
-		struct {  evAccept *this;  }			accept;
-		struct {  evFile *this; int eventmask;  }	file;
-		struct {  evStream *this;  }			stream;
-		struct {  evTimer *this;  }			timer;
-		struct {  evWait *this;  }			wait;
-		struct {  struct evEvent_p *next;  }		free;
-		struct {  const void *placeholder;  }		null;
-	} u;
-} evEvent_p;
-
-typedef struct {
-	/* Global. */
-	const evEvent_p	*cur;
-	/* Debugging. */
-	int		debug;
-	FILE		*output;
-	/* Connections. */
-	evConn		*conns;
-	LIST(evAccept)	accepts;
-	/* Files. */
-	evFile		*files, *fdNext;
-	fd_set		rdLast, rdNext;
-	fd_set		wrLast, wrNext;
-	fd_set		exLast, exNext;
-	fd_set		nonblockBefore;
-	int		fdMax, fdCount, highestFD;
-	evFile		*fdTable[FD_SETSIZE];
-#ifdef EVENTLIB_TIME_CHECKS
-	struct timespec	lastSelectTime;
-	int		lastFdCount;
-#endif
-	/* Streams. */
-	evStream	*streams;
-	evStream	*strDone, *strLast;
-	/* Timers. */
-	struct timespec	lastEventTime;
-	heap_context	timers;
-	/* Waits. */
-	evWaitList	*waitLists;
-	evWaitList	waitDone;
-} evContext_p;
-
-/* eventlib.c */
-#define evPrintf __evPrintf
-void evPrintf(const evContext_p *ctx, int level, const char *fmt, ...);
-
-/* ev_timers.c */
-#define evCreateTimers __evCreateTimers
-heap_context evCreateTimers(const evContext_p *);
-#define evDestroyTimers __evDestroyTimers
-void evDestroyTimers(const evContext_p *);
-
-/* ev_waits.c */
-#define evFreeWait __evFreeWait
-evWait *evFreeWait(evContext_p *ctx, evWait *old);
-
-/* Global options */
-int		__evOptMonoTime;
-
-#endif /*_EVENTLIB_P_H*/
diff --git a/libc/netbsd/net/getnameinfo.c b/libc/netbsd/net/getnameinfo.c
index d8ac037..4874da1 100644
--- a/libc/netbsd/net/getnameinfo.c
+++ b/libc/netbsd/net/getnameinfo.c
@@ -1,4 +1,4 @@
-/*	$NetBSD: getnameinfo.c,v 1.43 2006/02/17 15:58:26 ginsbach Exp $	*/
+/*	$NetBSD: getnameinfo.c,v 1.53 2012/09/26 23:13:00 christos Exp $	*/
 /*	$KAME: getnameinfo.c,v 1.45 2000/09/25 22:43:56 itojun Exp $	*/
 
 /*
@@ -47,30 +47,28 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getnameinfo.c,v 1.43 2006/02/17 15:58:26 ginsbach Exp $");
+__RCSID("$NetBSD: getnameinfo.c,v 1.53 2012/09/26 23:13:00 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <sys/un.h>
 #include <net/if.h>
-#if defined(ANDROID_CHANGES) && defined(AF_LINK)
-#include <net/if_dl.h>
-#endif
 #include <net/if_ieee1394.h>
 #include <net/if_types.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
-#include "arpa_nameser.h"
 #include <assert.h>
 #include <limits.h>
 #include <netdb.h>
 #ifdef ANDROID_CHANGES
+#include "arpa_nameser.h"
 #include "resolv_private.h"
 #include <sys/system_properties.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <sys/un.h>
 #include <errno.h>
+#define MIN(x,y) ((x) < (y) ? (x) : (y))
 #else
 #include <resolv.h>
 #endif
@@ -98,23 +96,15 @@
 	u_short	si_port;
 };
 
-static int getnameinfo_inet __P((const struct sockaddr *, socklen_t, char *,
-    socklen_t, char *, socklen_t, int));
+static int getnameinfo_inet(const struct sockaddr *, socklen_t, char *,
+    socklen_t, char *, socklen_t, int);
 #ifdef INET6
-static int ip6_parsenumeric __P((const struct sockaddr *, const char *, char *,
-				 socklen_t, int));
-static int ip6_sa2str __P((const struct sockaddr_in6 *, char *, size_t,
-				 int));
+static int ip6_parsenumeric(const struct sockaddr *, const char *, char *,
+				 socklen_t, int);
+static int ip6_sa2str(const struct sockaddr_in6 *, char *, size_t, int);
 #endif
-#if defined(ANDROID_CHANGES) && defined(AF_LINK)
-static int getnameinfo_link __P((const struct sockaddr *, socklen_t, char *,
-    socklen_t, char *, socklen_t, int));
-#endif
-static int hexname __P((const u_int8_t *, size_t, char *, socklen_t));
-
-// This should be synchronized to ResponseCode.h
-static const int DnsProxyQueryResult = 222;
-
+static int getnameinfo_local(const struct sockaddr *, socklen_t, char *,
+    socklen_t, char *, socklen_t, int);
 
 /*
  * Top-level getnameinfo() code.  Look at the address family, and pick an
@@ -127,16 +117,41 @@
 	case AF_INET6:
 		return getnameinfo_inet(sa, salen, host, hostlen,
 		    serv, servlen, flags);
-#if defined(ANDROID_CHANGES) && defined(AF_LINK)
-	case AF_LINK:
-		return getnameinfo_link(sa, salen, host, hostlen,
+	case AF_LOCAL:
+		return getnameinfo_local(sa, salen, host, hostlen,
 		    serv, servlen, flags);
-#endif
 	default:
 		return EAI_FAMILY;
 	}
 }
 
+/*
+ * getnameinfo_local():
+ * Format an local address into a printable format.
+ */
+/* ARGSUSED */
+static int
+getnameinfo_local(const struct sockaddr *sa, socklen_t salen,
+    char *host, socklen_t hostlen, char *serv, socklen_t servlen,
+    int flags __attribute__((unused)))
+{
+       const struct sockaddr_un *sun =
+           (const struct sockaddr_un *)(const void *)sa;
+
+       if (salen < (socklen_t) offsetof(struct sockaddr_un, sun_path)) {
+           return EAI_FAMILY;
+       }
+
+       if (serv != NULL && servlen > 0)
+               serv[0] = '\0';
+
+       if (host && hostlen > 0)
+               strlcpy(host, sun->sun_path,
+                   MIN((socklen_t) sizeof(sun->sun_path) + 1, hostlen));
+
+       return 0;
+}
+
 #ifdef ANDROID_CHANGES
 /* On success length of the host name is returned. A return
  * value of 0 means there's no host name associated with
@@ -213,6 +228,8 @@
 
 	int result_code = (int)strtol(msg_buf, NULL, 10);
 	// verify the code itself
+        // This should be synchronized to ResponseCode.h
+        static const int DnsProxyQueryResult = 222;
 	if (result_code != DnsProxyQueryResult) {
 		goto exit;
 	}
@@ -241,19 +258,16 @@
 	return result;
 }
 #endif
+
 /*
  * getnameinfo_inet():
  * Format an IPv4 or IPv6 sockaddr into a printable string.
  */
 static int
-getnameinfo_inet(sa, salen, host, hostlen, serv, servlen, flags)
-	const struct sockaddr *sa;
-	socklen_t salen;
-	char *host;
-	socklen_t hostlen;
-	char *serv;
-	socklen_t servlen;
-	int flags;
+getnameinfo_inet(const struct sockaddr* sa, socklen_t salen,
+       char *host, socklen_t hostlen,
+       char *serv, socklen_t servlen,
+       int flags)
 {
 	const struct afd *afd;
 	struct servent *sp;
@@ -261,7 +275,7 @@
 	u_short port;
 	int family, i;
 	const char *addr;
-	u_int32_t v4a;
+	uint32_t v4a;
 	char numserv[512];
 	char numaddr[512];
 
@@ -272,11 +286,6 @@
 	if (sa == NULL)
 		return EAI_FAIL;
 
-#ifdef BSD4_4
-	if (sa->sa_len != salen)
-		return EAI_FAIL;
-#endif
-
 	family = sa->sa_family;
 	for (i = 0; afdl[i].a_af; i++)
 		if (afdl[i].a_af == family) {
@@ -286,8 +295,11 @@
 	return EAI_FAMILY;
 
  found:
-	if (salen != afd->a_socklen)
-		return EAI_FAIL;
+	// http://b/1889275: callers should be allowed to provide too much
+	// space, but not too little.
+	if (salen < afd->a_socklen) {
+		return EAI_FAMILY;
+	}
 
 	/* network byte order */
 	port = ((const struct sockinet *)(const void *)sa)->si_port;
@@ -321,7 +333,7 @@
 
 	switch (sa->sa_family) {
 	case AF_INET:
-		v4a = (u_int32_t)
+		v4a = (uint32_t)
 		    ntohl(((const struct sockaddr_in *)
 		    (const void *)sa)->sin_addr.s_addr);
 		if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
@@ -412,7 +424,7 @@
 #endif
 
 		if (hp) {
-#if defined(ANDROID_CHANGES) && defined(AF_LINK)
+#if 0
 			/*
 			 * commented out, since "for local host" is not
 			 * implemented here - see RFC2553 p30
@@ -457,12 +469,8 @@
 
 #ifdef INET6
 static int
-ip6_parsenumeric(sa, addr, host, hostlen, flags)
-	const struct sockaddr *sa;
-	const char *addr;
-	char *host;
-	socklen_t hostlen;
-	int flags;
+ip6_parsenumeric(const struct sockaddr *sa, const char *addr, char *host,
+       socklen_t hostlen, int flags)
 {
 	size_t numaddrlen;
 	char numaddr[512];
@@ -471,9 +479,6 @@
 	assert(addr != NULL);
 	assert(host != NULL);
 
-	if (hostlen < 0)
-		return EAI_OVERFLOW;
-
 	if (inet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr)) == NULL)
 		return EAI_SYSTEM;
 
@@ -505,11 +510,7 @@
 
 /* ARGSUSED */
 static int
-ip6_sa2str(sa6, buf, bufsiz, flags)
-	const struct sockaddr_in6 *sa6;
-	char *buf;
-	size_t bufsiz;
-	int flags;
+ip6_sa2str(const struct sockaddr_in6 *sa6, char *buf, size_t bufsiz, int flags)
 {
 	unsigned int ifindex;
 	const struct in6_addr *a6;
@@ -548,109 +549,3 @@
 		return n;
 }
 #endif /* INET6 */
-
-
-#if defined(ANDROID_CHANGES) && defined(AF_LINK)
-/*
- * getnameinfo_link():
- * Format a link-layer address into a printable format, paying attention to
- * the interface type.
- */
-/* ARGSUSED */
-static int
-getnameinfo_link(const struct sockaddr *sa, socklen_t salen,
-    char *host, socklen_t hostlen, char *serv, socklen_t servlen,
-    int flags)
-{
-	const struct sockaddr_dl *sdl =
-	    (const struct sockaddr_dl *)(const void *)sa;
-	const struct ieee1394_hwaddr *iha;
-	int n;
-
-	if (serv != NULL && servlen > 0)
-		*serv = '\0';
-
-	if (sdl->sdl_nlen == 0 && sdl->sdl_alen == 0 && sdl->sdl_slen == 0) {
-		n = snprintf(host, hostlen, "link#%u", sdl->sdl_index);
-		if (n < 0 || (socklen_t) n > hostlen) {
-			*host = '\0';
-			return EAI_MEMORY;
-		}
-		return 0;
-	}
-
-	switch (sdl->sdl_type) {
-#ifdef IFT_ECONET
-	case IFT_ECONET:
-		if (sdl->sdl_alen < 2)
-			return EAI_FAMILY;
-		if (CLLADDR(sdl)[1] == 0)
-			n = snprintf(host, hostlen, "%u", CLLADDR(sdl)[0]);
-		else
-			n = snprintf(host, hostlen, "%u.%u",
-			    CLLADDR(sdl)[1], CLLADDR(sdl)[0]);
-		if (n < 0 || (socklen_t) n >= hostlen) {
-			*host = '\0';
-			return EAI_MEMORY;
-		} else
-			return 0;
-#endif
-	case IFT_IEEE1394:
-		if (sdl->sdl_alen < sizeof(iha->iha_uid))
-			return EAI_FAMILY;
-		iha =
-		    (const struct ieee1394_hwaddr *)(const void *)CLLADDR(sdl);
-		return hexname(iha->iha_uid, sizeof(iha->iha_uid),
-		    host, hostlen);
-	/*
-	 * The following have zero-length addresses.
-	 * IFT_ATM	(net/if_atmsubr.c)
-	 * IFT_FAITH	(net/if_faith.c)
-	 * IFT_GIF	(net/if_gif.c)
-	 * IFT_LOOP	(net/if_loop.c)
-	 * IFT_PPP	(net/if_ppp.c, net/if_spppsubr.c)
-	 * IFT_SLIP	(net/if_sl.c, net/if_strip.c)
-	 * IFT_STF	(net/if_stf.c)
-	 * IFT_L2VLAN	(net/if_vlan.c)
-	 * IFT_PROPVIRTUAL (net/if_bridge.h>
-	 */
-	/*
-	 * The following use IPv4 addresses as link-layer addresses:
-	 * IFT_OTHER	(net/if_gre.c)
-	 */
-	case IFT_ARCNET: /* default below is believed correct for all these. */
-	case IFT_ETHER:
-	case IFT_FDDI:
-	case IFT_HIPPI:
-	case IFT_ISO88025:
-	default:
-		return hexname((const u_int8_t *)CLLADDR(sdl),
-		    (size_t)sdl->sdl_alen, host, hostlen);
-	}
-}
-#endif
-
-static int
-hexname(cp, len, host, hostlen)
-	const u_int8_t *cp;
-	char *host;
-	size_t len;
-	socklen_t hostlen;
-{
-	int n;
-	size_t i;
-	char *outp = host;
-
-	*outp = '\0';
-	for (i = 0; i < len; i++) {
-		n = snprintf(outp, hostlen, "%s%02x",
-		    i ? ":" : "", cp[i]);
-		if (n < 0 || (socklen_t) n >= hostlen) {
-			*host = '\0';
-			return EAI_MEMORY;
-		}
-		outp += n;
-		hostlen -= n;
-	}
-	return 0;
-}
diff --git a/libc/netbsd/net/getservbyname_r.c b/libc/netbsd/net/getservbyname_r.c
deleted file mode 100644
index fb6dc52..0000000
--- a/libc/netbsd/net/getservbyname_r.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*	$NetBSD: getservbyname_r.c,v 1.3 2005/04/18 19:39:45 kleink Exp $	*/
-
-/*
- * Copyright (c) 1983, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)getservbyname.c	8.1 (Berkeley) 6/4/93";
-#else
-__RCSID("$NetBSD: getservbyname_r.c,v 1.3 2005/04/18 19:39:45 kleink Exp $");
-#endif
-#endif /* LIBC_SCCS and not lint */
-
-#include <assert.h>
-#include <netdb.h>
-#include <string.h>
-
-#include "servent.h"
-
-struct servent *
-getservbyname_r(const char *name, const char *proto, struct servent *sp,
-    struct servent_data *sd)
-{
-	struct servent *s;
-	char **cp;
-
-	assert(name != NULL);
-	/* proto may be NULL */
-
-	setservent_r(sd->stayopen, sd);
-	while ((s = getservent_r(sp, sd)) != NULL) {
-		if (strcmp(name, s->s_name) == 0)
-			goto gotname;
-		for (cp = s->s_aliases; *cp; cp++)
-			if (strcmp(name, *cp) == 0)
-				goto gotname;
-		continue;
-gotname:
-		if (proto == NULL || strcmp(s->s_proto, proto) == 0)
-			break;
-	}
-	if (!sd->stayopen)
-		if (sd->fp != NULL) {
-			(void)fclose(sd->fp);
-			sd->fp = NULL;
-		}
-	return s;
-}
diff --git a/libc/netbsd/net/getservbyport_r.c b/libc/netbsd/net/getservbyport_r.c
deleted file mode 100644
index 6fe4293..0000000
--- a/libc/netbsd/net/getservbyport_r.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*	$NetBSD: getservbyport_r.c,v 1.3 2005/04/18 19:39:45 kleink Exp $	*/
-
-/*
- * Copyright (c) 1983, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)getservbyport.c	8.1 (Berkeley) 6/4/93";
-#else
-__RCSID("$NetBSD: getservbyport_r.c,v 1.3 2005/04/18 19:39:45 kleink Exp $");
-#endif
-#endif /* LIBC_SCCS and not lint */
-
-#include <netdb.h>
-#include <string.h>
-
-#include "servent.h"
-
-struct servent *
-getservbyport_r(int port, const char *proto, struct servent *sp,
-    struct servent_data *sd)
-{
-	struct servent *s;
-
-	setservent_r(sd->stayopen, sd);
-	while ((s = getservent_r(sp, sd)) != NULL) {
-		if (s->s_port != port)
-			continue;
-		if (proto == NULL || strcmp(s->s_proto, proto) == 0)
-			break;
-	}
-	if (!sd->stayopen)
-		if (sd->fp != NULL) {
-			(void)fclose(sd->fp);
-			sd->fp = NULL;
-		}
-	return s;
-}
diff --git a/libc/netbsd/net/getservent_r.c b/libc/netbsd/net/getservent_r.c
deleted file mode 100644
index 1668759..0000000
--- a/libc/netbsd/net/getservent_r.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/*	$NetBSD: getservent_r.c,v 1.5 2005/04/18 19:39:45 kleink Exp $	*/
-
-/*
- * Copyright (c) 1983, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)getservent.c	8.1 (Berkeley) 6/4/93";
-#else
-__RCSID("$NetBSD: getservent_r.c,v 1.5 2005/04/18 19:39:45 kleink Exp $");
-#endif
-#endif /* LIBC_SCCS and not lint */
-
-#include <netdb.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <netinet/in.h>
-
-#include "servent.h"
-
-void
-setservent_r(int f, struct servent_data *sd)
-{
-	if (sd->fp == NULL)
-		sd->fp = fopen(_PATH_SERVICES, "r");
-	else
-		rewind(sd->fp);
-	sd->stayopen |= f;
-}
-
-void
-endservent_r(struct servent_data *sd)
-{
-	if (sd->fp) {
-		(void)fclose(sd->fp);
-		sd->fp = NULL;
-	}
-	if (sd->aliases) {
-		free(sd->aliases);
-		sd->aliases = NULL;
-		sd->maxaliases = 0;
-	}
-	if (sd->line) {
-		free(sd->line);
-		sd->line = NULL;
-	}
-	sd->stayopen = 0;
-}
-
-struct servent *
-getservent_r(struct servent *sp, struct servent_data *sd)
-{
-	char *p, *cp, **q;
-	size_t i = 0;
-	int oerrno;
-
-	if (sd->fp == NULL && (sd->fp = fopen(_PATH_SERVICES, "r")) == NULL)
-		return NULL;
-
-	for (;;) {
-		if (sd->line)
-			free(sd->line);
-//		sd->line = fparseln(sd->fp, NULL, NULL, NULL, FPARSELN_UNESCALL);
-		fprintf(stderr, "*** FIX ME! getservent_r() is going to fail!!!\n");
-		sd->line = NULL;
-		if (sd->line == NULL)
-			return NULL;
-		sp->s_name = p = sd->line;
-		p = strpbrk(p, " \t");
-		if (p == NULL)
-			continue;
-		*p++ = '\0';
-		while (*p == ' ' || *p == '\t')
-			p++;
-		cp = strpbrk(p, ",/");
-		if (cp == NULL)
-			continue;
-		*cp++ = '\0';
-		sp->s_port = htons((u_short)atoi(p));
-		sp->s_proto = cp;
-		if (sd->aliases == NULL) {
-			sd->maxaliases = 10;
-			sd->aliases = malloc(sd->maxaliases * sizeof(char *));
-			if (sd->aliases == NULL) {
-				oerrno = errno;
-				endservent_r(sd);
-				errno = oerrno;
-				return NULL;
-			}
-		}
-		q = sp->s_aliases = sd->aliases;
-		cp = strpbrk(cp, " \t");
-		if (cp != NULL)
-			*cp++ = '\0';
-		while (cp && *cp) {
-			if (*cp == ' ' || *cp == '\t') {
-				cp++;
-				continue;
-			}
-			if (i == sd->maxaliases - 2) {
-				sd->maxaliases *= 2;
-				q = realloc(q,
-				    sd->maxaliases * sizeof(char *));
-				if (q == NULL) {
-					oerrno = errno;
-					endservent_r(sd);
-					errno = oerrno;
-					return NULL;
-				}
-				sp->s_aliases = sd->aliases = q;
-			}
-			q[i++] = cp;
-			cp = strpbrk(cp, " \t");
-			if (cp != NULL)
-				*cp++ = '\0';
-		}
-		q[i] = NULL;
-		return sp;
-	}
-}
diff --git a/libc/private/ErrnoRestorer.h b/libc/private/ErrnoRestorer.h
new file mode 100644
index 0000000..ed6ab62
--- /dev/null
+++ b/libc/private/ErrnoRestorer.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ERRNO_RESTORER_H
+#define ERRNO_RESTORER_H
+
+#include <errno.h>
+
+class ErrnoRestorer {
+ public:
+  explicit ErrnoRestorer() : saved_errno_(errno) {
+  }
+
+  ~ErrnoRestorer() {
+    errno = saved_errno_;
+  }
+
+  void override(int new_errno) {
+    saved_errno_ = new_errno;
+  }
+
+ private:
+  int saved_errno_;
+
+  // Disallow copy and assignment.
+  ErrnoRestorer(const ErrnoRestorer&);
+  void operator=(const ErrnoRestorer&);
+};
+
+#endif // ERRNO_RESTORER_H
diff --git a/libc/private/KernelArgumentBlock.h b/libc/private/KernelArgumentBlock.h
new file mode 100644
index 0000000..d777267
--- /dev/null
+++ b/libc/private/KernelArgumentBlock.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef KERNEL_ARGUMENT_BLOCK_H
+#define KERNEL_ARGUMENT_BLOCK_H
+
+#include <elf.h>
+#include <stdint.h>
+#include <sys/auxv.h>
+
+// When the kernel starts the dynamic linker, it passes a pointer to a block
+// of memory containing argc, the argv array, the environment variable array,
+// and the array of ELF aux vectors. This class breaks that block up into its
+// constituents for easy access.
+class KernelArgumentBlock {
+ public:
+  KernelArgumentBlock(void* raw_args) {
+    uint32_t* args = reinterpret_cast<uint32_t*>(raw_args);
+    argc = static_cast<int>(*args);
+    argv = reinterpret_cast<char**>(args + 1);
+    envp = argv + argc + 1;
+
+    // Skip over all environment variable definitions to find aux vector.
+    // The end of the environment block is marked by two NULL pointers.
+    char** p = envp;
+    while (*p != NULL) {
+      ++p;
+    }
+    ++p; // Skip second NULL;
+
+    auxv = reinterpret_cast<Elf32_auxv_t*>(p);
+  }
+
+  // Similar to ::getauxval but doesn't require the libc global variables to be set up,
+  // so it's safe to call this really early on. This function also lets you distinguish
+  // between the inability to find the given type and its value just happening to be 0.
+  unsigned long getauxval(unsigned long type, bool* found_match = NULL) {
+    for (Elf32_auxv_t* v = auxv; v->a_type != AT_NULL; ++v) {
+      if (v->a_type == type) {
+        if (found_match != NULL) {
+            *found_match = true;
+        }
+        return v->a_un.a_val;
+      }
+    }
+    if (found_match != NULL) {
+      *found_match = false;
+    }
+    return 0;
+  }
+
+  int argc;
+  char** argv;
+  char** envp;
+  Elf32_auxv_t* auxv;
+
+ private:
+  // Disallow copy and assignment.
+  KernelArgumentBlock(const KernelArgumentBlock&);
+  void operator=(const KernelArgumentBlock&);
+};
+
+#endif // KERNEL_ARGUMENT_BLOCK_H
diff --git a/libc/private/ScopedPthreadMutexLocker.h b/libc/private/ScopedPthreadMutexLocker.h
new file mode 100644
index 0000000..06b8e37
--- /dev/null
+++ b/libc/private/ScopedPthreadMutexLocker.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SCOPED_PTHREAD_MUTEX_LOCKER_H
+#define SCOPED_PTHREAD_MUTEX_LOCKER_H
+
+#include <pthread.h>
+
+class ScopedPthreadMutexLocker {
+ public:
+  explicit ScopedPthreadMutexLocker(pthread_mutex_t* mu) : mu_(mu) {
+    pthread_mutex_lock(mu_);
+  }
+
+  ~ScopedPthreadMutexLocker() {
+    pthread_mutex_unlock(mu_);
+  }
+
+ private:
+  pthread_mutex_t* mu_;
+
+  // Disallow copy and assignment.
+  ScopedPthreadMutexLocker(const ScopedPthreadMutexLocker&);
+  void operator=(const ScopedPthreadMutexLocker&);
+};
+
+#endif // SCOPED_PTHREAD_MUTEX_LOCKER_H
diff --git a/libc/private/ScopedReaddir.h b/libc/private/ScopedReaddir.h
new file mode 100644
index 0000000..797809a
--- /dev/null
+++ b/libc/private/ScopedReaddir.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SCOPED_READDIR_H
+#define SCOPED_READDIR_H
+
+#include <dirent.h>
+
+class ScopedReaddir {
+ public:
+  ScopedReaddir(const char* path) {
+    dir_ = opendir(path);
+  }
+
+  ~ScopedReaddir() {
+    if (dir_ != NULL) {
+      closedir(dir_);
+    }
+  }
+
+  bool IsBad() {
+    return dir_ == NULL;
+  }
+
+  dirent* ReadEntry() {
+    return readdir(dir_);
+  }
+
+ private:
+  DIR* dir_;
+
+  // Disallow copy and assignment.
+  ScopedReaddir(const ScopedReaddir&);
+  void operator=(const ScopedReaddir&);
+};
+
+#endif // SCOPED_READDIR_H
diff --git a/libc/private/ThreadLocalBuffer.h b/libc/private/ThreadLocalBuffer.h
new file mode 100644
index 0000000..e5bd28c
--- /dev/null
+++ b/libc/private/ThreadLocalBuffer.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _BIONIC_THREAD_LOCAL_BUFFER_H_included
+#define _BIONIC_THREAD_LOCAL_BUFFER_H_included
+
+#include <malloc.h>
+#include <pthread.h>
+
+// libstdc++ currently contains __cxa_guard_acquire and __cxa_guard_release,
+// so we make do with macros instead of a C++ class.
+// TODO: move __cxa_guard_acquire and __cxa_guard_release into libc.
+
+// We used to use pthread_once to initialize the keys, but life is more predictable
+// if we allocate them all up front when the C library starts up, via __constructor__.
+
+#define GLOBAL_INIT_THREAD_LOCAL_BUFFER(name) \
+  static pthread_key_t __bionic_tls_ ## name ## _key; \
+  static void __bionic_tls_ ## name ## _key_destroy(void* buffer) { \
+    free(buffer); \
+  } \
+  __attribute__((constructor)) static void __bionic_tls_ ## name ## _key_init() { \
+    pthread_key_create(&__bionic_tls_ ## name ## _key, __bionic_tls_ ## name ## _key_destroy); \
+  }
+
+// Leaves "name_tls_buffer" and "name_tls_buffer_size" defined and initialized.
+#define LOCAL_INIT_THREAD_LOCAL_BUFFER(type, name, byte_count) \
+  type name ## _tls_buffer = \
+      reinterpret_cast<type>(pthread_getspecific(__bionic_tls_ ## name ## _key)); \
+  if (name ## _tls_buffer == NULL) { \
+    name ## _tls_buffer = reinterpret_cast<type>(calloc(1, byte_count)); \
+    pthread_setspecific(__bionic_tls_ ## name ## _key, name ## _tls_buffer); \
+  } \
+  const size_t name ## _tls_buffer_size __attribute__((unused)) = byte_count
+
+#endif // _BIONIC_THREAD_LOCAL_BUFFER_H_included
diff --git a/libc/private/bionic_auxv.h b/libc/private/bionic_auxv.h
new file mode 100644
index 0000000..69d15b6
--- /dev/null
+++ b/libc/private/bionic_auxv.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef _PRIVATE_BIONIC_AUXV_H_
+#define _PRIVATE_BIONIC_AUXV_H_
+
+#include <elf.h>
+
+__BEGIN_DECLS
+
+extern Elf32_auxv_t* __libc_auxv;
+
+__END_DECLS
+
+#endif /* _PRIVATE_BIONIC_AUXV_H_ */
diff --git a/libc/private/bionic_futex.h b/libc/private/bionic_futex.h
index eb49fb7..6c7fdbe 100644
--- a/libc/private/bionic_futex.h
+++ b/libc/private/bionic_futex.h
@@ -30,6 +30,8 @@
 
 #include <linux/futex.h>
 
+__BEGIN_DECLS
+
 extern int __futex_wait(volatile void *ftx, int val, const struct timespec *timeout);
 extern int __futex_wake(volatile void *ftx, int count);
 
@@ -54,4 +56,6 @@
 extern int  __futex_wake_ex(volatile void *ftx, int pshared, int val);
 extern int  __futex_wait_ex(volatile void *ftx, int pshared, int val, const struct timespec *timeout);
 
+__END_DECLS
+
 #endif /* _BIONIC_FUTEX_H */
diff --git a/libc/private/bionic_ssp.h b/libc/private/bionic_ssp.h
new file mode 100644
index 0000000..9883d72
--- /dev/null
+++ b/libc/private/bionic_ssp.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PRIVATE_SSP_H
+#define _PRIVATE_SSP_H
+
+#include <stdint.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+/* GCC uses this on ARM and MIPS; we use it on x86 to set the guard in TLS. */
+extern uintptr_t __stack_chk_guard;
+
+/* GCC calls this if a stack guard check fails. */
+extern void __stack_chk_fail();
+
+__END_DECLS
+
+#endif
diff --git a/libc/private/bionic_tls.h b/libc/private/bionic_tls.h
index 4658866..dd6b932 100644
--- a/libc/private/bionic_tls.h
+++ b/libc/private/bionic_tls.h
@@ -43,92 +43,52 @@
  ** pre-allocated slot directly for performance reason).
  **/
 
-/* maximum number of elements in the TLS array */
-#define BIONIC_TLS_SLOTS            64
+/* Well-known TLS slots. What data goes in which slot is arbitrary unless otherwise noted. */
+enum {
+  TLS_SLOT_SELF = 0, /* The kernel requires this specific slot for x86. */
+  TLS_SLOT_THREAD_ID,
+  TLS_SLOT_ERRNO,
 
-/* note that slot 0, called TLS_SLOT_SELF must point to itself.
- * this is required to implement thread-local storage with the x86
- * Linux kernel, that reads the TLS from fs:[0], where 'fs' is a
- * thread-specific segment descriptor...
+  /* These two aren't used by bionic itself, but allow the graphics code to
+   * access TLS directly rather than using the pthread API. */
+  TLS_SLOT_OPENGL_API = 3,
+  TLS_SLOT_OPENGL = 4,
+
+  /* This slot is only used to pass information from the dynamic linker to
+   * libc.so when the C library is loaded in to memory. The C runtime init
+   * function will then clear it. Since its use is extremely temporary,
+   * we reuse an existing location that isn't needed during libc startup. */
+  TLS_SLOT_BIONIC_PREINIT = TLS_SLOT_OPENGL_API,
+
+  TLS_SLOT_STACK_GUARD = 5, /* GCC requires this specific slot for x86. */
+  TLS_SLOT_DLERROR,
+
+  TLS_SLOT_FIRST_USER_SLOT /* Must come last! */
+};
+
+/*
+ * Maximum number of elements in the TLS array.
+ * POSIX says this must be at least 128, but Android has traditionally had only 64, minus those
+ * ones used internally by bionic itself.
+ * There are two kinds of slot used internally by bionic --- there are the well-known slots
+ * enumerated above, and then there are those that are allocated during startup by calls to
+ * pthread_key_create; grep for GLOBAL_INIT_THREAD_LOCAL_BUFFER to find those. We need to manually
+ * maintain that second number, but pthread_test will fail if we forget.
  */
-
-/* Well known TLS slots */
-#define TLS_SLOT_SELF               0
-#define TLS_SLOT_THREAD_ID          1
-#define TLS_SLOT_ERRNO              2
-
-#define TLS_SLOT_OPENGL_API         3
-#define TLS_SLOT_OPENGL             4
-
-/* this slot is only used to pass information from the dynamic linker to
- * libc.so when the C library is loaded in to memory. The C runtime init
- * function will then clear it. Since its use is extremely temporary,
- * we reuse an existing location.
- */
-#define  TLS_SLOT_BIONIC_PREINIT    (TLS_SLOT_ERRNO+1)
-
-/* small technical note: it is not possible to call pthread_setspecific
- * on keys that are <= TLS_SLOT_MAX_WELL_KNOWN, which is why it is set to
- * TLS_SLOT_ERRNO.
- *
- * later slots like TLS_SLOT_OPENGL are pre-allocated through the use of
- * TLS_DEFAULT_ALLOC_MAP. this means that there is no need to use
- * pthread_key_create() to initialize them. on the other hand, there is
- * no destructor associated to them (we might need to implement this later)
- */
-#define TLS_SLOT_MAX_WELL_KNOWN     TLS_SLOT_ERRNO
-
-#define TLS_DEFAULT_ALLOC_MAP       0x0000001F
-
-/* set the Thread Local Storage, must contain at least BIONIC_TLS_SLOTS pointers */
-extern void __init_tls(void**  tls, void*  thread_info);
+#define GLOBAL_INIT_THREAD_LOCAL_BUFFER_COUNT 4
+#define BIONIC_TLS_SLOTS 64
 
 /* syscall only, do not call directly */
-extern int __set_tls(void *ptr);
+extern int __set_tls(void* ptr);
 
 /* get the TLS */
-#ifdef __arm__
-/* The standard way to get the TLS is to call a kernel helper
- * function (i.e. a function provided at a fixed address in a
- * "magic page" mapped in all user-space address spaces ), which
- * contains the most appropriate code path for the target device.
- *
- * However, for performance reasons, we're going to use our own
- * machine code for the system's C shared library.
- *
- * We cannot use this optimization in the static version of the
- * C library, because we don't know where the corresponding code
- * is going to run.
- */
-#  ifdef LIBC_STATIC
-
-/* Use the kernel helper in static C library. */
-  typedef volatile void* (__kernel_get_tls_t)(void);
-#    define __get_tls() (*(__kernel_get_tls_t *)0xffff0fe0)()
-
-#  else /* !LIBC_STATIC */
-/* Use optimized code path.
- * Note that HAVE_ARM_TLS_REGISTER is build-specific
- * (it must match your kernel configuration)
- */
-#    ifdef HAVE_ARM_TLS_REGISTER
- /* We can read the address directly from a coprocessor
-  * register, which avoids touching the data cache
-  * completely.
-  */
-#      define __get_tls() \
+#if defined(__arm__)
+# define __get_tls() \
     ({ register unsigned int __val asm("r0"); \
        asm ("mrc p15, 0, r0, c13, c0, 3" : "=r"(__val) ); \
        (volatile void*)__val; })
-#    else /* !HAVE_ARM_TLS_REGISTER */
- /* The kernel provides the address of the TLS at a fixed
-  * address of the magic page too.
-  */
-#      define __get_tls() ( *((volatile void **) 0xffff0ff0) )
-#    endif
-#  endif /* !LIBC_STATIC */
 #elif defined(__mips__)
-#    define __get_tls() \
+# define __get_tls() \
     ({ register unsigned int __val asm("v1");   \
         asm (                                   \
             "   .set    push\n"                 \
@@ -138,16 +98,23 @@
             : "=r"(__val)                       \
             );                                  \
         (volatile void*)__val; })
+#elif defined(__i386__)
+# define __get_tls() \
+    ({ register void* __val; \
+       asm ("movl %%gs:0, %0" : "=r"(__val)); \
+       (volatile void*) __val; })
 #else
-extern void*  __get_tls( void );
+#error unsupported architecture
 #endif
 
 /* return the stack base and size, used by our malloc debugger */
-extern void*  __get_stack_base(int  *p_stack_size);
-
-/* Initialize the TLS. */
-extern void __libc_init_tls(unsigned** elfdata);
+extern void* __get_stack_base(int* p_stack_size);
 
 __END_DECLS
 
+#if defined(__cplusplus)
+struct KernelArgumentBlock;
+extern void __libc_init_tls(KernelArgumentBlock& args);
+#endif
+
 #endif /* _SYS_TLS_H */
diff --git a/libc/private/debug_format.h b/libc/private/debug_format.h
new file mode 100644
index 0000000..0bc1148
--- /dev/null
+++ b/libc/private/debug_format.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _DEBUG_FORMAT_H
+#define _DEBUG_FORMAT_H
+
+#include <sys/cdefs.h>
+#include <stdarg.h>
+#include <stddef.h>
+
+__BEGIN_DECLS
+
+// Formatting routines for the C library's internal debugging.
+// Unlike the usual alternatives, these don't allocate.
+
+__LIBC_HIDDEN__ int __libc_format_buffer(char* buffer, size_t buffer_size, const char* format, ...)
+    __attribute__((__format__(printf, 3, 4)));
+
+__LIBC_HIDDEN__ int __libc_format_fd(int fd, const char* format, ...)
+    __attribute__((__format__(printf, 2, 3)));
+
+__LIBC_HIDDEN__ int __libc_format_log(int priority, const char* tag, const char* format, ...)
+    __attribute__((__format__(printf, 3, 4)));
+
+__LIBC_HIDDEN__ int __libc_format_log_va_list(int priority, const char* tag, const char* format,
+                                              va_list ap);
+
+__END_DECLS
+
+#endif /* _DEBUG_FORMAT_H */
diff --git a/libc/private/isc/assertions.h b/libc/private/isc/assertions.h
deleted file mode 100644
index 921d18f..0000000
--- a/libc/private/isc/assertions.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/*	$NetBSD: assertions.h,v 1.1.1.1 2004/05/20 19:49:41 christos Exp $	*/
-
-/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1997-1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/*
- * Id: assertions.h,v 1.1.206.1 2004/03/09 08:33:30 marka Exp
- */
-
-#ifndef ASSERTIONS_H
-#define ASSERTIONS_H		1
-
-typedef enum {
-	assert_require, assert_ensure, assert_insist, assert_invariant
-} assertion_type;
-
-typedef void (*assertion_failure_callback)(const char *, int, assertion_type,
-					   const char *, int);
-
-extern assertion_failure_callback __assertion_failed;
-void set_assertion_failure_callback(assertion_failure_callback f);
-const char *assertion_type_to_text(assertion_type type);
-
-#ifdef CHECK_ALL
-#define CHECK_REQUIRE		1
-#define CHECK_ENSURE		1
-#define CHECK_INSIST		1
-#define CHECK_INVARIANT		1
-#endif
-
-#ifdef CHECK_NONE
-#define CHECK_REQUIRE		0
-#define CHECK_ENSURE		0
-#define CHECK_INSIST		0
-#define CHECK_INVARIANT		0
-#endif
-
-#ifndef CHECK_REQUIRE
-#define CHECK_REQUIRE		1
-#endif
-
-#ifndef CHECK_ENSURE
-#define CHECK_ENSURE		1
-#endif
-
-#ifndef CHECK_INSIST
-#define CHECK_INSIST		1
-#endif
-
-#ifndef CHECK_INVARIANT
-#define CHECK_INVARIANT		1
-#endif
-
-#if CHECK_REQUIRE != 0
-#define REQUIRE(cond) \
-	((void) ((cond) || \
-		 ((__assertion_failed)(__FILE__, __LINE__, assert_require, \
-				       #cond, 0), 0)))
-#define REQUIRE_ERR(cond) \
-	((void) ((cond) || \
-		 ((__assertion_failed)(__FILE__, __LINE__, assert_require, \
-				       #cond, 1), 0)))
-#else
-#define REQUIRE(cond)		((void) (cond))
-#define REQUIRE_ERR(cond)	((void) (cond))
-#endif /* CHECK_REQUIRE */
-
-#if CHECK_ENSURE != 0
-#define ENSURE(cond) \
-	((void) ((cond) || \
-		 ((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \
-				       #cond, 0), 0)))
-#define ENSURE_ERR(cond) \
-	((void) ((cond) || \
-		 ((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \
-				       #cond, 1), 0)))
-#else
-#define ENSURE(cond)		((void) (cond))
-#define ENSURE_ERR(cond)	((void) (cond))
-#endif /* CHECK_ENSURE */
-
-#if CHECK_INSIST != 0
-#define INSIST(cond) \
-	((void) ((cond) || \
-		 ((__assertion_failed)(__FILE__, __LINE__, assert_insist, \
-				       #cond, 0), 0)))
-#define INSIST_ERR(cond) \
-	((void) ((cond) || \
-		 ((__assertion_failed)(__FILE__, __LINE__, assert_insist, \
-				       #cond, 1), 0)))
-#else
-#define INSIST(cond)		((void) (cond))
-#define INSIST_ERR(cond)	((void) (cond))
-#endif /* CHECK_INSIST */
-
-#if CHECK_INVARIANT != 0
-#define INVARIANT(cond) \
-	((void) ((cond) || \
-		 ((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \
-				       #cond, 0), 0)))
-#define INVARIANT_ERR(cond) \
-	((void) ((cond) || \
-		 ((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \
-				       #cond, 1), 0)))
-#else
-#define INVARIANT(cond)		((void) (cond))
-#define INVARIANT_ERR(cond)	((void) (cond))
-#endif /* CHECK_INVARIANT */
-
-#endif /* ASSERTIONS_H */
diff --git a/libc/private/isc/dst.h b/libc/private/isc/dst.h
deleted file mode 100644
index afb0710..0000000
--- a/libc/private/isc/dst.h
+++ /dev/null
@@ -1,182 +0,0 @@
-/*	$NetBSD: dst.h,v 1.1.1.1 2004/05/20 19:49:41 christos Exp $	*/
-
-#ifndef DST_H
-#define DST_H
-
-#ifndef HAS_DST_KEY
-typedef struct dst_key {
-	char	*dk_key_name;   /* name of the key */
-	int	dk_key_size;    /* this is the size of the key in bits */
-	int	dk_proto;       /* what protocols this key can be used for */
-	int	dk_alg;         /* algorithm number from key record */
-	u_int32_t dk_flags;     /* and the flags of the public key */
-	u_int16_t dk_id;        /* identifier of the key */
-} DST_KEY;
-#endif /* HAS_DST_KEY */
-
-/*
- * do not taint namespace
- */
-#define	dst_bsafe_init		__dst_bsafe_init
-#define	dst_buffer_to_key	__dst_buffer_to_key
-#define	dst_check_algorithm	__dst_check_algorithm
-#define	dst_compare_keys	__dst_compare_keys
-#define	dst_cylink_init		__dst_cylink_init
-#define	dst_dnskey_to_key	__dst_dnskey_to_key
-#define	dst_eay_dss_init	__dst_eay_dss_init
-#define	dst_free_key		__dst_free_key
-#define	dst_generate_key	__dst_generate_key
-#define	dst_hmac_md5_init	__dst_hmac_md5_init
-#define	dst_init		__dst_init
-#define	dst_key_to_buffer	__dst_key_to_buffer
-#define	dst_key_to_dnskey	__dst_key_to_dnskey
-#define	dst_read_key		__dst_read_key
-#define	dst_rsaref_init		__dst_rsaref_init
-#define	dst_s_build_filename	__dst_s_build_filename
-#define	dst_s_calculate_bits	__dst_s_calculate_bits
-#define	dst_s_conv_bignum_b64_to_u8	__dst_s_conv_bignum_b64_to_u8
-#define	dst_s_conv_bignum_u8_to_b64	__dst_s_conv_bignum_u8_to_b64
-#define	dst_s_dns_key_id	__dst_s_dns_key_id
-#define	dst_s_dump		__dst_s_dump
-#define	dst_s_filename_length	__dst_s_filename_length
-#define	dst_s_fopen		__dst_s_fopen
-#define	dst_s_get_int16		__dst_s_get_int16
-#define	dst_s_get_int32		__dst_s_get_int32
-#define	dst_s_id_calc		__dst_s_id_calc
-#define	dst_s_put_int16		__dst_s_put_int16
-#define	dst_s_put_int32		__dst_s_put_int32
-#define	dst_s_quick_random	__dst_s_quick_random
-#define	dst_s_quick_random_set	__dst_s_quick_random_set
-#define	dst_s_random		__dst_s_random
-#define	dst_s_semi_random	__dst_s_semi_random
-#define	dst_s_verify_str	__dst_s_verify_str
-#define	dst_sig_size		__dst_sig_size
-#define	dst_sign_data		__dst_sign_data
-#define	dst_verify_data		__dst_verify_data
-#define	dst_write_key		__dst_write_key
-
-/* 
- * DST Crypto API defintions 
- */
-void     dst_init(void);
-int      dst_check_algorithm(const int);
-
-int dst_sign_data(const int,	 	/* specifies INIT/UPDATE/FINAL/ALL */
-		  DST_KEY *,	 	/* the key to use */
-		  void **,	 	/* pointer to state structure */
-		  const u_char *,	/* data to be signed */
-		  const int,	 	/* length of input data */
-		  u_char *,	 	/* buffer to write signature to */
-		  const int);	 	/* size of output buffer */
-
-int dst_verify_data(const int,	 	/* specifies INIT/UPDATE/FINAL/ALL */
-		    DST_KEY *,	 	/* the key to use */
-		    void **,	 	/* pointer to state structure */
-		    const u_char *,	/* data to be verified */
-		    const int,	 	/* length of input data */
-		    const u_char *,	/* buffer containing signature */
-		    const int);	 	/* length of signature */
-
-
-DST_KEY *dst_read_key(const char *,	/* name of key */
-		      const u_int16_t,	/* key tag identifier */
-		      const int,	/* key algorithm */
-		      const int);	/* Private/PublicKey wanted*/
-
-int      dst_write_key(const DST_KEY *,	/* key to write out */
-		       const int); 	/* Public/Private */
-
-DST_KEY *dst_dnskey_to_key(const char *,	/* KEY record name */
-			   const u_char *,	/* KEY RDATA */
-			   const int);		/* size of input buffer*/
-
-
-int      dst_key_to_dnskey(const DST_KEY *,	/* key to translate */
-			   u_char *,		/* output buffer */
-			   const int);		/* size of out_storage*/
-
-
-DST_KEY *dst_buffer_to_key(const char *,  	/* name of the key */
-			   const int,	  	/* algorithm */
-			   const int,	  	/* dns flags */
-			   const int,	  	/* dns protocol */
-			   const u_char *, 	/* key in dns wire fmt */
-			   const int);	  	/* size of key */
-
-
-int     dst_key_to_buffer(DST_KEY *, u_char *, int);
-
-DST_KEY *dst_generate_key(const char *,    	/* name of new key */
-			  const int,       	/* key algorithm to generate */
-			  const int,      	/* size of new key */
-			  const int,       	/* alg dependent parameter*/
-			  const int,     	/* key DNS flags */
-			  const int);		/* key DNS protocol */
-
-DST_KEY *dst_free_key(DST_KEY *);
-int      dst_compare_keys(const DST_KEY *, const DST_KEY *);
-
-int	dst_sig_size(DST_KEY *);
-
-
-/* support for dns key tags/ids */
-u_int16_t dst_s_dns_key_id(const u_char *, const int);
-u_int16_t dst_s_id_calc(const u_char *, const int);
-
-/* Used by callers as well as by the library.  */
-#define RAW_KEY_SIZE    8192        /* large enough to store any key */
-
-/* DST_API control flags */
-/* These are used used in functions dst_sign_data and dst_verify_data */
-#define SIG_MODE_INIT		1  /* initialize digest */
-#define SIG_MODE_UPDATE		2  /* add data to digest */
-#define SIG_MODE_FINAL		4  /* generate/verify signature */
-#define SIG_MODE_ALL		(SIG_MODE_INIT|SIG_MODE_UPDATE|SIG_MODE_FINAL)
-
-/* Flags for dst_read_private_key()  */
-#define DST_FORCE_READ		0x1000000
-#define DST_CAN_SIGN		0x010F
-#define DST_NO_AUTHEN		0x8000
-#define DST_EXTEND_FLAG         0x1000
-#define DST_STANDARD		0
-#define DST_PRIVATE             0x2000000
-#define DST_PUBLIC              0x4000000
-#define DST_RAND_SEMI           1
-#define DST_RAND_STD            2
-#define DST_RAND_KEY            3
-#define DST_RAND_DSS            4
-
-
-/* DST algorithm codes */
-#define KEY_RSA			1
-#define KEY_DH			2
-#define KEY_DSA			3
-#define KEY_PRIVATE		254
-#define KEY_EXPAND		255
-#define KEY_HMAC_MD5		157
-#define KEY_HMAC_SHA1		158
-#define UNKNOWN_KEYALG		0
-#define DST_MAX_ALGS            KEY_HMAC_SHA1
-
-/* DST constants to locations in KEY record  changes in new KEY record */
-#define DST_FLAGS_SIZE		2
-#define DST_KEY_PROT		2
-#define DST_KEY_ALG		3
-#define DST_EXT_FLAG            4
-#define DST_KEY_START		4
-
-#ifndef SIGN_F_NOKEY 
-#define SIGN_F_NOKEY		0xC000
-#endif
-
-/* error codes from dst routines */
-#define SIGN_INIT_FAILURE	(-23)
-#define SIGN_UPDATE_FAILURE	(-24)
-#define SIGN_FINAL_FAILURE	(-25)
-#define VERIFY_INIT_FAILURE	(-26)
-#define VERIFY_UPDATE_FAILURE	(-27)
-#define VERIFY_FINAL_FAILURE	(-28)
-#define MISSING_KEY_OR_SIGNATURE (-30)
-#define UNSUPPORTED_KEYALG	(-31)
-
-#endif /* DST_H */
diff --git a/libc/private/isc/eventlib.h b/libc/private/isc/eventlib.h
deleted file mode 100644
index 9185f67..0000000
--- a/libc/private/isc/eventlib.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/*	$NetBSD: eventlib.h,v 1.1.1.3 2005/12/21 23:15:22 christos Exp $	*/
-
-/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1995-1999 by Internet Software Consortium
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/* eventlib.h - exported interfaces for eventlib
- * vix 09sep95 [initial]
- *
- * Id: eventlib.h,v 1.1.2.1.4.2 2005/07/28 07:43:18 marka Exp
- */
-
-#ifndef _EVENTLIB_H
-#define _EVENTLIB_H
-
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <sys/time.h>
-#include <stdio.h>
-
-#ifndef __P
-# define __EVENTLIB_P_DEFINED
-# ifdef __STDC__
-#  define __P(x) x
-# else
-#  define __P(x) ()
-# endif
-#endif
-
-/* In the absence of branded types... */
-typedef struct { void *opaque; } evConnID;
-typedef struct { void *opaque; } evFileID;
-typedef struct { void *opaque; } evStreamID;
-typedef struct { void *opaque; } evTimerID;
-typedef struct { void *opaque; } evWaitID;
-typedef struct { void *opaque; } evContext;
-typedef struct { void *opaque; } evEvent;
-
-#define	evInitID(id) ((id)->opaque = NULL)
-#define	evTestID(id) ((id).opaque != NULL)
-
-typedef void (*evConnFunc)__P((evContext, void *, int, const void *, int,
-			       const void *, int));
-typedef void (*evFileFunc)__P((evContext, void *, int, int));
-typedef	void (*evStreamFunc)__P((evContext, void *, int, int));
-typedef void (*evTimerFunc)__P((evContext, void *,
-				struct timespec, struct timespec));
-typedef	void (*evWaitFunc)__P((evContext, void *, const void *));
-
-typedef	struct { unsigned char mask[256/8]; } evByteMask;
-#define	EV_BYTEMASK_BYTE(b) ((b) / 8)
-#define	EV_BYTEMASK_MASK(b) (1 << ((b) % 8))
-#define	EV_BYTEMASK_SET(bm, b) \
-	((bm).mask[EV_BYTEMASK_BYTE(b)] |= EV_BYTEMASK_MASK(b))
-#define	EV_BYTEMASK_CLR(bm, b) \
-	((bm).mask[EV_BYTEMASK_BYTE(b)] &= ~EV_BYTEMASK_MASK(b))
-#define	EV_BYTEMASK_TST(bm, b) \
-	((bm).mask[EV_BYTEMASK_BYTE(b)] & EV_BYTEMASK_MASK(b))
-
-#define	EV_POLL		1
-#define	EV_WAIT		2
-#define	EV_NULL		4
-
-#define	EV_READ		1
-#define	EV_WRITE	2
-#define	EV_EXCEPT	4
-
-#define EV_WASNONBLOCKING 8	/* Internal library use. */
-
-/* eventlib.c */
-#define evCreate	__evCreate
-#define evSetDebug	__evSetDebug
-#define evDestroy	__evDestroy
-#define evGetNext	__evGetNext
-#define evDispatch	__evDispatch
-#define evDrop		__evDrop
-#define evMainLoop	__evMainLoop
-#define evHighestFD	__evHighestFD
-#define evGetOption	__evGetOption
-#define evSetOption	__evSetOption
-
-int  evCreate __P((evContext *));
-void evSetDebug __P((evContext, int, FILE *));
-int  evDestroy __P((evContext));
-int  evGetNext __P((evContext, evEvent *, int));
-int  evDispatch __P((evContext, evEvent));
-void evDrop __P((evContext, evEvent));
-int  evMainLoop __P((evContext));
-int  evHighestFD __P((evContext));
-int  evGetOption __P((evContext *, const char *, int *));
-int  evSetOption __P((evContext *, const char *, int));
-
-/* ev_connects.c */
-#define evListen	__evListen
-#define evConnect	__evConnect
-#define evCancelConn	__evCancelConn
-#define evHold		__evHold
-#define evUnhold	__evUnhold
-#define evTryAccept	__evTryAccept
-
-int evListen __P((evContext, int, int, evConnFunc, void *, evConnID *));
-int evConnect __P((evContext, int, const void *, int,
-		   evConnFunc, void *, evConnID *));
-int evCancelConn __P((evContext, evConnID));
-int evHold __P((evContext, evConnID));
-int evUnhold __P((evContext, evConnID));
-int evTryAccept __P((evContext, evConnID, int *));
-
-/* ev_files.c */
-#define evSelectFD	__evSelectFD
-#define evDeselectFD	__evDeselectFD
-
-int evSelectFD __P((evContext, int, int, evFileFunc, void *, evFileID *));
-int evDeselectFD __P((evContext, evFileID));
-
-/* ev_streams.c */
-#define evConsIovec	__evConsIovec
-#define evWrite		__evWrite
-#define evRead		__evRead
-#define evTimeRW	__evTimeRW
-#define evUntimeRW	__evUntimeRW
-#define	evCancelRW	__evCancelRW
-
-struct iovec evConsIovec __P((void *, size_t));
-int evWrite __P((evContext, int, const struct iovec *, int,
-		 evStreamFunc func, void *, evStreamID *));
-int evRead __P((evContext, int, const struct iovec *, int,
-		evStreamFunc func, void *, evStreamID *));
-int evTimeRW __P((evContext, evStreamID, evTimerID timer));
-int evUntimeRW __P((evContext, evStreamID));
-int evCancelRW __P((evContext, evStreamID));
-
-/* ev_timers.c */
-#define evConsTime	__evConsTime
-#define evAddTime	__evAddTime
-#define evSubTime	__evSubTime
-#define evCmpTime	__evCmpTime
-#define	evTimeSpec	__evTimeSpec
-#define	evTimeVal	__evTimeVal
-
-#define evNowTime		__evNowTime
-#define evUTCTime		__evUTCTime
-#define evLastEventTime		__evLastEventTime
-#define evSetTimer		__evSetTimer
-#define evClearTimer		__evClearTimer
-#define evConfigTimer		__evConfigTimer
-#define evResetTimer		__evResetTimer
-#define evSetIdleTimer		__evSetIdleTimer
-#define evClearIdleTimer	__evClearIdleTimer
-#define evResetIdleTimer	__evResetIdleTimer
-#define evTouchIdleTimer	__evTouchIdleTimer
-
-struct timespec evConsTime __P((time_t sec, long nsec));
-struct timespec evAddTime __P((struct timespec, struct timespec));
-struct timespec evSubTime __P((struct timespec, struct timespec));
-struct timespec evNowTime __P((void));
-struct timespec evUTCTime __P((void));
-struct timespec evLastEventTime __P((evContext));
-struct timespec evTimeSpec __P((struct timeval));
-struct timeval evTimeVal __P((struct timespec));
-int evCmpTime __P((struct timespec, struct timespec));
-int evSetTimer __P((evContext, evTimerFunc, void *, struct timespec,
-		    struct timespec, evTimerID *));
-int evClearTimer __P((evContext, evTimerID));
-int evConfigTimer __P((evContext, evTimerID, const char *param,
-		      int value));
-int evResetTimer __P((evContext, evTimerID, evTimerFunc, void *,
-		      struct timespec, struct timespec));
-int evSetIdleTimer __P((evContext, evTimerFunc, void *, struct timespec,
-			evTimerID *));
-int evClearIdleTimer __P((evContext, evTimerID));
-int evResetIdleTimer __P((evContext, evTimerID, evTimerFunc, void *,
-			  struct timespec));
-int evTouchIdleTimer __P((evContext, evTimerID));
-
-/* ev_waits.c */
-#define evWaitFor	__evWaitFor
-#define evDo		__evDo
-#define evUnwait	__evUnwait
-#define evDefer		__evDefer
-
-int evWaitFor __P((evContext, const void *, evWaitFunc, void *, evWaitID *));
-int evDo __P((evContext, const void *));
-int evUnwait __P((evContext, evWaitID));
-int evDefer __P((evContext, evWaitFunc, void *));
-
-#ifdef __EVENTLIB_P_DEFINED
-# undef __P
-#endif
-
-#endif /*_EVENTLIB_H*/
diff --git a/libc/private/isc/heap.h b/libc/private/isc/heap.h
deleted file mode 100644
index ea5a6e9..0000000
--- a/libc/private/isc/heap.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*	$NetBSD: heap.h,v 1.1.1.1 2004/05/20 19:49:41 christos Exp $	*/
-
-/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1997,1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-typedef int (*heap_higher_priority_func)(void *, void *);
-typedef void (*heap_index_func)(void *, int);
-typedef void (*heap_for_each_func)(void *, void *);
-
-typedef struct heap_context {
-	int array_size;
-	int array_size_increment;
-	int heap_size;
-	void **heap;
-	heap_higher_priority_func higher_priority;
-	heap_index_func index;
-} *heap_context;
-
-#define heap_new	__heap_new
-#define heap_free	__heap_free
-#define heap_insert	__heap_insert
-#define heap_delete	__heap_delete
-#define heap_increased	__heap_increased
-#define heap_decreased	__heap_decreased
-#define heap_element	__heap_element
-#define heap_for_each	__heap_for_each
-
-heap_context	heap_new(heap_higher_priority_func, heap_index_func, int);
-int		heap_free(heap_context);
-int		heap_insert(heap_context, void *);
-int		heap_delete(heap_context, int);
-int		heap_increased(heap_context, int);
-int		heap_decreased(heap_context, int);
-void *		heap_element(heap_context, int);
-int		heap_for_each(heap_context, heap_for_each_func, void *);
diff --git a/libc/private/isc/list.h b/libc/private/isc/list.h
deleted file mode 100644
index 489766a..0000000
--- a/libc/private/isc/list.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*	$NetBSD: list.h,v 1.2 2004/05/20 19:51:55 christos Exp $	*/
-
-/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1997,1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef LIST_H
-#define LIST_H 1
-#include <isc/assertions.h>
-
-#define LIST(type) struct { type *head, *tail; }
-#define INIT_LIST(list) \
-	do { (list).head = NULL; (list).tail = NULL; } while (/*CONSTCOND*/0)
-
-#define LINK(type) struct { type *prev, *next; }
-#define INIT_LINK_TYPE(elt, link, type) \
-	do { \
-		(elt)->link.prev = (type *)(-1); \
-		(elt)->link.next = (type *)(-1); \
-	} while (/*CONSTCOND*/0)
-#define INIT_LINK(elt, link) \
-	INIT_LINK_TYPE(elt, link, void)
-#define LINKED(elt, link) ((void *)((elt)->link.prev) != (void *)(-1))
-
-#define HEAD(list) ((list).head)
-#define TAIL(list) ((list).tail)
-#define EMPTY(list) ((list).head == NULL)
-
-#define PREPEND(list, elt, link) \
-	do { \
-		INSIST(!LINKED(elt, link));\
-		if ((list).head != NULL) \
-			(list).head->link.prev = (elt); \
-		else \
-			(list).tail = (elt); \
-		(elt)->link.prev = NULL; \
-		(elt)->link.next = (list).head; \
-		(list).head = (elt); \
-	} while (/*CONSTCOND*/0)
-
-#define APPEND(list, elt, link) \
-	do { \
-		INSIST(!LINKED(elt, link));\
-		if ((list).tail != NULL) \
-			(list).tail->link.next = (elt); \
-		else \
-			(list).head = (elt); \
-		(elt)->link.prev = (list).tail; \
-		(elt)->link.next = NULL; \
-		(list).tail = (elt); \
-	} while (/*CONSTCOND*/0)
-
-#define UNLINK_TYPE(list, elt, link, type) \
-	do { \
-		INSIST(LINKED(elt, link));\
-		if ((elt)->link.next != NULL) \
-			(elt)->link.next->link.prev = (elt)->link.prev; \
-		else \
-			(list).tail = (elt)->link.prev; \
-		if ((elt)->link.prev != NULL) \
-			(elt)->link.prev->link.next = (elt)->link.next; \
-		else \
-			(list).head = (elt)->link.next; \
-		INIT_LINK_TYPE(elt, link, type); \
-	} while (/*CONSTCOND*/0)
-#define UNLINK(list, elt, link) \
-	UNLINK_TYPE(list, elt, link, void)
-
-#define PREV(elt, link) ((elt)->link.prev)
-#define NEXT(elt, link) ((elt)->link.next)
-
-#define INSERT_BEFORE(list, before, elt, link) \
-	do { \
-		INSIST(!LINKED(elt, link));\
-		if ((before)->link.prev == NULL) \
-			PREPEND(list, elt, link); \
-		else { \
-			(elt)->link.prev = (before)->link.prev; \
-			(before)->link.prev = (elt); \
-			(elt)->link.prev->link.next = (elt); \
-			(elt)->link.next = (before); \
-		} \
-	} while (/*CONSTCOND*/0)
-
-#define INSERT_AFTER(list, after, elt, link) \
-	do { \
-		INSIST(!LINKED(elt, link));\
-		if ((after)->link.next == NULL) \
-			APPEND(list, elt, link); \
-		else { \
-			(elt)->link.next = (after)->link.next; \
-			(after)->link.next = (elt); \
-			(elt)->link.next->link.prev = (elt); \
-			(elt)->link.prev = (after); \
-		} \
-	} while (/*CONSTCOND*/0)
-
-#define ENQUEUE(list, elt, link) APPEND(list, elt, link)
-#define DEQUEUE(list, elt, link) UNLINK(list, elt, link)
-
-#endif /* LIST_H */
diff --git a/libc/private/isc/memcluster.h b/libc/private/isc/memcluster.h
deleted file mode 100644
index edaaf20..0000000
--- a/libc/private/isc/memcluster.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*	$NetBSD: memcluster.h,v 1.1.1.1 2004/05/20 19:49:41 christos Exp $	*/
-
-/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1997,1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MEMCLUSTER_H
-#define MEMCLUSTER_H
-
-#include <stdio.h>
-
-#define meminit		__meminit
-#ifdef MEMCLUSTER_DEBUG
-#define memget(s)	__memget_debug(s, __FILE__, __LINE__)
-#define memput(p, s)	__memput_debug(p, s, __FILE__, __LINE__)
-#else /*MEMCLUSTER_DEBUG*/
-#ifdef MEMCLUSTER_RECORD
-#define memget(s)	__memget_record(s, __FILE__, __LINE__)
-#define memput(p, s)	__memput_record(p, s, __FILE__, __LINE__)
-#else /*MEMCLUSTER_RECORD*/
-#define memget		__memget
-#define memput		__memput
-#endif /*MEMCLUSTER_RECORD*/
-#endif /*MEMCLUSTER_DEBUG*/
-#define memstats	__memstats
-#define memactive	__memactive
-
-int	meminit(size_t, size_t);
-void *	__memget(size_t);
-void 	__memput(void *, size_t);
-void *	__memget_debug(size_t, const char *, int);
-void 	__memput_debug(void *, size_t, const char *, int);
-void *	__memget_record(size_t, const char *, int);
-void 	__memput_record(void *, size_t, const char *, int);
-void 	memstats(FILE *);
-int	memactive(void);
-
-#endif /* MEMCLUSTER_H */
diff --git a/libc/private/kernel_sigset_t.h b/libc/private/kernel_sigset_t.h
new file mode 100644
index 0000000..733a842
--- /dev/null
+++ b/libc/private/kernel_sigset_t.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef LIBC_PRIVATE_KERNEL_SIGSET_T_H_
+#define LIBC_PRIVATE_KERNEL_SIGSET_T_H_
+
+// Our sigset_t is wrong for ARM and x86. It's 32-bit but the kernel expects 64 bits.
+// This means we can't support real-time signals correctly until we can change the ABI.
+// In the meantime, we can use this union to pass an appropriately-sized block of memory
+// to the kernel, at the cost of not being able to refer to real-time signals.
+union kernel_sigset_t {
+  kernel_sigset_t() {
+    clear();
+  }
+
+  kernel_sigset_t(const sigset_t* value) {
+    clear();
+    set(value);
+  }
+
+  void clear() {
+    memset(this, 0, sizeof(*this));
+  }
+
+  void set(const sigset_t* value) {
+    bionic = *value;
+  }
+
+  sigset_t* get() {
+    return &bionic;
+  }
+
+  sigset_t bionic;
+#ifndef __mips__
+  uint32_t kernel[2];
+#endif
+};
+
+#endif
diff --git a/libc/private/logd.h b/libc/private/logd.h
index c81a91a..a2828ec 100644
--- a/libc/private/logd.h
+++ b/libc/private/logd.h
@@ -29,6 +29,7 @@
 #define _ANDROID_BIONIC_LOGD_H
 
 #include <stdarg.h>
+#include <stdint.h>
 
 #define BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW 80100
 #define BIONIC_EVENT_STRCAT_BUFFER_OVERFLOW 80105
@@ -70,6 +71,8 @@
 void __libc_android_log_event_int(int32_t tag, int value);
 void __libc_android_log_event_uid(int32_t tag);
 
+__noreturn extern void __fortify_chk_fail(const char *, uint32_t);
+
 #ifdef __cplusplus
 };
 #endif
diff --git a/libc/private/rand48.h b/libc/private/rand48.h
index afa49f6..1ad8b0d 100644
--- a/libc/private/rand48.h
+++ b/libc/private/rand48.h
@@ -1,3 +1,5 @@
+/*	$NetBSD: rand48.h,v 1.6 2011/05/18 19:36:36 dsl Exp $	*/
+
 /*
  * Copyright (c) 1993 Martin Birgmeier
  * All rights reserved.
@@ -9,17 +11,17 @@
  * This software is provided ``as is'', and comes with no warranties
  * of any kind. I shall in no event be liable for anything that happens
  * to anyone/anything when using this software.
- *
- *	$OpenBSD: rand48.h,v 1.3 2002/02/16 21:27:24 millert Exp $
  */
 
 #ifndef _RAND48_H_
 #define _RAND48_H_
 
-#include <math.h>
 #include <stdlib.h>
 
-void		__dorand48(unsigned short[3]);
+extern void		__dorand48(unsigned short[3]);
+extern unsigned short	__rand48_seed[3];
+extern unsigned short	__rand48_mult[3];
+extern unsigned short	__rand48_add;
 
 #define	RAND48_SEED_0	(0x330e)
 #define	RAND48_SEED_1	(0xabcd)
diff --git a/libc/stdio/__fgets_chk.c b/libc/stdio/__fgets_chk.c
deleted file mode 100644
index 19123b9..0000000
--- a/libc/stdio/__fgets_chk.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <private/logd.h>
-
-/*
- * __fgets_chk. Called in place of fgets() when we know the
- * size of the buffer we're writing into.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- * for details.
- *
- * This fgets check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-char *__fgets_chk(char *dest, int supplied_size,
-                  FILE *stream, size_t dest_len_from_compiler)
-{
-    if (supplied_size < 0) {
-        __libc_android_log_print(ANDROID_LOG_FATAL, "libc",
-            "*** fgets buffer size less than 0 ***\n");
-        abort();
-    }
-
-    if (((size_t) supplied_size) > dest_len_from_compiler) {
-        __libc_android_log_print(ANDROID_LOG_FATAL, "libc",
-            "*** fgets buffer overflow detected ***\n");
-        abort();
-    }
-
-    return fgets(dest, supplied_size, stream);
-}
diff --git a/libc/stdio/__snprintf_chk.c b/libc/stdio/__snprintf_chk.c
deleted file mode 100644
index dbda3db..0000000
--- a/libc/stdio/__snprintf_chk.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-
-/*
- * Runtime implementation of __builtin____snprintf_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This snprintf check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-int __snprintf_chk(
-        char *dest,
-        size_t supplied_size,
-        int flags,
-        size_t dest_len_from_compiler,
-        const char *format, ...)
-{
-    va_list va;
-    int retval;
-
-    va_start(va, format);
-    retval = __vsnprintf_chk(dest, supplied_size, flags,
-                             dest_len_from_compiler, format, va);
-    va_end(va);
-
-    return retval;
-}
diff --git a/libc/stdio/__sprintf_chk.c b/libc/stdio/__sprintf_chk.c
deleted file mode 100644
index 67acbe1..0000000
--- a/libc/stdio/__sprintf_chk.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-
-/*
- * Runtime implementation of __builtin____sprintf_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This sprintf check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-int __sprintf_chk(
-        char *dest,
-        int flags,
-        size_t dest_len_from_compiler,
-        const char *format, ...)
-{
-    va_list va;
-    int retval;
-
-    va_start(va, format);
-    retval = __vsprintf_chk(dest, flags,
-                             dest_len_from_compiler, format, va);
-    va_end(va);
-
-    return retval;
-}
diff --git a/libc/stdio/__vsnprintf_chk.c b/libc/stdio/__vsnprintf_chk.c
deleted file mode 100644
index a1a1039..0000000
--- a/libc/stdio/__vsnprintf_chk.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <private/logd.h>
-
-/*
- * Runtime implementation of __builtin____vsnprintf_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This vsnprintf check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-int __vsnprintf_chk(
-        char *dest,
-        size_t supplied_size,
-        int flags,
-        size_t dest_len_from_compiler,
-        const char *format,
-        va_list va)
-{
-    if (supplied_size > dest_len_from_compiler) {
-        __libc_android_log_print(ANDROID_LOG_FATAL, "libc",
-            "*** vsnprintf buffer overflow detected ***\n");
-        abort();
-    }
-
-    return vsnprintf(dest, supplied_size, format, va);
-}
diff --git a/libc/stdio/__vsprintf_chk.c b/libc/stdio/__vsprintf_chk.c
deleted file mode 100644
index 8a809fc..0000000
--- a/libc/stdio/__vsprintf_chk.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <private/logd.h>
-
-/*
- * Runtime implementation of __builtin____vsprintf_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This vsprintf check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-int __vsprintf_chk(
-        char *dest,
-        int flags,
-        size_t dest_len_from_compiler,
-        const char *format,
-        va_list va)
-{
-    int ret = vsnprintf(dest, dest_len_from_compiler, format, va);
-
-    if ((size_t) ret >= dest_len_from_compiler) {
-        __libc_android_log_print(ANDROID_LOG_FATAL, "libc",
-            "*** vsprintf buffer overflow detected ***\n");
-        abort();
-    }
-
-    return ret;
-}
diff --git a/libc/stdio/fopen.c b/libc/stdio/fopen.c
index a6cddd3..6d2d882 100644
--- a/libc/stdio/fopen.c
+++ b/libc/stdio/fopen.c
@@ -31,6 +31,8 @@
  * SUCH DAMAGE.
  */
 
+#define __USE_BSD
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
diff --git a/libc/stdio/freopen.c b/libc/stdio/freopen.c
index da3a674..f0386e9 100644
--- a/libc/stdio/freopen.c
+++ b/libc/stdio/freopen.c
@@ -31,6 +31,8 @@
  * SUCH DAMAGE.
  */
 
+#define __USE_BSD
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
diff --git a/libc/stdio/local.h b/libc/stdio/local.h
index 6b2111a..664cec1 100644
--- a/libc/stdio/local.h
+++ b/libc/stdio/local.h
@@ -35,10 +35,6 @@
 #include "wcio.h"
 #include "fileext.h"
 
-#ifndef DEFFILEMODE
-#define DEFFILEMODE  (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
-#endif
-
 
 /*
  * Information local to this implementation of stdio,
diff --git a/libc/stdio/tmpfile.c b/libc/stdio/tmpfile.c
deleted file mode 100644
index 39f7e92..0000000
--- a/libc/stdio/tmpfile.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*	$OpenBSD: tmpfile.c,v 1.10 2005/10/10 12:00:52 espie Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <paths.h>
-
-FILE *
-tmpfile(void)
-{
-	sigset_t set, oset;
-	FILE *fp;
-	int fd, sverrno;
-#define	TRAILER	"tmp.XXXXXXXXXX"
-	char buf[sizeof(_PATH_TMP) + sizeof(TRAILER)];
-
-	(void)memcpy(buf, _PATH_TMP, sizeof(_PATH_TMP) - 1);
-	(void)memcpy(buf + sizeof(_PATH_TMP) - 1, TRAILER, sizeof(TRAILER));
-
-	sigfillset(&set);
-	(void)sigprocmask(SIG_BLOCK, &set, &oset);
-
-	fd = mkstemp(buf);
-	if (fd != -1) {
-		mode_t u;
-
-		(void)unlink(buf);
-		u = umask(0);
-		(void)umask(u);
-		(void)fchmod(fd, 0666 & ~u);
-	}
-
-	(void)sigprocmask(SIG_SETMASK, &oset, NULL);
-
-	if (fd == -1)
-		return (NULL);
-
-	if ((fp = fdopen(fd, "w+")) == NULL) {
-		sverrno = errno;
-		(void)close(fd);
-		errno = sverrno;
-		return (NULL);
-	}
-	return (fp);
-}
diff --git a/libc/stdlib/_rand48.c b/libc/stdlib/_rand48.c
deleted file mode 100644
index 7c950f7..0000000
--- a/libc/stdlib/_rand48.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*	$OpenBSD: _rand48.c,v 1.3 2005/08/08 08:05:36 espie Exp $ */
-/*
- * Copyright (c) 1993 Martin Birgmeier
- * All rights reserved.
- *
- * You may redistribute unmodified or modified versions of this source
- * code provided that the above copyright notice and this and the
- * following conditions are retained.
- *
- * This software is provided ``as is'', and comes with no warranties
- * of any kind. I shall in no event be liable for anything that happens
- * to anyone/anything when using this software.
- */
-
-#include "rand48.h"
-
-unsigned short __rand48_seed[3] = {
-	RAND48_SEED_0,
-	RAND48_SEED_1,
-	RAND48_SEED_2
-};
-unsigned short __rand48_mult[3] = {
-	RAND48_MULT_0,
-	RAND48_MULT_1,
-	RAND48_MULT_2
-};
-unsigned short __rand48_add = RAND48_ADD;
-
-void
-__dorand48(unsigned short xseed[3])
-{
-	unsigned long accu;
-	unsigned short temp[2];
-
-	accu = (unsigned long) __rand48_mult[0] * (unsigned long) xseed[0] +
-	 (unsigned long) __rand48_add;
-	temp[0] = (unsigned short) accu;	/* lower 16 bits */
-	accu >>= sizeof(unsigned short) * 8;
-	accu += (unsigned long) __rand48_mult[0] * (unsigned long) xseed[1] +
-	 (unsigned long) __rand48_mult[1] * (unsigned long) xseed[0];
-	temp[1] = (unsigned short) accu;	/* middle 16 bits */
-	accu >>= sizeof(unsigned short) * 8;
-	accu += __rand48_mult[0] * xseed[2] + __rand48_mult[1] * xseed[1] + __rand48_mult[2] * xseed[0];
-	xseed[0] = temp[0];
-	xseed[1] = temp[1];
-	xseed[2] = (unsigned short) accu;
-}
diff --git a/libc/stdlib/assert.c b/libc/stdlib/assert.c
deleted file mode 100644
index 7c0a860..0000000
--- a/libc/stdlib/assert.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*	$OpenBSD: assert.c,v 1.8 2005/08/08 08:05:33 espie Exp $ */
-/*-
- * Copyright (c) 1992, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <private/logd.h>
-
-// We log to stderr for the benefit of "adb shell" users, and the log for the benefit
-// of regular app developers who want to see their asserts.
-
-void __assert(const char* file, int line, const char* failed_expression) {
-  const char* fmt = "%s:%d: assertion \"%s\" failed\n";
-  __libc_android_log_print(ANDROID_LOG_FATAL, "libc", fmt, file, line, failed_expression);
-  fprintf(stderr, fmt, file, line, failed_expression);
-  abort();
-  /* NOTREACHED */
-}
-
-void __assert2(const char* file, int line, const char* function, const char* failed_expression) {
-  const char* fmt = "%s:%d: %s: assertion \"%s\" failed\n";
-  __libc_android_log_print(ANDROID_LOG_FATAL, "libc", fmt, file, line, function, failed_expression);
-  fprintf(stderr, fmt, file, line, function, failed_expression);
-  abort();
-  /* NOTREACHED */
-}
diff --git a/libc/stdlib/atexit.h b/libc/stdlib/atexit.h
index 1b23565..4b3e5ab 100644
--- a/libc/stdlib/atexit.h
+++ b/libc/stdlib/atexit.h
@@ -30,6 +30,8 @@
  *
  */
 
+#include <sys/cdefs.h>
+
 struct atexit {
 	struct atexit *next;		/* next in list */
 	int ind;			/* next index in this table */
@@ -44,8 +46,12 @@
 	} fns[1];			/* the table itself */
 };
 
+__BEGIN_DECLS
+
 extern int __atexit_invalid;
 extern struct atexit *__atexit;		/* points to head of LIFO stack */
 
 int	__cxa_atexit(void (*)(void *), void *, void *);
 void	__cxa_finalize(void *);
+
+__END_DECLS
diff --git a/libc/stdlib/bsearch.c b/libc/stdlib/bsearch.c
deleted file mode 100644
index 7eb6325..0000000
--- a/libc/stdlib/bsearch.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 1990 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdlib.h>
-
-/*
- * Perform a binary search.
- *
- * The code below is a bit sneaky.  After a comparison fails, we
- * divide the work in half by moving either left or right. If lim
- * is odd, moving left simply involves halving lim: e.g., when lim
- * is 5 we look at item 2, so we change lim to 2 so that we will
- * look at items 0 & 1.  If lim is even, the same applies.  If lim
- * is odd, moving right again involes halving lim, this time moving
- * the base up one item past p: e.g., when lim is 5 we change base
- * to item 3 and make lim 2 so that we will look at items 3 and 4.
- * If lim is even, however, we have to shrink it by one before
- * halving: e.g., when lim is 4, we still looked at item 2, so we
- * have to make lim 3, then halve, obtaining 1, so that we will only
- * look at item 3.
- */
-void *
-bsearch(const void *key, const void *base0, size_t nmemb, size_t size,
-    int (*compar)(const void *, const void *))
-{
-	const char *base = base0;
-	int lim, cmp;
-	const void *p;
-
-	for (lim = nmemb; lim != 0; lim >>= 1) {
-		p = base + (lim >> 1) * size;
-		cmp = (*compar)(key, p);
-		if (cmp > 0) {	/* key > p: move right */
-			base = (char *)p + size;
-			lim--;
-		} else if (cmp == 0) {
-			return ((void *)p);
-		} /* else move left */
-	}
-	return (NULL);
-}
diff --git a/libc/stdlib/div.c b/libc/stdlib/div.c
deleted file mode 100644
index f7ac2db..0000000
--- a/libc/stdlib/div.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/*	$OpenBSD: div.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */
-/*
- * Copyright (c) 1990 Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdlib.h>		/* div_t */
-
-div_t
-div(int num, int denom)
-{
-	div_t r;
-
-	r.quot = num / denom;
-	r.rem = num % denom;
-	/*
-	 * The ANSI standard says that |r.quot| <= |n/d|, where
-	 * n/d is to be computed in infinite precision.  In other
-	 * words, we should always truncate the quotient towards
-	 * 0, never -infinity.
-	 *
-	 * Machine division and remainer may work either way when
-	 * one or both of n or d is negative.  If only one is
-	 * negative and r.quot has been truncated towards -inf,
-	 * r.rem will have the same sign as denom and the opposite
-	 * sign of num; if both are negative and r.quot has been
-	 * truncated towards -inf, r.rem will be positive (will
-	 * have the opposite sign of num).  These are considered
-	 * `wrong'.
-	 *
-	 * If both are num and denom are positive, r will always
-	 * be positive.
-	 *
-	 * This all boils down to:
-	 *	if num >= 0, but r.rem < 0, we got the wrong answer.
-	 * In that case, to get the right answer, add 1 to r.quot and
-	 * subtract denom from r.rem.
-	 */
-	if (num >= 0 && r.rem < 0) {
-		r.quot++;
-		r.rem -= denom;
-	}
-	return (r);
-}
diff --git a/libc/stdlib/jrand48.c b/libc/stdlib/jrand48.c
deleted file mode 100644
index cb8c592..0000000
--- a/libc/stdlib/jrand48.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/*	$OpenBSD: jrand48.c,v 1.3 2005/08/08 08:05:36 espie Exp $ */
-/*
- * Copyright (c) 1993 Martin Birgmeier
- * All rights reserved.
- *
- * You may redistribute unmodified or modified versions of this source
- * code provided that the above copyright notice and this and the
- * following conditions are retained.
- *
- * This software is provided ``as is'', and comes with no warranties
- * of any kind. I shall in no event be liable for anything that happens
- * to anyone/anything when using this software.
- */
-
-#include "rand48.h"
-
-long
-jrand48(unsigned short xseed[3])
-{
-	__dorand48(xseed);
-	return ((long) xseed[2] << 16) + (long) xseed[1];
-}
diff --git a/libc/stdlib/ldiv.c b/libc/stdlib/ldiv.c
deleted file mode 100644
index 775065f..0000000
--- a/libc/stdlib/ldiv.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*	$OpenBSD: ldiv.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */
-/*
- * Copyright (c) 1990 Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdlib.h>		/* ldiv_t */
-
-ldiv_t
-ldiv(long num, long denom)
-{
-	ldiv_t r;
-
-	/* see div.c for comments */
-
-	r.quot = num / denom;
-	r.rem = num % denom;
-	if (num >= 0 && r.rem < 0) {
-		r.quot++;
-		r.rem -= denom;
-	}
-	return (r);
-}
diff --git a/libc/stdlib/lldiv.c b/libc/stdlib/lldiv.c
deleted file mode 100644
index e8d6c97..0000000
--- a/libc/stdlib/lldiv.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*	$OpenBSD: lldiv.c,v 1.1 2006/01/13 17:58:09 millert Exp $	*/
-/*
- * Copyright (c) 1990 Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdlib.h>		/* lldiv_t */
-
-lldiv_t
-lldiv(long long num, long long denom)
-{
-	lldiv_t r;
-
-	/* see div.c for comments */
-
-	r.quot = num / denom;
-	r.rem = num % denom;
-	if (num >= 0 && r.rem < 0) {
-		r.quot++;
-		r.rem -= denom;
-	}
-	return (r);
-}
diff --git a/libc/stdlib/locale.c b/libc/stdlib/locale.c
deleted file mode 100644
index 9dabbe4..0000000
--- a/libc/stdlib/locale.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <locale.h>
-
-char* setlocale (int category, char const *locale)
-{
-    /* INTENTIONAL: there is no locale support in Bionic */
-    return 0;
-}
diff --git a/libc/stdlib/lrand48.c b/libc/stdlib/lrand48.c
deleted file mode 100644
index 21beb85..0000000
--- a/libc/stdlib/lrand48.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/*	$OpenBSD: lrand48.c,v 1.3 2005/08/08 08:05:36 espie Exp $ */
-/*
- * Copyright (c) 1993 Martin Birgmeier
- * All rights reserved.
- *
- * You may redistribute unmodified or modified versions of this source
- * code provided that the above copyright notice and this and the
- * following conditions are retained.
- *
- * This software is provided ``as is'', and comes with no warranties
- * of any kind. I shall in no event be liable for anything that happens
- * to anyone/anything when using this software.
- */
-
-#include "rand48.h"
-
-extern unsigned short __rand48_seed[3];
-
-long
-lrand48(void)
-{
-	__dorand48(__rand48_seed);
-	return ((long) __rand48_seed[2] << 15) + ((long) __rand48_seed[1] >> 1);
-}
diff --git a/libc/stdlib/mrand48.c b/libc/stdlib/mrand48.c
deleted file mode 100644
index 977264a..0000000
--- a/libc/stdlib/mrand48.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/*	$OpenBSD: mrand48.c,v 1.3 2005/08/08 08:05:37 espie Exp $ */
-/*
- * Copyright (c) 1993 Martin Birgmeier
- * All rights reserved.
- *
- * You may redistribute unmodified or modified versions of this source
- * code provided that the above copyright notice and this and the
- * following conditions are retained.
- *
- * This software is provided ``as is'', and comes with no warranties
- * of any kind. I shall in no event be liable for anything that happens
- * to anyone/anything when using this software.
- */
-
-#include "rand48.h"
-
-extern unsigned short __rand48_seed[3];
-
-long
-mrand48(void)
-{
-	__dorand48(__rand48_seed);
-	return ((long) __rand48_seed[2] << 16) + (long) __rand48_seed[1];
-}
diff --git a/libc/stdlib/nrand48.c b/libc/stdlib/nrand48.c
deleted file mode 100644
index f1f548c..0000000
--- a/libc/stdlib/nrand48.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/*	$OpenBSD: nrand48.c,v 1.3 2005/08/08 08:05:37 espie Exp $ */
-/*
- * Copyright (c) 1993 Martin Birgmeier
- * All rights reserved.
- *
- * You may redistribute unmodified or modified versions of this source
- * code provided that the above copyright notice and this and the
- * following conditions are retained.
- *
- * This software is provided ``as is'', and comes with no warranties
- * of any kind. I shall in no event be liable for anything that happens
- * to anyone/anything when using this software.
- */
-
-#include "rand48.h"
-
-long
-nrand48(unsigned short xseed[3])
-{
-	__dorand48(xseed);
-	return ((long) xseed[2] << 15) + ((long) xseed[1] >> 1);
-}
diff --git a/libc/stdlib/seed48.c b/libc/stdlib/seed48.c
deleted file mode 100644
index 583262f..0000000
--- a/libc/stdlib/seed48.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*	$OpenBSD: seed48.c,v 1.3 2005/08/08 08:05:37 espie Exp $ */
-/*
- * Copyright (c) 1993 Martin Birgmeier
- * All rights reserved.
- *
- * You may redistribute unmodified or modified versions of this source
- * code provided that the above copyright notice and this and the
- * following conditions are retained.
- *
- * This software is provided ``as is'', and comes with no warranties
- * of any kind. I shall in no event be liable for anything that happens
- * to anyone/anything when using this software.
- */
-
-#include "rand48.h"
-
-extern unsigned short __rand48_seed[3];
-extern unsigned short __rand48_mult[3];
-extern unsigned short __rand48_add;
-
-unsigned short *
-seed48(unsigned short xseed[3])
-{
-	static unsigned short sseed[3];
-
-	sseed[0] = __rand48_seed[0];
-	sseed[1] = __rand48_seed[1];
-	sseed[2] = __rand48_seed[2];
-	__rand48_seed[0] = xseed[0];
-	__rand48_seed[1] = xseed[1];
-	__rand48_seed[2] = xseed[2];
-	__rand48_mult[0] = RAND48_MULT_0;
-	__rand48_mult[1] = RAND48_MULT_1;
-	__rand48_mult[2] = RAND48_MULT_2;
-	__rand48_add = RAND48_ADD;
-	return sseed;
-}
diff --git a/libc/stdlib/setjmperr.c b/libc/stdlib/setjmperr.c
deleted file mode 100644
index 9a06cdc..0000000
--- a/libc/stdlib/setjmperr.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*	$OpenBSD: setjmperr.c,v 1.5 2005/08/08 08:05:34 espie Exp $ */
-/*
- * Copyright (c) 1980, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * This routine is called from longjmp() when an error occurs.
- * Programs that wish to exit gracefully from this error may
- * write their own versions.
- * If this routine returns, the program is aborted.
- */
-
-#include <setjmp.h>
-#include <unistd.h>
-
-void
-longjmperror(void)
-{
-#define	ERRMSG	"longjmp botch.\n"
-	(void)write(STDERR_FILENO, ERRMSG, sizeof(ERRMSG) - 1);
-}
diff --git a/libc/stdlib/srand48.c b/libc/stdlib/srand48.c
deleted file mode 100644
index f76b6cc..0000000
--- a/libc/stdlib/srand48.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/*	$OpenBSD: srand48.c,v 1.3 2005/08/08 08:05:37 espie Exp $ */
-/*
- * Copyright (c) 1993 Martin Birgmeier
- * All rights reserved.
- *
- * You may redistribute unmodified or modified versions of this source
- * code provided that the above copyright notice and this and the
- * following conditions are retained.
- *
- * This software is provided ``as is'', and comes with no warranties
- * of any kind. I shall in no event be liable for anything that happens
- * to anyone/anything when using this software.
- */
-
-#include "rand48.h"
-
-extern unsigned short __rand48_seed[3];
-extern unsigned short __rand48_mult[3];
-extern unsigned short __rand48_add;
-
-void
-srand48(long seed)
-{
-	__rand48_seed[0] = RAND48_SEED_0;
-	__rand48_seed[1] = (unsigned short) seed;
-	__rand48_seed[2] = (unsigned short) (seed >> 16);
-	__rand48_mult[0] = RAND48_MULT_0;
-	__rand48_mult[1] = RAND48_MULT_1;
-	__rand48_mult[2] = RAND48_MULT_2;
-	__rand48_add = RAND48_ADD;
-}
diff --git a/libc/stdlib/wchar.c b/libc/stdlib/wchar.c
deleted file mode 100644
index d83613a..0000000
--- a/libc/stdlib/wchar.c
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <wchar.h>
-#include <ctype.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-
-/* stubs for wide-char functions */
-wint_t  btowc(int c)
-{
-  return (c == EOF) ? WEOF : c;
-}
-
-int fwprintf(FILE *stream, const wchar_t *format, ...)
-{
-    va_list  args;
-    int      result;
-
-    va_start(args, format);
-    result = vfwprintf(stream, format, args);
-    va_end(args);
-    return result;
-}
-
-int wprintf(const wchar_t *format, ...)
-{
-    va_list  args;
-    int      result;
-
-    va_start(args, format);
-    result = vwprintf(format, args);
-    va_end(args);
-    return result;
-}
-
-int swprintf(wchar_t *s, size_t n, const wchar_t *format, ...)
-{
-    va_list  args;
-    int      result;
-
-    va_start(args, format);
-    result = vswprintf(s, n, format, args);
-    va_end(args);
-    return result;
-}
-
-int vwprintf(const wchar_t *format, va_list arg)
-{
-    return vfwprintf(stdout, format, arg);
-}
-
-int vfwprintf(FILE *stream, const wchar_t *format, va_list arg)
-{
-    errno = ENOTSUP;
-    return -1;
-}
-
-int vswprintf(wchar_t *s, size_t n, const wchar_t *format, va_list arg)
-{
-    errno = ENOTSUP;
-    return -1;
-}
-
-int fwscanf(FILE *stream, const wchar_t *format, ... )
-{
-    errno = ENOTSUP;
-    return -1;
-}
-
-int wscanf(const wchar_t *format, ... )
-{
-    va_list  args;
-    int      result;
-
-    va_start (args, format);
-    result = fwscanf(stdout, format, args );
-    va_end (args);
-    return result;
-}
-
-int swscanf(const wchar_t *s, const wchar_t *format, ... )
-{
-    errno = ENOTSUP;
-    return -1;
-}
-
-int iswalnum(wint_t wc) { return isalnum(wc); }
-int iswalpha(wint_t wc) { return isalpha(wc); }
-int iswcntrl(wint_t wc) { return iscntrl(wc); }
-int iswdigit(wint_t wc) { return isdigit(wc); }
-int iswgraph(wint_t wc) { return isgraph(wc); }
-int iswlower(wint_t wc) { return islower(wc); }
-int iswprint(wint_t wc) { return isprint(wc); }
-int iswpunct(wint_t wc) { return ispunct(wc); }
-int iswspace(wint_t wc) { return isspace(wc); }
-int iswupper(wint_t wc) { return isupper(wc); }
-int iswxdigit(wint_t wc) { return isxdigit(wc); }
-
-int iswctype(wint_t wc, wctype_t charclass)
-{
-    switch (charclass) {
-        case WC_TYPE_ALNUM: return isalnum(wc);
-        case WC_TYPE_ALPHA: return isalpha(wc);
-        case WC_TYPE_BLANK: return isblank(wc);
-        case WC_TYPE_CNTRL: return iscntrl(wc);
-        case WC_TYPE_DIGIT: return isdigit(wc);
-        case WC_TYPE_GRAPH: return isgraph(wc);
-        case WC_TYPE_LOWER: return islower(wc);
-        case WC_TYPE_PRINT: return isprint(wc);
-        case WC_TYPE_PUNCT: return ispunct(wc);
-        case WC_TYPE_SPACE: return isspace(wc);
-        case WC_TYPE_UPPER: return isupper(wc);
-        case WC_TYPE_XDIGIT: return isxdigit(wc);
-        default: return 0;
-    };
-}
-
-wint_t fgetwc(FILE *stream)
-{
-    return (wint_t)fgetc(stream);
-}
-
-wchar_t *fgetws(wchar_t *ws, int n, FILE *stream)
-{
-    return (wchar_t*) fgets((char*)ws, n, stream);
-}
-
-wint_t   fputwc(wchar_t wc, FILE *stream)
-{
-    return (wint_t)fputc((char)wc, stream);
-}
-
-int  fputws(const wchar_t *str, FILE *stream)
-{
-    return fputs( (const char*)str, stream );
-}
-
-int  fwide(FILE *stream, int  mode)
-{
-    stream=stream;
-    return (mode);
-}
-
-wint_t  getwc(FILE *stream)
-{
-    return getc(stream);
-}
-
-wint_t  getwchar(void)
-{
-    return getchar();
-}
-
-int mbsinit(const mbstate_t *ps)
-{
-    ps=ps;
-    return 1;
-}
-
-size_t mbrlen(const char *s, size_t n, mbstate_t *ps)
-{
-    return (n != 0);
-}
-
-size_t mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
-{
-    if (s == NULL) {
-        s   = "";
-        pwc = NULL;
-    }
-    if (n == 0) {
-        if (pwc)
-            *pwc = 0;
-        return 0;
-    }
-    if (pwc)
-        *pwc = *s;
-
-    return (*s != 0);
-}
-
-size_t mbsrtowcs(wchar_t *dst, const char **src, size_t len, mbstate_t *ps)
-{
-    const char*  s  = *src;
-    const char*  s2 = memchr( s, 0, len );
-
-    if (s2 != NULL)
-        len = (size_t)(s2 - s) + 1U;
-
-    if (dst)
-        memcpy( (char*)dst, s, len );
-
-    *src = s + len;
-    return len;
-}
-
-size_t mbstowcs(wchar_t *dst, const char *src, size_t len)
-{
-    return mbsrtowcs(dst, &src, len, NULL);
-}
-
-wint_t  putwc(wchar_t wc, FILE *stream)
-{
-    return fputc((char)wc, stream);
-}
-
-wint_t  putwchar(wchar_t wc)
-{
-    return  putchar((char)wc);
-}
-
-wint_t  towlower(wint_t wc)
-{
-    return tolower(wc);
-}
-
-wint_t  towupper(wint_t  wc)
-{
-    return toupper(wc);
-}
-
-wint_t  ungetwc(wint_t wc, FILE *stream)
-{
-    return ungetc((char)wc, stream);
-}
-
-size_t wcrtomb(char *s, wchar_t wc, mbstate_t *ps)
-{
-    if (s != NULL)
-        *s = 1;
-    return 1;
-}
-
-size_t wcsftime(wchar_t *wcs, size_t maxsize, const wchar_t *format,  const struct tm *timptr)
-{
-    return strftime( (char*)wcs, maxsize, (const char*)format, timptr );
-}
-
-size_t wcsrtombs(char *dst, const wchar_t **src, size_t len, mbstate_t *ps)
-{
-    const char*  s = (const char*)*src;
-    const char*  s2 = memchr( s, 0, len );
-
-    if (s2 != NULL)
-        len = (s2 - s)+1;
-
-    if (dst != NULL)
-        memcpy( dst, s, len );
-
-    *src = (wchar_t*)(s + len);
-    return len;
-}
-
-size_t wcstombs(char *dst, const wchar_t *src, size_t len)
-{
-    return wcsrtombs(dst, &src, len, NULL);
-}
-
-double wcstod(const wchar_t *nptr, wchar_t **endptr)
-{
-    return strtod( (const char*)nptr, (char**)endptr );
-}
-
-long int wcstol(const wchar_t *nptr, wchar_t **endptr, int base)
-{
-    return strtol( (const char*)nptr, (char**)endptr, base );
-}
-
-unsigned long int wcstoul(const wchar_t *nptr, wchar_t **endptr, int base)
-{
-    return strtoul( (const char*)nptr, (char**)endptr, base );
-}
-
-wchar_t *wcswcs(const wchar_t *ws1, const wchar_t *ws2)
-{
-    return (wchar_t*) strstr( (const char*)ws1, (const char*)ws2 );
-}
-
-int wctob(wint_t c)
-{
-    return c;
-}
-
-wctype_t wctype(const char *property)
-{
-    static const char* const  properties[WC_TYPE_MAX] =
-    {
-        "<invalid>",
-        "alnum", "alpha", "blank", "cntrl", "digit", "graph",
-        "lower", "print", "punct", "space", "upper", "xdigit"
-    };
-    int  nn;
-
-    for ( nn = 0; nn < WC_TYPE_MAX; nn++ )
-        if ( !strcmp( properties[nn], property ) )
-            return (wctype_t)(nn);
-
-    return 0;
-}
-
-int wcwidth(wchar_t wc)
-{
-    return (wc > 0);
-}
diff --git a/libc/string/__memcpy_chk.c b/libc/string/__memcpy_chk.c
deleted file mode 100644
index 10334ba..0000000
--- a/libc/string/__memcpy_chk.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-#include <string.h>
-#include <stdlib.h>
-#include <private/logd.h>
-
-/*
- * Runtime implementation of __memcpy_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This memcpy check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-void *__memcpy_chk(void *dest, const void *src,
-              size_t copy_amount, size_t dest_len)
-{
-    if (__builtin_expect(copy_amount > dest_len, 0)) {
-        __libc_android_log_print(ANDROID_LOG_FATAL, "libc",
-            "*** memcpy buffer overflow detected ***\n");
-        __libc_android_log_event_uid(BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW);
-        abort();
-    }
-
-    return memcpy(dest, src, copy_amount);
-}
diff --git a/libc/string/__memmove_chk.c b/libc/string/__memmove_chk.c
deleted file mode 100644
index 529eb8f..0000000
--- a/libc/string/__memmove_chk.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <private/logd.h>
-
-/*
- * Runtime implementation of __builtin____memmove_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This memmove check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-void *__memmove_chk (void *dest, const void *src,
-              size_t len, size_t dest_len)
-{
-    if (len > dest_len) {
-        __libc_android_log_print(ANDROID_LOG_FATAL, "libc",
-            "*** memmove buffer overflow detected ***\n");
-        __libc_android_log_event_uid(BIONIC_EVENT_MEMMOVE_BUFFER_OVERFLOW);
-        abort();
-    }
-
-    return memmove(dest, src, len);
-}
diff --git a/libc/string/__memset_chk.c b/libc/string/__memset_chk.c
deleted file mode 100644
index 0904c03..0000000
--- a/libc/string/__memset_chk.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <private/logd.h>
-
-/*
- * Runtime implementation of __builtin____memset_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This memset check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-void *__memset_chk (void *dest, int c, size_t n, size_t dest_len)
-{
-    if (n > dest_len) {
-        __libc_android_log_print(ANDROID_LOG_FATAL, "libc",
-            "*** memset buffer overflow detected ***\n");
-        __libc_android_log_event_uid(BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW);
-        abort();
-    }
-
-    return memset(dest, c, n);
-}
diff --git a/libc/string/__strcat_chk.c b/libc/string/__strcat_chk.c
deleted file mode 100644
index 4665d66..0000000
--- a/libc/string/__strcat_chk.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <private/logd.h>
-#include <safe_iop.h>
-
-/*
- * Runtime implementation of __builtin____strcat_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This strcat check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-char *__strcat_chk (char *dest, const char *src, size_t dest_buf_size)
-{
-    // TODO: optimize so we don't scan src/dest twice.
-    size_t src_len  = strlen(src);
-    size_t dest_len = strlen(dest);
-    size_t sum;
-
-    // sum = src_len + dest_len + 1 (with overflow protection)
-    if (!safe_add3(&sum, src_len, dest_len, 1U)) {
-        __libc_android_log_print(ANDROID_LOG_FATAL, "libc",
-            "*** strcat integer overflow detected ***\n");
-        __libc_android_log_event_uid(BIONIC_EVENT_STRCAT_INTEGER_OVERFLOW);
-        abort();
-    }
-
-    if (sum > dest_buf_size) {
-        __libc_android_log_print(ANDROID_LOG_FATAL, "libc",
-            "*** strcat buffer overflow detected ***\n");
-        __libc_android_log_event_uid(BIONIC_EVENT_STRNCAT_BUFFER_OVERFLOW);
-        abort();
-    }
-
-    return strcat(dest, src);
-}
diff --git a/libc/string/__strcpy_chk.c b/libc/string/__strcpy_chk.c
deleted file mode 100644
index 79486b4..0000000
--- a/libc/string/__strcpy_chk.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <private/logd.h>
-
-/*
- * Runtime implementation of __builtin____strcpy_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This strcpy check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-char *__strcpy_chk (char *dest, const char *src, size_t dest_len)
-{
-    // TODO: optimize so we don't scan src twice.
-    size_t src_len = strlen(src) + 1;
-    if (src_len > dest_len) {
-        __libc_android_log_print(ANDROID_LOG_FATAL, "libc",
-            "*** strcpy buffer overflow detected ***\n");
-        __libc_android_log_event_uid(BIONIC_EVENT_STRCPY_BUFFER_OVERFLOW);
-        abort();
-    }
-
-    return strcpy(dest, src);
-}
diff --git a/libc/string/__strlcat_chk.c b/libc/string/__strlcat_chk.c
deleted file mode 100644
index b895fb8..0000000
--- a/libc/string/__strlcat_chk.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <private/logd.h>
-
-/*
- * __strlcat_chk. Called in place of strlcat() when we know the
- * size of the buffer we're writing into.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This strlcat check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-size_t __strlcat_chk(char *dest, const char *src,
-              size_t supplied_size, size_t dest_len_from_compiler)
-{
-    if (supplied_size > dest_len_from_compiler) {
-        __libc_android_log_print(ANDROID_LOG_FATAL, "libc",
-            "*** strlcat buffer overflow detected ***\n");
-        abort();
-    }
-
-    return strlcat(dest, src, supplied_size);
-}
diff --git a/libc/string/__strlcpy_chk.c b/libc/string/__strlcpy_chk.c
deleted file mode 100644
index 752c86c..0000000
--- a/libc/string/__strlcpy_chk.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <private/logd.h>
-
-/*
- * __strlcpy_chk. Called in place of strlcpy() when we know the
- * size of the buffer we're writing into.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This strlcpy check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-size_t __strlcpy_chk(char *dest, const char *src,
-              size_t supplied_size, size_t dest_len_from_compiler)
-{
-    if (supplied_size > dest_len_from_compiler) {
-        __libc_android_log_print(ANDROID_LOG_FATAL, "libc",
-            "*** strlcpy buffer overflow detected ***\n");
-        abort();
-    }
-
-    return strlcpy(dest, src, supplied_size);
-}
diff --git a/libc/string/__strlen_chk.c b/libc/string/__strlen_chk.c
deleted file mode 100644
index 43e7e80..0000000
--- a/libc/string/__strlen_chk.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <private/logd.h>
-
-/*
- * Runtime implementation of __strlen_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This strlen check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- *
- * This test is designed to detect code such as:
- *
- * int main() {
- *   char buf[10];
- *   memcpy(buf, "1234567890", sizeof(buf));
- *   size_t len = strlen(buf); // segfault here with _FORTIFY_SOURCE
- *   printf("%d\n", len);
- *   return 0;
- * }
- *
- * or anytime strlen reads beyond an object boundary.
- */
-size_t __strlen_chk(const char *s, size_t s_len)
-{
-    size_t ret = strlen(s);
-
-    if (__builtin_expect(ret >= s_len, 0)) {
-        __libc_android_log_print(ANDROID_LOG_FATAL, "libc",
-            "*** strlen read overflow detected ***\n");
-        abort();
-    }
-
-    return ret;
-}
diff --git a/libc/string/__strncat_chk.c b/libc/string/__strncat_chk.c
deleted file mode 100644
index 2036c9f..0000000
--- a/libc/string/__strncat_chk.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <private/logd.h>
-#include <safe_iop.h>
-
-/*
- * Runtime implementation of __builtin____strncat_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This strncat check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-char *__strncat_chk (char *dest, const char *src,
-              size_t len, size_t dest_buf_size)
-{
-    // TODO: optimize so we don't scan src/dest twice.
-    size_t dest_len = strlen(dest);
-    size_t src_len = strlen(src);
-    if (src_len > len) {
-        src_len = len;
-    }
-
-    size_t sum;
-    // sum = src_len + dest_len + 1 (with overflow protection)
-    if (!safe_add3(&sum, src_len, dest_len, 1U)) {
-        __libc_android_log_print(ANDROID_LOG_FATAL, "libc",
-            "*** strncat integer overflow detected ***\n");
-        __libc_android_log_event_uid(BIONIC_EVENT_STRNCAT_INTEGER_OVERFLOW);
-        abort();
-    }
-
-    if (sum > dest_buf_size) {
-        __libc_android_log_print(ANDROID_LOG_FATAL, "libc",
-            "*** strncat buffer overflow detected ***\n");
-        __libc_android_log_event_uid(BIONIC_EVENT_STRNCAT_BUFFER_OVERFLOW);
-        abort();
-    }
-
-    return strncat(dest, src, len);
-}
diff --git a/libc/string/__strncpy_chk.c b/libc/string/__strncpy_chk.c
deleted file mode 100644
index 3f9e9fb..0000000
--- a/libc/string/__strncpy_chk.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <private/logd.h>
-
-/*
- * Runtime implementation of __builtin____strncpy_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This strncpy check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-char *__strncpy_chk (char *dest, const char *src,
-              size_t len, size_t dest_len)
-{
-    if (len > dest_len) {
-        __libc_android_log_print(ANDROID_LOG_FATAL, "libc",
-            "*** strncpy buffer overflow detected ***\n");
-        __libc_android_log_event_uid(BIONIC_EVENT_STRNCPY_BUFFER_OVERFLOW);
-        abort();
-    }
-
-    return strncpy(dest, src, len);
-}
diff --git a/libc/string/memccpy.c b/libc/string/memccpy.c
deleted file mode 100644
index 789fde6..0000000
--- a/libc/string/memccpy.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <stddef.h>
-#include <string.h>
-
-void *memccpy(void *dst, const void *src, int c, size_t n)
-{
-    char*        q     = dst;
-    const char*  p     = src;
-    const char*  p_end = p + n;
-    char         ch    = ~(char)c;  /* ensure ch != c */
-
-    for (;;) {
-        if (ch == c || p >= p_end) break;
-        *q++ = ch = *p++;
-    }
-
-    if (p >= p_end && ch != c)
-        return NULL;
-
-    return q;
-}
diff --git a/libc/string/strcasestr.c b/libc/string/strcasestr.c
deleted file mode 100644
index aa74c01..0000000
--- a/libc/string/strcasestr.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*	$OpenBSD: strcasestr.c,v 1.3 2006/03/31 05:34:55 deraadt Exp $	*/
-/*	$NetBSD: strcasestr.c,v 1.2 2005/02/09 21:35:47 kleink Exp $	*/
-
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <ctype.h>
-#include <string.h>
-
-/*
- * Find the first occurrence of find in s, ignore case.
- */
-char *
-strcasestr(const char *s, const char *find)
-{
-	char c, sc;
-	size_t len;
-
-	if ((c = *find++) != 0) {
-		c = (char)tolower((unsigned char)c);
-		len = strlen(find);
-		do {
-			do {
-				if ((sc = *s++) == 0)
-					return (NULL);
-			} while ((char)tolower((unsigned char)sc) != c);
-		} while (strncasecmp(s, find, len) != 0);
-		s--;
-	}
-	return ((char *)s);
-}
diff --git a/libc/string/strchr.c b/libc/string/strchr.c
index 9b4332c..564ea80 100644
--- a/libc/string/strchr.c
+++ b/libc/string/strchr.c
@@ -29,11 +29,14 @@
  */
 
 #include <string.h>
+#include <private/logd.h>
 
 char *
-strchr(const char *p, int ch)
+__strchr_chk(const char *p, int ch, size_t s_len)
 {
-	for (;; ++p) {
+	for (;; ++p, s_len--) {
+		if (s_len == 0)
+			__fortify_chk_fail("strchr read beyond buffer", 0);
 		if (*p == (char) ch)
 			return((char *)p);
 		if (!*p)
@@ -41,3 +44,8 @@
 	}
 	/* NOTREACHED */
 }
+
+char *
+strchr(const char *p, int ch) {
+    return __strchr_chk(p, ch, (size_t) -1);
+}
diff --git a/libc/string/strcoll.c b/libc/string/strcoll.c
deleted file mode 100755
index e3b1ec3..0000000
--- a/libc/string/strcoll.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <string.h>
-
-/*
- * Compare strings using the current locale.  Since Bionic really does not
- * support locales, we assume we always use the C locale and call strcmp.
- *
- * This function is provided to make libstdc++-v3 usable.
- */
-int
-strcoll(const char *s1, const char *s2)
-{
-	return strcmp(s1, s2);
-}
diff --git a/libc/string/strrchr.c b/libc/string/strrchr.c
index 10c07e6..5d0415e 100644
--- a/libc/string/strrchr.c
+++ b/libc/string/strrchr.c
@@ -29,13 +29,16 @@
  */
 
 #include <string.h>
+#include <private/logd.h>
 
 char *
-strrchr(const char *p, int ch)
+__strrchr_chk(const char *p, int ch, size_t s_len)
 {
 	char *save;
 
-	for (save = NULL;; ++p) {
+	for (save = NULL;; ++p, s_len--) {
+		if (s_len == 0)
+			__fortify_chk_fail("strrchr read beyond buffer", 0);
 		if (*p == (char) ch)
 			save = (char *)p;
 		if (!*p)
@@ -43,3 +46,9 @@
 	}
 	/* NOTREACHED */
 }
+
+char *
+strrchr(const char *p, int ch)
+{
+	return __strrchr_chk(p, ch, (size_t) -1);
+}
diff --git a/libc/tools/bionic_utils.py b/libc/tools/bionic_utils.py
index abb7820..bbfff7d 100644
--- a/libc/tools/bionic_utils.py
+++ b/libc/tools/bionic_utils.py
@@ -302,17 +302,6 @@
         fp.close()
 
 
-class Output:
-    def  __init__(self,out=sys.stdout):
-        self.out = out
-
-    def write(self,msg):
-        self.out.write(msg)
-
-    def writeln(self,msg):
-        self.out.write(msg)
-        self.out.write("\n")
-
 class StringOutput:
     def __init__(self):
         self.line = ""
@@ -321,10 +310,6 @@
         self.line += msg
         D2("write '%s'" % msg)
 
-    def writeln(self,msg):
-        self.line += msg + '\n'
-        D2("write '%s\\n'"% msg)
-
     def get(self):
         return self.line
 
diff --git a/libc/tools/check-symbols.py b/libc/tools/check-symbols.py
new file mode 100755
index 0000000..0922548
--- /dev/null
+++ b/libc/tools/check-symbols.py
@@ -0,0 +1,64 @@
+#!/usr/bin/python
+
+import glob
+import os
+import re
+import string
+import subprocess
+import sys
+
+toolchain = os.environ['ANDROID_TOOLCHAIN']
+arch = re.sub(r'.*/linux-x86/([^/]+)/.*', r'\1', toolchain)
+
+sys.stderr.write('Checking symbols for arch "%s"...\n' % arch)
+
+def GetSymbols(library, functions_or_variables):
+  api = '9'
+  if library == 'libm' and arch == 'arm':
+    api = '3'
+  path = '%s/development/ndk/platforms/android-%s/arch-%s/symbols/%s.so.%s.txt' % (os.environ['ANDROID_BUILD_TOP'], api, arch, library, functions_or_variables)
+  symbols = set()
+  for line in open(path, 'r'):
+    symbols.add(line.rstrip())
+  #sys.stdout.write('%d %s in %s for %s\n' % (len(symbols), functions_or_variables, library, arch))
+  return symbols
+
+def CheckSymbols(library, functions_or_variables):
+  expected_symbols = GetSymbols(library, functions_or_variables)
+
+  so_file = '%s/system/lib/%s.so' % (os.environ['ANDROID_PRODUCT_OUT'], library)
+
+  # Example readelf output:
+  #   264: 0001623c     4 FUNC    GLOBAL DEFAULT    8 cabsf
+  #   266: 00016244     4 FUNC    GLOBAL DEFAULT    8 dremf
+  #   267: 00019018     4 OBJECT  GLOBAL DEFAULT   11 __fe_dfl_env
+  #   268: 00000000     0 FUNC    GLOBAL DEFAULT  UND __aeabi_dcmplt
+
+
+  r = re.compile(r' +\d+: [0-9a-f]+ +\d+ (FUNC|OBJECT) +\S+ +\S+ +\d+ (\S+)')
+
+  actual_symbols = set()
+  for line in subprocess.check_output(['readelf', '--dyn-syms', so_file]).split('\n'):
+    m = r.match(line)
+    if m:
+      if m.group(1) == 'FUNC' and functions_or_variables == 'functions':
+        actual_symbols.add(m.group(2))
+      elif m.group(1) == 'OBJECT' and functions_or_variables == 'variables':
+        actual_symbols.add(m.group(2))
+    #else:
+      #print 'ignoring: ' % line
+
+  missing = expected_symbols - actual_symbols
+  if len(missing) > 0:
+    sys.stderr.write('%d missing %s in %s for %s:\n' % (len(missing), functions_or_variables, library, arch))
+    for miss in sorted(missing):
+      sys.stderr.write('  %s\n' % miss)
+
+  return len(missing) == 0
+
+CheckSymbols("libc", "functions")
+CheckSymbols("libc", "variables")
+CheckSymbols("libm", "functions")
+CheckSymbols("libm", "variables")
+
+sys.exit(0)
diff --git a/libc/tools/checksyscalls.py b/libc/tools/checksyscalls.py
index 286e727..b325676 100755
--- a/libc/tools/checksyscalls.py
+++ b/libc/tools/checksyscalls.py
@@ -2,7 +2,7 @@
 #
 # this tool is used to check that the syscall numbers that are in
 # SYSCALLS.TXT correspond to those found in the Linux kernel sources
-# for the arm and i386 architectures
+# for the arm, i386 and mips architectures
 #
 
 import sys, re, string, os, commands
@@ -167,13 +167,12 @@
     for sc in syscalls:
         sc_name = sc["name"]
         sc_id   = sc[idname]
+        if sc_id == -1:
+            sc_id = sc["common"]
         if sc_id >= 0:
             if not arch_dict.has_key(sc_name):
                 print "error: %s syscall %s not defined, should be %d" % (archname, sc_name, sc_id)
                 errors += 1
-            elif not arch_dict.has_key(sc_name):
-                print "error: %s syscall %s is not implemented" % (archname, sc_name)
-                errors += 1
             elif arch_dict[sc_name] != sc_id:
                 print "error: %s syscall %s should be %d instead of %d" % (archname, sc_name, arch_dict[sc_name], sc_id)
                 errors += 1
diff --git a/libc/tools/generate-NOTICE.py b/libc/tools/generate-NOTICE.py
index b7d23f7..5115317 100755
--- a/libc/tools/generate-NOTICE.py
+++ b/libc/tools/generate-NOTICE.py
@@ -20,7 +20,7 @@
         return True
     if path.endswith("/notice") or path.endswith("/readme") or path.endswith("/caveats"):
         return True
-    if path.endswith("/zoneinfo.dat") or path.endswith("/zoneinfo.idx") or path.endswith("/zoneinfo.version") or path.endswith("/zoneinfo/generate"):
+    if path.endswith("/tzdata") or path.endswith("/zoneinfo/generate"):
         return True
     return False
 
diff --git a/libc/tools/gensyscalls.py b/libc/tools/gensyscalls.py
index 21d2f1d..5e519de 100755
--- a/libc/tools/gensyscalls.py
+++ b/libc/tools/gensyscalls.py
@@ -10,12 +10,6 @@
 
 from bionic_utils import *
 
-# set this to 1 if you want to generate thumb stubs
-gen_thumb_stubs = 0
-
-# set this to 1 if you want to generate ARM EABI stubs
-gen_eabi_stubs = 1
-
 # get the root Bionic directory, simply this script's dirname
 #
 bionic_root = find_bionic_root()
@@ -32,7 +26,7 @@
 bionic_temp = "/tmp/bionic_gensyscalls/"
 
 # all architectures, update as you see fit
-all_archs = [ "arm", "x86", "mips" ]
+all_archs = [ "arm", "mips", "x86" ]
 
 def make_dir( path ):
     path = os.path.abspath(path)
@@ -47,18 +41,15 @@
     make_dir(dir)
     return open( bionic_temp + relpath, "w" )
 
+#
 # x86 assembler templates for each syscall stub
 #
 
 x86_header = """/* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type %(fname)s, @function
-    .globl %(fname)s
-    .align 4
-
-%(fname)s:
+ENTRY(%(fname)s)
 """
 
 x86_registers = [ "%ebx", "%ecx", "%edx", "%esi", "%edi", "%ebp" ]
@@ -76,10 +67,13 @@
 """
 
 x86_return = """    ret
+END(%(fname)s)
 """
 
+#
 # ARM assembler templates for each syscall stub
 #
+
 arm_header = """/* autogenerated by gensyscalls.py */
 #include <machine/asm.h>
 #include <sys/linux-syscalls.h>
@@ -87,39 +81,16 @@
 ENTRY(%(fname)s)
 """
 
-arm_footer = """\
-END(%(fname)s)
-"""
-
-arm_call_default = arm_header + """\
-    swi   #%(idname)s
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
-""" + arm_footer
-
-arm_call_long = arm_header + """\
-    .save   {r4, r5, lr}
-    stmfd   sp!, {r4, r5, lr}
-    ldr     r4, [sp, #12]
-    ldr     r5, [sp, #16]
-    swi     # %(idname)s
-    ldmfd   sp!, {r4, r5, lr}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
-""" + arm_footer
-
 arm_eabi_call_default = arm_header + """\
-    .save   {r4, r7}
-    stmfd   sp!, {r4, r7}
+    mov     ip, r7
     ldr     r7, =%(idname)s
     swi     #0
-    ldmfd   sp!, {r4, r7}
+    mov     r7, ip
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-""" + arm_footer
+END(%(fname)s)
+"""
 
 arm_eabi_call_long = arm_header + """\
     mov     ip, sp
@@ -132,61 +103,13 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-""" + arm_footer
+END(%(fname)s)
+"""
 
-# ARM thumb assembler templates for each syscall stub
 #
-thumb_header = """/* autogenerated by gensyscalls.py */
-    .text
-    .type %(fname)s, #function
-    .globl %(fname)s
-    .align 4
-    .thumb_func
-    .fnstart
-
-#define  __thumb__
-#include <sys/linux-syscalls.h>
-
-
-%(fname)s:
-"""
-
-thumb_call_default = thumb_header + """\
-    .save   {r7,lr}
-    push    {r7,lr}
-    ldr     r7, =%(idname)s
-    swi     #0
-    tst     r0, r0
-    bmi     1f
-    pop     {r7,pc}
-1:
-    neg     r0, r0
-    ldr     r1, =__set_errno
-    blx     r1
-    pop     {r7,pc}
-    .fnend
-"""
-
-thumb_call_long = thumb_header + """\
-    .save  {r4,r5,r7,lr}
-    push   {r4,r5,r7,lr}
-    ldr    r4, [sp,#16]
-    ldr    r5, [sp,#20]
-    ldr    r7, =%(idname)s
-    swi    #0
-    tst    r0, r0
-    bmi    1f
-    pop    {r4,r5,r7,pc}
-1:
-    neg    r0, r0
-    ldr    r1, =__set_errno
-    blx    r1
-    pop    {r4,r5,r7,pc}
-    .fnend
-"""
-
 # mips assembler templates for each syscall stub
 #
+
 mips_call = """/* autogenerated by gensyscalls.py */
 #include <sys/linux-syscalls.h>
     .text
@@ -233,7 +156,7 @@
 
 def count_arm_param_registers(params):
     """This function is used to count the number of register used
-       to pass parameters when invoking a thumb or ARM system call.
+       to pass parameters when invoking an ARM system call.
        This is because the ARM EABI mandates that 64-bit quantities
        must be passed in an even+odd register pair. So, for example,
        something like:
@@ -289,7 +212,7 @@
         for r in range(numparams):
             result += "    popl    " + x86_registers[numparams-r-1] + "\n"
 
-        result += x86_return
+        result += x86_return % t
         return result
 
     def x86_genstub_cid(self, fname, numparams, idname, cid):
@@ -327,18 +250,9 @@
         result += "    popl    %ebx" + "\n"
 
         # epilog
-        result += x86_return
+        result += x86_return % t
         return result
 
-    def arm_genstub(self,fname, flags, idname):
-        t = { "fname"  : fname,
-              "idname" : idname }
-        if flags:
-            numargs = int(flags)
-            if numargs > 4:
-                return arm_call_long % t
-        return arm_call_default % t
-
 
     def arm_eabi_genstub(self,fname, flags, idname):
         t = { "fname"  : fname,
@@ -350,15 +264,6 @@
         return arm_eabi_call_default % t
 
 
-    def thumb_genstub(self,fname, flags, idname):
-        t = { "fname"  : fname,
-              "idname" : idname }
-        if flags:
-            numargs = int(flags)
-            if numargs > 4:
-                return thumb_call_long % t
-        return thumb_call_default % t
-
     def mips_genstub(self,fname, idname):
         t = { "fname"  : fname,
               "idname" : idname }
@@ -377,13 +282,7 @@
 
             if t["common"] >= 0 or t["armid"] >= 0:
                 num_regs = count_arm_param_registers(syscall_params)
-                if gen_thumb_stubs:
-                    t["asm-thumb"] = self.thumb_genstub(syscall_func,num_regs,"__NR_"+syscall_name)
-                else:
-                    if gen_eabi_stubs:
-                        t["asm-arm"]   = self.arm_eabi_genstub(syscall_func,num_regs,"__NR_"+syscall_name)
-                    else:
-                        t["asm-arm"]   = self.arm_genstub(syscall_func,num_regs,"__NR_"+syscall_name)
+                t["asm-arm"] = self.arm_eabi_genstub(syscall_func,num_regs,"__NR_"+syscall_name)
 
             if t["common"] >= 0 or t["x86id"] >= 0:
                 num_regs = count_generic_param_registers(syscall_params)
@@ -395,6 +294,7 @@
                 E("cid for dispatch syscalls is only supported for x86 in "
                   "'%s'" % syscall_name)
                 return
+
             if t["common"] >= 0 or t["mipsid"] >= 0:
                 t["asm-mips"] = self.mips_genstub(syscall_func,"__NR_"+syscall_name)
 
@@ -468,7 +368,7 @@
         fp.write( "# auto-generated by gensyscalls.py, do not touch\n" )
         fp.write( "syscall_src := \n" )
         arch_test = {
-            "arm": lambda x: x.has_key("asm-arm") or x.has_key("asm-thumb"),
+            "arm": lambda x: x.has_key("asm-arm"),
             "x86": lambda x: x.has_key("asm-x86"),
             "mips": lambda x: x.has_key("asm-mips")
         }
@@ -492,14 +392,6 @@
                 fp.close()
                 self.new_stubs.append( fname )
 
-            if sc.has_key("asm-thumb") and 'arm' in all_archs:
-                fname = "arch-arm/syscalls/%s.S" % sc["func"]
-                D2( ">>> generating "+fname )
-                fp = create_file( fname )
-                fp.write(sc["asm-thumb"])
-                fp.close()
-                self.new_stubs.append( fname )
-
             if sc.has_key("asm-x86") and 'x86' in all_archs:
                 fname = "arch-x86/syscalls/%s.S" % sc["func"]
                 D2( ">>> generating "+fname )
@@ -534,12 +426,6 @@
             D( "creating %s" % bionic_temp )
             make_dir( bionic_temp )
 
-#        D( "p4 editing source files" )
-#        for arch in all_archs:
-#            commands.getoutput( "p4 edit " + arch + "/syscalls/*.S " )
-#            commands.getoutput( "p4 edit " + arch + "/syscalls.mk" )
-#        commands.getoutput( "p4 edit " + bionic_root + "include/sys/linux-syscalls.h" )
-
         D( "re-generating stubs and support files" )
 
         self.gen_linux_syscalls_h()
diff --git a/libc/tools/zoneinfo/ZoneCompactor.java b/libc/tools/zoneinfo/ZoneCompactor.java
index b657748..8a1a628 100644
--- a/libc/tools/zoneinfo/ZoneCompactor.java
+++ b/libc/tools/zoneinfo/ZoneCompactor.java
@@ -1,11 +1,13 @@
 
 import java.io.*;
+import java.nio.ByteOrder;
 import java.util.*;
+import libcore.io.BufferIterator;
+import libcore.util.ZoneInfo;
 
-// usage: java ZoneCompiler <setup file> <top-level directory>
+// usage: java ZoneCompiler <setup file> <data directory> <output directory> <tzdata version>
 //
-// Compile a set of tzfile-formatted files into a single file plus
-// an index file.
+// Compile a set of tzfile-formatted files into a single file containing an index.
 //
 // The compilation is controlled by a setup file, which is provided as a
 // command-line argument.  The setup file has the form:
@@ -15,152 +17,225 @@
 // <zone filename>
 // ...
 //
-// Note that the links must be declared prior to the zone names.  A
-// zone name is a filename relative to the source directory such as
+// Note that the links must be declared prior to the zone names.
+// A zone name is a filename relative to the source directory such as
 // 'GMT', 'Africa/Dakar', or 'America/Argentina/Jujuy'.
 //
 // Use the 'zic' command-line tool to convert from flat files
-// (e.g., 'africa', 'northamerica') into a suitable source directory
-// hierarchy for this tool (e.g., 'data/Africa/Abidjan').
+// (such as 'africa' or 'northamerica') to a directory
+// hierarchy suitable for this tool (containing files such as 'data/Africa/Abidjan').
 //
-// Example:
-//     zic -d data tz2007h
-//     javac ZoneCompactor.java
-//     java ZoneCompactor setup data
-//     <produces zoneinfo.dat and zoneinfo.idx>
 
 public class ZoneCompactor {
+  public static class ByteArrayBufferIteratorBE extends BufferIterator {
+    private final byte[] bytes;
+    private int offset = 0;
 
-    // Zone name synonyms
-    Map<String,String> links = new HashMap<String,String>();
-
-    // File starting bytes by zone name
-    Map<String,Integer> starts = new HashMap<String,Integer>();
-
-    // File lengths by zone name
-    Map<String,Integer> lengths = new HashMap<String,Integer>();
-
-    // Raw GMT offsets by zone name
-    Map<String,Integer> offsets = new HashMap<String,Integer>();
-    int start = 0;
-
-    // Maximum number of characters in a zone name, including '\0' terminator
-    private static final int MAXNAME = 40;
-
-    // Concatenate the contents of 'inFile' onto 'out'
-    // and return the contents as a byte array.
-    private static byte[] copyFile(File inFile, OutputStream out)
-        throws Exception {
-        byte[] ret = new byte[0];
-
-        InputStream in = new FileInputStream(inFile);
-        byte[] buf = new byte[8192];
-        while (true) {
-            int nbytes = in.read(buf);
-            if (nbytes == -1) {
-                break;
-            }
-            out.write(buf, 0, nbytes);
-
-            byte[] nret = new byte[ret.length + nbytes];
-            System.arraycopy(ret, 0, nret, 0, ret.length);
-            System.arraycopy(buf, 0, nret, ret.length, nbytes);
-            ret = nret;
-        }
-        out.flush();
-        return ret;
-    }
-    
-    // Write a 32-bit integer in network byte order
-    private void writeInt(OutputStream os, int x) throws IOException {
-        os.write((x >> 24) & 0xff);
-        os.write((x >> 16) & 0xff);
-        os.write((x >>  8) & 0xff);
-        os.write( x        & 0xff);
+    public ByteArrayBufferIteratorBE(byte[] bytes) {
+      this.bytes = bytes;
+      this.offset = 0;
     }
 
-    public ZoneCompactor(String setupFilename, String dirName)
-        throws Exception {
-        File zoneInfoFile = new File("zoneinfo.dat");
-        zoneInfoFile.delete();
-        OutputStream zoneInfo = new FileOutputStream(zoneInfoFile);
-
-        BufferedReader rdr = new BufferedReader(new FileReader(setupFilename));
-    
-        String s;
-        while ((s = rdr.readLine()) != null) {
-            s = s.trim();
-            if (s.startsWith("Link")) {
-                StringTokenizer st = new StringTokenizer(s);
-                st.nextToken();
-                String to = st.nextToken();
-                String from = st.nextToken();
-                links.put(from, to);
-            } else {
-                String link = links.get(s);
-                if (link == null) {
-                    File f = new File(dirName, s);
-                    long length = f.length();
-                    starts.put(s, new Integer(start));
-                    lengths.put(s, new Integer((int)length));
-
-                    start += length;
-                    byte[] data = copyFile(f, zoneInfo);
-
-                    TimeZone tz = ZoneInfo.make(s, data);
-                    int gmtOffset = tz.getRawOffset();
-                    offsets.put(s, new Integer(gmtOffset));
-                }
-            }
-        }
-        zoneInfo.close();
-
-        // Fill in fields for links
-        Iterator<String> iter = links.keySet().iterator();
-        while (iter.hasNext()) {
-            String from = iter.next();
-            String to = links.get(from);
-
-            starts.put(from, starts.get(to));
-            lengths.put(from, lengths.get(to));
-            offsets.put(from, offsets.get(to));
-        }
-
-        File idxFile = new File("zoneinfo.idx");
-        idxFile.delete();
-        FileOutputStream idx = new FileOutputStream(idxFile);
-
-        ArrayList<String> l = new ArrayList<String>();
-        l.addAll(starts.keySet());
-        Collections.sort(l);
-        Iterator<String> ziter = l.iterator();
-        while (ziter.hasNext()) {
-            String zname = ziter.next();
-            if (zname.length() >= MAXNAME) {
-                System.err.println("Error - zone filename exceeds " +
-                                   (MAXNAME - 1) + " characters!");
-            }
-
-            byte[] znameBuf = new byte[MAXNAME];
-            for (int i = 0; i < zname.length(); i++) {
-                znameBuf[i] = (byte)zname.charAt(i);
-            }
-            idx.write(znameBuf);
-            writeInt(idx, starts.get(zname).intValue());
-            writeInt(idx, lengths.get(zname).intValue());
-            writeInt(idx, offsets.get(zname).intValue());
-        }
-        idx.close();
-
-        // System.out.println("maxLength = " + maxLength);
+    public void seek(int offset) {
+      this.offset = offset;
     }
 
-    public static void main(String[] args) throws Exception {
-        if (args.length != 2) {
-            System.err.println("usage: java ZoneCompactor <setup> <data dir>");
-            System.exit(0);
-        }
-        new ZoneCompactor(args[0], args[1]);
+    public void skip(int byteCount) {
+      this.offset += byteCount;
     }
 
+    public void readByteArray(byte[] dst, int dstOffset, int byteCount) {
+      System.arraycopy(bytes, offset, dst, dstOffset, byteCount);
+      offset += byteCount;
+    }
+
+    public byte readByte() {
+      return bytes[offset++];
+    }
+
+    public int readInt() {
+      return ((readByte() & 0xff) << 24) | ((readByte() & 0xff) << 16) | ((readByte() & 0xff) << 8) | (readByte() & 0xff);
+    }
+
+    public void readIntArray(int[] dst, int dstOffset, int intCount) {
+      for (int i = 0; i < intCount; ++i) {
+        dst[dstOffset++] = readInt();
+      }
+    }
+
+    public short readShort() {
+      throw new UnsupportedOperationException();
+    }
+  }
+
+  // Maximum number of characters in a zone name, including '\0' terminator
+  private static final int MAXNAME = 40;
+
+  // Zone name synonyms
+  private Map<String,String> links = new HashMap<String,String>();
+
+  // File starting bytes by zone name
+  private Map<String,Integer> starts = new HashMap<String,Integer>();
+
+  // File lengths by zone name
+  private Map<String,Integer> lengths = new HashMap<String,Integer>();
+
+  // Raw GMT offsets by zone name
+  private Map<String,Integer> offsets = new HashMap<String,Integer>();
+  private int start = 0;
+
+  // Concatenate the contents of 'inFile' onto 'out'
+  // and return the contents as a byte array.
+  private static byte[] copyFile(File inFile, OutputStream out) throws Exception {
+    byte[] ret = new byte[0];
+
+    InputStream in = new FileInputStream(inFile);
+    byte[] buf = new byte[8192];
+    while (true) {
+      int nbytes = in.read(buf);
+      if (nbytes == -1) {
+        break;
+      }
+      out.write(buf, 0, nbytes);
+
+      byte[] nret = new byte[ret.length + nbytes];
+      System.arraycopy(ret, 0, nret, 0, ret.length);
+      System.arraycopy(buf, 0, nret, ret.length, nbytes);
+      ret = nret;
+    }
+    out.flush();
+    return ret;
+  }
+
+  public ZoneCompactor(String setupFile, String dataDirectory, String zoneTabFile, String outputDirectory, String version) throws Exception {
+    // Read the setup file, and concatenate all the data.
+    ByteArrayOutputStream allData = new ByteArrayOutputStream();
+    BufferedReader reader = new BufferedReader(new FileReader(setupFile));
+    String s;
+    while ((s = reader.readLine()) != null) {
+      s = s.trim();
+      if (s.startsWith("Link")) {
+        StringTokenizer st = new StringTokenizer(s);
+        st.nextToken();
+        String to = st.nextToken();
+        String from = st.nextToken();
+        links.put(from, to);
+      } else {
+        String link = links.get(s);
+        if (link == null) {
+          File sourceFile = new File(dataDirectory, s);
+          long length = sourceFile.length();
+          starts.put(s, start);
+          lengths.put(s, (int) length);
+
+          start += length;
+          byte[] data = copyFile(sourceFile, allData);
+
+          BufferIterator it = new ByteArrayBufferIteratorBE(data);
+          TimeZone tz = ZoneInfo.makeTimeZone(s, it);
+          int gmtOffset = tz.getRawOffset();
+          offsets.put(s, gmtOffset);
+        }
+      }
+    }
+    reader.close();
+
+    // Fill in fields for links.
+    Iterator<String> it = links.keySet().iterator();
+    while (it.hasNext()) {
+      String from = it.next();
+      String to = links.get(from);
+
+      starts.put(from, starts.get(to));
+      lengths.put(from, lengths.get(to));
+      offsets.put(from, offsets.get(to));
+    }
+
+    // Create/truncate the destination file.
+    RandomAccessFile f = new RandomAccessFile(new File(outputDirectory, "tzdata"), "rw");
+    f.setLength(0);
+
+    // Write the header.
+
+    // byte[12] tzdata_version -- 'tzdata2012f\0'
+    // int index_offset -- so we can slip in extra header fields in a backwards-compatible way
+    // int data_offset
+    // int zonetab_offset
+
+    // tzdata_version
+    f.write(toAscii(new byte[12], version));
+
+    // Write dummy values for the three offsets, and remember where we need to seek back to later
+    // when we have the real values.
+    int index_offset_offset = (int) f.getFilePointer();
+    f.writeInt(0);
+    int data_offset_offset = (int) f.getFilePointer();
+    f.writeInt(0);
+    int zonetab_offset_offset = (int) f.getFilePointer();
+    f.writeInt(0);
+
+    int index_offset = (int) f.getFilePointer();
+
+    // Write the index.
+    ArrayList<String> sortedOlsonIds = new ArrayList<String>();
+    sortedOlsonIds.addAll(starts.keySet());
+    Collections.sort(sortedOlsonIds);
+    it = sortedOlsonIds.iterator();
+    while (it.hasNext()) {
+      String zoneName = it.next();
+      if (zoneName.length() >= MAXNAME) {
+        throw new RuntimeException("zone filename too long: " + zoneName.length());
+      }
+
+      f.write(toAscii(new byte[MAXNAME], zoneName));
+      f.writeInt(starts.get(zoneName));
+      f.writeInt(lengths.get(zoneName));
+      f.writeInt(offsets.get(zoneName));
+    }
+
+    int data_offset = (int) f.getFilePointer();
+
+    // Write the data.
+    f.write(allData.toByteArray());
+
+    // Copy the zone.tab.
+    reader = new BufferedReader(new FileReader(zoneTabFile));
+    while ((s = reader.readLine()) != null) {
+      if (!s.startsWith("#")) {
+        f.writeBytes(s);
+        f.write('\n');
+      }
+    }
+    reader.close();
+
+    int zonetab_offset = (int) f.getFilePointer();
+
+    // Go back and fix up the offsets in the header.
+    f.seek(index_offset_offset);
+    f.writeInt(index_offset);
+    f.seek(data_offset_offset);
+    f.writeInt(data_offset);
+    f.seek(zonetab_offset_offset);
+    f.writeInt(zonetab_offset);
+
+    f.close();
+  }
+
+  private static byte[] toAscii(byte[] dst, String src) {
+    for (int i = 0; i < src.length(); ++i) {
+      if (src.charAt(i) > '~') {
+        throw new RuntimeException("non-ASCII string: " + src);
+      }
+      dst[i] = (byte) src.charAt(i);
+    }
+    return dst;
+  }
+
+  public static void main(String[] args) throws Exception {
+    if (args.length != 5) {
+      System.err.println("usage: java ZoneCompactor <setup file> <data directory> <zone.tab file> <output directory> <tzdata version>");
+      System.exit(0);
+    }
+    new ZoneCompactor(args[0], args[1], args[2], args[3], args[4]);
+  }
 }
diff --git a/libc/tools/zoneinfo/ZoneInfo.java b/libc/tools/zoneinfo/ZoneInfo.java
deleted file mode 100644
index 99507ae..0000000
--- a/libc/tools/zoneinfo/ZoneInfo.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.TimeZone;
-
-/**
- * Copied from ZoneInfo and ZoneInfoDB in dalvik.
- * {@hide}
- */
-public class ZoneInfo extends TimeZone {
-
-    private static final long MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;
-    private static final long MILLISECONDS_PER_400_YEARS =
-        MILLISECONDS_PER_DAY * (400 * 365 + 100 - 3);
-
-    private static final long UNIX_OFFSET = 62167219200000L;
-
-    private static final int[] NORMAL = new int[] {
-        0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334,
-    };
-
-    private static final int[] LEAP = new int[] {
-        0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335,
-    };
-
-    private static String nullName(byte[] data, int where, int off) {
-        if (off < 0)
-            return null;
-
-        int end = where + off;
-        while (end < data.length && data[end] != '\0')
-            end++;
-
-        return new String(data, where + off, end - (where + off));
-    }
-
-    public static ZoneInfo make(String name, byte[] data) {
-        int ntransition = read4(data, 32);
-        int ngmtoff = read4(data, 36);
-        int base = 44;
-
-        int[] transitions = new int[ntransition];
-        for (int i = 0; i < ntransition; i++)
-            transitions[i] = read4(data, base + 4 * i);
-        base += 4 * ntransition;
-
-        byte[] type = new byte[ntransition];
-        for (int i = 0; i < ntransition; i++)
-            type[i] = data[base + i];
-        base += ntransition;
-
-        int[] gmtoff = new int[ngmtoff];
-        byte[] isdst = new byte[ngmtoff];
-        byte[] abbrev = new byte[ngmtoff];
-        for (int i = 0; i < ngmtoff; i++) {
-            gmtoff[i] = read4(data, base + 6 * i);
-            isdst[i] = data[base + 6 * i + 4];
-            abbrev[i] = data[base + 6 * i + 5];
-        }
-
-        base += 6 * ngmtoff;
-
-        return new ZoneInfo(name, transitions, type, gmtoff, isdst, abbrev, data, base);
-    }
-
-    private static int read4(byte[] data, int off) {
-        return ((data[off    ] & 0xFF) << 24) |
-               ((data[off + 1] & 0xFF) << 16) |
-               ((data[off + 2] & 0xFF) <<  8) |
-               ((data[off + 3] & 0xFF) <<  0);
-    }
-
-    /*package*/ ZoneInfo(String name, int[] transitions, byte[] type,
-                     int[] gmtoff, byte[] isdst, byte[] abbrev,
-                     byte[] data, int abbrevoff) {
-        mTransitions = transitions;
-        mTypes = type;
-        mGmtOffs = gmtoff;
-        mIsDsts = isdst;
-        mUseDst = false;
-        setID(name);
-
-        // Find the latest GMT and non-GMT offsets for their abbreviations
-
-        int lastdst;
-        for (lastdst = mTransitions.length - 1; lastdst >= 0; lastdst--) {
-            if (mIsDsts[mTypes[lastdst] & 0xFF] != 0)
-                break;
-        }
-
-        int laststd;
-        for (laststd = mTransitions.length - 1; laststd >= 0; laststd--) {
-            if (mIsDsts[mTypes[laststd] & 0xFF] == 0)
-                break;
-        }
-
-        if (lastdst >= 0) {
-            mDaylightName = nullName(data, abbrevoff,
-                                     abbrev[mTypes[lastdst] & 0xFF]);
-        }
-        if (laststd >= 0) {
-            mStandardName = nullName(data, abbrevoff,
-                                     abbrev[mTypes[laststd] & 0xFF]);
-        }
-
-        // Use the latest non-DST offset if any as the raw offset
-
-        if (laststd < 0) {
-            laststd = 0;
-        }
-
-        if (laststd >= mTypes.length) {
-            mRawOffset = mGmtOffs[0];
-        } else {
-            mRawOffset = mGmtOffs[mTypes[laststd] & 0xFF];
-        }
-
-        // Subtract the raw offset from all offsets so it can be changed
-        // and affect them too.
-        // Find whether there exist any observances of DST.
-
-        for (int i = 0; i < mGmtOffs.length; i++) {
-            mGmtOffs[i] -= mRawOffset;
-
-            if (mIsDsts[i] != 0) {
-                mUseDst = true;
-            }
-        }
-
-        mRawOffset *= 1000;
-    }
-
-    @Override
-    public int getOffset(@SuppressWarnings("unused") int era,
-        int year, int month, int day,
-        @SuppressWarnings("unused") int dayOfWeek,
-        int millis) {
-        // XXX This assumes Gregorian always; Calendar switches from
-        // Julian to Gregorian in 1582.  What calendar system are the
-        // arguments supposed to come from?
-
-        long calc = (year / 400) * MILLISECONDS_PER_400_YEARS;
-        year %= 400;
-
-        calc += year * (365 * MILLISECONDS_PER_DAY);
-        calc += ((year + 3) / 4) * MILLISECONDS_PER_DAY;
-
-        if (year > 0)
-            calc -= ((year - 1) / 100) * MILLISECONDS_PER_DAY;
-
-        boolean isLeap = (year == 0 || (year % 4 == 0 && year % 100 != 0));
-        int[] mlen = isLeap ? LEAP : NORMAL;
-
-        calc += mlen[month] * MILLISECONDS_PER_DAY;
-        calc += (day - 1) * MILLISECONDS_PER_DAY;
-        calc += millis;
-
-        calc -= mRawOffset;
-        calc -= UNIX_OFFSET;
-
-        return getOffset(calc);
-    }
-
-    @Override
-    public int getOffset(long when) {
-        int unix = (int) (when / 1000);
-        int trans = Arrays.binarySearch(mTransitions, unix);
-
-        if (trans == ~0) {
-            return mGmtOffs[0] * 1000 + mRawOffset;
-        }
-        if (trans < 0) {
-            trans = ~trans - 1;
-        }
-
-        return mGmtOffs[mTypes[trans] & 0xFF] * 1000 + mRawOffset;
-    }
-
-    @Override
-    public int getRawOffset() {
-        return mRawOffset;
-    }
-
-    @Override
-    public void setRawOffset(int off) {
-        mRawOffset = off;
-    }
-
-    @Override
-    public boolean inDaylightTime(Date when) {
-        int unix = (int) (when.getTime() / 1000);
-        int trans = Arrays.binarySearch(mTransitions, unix);
-
-        if (trans == ~0) {
-            return mIsDsts[0] != 0;
-        }
-        if (trans < 0) {
-            trans = ~trans - 1;
-        }
-
-        return mIsDsts[mTypes[trans] & 0xFF] != 0;
-    }
-
-    @Override
-    public boolean useDaylightTime() {
-        return mUseDst;
-    }
-
-    private int mRawOffset;
-    private int[] mTransitions;
-    private int[] mGmtOffs;
-    private byte[] mTypes;
-    private byte[] mIsDsts;
-    private boolean mUseDst;
-    private String mDaylightName;
-    private String mStandardName;
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!(obj instanceof ZoneInfo)) {
-           return false;
-        }
-        ZoneInfo other = (ZoneInfo) obj;
-        return mUseDst == other.mUseDst
-                && (mDaylightName == null ? other.mDaylightName == null :
-                        mDaylightName.equals(other.mDaylightName))
-                && (mStandardName == null ? other.mStandardName == null :
-                        mStandardName.equals(other.mStandardName))
-                && mRawOffset == other.mRawOffset
-                // Arrays.equals returns true if both arrays are null
-                && Arrays.equals(mGmtOffs, other.mGmtOffs)
-                && Arrays.equals(mIsDsts, other.mIsDsts)
-                && Arrays.equals(mTypes, other.mTypes)
-                && Arrays.equals(mTransitions, other.mTransitions);
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((mDaylightName == null) ? 0 :
-                mDaylightName.hashCode());
-        result = prime * result + Arrays.hashCode(mGmtOffs);
-        result = prime * result + Arrays.hashCode(mIsDsts);
-        result = prime * result + mRawOffset;
-        result = prime * result + ((mStandardName == null) ? 0 :
-                mStandardName.hashCode());
-        result = prime * result + Arrays.hashCode(mTransitions);
-        result = prime * result + Arrays.hashCode(mTypes);
-        result = prime * result + (mUseDst ? 1231 : 1237);
-        return result;
-    }
-}
diff --git a/libc/tools/zoneinfo/generate b/libc/tools/zoneinfo/generate
index ab2617f..334ba3c 100755
--- a/libc/tools/zoneinfo/generate
+++ b/libc/tools/zoneinfo/generate
@@ -1,12 +1,10 @@
 #!/usr/bin/python
-# Run with no arguments from any directory, with no special setup required.
+
+"""Updates the tzdata file."""
 
 import ftplib
-import hashlib
 import os
 import re
-import shutil
-import string
 import subprocess
 import sys
 import tarfile
@@ -18,45 +16,78 @@
 bionic_libc_dir = os.path.dirname(bionic_libc_tools_dir)
 bionic_dir = os.path.dirname(bionic_libc_dir)
 bionic_libc_zoneinfo_dir = '%s/libc/zoneinfo' % bionic_dir
-if not os.path.isdir(bionic_libc_tools_zoneinfo_dir) or not os.path.isdir(bionic_libc_zoneinfo_dir):
+
+if not os.path.isdir(bionic_libc_tools_zoneinfo_dir):
   print "Couldn't find bionic/libc/tools/zoneinfo!"
   sys.exit(1)
+if not os.path.isdir(bionic_libc_zoneinfo_dir):
+  print "Couldn't find bionic/libc/zoneinfo!"
+  sys.exit(1)
+
 print 'Found bionic in %s...' % bionic_dir
 
 
-regions = ['africa', 'antarctica', 'asia', 'australasia', 'backward', 'etcetera', 'europe', 'northamerica', 'southamerica']
+regions = ['africa', 'antarctica', 'asia', 'australasia', 'backward',
+           'etcetera', 'europe', 'northamerica', 'southamerica']
 
 
-def current_tzdata_version():
-  return open('%s/zoneinfo.version' % bionic_libc_zoneinfo_dir).readline().rstrip('\n')
+def GetCurrentTzDataVersion():
+  return open('%s/tzdata' % bionic_libc_zoneinfo_dir).read().split('\x00', 1)[0]
 
 
-def md5_file(filename):
-  md5 = hashlib.md5()
-  f = open(filename, 'rb')
-  while True:
-    data = f.read(8192)
-    if not data:
-      break
-    md5.update(data)
-  return md5.hexdigest()
+def WriteSetupFile():
+  """Writes the list of zones that ZoneCompactor should process."""
+  links = []
+  zones = []
+  for region in regions:
+    for line in open('extracted/%s' % region):
+      fields = line.split()
+      if fields:
+        if fields[0] == 'Link':
+          links.append('%s %s %s\n' % (fields[0], fields[1], fields[2]))
+          zones.append(fields[2])
+        elif fields[0] == 'Zone':
+          zones.append(fields[1])
+  zones.sort()
+
+  setup = open('setup', 'w')
+  for link in links:
+    setup.write(link)
+  for zone in zones:
+    setup.write('%s\n' % zone)
+  setup.close()
 
 
-def upgrade_to(ftp, filename):
-  version = re.search('tzdata(.+)\.tar\.gz', filename).group(1)
+def Retrieve(ftp, filename):
+  ftp.retrbinary('RETR %s' % filename, open(filename, 'wb').write)
+
+
+def UpgradeTo(ftp, data_filename):
+  """Downloads and repackages the given data from the given FTP server."""
+
+  new_version = re.search('(tzdata.+)\\.tar\\.gz', data_filename).group(1)
 
   # Switch to a temporary directory.
   tmp_dir = tempfile.mkdtemp('-tzdata')
   os.chdir(tmp_dir)
   print 'Created temporary directory "%s"...' % tmp_dir
 
-  print 'Downloading %s...' % filename
-  ftp.retrbinary('RETR %s' % filename, open(filename, 'wb').write)
-  print 'MD5: %s' % md5_file(filename)
+  print 'Downloading data...'
+  Retrieve(ftp, data_filename)
+
+  print 'Downloading signature...'
+  signature_filename = '%s.asc' % data_filename
+  Retrieve(ftp, signature_filename)
+
+  print 'Verifying signature...'
+  # If this fails for you, you probably need to import Paul Eggert's public key:
+  # gpg --recv-keys ED97E90E62AA7E34
+  subprocess.check_call(['gpg', '--trusted-key=ED97E90E62AA7E34', '--verify',
+                         signature_filename, data_filename])
 
   print 'Extracting...'
   os.mkdir('extracted')
-  tar = tarfile.open(filename, 'r')
+  tar = tarfile.open(data_filename, 'r')
   tar.extractall('extracted')
 
   print 'Calling zic(1)...'
@@ -65,67 +96,45 @@
     if region != 'backward':
       subprocess.check_call(['zic', '-d', 'data', 'extracted/%s' % region])
 
-  # Collect the data ZoneCompactor needs.
-  links = []
-  zones = []
-  for region in regions:
-    for line in open('extracted/%s' % region).readlines():
-      fields = string.split(line)
-      if len(fields) == 0:
-        continue
-      elif fields[0] == 'Link':
-        links.append('%s %s %s\n' % (fields[0], fields[1], fields[2]))
-        zones.append(fields[2])
-      elif fields[0] == 'Zone':
-        zones.append(fields[1])
-  zones.sort()
+  WriteSetupFile()
 
-  # Write it into the "setup" file.
-  setup = open('setup', 'w')
-  for link in links:
-    setup.write(link)
-  for zone in zones:
-    setup.write('%s\n' % zone)
-  setup.close()
-
-  print 'Calling ZoneCompactor...'
+  print 'Calling ZoneCompactor to update bionic to %s...' % new_version
+  libcore_src_dir = '%s/../libcore/luni/src/main/java/' % bionic_dir
   subprocess.check_call(['javac', '-d', '.',
                          '%s/ZoneCompactor.java' % bionic_libc_tools_zoneinfo_dir,
-                         '%s/ZoneInfo.java' % bionic_libc_tools_zoneinfo_dir])
-  subprocess.check_call(['java', 'ZoneCompactor', 'setup', 'data'])
-
-  print 'Updating bionic from %s to %s...' % (current_tzdata_version(), version)
-  # Move the .dat and .idx files...
-  os.remove('%s/zoneinfo.dat' % bionic_libc_zoneinfo_dir)
-  shutil.move('zoneinfo.dat', bionic_libc_zoneinfo_dir)
-  os.remove('%s/zoneinfo.idx' % bionic_libc_zoneinfo_dir)
-  shutil.move('zoneinfo.idx', bionic_libc_zoneinfo_dir)
-  # Write the .version file...
-  zoneinfo_version = open('%s/zoneinfo.version' % bionic_libc_zoneinfo_dir, 'wb+')
-  zoneinfo_version.write('%s\n' % version)
-  zoneinfo_version.close()
+                         '%s/libcore/util/ZoneInfo.java' % libcore_src_dir,
+                         '%s/libcore/io/BufferIterator.java' % libcore_src_dir])
+  subprocess.check_call(['java', 'ZoneCompactor',
+                         'setup', 'data', 'extracted/zone.tab',
+                         bionic_libc_zoneinfo_dir, new_version])
 
 
-# URL from "Sources for Time Zone and Daylight Saving Time Data"
-# http://www.twinsun.com/tz/tz-link.htm
+# Run with no arguments from any directory, with no special setup required.
+# See http://www.iana.org/time-zones/ for more about the source of this data.
+def main():
+  print 'Looking for new tzdata...'
+  ftp = ftplib.FTP('ftp.iana.org')
+  ftp.login()
+  ftp.cwd('tz/releases')
+  tzdata_filenames = []
+  for filename in ftp.nlst():
+    if filename.startswith('tzdata20') and filename.endswith('.tar.gz'):
+      tzdata_filenames.append(filename)
+  tzdata_filenames.sort()
 
-print 'Looking for new tzdata...'
-ftp = ftplib.FTP('ftp.iana.org')
-ftp.login()
-ftp.cwd('tz/releases')
-tzdata_filenames = []
-for filename in ftp.nlst():
-  if filename.startswith('tzdata20'):
-    tzdata_filenames.append(filename)
-tzdata_filenames.sort()
+  # If you're several releases behind, we'll walk you through the upgrades
+  # one by one.
+  current_version = GetCurrentTzDataVersion()
+  current_filename = '%s.tar.gz' % current_version
+  for filename in tzdata_filenames:
+    if filename > current_filename:
+      print 'Found new tzdata: %s' % filename
+      UpgradeTo(ftp, filename)
+      sys.exit(0)
 
-# If you're several releases behind, we'll walk you through the upgrades one by one.
-current_version = current_tzdata_version()
-current_filename = 'tzdata%s.tar.gz' % current_version
-for filename in tzdata_filenames:
-  if filename > current_filename:
-    upgrade_to(ftp, filename)
-    sys.exit(0)
+  print 'You already have the latest tzdata (%s)!' % current_version
+  sys.exit(0)
 
-print 'You already have the latest tzdata (%s)!' % current_version
-sys.exit(0)
+
+if __name__ == '__main__':
+  main()
diff --git a/libc/tzcode/localtime.c b/libc/tzcode/localtime.c
index 6838180..447907e 100644
--- a/libc/tzcode/localtime.c
+++ b/libc/tzcode/localtime.c
@@ -37,12 +37,6 @@
 #define TZ_ABBR_ERR_CHAR    '_'
 #endif /* !defined TZ_ABBR_ERR_CHAR */
 
-#define INDEXFILE "/system/usr/share/zoneinfo/zoneinfo.idx"
-#define DATAFILE "/system/usr/share/zoneinfo/zoneinfo.dat"
-#define NAMELEN 40
-#define INTLEN 4
-#define READLEN (NAMELEN + 3 * INTLEN)
-
 /*
 ** SunOS 4.1.1 headers lack O_BINARY.
 */
@@ -205,6 +199,7 @@
 
 /* NOTE: all internal functions assume that _tzLock() was already called */
 
+static int __bionic_open_tzdata(const char*, int*);
 static long     detzcode P((const char * codep));
 static time_t   detzcode64 P((const char * codep));
 static int      differ_by_repeat P((time_t t1, time_t t0));
@@ -470,44 +465,8 @@
             return -1;
         }
         if ((fid = open(name, OPEN_MODE)) == -1) {
-            char buf[READLEN];
-            char name[NAMELEN + 1];
-            int fidix = open(INDEXFILE, OPEN_MODE);
-            int off = -1;
-
-            XLOG(( "tzload: could not open '%s', trying '%s'\n", fullname, INDEXFILE ));
-            if (fidix < 0) {
-                XLOG(( "tzload: could not find '%s'\n", INDEXFILE ));
-                return -1;
-            }
-
-            while (read(fidix, buf, sizeof(buf)) == sizeof(buf)) {
-                memcpy(name, buf, NAMELEN);
-                name[NAMELEN] = '\0';
-
-                if (strcmp(name, origname) == 0) {
-                    off = toint((unsigned char *) buf + NAMELEN);
-                    toread = toint((unsigned char *) buf + NAMELEN + INTLEN);
-                    break;
-                }
-            }
-
-            close(fidix);
-
-            if (off < 0) {
-                XLOG(( "tzload: invalid offset (%d)\n", off ));
-                return -1;
-            }
-
-            fid = open(DATAFILE, OPEN_MODE);
-
+            fid = __bionic_open_tzdata(origname, &toread);
             if (fid < 0) {
-                XLOG(( "tzload: could not open '%s'\n", DATAFILE ));
-                return -1;
-            }
-
-            if (lseek(fid, off, SEEK_SET) < 0) {
-                XLOG(( "tzload: could not seek to %d in '%s'\n", off, DATAFILE ));
                 return -1;
             }
         }
@@ -2275,3 +2234,94 @@
 }
 
 #endif /* defined STD_INSPIRED */
+
+#include <assert.h>
+#include <stdint.h>
+#include <arpa/inet.h> // For ntohl(3).
+
+static int __bionic_open_tzdata_path(const char* path, const char* olson_id, int* data_size) {
+  int fd = TEMP_FAILURE_RETRY(open(path, OPEN_MODE));
+  if (fd == -1) {
+    XLOG(("%s: could not open \"%s\": %s\n", __FUNCTION__, path, strerror(errno)));
+    return -2; // Distinguish failure to find any data from failure to find a specific id.
+  }
+
+  // byte[12] tzdata_version  -- "tzdata2012f\0"
+  // int index_offset
+  // int data_offset
+  // int zonetab_offset
+  struct bionic_tzdata_header {
+    char tzdata_version[12];
+    int32_t index_offset;
+    int32_t data_offset;
+    int32_t zonetab_offset;
+  } header;
+  if (TEMP_FAILURE_RETRY(read(fd, &header, sizeof(header))) != sizeof(header)) {
+    fprintf(stderr, "%s: could not read header: %s\n", __FUNCTION__, strerror(errno));
+    close(fd);
+    return -1;
+  }
+
+  if (strncmp(header.tzdata_version, "tzdata", 6) != 0 || header.tzdata_version[11] != 0) {
+    fprintf(stderr, "%s: bad magic: %s\n", __FUNCTION__, header.tzdata_version);
+    close(fd);
+    return -1;
+  }
+
+#if 0
+  fprintf(stderr, "version: %s\n", header.tzdata_version);
+  fprintf(stderr, "index_offset = %d\n", ntohl(header.index_offset));
+  fprintf(stderr, "data_offset = %d\n", ntohl(header.data_offset));
+  fprintf(stderr, "zonetab_offset = %d\n", ntohl(header.zonetab_offset));
+#endif
+
+  if (TEMP_FAILURE_RETRY(lseek(fd, ntohl(header.index_offset), SEEK_SET)) == -1) {
+    fprintf(stderr, "%s: couldn't seek to index: %s\n", __FUNCTION__, strerror(errno));
+    close(fd);
+    return -1;
+  }
+
+  off_t specific_zone_offset = -1;
+
+  static const size_t NAME_LENGTH = 40;
+  unsigned char buf[NAME_LENGTH + 3 * sizeof(int32_t)];
+  while (TEMP_FAILURE_RETRY(read(fd, buf, sizeof(buf))) == (ssize_t) sizeof(buf)) {
+    char this_id[NAME_LENGTH + 1];
+    memcpy(this_id, buf, NAME_LENGTH);
+    this_id[NAME_LENGTH] = '\0';
+
+    if (strcmp(this_id, olson_id) == 0) {
+      specific_zone_offset = toint(buf + NAME_LENGTH) + ntohl(header.data_offset);
+      *data_size = toint(buf + NAME_LENGTH + sizeof(int32_t));
+      break;
+    }
+  }
+
+  if (specific_zone_offset == -1) {
+    XLOG(("%s: couldn't find zone \"%s\"\n", __FUNCTION__, olson_id));
+    close(fd);
+    return -1;
+  }
+
+  if (TEMP_FAILURE_RETRY(lseek(fd, specific_zone_offset, SEEK_SET)) == -1) {
+    fprintf(stderr, "%s: could not seek to %ld: %s\n", __FUNCTION__, specific_zone_offset, strerror(errno));
+    close(fd);
+    return -1;
+  }
+
+  return fd;
+}
+
+static int __bionic_open_tzdata(const char* olson_id, int* data_size) {
+  // TODO: use $ANDROID_DATA and $ANDROID_ROOT like libcore, to support bionic on the host.
+  int fd = __bionic_open_tzdata_path("/data/misc/zoneinfo/tzdata", olson_id, data_size);
+  if (fd < 0) {
+    fd = __bionic_open_tzdata_path("/system/usr/share/zoneinfo/tzdata", olson_id, data_size);
+    if (fd == -2) {
+      // The first thing that 'recovery' does is try to format the current time. It doesn't have
+      // any tzdata available, so we must not abort here --- doing so breaks the recovery image!
+      fprintf(stderr, "%s: couldn't find any tzdata when looking for %s!\n", __FUNCTION__, olson_id);
+    }
+  }
+  return fd;
+}
diff --git a/libc/unistd/brk.c b/libc/unistd/brk.c
deleted file mode 100644
index bf2f108..0000000
--- a/libc/unistd/brk.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <stddef.h>
-#include <unistd.h>
-#include <sys/types.h>
-
-/* shared with sbrk.c */
-char *__bionic_brk;
-
-int brk(void*  end_data)
-{
-    char*  new_brk = __brk( end_data );
-
-    if (new_brk != end_data)
-        return -1;
-
-    __bionic_brk = new_brk;
-  
-  return 0;
-}
diff --git a/libc/unistd/killpg.c b/libc/unistd/killpg.c
deleted file mode 100644
index 75b1ad9..0000000
--- a/libc/unistd/killpg.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <signal.h>
-#include <errno.h>
-
-/*
- * Backwards-compatible killpg().
- */
-int
-killpg(pid_t pgid, int sig)
-{
-	if (pgid == 1) {
-		errno = ESRCH;
-		return (-1);
-	}
-	return (kill(-pgid, sig));
-}
diff --git a/libc/unistd/mmap.c b/libc/unistd/mmap.c
deleted file mode 100644
index e097086..0000000
--- a/libc/unistd/mmap.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <unistd.h>
-#include <errno.h>
-#include <sys/mman.h>
-
-extern void*  __mmap2(void*, size_t, int, int, int, size_t);
-
-#define  MMAP2_SHIFT  12
-void* mmap(void *addr, size_t size, int prot, int flags, int fd, long offset)
-{
-    void *ret;
-
-    if (offset & ((1UL << MMAP2_SHIFT)-1)) {
-        errno = EINVAL;
-        return MAP_FAILED;
-    }
-
-    ret = __mmap2(addr, size, prot, flags, fd, (size_t)offset >> MMAP2_SHIFT);
-
-    if (ret && (flags & (MAP_PRIVATE | MAP_ANONYMOUS)))
-	    madvise(ret, size, MADV_MERGEABLE);
-
-    return ret;
-}
diff --git a/libc/unistd/open.c b/libc/unistd/open.c
deleted file mode 100644
index 56602db..0000000
--- a/libc/unistd/open.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <private/logd.h>
-
-extern int  __open(const char*, int, int);
-
-int open(const char *pathname, int flags, ...)
-{
-    mode_t  mode = 0;
-
-    flags |= O_LARGEFILE;
-
-    if (flags & O_CREAT)
-    {
-        va_list  args;
-
-        va_start(args, flags);
-        mode = (mode_t) va_arg(args, int);
-        va_end(args);
-    }
-
-    return __open(pathname, flags, mode);
-}
-
-int __open_2(const char *pathname, int flags) {
-    if (flags & O_CREAT) {
-        __libc_android_log_print(ANDROID_LOG_FATAL, "libc",
-            "*** open(O_CREAT) called without specifying a mode ***\n");
-        abort();
-    }
-
-    flags |= O_LARGEFILE;
-
-    return __open(pathname, flags, 0);
-}
-
diff --git a/libc/unistd/openat.c b/libc/unistd/openat.c
deleted file mode 100644
index fb04e9c..0000000
--- a/libc/unistd/openat.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <private/logd.h>
-
-extern int  __openat(int, const char*, int, int);
-
-int openat(int fd, const char *pathname, int flags, ...)
-{
-    mode_t  mode = 0;
-
-    flags |= O_LARGEFILE;
-
-    if (flags & O_CREAT)
-    {
-        va_list  args;
-
-        va_start(args, flags);
-        mode = (mode_t) va_arg(args, int);
-        va_end(args);
-    }
-
-    return __openat(fd, pathname, flags, mode);
-}
-
-int __openat_2(int fd, const char *pathname, int flags)
-{
-    if (flags & O_CREAT) {
-        __libc_android_log_print(ANDROID_LOG_FATAL, "libc",
-            "*** openat(O_CREAT) called without specifying a mode ***\n");
-        abort();
-    }
-
-    flags |= O_LARGEFILE;
-
-    return __openat(fd, pathname, flags, 0);
-}
-
diff --git a/libc/unistd/opendir.c b/libc/unistd/opendir.c
deleted file mode 100644
index f178bc6..0000000
--- a/libc/unistd/opendir.c
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <unistd.h>
-#include <dirent.h>
-#include <memory.h>
-#include <string.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <errno.h>
-
-struct DIR
-{
-    int              _DIR_fd;
-    size_t           _DIR_avail;
-    struct dirent*   _DIR_next;
-    pthread_mutex_t  _DIR_lock;
-    struct dirent    _DIR_buff[15];
-};
-
-int dirfd(DIR* dirp)
-{
-    return dirp->_DIR_fd;
-}
-
-DIR*  opendir( const char*  dirpath )
-{
-    DIR*  dir = malloc(sizeof(DIR));
-
-    if (!dir)
-        goto Exit;
-
-    dir->_DIR_fd = open(dirpath, O_RDONLY|O_DIRECTORY);
-    if (dir->_DIR_fd < 0)
-    {
-        free(dir);
-        dir = NULL;
-    }
-    else
-    {
-        dir->_DIR_avail = 0;
-        dir->_DIR_next  = NULL;
-        pthread_mutex_init( &dir->_DIR_lock, NULL );
-    }
-Exit:
-    return dir;
-}
-
-
-DIR*  fdopendir(int fd)
-{
-    DIR*  dir = malloc(sizeof(DIR));
-
-    if (!dir)
-        return 0;
-
-    dir->_DIR_fd = fd;
-    dir->_DIR_avail = 0;
-    dir->_DIR_next  = NULL;
-    pthread_mutex_init( &dir->_DIR_lock, NULL );
-
-    return dir;
-}
-
-
-static struct dirent*
-_readdir_unlocked(DIR*  dir)
-{
-    struct dirent*  entry;
-#ifndef NDEBUG
-    unsigned reclen;
-#endif
-
-    if ( !dir->_DIR_avail )
-    {
-        int  rc;
-
-        for (;;) {
-            rc = getdents( dir->_DIR_fd, dir->_DIR_buff, sizeof(dir->_DIR_buff));
-            if (rc >= 0 || errno != EINTR)
-            break;
-        }
-        if (rc <= 0)
-            return NULL;
-
-        dir->_DIR_avail = rc;
-        dir->_DIR_next  = dir->_DIR_buff;
-    }
-
-    entry = dir->_DIR_next;
-
-    /* perform some sanity checks here */
-    if (((long)(void*)entry & 3) != 0)
-        return NULL;
-
-#ifndef NDEBUG
-    // paranoid testing of the interface with the kernel getdents64 system call
-    reclen = offsetof(struct dirent, d_name) + strlen(entry->d_name) + 1;
-    if ( reclen > sizeof(*entry) || reclen <= offsetof(struct dirent, d_name) )
-        goto Bad;
-
-    if ( (char*)entry + reclen > (char*)dir->_DIR_buff + sizeof(dir->_DIR_buff) )
-        goto Bad;
-
-    if ( !memchr( entry->d_name, 0, reclen - offsetof(struct dirent, d_name)) )
-        goto Bad; 
-#endif
-
-    dir->_DIR_next   = (struct dirent*)((char*)entry + entry->d_reclen);
-    dir->_DIR_avail -= entry->d_reclen;
-
-    return entry;
-
-  Bad:
-    errno = EINVAL;
-    return NULL;
-}
-
-
-struct dirent*
-readdir(DIR * dir)
-{
-    struct dirent *entry = NULL;
-
-    pthread_mutex_lock( &dir->_DIR_lock );
-    entry = _readdir_unlocked(dir);
-    pthread_mutex_unlock( &dir->_DIR_lock );
-
-    return entry;
-}
-
-
-int readdir_r(DIR*  dir, struct dirent *entry, struct dirent **result)
-{
-    struct dirent*  ent;
-    int  save_errno = errno;
-    int  retval;
-
-    *result = NULL;
-    errno   = 0;
-
-    pthread_mutex_lock( &dir->_DIR_lock );
-
-    ent    = _readdir_unlocked(dir);
-    retval = errno;
-    if (ent == NULL) {
-        if (!retval) {
-            errno = save_errno;
-        }
-    } else {
-        if (!retval) {
-            errno   = save_errno;
-            *result = entry;
-            memcpy( entry, ent, ent->d_reclen );
-        }
-    }
-
-    pthread_mutex_unlock( &dir->_DIR_lock );
-
-    return retval;
-}
-
-
-
-int closedir(DIR *dir)
-{
-  int rc;
-
-  rc = close(dir->_DIR_fd);
-  dir->_DIR_fd = -1;
-
-  pthread_mutex_destroy( &dir->_DIR_lock );
-
-  free(dir);
-  return rc;
-}
-
-
-void   rewinddir(DIR *dir)
-{
-    pthread_mutex_lock( &dir->_DIR_lock );
-    lseek( dir->_DIR_fd, 0, SEEK_SET );
-    dir->_DIR_avail = 0;
-    pthread_mutex_unlock( &dir->_DIR_lock );
-}
-
-
-int alphasort(const void *a, const void *b)
-{
-        struct dirent **d1, **d2;
-
-        d1 = (struct dirent **) a;
-        d2 = (struct dirent **) b;
-        return strcmp((*d1)->d_name, (*d2)->d_name);
-}
-
-
-int scandir(const char *dir, struct dirent ***namelist,
-            int(*filter)(const struct dirent *),
-            int(*compar)(const struct dirent **, const struct dirent **))
-{
-    DIR *d;
-    int n_elem = 0;
-    struct dirent *this_de, *de;
-    struct dirent **de_list = NULL;
-    int de_list_size = 0;
-
-    d = opendir(dir);
-    if (d == NULL) {
-        return -1;
-    }
-
-    while ((this_de = readdir(d)) != NULL) {
-        if (filter && (*filter)(this_de) == 0) {
-            continue;
-        }
-        if (n_elem == 0) {
-            de_list_size = 4;
-            de_list = (struct dirent **) 
-                    malloc(sizeof(struct dirent *)*de_list_size);
-            if (de_list == NULL) {
-                return -1;
-            }
-        }
-        else if (n_elem == de_list_size) {
-            struct dirent **de_list_new;
-
-            de_list_size += 10;
-            de_list_new = (struct dirent **) 
-                    realloc(de_list, sizeof(struct dirent *)*de_list_size);
-            if (de_list_new == NULL) {
-                free(de_list);
-                return -1;
-            }
-            de_list = de_list_new;
-        }
-        de = (struct dirent *) malloc(sizeof(struct dirent));
-        *de = *this_de;
-        de_list[n_elem++] = de;
-    }
-    closedir(d);
-    if (n_elem && compar) {
-        qsort(de_list, n_elem, sizeof(struct dirent *), 
-              (int (*)(const void *, const void *)) compar);
-    }
-    *namelist = de_list;
-    return n_elem;
-}
diff --git a/libc/unistd/popen.c b/libc/unistd/popen.c
deleted file mode 100644
index c2355c1..0000000
--- a/libc/unistd/popen.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/*	$OpenBSD: popen.c,v 1.17 2005/08/08 08:05:34 espie Exp $ */
-/*
- * Copyright (c) 1988, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software written by Ken Arnold and
- * published in UNIX Review, Vol. 6, No. 8.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/param.h>
-#include <sys/wait.h>
-
-#include <signal.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <paths.h>
-
-static struct pid {
-	struct pid *next;
-	FILE *fp;
-	pid_t pid;
-} *pidlist;
-
-extern char **environ;
-
-FILE *
-popen(const char *program, const char *type)
-{
-	struct pid * volatile cur;
-	FILE *iop;
-	int pdes[2];
-	pid_t pid;
-	char *argp[] = {"sh", "-c", NULL, NULL};
-
-	if ((*type != 'r' && *type != 'w') || type[1] != '\0') {
-		errno = EINVAL;
-		return (NULL);
-	}
-
-	if ((cur = malloc(sizeof(struct pid))) == NULL)
-		return (NULL);
-
-	if (pipe(pdes) < 0) {
-		free(cur);
-		return (NULL);
-	}
-
-	switch (pid = fork()) {
-	case -1:			/* Error. */
-		(void)close(pdes[0]);
-		(void)close(pdes[1]);
-		free(cur);
-		return (NULL);
-		/* NOTREACHED */
-	case 0:				/* Child. */
-	    {
-		struct pid *pcur;
-		/*
-		 * We fork()'d, we got our own copy of the list, no
-		 * contention.
-		 */
-		for (pcur = pidlist; pcur; pcur = pcur->next)
-			close(fileno(pcur->fp));
-
-		if (*type == 'r') {
-			(void) close(pdes[0]);
-			if (pdes[1] != STDOUT_FILENO) {
-				(void)dup2(pdes[1], STDOUT_FILENO);
-				(void)close(pdes[1]);
-			}
-		} else {
-			(void)close(pdes[1]);
-			if (pdes[0] != STDIN_FILENO) {
-				(void)dup2(pdes[0], STDIN_FILENO);
-				(void)close(pdes[0]);
-			}
-		}
-		argp[2] = (char *)program;
-		execve(_PATH_BSHELL, argp, environ);
-		_exit(127);
-		/* NOTREACHED */
-	    }
-	}
-
-	/* Parent; assume fdopen can't fail. */
-	if (*type == 'r') {
-		iop = fdopen(pdes[0], type);
-		(void)close(pdes[1]);
-	} else {
-		iop = fdopen(pdes[1], type);
-		(void)close(pdes[0]);
-	}
-
-	/* Link into list of file descriptors. */
-	cur->fp = iop;
-	cur->pid =  pid;
-	cur->next = pidlist;
-	pidlist = cur;
-
-	return (iop);
-}
-
-/*
- * pclose --
- *	Pclose returns -1 if stream is not associated with a `popened' command,
- *	if already `pclosed', or waitpid returns an error.
- */
-int
-pclose(FILE *iop)
-{
-	struct pid *cur, *last;
-	int pstat;
-	pid_t pid;
-
-	/* Find the appropriate file pointer. */
-	for (last = NULL, cur = pidlist; cur; last = cur, cur = cur->next)
-		if (cur->fp == iop)
-			break;
-
-	if (cur == NULL)
-		return (-1);
-
-	(void)fclose(iop);
-
-	do {
-		pid = waitpid(cur->pid, &pstat, 0);
-	} while (pid == -1 && errno == EINTR);
-
-	/* Remove the entry from the linked list. */
-	if (last == NULL)
-		pidlist = cur->next;
-	else
-		last->next = cur->next;
-	free(cur);
-
-	return (pid == -1 ? -1 : pstat);
-}
diff --git a/libc/unistd/raise.c b/libc/unistd/raise.c
deleted file mode 100644
index 7b03a7a..0000000
--- a/libc/unistd/raise.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <unistd.h>
-#include <signal.h>
-
-int raise(int signum)
-{
-    return kill(gettid(), signum);
-}
diff --git a/libc/unistd/sbrk.c b/libc/unistd/sbrk.c
deleted file mode 100644
index a112b6c..0000000
--- a/libc/unistd/sbrk.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <unistd.h>
-#include <errno.h>
-
-
-#define  SBRK_ALIGN  32
-
-/* shared with brk() implementation */
-char*   __bionic_brk;
-
-void *sbrk(ptrdiff_t increment)
-{
-    char*  start;
-    char*  end;
-    char*  new_brk;
-  
-    if ( !__bionic_brk)
-        __bionic_brk = __brk((void*)0);
-
-    start = (char*)(((long)__bionic_brk + SBRK_ALIGN-1) & ~(SBRK_ALIGN-1));
-  end   = start + increment;
-
-  new_brk = __brk(end);
-    if (new_brk == (void*)-1)
-        return new_brk;
-    else if (new_brk < end)
-    {
-    errno = ENOMEM;
-        return (void*)-1;
-  }
-
-    __bionic_brk = new_brk;
-  return start;
-}
diff --git a/libc/unistd/sigwait.c b/libc/unistd/sigwait.c
deleted file mode 100644
index 1e90c41..0000000
--- a/libc/unistd/sigwait.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <errno.h>
-#include <signal.h>
-#include <string.h>
-#include <time.h>
-
-int __rt_sigtimedwait(const sigset_t *uthese, siginfo_t *uinfo, const struct timespec *uts, size_t sigsetsize);
-
-/* ok, this is really subtle: <asm/signal.h> defines sigset_t differently
- * when you're in the kernel or in the C library.
- *
- * in the kernel, this is an array of 2 32-bit unsigned longs
- * in the C library, this is a single 32-bit unsigned long
- *
- * moreover, the kernel implementation of rt_sigtimedwait doesn't
- * accept anything except kernel-sized signal sets (probably a bug !)
- *
- * we thus need to create a fake kernel sigset !!
- */
-
-int sigwait(const sigset_t *set, int *sig)
-{
-    int  ret;
-#ifdef __mips__
-    /* use a union to get rid of aliasing warnings. On MIPS sigset_t is 128 bits */
-    union {
-      sigset_t       kernel_sigset;
-      sigset_t       dummy_sigset;
-    } u;
-    u.dummy_sigset = *set;
-#else
-    /* use a union to get rid of aliasing warnings */
-    union {
-      unsigned long  kernel_sigset[2];
-      sigset_t       dummy_sigset;
-    } u;
-
-    u.kernel_sigset[0] = *set;
-    u.kernel_sigset[1] = 0;  /* no real-time signals supported ? */
-#endif
-    for (;;)
-    {
-     /* __rt_sigtimedwait can return EAGAIN or EINTR, we need to loop
-      * around them since sigwait is only allowed to return EINVAL
-      */
-      ret = __rt_sigtimedwait ( &u.dummy_sigset, NULL, NULL, sizeof(u.kernel_sigset));
-      if (ret >= 0)
-        break;
-
-      if (errno != EAGAIN && errno != EINTR)
-        return errno;
-    }
-
-    *sig = ret;
-    return 0;
-}
-
diff --git a/libc/unistd/sysconf.c b/libc/unistd/sysconf.c
deleted file mode 100644
index 7caa4e9..0000000
--- a/libc/unistd/sysconf.c
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <asm/page.h>
-#include <bionic_tls.h>
-#include <ctype.h>
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <stdbool.h>
-#include <stdio.h>  // For FOPEN_MAX.
-#include <string.h>
-#include <sys/sysconf.h>
-#include <unistd.h>
-
-/* seems to be the default on Linux, per the GLibc sources and my own digging */
-
-#define  SYSTEM_CLK_TCK         100
-#define  SYSTEM_IOV_MAX         1024
-#define  SYSTEM_DELAYTIMER_MAX  2147483647
-#define  SYSTEM_MQ_OPEN_MAX     8
-#define  SYSTEM_MQ_PRIO_MAX     32768
-#define  SYSTEM_SEM_NSEMS_MAX   256
-#define  SYSTEM_SEM_VALUE_MAX   0x3fffffff  /* see bionic/semaphore.c */
-#define  SYSTEM_SIGQUEUE_MAX    32
-#define  SYSTEM_TIMER_MAX       32
-#define  SYSTEM_LOGIN_NAME_MAX  256
-#define  SYSTEM_TTY_NAME_MAX    32
-
-/* the following depends on our implementation */
-#define  SYSTEM_ATEXIT_MAX          65536    /* our implementation is unlimited */
-#define  SYSTEM_THREAD_KEYS_MAX     BIONIC_TLS_SLOTS
-#define  SYSTEM_THREAD_STACK_MIN    32768    /* lower values may be possible, but be conservative */
-#define  SYSTEM_THREAD_THREADS_MAX  2048     /* really unlimited */
-
-#define  SYSTEM_2_C_BIND     _POSIX_VERSION  /* Posix C binding version */
-#define  SYSTEM_2_C_VER      _POSIX2_C_VERSION
-#define  SYSTEM_2_C_DEV      -1       /* Posix C development tools unsupported on the device */
-#define  SYSTEM_2_FORT_DEV   -1       /* Fortran development unsupported */
-#define  SYSTEM_2_FORT_RUN   -1       /* Fortran runtime unsupported */
-#define  SYSTEM_2_SW_DEV     -1       /* posix software dev utilities unsupported */
-#define  SYSTEM_2_LOCALEDEF  -1       /* localedef() unimplemented */
-#define  SYSTEM_2_UPE        -1       /* No UPE for you ! (User Portability Utilities) */
-#define  SYSTEM_2_VERSION    -1       /* No posix command-line tools */
-
-static bool __matches_cpuN(const char* s) {
-  // The %c trick is to ensure that we have the anchored match "^cpu[0-9]+$".
-  unsigned cpu;
-  char dummy;
-  return (sscanf(s, "cpu%u%c", &cpu, &dummy) == 1);
-}
-
-static int __get_nproc_conf(void) {
-  // On x86 kernels you can use /proc/cpuinfo for this, but on ARM kernels offline CPUs disappear
-  // from there. This method works on both.
-  DIR* d = opendir("/sys/devices/system/cpu");
-  if (!d) {
-    return 1;
-  }
-
-  int result = 0;
-  struct dirent de;
-  struct dirent* e;
-  while (!readdir_r(d, &de, &e) && e != NULL) {
-    if (e->d_type == DT_DIR && __matches_cpuN(e->d_name)) {
-      ++result;
-    }
-  }
-  closedir(d);
-  return result;
-}
-
-static int __get_nproc_onln(void) {
-  FILE* fp = fopen("/proc/stat", "r");
-  if (fp == NULL) {
-    return 1;
-  }
-
-  int result = 0;
-  char buf[256];
-  while (fgets(buf, sizeof(buf), fp) != NULL) {
-    // Extract just the first word from the line.
-    // 'cpu0 7976751 1364388 3116842 469770388 8629405 0 49047 0 0 0'
-    char* p = strchr(buf, ' ');
-    if (p != NULL) {
-      *p = 0;
-    }
-    if (__matches_cpuN(buf)) {
-      ++result;
-    }
-  }
-  fclose(fp);
-  return result;
-}
-
-static int __get_meminfo(const char* pattern) {
-  FILE* fp = fopen("/proc/meminfo", "r");
-  if (fp == NULL) {
-    return -1;
-  }
-
-  int result = -1;
-  char buf[256];
-  while (fgets(buf, sizeof(buf), fp) != NULL) {
-    long total;
-    if (sscanf(buf, pattern, &total) == 1) {
-      result = (int) (total / (PAGE_SIZE/1024));
-      break;
-    }
-  }
-  fclose(fp);
-  return result;
-}
-
-static int __get_phys_pages(void) {
-  return __get_meminfo("MemTotal: %ld kB");
-}
-
-static int __get_avphys_pages(void) {
-  return __get_meminfo("MemFree: %ld kB");
-}
-
-int sysconf(int name) {
-    switch (name) {
-#ifdef _POSIX_ARG_MAX
-    case _SC_ARG_MAX:           return _POSIX_ARG_MAX;
-#endif
-#ifdef _POSIX2_BC_BASE_MAX
-    case _SC_BC_BASE_MAX:       return _POSIX2_BC_BASE_MAX;
-#endif
-#ifdef _POSIX2_BC_DIM_MAX
-    case _SC_BC_DIM_MAX:        return _POSIX2_BC_DIM_MAX;
-#endif
-#ifdef _POSIX2_BC_SCALE_MAX
-    case _SC_BC_SCALE_MAX:      return _POSIX2_BC_SCALE_MAX;
-#endif
-#ifdef _POSIX2_BC_STRING_MAX
-    case _SC_BC_STRING_MAX:     return _POSIX2_BC_STRING_MAX;
-#endif
-    case _SC_CHILD_MAX:         return CHILD_MAX;
-    case _SC_CLK_TCK:           return SYSTEM_CLK_TCK;
-#ifdef _POSIX2_COLL_WEIGHTS_MASK
-    case _SC_COLL_WEIGHTS_MAX:  return _POSIX2_COLL_WEIGHTS_MASK;
-#endif
-#ifdef _POSIX2_EXPR_NEST_MAX
-    case _SC_EXPR_NEST_MAX:    return _POSIX2_EXPR_NEST_MAX;
-#endif
-#ifdef _POSIX2_LINE_MAX
-    case _SC_LINE_MAX:          return _POSIX2_LINE_MAX;
-#endif
-    case _SC_NGROUPS_MAX:       return NGROUPS_MAX;
-    case _SC_OPEN_MAX:          return OPEN_MAX;
-    //case _SC_PASS_MAX:          return PASS_MAX;
-    case _SC_2_C_BIND:          return SYSTEM_2_C_BIND;
-    case _SC_2_C_DEV:           return SYSTEM_2_C_DEV;
-    case _SC_2_C_VERSION:       return SYSTEM_2_C_VER;
-    //case _SC_2_CHAR_TERM:         return ;
-    case _SC_2_FORT_DEV:        return SYSTEM_2_FORT_DEV;
-    case _SC_2_FORT_RUN:        return SYSTEM_2_FORT_RUN;
-    case _SC_2_LOCALEDEF:       return SYSTEM_2_LOCALEDEF;
-    case _SC_2_SW_DEV:          return SYSTEM_2_SW_DEV;
-    case _SC_2_UPE:             return SYSTEM_2_UPE;
-    case _SC_2_VERSION:         return SYSTEM_2_VERSION;
-#ifdef _POSIX_JOB_CONTROL
-    case _SC_JOB_CONTROL:       return _POSIX_JOB_CONTROL;
-#endif
-#ifdef _POSIX_SAVED_IDS
-    case _SC_SAVED_IDS:         return _POSIX_SAVED_IDS;
-#endif
-#ifdef _POSIX_VERSION
-    case _SC_VERSION:           return _POSIX_VERSION;
-#endif
-    //case _SC_RE_DUP_<AX:        return ;
-    case _SC_STREAM_MAX:        return FOPEN_MAX;
-    //case _SC_TZNAME_MAX:        return ;
-#if _XOPEN_CRYPT
-    case _SC_XOPEN_CRYPT:       return _XOPEN_CRYPT;
-#endif
-#ifdef _XOPEN_ENH_I18N
-    case _SC_XOPEN_ENH_I18N:    return _XOPEN_ENH_I18N;
-#endif
-#ifdef _XOPEN_SHM
-    case _SC_XOPEN_SHM:         return _XOPEN_SHM;
-#endif
-#ifdef _XOPEN_VERSION
-    case _SC_XOPEN_VERSION:     return _XOPEN_VERSION;
-#endif
-#ifdef _XOPEN_XCU_VERSION
-    case _SC_XOPEN_XCU_VERSION: return _XOPEN_XCU_VERSION;
-#endif
-#ifdef _XOPEN_REALTIME
-    case _SC_XOPEN_REALTIME:    return _XOPEN_REALTIME;
-#endif
-#ifdef _XOPEN_REALTIME_THREADS
-    case _SC_XOPEN_REALTIME_THREADS: return _XOPEN_REALTIME_THREADS;
-#endif
-#ifdef _XOPEN_LEGACY
-    case _SC_XOPEN_LEGACY:      return _XOPEN_LEGACY;
-#endif
-    case _SC_ATEXIT_MAX:        return SYSTEM_ATEXIT_MAX;
-    case _SC_IOV_MAX:           return SYSTEM_IOV_MAX;
-    case _SC_PAGESIZE:          return PAGE_SIZE;
-    case _SC_PAGE_SIZE:         return PAGE_SIZE;
-#ifdef _XOPEN_UNIX
-    case _SC_XOPEN_UNIX:        return _XOPEN_UNIX;
-#endif
-
-    // XXX: TODO: XBS5 nonsense
-
-#ifdef AIO_LISTIO_MAX
-    case _SC_AIO_LISTIO_MAX:       return AIO_LISTIO_MAX;
-#endif
-#ifdef AIO_MAX
-    case _SC_AIO_MAX:              return AIO_MAX;
-#endif
-#ifdef AIO_PRIO_DELTA_MAX
-    case _SC_AIO_PRIO_DELTA_MAX:   return AIO_PRIO_DELTA_MAX;
-#endif
-    case _SC_DELAYTIMER_MAX:    return SYSTEM_DELAYTIMER_MAX;
-    case _SC_MQ_OPEN_MAX:       return SYSTEM_MQ_OPEN_MAX;
-    case _SC_MQ_PRIO_MAX:       return SYSTEM_MQ_PRIO_MAX;
-    case _SC_RTSIG_MAX:         return RTSIG_MAX;
-    case _SC_SEM_NSEMS_MAX:     return SYSTEM_SEM_NSEMS_MAX;
-    case _SC_SEM_VALUE_MAX:     return SYSTEM_SEM_VALUE_MAX;
-    case _SC_SIGQUEUE_MAX:      return SYSTEM_SIGQUEUE_MAX;
-    case _SC_TIMER_MAX:         return SYSTEM_TIMER_MAX;
-#ifdef _POSIX_ASYNCHRONOUS_IO
-    case _SC_ASYNCHRONOUS_IO:   return _POSIX_ASYNCHRONOUS_IO;
-#endif
-#ifdef _POSIX_FSYNC
-    case _SC_FSYNC:             return _POSIX_FSYNC;
-#endif
-#ifdef _POSIX_MAPPED_FILES
-    case _SC_MAPPED_FILES:      return _POSIX_MAPPED_FILES;
-#endif
-#ifdef _POSIX_MEMLOCK
-    case _SC_MEMLOCK:           return _POSIX_MEMLOCK;
-#endif
-#ifdef _POSIX_MEMLOCK_RANGE
-    case _SC_MEMLOCK_RANGE:     return _POSIX_MEMLOCK_RANGE
-#endif
-#ifdef _POSIX_MEMORY_PROTECTION
-    case _SC_MEMORY_PROTECTION: return _POSIX_MEMORY_PROTECTION;
-#endif
-#ifdef _POSIX_MESSAGE_PASSING
-    case _SC_MESSAGE_PASSING:   return _POSIX_MESSAGE_PASSING;
-#endif
-#ifdef _POSIX_PRIORITIZED_IO
-    case _SC_PRIORITIZED_IO:    return _POSIX_PRIORITIZED_IO;
-#endif
-#ifdef _POSIX_PRIORITY_SCHEDULING
-    case _SC_PRIORITY_SCHEDULING:  return _POSIX_PRIORITY_SCHEDULING;
-#endif
-#ifdef _POSIX_REALTIME_SIGNALS
-    case _SC_REALTIME_SIGNALS:  return _POSIX_REALTIME_SIGNALS;
-#endif
-#ifdef _POSIX_SEMAPHORES
-    case _SC_SEMAPHORES:        return _POSIX_SEMAPHORES;
-#endif
-#ifdef _POSIX_SHARED_MEMORY_OBJECTS
-    case _SC_SHARED_MEMORY_OBJECTS:  return _POSIX_SHARED_MEMORY_OBJECTS;
-#endif
-#ifdef _POSIX_SYNCHRONIZED_IO
-    case _SC_SYNCHRONIZED_IO:   return _POSIX_SYNCHRONIZED_IO;
-#endif
-#ifdef _POSIX_TIMERS
-    case _SC_TIMERS:            return _POSIX_TIMERS;
-#endif
-
-    // GETGR_R_SIZE_MAX ?
-    // GETPW_R_SIZE_MAX ?
-
-    case _SC_LOGIN_NAME_MAX:    return SYSTEM_LOGIN_NAME_MAX;
-#ifdef _POSIX_THREAD_DESTRUCTOR_ITERATIONS
-    case _SC_THREAD_DESTRUCTOR_ITERATIONS:  return _POSIX_THREAD_DESTRUCTOR_ITERATIONS;
-#endif
-    case _SC_THREAD_KEYS_MAX:     return SYSTEM_THREAD_KEYS_MAX;
-    case _SC_THREAD_STACK_MIN:    return SYSTEM_THREAD_STACK_MIN;
-    case _SC_THREAD_THREADS_MAX:  return SYSTEM_THREAD_THREADS_MAX;
-    case _SC_TTY_NAME_MAX:        return SYSTEM_TTY_NAME_MAX;
-#ifdef _POSIX_THREADS
-    case _SC_THREADS:             return _POSIX_THREADS;
-#endif
-#ifdef _POSIX_THREAD_ATTR_STACKADDR
-    case _SC_THREAD_ATTR_STACKADDR:   return _POSIX_THREAD_ATTR_STACKADDR;
-#endif
-#ifdef _POSIX_THREAD_ATTR_STACKSIZE
-    case _SC_THREAD_ATTR_STACKSIZE:   return _POSIX_THREAD_ATTR_STACKSIZE;
-#endif
-#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
-    case _SC_THREAD_PRIORITY_SCHEDULING:  return _POSIX_THREAD_PRIORITY_SCHEDULING;
-#endif
-#ifdef _POSIX_THREAD_PRIO_INHERIT
-    case _SC_THREAD_PRIO_INHERIT:         return _POSIX_THREAD_PRIO_INHERIT;
-#endif
-#ifdef _POSIX_THREAD_PRIO_PROTECT
-    case _SC_THREAD_PRIO_PROTECT: return _POSIX_THREAD_PRIO_PROTECT;
-#endif
-#ifdef _POSIX_THREAD_SAFE_FUNCTIONS
-    case _SC_THREAD_SAFE_FUNCTIONS:  return _POSIX_THREAD_SAFE_FUNCTIONS
-#endif
-
-
-    case _SC_NPROCESSORS_CONF:  return __get_nproc_conf();
-    case _SC_NPROCESSORS_ONLN:  return __get_nproc_onln();
-    case _SC_PHYS_PAGES:        return __get_phys_pages();
-    case _SC_AVPHYS_PAGES:      return __get_avphys_pages();
-
-    default:
-       /* Posix says EINVAL is the only error that shall be returned,
-        * but GLibc uses ENOSYS */
-        errno = ENOSYS;
-        return -1;
-    }
-}
diff --git a/libc/unistd/syslog.c b/libc/unistd/syslog.c
index 3571d59..7878475 100644
--- a/libc/unistd/syslog.c
+++ b/libc/unistd/syslog.c
@@ -46,7 +46,7 @@
 
 static struct syslog_data sdata = SYSLOG_DATA_INIT;
 
-extern char	*__progname;		/* Program name, from crt0. */
+extern const char	*__progname;		/* Program name, from crt0. */
 
 static void	disconnectlog_r(struct syslog_data *);	/* disconnect from syslogd */
 static void	connectlog_r(struct syslog_data *);	/* (re)connect to syslogd */
diff --git a/libc/upstream-freebsd/README.txt b/libc/upstream-freebsd/README.txt
new file mode 100644
index 0000000..fbfc04a
--- /dev/null
+++ b/libc/upstream-freebsd/README.txt
@@ -0,0 +1,5 @@
+This directory contains upstream FreeBSD source. You should not edit these
+files directly. Make fixes upstream and then pull down the new version of
+the file.
+
+TODO: write a script to make this process automated.
diff --git a/libc/upstream-freebsd/freebsd-compat.h b/libc/upstream-freebsd/freebsd-compat.h
new file mode 100644
index 0000000..08dec15
--- /dev/null
+++ b/libc/upstream-freebsd/freebsd-compat.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _BIONIC_FREEBSD_COMPAT_H_included
+#define _BIONIC_FREEBSD_COMPAT_H_included
+
+#endif
diff --git a/libc/upstream-freebsd/lib/libc/stdlib/realpath.c b/libc/upstream-freebsd/lib/libc/stdlib/realpath.c
new file mode 100644
index 0000000..8fd5457
--- /dev/null
+++ b/libc/upstream-freebsd/lib/libc/stdlib/realpath.c
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 2003 Constantin S. Svintsoff <kostik@iclub.nsu.ru>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ *    products derived from this software without specific prior written
+ *    permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)realpath.c	8.1 (Berkeley) 2/16/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "namespace.h"
+#include <sys/param.h>
+#include <sys/stat.h>
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include "un-namespace.h"
+
+/*
+ * Find the real name of path, by removing all ".", ".." and symlink
+ * components.  Returns (resolved) on success, or (NULL) on failure,
+ * in which case the path which caused trouble is left in (resolved).
+ */
+char *
+realpath(const char * __restrict path, char * __restrict resolved)
+{
+	struct stat sb;
+	char *p, *q, *s;
+	size_t left_len, resolved_len;
+	unsigned symlinks;
+	int m, slen;
+	char left[PATH_MAX], next_token[PATH_MAX], symlink[PATH_MAX];
+
+	if (path == NULL) {
+		errno = EINVAL;
+		return (NULL);
+	}
+	if (path[0] == '\0') {
+		errno = ENOENT;
+		return (NULL);
+	}
+	if (resolved == NULL) {
+		resolved = malloc(PATH_MAX);
+		if (resolved == NULL)
+			return (NULL);
+		m = 1;
+	} else
+		m = 0;
+	symlinks = 0;
+	if (path[0] == '/') {
+		resolved[0] = '/';
+		resolved[1] = '\0';
+		if (path[1] == '\0')
+			return (resolved);
+		resolved_len = 1;
+		left_len = strlcpy(left, path + 1, sizeof(left));
+	} else {
+		if (getcwd(resolved, PATH_MAX) == NULL) {
+			if (m)
+				free(resolved);
+			else {
+				resolved[0] = '.';
+				resolved[1] = '\0';
+			}
+			return (NULL);
+		}
+		resolved_len = strlen(resolved);
+		left_len = strlcpy(left, path, sizeof(left));
+	}
+	if (left_len >= sizeof(left) || resolved_len >= PATH_MAX) {
+		if (m)
+			free(resolved);
+		errno = ENAMETOOLONG;
+		return (NULL);
+	}
+
+	/*
+	 * Iterate over path components in `left'.
+	 */
+	while (left_len != 0) {
+		/*
+		 * Extract the next path component and adjust `left'
+		 * and its length.
+		 */
+		p = strchr(left, '/');
+		s = p ? p : left + left_len;
+		if (s - left >= sizeof(next_token)) {
+			if (m)
+				free(resolved);
+			errno = ENAMETOOLONG;
+			return (NULL);
+		}
+		memcpy(next_token, left, s - left);
+		next_token[s - left] = '\0';
+		left_len -= s - left;
+		if (p != NULL)
+			memmove(left, s + 1, left_len + 1);
+		if (resolved[resolved_len - 1] != '/') {
+			if (resolved_len + 1 >= PATH_MAX) {
+				if (m)
+					free(resolved);
+				errno = ENAMETOOLONG;
+				return (NULL);
+			}
+			resolved[resolved_len++] = '/';
+			resolved[resolved_len] = '\0';
+		}
+		if (next_token[0] == '\0') {
+			/*
+			 * Handle consequential slashes.  The path
+			 * before slash shall point to a directory.
+			 *
+			 * Only the trailing slashes are not covered
+			 * by other checks in the loop, but we verify
+			 * the prefix for any (rare) "//" or "/\0"
+			 * occurence to not implement lookahead.
+			 */
+			if (lstat(resolved, &sb) != 0) {
+				if (m)
+					free(resolved);
+				return (NULL);
+			}
+			if (!S_ISDIR(sb.st_mode)) {
+				if (m)
+					free(resolved);
+				errno = ENOTDIR;
+				return (NULL);
+			}
+			continue;
+		}
+		else if (strcmp(next_token, ".") == 0)
+			continue;
+		else if (strcmp(next_token, "..") == 0) {
+			/*
+			 * Strip the last path component except when we have
+			 * single "/"
+			 */
+			if (resolved_len > 1) {
+				resolved[resolved_len - 1] = '\0';
+				q = strrchr(resolved, '/') + 1;
+				*q = '\0';
+				resolved_len = q - resolved;
+			}
+			continue;
+		}
+
+		/*
+		 * Append the next path component and lstat() it.
+		 */
+		resolved_len = strlcat(resolved, next_token, PATH_MAX);
+		if (resolved_len >= PATH_MAX) {
+			if (m)
+				free(resolved);
+			errno = ENAMETOOLONG;
+			return (NULL);
+		}
+		if (lstat(resolved, &sb) != 0) {
+			if (m)
+				free(resolved);
+			return (NULL);
+		}
+		if (S_ISLNK(sb.st_mode)) {
+			if (symlinks++ > MAXSYMLINKS) {
+				if (m)
+					free(resolved);
+				errno = ELOOP;
+				return (NULL);
+			}
+			slen = readlink(resolved, symlink, sizeof(symlink) - 1);
+			if (slen < 0) {
+				if (m)
+					free(resolved);
+				return (NULL);
+			}
+			symlink[slen] = '\0';
+			if (symlink[0] == '/') {
+				resolved[1] = 0;
+				resolved_len = 1;
+			} else if (resolved_len > 1) {
+				/* Strip the last path component. */
+				resolved[resolved_len - 1] = '\0';
+				q = strrchr(resolved, '/') + 1;
+				*q = '\0';
+				resolved_len = q - resolved;
+			}
+
+			/*
+			 * If there are any path components left, then
+			 * append them to symlink. The result is placed
+			 * in `left'.
+			 */
+			if (p != NULL) {
+				if (symlink[slen - 1] != '/') {
+					if (slen + 1 >= sizeof(symlink)) {
+						if (m)
+							free(resolved);
+						errno = ENAMETOOLONG;
+						return (NULL);
+					}
+					symlink[slen] = '/';
+					symlink[slen + 1] = 0;
+				}
+				left_len = strlcat(symlink, left,
+				    sizeof(symlink));
+				if (left_len >= sizeof(left)) {
+					if (m)
+						free(resolved);
+					errno = ENAMETOOLONG;
+					return (NULL);
+				}
+			}
+			left_len = strlcpy(left, symlink, sizeof(left));
+		}
+	}
+
+	/*
+	 * Remove trailing slash except when the resolved pathname
+	 * is a single "/".
+	 */
+	if (resolved_len > 1 && resolved[resolved_len - 1] == '/')
+		resolved[resolved_len - 1] = '\0';
+	return (resolved);
+}
diff --git a/libc/wchar/wcpcpy.c b/libc/upstream-freebsd/lib/libc/string/wcpcpy.c
similarity index 100%
rename from libc/wchar/wcpcpy.c
rename to libc/upstream-freebsd/lib/libc/string/wcpcpy.c
diff --git a/libc/wchar/wcpncpy.c b/libc/upstream-freebsd/lib/libc/string/wcpncpy.c
similarity index 100%
rename from libc/wchar/wcpncpy.c
rename to libc/upstream-freebsd/lib/libc/string/wcpncpy.c
diff --git a/libc/wchar/wcscasecmp.c b/libc/upstream-freebsd/lib/libc/string/wcscasecmp.c
similarity index 100%
rename from libc/wchar/wcscasecmp.c
rename to libc/upstream-freebsd/lib/libc/string/wcscasecmp.c
diff --git a/libc/wchar/wcscat.c b/libc/upstream-freebsd/lib/libc/string/wcscat.c
similarity index 100%
rename from libc/wchar/wcscat.c
rename to libc/upstream-freebsd/lib/libc/string/wcscat.c
diff --git a/libc/wchar/wcschr.c b/libc/upstream-freebsd/lib/libc/string/wcschr.c
similarity index 100%
rename from libc/wchar/wcschr.c
rename to libc/upstream-freebsd/lib/libc/string/wcschr.c
diff --git a/libc/wchar/wcscmp.c b/libc/upstream-freebsd/lib/libc/string/wcscmp.c
similarity index 100%
rename from libc/wchar/wcscmp.c
rename to libc/upstream-freebsd/lib/libc/string/wcscmp.c
diff --git a/libc/wchar/wcscpy.c b/libc/upstream-freebsd/lib/libc/string/wcscpy.c
similarity index 100%
rename from libc/wchar/wcscpy.c
rename to libc/upstream-freebsd/lib/libc/string/wcscpy.c
diff --git a/libc/wchar/wcscspn.c b/libc/upstream-freebsd/lib/libc/string/wcscspn.c
similarity index 100%
rename from libc/wchar/wcscspn.c
rename to libc/upstream-freebsd/lib/libc/string/wcscspn.c
diff --git a/libc/wchar/wcsdup.c b/libc/upstream-freebsd/lib/libc/string/wcsdup.c
similarity index 100%
rename from libc/wchar/wcsdup.c
rename to libc/upstream-freebsd/lib/libc/string/wcsdup.c
diff --git a/libc/wchar/wcslcat.c b/libc/upstream-freebsd/lib/libc/string/wcslcat.c
similarity index 100%
rename from libc/wchar/wcslcat.c
rename to libc/upstream-freebsd/lib/libc/string/wcslcat.c
diff --git a/libc/wchar/wcslcpy.c b/libc/upstream-freebsd/lib/libc/string/wcslcpy.c
similarity index 100%
rename from libc/wchar/wcslcpy.c
rename to libc/upstream-freebsd/lib/libc/string/wcslcpy.c
diff --git a/libc/wchar/wcslen.c b/libc/upstream-freebsd/lib/libc/string/wcslen.c
similarity index 100%
rename from libc/wchar/wcslen.c
rename to libc/upstream-freebsd/lib/libc/string/wcslen.c
diff --git a/libc/wchar/wcsncasecmp.c b/libc/upstream-freebsd/lib/libc/string/wcsncasecmp.c
similarity index 100%
rename from libc/wchar/wcsncasecmp.c
rename to libc/upstream-freebsd/lib/libc/string/wcsncasecmp.c
diff --git a/libc/wchar/wcsncat.c b/libc/upstream-freebsd/lib/libc/string/wcsncat.c
similarity index 100%
rename from libc/wchar/wcsncat.c
rename to libc/upstream-freebsd/lib/libc/string/wcsncat.c
diff --git a/libc/wchar/wcsncmp.c b/libc/upstream-freebsd/lib/libc/string/wcsncmp.c
similarity index 100%
rename from libc/wchar/wcsncmp.c
rename to libc/upstream-freebsd/lib/libc/string/wcsncmp.c
diff --git a/libc/wchar/wcsncpy.c b/libc/upstream-freebsd/lib/libc/string/wcsncpy.c
similarity index 100%
rename from libc/wchar/wcsncpy.c
rename to libc/upstream-freebsd/lib/libc/string/wcsncpy.c
diff --git a/libc/wchar/wcsnlen.c b/libc/upstream-freebsd/lib/libc/string/wcsnlen.c
similarity index 100%
rename from libc/wchar/wcsnlen.c
rename to libc/upstream-freebsd/lib/libc/string/wcsnlen.c
diff --git a/libc/wchar/wcspbrk.c b/libc/upstream-freebsd/lib/libc/string/wcspbrk.c
similarity index 100%
rename from libc/wchar/wcspbrk.c
rename to libc/upstream-freebsd/lib/libc/string/wcspbrk.c
diff --git a/libc/wchar/wcsrchr.c b/libc/upstream-freebsd/lib/libc/string/wcsrchr.c
similarity index 100%
rename from libc/wchar/wcsrchr.c
rename to libc/upstream-freebsd/lib/libc/string/wcsrchr.c
diff --git a/libc/wchar/wcsspn.c b/libc/upstream-freebsd/lib/libc/string/wcsspn.c
similarity index 100%
rename from libc/wchar/wcsspn.c
rename to libc/upstream-freebsd/lib/libc/string/wcsspn.c
diff --git a/libc/wchar/wcsstr.c b/libc/upstream-freebsd/lib/libc/string/wcsstr.c
similarity index 100%
rename from libc/wchar/wcsstr.c
rename to libc/upstream-freebsd/lib/libc/string/wcsstr.c
diff --git a/libc/wchar/wcstok.c b/libc/upstream-freebsd/lib/libc/string/wcstok.c
similarity index 100%
rename from libc/wchar/wcstok.c
rename to libc/upstream-freebsd/lib/libc/string/wcstok.c
diff --git a/libc/wchar/wmemchr.c b/libc/upstream-freebsd/lib/libc/string/wmemchr.c
similarity index 100%
rename from libc/wchar/wmemchr.c
rename to libc/upstream-freebsd/lib/libc/string/wmemchr.c
diff --git a/libc/wchar/wmemcmp.c b/libc/upstream-freebsd/lib/libc/string/wmemcmp.c
similarity index 100%
rename from libc/wchar/wmemcmp.c
rename to libc/upstream-freebsd/lib/libc/string/wmemcmp.c
diff --git a/libc/wchar/wmemcpy.c b/libc/upstream-freebsd/lib/libc/string/wmemcpy.c
similarity index 100%
rename from libc/wchar/wmemcpy.c
rename to libc/upstream-freebsd/lib/libc/string/wmemcpy.c
diff --git a/libc/wchar/wmemmove.c b/libc/upstream-freebsd/lib/libc/string/wmemmove.c
similarity index 100%
rename from libc/wchar/wmemmove.c
rename to libc/upstream-freebsd/lib/libc/string/wmemmove.c
diff --git a/libc/wchar/wmemset.c b/libc/upstream-freebsd/lib/libc/string/wmemset.c
similarity index 100%
rename from libc/wchar/wmemset.c
rename to libc/upstream-freebsd/lib/libc/string/wmemset.c
diff --git a/libc/upstream-freebsd/namespace.h b/libc/upstream-freebsd/namespace.h
new file mode 100644
index 0000000..a3f850e
--- /dev/null
+++ b/libc/upstream-freebsd/namespace.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _BIONIC_FREEBSD_NAMESPACE_H_included
+#define _BIONIC_FREEBSD_NAMESPACE_H_included
+
+#endif
diff --git a/libc/upstream-freebsd/un-namespace.h b/libc/upstream-freebsd/un-namespace.h
new file mode 100644
index 0000000..a3f850e
--- /dev/null
+++ b/libc/upstream-freebsd/un-namespace.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _BIONIC_FREEBSD_NAMESPACE_H_included
+#define _BIONIC_FREEBSD_NAMESPACE_H_included
+
+#endif
diff --git a/libc/upstream-netbsd/common/lib/libc/hash/sha1/sha1.c b/libc/upstream-netbsd/common/lib/libc/hash/sha1/sha1.c
new file mode 100644
index 0000000..cbd60fc
--- /dev/null
+++ b/libc/upstream-netbsd/common/lib/libc/hash/sha1/sha1.c
@@ -0,0 +1,289 @@
+/*	$NetBSD: sha1.c,v 1.6 2009/11/06 20:31:18 joerg Exp $	*/
+/*	$OpenBSD: sha1.c,v 1.9 1997/07/23 21:12:32 kstailey Exp $	*/
+
+/*
+ * SHA-1 in C
+ * By Steve Reid <steve@edmweb.com>
+ * 100% Public Domain
+ *
+ * Test Vectors (from FIPS PUB 180-1)
+ * "abc"
+ *   A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
+ * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ *   84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
+ * A million repetitions of "a"
+ *   34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
+ */
+
+#define SHA1HANDSOFF		/* Copies data before messing with it. */
+
+#include <sys/cdefs.h>
+
+#if defined(_KERNEL) || defined(_STANDALONE)
+__KERNEL_RCSID(0, "$NetBSD: sha1.c,v 1.6 2009/11/06 20:31:18 joerg Exp $");
+
+#include <lib/libkern/libkern.h>
+
+#else
+
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: sha1.c,v 1.6 2009/11/06 20:31:18 joerg Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+#include <assert.h>
+#include <string.h>
+
+#endif
+
+#include <sys/types.h>
+#include <sys/sha1.h>
+
+
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
+#if !HAVE_SHA1_H
+
+#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
+
+/*
+ * blk0() and blk() perform the initial expand.
+ * I got the idea of expanding during the round function from SSLeay
+ */
+#if BYTE_ORDER == LITTLE_ENDIAN
+# define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
+    |(rol(block->l[i],8)&0x00FF00FF))
+#else
+# define blk0(i) block->l[i]
+#endif
+#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
+    ^block->l[(i+2)&15]^block->l[i&15],1))
+
+/*
+ * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1
+ */
+#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
+#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
+#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
+
+
+#if !defined(_KERNEL) && !defined(_STANDALONE)
+#if defined(__weak_alias)
+__weak_alias(SHA1Transform,_SHA1Transform)
+__weak_alias(SHA1Init,_SHA1Init)
+__weak_alias(SHA1Update,_SHA1Update)
+__weak_alias(SHA1Final,_SHA1Final)
+#endif
+#endif
+
+typedef union {
+    uint8_t c[64];
+    uint32_t l[16];
+} CHAR64LONG16;
+
+/* old sparc64 gcc could not compile this */
+#undef SPARC64_GCC_WORKAROUND
+#if defined(__sparc64__) && defined(__GNUC__) && __GNUC__ < 3
+#define SPARC64_GCC_WORKAROUND
+#endif
+
+#ifdef SPARC64_GCC_WORKAROUND
+void do_R01(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *);
+void do_R2(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *);
+void do_R3(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *);
+void do_R4(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *);
+
+#define nR0(v,w,x,y,z,i) R0(*v,*w,*x,*y,*z,i)
+#define nR1(v,w,x,y,z,i) R1(*v,*w,*x,*y,*z,i)
+#define nR2(v,w,x,y,z,i) R2(*v,*w,*x,*y,*z,i)
+#define nR3(v,w,x,y,z,i) R3(*v,*w,*x,*y,*z,i)
+#define nR4(v,w,x,y,z,i) R4(*v,*w,*x,*y,*z,i)
+
+void
+do_R01(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
+{
+    nR0(a,b,c,d,e, 0); nR0(e,a,b,c,d, 1); nR0(d,e,a,b,c, 2); nR0(c,d,e,a,b, 3);
+    nR0(b,c,d,e,a, 4); nR0(a,b,c,d,e, 5); nR0(e,a,b,c,d, 6); nR0(d,e,a,b,c, 7);
+    nR0(c,d,e,a,b, 8); nR0(b,c,d,e,a, 9); nR0(a,b,c,d,e,10); nR0(e,a,b,c,d,11);
+    nR0(d,e,a,b,c,12); nR0(c,d,e,a,b,13); nR0(b,c,d,e,a,14); nR0(a,b,c,d,e,15);
+    nR1(e,a,b,c,d,16); nR1(d,e,a,b,c,17); nR1(c,d,e,a,b,18); nR1(b,c,d,e,a,19);
+}
+
+void
+do_R2(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
+{
+    nR2(a,b,c,d,e,20); nR2(e,a,b,c,d,21); nR2(d,e,a,b,c,22); nR2(c,d,e,a,b,23);
+    nR2(b,c,d,e,a,24); nR2(a,b,c,d,e,25); nR2(e,a,b,c,d,26); nR2(d,e,a,b,c,27);
+    nR2(c,d,e,a,b,28); nR2(b,c,d,e,a,29); nR2(a,b,c,d,e,30); nR2(e,a,b,c,d,31);
+    nR2(d,e,a,b,c,32); nR2(c,d,e,a,b,33); nR2(b,c,d,e,a,34); nR2(a,b,c,d,e,35);
+    nR2(e,a,b,c,d,36); nR2(d,e,a,b,c,37); nR2(c,d,e,a,b,38); nR2(b,c,d,e,a,39);
+}
+
+void
+do_R3(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
+{
+    nR3(a,b,c,d,e,40); nR3(e,a,b,c,d,41); nR3(d,e,a,b,c,42); nR3(c,d,e,a,b,43);
+    nR3(b,c,d,e,a,44); nR3(a,b,c,d,e,45); nR3(e,a,b,c,d,46); nR3(d,e,a,b,c,47);
+    nR3(c,d,e,a,b,48); nR3(b,c,d,e,a,49); nR3(a,b,c,d,e,50); nR3(e,a,b,c,d,51);
+    nR3(d,e,a,b,c,52); nR3(c,d,e,a,b,53); nR3(b,c,d,e,a,54); nR3(a,b,c,d,e,55);
+    nR3(e,a,b,c,d,56); nR3(d,e,a,b,c,57); nR3(c,d,e,a,b,58); nR3(b,c,d,e,a,59);
+}
+
+void
+do_R4(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
+{
+    nR4(a,b,c,d,e,60); nR4(e,a,b,c,d,61); nR4(d,e,a,b,c,62); nR4(c,d,e,a,b,63);
+    nR4(b,c,d,e,a,64); nR4(a,b,c,d,e,65); nR4(e,a,b,c,d,66); nR4(d,e,a,b,c,67);
+    nR4(c,d,e,a,b,68); nR4(b,c,d,e,a,69); nR4(a,b,c,d,e,70); nR4(e,a,b,c,d,71);
+    nR4(d,e,a,b,c,72); nR4(c,d,e,a,b,73); nR4(b,c,d,e,a,74); nR4(a,b,c,d,e,75);
+    nR4(e,a,b,c,d,76); nR4(d,e,a,b,c,77); nR4(c,d,e,a,b,78); nR4(b,c,d,e,a,79);
+}
+#endif
+
+/*
+ * Hash a single 512-bit block. This is the core of the algorithm.
+ */
+void SHA1Transform(uint32_t state[5], const uint8_t buffer[64])
+{
+    uint32_t a, b, c, d, e;
+    CHAR64LONG16 *block;
+
+#ifdef SHA1HANDSOFF
+    CHAR64LONG16 workspace;
+#endif
+
+    _DIAGASSERT(buffer != 0);
+    _DIAGASSERT(state != 0);
+
+#ifdef SHA1HANDSOFF
+    block = &workspace;
+    (void)memcpy(block, buffer, 64);
+#else
+    block = (CHAR64LONG16 *)(void *)buffer;
+#endif
+
+    /* Copy context->state[] to working vars */
+    a = state[0];
+    b = state[1];
+    c = state[2];
+    d = state[3];
+    e = state[4];
+
+#ifdef SPARC64_GCC_WORKAROUND
+    do_R01(&a, &b, &c, &d, &e, block);
+    do_R2(&a, &b, &c, &d, &e, block);
+    do_R3(&a, &b, &c, &d, &e, block);
+    do_R4(&a, &b, &c, &d, &e, block);
+#else
+    /* 4 rounds of 20 operations each. Loop unrolled. */
+    R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
+    R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
+    R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
+    R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
+    R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
+    R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
+    R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
+    R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
+    R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
+    R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
+    R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
+    R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
+    R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
+    R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
+    R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
+    R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
+    R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
+    R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
+    R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
+    R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
+#endif
+
+    /* Add the working vars back into context.state[] */
+    state[0] += a;
+    state[1] += b;
+    state[2] += c;
+    state[3] += d;
+    state[4] += e;
+
+    /* Wipe variables */
+    a = b = c = d = e = 0;
+}
+
+
+/*
+ * SHA1Init - Initialize new context
+ */
+void SHA1Init(SHA1_CTX *context)
+{
+
+    _DIAGASSERT(context != 0);
+
+    /* SHA1 initialization constants */
+    context->state[0] = 0x67452301;
+    context->state[1] = 0xEFCDAB89;
+    context->state[2] = 0x98BADCFE;
+    context->state[3] = 0x10325476;
+    context->state[4] = 0xC3D2E1F0;
+    context->count[0] = context->count[1] = 0;
+}
+
+
+/*
+ * Run your data through this.
+ */
+void SHA1Update(SHA1_CTX *context, const uint8_t *data, unsigned int len)
+{
+    unsigned int i, j;
+
+    _DIAGASSERT(context != 0);
+    _DIAGASSERT(data != 0);
+
+    j = context->count[0];
+    if ((context->count[0] += len << 3) < j)
+	context->count[1] += (len>>29)+1;
+    j = (j >> 3) & 63;
+    if ((j + len) > 63) {
+	(void)memcpy(&context->buffer[j], data, (i = 64-j));
+	SHA1Transform(context->state, context->buffer);
+	for ( ; i + 63 < len; i += 64)
+	    SHA1Transform(context->state, &data[i]);
+	j = 0;
+    } else {
+	i = 0;
+    }
+    (void)memcpy(&context->buffer[j], &data[i], len - i);
+}
+
+
+/*
+ * Add padding and return the message digest.
+ */
+void SHA1Final(uint8_t digest[20], SHA1_CTX *context)
+{
+    unsigned int i;
+    uint8_t finalcount[8];
+
+    _DIAGASSERT(digest != 0);
+    _DIAGASSERT(context != 0);
+
+    for (i = 0; i < 8; i++) {
+	finalcount[i] = (uint8_t)((context->count[(i >= 4 ? 0 : 1)]
+	 >> ((3-(i & 3)) * 8) ) & 255);	 /* Endian independent */
+    }
+    SHA1Update(context, (const uint8_t *)"\200", 1);
+    while ((context->count[0] & 504) != 448)
+	SHA1Update(context, (const uint8_t *)"\0", 1);
+    SHA1Update(context, finalcount, 8);  /* Should cause a SHA1Transform() */
+
+    if (digest) {
+	for (i = 0; i < 20; i++)
+	    digest[i] = (uint8_t)
+		((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
+    }
+}
+
+#endif /* HAVE_SHA1_H */
diff --git a/libc/upstream-netbsd/common/lib/libc/inet/inet_addr.c b/libc/upstream-netbsd/common/lib/libc/inet/inet_addr.c
new file mode 100644
index 0000000..1360ce9
--- /dev/null
+++ b/libc/upstream-netbsd/common/lib/libc/inet/inet_addr.c
@@ -0,0 +1,224 @@
+/*	$NetBSD: inet_addr.c,v 1.3 2012/03/09 15:41:16 christos Exp $	*/
+
+/*
+ * Copyright (c) 1983, 1990, 1993
+ *    The Regents of the University of California.  All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ * 	This product includes software developed by the University of
+ * 	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Portions Copyright (c) 1993 by Digital Equipment Corporation.
+ * 
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies, and that
+ * the name of Digital Equipment Corporation not be used in advertising or
+ * publicity pertaining to distribution of the document or software without
+ * specific, written prior permission.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
+ * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/*
+ * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
+ * Portions Copyright (c) 1996-1999 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#if !defined(_KERNEL) && !defined(_STANDALONE)
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static const char sccsid[] = "@(#)inet_addr.c	8.1 (Berkeley) 6/17/93";
+static const char rcsid[] = "Id: inet_addr.c,v 1.2.206.2 2004/03/17 00:29:45 marka Exp";
+#else
+__RCSID("$NetBSD: inet_addr.c,v 1.3 2012/03/09 15:41:16 christos Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#include "port_before.h"
+
+#include "namespace.h"
+#include <sys/types.h>
+#include <sys/param.h>
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <ctype.h>
+
+#include "port_after.h"
+
+#ifdef __weak_alias
+__weak_alias(inet_aton,_inet_aton)
+#endif
+#else
+#include <lib/libkern/libkern.h>
+#include <netinet/in.h>
+#endif
+
+/*
+ * Ascii internet address interpretation routine.
+ * The value returned is in network order.
+ */
+uint32_t
+inet_addr(const char *cp) {
+	struct in_addr val;
+
+	if (inet_aton(cp, &val))
+		return (val.s_addr);
+	return (INADDR_NONE);
+}
+
+/* 
+ * Check whether "cp" is a valid ascii representation
+ * of an Internet address and convert to a binary address.
+ * Returns 1 if the address is valid, 0 if not.
+ * This replaces inet_addr, the return value from which
+ * cannot distinguish between failure and a local broadcast address.
+ */
+int
+inet_aton(const char *cp, struct in_addr *addr) {
+	uint32_t val;
+	int base;
+	size_t n;
+	char c;
+	uint8_t parts[4];
+	uint8_t *pp = parts;
+	int digit;
+
+	c = *cp;
+	for (;;) {
+		/*
+		 * Collect number up to ``.''.
+		 * Values are specified as for C:
+		 * 0x=hex, 0=octal, isdigit=decimal.
+		 */
+		if (!isdigit((unsigned char)c))
+			return (0);
+		val = 0; base = 10; digit = 0;
+		if (c == '0') {
+			c = *++cp;
+			if (c == 'x' || c == 'X')
+				base = 16, c = *++cp;
+			else {
+				base = 8;
+				digit = 1 ;
+			}
+		}
+		for (;;) {
+			if (isascii(c) && isdigit((unsigned char)c)) {
+				if (base == 8 && (c == '8' || c == '9'))
+					return (0);
+				val = (val * base) + (c - '0');
+				c = *++cp;
+				digit = 1;
+			} else if (base == 16 && isascii(c) && 
+				   isxdigit((unsigned char)c)) {
+				val = (val << 4) |
+					(c + 10 - (islower((unsigned char)c) ? 'a' : 'A'));
+				c = *++cp;
+				digit = 1;
+			} else
+				break;
+		}
+		if (c == '.') {
+			/*
+			 * Internet format:
+			 *	a.b.c.d
+			 *	a.b.c	(with c treated as 16 bits)
+			 *	a.b	(with b treated as 24 bits)
+			 */
+			if (pp >= parts + 3 || val > 0xffU)
+				return (0);
+			*pp++ = val;
+			c = *++cp;
+		} else
+			break;
+	}
+	/*
+	 * Check for trailing characters.
+	 */
+	if (c != '\0' && (!isascii(c) || !isspace((unsigned char)c)))
+		return (0);
+	/*
+	 * Did we get a valid digit?
+	 */
+	if (!digit)
+		return (0);
+	/*
+	 * Concoct the address according to
+	 * the number of parts specified.
+	 */
+	n = pp - parts + 1;
+	switch (n) {
+	case 1:				/* a -- 32 bits */
+		break;
+
+	case 2:				/* a.b -- 8.24 bits */
+		if (val > 0xffffffU)
+			return (0);
+		val |= parts[0] << 24;
+		break;
+
+	case 3:				/* a.b.c -- 8.8.16 bits */
+		if (val > 0xffffU)
+			return (0);
+		val |= (parts[0] << 24) | (parts[1] << 16);
+		break;
+
+	case 4:				/* a.b.c.d -- 8.8.8.8 bits */
+		if (val > 0xffU)
+			return (0);
+		val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
+		break;
+	}
+	if (addr != NULL)
+		addr->s_addr = htonl(val);
+	return (1);
+}
diff --git a/libc/upstream-netbsd/env.h b/libc/upstream-netbsd/env.h
new file mode 100644
index 0000000..8f99f9d
--- /dev/null
+++ b/libc/upstream-netbsd/env.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _BIONIC_NETBSD_ENV_H_included
+#define _BIONIC_NETBSD_ENV_H_included
+
+/* Placeholder. */
+
+#endif
diff --git a/libc/upstream-netbsd/extern.h b/libc/upstream-netbsd/extern.h
index 942e237..616becd 100644
--- a/libc/upstream-netbsd/extern.h
+++ b/libc/upstream-netbsd/extern.h
@@ -17,6 +17,12 @@
 #ifndef _BIONIC_NETBSD_EXTERN_H_included
 #define _BIONIC_NETBSD_EXTERN_H_included
 
-// Placeholder.
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+const char* __strsignal(int, char*, size_t);
+
+__END_DECLS
 
 #endif
diff --git a/libc/upstream-netbsd/fd_setsize.h b/libc/upstream-netbsd/fd_setsize.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/libc/upstream-netbsd/fd_setsize.h
diff --git a/libc/upstream-netbsd/libc/gen/popen.c b/libc/upstream-netbsd/libc/gen/popen.c
new file mode 100644
index 0000000..593e346
--- /dev/null
+++ b/libc/upstream-netbsd/libc/gen/popen.c
@@ -0,0 +1,227 @@
+/*	$NetBSD: popen.c,v 1.32 2012/06/25 22:32:43 abs Exp $	*/
+
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software written by Ken Arnold and
+ * published in UNIX Review, Vol. 6, No. 8.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)popen.c	8.3 (Berkeley) 5/3/95";
+#else
+__RCSID("$NetBSD: popen.c,v 1.32 2012/06/25 22:32:43 abs Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+#include <sys/param.h>
+#include <sys/wait.h>
+#include <sys/socket.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <paths.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include "env.h"
+#include "reentrant.h"
+
+#ifdef __weak_alias
+__weak_alias(popen,_popen)
+__weak_alias(pclose,_pclose)
+#endif
+
+static struct pid {
+	struct pid *next;
+	FILE *fp;
+#ifdef _REENTRANT
+	int fd;
+#endif
+	pid_t pid;
+} *pidlist; 
+	
+#ifdef _REENTRANT
+static rwlock_t pidlist_lock = RWLOCK_INITIALIZER;
+#endif
+
+FILE *
+popen(const char *command, const char *type)
+{
+	struct pid *cur, *old;
+	FILE *iop;
+	const char * volatile xtype = type;
+	int pdes[2], pid, serrno;
+	volatile int twoway;
+	int flags;
+
+	_DIAGASSERT(command != NULL);
+	_DIAGASSERT(xtype != NULL);
+
+	flags = strchr(xtype, 'e') ? O_CLOEXEC : 0;
+	if (strchr(xtype, '+')) {
+		int stype = flags ? (SOCK_STREAM | SOCK_CLOEXEC) : SOCK_STREAM;
+		twoway = 1;
+		xtype = "r+";
+		if (socketpair(AF_LOCAL, stype, 0, pdes) < 0)
+			return NULL;
+	} else  {
+		twoway = 0;
+		xtype = strrchr(xtype, 'r') ? "r" : "w";
+		if (pipe2(pdes, flags) == -1)
+			return NULL;
+	}
+
+	if ((cur = malloc(sizeof(struct pid))) == NULL) {
+		(void)close(pdes[0]);
+		(void)close(pdes[1]);
+		errno = ENOMEM;
+		return (NULL);
+	}
+
+	(void)rwlock_rdlock(&pidlist_lock);
+	(void)__readlockenv();
+	switch (pid = vfork()) {
+	case -1:			/* Error. */
+		serrno = errno;
+		(void)__unlockenv();
+		(void)rwlock_unlock(&pidlist_lock);
+		free(cur);
+		(void)close(pdes[0]);
+		(void)close(pdes[1]);
+		errno = serrno;
+		return (NULL);
+		/* NOTREACHED */
+	case 0:				/* Child. */
+		/* POSIX.2 B.3.2.2 "popen() shall ensure that any streams
+		   from previous popen() calls that remain open in the 
+		   parent process are closed in the new child process. */
+		for (old = pidlist; old; old = old->next)
+#ifdef _REENTRANT
+			close(old->fd); /* don't allow a flush */
+#else
+			close(fileno(old->fp)); /* don't allow a flush */
+#endif
+
+		if (*xtype == 'r') {
+			(void)close(pdes[0]);
+			if (pdes[1] != STDOUT_FILENO) {
+				(void)dup2(pdes[1], STDOUT_FILENO);
+				(void)close(pdes[1]);
+			}
+			if (twoway)
+				(void)dup2(STDOUT_FILENO, STDIN_FILENO);
+		} else {
+			(void)close(pdes[1]);
+			if (pdes[0] != STDIN_FILENO) {
+				(void)dup2(pdes[0], STDIN_FILENO);
+				(void)close(pdes[0]);
+			}
+		}
+
+		execl(_PATH_BSHELL, "sh", "-c", command, NULL);
+		_exit(127);
+		/* NOTREACHED */
+	}
+	(void)__unlockenv();
+
+	/* Parent; assume fdopen can't fail. */
+	if (*xtype == 'r') {
+		iop = fdopen(pdes[0], xtype);
+#ifdef _REENTRANT
+		cur->fd = pdes[0];
+#endif
+		(void)close(pdes[1]);
+	} else {
+		iop = fdopen(pdes[1], xtype);
+#ifdef _REENTRANT
+		cur->fd = pdes[1];
+#endif
+		(void)close(pdes[0]);
+	}
+
+	/* Link into list of file descriptors. */
+	cur->fp = iop;
+	cur->pid =  pid;
+	cur->next = pidlist;
+	pidlist = cur;
+	(void)rwlock_unlock(&pidlist_lock);
+
+	return (iop);
+}
+
+/*
+ * pclose --
+ *	Pclose returns -1 if stream is not associated with a `popened' command,
+ *	if already `pclosed', or waitpid returns an error.
+ */
+int
+pclose(FILE *iop)
+{
+	struct pid *cur, *last;
+	int pstat;
+	pid_t pid;
+
+	_DIAGASSERT(iop != NULL);
+
+	rwlock_wrlock(&pidlist_lock);
+
+	/* Find the appropriate file pointer. */
+	for (last = NULL, cur = pidlist; cur; last = cur, cur = cur->next)
+		if (cur->fp == iop)
+			break;
+	if (cur == NULL) {
+		(void)rwlock_unlock(&pidlist_lock);
+		return (-1);
+	}
+
+	(void)fclose(iop);
+
+	/* Remove the entry from the linked list. */
+	if (last == NULL)
+		pidlist = cur->next;
+	else
+		last->next = cur->next;
+
+	(void)rwlock_unlock(&pidlist_lock);
+
+	do {
+		pid = waitpid(cur->pid, &pstat, 0);
+	} while (pid == -1 && errno == EINTR);
+
+	free(cur);
+
+	return (pid == -1 ? -1 : pstat);
+}
diff --git a/libc/upstream-netbsd/libc/gen/setjmperr.c b/libc/upstream-netbsd/libc/gen/setjmperr.c
new file mode 100644
index 0000000..5b1432e
--- /dev/null
+++ b/libc/upstream-netbsd/libc/gen/setjmperr.c
@@ -0,0 +1,56 @@
+/*	$NetBSD: setjmperr.c,v 1.8 2012/06/24 15:26:03 christos Exp $	*/
+
+/*
+ * Copyright (c) 1980, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)setjmperr.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: setjmperr.c,v 1.8 2012/06/24 15:26:03 christos Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * This routine is called from longjmp() when an error occurs.
+ * Programs that wish to exit gracefully from this error may
+ * write their own versions.
+ * If this routine returns, the program is aborted.
+ */
+
+#include <setjmp.h>
+#include <unistd.h>
+
+void
+longjmperror(void)
+{
+#define	ERRMSG	"longjmp botch.\n"
+	(void)write(STDERR_FILENO, ERRMSG, sizeof(ERRMSG) - 1);
+}
diff --git a/libc/upstream-netbsd/libc/gen/utime.c b/libc/upstream-netbsd/libc/gen/utime.c
new file mode 100644
index 0000000..d41aac7
--- /dev/null
+++ b/libc/upstream-netbsd/libc/gen/utime.c
@@ -0,0 +1,65 @@
+/*	$NetBSD: utime.c,v 1.14 2012/06/25 22:32:44 abs Exp $	*/
+
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)utime.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: utime.c,v 1.14 2012/06/25 22:32:44 abs Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+#include <sys/time.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <stddef.h>
+#include <utime.h>
+
+int
+utime(const char *path, const struct utimbuf *times)
+{
+	struct timeval tv[2], *tvp;
+
+	_DIAGASSERT(path != NULL);
+
+	if (times == (struct utimbuf *) NULL)
+		tvp = NULL;
+	else {
+		tv[0].tv_sec = times->actime;
+		tv[1].tv_sec = times->modtime;
+		tv[0].tv_usec = tv[1].tv_usec = 0;
+		tvp = tv;
+	}
+	return (utimes(path, tvp));
+}
diff --git a/libc/upstream-netbsd/libc/include/isc/assertions.h b/libc/upstream-netbsd/libc/include/isc/assertions.h
new file mode 100644
index 0000000..7db7361
--- /dev/null
+++ b/libc/upstream-netbsd/libc/include/isc/assertions.h
@@ -0,0 +1,132 @@
+/*	$NetBSD: assertions.h,v 1.5 2009/04/12 17:07:16 christos Exp $	*/
+
+/*
+ * Copyright (C) 2004, 2005, 2008  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1997-2001  Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * Id: assertions.h,v 1.5 2008/11/14 02:36:51 marka Exp
+ */
+
+#ifndef ASSERTIONS_H
+#define ASSERTIONS_H		1
+
+typedef enum {
+	assert_require, assert_ensure, assert_insist, assert_invariant
+} assertion_type;
+
+typedef void (*assertion_failure_callback)(const char *, int, assertion_type,
+					   const char *, int);
+
+/* coverity[+kill] */
+extern assertion_failure_callback __assertion_failed;
+void set_assertion_failure_callback(assertion_failure_callback f);
+const char *assertion_type_to_text(assertion_type type);
+
+#if defined(CHECK_ALL) || defined(__COVERITY__)
+#define CHECK_REQUIRE		1
+#define CHECK_ENSURE		1
+#define CHECK_INSIST		1
+#define CHECK_INVARIANT		1
+#endif
+
+#if defined(CHECK_NONE) && !defined(__COVERITY__)
+#define CHECK_REQUIRE		0
+#define CHECK_ENSURE		0
+#define CHECK_INSIST		0
+#define CHECK_INVARIANT		0
+#endif
+
+#ifdef _DIAGNOSTIC
+#ifndef CHECK_REQUIRE
+#define CHECK_REQUIRE		1
+#endif
+
+#ifndef CHECK_ENSURE
+#define CHECK_ENSURE		1
+#endif
+
+#ifndef CHECK_INSIST
+#define CHECK_INSIST		1
+#endif
+
+#ifndef CHECK_INVARIANT
+#define CHECK_INVARIANT		1
+#endif
+#endif	/* _DIAGNOSTIC */
+
+#if CHECK_REQUIRE != 0
+#define REQUIRE(cond) \
+	((void) ((cond) || \
+		 ((__assertion_failed)(__FILE__, __LINE__, assert_require, \
+				       #cond, 0), 0)))
+#define REQUIRE_ERR(cond) \
+	((void) ((cond) || \
+		 ((__assertion_failed)(__FILE__, __LINE__, assert_require, \
+				       #cond, 1), 0)))
+#else
+#define REQUIRE(cond)		((void) (cond))
+#define REQUIRE_ERR(cond)	((void) (cond))
+#endif /* CHECK_REQUIRE */
+
+#if CHECK_ENSURE != 0
+#define ENSURE(cond) \
+	((void) ((cond) || \
+		 ((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \
+				       #cond, 0), 0)))
+#define ENSURE_ERR(cond) \
+	((void) ((cond) || \
+		 ((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \
+				       #cond, 1), 0)))
+#else
+#define ENSURE(cond)		((void) (cond))
+#define ENSURE_ERR(cond)	((void) (cond))
+#endif /* CHECK_ENSURE */
+
+#if CHECK_INSIST != 0
+#define INSIST(cond) \
+	((void) ((cond) || \
+		 ((__assertion_failed)(__FILE__, __LINE__, assert_insist, \
+				       #cond, 0), 0)))
+#define INSIST_ERR(cond) \
+	((void) ((cond) || \
+		 ((__assertion_failed)(__FILE__, __LINE__, assert_insist, \
+				       #cond, 1), 0)))
+#else
+#if !defined(__lint__)
+#define INSIST(cond)		((void) (cond))
+#define INSIST_ERR(cond)	((void) (cond))
+#else /* !__lint__ */
+#define INSIST(cond)
+#define INSIST_ERR(cond)
+#endif /* !__lint__ */
+#endif /* CHECK_INSIST */
+
+#if CHECK_INVARIANT != 0
+#define INVARIANT(cond) \
+	((void) ((cond) || \
+		 ((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \
+				       #cond, 0), 0)))
+#define INVARIANT_ERR(cond) \
+	((void) ((cond) || \
+		 ((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \
+				       #cond, 1), 0)))
+#else
+#define INVARIANT(cond)		((void) (cond))
+#define INVARIANT_ERR(cond)	((void) (cond))
+#endif /* CHECK_INVARIANT */
+#endif /* ASSERTIONS_H */
+/*! \file */
diff --git a/libc/upstream-netbsd/libc/include/isc/dst.h b/libc/upstream-netbsd/libc/include/isc/dst.h
new file mode 100644
index 0000000..5537e3d
--- /dev/null
+++ b/libc/upstream-netbsd/libc/include/isc/dst.h
@@ -0,0 +1,170 @@
+/*	$NetBSD: dst.h,v 1.1.1.4 2009/04/12 16:35:44 christos Exp $	*/
+
+#ifndef DST_H
+#define DST_H
+
+#ifndef HAS_DST_KEY
+typedef struct dst_key {
+	char	*dk_key_name;   /*%< name of the key */
+	int	dk_key_size;    /*%< this is the size of the key in bits */
+	int	dk_proto;       /*%< what protocols this key can be used for */
+	int	dk_alg;         /*%< algorithm number from key record */
+	u_int32_t dk_flags;     /*%< and the flags of the public key */
+	u_int16_t dk_id;        /*%< identifier of the key */
+} DST_KEY;
+#endif /* HAS_DST_KEY */
+/*
+ * do not taint namespace
+ */
+#define	dst_bsafe_init		__dst_bsafe_init
+#define	dst_buffer_to_key	__dst_buffer_to_key
+#define	dst_check_algorithm	__dst_check_algorithm
+#define	dst_compare_keys	__dst_compare_keys
+#define	dst_cylink_init		__dst_cylink_init
+#define	dst_dnskey_to_key	__dst_dnskey_to_key
+#define	dst_eay_dss_init	__dst_eay_dss_init
+#define	dst_free_key		__dst_free_key
+#define	dst_generate_key	__dst_generate_key
+#define	dst_hmac_md5_init	__dst_hmac_md5_init
+#define	dst_init		__dst_init
+#define	dst_key_to_buffer	__dst_key_to_buffer
+#define	dst_key_to_dnskey	__dst_key_to_dnskey
+#define	dst_read_key		__dst_read_key
+#define	dst_rsaref_init		__dst_rsaref_init
+#define	dst_s_build_filename	__dst_s_build_filename
+#define	dst_s_calculate_bits	__dst_s_calculate_bits
+#define	dst_s_conv_bignum_b64_to_u8	__dst_s_conv_bignum_b64_to_u8
+#define	dst_s_conv_bignum_u8_to_b64	__dst_s_conv_bignum_u8_to_b64
+#define	dst_s_dns_key_id	__dst_s_dns_key_id
+#define	dst_s_dump		__dst_s_dump
+#define	dst_s_filename_length	__dst_s_filename_length
+#define	dst_s_fopen		__dst_s_fopen
+#define	dst_s_get_int16		__dst_s_get_int16
+#define	dst_s_get_int32		__dst_s_get_int32
+#define	dst_s_id_calc		__dst_s_id_calc
+#define	dst_s_put_int16		__dst_s_put_int16
+#define	dst_s_put_int32		__dst_s_put_int32
+#define	dst_s_quick_random	__dst_s_quick_random
+#define	dst_s_quick_random_set	__dst_s_quick_random_set
+#define	dst_s_random		__dst_s_random
+#define	dst_s_semi_random	__dst_s_semi_random
+#define	dst_s_verify_str	__dst_s_verify_str
+#define	dst_sig_size		__dst_sig_size
+#define	dst_sign_data		__dst_sign_data
+#define	dst_verify_data		__dst_verify_data
+#define	dst_write_key		__dst_write_key
+
+/* 
+ * DST Crypto API defintions 
+ */
+void     dst_init(void);
+int      dst_check_algorithm(const int);
+
+
+int dst_sign_data(const int,	 	/*!<   specifies INIT/UPDATE/FINAL/ALL  */
+		  DST_KEY *,	 	/*!<   the key to use  */
+		  void **,	 	/*!<   pointer to state structure  */
+		  const u_char *,	/*!<   data to be signed  */
+		  const int,	 	/*!<   length of input data  */
+		  u_char *,	 	/*!<   buffer to write signature to  */
+		  const int);	 	/*!<   size of output buffer  */
+int dst_verify_data(const int,	 	/*!<   specifies INIT/UPDATE/FINAL/ALL  */
+		    DST_KEY *,	 	/*!<   the key to use  */
+		    void **,	 	/*!<   pointer to state structure  */
+		    const u_char *,	/*!<   data to be verified  */
+		    const int,	 	/*!<   length of input data  */
+		    const u_char *,	/*!<   buffer containing signature  */
+		    const int);	 	/*!<   length of signature  */
+DST_KEY *dst_read_key(const char *,	/*!<   name of key  */
+		      const u_int16_t,	/*!<   key tag identifier  */
+		      const int,	/*!<   key algorithm  */
+		      const int);	/*!<   Private/PublicKey wanted */
+int      dst_write_key(const DST_KEY *,	/*!<   key to write out  */
+		       const int); 	/*!<   Public/Private  */
+DST_KEY *dst_dnskey_to_key(const char *,	/*!<   KEY record name  */
+			   const u_char *,	/*!<   KEY RDATA  */
+			   const int);		/*!<   size of input buffer */
+int      dst_key_to_dnskey(const DST_KEY *,	/*!<   key to translate  */
+			   u_char *,		/*!<   output buffer  */
+			   const int);		/*!<   size of out_storage */
+DST_KEY *dst_buffer_to_key(const char *,  	/*!<   name of the key  */
+			   const int,	  	/*!<   algorithm  */
+			   const int,	  	/*!<   dns flags  */
+			   const int,	  	/*!<   dns protocol  */
+			   const u_char *, 	/*!<   key in dns wire fmt  */
+			   const int);	  	/*!<   size of key  */
+int     dst_key_to_buffer(DST_KEY *, u_char *, int);
+
+DST_KEY *dst_generate_key(const char *,    	/*!<   name of new key  */
+			  const int,       	/*!<   key algorithm to generate  */
+			  const int,      	/*!<   size of new key  */
+			  const int,       	/*!<   alg dependent parameter */
+			  const int,     	/*!<   key DNS flags  */
+			  const int);		/*!<   key DNS protocol  */
+DST_KEY *dst_free_key(DST_KEY *);
+int      dst_compare_keys(const DST_KEY *, const DST_KEY *);
+
+int	dst_sig_size(DST_KEY *);
+
+
+/* support for dns key tags/ids */
+u_int16_t dst_s_dns_key_id(const u_char *, const int);
+u_int16_t dst_s_id_calc(const u_char *, const int);
+
+/* Used by callers as well as by the library.  */
+#define RAW_KEY_SIZE    8192        /*%< large enough to store any key */
+/* DST_API control flags */
+/* These are used used in functions dst_sign_data and dst_verify_data */
+#define SIG_MODE_INIT		1  /*%< initialize digest */
+#define SIG_MODE_UPDATE		2  /*%< add data to digest */
+#define SIG_MODE_FINAL		4  /*%< generate/verify signature */
+#define SIG_MODE_ALL		(SIG_MODE_INIT|SIG_MODE_UPDATE|SIG_MODE_FINAL)
+
+/* Flags for dst_read_private_key()  */
+#define DST_FORCE_READ		0x1000000
+#define DST_CAN_SIGN		0x010F
+#define DST_NO_AUTHEN		0x8000
+#define DST_EXTEND_FLAG         0x1000
+#define DST_STANDARD		0
+#define DST_PRIVATE             0x2000000
+#define DST_PUBLIC              0x4000000
+#define DST_RAND_SEMI           1
+#define DST_RAND_STD            2
+#define DST_RAND_KEY            3
+#define DST_RAND_DSS            4
+
+
+/* DST algorithm codes */
+#define KEY_RSA			1
+#define KEY_DH			2
+#define KEY_DSA			3
+#define KEY_PRIVATE		254
+#define KEY_EXPAND		255
+#define KEY_HMAC_MD5		157
+#define KEY_HMAC_SHA1		158
+#define UNKNOWN_KEYALG		0
+#define DST_MAX_ALGS            KEY_HMAC_SHA1
+
+/* DST constants to locations in KEY record  changes in new KEY record */
+#define DST_FLAGS_SIZE		2
+#define DST_KEY_PROT		2
+#define DST_KEY_ALG		3
+#define DST_EXT_FLAG            4
+#define DST_KEY_START		4
+
+#ifndef SIGN_F_NOKEY 
+#define SIGN_F_NOKEY		0xC000
+#endif
+
+/* error codes from dst routines */
+#define SIGN_INIT_FAILURE	(-23)
+#define SIGN_UPDATE_FAILURE	(-24)
+#define SIGN_FINAL_FAILURE	(-25)
+#define VERIFY_INIT_FAILURE	(-26)
+#define VERIFY_UPDATE_FAILURE	(-27)
+#define VERIFY_FINAL_FAILURE	(-28)
+#define MISSING_KEY_OR_SIGNATURE (-30)
+#define UNSUPPORTED_KEYALG	(-31)
+
+#endif /* DST_H */
+/*! \file */
diff --git a/libc/upstream-netbsd/libc/include/isc/eventlib.h b/libc/upstream-netbsd/libc/include/isc/eventlib.h
new file mode 100644
index 0000000..4e9cc2e
--- /dev/null
+++ b/libc/upstream-netbsd/libc/include/isc/eventlib.h
@@ -0,0 +1,206 @@
+/*	$NetBSD: eventlib.h,v 1.3 2009/04/12 17:07:16 christos Exp $	*/
+
+/*
+ * Copyright (C) 2004, 2005, 2008  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1995-1999, 2001, 2003  Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* eventlib.h - exported interfaces for eventlib
+ * vix 09sep95 [initial]
+ *
+ * Id: eventlib.h,v 1.7 2008/11/14 02:36:51 marka Exp
+ */
+
+#ifndef _EVENTLIB_H
+#define _EVENTLIB_H
+
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <sys/time.h>
+#include <stdio.h>
+
+#ifndef __P
+# define __EVENTLIB_P_DEFINED
+# ifdef __STDC__
+#  define __P(x) x
+# else
+#  define __P(x) ()
+# endif
+#endif
+
+/* In the absence of branded types... */
+typedef struct { void *opaque; } evConnID;
+typedef struct { void *opaque; } evFileID;
+typedef struct { void *opaque; } evStreamID;
+typedef struct { void *opaque; } evTimerID;
+typedef struct { void *opaque; } evWaitID;
+typedef struct { void *opaque; } evContext;
+typedef struct { void *opaque; } evEvent;
+
+#define	evInitID(id) ((id)->opaque = NULL)
+#define	evTestID(id) ((id).opaque != NULL)
+
+typedef void (*evConnFunc)__P((evContext, void *, int, const void *, int,
+			       const void *, int));
+typedef void (*evFileFunc)__P((evContext, void *, int, int));
+typedef	void (*evStreamFunc)__P((evContext, void *, int, int));
+typedef void (*evTimerFunc)__P((evContext, void *,
+				struct timespec, struct timespec));
+typedef	void (*evWaitFunc)__P((evContext, void *, const void *));
+
+typedef	struct { unsigned char mask[256/8]; } evByteMask;
+#define	EV_BYTEMASK_BYTE(b) ((b) / 8)
+#define	EV_BYTEMASK_MASK(b) (1 << ((b) % 8))
+#define	EV_BYTEMASK_SET(bm, b) \
+	((bm).mask[EV_BYTEMASK_BYTE(b)] |= EV_BYTEMASK_MASK(b))
+#define	EV_BYTEMASK_CLR(bm, b) \
+	((bm).mask[EV_BYTEMASK_BYTE(b)] &= ~EV_BYTEMASK_MASK(b))
+#define	EV_BYTEMASK_TST(bm, b) \
+	((bm).mask[EV_BYTEMASK_BYTE(b)] & EV_BYTEMASK_MASK(b))
+
+#define	EV_POLL		1
+#define	EV_WAIT		2
+#define	EV_NULL		4
+
+#define	EV_READ		1
+#define	EV_WRITE	2
+#define	EV_EXCEPT	4
+
+#define EV_WASNONBLOCKING 8	/* Internal library use. */
+
+/* eventlib.c */
+#define evCreate	__evCreate
+#define evSetDebug	__evSetDebug
+#define evDestroy	__evDestroy
+#define evGetNext	__evGetNext
+#define evDispatch	__evDispatch
+#define evDrop		__evDrop
+#define evMainLoop	__evMainLoop
+#define evHighestFD	__evHighestFD
+#define evGetOption	__evGetOption
+#define evSetOption	__evSetOption
+
+int  evCreate __P((evContext *));
+void evSetDebug __P((evContext, int, FILE *));
+int  evDestroy __P((evContext));
+int  evGetNext __P((evContext, evEvent *, int));
+int  evDispatch __P((evContext, evEvent));
+void evDrop __P((evContext, evEvent));
+int  evMainLoop __P((evContext));
+int  evHighestFD __P((evContext));
+int  evGetOption __P((evContext *, const char *, int *));
+int  evSetOption __P((evContext *, const char *, int));
+
+/* ev_connects.c */
+#define evListen	__evListen
+#define evConnect	__evConnect
+#define evCancelConn	__evCancelConn
+#define evHold		__evHold
+#define evUnhold	__evUnhold
+#define evTryAccept	__evTryAccept
+
+int evListen __P((evContext, int, int, evConnFunc, void *, evConnID *));
+int evConnect __P((evContext, int, const void *, int,
+		   evConnFunc, void *, evConnID *));
+int evCancelConn __P((evContext, evConnID));
+int evHold __P((evContext, evConnID));
+int evUnhold __P((evContext, evConnID));
+int evTryAccept __P((evContext, evConnID, int *));
+
+/* ev_files.c */
+#define evSelectFD	__evSelectFD
+#define evDeselectFD	__evDeselectFD
+
+int evSelectFD __P((evContext, int, int, evFileFunc, void *, evFileID *));
+int evDeselectFD __P((evContext, evFileID));
+
+/* ev_streams.c */
+#define evConsIovec	__evConsIovec
+#define evWrite		__evWrite
+#define evRead		__evRead
+#define evTimeRW	__evTimeRW
+#define evUntimeRW	__evUntimeRW
+#define	evCancelRW	__evCancelRW
+
+struct iovec evConsIovec __P((void *, size_t));
+int evWrite __P((evContext, int, const struct iovec *, int,
+		 evStreamFunc func, void *, evStreamID *));
+int evRead __P((evContext, int, const struct iovec *, int,
+		evStreamFunc func, void *, evStreamID *));
+int evTimeRW __P((evContext, evStreamID, evTimerID timer));
+int evUntimeRW __P((evContext, evStreamID));
+int evCancelRW __P((evContext, evStreamID));
+
+/* ev_timers.c */
+#define evConsTime	__evConsTime
+#define evAddTime	__evAddTime
+#define evSubTime	__evSubTime
+#define evCmpTime	__evCmpTime
+#define	evTimeSpec	__evTimeSpec
+#define	evTimeVal	__evTimeVal
+
+#define evNowTime		__evNowTime
+#define evUTCTime		__evUTCTime
+#define evLastEventTime		__evLastEventTime
+#define evSetTimer		__evSetTimer
+#define evClearTimer		__evClearTimer
+#define evConfigTimer		__evConfigTimer
+#define evResetTimer		__evResetTimer
+#define evSetIdleTimer		__evSetIdleTimer
+#define evClearIdleTimer	__evClearIdleTimer
+#define evResetIdleTimer	__evResetIdleTimer
+#define evTouchIdleTimer	__evTouchIdleTimer
+
+struct timespec evConsTime __P((time_t sec, long nsec));
+struct timespec evAddTime __P((struct timespec, struct timespec));
+struct timespec evSubTime __P((struct timespec, struct timespec));
+struct timespec evNowTime __P((void));
+struct timespec evUTCTime __P((void));
+struct timespec evLastEventTime __P((evContext));
+struct timespec evTimeSpec __P((struct timeval));
+struct timeval evTimeVal __P((struct timespec));
+int evCmpTime __P((struct timespec, struct timespec));
+int evSetTimer __P((evContext, evTimerFunc, void *, struct timespec,
+		    struct timespec, evTimerID *));
+int evClearTimer __P((evContext, evTimerID));
+int evConfigTimer __P((evContext, evTimerID, const char *param,
+		      int value));
+int evResetTimer __P((evContext, evTimerID, evTimerFunc, void *,
+		      struct timespec, struct timespec));
+int evSetIdleTimer __P((evContext, evTimerFunc, void *, struct timespec,
+			evTimerID *));
+int evClearIdleTimer __P((evContext, evTimerID));
+int evResetIdleTimer __P((evContext, evTimerID, evTimerFunc, void *,
+			  struct timespec));
+int evTouchIdleTimer __P((evContext, evTimerID));
+
+/* ev_waits.c */
+#define evWaitFor	__evWaitFor
+#define evDo		__evDo
+#define evUnwait	__evUnwait
+#define evDefer		__evDefer
+
+int evWaitFor __P((evContext, const void *, evWaitFunc, void *, evWaitID *));
+int evDo __P((evContext, const void *));
+int evUnwait __P((evContext, evWaitID));
+int evDefer __P((evContext, evWaitFunc, void *));
+
+#ifdef __EVENTLIB_P_DEFINED
+# undef __P
+#endif
+
+#endif /*_EVENTLIB_H*/
+
+/*! \file */
diff --git a/libc/upstream-netbsd/libc/include/isc/heap.h b/libc/upstream-netbsd/libc/include/isc/heap.h
new file mode 100644
index 0000000..30cec98
--- /dev/null
+++ b/libc/upstream-netbsd/libc/include/isc/heap.h
@@ -0,0 +1,51 @@
+/*	$NetBSD: heap.h,v 1.1.1.4 2009/04/12 16:35:44 christos Exp $	*/
+
+/*
+ * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 1997,1999 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+typedef int (*heap_higher_priority_func)(void *, void *);
+typedef void (*heap_index_func)(void *, int);
+typedef void (*heap_for_each_func)(void *, void *);
+
+typedef struct heap_context {
+	int array_size;
+	int array_size_increment;
+	int heap_size;
+	void **heap;
+	heap_higher_priority_func higher_priority;
+	heap_index_func index;
+} *heap_context;
+
+#define heap_new	__heap_new
+#define heap_free	__heap_free
+#define heap_insert	__heap_insert
+#define heap_delete	__heap_delete
+#define heap_increased	__heap_increased
+#define heap_decreased	__heap_decreased
+#define heap_element	__heap_element
+#define heap_for_each	__heap_for_each
+
+heap_context	heap_new(heap_higher_priority_func, heap_index_func, int);
+int		heap_free(heap_context);
+int		heap_insert(heap_context, void *);
+int		heap_delete(heap_context, int);
+int		heap_increased(heap_context, int);
+int		heap_decreased(heap_context, int);
+void *		heap_element(heap_context, int);
+int		heap_for_each(heap_context, heap_for_each_func, void *);
+
+/*! \file */
diff --git a/libc/upstream-netbsd/libc/include/isc/list.h b/libc/upstream-netbsd/libc/include/isc/list.h
new file mode 100644
index 0000000..46f2e79
--- /dev/null
+++ b/libc/upstream-netbsd/libc/include/isc/list.h
@@ -0,0 +1,120 @@
+/*	$NetBSD: list.h,v 1.5 2009/04/12 17:07:16 christos Exp $	*/
+
+/*
+ * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 1997,1999 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef LIST_H
+#define LIST_H 1
+#include <isc/assertions.h>
+
+#define LIST(type) struct { type *head, *tail; }
+#define INIT_LIST(list) \
+	do { (list).head = NULL; (list).tail = NULL; } while (/*CONSTCOND*/0)
+
+#define LINK(type) struct { type *prev, *next; }
+#define INIT_LINK_TYPE(elt, link, type) \
+	do { \
+		(elt)->link.prev = (type *)(-1); \
+		(elt)->link.next = (type *)(-1); \
+	} while (/*CONSTCOND*/0)
+#define INIT_LINK(elt, link) \
+	INIT_LINK_TYPE(elt, link, void)
+#define LINKED(elt, link) ((void *)((elt)->link.prev) != (void *)(-1) && \
+			   (void *)((elt)->link.next) != (void *)(-1))
+
+#define HEAD(list) ((list).head)
+#define TAIL(list) ((list).tail)
+#define EMPTY(list) ((list).head == NULL)
+
+#define PREPEND(list, elt, link) \
+	do { \
+		INSIST(!LINKED(elt, link));\
+		if ((list).head != NULL) \
+			(list).head->link.prev = (elt); \
+		else \
+			(list).tail = (elt); \
+		(elt)->link.prev = NULL; \
+		(elt)->link.next = (list).head; \
+		(list).head = (elt); \
+	} while (/*CONSTCOND*/0)
+
+#define APPEND(list, elt, link) \
+	do { \
+		INSIST(!LINKED(elt, link));\
+		if ((list).tail != NULL) \
+			(list).tail->link.next = (elt); \
+		else \
+			(list).head = (elt); \
+		(elt)->link.prev = (list).tail; \
+		(elt)->link.next = NULL; \
+		(list).tail = (elt); \
+	} while (/*CONSTCOND*/0)
+
+#define UNLINK_TYPE(list, elt, link, type) \
+	do { \
+		INSIST(LINKED(elt, link));\
+		if ((elt)->link.next != NULL) \
+			(elt)->link.next->link.prev = (elt)->link.prev; \
+		else { \
+			INSIST((list).tail == (elt)); \
+			(list).tail = (elt)->link.prev; \
+		} \
+		if ((elt)->link.prev != NULL) \
+			(elt)->link.prev->link.next = (elt)->link.next; \
+		else { \
+			INSIST((list).head == (elt)); \
+			(list).head = (elt)->link.next; \
+		} \
+		INIT_LINK_TYPE(elt, link, type); \
+	} while (/*CONSTCOND*/0)
+#define UNLINK(list, elt, link) \
+	UNLINK_TYPE(list, elt, link, void)
+
+#define PREV(elt, link) ((elt)->link.prev)
+#define NEXT(elt, link) ((elt)->link.next)
+
+#define INSERT_BEFORE(list, before, elt, link) \
+	do { \
+		INSIST(!LINKED(elt, link));\
+		if ((before)->link.prev == NULL) \
+			PREPEND(list, elt, link); \
+		else { \
+			(elt)->link.prev = (before)->link.prev; \
+			(before)->link.prev = (elt); \
+			(elt)->link.prev->link.next = (elt); \
+			(elt)->link.next = (before); \
+		} \
+	} while (/*CONSTCOND*/0)
+
+#define INSERT_AFTER(list, after, elt, link) \
+	do { \
+		INSIST(!LINKED(elt, link));\
+		if ((after)->link.next == NULL) \
+			APPEND(list, elt, link); \
+		else { \
+			(elt)->link.next = (after)->link.next; \
+			(after)->link.next = (elt); \
+			(elt)->link.next->link.prev = (elt); \
+			(elt)->link.prev = (after); \
+		} \
+	} while (/*CONSTCOND*/0)
+
+#define ENQUEUE(list, elt, link) APPEND(list, elt, link)
+#define DEQUEUE(list, elt, link) UNLINK(list, elt, link)
+
+#endif /* LIST_H */
+/*! \file */
diff --git a/libc/upstream-netbsd/libc/include/isc/memcluster.h b/libc/upstream-netbsd/libc/include/isc/memcluster.h
new file mode 100644
index 0000000..3c1b489
--- /dev/null
+++ b/libc/upstream-netbsd/libc/include/isc/memcluster.h
@@ -0,0 +1,52 @@
+/*	$NetBSD: memcluster.h,v 1.1.1.4 2009/04/12 16:35:44 christos Exp $	*/
+
+/*
+ * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 1997,1999 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef MEMCLUSTER_H
+#define MEMCLUSTER_H
+
+#include <stdio.h>
+
+#define meminit		__meminit
+#ifdef MEMCLUSTER_DEBUG
+#define memget(s)	__memget_debug(s, __FILE__, __LINE__)
+#define memput(p, s)	__memput_debug(p, s, __FILE__, __LINE__)
+#else /*MEMCLUSTER_DEBUG*/
+#ifdef MEMCLUSTER_RECORD
+#define memget(s)	__memget_record(s, __FILE__, __LINE__)
+#define memput(p, s)	__memput_record(p, s, __FILE__, __LINE__)
+#else /*MEMCLUSTER_RECORD*/
+#define memget		__memget
+#define memput		__memput
+#endif /*MEMCLUSTER_RECORD*/
+#endif /*MEMCLUSTER_DEBUG*/
+#define memstats	__memstats
+#define memactive	__memactive
+
+int	meminit(size_t, size_t);
+void *	__memget(size_t);
+void 	__memput(void *, size_t);
+void *	__memget_debug(size_t, const char *, int);
+void 	__memput_debug(void *, size_t, const char *, int);
+void *	__memget_record(size_t, const char *, int);
+void 	__memput_record(void *, size_t, const char *, int);
+void 	memstats(FILE *);
+int	memactive(void);
+
+#endif /* MEMCLUSTER_H */
+/*! \file */
diff --git a/libc/upstream-netbsd/libc/inet/inet_ntoa.c b/libc/upstream-netbsd/libc/inet/inet_ntoa.c
new file mode 100644
index 0000000..6ed023b
--- /dev/null
+++ b/libc/upstream-netbsd/libc/inet/inet_ntoa.c
@@ -0,0 +1,64 @@
+/*	$NetBSD: inet_ntoa.c,v 1.2 2012/03/13 21:13:38 christos Exp $	*/
+
+/*
+ * Copyright (c) 1983, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)inet_ntoa.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: inet_ntoa.c,v 1.2 2012/03/13 21:13:38 christos Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <stdio.h>
+#include <string.h>
+
+#ifdef __weak_alias
+__weak_alias(inet_ntoa,_inet_ntoa)
+#endif
+
+/*
+ * Convert network-format internet address
+ * to base 256 d.d.d.d representation.
+ */
+/*const*/ char *
+inet_ntoa(struct in_addr in) {
+	static char ret[18];
+
+	strlcpy(ret, "[inet_ntoa error]", sizeof(ret));
+	(void) inet_ntop(AF_INET, &in, ret, (socklen_t)sizeof ret);
+	return ret;
+}
diff --git a/libc/upstream-netbsd/libc/inet/inet_ntop.c b/libc/upstream-netbsd/libc/inet/inet_ntop.c
new file mode 100644
index 0000000..00c55a8
--- /dev/null
+++ b/libc/upstream-netbsd/libc/inet/inet_ntop.c
@@ -0,0 +1,232 @@
+/*	$NetBSD: inet_ntop.c,v 1.9 2012/03/20 17:08:13 matt Exp $	*/
+
+/*
+ * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 1996-1999 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static const char rcsid[] = "Id: inet_ntop.c,v 1.5 2005/11/03 22:59:52 marka Exp";
+#else
+__RCSID("$NetBSD: inet_ntop.c,v 1.9 2012/03/20 17:08:13 matt Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#include "port_before.h"
+
+#include "namespace.h"
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <arpa/nameser.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "port_after.h"
+
+#ifdef __weak_alias
+__weak_alias(inet_ntop,_inet_ntop)
+#endif
+
+/*%
+ * WARNING: Don't even consider trying to compile this on a system where
+ * sizeof(int) < 4.  sizeof(int) > 4 is fine; all the world's not a VAX.
+ */
+
+static const char *inet_ntop4(const u_char *src, char *dst, socklen_t size);
+static const char *inet_ntop6(const u_char *src, char *dst, socklen_t size);
+
+/* char *
+ * inet_ntop(af, src, dst, size)
+ *	convert a network format address to presentation format.
+ * return:
+ *	pointer to presentation format address (`dst'), or NULL (see errno).
+ * author:
+ *	Paul Vixie, 1996.
+ */
+const char *
+inet_ntop(int af, const void *src, char *dst, socklen_t size)
+{
+
+	_DIAGASSERT(src != NULL);
+	_DIAGASSERT(dst != NULL);
+
+	switch (af) {
+	case AF_INET:
+		return (inet_ntop4(src, dst, size));
+	case AF_INET6:
+		return (inet_ntop6(src, dst, size));
+	default:
+		errno = EAFNOSUPPORT;
+		return (NULL);
+	}
+	/* NOTREACHED */
+}
+
+/* const char *
+ * inet_ntop4(src, dst, size)
+ *	format an IPv4 address, more or less like inet_ntoa()
+ * return:
+ *	`dst' (as a const)
+ * notes:
+ *	(1) uses no statics
+ *	(2) takes a u_char* not an in_addr as input
+ * author:
+ *	Paul Vixie, 1996.
+ */
+static const char *
+inet_ntop4(const u_char *src, char *dst, socklen_t size)
+{
+	char tmp[sizeof "255.255.255.255"];
+	int l;
+
+	_DIAGASSERT(src != NULL);
+	_DIAGASSERT(dst != NULL);
+
+	l = snprintf(tmp, sizeof(tmp), "%u.%u.%u.%u",
+	    src[0], src[1], src[2], src[3]);
+	if (l <= 0 || (socklen_t) l >= size) {
+		errno = ENOSPC;
+		return (NULL);
+	}
+	strlcpy(dst, tmp, size);
+	return (dst);
+}
+
+/* const char *
+ * inet_ntop6(src, dst, size)
+ *	convert IPv6 binary address into presentation (printable) format
+ * author:
+ *	Paul Vixie, 1996.
+ */
+static const char *
+inet_ntop6(const u_char *src, char *dst, socklen_t size)
+{
+	/*
+	 * Note that int32_t and int16_t need only be "at least" large enough
+	 * to contain a value of the specified size.  On some systems, like
+	 * Crays, there is no such thing as an integer variable with 16 bits.
+	 * Keep this in mind if you think this function should have been coded
+	 * to use pointer overlays.  All the world's not a VAX.
+	 */
+	char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
+	char *tp, *ep;
+	struct { int base, len; } best, cur;
+	u_int words[NS_IN6ADDRSZ / NS_INT16SZ];
+	int i;
+	int advance;
+
+	_DIAGASSERT(src != NULL);
+	_DIAGASSERT(dst != NULL);
+
+	/*
+	 * Preprocess:
+	 *	Copy the input (bytewise) array into a wordwise array.
+	 *	Find the longest run of 0x00's in src[] for :: shorthanding.
+	 */
+	memset(words, '\0', sizeof words);
+	for (i = 0; i < NS_IN6ADDRSZ; i++)
+		words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
+	best.base = -1;
+	best.len = 0;
+	cur.base = -1;
+	cur.len = 0;
+	for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
+		if (words[i] == 0) {
+			if (cur.base == -1)
+				cur.base = i, cur.len = 1;
+			else
+				cur.len++;
+		} else {
+			if (cur.base != -1) {
+				if (best.base == -1 || cur.len > best.len)
+					best = cur;
+				cur.base = -1;
+			}
+		}
+	}
+	if (cur.base != -1) {
+		if (best.base == -1 || cur.len > best.len)
+			best = cur;
+	}
+	if (best.base != -1 && best.len < 2)
+		best.base = -1;
+
+	/*
+	 * Format the result.
+	 */
+	tp = tmp;
+	ep = tmp + sizeof(tmp);
+	for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
+		/* Are we inside the best run of 0x00's? */
+		if (best.base != -1 && i >= best.base &&
+		    i < (best.base + best.len)) {
+			if (i == best.base)
+				*tp++ = ':';
+			continue;
+		}
+		/* Are we following an initial run of 0x00s or any real hex? */
+		if (i != 0) {
+			if (tp + 1 >= ep)
+				return (NULL);
+			*tp++ = ':';
+		}
+		/* Is this address an encapsulated IPv4? */
+		if (i == 6 && best.base == 0 &&
+		    (best.len == 6 ||
+		    (best.len == 7 && words[7] != 0x0001) ||
+		    (best.len == 5 && words[5] == 0xffff))) {
+			if (!inet_ntop4(src+12, tp, (socklen_t)(ep - tp)))
+				return (NULL);
+			tp += strlen(tp);
+			break;
+		}
+		advance = snprintf(tp, (size_t)(ep - tp), "%x", words[i]);
+		if (advance <= 0 || advance >= ep - tp)
+			return (NULL);
+		tp += advance;
+	}
+	/* Was it a trailing run of 0x00's? */
+	if (best.base != -1 && (best.base + best.len) == 
+	    (NS_IN6ADDRSZ / NS_INT16SZ)) {
+		if (tp + 1 >= ep)
+			return (NULL);
+		*tp++ = ':';
+	}
+	if (tp + 1 >= ep)
+		return (NULL);
+	*tp++ = '\0';
+
+	/*
+	 * Check for overflow, copy, and we're done.
+	 */
+	if ((size_t)(tp - tmp) > size) {
+		errno = ENOSPC;
+		return (NULL);
+	}
+	strlcpy(dst, tmp, size);
+	return (dst);
+}
+
+/*! \file */
diff --git a/libc/upstream-netbsd/libc/inet/inet_pton.c b/libc/upstream-netbsd/libc/inet/inet_pton.c
new file mode 100644
index 0000000..c1e9a69
--- /dev/null
+++ b/libc/upstream-netbsd/libc/inet/inet_pton.c
@@ -0,0 +1,310 @@
+/*	$NetBSD: inet_pton.c,v 1.8 2012/03/13 21:13:38 christos Exp $	*/
+
+/*
+ * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 1996,1999 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static const char rcsid[] = "Id: inet_pton.c,v 1.5 2005/07/28 06:51:47 marka Exp";
+#else
+__RCSID("$NetBSD: inet_pton.c,v 1.8 2012/03/13 21:13:38 christos Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#include "port_before.h"
+
+#include "namespace.h"
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <arpa/nameser.h>
+#include <stddef.h>
+#include <string.h>
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+
+#include "port_after.h"
+
+#ifdef __weak_alias
+__weak_alias(inet_pton,_inet_pton)
+#endif
+
+/*%
+ * WARNING: Don't even consider trying to compile this on a system where
+ * sizeof(int) < 4.  sizeof(int) > 4 is fine; all the world's not a VAX.
+ */
+
+static int	inet_pton4(const char *src, u_char *dst, int pton);
+static int	inet_pton6(const char *src, u_char *dst);
+
+/* int
+ * inet_pton(af, src, dst)
+ *	convert from presentation format (which usually means ASCII printable)
+ *	to network format (which is usually some kind of binary format).
+ * return:
+ *	1 if the address was valid for the specified address family
+ *	0 if the address wasn't valid (`dst' is untouched in this case)
+ *	-1 if some other error occurred (`dst' is untouched in this case, too)
+ * author:
+ *	Paul Vixie, 1996.
+ */
+int
+inet_pton(int af, const char *src, void *dst)
+{
+
+	_DIAGASSERT(src != NULL);
+	_DIAGASSERT(dst != NULL);
+
+	switch (af) {
+	case AF_INET:
+		return (inet_pton4(src, dst, 1));
+	case AF_INET6:
+		return (inet_pton6(src, dst));
+	default:
+		errno = EAFNOSUPPORT;
+		return (-1);
+	}
+	/* NOTREACHED */
+}
+
+/* int
+ * inet_pton4(src, dst, pton)
+ *	when last arg is 0: inet_aton(). with hexadecimal, octal and shorthand.
+ *	when last arg is 1: inet_pton(). decimal dotted-quad only.
+ * return:
+ *	1 if `src' is a valid input, else 0.
+ * notice:
+ *	does not touch `dst' unless it's returning 1.
+ * author:
+ *	Paul Vixie, 1996.
+ */
+static int
+inet_pton4(const char *src, u_char *dst, int pton)
+{
+	u_int32_t val;
+	u_int digit, base;
+	ptrdiff_t n;
+	unsigned char c;
+	u_int parts[4];
+	u_int *pp = parts;
+
+	_DIAGASSERT(src != NULL);
+	_DIAGASSERT(dst != NULL);
+
+	c = *src;
+	for (;;) {
+		/*
+		 * Collect number up to ``.''.
+		 * Values are specified as for C:
+		 * 0x=hex, 0=octal, isdigit=decimal.
+		 */
+		if (!isdigit(c))
+			return (0);
+		val = 0; base = 10;
+		if (c == '0') {
+			c = *++src;
+			if (c == 'x' || c == 'X')
+				base = 16, c = *++src;
+			else if (isdigit(c) && c != '9')
+				base = 8;
+		}
+		/* inet_pton() takes decimal only */
+		if (pton && base != 10)
+			return (0);
+		for (;;) {
+			if (isdigit(c)) {
+				digit = c - '0';
+				if (digit >= base)
+					break;
+				val = (val * base) + digit;
+				c = *++src;
+			} else if (base == 16 && isxdigit(c)) {
+				digit = c + 10 - (islower(c) ? 'a' : 'A');
+				if (digit >= 16)
+					break;
+				val = (val << 4) | digit;
+				c = *++src;
+			} else
+				break;
+		}
+		if (c == '.') {
+			/*
+			 * Internet format:
+			 *	a.b.c.d
+			 *	a.b.c	(with c treated as 16 bits)
+			 *	a.b	(with b treated as 24 bits)
+			 *	a	(with a treated as 32 bits)
+			 */
+			if (pp >= parts + 3)
+				return (0);
+			*pp++ = val;
+			c = *++src;
+		} else
+			break;
+	}
+	/*
+	 * Check for trailing characters.
+	 */
+	if (c != '\0' && !isspace(c))
+		return (0);
+	/*
+	 * Concoct the address according to
+	 * the number of parts specified.
+	 */
+	n = pp - parts + 1;
+	/* inet_pton() takes dotted-quad only.  it does not take shorthand. */
+	if (pton && n != 4)
+		return (0);
+	switch (n) {
+
+	case 0:
+		return (0);		/* initial nondigit */
+
+	case 1:				/* a -- 32 bits */
+		break;
+
+	case 2:				/* a.b -- 8.24 bits */
+		if (parts[0] > 0xff || val > 0xffffff)
+			return (0);
+		val |= parts[0] << 24;
+		break;
+
+	case 3:				/* a.b.c -- 8.8.16 bits */
+		if ((parts[0] | parts[1]) > 0xff || val > 0xffff)
+			return (0);
+		val |= (parts[0] << 24) | (parts[1] << 16);
+		break;
+
+	case 4:				/* a.b.c.d -- 8.8.8.8 bits */
+		if ((parts[0] | parts[1] | parts[2] | val) > 0xff)
+			return (0);
+		val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
+		break;
+	}
+	if (dst) {
+		val = htonl(val);
+		memcpy(dst, &val, NS_INADDRSZ);
+	}
+	return (1);
+}
+
+/* int
+ * inet_pton6(src, dst)
+ *	convert presentation level address to network order binary form.
+ * return:
+ *	1 if `src' is a valid [RFC1884 2.2] address, else 0.
+ * notice:
+ *	(1) does not touch `dst' unless it's returning 1.
+ *	(2) :: in a full address is silently ignored.
+ * credit:
+ *	inspired by Mark Andrews.
+ * author:
+ *	Paul Vixie, 1996.
+ */
+static int
+inet_pton6(const char *src, u_char *dst)
+{
+	static const char xdigits_l[] = "0123456789abcdef",
+			  xdigits_u[] = "0123456789ABCDEF";
+	u_char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
+	const char *xdigits, *curtok;
+	int ch, seen_xdigits;
+	u_int val;
+
+	_DIAGASSERT(src != NULL);
+	_DIAGASSERT(dst != NULL);
+
+	memset((tp = tmp), '\0', NS_IN6ADDRSZ);
+	endp = tp + NS_IN6ADDRSZ;
+	colonp = NULL;
+	/* Leading :: requires some special handling. */
+	if (*src == ':')
+		if (*++src != ':')
+			return (0);
+	curtok = src;
+	seen_xdigits = 0;
+	val = 0;
+	while ((ch = *src++) != '\0') {
+		const char *pch;
+
+		if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
+			pch = strchr((xdigits = xdigits_u), ch);
+		if (pch != NULL) {
+			val <<= 4;
+			val |= (int)(pch - xdigits);
+			if (++seen_xdigits > 4)
+				return (0);
+			continue;
+		}
+		if (ch == ':') {
+			curtok = src;
+			if (!seen_xdigits) {
+				if (colonp)
+					return (0);
+				colonp = tp;
+				continue;
+			} else if (*src == '\0')
+				return (0);
+			if (tp + NS_INT16SZ > endp)
+				return (0);
+			*tp++ = (u_char) (val >> 8) & 0xff;
+			*tp++ = (u_char) val & 0xff;
+			seen_xdigits = 0;
+			val = 0;
+			continue;
+		}
+		if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
+		    inet_pton4(curtok, tp, 1) > 0) {
+			tp += NS_INADDRSZ;
+			seen_xdigits = 0;
+			break;	/*%< '\\0' was seen by inet_pton4(). */
+		}
+		return (0);
+	}
+	if (seen_xdigits) {
+		if (tp + NS_INT16SZ > endp)
+			return (0);
+		*tp++ = (u_char) (val >> 8) & 0xff;
+		*tp++ = (u_char) val & 0xff;
+	}
+	if (colonp != NULL) {
+		/*
+		 * Since some memmove()'s erroneously fail to handle
+		 * overlapping regions, we'll do the shift by hand.
+		 */
+		const ptrdiff_t n = tp - colonp;
+		int i;
+
+		if (tp == endp)
+			return (0);
+		for (i = 1; i <= n; i++) {
+			endp[- i] = colonp[n - i];
+			colonp[n - i] = 0;
+		}
+		tp = endp;
+	}
+	if (tp != endp)
+		return (0);
+	memcpy(dst, tmp, NS_IN6ADDRSZ);
+	return (1);
+}
+
+/*! \file */
diff --git a/libc/upstream-netbsd/libc/isc/ev_streams.c b/libc/upstream-netbsd/libc/isc/ev_streams.c
new file mode 100644
index 0000000..2804b9f
--- /dev/null
+++ b/libc/upstream-netbsd/libc/isc/ev_streams.c
@@ -0,0 +1,319 @@
+/*	$NetBSD: ev_streams.c,v 1.6 2009/04/12 17:07:17 christos Exp $	*/
+
+/*
+ * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 1996-1999 by Internet Software Consortium
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* ev_streams.c - implement asynch stream file IO for the eventlib
+ * vix 04mar96 [initial]
+ */
+
+#include <sys/cdefs.h>
+#if !defined(LINT) && !defined(CODECENTER) && !defined(lint)
+#ifdef notdef
+static const char rcsid[] = "Id: ev_streams.c,v 1.5 2005/04/27 04:56:36 sra Exp";
+#else
+__RCSID("$NetBSD: ev_streams.c,v 1.6 2009/04/12 17:07:17 christos Exp $");
+#endif
+#endif
+
+#include "port_before.h"
+#include "fd_setsize.h"
+
+#include <sys/types.h>
+#include <sys/uio.h>
+
+#include <errno.h>
+
+#include <isc/eventlib.h>
+#include <isc/assertions.h>
+#include "eventlib_p.h"
+
+#include "port_after.h"
+
+#ifndef _LIBC
+static int	copyvec(evStream *str, const struct iovec *iov, int iocnt);
+static void	consume(evStream *str, size_t bytes);
+static void	done(evContext opaqueCtx, evStream *str);
+static void	writable(evContext opaqueCtx, void *uap, int fd, int evmask);
+static void	readable(evContext opaqueCtx, void *uap, int fd, int evmask);
+#endif
+
+struct iovec
+evConsIovec(void *buf, size_t cnt) {
+	struct iovec ret;
+
+	memset(&ret, 0xf5, sizeof ret);
+	ret.iov_base = buf;
+	ret.iov_len = cnt;
+	return (ret);
+}
+
+#ifndef _LIBC
+int
+evWrite(evContext opaqueCtx, int fd, const struct iovec *iov, int iocnt,
+	evStreamFunc func, void *uap, evStreamID *id)
+{
+	evContext_p *ctx = opaqueCtx.opaque;
+	evStream *new;
+	int save;
+
+	OKNEW(new);
+	new->func = func;
+	new->uap = uap;
+	new->fd = fd;
+	new->flags = 0;
+	if (evSelectFD(opaqueCtx, fd, EV_WRITE, writable, new, &new->file) < 0)
+		goto free;
+	if (copyvec(new, iov, iocnt) < 0)
+		goto free;
+	new->prevDone = NULL;
+	new->nextDone = NULL;
+	if (ctx->streams != NULL)
+		ctx->streams->prev = new;
+	new->prev = NULL;
+	new->next = ctx->streams;
+	ctx->streams = new;
+	if (id != NULL)
+		id->opaque = new;
+	return (0);
+ free:
+	save = errno;
+	FREE(new);
+	errno = save;
+	return (-1);
+}
+
+int
+evRead(evContext opaqueCtx, int fd, const struct iovec *iov, int iocnt,
+       evStreamFunc func, void *uap, evStreamID *id)
+{
+	evContext_p *ctx = opaqueCtx.opaque;
+	evStream *new;
+	int save;
+
+	OKNEW(new);
+	new->func = func;
+	new->uap = uap;
+	new->fd = fd;
+	new->flags = 0;
+	if (evSelectFD(opaqueCtx, fd, EV_READ, readable, new, &new->file) < 0)
+		goto free;
+	if (copyvec(new, iov, iocnt) < 0)
+		goto free;
+	new->prevDone = NULL;
+	new->nextDone = NULL;
+	if (ctx->streams != NULL)
+		ctx->streams->prev = new;
+	new->prev = NULL;
+	new->next = ctx->streams;
+	ctx->streams = new;
+	if (id)
+		id->opaque = new;
+	return (0);
+ free:
+	save = errno;
+	FREE(new);
+	errno = save;
+	return (-1);
+}
+
+int
+evTimeRW(evContext opaqueCtx, evStreamID id, evTimerID timer) /*ARGSUSED*/ {
+	evStream *str = id.opaque;
+
+	UNUSED(opaqueCtx);
+
+	str->timer = timer;
+	str->flags |= EV_STR_TIMEROK;
+	return (0);
+}
+
+int
+evUntimeRW(evContext opaqueCtx, evStreamID id) /*ARGSUSED*/ {
+	evStream *str = id.opaque;
+
+	UNUSED(opaqueCtx);
+
+	str->flags &= ~EV_STR_TIMEROK;
+	return (0);
+}
+
+int
+evCancelRW(evContext opaqueCtx, evStreamID id) {
+	evContext_p *ctx = opaqueCtx.opaque;
+	evStream *old = id.opaque;
+
+	/*
+	 * The streams list is doubly threaded.  First, there's ctx->streams
+	 * that's used by evDestroy() to find and cancel all streams.  Second,
+	 * there's ctx->strDone (head) and ctx->strLast (tail) which thread
+	 * through the potentially smaller number of "IO completed" streams,
+	 * used in evGetNext() to avoid scanning the entire list.
+	 */
+
+	/* Unlink from ctx->streams. */
+	if (old->prev != NULL)
+		old->prev->next = old->next;
+	else
+		ctx->streams = old->next;
+	if (old->next != NULL)
+		old->next->prev = old->prev;
+
+	/*
+	 * If 'old' is on the ctx->strDone list, remove it.  Update
+	 * ctx->strLast if necessary.
+	 */
+	if (old->prevDone == NULL && old->nextDone == NULL) {
+		/*
+		 * Either 'old' is the only item on the done list, or it's
+		 * not on the done list.  If the former, then we unlink it
+		 * from the list.  If the latter, we leave the list alone.
+		 */
+		if (ctx->strDone == old) {
+			ctx->strDone = NULL;
+			ctx->strLast = NULL;
+		}
+	} else {
+		if (old->prevDone != NULL)
+			old->prevDone->nextDone = old->nextDone;
+		else
+			ctx->strDone = old->nextDone;
+		if (old->nextDone != NULL)
+			old->nextDone->prevDone = old->prevDone;
+		else
+			ctx->strLast = old->prevDone;
+	}
+
+	/* Deallocate the stream. */
+	if (old->file.opaque)
+		evDeselectFD(opaqueCtx, old->file);
+	memput(old->iovOrig, sizeof (struct iovec) * old->iovOrigCount);
+	FREE(old);
+	return (0);
+}
+
+/* Copy a scatter/gather vector and initialize a stream handler's IO. */
+static int
+copyvec(evStream *str, const struct iovec *iov, int iocnt) {
+	int i;
+
+	str->iovOrig = (struct iovec *)memget(sizeof(struct iovec) * iocnt);
+	if (str->iovOrig == NULL) {
+		errno = ENOMEM;
+		return (-1);
+	}
+	str->ioTotal = 0;
+	for (i = 0; i < iocnt; i++) {
+		str->iovOrig[i] = iov[i];
+		str->ioTotal += iov[i].iov_len;
+	}
+	str->iovOrigCount = iocnt;
+	str->iovCur = str->iovOrig;
+	str->iovCurCount = str->iovOrigCount;
+	str->ioDone = 0;
+	return (0);
+}
+
+/* Pull off or truncate lead iovec(s). */
+static void
+consume(evStream *str, size_t bytes) {
+	while (bytes > 0U) {
+		if (bytes < (size_t)str->iovCur->iov_len) {
+			str->iovCur->iov_len -= bytes;
+			str->iovCur->iov_base = (void *)
+				((u_char *)str->iovCur->iov_base + bytes);
+			str->ioDone += bytes;
+			bytes = 0;
+		} else {
+			bytes -= str->iovCur->iov_len;
+			str->ioDone += str->iovCur->iov_len;
+			str->iovCur++;
+			str->iovCurCount--;
+		}
+	}
+}
+
+/* Add a stream to Done list and deselect the FD. */
+static void
+done(evContext opaqueCtx, evStream *str) {
+	evContext_p *ctx = opaqueCtx.opaque;
+
+	if (ctx->strLast != NULL) {
+		str->prevDone = ctx->strLast;
+		ctx->strLast->nextDone = str;
+		ctx->strLast = str;
+	} else {
+		INSIST(ctx->strDone == NULL);
+		ctx->strDone = ctx->strLast = str;
+	}
+	evDeselectFD(opaqueCtx, str->file);
+	str->file.opaque = NULL;
+	/* evDrop() will call evCancelRW() on us. */
+}
+
+/* Dribble out some bytes on the stream.  (Called by evDispatch().) */
+static void
+writable(evContext opaqueCtx, void *uap, int fd, int evmask) {
+	evStream *str = uap;
+	int bytes;
+
+	UNUSED(evmask);
+
+	bytes = writev(fd, str->iovCur, str->iovCurCount);
+	if (bytes > 0) {
+		if ((str->flags & EV_STR_TIMEROK) != 0)
+			evTouchIdleTimer(opaqueCtx, str->timer);
+		consume(str, bytes);
+	} else {
+		if (bytes < 0 && errno != EINTR) {
+			str->ioDone = -1;
+			str->ioErrno = errno;
+		}
+	}
+	if (str->ioDone == -1 || str->ioDone == str->ioTotal)
+		done(opaqueCtx, str);
+}
+
+/* Scoop up some bytes from the stream.  (Called by evDispatch().) */
+static void
+readable(evContext opaqueCtx, void *uap, int fd, int evmask) {
+	evStream *str = uap;
+	int bytes;
+
+	UNUSED(evmask);
+
+	bytes = readv(fd, str->iovCur, str->iovCurCount);
+	if (bytes > 0) {
+		if ((str->flags & EV_STR_TIMEROK) != 0)
+			evTouchIdleTimer(opaqueCtx, str->timer);
+		consume(str, bytes);
+	} else {
+		if (bytes == 0)
+			str->ioDone = 0;
+		else {
+			if (errno != EINTR) {
+				str->ioDone = -1;
+				str->ioErrno = errno;
+			}
+		}
+	}
+	if (str->ioDone <= 0 || str->ioDone == str->ioTotal)
+		done(opaqueCtx, str);
+}
+#endif
+
+/*! \file */
diff --git a/libc/upstream-netbsd/libc/isc/ev_timers.c b/libc/upstream-netbsd/libc/isc/ev_timers.c
new file mode 100644
index 0000000..40521a7
--- /dev/null
+++ b/libc/upstream-netbsd/libc/isc/ev_timers.c
@@ -0,0 +1,519 @@
+/*	$NetBSD: ev_timers.c,v 1.11 2012/03/21 00:34:54 christos Exp $	*/
+
+/*
+ * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 1995-1999 by Internet Software Consortium
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* ev_timers.c - implement timers for the eventlib
+ * vix 09sep95 [initial]
+ */
+
+#include <sys/cdefs.h>
+#if !defined(LINT) && !defined(CODECENTER) && !defined(lint)
+#ifdef notdef
+static const char rcsid[] = "Id: ev_timers.c,v 1.6 2005/04/27 04:56:36 sra Exp";
+#else
+__RCSID("$NetBSD: ev_timers.c,v 1.11 2012/03/21 00:34:54 christos Exp $");
+#endif
+#endif
+
+/* Import. */
+
+#include "port_before.h"
+#include "fd_setsize.h"
+
+#include <errno.h>
+
+#include <isc/assertions.h>
+#include <isc/eventlib.h>
+#include "eventlib_p.h"
+
+#include "port_after.h"
+
+/* Constants. */
+
+#define	MILLION 1000000
+#define BILLION 1000000000
+
+/* Forward. */
+
+#ifndef _LIBC
+static int due_sooner(void *, void *);
+static void set_index(void *, int);
+static void free_timer(void *, void *);
+static void print_timer(void *, void *);
+static void idle_timeout(evContext, void *, struct timespec, struct timespec);
+
+/* Private type. */
+
+typedef struct {
+	evTimerFunc	func;
+	void *		uap;
+	struct timespec	lastTouched;
+	struct timespec	max_idle;
+	evTimer *	timer;
+} idle_timer;
+#endif
+
+/* Public. */
+
+struct timespec
+evConsTime(time_t sec, long nsec) {
+	struct timespec x;
+
+	x.tv_sec = sec;
+	x.tv_nsec = nsec;
+	return (x);
+}
+
+struct timespec
+evAddTime(struct timespec addend1, struct timespec addend2) {
+	struct timespec x;
+
+	x.tv_sec = addend1.tv_sec + addend2.tv_sec;
+	x.tv_nsec = addend1.tv_nsec + addend2.tv_nsec;
+	if (x.tv_nsec >= BILLION) {
+		x.tv_sec++;
+		x.tv_nsec -= BILLION;
+	}
+	return (x);
+}
+
+struct timespec
+evSubTime(struct timespec minuend, struct timespec subtrahend) {
+	struct timespec x;
+
+	x.tv_sec = minuend.tv_sec - subtrahend.tv_sec;
+	if (minuend.tv_nsec >= subtrahend.tv_nsec)
+		x.tv_nsec = minuend.tv_nsec - subtrahend.tv_nsec;
+	else {
+		x.tv_nsec = BILLION - subtrahend.tv_nsec + minuend.tv_nsec;
+		x.tv_sec--;
+	}
+	return (x);
+}
+
+int
+evCmpTime(struct timespec a, struct timespec b) {
+#define SGN(x) ((x) < 0 ? (-1) : (x) > 0 ? (1) : (0));
+	time_t s = a.tv_sec - b.tv_sec;
+	long n;
+
+	if (s != 0)
+		return SGN(s);
+
+	n = a.tv_nsec - b.tv_nsec;
+	return SGN(n);
+}
+
+struct timespec
+evNowTime(void)
+{
+	struct timeval now;
+#ifdef CLOCK_REALTIME
+	struct timespec tsnow;
+	int m = CLOCK_REALTIME;
+
+#ifdef CLOCK_MONOTONIC
+#ifndef _LIBC
+	if (__evOptMonoTime)
+		m = CLOCK_MONOTONIC;
+#endif
+#endif
+	if (clock_gettime(m, &tsnow) == 0)
+		return (tsnow);
+#endif
+	if (gettimeofday(&now, NULL) < 0)
+		return (evConsTime((time_t)0, 0L));
+	return (evTimeSpec(now));
+}
+
+struct timespec
+evUTCTime(void) {
+	struct timeval now;
+#ifdef CLOCK_REALTIME
+	struct timespec tsnow;
+	if (clock_gettime(CLOCK_REALTIME, &tsnow) == 0)
+		return (tsnow);
+#endif
+	if (gettimeofday(&now, NULL) < 0)
+		return (evConsTime((time_t)0, 0L));
+	return (evTimeSpec(now));
+}
+
+#ifndef _LIBC
+struct timespec
+evLastEventTime(evContext opaqueCtx) {
+	evContext_p *ctx = opaqueCtx.opaque;
+
+	return (ctx->lastEventTime);
+}
+#endif
+
+struct timespec
+evTimeSpec(struct timeval tv) {
+	struct timespec ts;
+
+	ts.tv_sec = tv.tv_sec;
+	ts.tv_nsec = tv.tv_usec * 1000;
+	return (ts);
+}
+
+struct timeval
+evTimeVal(struct timespec ts) {
+	struct timeval tv;
+
+	tv.tv_sec = ts.tv_sec;
+	tv.tv_usec = (suseconds_t)(ts.tv_nsec / 1000);
+	return (tv);
+}
+
+#ifndef _LIBC
+int
+evSetTimer(evContext opaqueCtx,
+	   evTimerFunc func,
+	   void *uap,
+	   struct timespec due,
+	   struct timespec inter,
+	   evTimerID *opaqueID
+) {
+	evContext_p *ctx = opaqueCtx.opaque;
+	evTimer *id;
+
+	evPrintf(ctx, 1,
+"evSetTimer(ctx %p, func %p, uap %p, due %ld.%09ld, inter %ld.%09ld)\n",
+		 ctx, func, uap,
+		 (long)due.tv_sec, due.tv_nsec,
+		 (long)inter.tv_sec, inter.tv_nsec);
+
+#ifdef __hpux
+	/*
+	 * tv_sec and tv_nsec are unsigned.
+	 */
+	if (due.tv_nsec >= BILLION)
+		EV_ERR(EINVAL);
+
+	if (inter.tv_nsec >= BILLION)
+		EV_ERR(EINVAL);
+#else
+	if (due.tv_sec < 0 || due.tv_nsec < 0 || due.tv_nsec >= BILLION)
+		EV_ERR(EINVAL);
+
+	if (inter.tv_sec < 0 || inter.tv_nsec < 0 || inter.tv_nsec >= BILLION)
+		EV_ERR(EINVAL);
+#endif
+
+	/* due={0,0} is a magic cookie meaning "now." */
+	if (due.tv_sec == (time_t)0 && due.tv_nsec == 0L)
+		due = evNowTime();
+
+	/* Allocate and fill. */
+	OKNEW(id);
+	id->func = func;
+	id->uap = uap;
+	id->due = due;
+	id->inter = inter;
+
+	if (heap_insert(ctx->timers, id) < 0)
+		return (-1);
+
+	/* Remember the ID if the caller provided us a place for it. */
+	if (opaqueID)
+		opaqueID->opaque = id;
+
+	if (ctx->debug > 7) {
+		evPrintf(ctx, 7, "timers after evSetTimer:\n");
+		(void) heap_for_each(ctx->timers, print_timer, (void *)ctx);
+	}
+
+	return (0);
+}
+
+int
+evClearTimer(evContext opaqueCtx, evTimerID id) {
+	evContext_p *ctx = opaqueCtx.opaque;
+	evTimer *del = id.opaque;
+
+	if (ctx->cur != NULL &&
+	    ctx->cur->type == Timer &&
+	    ctx->cur->u.timer.this == del) {
+		evPrintf(ctx, 8, "deferring delete of timer (executing)\n");
+		/*
+		 * Setting the interval to zero ensures that evDrop() will
+		 * clean up the timer.
+		 */
+		del->inter = evConsTime(0, 0);
+		return (0);
+	}
+
+	if (heap_element(ctx->timers, del->index) != del)
+		EV_ERR(ENOENT);
+
+	if (heap_delete(ctx->timers, del->index) < 0)
+		return (-1);
+	FREE(del);
+
+	if (ctx->debug > 7) {
+		evPrintf(ctx, 7, "timers after evClearTimer:\n");
+		(void) heap_for_each(ctx->timers, print_timer, (void *)ctx);
+	}
+
+	return (0);
+}
+
+int
+evConfigTimer(evContext opaqueCtx,
+	     evTimerID id,
+	     const char *param,
+	     int value
+) {
+	evContext_p *ctx = opaqueCtx.opaque;
+	evTimer *timer = id.opaque;
+	int result=0;
+
+	UNUSED(value);
+
+	if (heap_element(ctx->timers, timer->index) != timer)
+		EV_ERR(ENOENT);
+
+	if (strcmp(param, "rate") == 0)
+		timer->mode |= EV_TMR_RATE;
+	else if (strcmp(param, "interval") == 0)
+		timer->mode &= ~EV_TMR_RATE;
+	else
+		EV_ERR(EINVAL);
+
+	return (result);
+}
+
+int
+evResetTimer(evContext opaqueCtx,
+	     evTimerID id,
+	     evTimerFunc func,
+	     void *uap,
+	     struct timespec due,
+	     struct timespec inter
+) {
+	evContext_p *ctx = opaqueCtx.opaque;
+	evTimer *timer = id.opaque;
+	struct timespec old_due;
+	int result=0;
+
+	if (heap_element(ctx->timers, timer->index) != timer)
+		EV_ERR(ENOENT);
+
+#ifdef __hpux
+	/*
+	 * tv_sec and tv_nsec are unsigned.
+	 */
+	if (due.tv_nsec >= BILLION)
+		EV_ERR(EINVAL);
+
+	if (inter.tv_nsec >= BILLION)
+		EV_ERR(EINVAL);
+#else
+	if (due.tv_sec < 0 || due.tv_nsec < 0 || due.tv_nsec >= BILLION)
+		EV_ERR(EINVAL);
+
+	if (inter.tv_sec < 0 || inter.tv_nsec < 0 || inter.tv_nsec >= BILLION)
+		EV_ERR(EINVAL);
+#endif
+
+	old_due = timer->due;
+
+	timer->func = func;
+	timer->uap = uap;
+	timer->due = due;
+	timer->inter = inter;
+
+	switch (evCmpTime(due, old_due)) {
+	case -1:
+		result = heap_increased(ctx->timers, timer->index);
+		break;
+	case 0:
+		result = 0;
+		break;
+	case 1:
+		result = heap_decreased(ctx->timers, timer->index);
+		break;
+	}
+
+	if (ctx->debug > 7) {
+		evPrintf(ctx, 7, "timers after evResetTimer:\n");
+		(void) heap_for_each(ctx->timers, print_timer, (void *)ctx);
+	}
+
+	return (result);
+}
+
+int
+evSetIdleTimer(evContext opaqueCtx,
+		evTimerFunc func,
+		void *uap,
+		struct timespec max_idle,
+		evTimerID *opaqueID
+) {
+	evContext_p *ctx = opaqueCtx.opaque;
+	idle_timer *tt;
+
+	/* Allocate and fill. */
+	OKNEW(tt);
+	tt->func = func;
+	tt->uap = uap;
+	tt->lastTouched = ctx->lastEventTime;
+	tt->max_idle = max_idle;
+
+	if (evSetTimer(opaqueCtx, idle_timeout, tt,
+		       evAddTime(ctx->lastEventTime, max_idle),
+		       max_idle, opaqueID) < 0) {
+		FREE(tt);
+		return (-1);
+	}
+
+	tt->timer = opaqueID->opaque;
+
+	return (0);
+}
+
+int
+evClearIdleTimer(evContext opaqueCtx, evTimerID id) {
+	evTimer *del = id.opaque;
+	idle_timer *tt = del->uap;
+
+	FREE(tt);
+	return (evClearTimer(opaqueCtx, id));
+}
+
+int
+evResetIdleTimer(evContext opaqueCtx,
+		 evTimerID opaqueID,
+		 evTimerFunc func,
+		 void *uap,
+		 struct timespec max_idle
+) {
+	evContext_p *ctx = opaqueCtx.opaque;
+	evTimer *timer = opaqueID.opaque;
+	idle_timer *tt = timer->uap;
+
+	tt->func = func;
+	tt->uap = uap;
+	tt->lastTouched = ctx->lastEventTime;
+	tt->max_idle = max_idle;
+
+	return (evResetTimer(opaqueCtx, opaqueID, idle_timeout, tt,
+			     evAddTime(ctx->lastEventTime, max_idle),
+			     max_idle));
+}
+
+int
+evTouchIdleTimer(evContext opaqueCtx, evTimerID id) {
+	evContext_p *ctx = opaqueCtx.opaque;
+	evTimer *t = id.opaque;
+	idle_timer *tt = t->uap;
+
+	tt->lastTouched = ctx->lastEventTime;
+
+	return (0);
+}
+
+/* Public to the rest of eventlib. */
+
+heap_context
+evCreateTimers(const evContext_p *ctx) {
+
+	UNUSED(ctx);
+
+	return (heap_new(due_sooner, set_index, 2048));
+}
+
+void
+evDestroyTimers(const evContext_p *ctx) {
+	(void) heap_for_each(ctx->timers, free_timer, NULL);
+	(void) heap_free(ctx->timers);
+}
+
+/* Private. */
+
+static int
+due_sooner(void *a, void *b) {
+	evTimer *a_timer, *b_timer;
+
+	a_timer = a;
+	b_timer = b;
+	return (evCmpTime(a_timer->due, b_timer->due) < 0);
+}
+
+static void
+set_index(void *what, int idx) {
+	evTimer *timer;
+
+	timer = what;
+	timer->index = idx;
+}
+
+static void
+free_timer(void *what, void *uap) {
+	evTimer *t = what;
+
+	UNUSED(uap);
+
+	FREE(t);
+}
+
+static void
+print_timer(void *what, void *uap) {
+	evTimer *cur = what;
+	evContext_p *ctx = uap;
+
+	cur = what;
+	evPrintf(ctx, 7,
+	    "  func %p, uap %p, due %ld.%09ld, inter %ld.%09ld\n",
+		 cur->func, cur->uap,
+		 (long)cur->due.tv_sec, cur->due.tv_nsec,
+		 (long)cur->inter.tv_sec, cur->inter.tv_nsec);
+}
+
+static void
+idle_timeout(evContext opaqueCtx,
+	     void *uap,
+	     struct timespec due,
+	     struct timespec inter
+) {
+	evContext_p *ctx = opaqueCtx.opaque;
+	idle_timer *this = uap;
+	struct timespec idle;
+
+	UNUSED(due);
+	UNUSED(inter);
+	
+	idle = evSubTime(ctx->lastEventTime, this->lastTouched);
+	if (evCmpTime(idle, this->max_idle) >= 0) {
+		(this->func)(opaqueCtx, this->uap, this->timer->due,
+			     this->max_idle);
+		/*
+		 * Setting the interval to zero will cause the timer to
+		 * be cleaned up in evDrop().
+		 */
+		this->timer->inter = evConsTime(0L, 0L);
+		FREE(this);
+	} else {
+		/* evDrop() will reschedule the timer. */
+		this->timer->inter = evSubTime(this->max_idle, idle);
+	}
+}
+#endif
+
+/*! \file */
diff --git a/libc/upstream-netbsd/libc/isc/eventlib_p.h b/libc/upstream-netbsd/libc/isc/eventlib_p.h
new file mode 100644
index 0000000..4d6b788
--- /dev/null
+++ b/libc/upstream-netbsd/libc/isc/eventlib_p.h
@@ -0,0 +1,283 @@
+/*	$NetBSD: eventlib_p.h,v 1.3 2009/04/12 17:07:17 christos Exp $	*/
+
+/*
+ * Copyright (c) 2005 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 1995-1999 by Internet Software Consortium
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*! \file 
+ * \brief private interfaces for eventlib
+ * \author vix 09sep95 [initial]
+ *
+ * Id: eventlib_p.h,v 1.9 2006/03/09 23:57:56 marka Exp
+ */
+
+#ifndef _EVENTLIB_P_H
+#define _EVENTLIB_P_H
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <sys/un.h>
+
+#define EVENTLIB_DEBUG 1
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <isc/heap.h>
+#include <isc/list.h>
+#include <isc/memcluster.h>
+
+#define	EV_MASK_ALL	(EV_READ | EV_WRITE | EV_EXCEPT)
+#define EV_ERR(e)		return (errno = (e), -1)
+#define OK(x)		if ((x) < 0) EV_ERR(errno); else (void)NULL
+#define OKFREE(x, y)	if ((x) < 0) { FREE((y)); EV_ERR(errno); } \
+			else (void)NULL
+
+#define	NEW(p)		if (((p) = memget(sizeof *(p))) != NULL) \
+				FILL(p); \
+			else \
+				(void)NULL;
+#define OKNEW(p)	if (!((p) = memget(sizeof *(p)))) { \
+				errno = ENOMEM; \
+				return (-1); \
+			} else \
+				FILL(p)
+#define FREE(p)		memput((p), sizeof *(p))
+
+#if EVENTLIB_DEBUG
+#define FILL(p)		memset((p), 0xF5, sizeof *(p))
+#else
+#define FILL(p)
+#endif
+
+#ifdef USE_POLL
+#ifdef HAVE_STROPTS_H
+#include <stropts.h>
+#endif
+#include <poll.h>
+#endif /* USE_POLL */
+
+typedef struct evConn {
+	evConnFunc	func;
+	void *		uap;
+	int		fd;
+	int		flags;
+#define EV_CONN_LISTEN		0x0001		/*%< Connection is a listener. */
+#define EV_CONN_SELECTED	0x0002		/*%< evSelectFD(conn->file). */
+#define EV_CONN_BLOCK		0x0004		/*%< Listener fd was blocking. */
+	evFileID	file;
+	struct evConn *	prev;
+	struct evConn *	next;
+} evConn;
+
+typedef struct evAccept {
+	int		fd;
+	union {
+		struct sockaddr		sa;
+		struct sockaddr_in	in;
+#ifndef NO_SOCKADDR_UN
+		struct sockaddr_un	un;
+#endif
+	}		la;
+	ISC_SOCKLEN_T	lalen;
+	union {
+		struct sockaddr		sa;
+		struct sockaddr_in	in;
+#ifndef NO_SOCKADDR_UN
+		struct sockaddr_un	un;
+#endif
+	}		ra;
+	ISC_SOCKLEN_T	ralen;
+	int		ioErrno;
+	evConn *	conn;
+	LINK(struct evAccept) link;
+} evAccept;
+
+typedef struct evFile {
+	evFileFunc	func;
+	void *		uap;
+	int		fd;
+	int		eventmask;
+	int		preemptive;
+	struct evFile *	prev;
+	struct evFile *	next;
+	struct evFile *	fdprev;
+	struct evFile *	fdnext;
+} evFile;
+
+typedef struct evStream {
+	evStreamFunc	func;
+	void *		uap;
+	evFileID	file;
+	evTimerID	timer;
+	int		flags;
+#define EV_STR_TIMEROK	0x0001	/*%< IFF timer valid. */
+	int		fd;
+	struct iovec *	iovOrig;
+	int		iovOrigCount;
+	struct iovec *	iovCur;
+	int		iovCurCount;
+	int		ioTotal;
+	int		ioDone;
+	int		ioErrno;
+	struct evStream	*prevDone, *nextDone;
+	struct evStream	*prev, *next;
+} evStream;
+
+typedef struct evTimer {
+	evTimerFunc	func;
+	void *		uap;
+	struct timespec	due, inter;
+	int		index;
+	int		mode;
+#define EV_TMR_RATE	1
+} evTimer;
+
+typedef struct evWait {
+	evWaitFunc	func;
+	void *		uap;
+	const void *	tag;
+	struct evWait *	next;
+} evWait;
+
+typedef struct evWaitList {
+	evWait *		first;
+	evWait *		last;
+	struct evWaitList *	prev;
+	struct evWaitList *	next;
+} evWaitList;
+
+typedef struct evEvent_p {
+	enum {  Accept, File, Stream, Timer, Wait, Free, Null  } type;
+	union {
+		struct {  evAccept *this;  }			accept;
+		struct {  evFile *this; int eventmask;  }	file;
+		struct {  evStream *this;  }			stream;
+		struct {  evTimer *this;  }			timer;
+		struct {  evWait *this;  }			wait;
+		struct {  struct evEvent_p *next;  }		free;
+		struct {  const void *placeholder;  }		null;
+	} u;
+} evEvent_p;
+
+#ifdef USE_POLL
+typedef struct { 
+	void		*ctx;	/* pointer to the evContext_p   */ 
+	uint32_t	type;	/* READ, WRITE, EXCEPT, nonblk  */ 
+	uint32_t	result;	/* 1 => revents, 0 => events    */ 
+} __evEmulMask; 
+
+#define emulMaskInit(ctx, field, ev, lastnext) \
+	ctx->field.ctx = ctx; \
+	ctx->field.type = ev; \
+	ctx->field.result = lastnext; 
+  
+extern short	*__fd_eventfield(int fd, __evEmulMask *maskp); 
+extern short	__poll_event(__evEmulMask *maskp); 
+extern void		__fd_clr(int fd, __evEmulMask *maskp); 
+extern void		__fd_set(int fd, __evEmulMask *maskp); 
+
+#undef  FD_ZERO 
+#define FD_ZERO(maskp) 
+  
+#undef  FD_SET 
+#define FD_SET(fd, maskp) \
+	__fd_set(fd, maskp) 
+
+#undef  FD_CLR 
+#define FD_CLR(fd, maskp) \
+	__fd_clr(fd, maskp) 
+
+#undef  FD_ISSET 
+#define FD_ISSET(fd, maskp) \
+	((*__fd_eventfield(fd, maskp) & __poll_event(maskp)) != 0) 
+
+#endif /* USE_POLL */
+
+typedef struct {
+	/* Global. */
+	const evEvent_p	*cur;
+	/* Debugging. */
+	int		debug;
+	FILE		*output;
+	/* Connections. */
+	evConn		*conns;
+	LIST(evAccept)	accepts;
+	/* Files. */
+	evFile		*files, *fdNext;
+#ifndef USE_POLL
+	fd_set		rdLast, rdNext;
+	fd_set		wrLast, wrNext;
+	fd_set		exLast, exNext;
+	fd_set		nonblockBefore;
+	int		fdMax, fdCount, highestFD;
+	evFile		*fdTable[FD_SETSIZE];
+#else
+	struct pollfd	*pollfds;	/* Allocated as needed  */ 
+	evFile		**fdTable;	/* Ditto                */ 
+	int		maxnfds;	/* # elements in above  */ 
+	int		firstfd;	/* First active fd      */ 
+	int		fdMax;		/* Last active fd       */ 
+	int		fdCount;	/* # fd:s with I/O      */ 
+	int		highestFD;	/* max fd allowed by OS */ 
+	__evEmulMask	rdLast, rdNext; 
+	__evEmulMask	wrLast, wrNext; 
+	__evEmulMask	exLast, exNext; 
+	__evEmulMask	nonblockBefore; 
+#endif /* USE_POLL */
+#ifdef EVENTLIB_TIME_CHECKS
+	struct timespec	lastSelectTime;
+	int		lastFdCount;
+#endif
+	/* Streams. */
+	evStream	*streams;
+	evStream	*strDone, *strLast;
+	/* Timers. */
+	struct timespec	lastEventTime;
+	heap_context	timers;
+	/* Waits. */
+	evWaitList	*waitLists;
+	evWaitList	waitDone;
+} evContext_p;
+
+/* eventlib.c */
+#define evPrintf __evPrintf
+void evPrintf(const evContext_p *ctx, int level, const char *fmt, ...)
+     ISC_FORMAT_PRINTF(3, 4);
+
+#ifdef USE_POLL
+extern int evPollfdRealloc(evContext_p *ctx, int pollfd_chunk_size, int fd);
+#endif /* USE_POLL */
+
+/* ev_timers.c */
+#define evCreateTimers __evCreateTimers
+heap_context evCreateTimers(const evContext_p *);
+#define evDestroyTimers __evDestroyTimers
+void evDestroyTimers(const evContext_p *);
+
+/* ev_waits.c */
+#define evFreeWait __evFreeWait
+evWait *evFreeWait(evContext_p *ctx, evWait *old);
+
+/* Global options */
+extern int	__evOptMonoTime;
+
+#endif /*_EVENTLIB_P_H*/
diff --git a/libc/upstream-netbsd/libc/stdio/getdelim.c b/libc/upstream-netbsd/libc/stdio/getdelim.c
new file mode 100644
index 0000000..acce376
--- /dev/null
+++ b/libc/upstream-netbsd/libc/stdio/getdelim.c
@@ -0,0 +1,154 @@
+/* $NetBSD: getdelim.c,v 1.13 2011/07/22 23:12:30 joerg Exp $ */
+
+/*
+ * Copyright (c) 2009 The NetBSD Foundation, Inc.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Roy Marples.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: getdelim.c,v 1.13 2011/07/22 23:12:30 joerg Exp $");
+
+#include "namespace.h"
+
+#include <sys/param.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "reentrant.h"
+#include "local.h"
+
+#ifdef __weak_alias
+__weak_alias(getdelim, _getdelim)
+#endif
+
+/* Minimum buffer size we create.
+ * This should allow config files to fit into our power of 2 buffer growth
+ * without the need for a realloc. */
+#define MINBUF	128
+
+ssize_t
+__getdelim(char **__restrict buf, size_t *__restrict buflen,
+    int sep, FILE *__restrict fp)
+{
+	unsigned char *p;
+	size_t len, newlen, off;
+	char *newb;
+
+	_DIAGASSERT(fp != NULL);
+
+	if (buf == NULL || buflen == NULL) {
+		errno = EINVAL;
+		goto error;
+	}
+
+	/* If buf is NULL, we have to assume a size of zero */
+	if (*buf == NULL)
+		*buflen = 0;
+
+	_SET_ORIENTATION(fp, -1);
+	off = 0;
+	do {
+		/* If the input buffer is empty, refill it */
+		if (fp->_r <= 0 && __srefill(fp)) {
+			if (__sferror(fp))
+				goto error;
+			/* No error, so EOF. */
+			break;
+		}
+
+		/* Scan through looking for the separator */
+		p = memchr(fp->_p, sep, (size_t)fp->_r);
+		if (p == NULL)
+			len = fp->_r;
+		else
+			len = (p - fp->_p) + 1;
+
+		newlen = off + len;
+		/* Ensure we can handle it */
+		if (newlen < off || newlen > SSIZE_MAX) {
+			errno = EOVERFLOW;
+			goto error;
+		}
+		newlen++; /* reserve space for the NULL terminator */
+		if (newlen > *buflen) {
+			if (newlen < MINBUF)
+				newlen = MINBUF;
+			if (!powerof2(newlen)) {
+				/* Grow the buffer to the next power of 2 */
+				newlen--;
+				newlen |= newlen >> 1;
+				newlen |= newlen >> 2;
+				newlen |= newlen >> 4;
+				newlen |= newlen >> 8;
+				newlen |= newlen >> 16;
+#if SIZE_T_MAX > 0xffffffffU
+				newlen |= newlen >> 32;
+#endif
+				newlen++;
+			}
+
+			newb = realloc(*buf, newlen);
+			if (newb == NULL)
+				goto error;
+			*buf = newb;
+			*buflen = newlen;
+		}
+
+		(void)memcpy((*buf + off), fp->_p, len);
+		/* Safe, len is never greater than what fp->_r can fit. */
+		fp->_r -= (int)len;
+		fp->_p += (int)len;
+		off += len;
+	} while (p == NULL);
+
+	/* POSIX demands we return -1 on EOF. */
+	if (off == 0) 
+		return -1;
+
+	if (*buf != NULL)
+		*(*buf + off) = '\0';
+	return off;
+
+error:
+	fp->_flags |= __SERR;
+	return -1;
+}
+
+ssize_t
+getdelim(char **__restrict buf, size_t *__restrict buflen,
+    int sep, FILE *__restrict fp)
+{
+	ssize_t n;
+
+	FLOCKFILE(fp);
+	n = __getdelim(buf, buflen, sep, fp);
+	FUNLOCKFILE(fp);
+	return n;
+}
diff --git a/libc/upstream-netbsd/libc/stdio/getline.c b/libc/upstream-netbsd/libc/stdio/getline.c
new file mode 100644
index 0000000..e5d4bab
--- /dev/null
+++ b/libc/upstream-netbsd/libc/stdio/getline.c
@@ -0,0 +1,45 @@
+/* $NetBSD: getline.c,v 1.3 2009/12/02 08:46:33 roy Exp $ */
+
+/*
+ * Copyright (c) 2009 The NetBSD Foundation, Inc.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Roy Marples.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: getline.c,v 1.3 2009/12/02 08:46:33 roy Exp $");
+
+#include "namespace.h"
+
+#include <stdio.h>
+
+#ifdef __weak_alias
+__weak_alias(getline, _getline)
+#endif
+
+ssize_t
+getline(char **__restrict buf, size_t *__restrict buflen, FILE *__restrict fp)
+{
+	return getdelim(buf, buflen, '\n', fp);
+}
diff --git a/libc/upstream-netbsd/libc/stdlib/_rand48.c b/libc/upstream-netbsd/libc/stdlib/_rand48.c
new file mode 100644
index 0000000..0468026
--- /dev/null
+++ b/libc/upstream-netbsd/libc/stdlib/_rand48.c
@@ -0,0 +1,57 @@
+/*	$NetBSD: _rand48.c,v 1.7 2005/06/12 05:21:27 lukem Exp $	*/
+
+/*
+ * Copyright (c) 1993 Martin Birgmeier
+ * All rights reserved.
+ *
+ * You may redistribute unmodified or modified versions of this source
+ * code provided that the above copyright notice and this and the
+ * following conditions are retained.
+ *
+ * This software is provided ``as is'', and comes with no warranties
+ * of any kind. I shall in no event be liable for anything that happens
+ * to anyone/anything when using this software.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: _rand48.c,v 1.7 2005/06/12 05:21:27 lukem Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include <assert.h>
+
+#include "rand48.h"
+
+unsigned short __rand48_seed[3] = {
+	RAND48_SEED_0,
+	RAND48_SEED_1,
+	RAND48_SEED_2
+};
+unsigned short __rand48_mult[3] = {
+	RAND48_MULT_0,
+	RAND48_MULT_1,
+	RAND48_MULT_2
+};
+unsigned short __rand48_add = RAND48_ADD;
+
+void
+__dorand48(unsigned short xseed[3])
+{
+	unsigned long accu;
+	unsigned short temp[2];
+
+	_DIAGASSERT(xseed != NULL);
+
+	accu = (unsigned long) __rand48_mult[0] * (unsigned long) xseed[0] +
+	 (unsigned long) __rand48_add;
+	temp[0] = (unsigned short) accu;	/* lower 16 bits */
+	accu >>= sizeof(unsigned short) * 8;
+	accu += (unsigned long) __rand48_mult[0] * (unsigned long) xseed[1] +
+	 (unsigned long) __rand48_mult[1] * (unsigned long) xseed[0];
+	temp[1] = (unsigned short) accu;	/* middle 16 bits */
+	accu >>= sizeof(unsigned short) * 8;
+	accu += __rand48_mult[0] * xseed[2] + __rand48_mult[1] * xseed[1] + __rand48_mult[2] * xseed[0];
+	xseed[0] = temp[0];
+	xseed[1] = temp[1];
+	xseed[2] = (unsigned short) accu;
+}
diff --git a/libc/upstream-netbsd/libc/stdlib/bsearch.c b/libc/upstream-netbsd/libc/stdlib/bsearch.c
new file mode 100644
index 0000000..2b0e0d8
--- /dev/null
+++ b/libc/upstream-netbsd/libc/stdlib/bsearch.c
@@ -0,0 +1,85 @@
+/*	$NetBSD: bsearch.c,v 1.15 2012/03/04 20:01:45 christos Exp $	*/
+
+/*
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)bsearch.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: bsearch.c,v 1.15 2012/03/04 20:01:45 christos Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#include <assert.h>
+#include <errno.h>
+#include <stdlib.h>
+
+/*
+ * Perform a binary search.
+ *
+ * The code below is a bit sneaky.  After a comparison fails, we
+ * divide the work in half by moving either left or right. If lim
+ * is odd, moving left simply involves halving lim: e.g., when lim
+ * is 5 we look at item 2, so we change lim to 2 so that we will
+ * look at items 0 & 1.  If lim is even, the same applies.  If lim
+ * is odd, moving right again involes halving lim, this time moving
+ * the base up one item past p: e.g., when lim is 5 we change base
+ * to item 3 and make lim 2 so that we will look at items 3 and 4.
+ * If lim is even, however, we have to shrink it by one before
+ * halving: e.g., when lim is 4, we still looked at item 2, so we
+ * have to make lim 3, then halve, obtaining 1, so that we will only
+ * look at item 3.
+ */
+void *
+bsearch(const void *key, const void *base0, size_t nmemb, size_t size,
+    int (*compar)(const void *, const void *))
+{
+	const char *base = base0;
+	size_t lim;
+	int cmp;
+	const void *p;
+
+	_DIAGASSERT(key != NULL);
+	_DIAGASSERT(base0 != NULL || nmemb == 0);
+	_DIAGASSERT(compar != NULL);
+
+	for (lim = nmemb; lim != 0; lim >>= 1) {
+		p = base + (lim >> 1) * size;
+		cmp = (*compar)(key, p);
+		if (cmp == 0)
+			return __UNCONST(p);
+		if (cmp > 0) {	/* key > p: move right */
+			base = (const char *)p + size;
+			lim--;
+		}		/* else move left */
+	}
+	return (NULL);
+}
diff --git a/libc/upstream-netbsd/libc/stdlib/div.c b/libc/upstream-netbsd/libc/stdlib/div.c
new file mode 100644
index 0000000..f3bd32f
--- /dev/null
+++ b/libc/upstream-netbsd/libc/stdlib/div.c
@@ -0,0 +1,81 @@
+/*	$NetBSD: div.c,v 1.8 2012/06/25 22:32:45 abs Exp $	*/
+
+/*
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)div.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: div.c,v 1.8 2012/06/25 22:32:45 abs Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdlib.h>		/* div_t */
+
+div_t
+div(int num, int denom)
+{
+	div_t r;
+
+	r.quot = num / denom;
+	r.rem = num % denom;
+	/*
+	 * The ANSI standard says that |r.quot| <= |n/d|, where
+	 * n/d is to be computed in infinite precision.  In other
+	 * words, we should always truncate the quotient towards
+	 * 0, never -infinity.
+	 *
+	 * Machine division and remainer may work either way when
+	 * one or both of n or d is negative.  If only one is
+	 * negative and r.quot has been truncated towards -inf,
+	 * r.rem will have the same sign as denom and the opposite
+	 * sign of num; if both are negative and r.quot has been
+	 * truncated towards -inf, r.rem will be positive (will
+	 * have the opposite sign of num).  These are considered
+	 * `wrong'.
+	 *
+	 * If both are num and denom are positive, r will always
+	 * be positive.
+	 *
+	 * This all boils down to:
+	 *	if num >= 0, but r.rem < 0, we got the wrong answer.
+	 * In that case, to get the right answer, add 1 to r.quot and
+	 * subtract denom from r.rem.
+	 */
+	if (num >= 0 && r.rem < 0) {
+		r.quot++;
+		r.rem -= denom;
+	}
+	return (r);
+}
diff --git a/libc/upstream-netbsd/libc/stdlib/drand48.c b/libc/upstream-netbsd/libc/stdlib/drand48.c
new file mode 100644
index 0000000..6fba607
--- /dev/null
+++ b/libc/upstream-netbsd/libc/stdlib/drand48.c
@@ -0,0 +1,32 @@
+/*	$NetBSD: drand48.c,v 1.6 2005/06/12 05:21:28 lukem Exp $	*/
+
+/*
+ * Copyright (c) 1993 Martin Birgmeier
+ * All rights reserved.
+ *
+ * You may redistribute unmodified or modified versions of this source
+ * code provided that the above copyright notice and this and the
+ * following conditions are retained.
+ *
+ * This software is provided ``as is'', and comes with no warranties
+ * of any kind. I shall in no event be liable for anything that happens
+ * to anyone/anything when using this software.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: drand48.c,v 1.6 2005/06/12 05:21:28 lukem Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+#include "rand48.h"
+
+#ifdef __weak_alias
+__weak_alias(drand48,_drand48)
+#endif
+
+double
+drand48(void)
+{
+	return erand48(__rand48_seed);
+}
diff --git a/libc/upstream-netbsd/libc/stdlib/erand48.c b/libc/upstream-netbsd/libc/stdlib/erand48.c
new file mode 100644
index 0000000..f1d8b4d
--- /dev/null
+++ b/libc/upstream-netbsd/libc/stdlib/erand48.c
@@ -0,0 +1,42 @@
+/*	$NetBSD: erand48.c,v 1.9 2006/03/22 20:52:16 drochner Exp $	*/
+
+/*
+ * Copyright (c) 1993 Martin Birgmeier
+ * All rights reserved.
+ *
+ * You may redistribute unmodified or modified versions of this source
+ * code provided that the above copyright notice and this and the
+ * following conditions are retained.
+ *
+ * This software is provided ``as is'', and comes with no warranties
+ * of any kind. I shall in no event be liable for anything that happens
+ * to anyone/anything when using this software.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: erand48.c,v 1.9 2006/03/22 20:52:16 drochner Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+
+#include <assert.h>
+#include <math.h>
+
+#include "rand48.h"
+
+#ifdef __weak_alias
+__weak_alias(erand48,_erand48)
+#endif
+
+double
+erand48(unsigned short xseed[3])
+{
+
+	_DIAGASSERT(xseed != NULL);
+
+	__dorand48(xseed);
+	return ldexp((double) xseed[0], -48) +
+	       ldexp((double) xseed[1], -32) +
+	       ldexp((double) xseed[2], -16);
+}
diff --git a/libc/upstream-netbsd/libc/stdlib/jrand48.c b/libc/upstream-netbsd/libc/stdlib/jrand48.c
new file mode 100644
index 0000000..0ab594e
--- /dev/null
+++ b/libc/upstream-netbsd/libc/stdlib/jrand48.c
@@ -0,0 +1,39 @@
+/*	$NetBSD: jrand48.c,v 1.8 2005/06/12 05:21:28 lukem Exp $	*/
+
+/*
+ * Copyright (c) 1993 Martin Birgmeier
+ * All rights reserved.
+ *
+ * You may redistribute unmodified or modified versions of this source
+ * code provided that the above copyright notice and this and the
+ * following conditions are retained.
+ *
+ * This software is provided ``as is'', and comes with no warranties
+ * of any kind. I shall in no event be liable for anything that happens
+ * to anyone/anything when using this software.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: jrand48.c,v 1.8 2005/06/12 05:21:28 lukem Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+
+#include <assert.h>
+
+#include "rand48.h"
+
+#ifdef __weak_alias
+__weak_alias(jrand48,_jrand48)
+#endif
+
+long
+jrand48(unsigned short xseed[3])
+{
+
+	_DIAGASSERT(xseed != NULL);
+
+	__dorand48(xseed);
+	return ((long) xseed[2] << 16) + (long) xseed[1];
+}
diff --git a/libc/upstream-netbsd/libc/stdlib/ldiv.c b/libc/upstream-netbsd/libc/stdlib/ldiv.c
new file mode 100644
index 0000000..507c831
--- /dev/null
+++ b/libc/upstream-netbsd/libc/stdlib/ldiv.c
@@ -0,0 +1,60 @@
+/*	$NetBSD: ldiv.c,v 1.8 2012/06/25 22:32:45 abs Exp $	*/
+
+/*
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)ldiv.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: ldiv.c,v 1.8 2012/06/25 22:32:45 abs Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdlib.h>		/* ldiv_t */
+
+ldiv_t
+ldiv(long num, long denom)
+{
+	ldiv_t r;
+
+	/* see div.c for comments */
+
+	r.quot = num / denom;
+	r.rem = num % denom;
+	if (num >= 0 && r.rem < 0) {
+		r.quot++;
+		r.rem -= denom;
+	}
+	return (r);
+}
diff --git a/libc/upstream-netbsd/libc/stdlib/lldiv.c b/libc/upstream-netbsd/libc/stdlib/lldiv.c
new file mode 100644
index 0000000..47104b3
--- /dev/null
+++ b/libc/upstream-netbsd/libc/stdlib/lldiv.c
@@ -0,0 +1,66 @@
+/*	$NetBSD: lldiv.c,v 1.4 2012/06/25 22:32:45 abs Exp $	*/
+
+/*
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "from: @(#)ldiv.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: lldiv.c,v 1.4 2012/06/25 22:32:45 abs Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+#include <stdlib.h>		/* lldiv_t */
+
+#ifdef __weak_alias
+__weak_alias(lldiv, _lldiv)
+#endif
+
+/* LONGLONG */
+lldiv_t
+lldiv(long long int num, long long int denom)
+{
+	lldiv_t r;
+
+	/* see div.c for comments */
+
+	r.quot = num / denom;
+	r.rem = num % denom;
+	if (num >= 0 && r.rem < 0) {
+		r.quot++;
+		r.rem -= denom;
+	}
+	return (r);
+}
diff --git a/libc/upstream-netbsd/libc/stdlib/lrand48.c b/libc/upstream-netbsd/libc/stdlib/lrand48.c
new file mode 100644
index 0000000..78f869e
--- /dev/null
+++ b/libc/upstream-netbsd/libc/stdlib/lrand48.c
@@ -0,0 +1,34 @@
+/*	$NetBSD: lrand48.c,v 1.8 2005/06/12 05:21:28 lukem Exp $	*/
+
+/*
+ * Copyright (c) 1993 Martin Birgmeier
+ * All rights reserved.
+ *
+ * You may redistribute unmodified or modified versions of this source
+ * code provided that the above copyright notice and this and the
+ * following conditions are retained.
+ *
+ * This software is provided ``as is'', and comes with no warranties
+ * of any kind. I shall in no event be liable for anything that happens
+ * to anyone/anything when using this software.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: lrand48.c,v 1.8 2005/06/12 05:21:28 lukem Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+#include "rand48.h"
+
+#ifdef __weak_alias
+__weak_alias(lrand48,_lrand48)
+#endif
+
+long
+lrand48(void)
+{
+	__dorand48(__rand48_seed);
+	return (long)((unsigned long) __rand48_seed[2] << 15) +
+	    ((unsigned long) __rand48_seed[1] >> 1);
+}
diff --git a/libc/upstream-netbsd/libc/stdlib/mrand48.c b/libc/upstream-netbsd/libc/stdlib/mrand48.c
new file mode 100644
index 0000000..c787ce6
--- /dev/null
+++ b/libc/upstream-netbsd/libc/stdlib/mrand48.c
@@ -0,0 +1,33 @@
+/*	$NetBSD: mrand48.c,v 1.7 2005/06/12 05:21:28 lukem Exp $	*/
+
+/*
+ * Copyright (c) 1993 Martin Birgmeier
+ * All rights reserved.
+ *
+ * You may redistribute unmodified or modified versions of this source
+ * code provided that the above copyright notice and this and the
+ * following conditions are retained.
+ *
+ * This software is provided ``as is'', and comes with no warranties
+ * of any kind. I shall in no event be liable for anything that happens
+ * to anyone/anything when using this software.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: mrand48.c,v 1.7 2005/06/12 05:21:28 lukem Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+#include "rand48.h"
+
+#ifdef __weak_alias
+__weak_alias(mrand48,_mrand48)
+#endif
+
+long
+mrand48(void)
+{
+	__dorand48(__rand48_seed);
+	return ((long) __rand48_seed[2] << 16) + (long) __rand48_seed[1];
+}
diff --git a/libc/upstream-netbsd/libc/stdlib/nrand48.c b/libc/upstream-netbsd/libc/stdlib/nrand48.c
new file mode 100644
index 0000000..fc73185
--- /dev/null
+++ b/libc/upstream-netbsd/libc/stdlib/nrand48.c
@@ -0,0 +1,39 @@
+/*	$NetBSD: nrand48.c,v 1.9 2005/06/12 05:21:28 lukem Exp $	*/
+
+/*
+ * Copyright (c) 1993 Martin Birgmeier
+ * All rights reserved.
+ *
+ * You may redistribute unmodified or modified versions of this source
+ * code provided that the above copyright notice and this and the
+ * following conditions are retained.
+ *
+ * This software is provided ``as is'', and comes with no warranties
+ * of any kind. I shall in no event be liable for anything that happens
+ * to anyone/anything when using this software.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: nrand48.c,v 1.9 2005/06/12 05:21:28 lukem Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+
+#include <assert.h>
+
+#include "rand48.h"
+
+#ifdef __weak_alias
+__weak_alias(nrand48,_nrand48)
+#endif
+
+long
+nrand48(unsigned short xseed[3])
+{
+	_DIAGASSERT(xseed != NULL);
+
+	__dorand48(xseed);
+	return (long)((unsigned long) xseed[2] << 15) +
+	    ((unsigned long) xseed[1] >> 1);
+}
diff --git a/libc/upstream-netbsd/libc/stdlib/seed48.c b/libc/upstream-netbsd/libc/stdlib/seed48.c
new file mode 100644
index 0000000..36c0570
--- /dev/null
+++ b/libc/upstream-netbsd/libc/stdlib/seed48.c
@@ -0,0 +1,49 @@
+/*	$NetBSD: seed48.c,v 1.8 2005/06/12 05:21:28 lukem Exp $	*/
+
+/*
+ * Copyright (c) 1993 Martin Birgmeier
+ * All rights reserved.
+ *
+ * You may redistribute unmodified or modified versions of this source
+ * code provided that the above copyright notice and this and the
+ * following conditions are retained.
+ *
+ * This software is provided ``as is'', and comes with no warranties
+ * of any kind. I shall in no event be liable for anything that happens
+ * to anyone/anything when using this software.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: seed48.c,v 1.8 2005/06/12 05:21:28 lukem Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+
+#include <assert.h>
+
+#include "rand48.h"
+
+#ifdef __weak_alias
+__weak_alias(seed48,_seed48)
+#endif
+
+unsigned short *
+seed48(unsigned short xseed[3])
+{
+	static unsigned short sseed[3];
+
+	_DIAGASSERT(xseed != NULL);
+
+	sseed[0] = __rand48_seed[0];
+	sseed[1] = __rand48_seed[1];
+	sseed[2] = __rand48_seed[2];
+	__rand48_seed[0] = xseed[0];
+	__rand48_seed[1] = xseed[1];
+	__rand48_seed[2] = xseed[2];
+	__rand48_mult[0] = RAND48_MULT_0;
+	__rand48_mult[1] = RAND48_MULT_1;
+	__rand48_mult[2] = RAND48_MULT_2;
+	__rand48_add = RAND48_ADD;
+	return sseed;
+}
diff --git a/libc/upstream-netbsd/libc/stdlib/srand48.c b/libc/upstream-netbsd/libc/stdlib/srand48.c
new file mode 100644
index 0000000..a9673fe
--- /dev/null
+++ b/libc/upstream-netbsd/libc/stdlib/srand48.c
@@ -0,0 +1,38 @@
+/*	$NetBSD: srand48.c,v 1.7 2005/06/12 05:21:28 lukem Exp $	*/
+
+/*
+ * Copyright (c) 1993 Martin Birgmeier
+ * All rights reserved.
+ *
+ * You may redistribute unmodified or modified versions of this source
+ * code provided that the above copyright notice and this and the
+ * following conditions are retained.
+ *
+ * This software is provided ``as is'', and comes with no warranties
+ * of any kind. I shall in no event be liable for anything that happens
+ * to anyone/anything when using this software.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: srand48.c,v 1.7 2005/06/12 05:21:28 lukem Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+#include "rand48.h"
+
+#ifdef __weak_alias
+__weak_alias(srand48,_srand48)
+#endif
+
+void
+srand48(long seed)
+{
+	__rand48_seed[0] = RAND48_SEED_0;
+	__rand48_seed[1] = (unsigned short) seed;
+	__rand48_seed[2] = (unsigned short) ((unsigned long)seed >> 16);
+	__rand48_mult[0] = RAND48_MULT_0;
+	__rand48_mult[1] = RAND48_MULT_1;
+	__rand48_mult[2] = RAND48_MULT_2;
+	__rand48_add = RAND48_ADD;
+}
diff --git a/libc/upstream-netbsd/libc/string/memccpy.c b/libc/upstream-netbsd/libc/string/memccpy.c
new file mode 100644
index 0000000..c086241
--- /dev/null
+++ b/libc/upstream-netbsd/libc/string/memccpy.c
@@ -0,0 +1,61 @@
+/*	$NetBSD: memccpy.c,v 1.13 2012/06/25 22:32:46 abs Exp $	*/
+
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)memccpy.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: memccpy.c,v 1.13 2012/06/25 22:32:46 abs Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#include <assert.h>
+#include <string.h>
+
+void *
+memccpy(void *t, const void *f, int c, size_t n)
+{
+
+	_DIAGASSERT(t != 0);
+	_DIAGASSERT(f != 0);
+
+	if (n) {
+		unsigned char *tp = t;
+		const unsigned char *fp = f;
+		unsigned char uc = c;
+		do {
+			if ((*tp++ = *fp++) == uc)
+				return (tp);
+		} while (--n != 0);
+	}
+	return (0);
+}
diff --git a/libc/upstream-netbsd/libc/string/strcasestr.c b/libc/upstream-netbsd/libc/string/strcasestr.c
new file mode 100644
index 0000000..f8a9444
--- /dev/null
+++ b/libc/upstream-netbsd/libc/string/strcasestr.c
@@ -0,0 +1,69 @@
+/*	$NetBSD: strcasestr.c,v 1.3 2005/11/29 03:12:00 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: strcasestr.c,v 1.3 2005/11/29 03:12:00 christos Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+#include <assert.h>
+#include <ctype.h>
+#include <string.h>
+
+/*
+ * Find the first occurrence of find in s, ignore case.
+ */
+char *
+strcasestr(const char *s, const char *find)
+{
+	char c, sc;
+	size_t len;
+
+	_DIAGASSERT(s != NULL);
+	_DIAGASSERT(find != NULL);
+
+	if ((c = *find++) != 0) {
+		c = tolower((unsigned char)c);
+		len = strlen(find);
+		do {
+			do {
+				if ((sc = *s++) == 0)
+					return (NULL);
+			} while ((char)tolower((unsigned char)sc) != c);
+		} while (strncasecmp(s, find, len) != 0);
+		s--;
+	}
+	return __UNCONST(s);
+}
diff --git a/libc/upstream-netbsd/libc/string/strcoll.c b/libc/upstream-netbsd/libc/string/strcoll.c
new file mode 100644
index 0000000..77a0942
--- /dev/null
+++ b/libc/upstream-netbsd/libc/string/strcoll.c
@@ -0,0 +1,59 @@
+/*	$NetBSD: strcoll.c,v 1.10 2012/06/25 22:32:46 abs Exp $	*/
+
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)strcoll.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: strcoll.c,v 1.10 2012/06/25 22:32:46 abs Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#include <assert.h>
+#include <string.h>
+
+/*
+ * Compare strings according to LC_COLLATE category of current locale.
+ */
+int
+strcoll(const char *s1, const char *s2)
+{
+
+	_DIAGASSERT(s1 != NULL);
+	_DIAGASSERT(s2 != NULL);
+
+	/* LC_COLLATE is unimplemented, hence always "C" */
+	return (strcmp(s1, s2));
+}
diff --git a/libc/upstream-netbsd/libc/unistd/killpg.c b/libc/upstream-netbsd/libc/unistd/killpg.c
new file mode 100644
index 0000000..ceac3f4
--- /dev/null
+++ b/libc/upstream-netbsd/libc/unistd/killpg.c
@@ -0,0 +1,56 @@
+/*	$NetBSD: killpg.c,v 1.8 2003/08/07 16:42:39 agc Exp $	*/
+
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)killpg.c	8.1 (Berkeley) 6/2/93";
+#else
+__RCSID("$NetBSD: killpg.c,v 1.8 2003/08/07 16:42:39 agc Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+#include <signal.h>
+#include <errno.h>
+
+/*
+ * Backwards-compatible killpg().
+ */
+int
+killpg(pid_t pgid, int sig)
+{
+	if (pgid == 1) {
+		errno = ESRCH;
+		return (-1);
+	}
+	return (kill(-pgid, sig));
+}
diff --git a/libc/upstream-netbsd/netbsd-compat.h b/libc/upstream-netbsd/netbsd-compat.h
index 3833c1d..e33885e 100644
--- a/libc/upstream-netbsd/netbsd-compat.h
+++ b/libc/upstream-netbsd/netbsd-compat.h
@@ -24,4 +24,13 @@
 // TODO: update our <sys/cdefs.h> to support this properly.
 #define __type_fit(t, a) (0 == 0)
 
+// TODO: our 2.6 emulator kernels don't support SOCK_CLOEXEC yet, so we have to do without.
+#define SOCK_CLOEXEC 0
+
+#define _GNU_SOURCE
+
+// TODO: we don't yet have thread-safe environment variables.
+#define __readlockenv() 0
+#define __unlockenv() 0
+
 #endif
diff --git a/libc/upstream-netbsd/port_after.h b/libc/upstream-netbsd/port_after.h
new file mode 100644
index 0000000..3f8b6f8
--- /dev/null
+++ b/libc/upstream-netbsd/port_after.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _BIONIC_NETBSD_PORT_BEFORE_H_included
+#define _BIONIC_NETBSD_PORT_BEFORE_H_included
+
+#endif
diff --git a/libc/upstream-netbsd/port_before.h b/libc/upstream-netbsd/port_before.h
new file mode 100644
index 0000000..70eed26
--- /dev/null
+++ b/libc/upstream-netbsd/port_before.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _BIONIC_NETBSD_PORT_BEFORE_H_included
+#define _BIONIC_NETBSD_PORT_BEFORE_H_included
+
+#include "namespace.h"
+#include <sys/cdefs.h>
+#include <arpa_nameser.h>
+
+#define ISC_FORMAT_PRINTF(a,b) __attribute__((__format__(__printf__,a,b)))
+#define ISC_SOCKLEN_T socklen_t
+
+#endif
diff --git a/libc/upstream-netbsd/reentrant.h b/libc/upstream-netbsd/reentrant.h
new file mode 100644
index 0000000..e2945da
--- /dev/null
+++ b/libc/upstream-netbsd/reentrant.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _BIONIC_NETBSD_REENTRANT_H_included
+#define _BIONIC_NETBSD_REENTRANT_H_included
+
+#define _REENTRANT
+
+#include <pthread.h>
+#include <signal.h>
+
+//
+// Map NetBSD libc internal locking to pthread locking.
+//
+
+#define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
+#define mutex_t pthread_mutex_t
+
+#define RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER
+#define rwlock_t pthread_rwlock_t
+#define rwlock_rdlock pthread_rwlock_rdlock
+#define rwlock_unlock pthread_rwlock_unlock
+#define rwlock_wrlock pthread_rwlock_wrlock
+
+#endif
diff --git a/libc/zoneinfo/Android.mk b/libc/zoneinfo/Android.mk
index 7cd9139..fe5099d 100644
--- a/libc/zoneinfo/Android.mk
+++ b/libc/zoneinfo/Android.mk
@@ -1,8 +1,7 @@
 LOCAL_PATH:= $(call my-dir)
 
-############################################
 include $(CLEAR_VARS)
-LOCAL_MODULE := zoneinfo.dat
+LOCAL_MODULE := tzdata
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
 LOCAL_SRC_FILES := $(LOCAL_MODULE)
 LOCAL_MODULE_CLASS := ETC
@@ -10,60 +9,14 @@
 LOCAL_MODULE_PATH := $(TARGET_OUT)/usr/share/zoneinfo
 include $(BUILD_PREBUILT)
 
-############################################
-include $(CLEAR_VARS)
-LOCAL_MODULE := zoneinfo.idx
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_SRC_FILES := $(LOCAL_MODULE)
-LOCAL_MODULE_CLASS := ETC
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_PATH := $(TARGET_OUT)/usr/share/zoneinfo
-include $(BUILD_PREBUILT)
-
-############################################
-include $(CLEAR_VARS)
-LOCAL_MODULE := zoneinfo.version
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_SRC_FILES := $(LOCAL_MODULE)
-LOCAL_MODULE_CLASS := ETC
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_PATH := $(TARGET_OUT)/usr/share/zoneinfo
-include $(BUILD_PREBUILT)
-
-
 # The host build doesn't use bionic, but it does use bionic's zoneinfo data
 ifeq ($(WITH_HOST_DALVIK),true)
 
-############################################
 include $(CLEAR_VARS)
-LOCAL_MODULE := zoneinfo-host.dat
+LOCAL_MODULE := tzdata-host
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
 LOCAL_IS_HOST_MODULE := true
-LOCAL_SRC_FILES := zoneinfo.dat
-LOCAL_MODULE_CLASS := ETC
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_STEM := $(LOCAL_SRC_FILES)
-LOCAL_MODULE_PATH := $(HOST_OUT)/usr/share/zoneinfo
-include $(BUILD_PREBUILT)
-
-############################################
-include $(CLEAR_VARS)
-LOCAL_MODULE := zoneinfo-host.idx
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_IS_HOST_MODULE := true
-LOCAL_SRC_FILES := zoneinfo.idx
-LOCAL_MODULE_CLASS := ETC
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_STEM := $(LOCAL_SRC_FILES)
-LOCAL_MODULE_PATH := $(HOST_OUT)/usr/share/zoneinfo
-include $(BUILD_PREBUILT)
-
-############################################
-include $(CLEAR_VARS)
-LOCAL_MODULE := zoneinfo-host.version
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_IS_HOST_MODULE := true
-LOCAL_SRC_FILES := zoneinfo.version
+LOCAL_SRC_FILES := tzdata
 LOCAL_MODULE_CLASS := ETC
 LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE_STEM := $(LOCAL_SRC_FILES)
diff --git a/libc/zoneinfo/tzdata b/libc/zoneinfo/tzdata
new file mode 100644
index 0000000..91cf3a6
--- /dev/null
+++ b/libc/zoneinfo/tzdata
Binary files differ
diff --git a/libc/zoneinfo/zoneinfo.dat b/libc/zoneinfo/zoneinfo.dat
deleted file mode 100644
index cb0507a..0000000
--- a/libc/zoneinfo/zoneinfo.dat
+++ /dev/null
Binary files differ
diff --git a/libc/zoneinfo/zoneinfo.idx b/libc/zoneinfo/zoneinfo.idx
deleted file mode 100644
index c93b637..0000000
--- a/libc/zoneinfo/zoneinfo.idx
+++ /dev/null
Binary files differ
diff --git a/libc/zoneinfo/zoneinfo.version b/libc/zoneinfo/zoneinfo.version
deleted file mode 100644
index 73bb417..0000000
--- a/libc/zoneinfo/zoneinfo.version
+++ /dev/null
@@ -1 +0,0 @@
-2012h
diff --git a/libdl/libdl.c b/libdl/libdl.c
index 1d51c37..378f521 100644
--- a/libdl/libdl.c
+++ b/libdl/libdl.c
@@ -24,13 +24,18 @@
 int dladdr(const void *addr, Dl_info *info) { return 0; }
 int dlclose(void *handle) { return 0; }
 
-#ifdef __arm__
+void android_update_LD_LIBRARY_PATH(const char* ld_library_path) { }
+
+#if defined(__arm__)
+
 void *dl_unwind_find_exidx(void *pc, int *pcount) { return 0; }
-#elif defined(__i386__) || defined(__sh__) || defined(__mips__)
+
+#elif defined(__i386__) || defined(__mips__)
+
 /* we munge the cb definition so we don't have to include any headers here.
  * It won't affect anything since these are just symbols anyway */
-int dl_iterate_phdr(int (*cb)(void *info, void *size, void *data),
-                    void *data) { return 0; }
+int dl_iterate_phdr(int (*cb)(void *info, void *size, void *data), void *data) { return 0; }
+
 #else
 #error Unsupported architecture. Only mips, arm and x86 are supported.
 #endif
diff --git a/libm/Android.mk b/libm/Android.mk
index 9c88798..0d2c843 100644
--- a/libm/Android.mk
+++ b/libm/Android.mk
@@ -1,229 +1,254 @@
 LOCAL_PATH:= $(call my-dir)
 
-libm_common_src_files:= \
-	isinf.c  \
-	fpclassify.c \
-	sincos.c \
-	bsdsrc/b_exp.c \
-	bsdsrc/b_log.c \
-	bsdsrc/b_tgamma.c \
-	src/e_acos.c \
-	src/e_acosf.c \
-	src/e_acosh.c \
-	src/e_acoshf.c \
-	src/e_asin.c \
-	src/e_asinf.c \
-	src/e_atan2.c \
-	src/e_atan2f.c \
-	src/e_atanh.c \
-	src/e_atanhf.c \
-	src/e_cosh.c \
-	src/e_coshf.c \
-	src/e_exp.c \
-	src/e_expf.c \
-	src/e_fmod.c \
-	src/e_fmodf.c \
-	src/e_gamma.c \
-	src/e_gamma_r.c \
-	src/e_gammaf.c \
-	src/e_gammaf_r.c \
-	src/e_hypot.c \
-	src/e_hypotf.c \
-	src/e_j0.c \
-	src/e_j0f.c \
-	src/e_j1.c \
-	src/e_j1f.c \
-	src/e_jn.c \
-	src/e_jnf.c \
-	src/e_lgamma.c \
-	src/e_lgamma_r.c \
-	src/e_lgammaf.c \
-	src/e_lgammaf_r.c \
-	src/e_log.c \
-	src/e_log10.c \
-	src/e_log10f.c \
-	src/e_logf.c \
-	src/e_pow.c \
-	src/e_powf.c \
-	src/e_rem_pio2.c \
-	src/e_rem_pio2f.c \
-	src/e_remainder.c \
-	src/e_remainderf.c \
-	src/e_scalb.c \
-	src/e_scalbf.c \
-	src/e_sinh.c \
-	src/e_sinhf.c \
-	src/e_sqrt.c \
-	src/k_cos.c \
-	src/k_cosf.c \
-	src/k_rem_pio2.c \
-	src/k_sin.c \
-	src/k_sinf.c \
-	src/k_tan.c \
-	src/k_tanf.c \
-	src/s_asinh.c \
-	src/s_asinhf.c \
-	src/s_atan.c \
-	src/s_atanf.c \
-	src/s_cbrt.c \
-	src/s_cbrtf.c \
-	src/s_ceil.c \
-	src/s_ceilf.c \
-	src/s_ceill.c \
-	src/s_copysign.c \
-	src/s_copysignf.c \
-	src/s_cos.c \
-	src/s_cosf.c \
-	src/s_erf.c \
-	src/s_erff.c \
-	src/s_exp2.c \
-	src/s_exp2f.c \
-	src/s_expm1.c \
-	src/s_expm1f.c \
-	src/s_fabsf.c \
-	src/s_fdim.c \
-	src/s_finite.c \
-	src/s_finitef.c \
-	src/s_floor.c \
-	src/s_floorf.c \
-	src/s_floorl.c \
-	src/s_fma.c \
-	src/s_fmaf.c \
-	src/s_fmax.c \
-	src/s_fmaxf.c \
-	src/s_fmaxl.c \
-	src/s_fmin.c \
-	src/s_fminf.c \
-	src/s_fminl.c \
-	src/s_frexpf.c \
-	src/s_ilogb.c \
-	src/s_ilogbf.c \
-	src/s_ilogbl.c \
-	src/s_isfinite.c \
-	src/s_isnormal.c \
-	src/s_llrint.c \
-	src/s_llrintf.c \
-	src/s_llround.c \
-	src/s_llroundf.c \
-	src/s_llroundl.c \
-	src/s_log1p.c \
-	src/s_log1pf.c \
-	src/s_logb.c \
-	src/s_logbf.c \
-	src/s_lrint.c \
-	src/s_lrintf.c \
-	src/s_lround.c \
-	src/s_lroundf.c \
-	src/s_lroundl.c \
-	src/s_modff.c \
-	src/s_nan.c \
-	src/s_nearbyint.c \
-	src/s_nextafter.c \
-	src/s_nextafterf.c \
-	src/s_nexttowardf.c \
-	src/s_remquo.c \
-	src/s_remquof.c \
-	src/s_rint.c \
-	src/s_rintf.c \
-	src/s_round.c \
-	src/s_roundf.c \
-	src/s_roundl.c \
-	src/s_signbit.c \
-	src/s_signgam.c \
-	src/s_significand.c \
-	src/s_significandf.c \
-	src/s_sin.c \
-	src/s_sinf.c \
-	src/s_tan.c \
-	src/s_tanf.c \
-	src/s_tanh.c \
-	src/s_tanhf.c \
-	src/s_tgammaf.c \
-	src/s_trunc.c \
-	src/s_truncf.c \
-	src/s_truncl.c \
-	src/w_drem.c \
-	src/w_dremf.c \
-	src/s_copysignl.c \
-	src/s_fabsl.c \
-	src/s_fabs.c \
-	src/s_frexp.c \
-	src/s_isnan.c \
-	src/s_modf.c
+# TODO: these come from from upstream's libc, not libm!
+libm_common_src_files := \
+    digittoint.c  \
+    fpclassify.c \
+    isinf.c  \
 
-libm_common_cflags :=
+# TODO: this is not in the BSDs.
+libm_common_src_files += \
+    sincos.c \
 
-ifeq ($(TARGET_ARCH),arm)
-  libm_common_src_files += \
-	arm/fenv.c \
-	src/e_ldexpf.c \
-	src/s_scalbln.c \
-	src/s_scalbn.c \
-	src/s_scalbnf.c \
-	src/e_sqrtf.c
+libm_common_src_files += \
+    upstream-freebsd/lib/msun/bsdsrc/b_exp.c \
+    upstream-freebsd/lib/msun/bsdsrc/b_log.c \
+    upstream-freebsd/lib/msun/bsdsrc/b_tgamma.c \
+    upstream-freebsd/lib/msun/src/e_acos.c \
+    upstream-freebsd/lib/msun/src/e_acosf.c \
+    upstream-freebsd/lib/msun/src/e_acosh.c \
+    upstream-freebsd/lib/msun/src/e_acoshf.c \
+    upstream-freebsd/lib/msun/src/e_asin.c \
+    upstream-freebsd/lib/msun/src/e_asinf.c \
+    upstream-freebsd/lib/msun/src/e_atan2.c \
+    upstream-freebsd/lib/msun/src/e_atan2f.c \
+    upstream-freebsd/lib/msun/src/e_atanh.c \
+    upstream-freebsd/lib/msun/src/e_atanhf.c \
+    upstream-freebsd/lib/msun/src/e_cosh.c \
+    upstream-freebsd/lib/msun/src/e_coshf.c \
+    upstream-freebsd/lib/msun/src/e_exp.c \
+    upstream-freebsd/lib/msun/src/e_expf.c \
+    upstream-freebsd/lib/msun/src/e_fmod.c \
+    upstream-freebsd/lib/msun/src/e_fmodf.c \
+    upstream-freebsd/lib/msun/src/e_gamma.c \
+    upstream-freebsd/lib/msun/src/e_gammaf.c \
+    upstream-freebsd/lib/msun/src/e_gammaf_r.c \
+    upstream-freebsd/lib/msun/src/e_gamma_r.c \
+    upstream-freebsd/lib/msun/src/e_hypot.c \
+    upstream-freebsd/lib/msun/src/e_hypotf.c \
+    upstream-freebsd/lib/msun/src/e_j0.c \
+    upstream-freebsd/lib/msun/src/e_j0f.c \
+    upstream-freebsd/lib/msun/src/e_j1.c \
+    upstream-freebsd/lib/msun/src/e_j1f.c \
+    upstream-freebsd/lib/msun/src/e_jn.c \
+    upstream-freebsd/lib/msun/src/e_jnf.c \
+    upstream-freebsd/lib/msun/src/e_lgamma.c \
+    upstream-freebsd/lib/msun/src/e_lgammaf.c \
+    upstream-freebsd/lib/msun/src/e_lgammaf_r.c \
+    upstream-freebsd/lib/msun/src/e_lgamma_r.c \
+    upstream-freebsd/lib/msun/src/e_log10.c \
+    upstream-freebsd/lib/msun/src/e_log10f.c \
+    upstream-freebsd/lib/msun/src/e_log2.c \
+    upstream-freebsd/lib/msun/src/e_log2f.c \
+    upstream-freebsd/lib/msun/src/e_log.c \
+    upstream-freebsd/lib/msun/src/e_logf.c \
+    upstream-freebsd/lib/msun/src/e_pow.c \
+    upstream-freebsd/lib/msun/src/e_powf.c \
+    upstream-freebsd/lib/msun/src/e_remainder.c \
+    upstream-freebsd/lib/msun/src/e_remainderf.c \
+    upstream-freebsd/lib/msun/src/e_rem_pio2.c \
+    upstream-freebsd/lib/msun/src/e_rem_pio2f.c \
+    upstream-freebsd/lib/msun/src/e_scalb.c \
+    upstream-freebsd/lib/msun/src/e_scalbf.c \
+    upstream-freebsd/lib/msun/src/e_sinh.c \
+    upstream-freebsd/lib/msun/src/e_sinhf.c \
+    upstream-freebsd/lib/msun/src/e_sqrt.c \
+    upstream-freebsd/lib/msun/src/e_sqrtf.c \
+    upstream-freebsd/lib/msun/src/k_cos.c \
+    upstream-freebsd/lib/msun/src/k_cosf.c \
+    upstream-freebsd/lib/msun/src/k_exp.c \
+    upstream-freebsd/lib/msun/src/k_expf.c \
+    upstream-freebsd/lib/msun/src/k_rem_pio2.c \
+    upstream-freebsd/lib/msun/src/k_sin.c \
+    upstream-freebsd/lib/msun/src/k_sinf.c \
+    upstream-freebsd/lib/msun/src/k_tan.c \
+    upstream-freebsd/lib/msun/src/k_tanf.c \
+    upstream-freebsd/lib/msun/src/s_asinh.c \
+    upstream-freebsd/lib/msun/src/s_asinhf.c \
+    upstream-freebsd/lib/msun/src/s_atan.c \
+    upstream-freebsd/lib/msun/src/s_atanf.c \
+    upstream-freebsd/lib/msun/src/s_carg.c \
+    upstream-freebsd/lib/msun/src/s_cargf.c \
+    upstream-freebsd/lib/msun/src/s_cbrt.c \
+    upstream-freebsd/lib/msun/src/s_cbrtf.c \
+    upstream-freebsd/lib/msun/src/s_ccosh.c \
+    upstream-freebsd/lib/msun/src/s_ccoshf.c \
+    upstream-freebsd/lib/msun/src/s_ceil.c \
+    upstream-freebsd/lib/msun/src/s_ceilf.c \
+    upstream-freebsd/lib/msun/src/s_cexp.c \
+    upstream-freebsd/lib/msun/src/s_cexpf.c \
+    upstream-freebsd/lib/msun/src/s_cimag.c \
+    upstream-freebsd/lib/msun/src/s_cimagf.c \
+    upstream-freebsd/lib/msun/src/s_conj.c \
+    upstream-freebsd/lib/msun/src/s_conjf.c \
+    upstream-freebsd/lib/msun/src/s_copysign.c \
+    upstream-freebsd/lib/msun/src/s_copysignf.c \
+    upstream-freebsd/lib/msun/src/s_cos.c \
+    upstream-freebsd/lib/msun/src/s_cosf.c \
+    upstream-freebsd/lib/msun/src/s_cproj.c \
+    upstream-freebsd/lib/msun/src/s_cprojf.c \
+    upstream-freebsd/lib/msun/src/s_creal.c \
+    upstream-freebsd/lib/msun/src/s_crealf.c \
+    upstream-freebsd/lib/msun/src/s_csinh.c \
+    upstream-freebsd/lib/msun/src/s_csinhf.c \
+    upstream-freebsd/lib/msun/src/s_csqrt.c \
+    upstream-freebsd/lib/msun/src/s_csqrtf.c \
+    upstream-freebsd/lib/msun/src/s_ctanh.c \
+    upstream-freebsd/lib/msun/src/s_ctanhf.c \
+    upstream-freebsd/lib/msun/src/s_erf.c \
+    upstream-freebsd/lib/msun/src/s_erff.c \
+    upstream-freebsd/lib/msun/src/s_exp2.c \
+    upstream-freebsd/lib/msun/src/s_exp2f.c \
+    upstream-freebsd/lib/msun/src/s_expm1.c \
+    upstream-freebsd/lib/msun/src/s_expm1f.c \
+    upstream-freebsd/lib/msun/src/s_fabs.c \
+    upstream-freebsd/lib/msun/src/s_fabsf.c \
+    upstream-freebsd/lib/msun/src/s_fdim.c \
+    upstream-freebsd/lib/msun/src/s_finite.c \
+    upstream-freebsd/lib/msun/src/s_finitef.c \
+    upstream-freebsd/lib/msun/src/s_floor.c \
+    upstream-freebsd/lib/msun/src/s_floorf.c \
+    upstream-freebsd/lib/msun/src/s_fma.c \
+    upstream-freebsd/lib/msun/src/s_fmaf.c \
+    upstream-freebsd/lib/msun/src/s_fmax.c \
+    upstream-freebsd/lib/msun/src/s_fmaxf.c \
+    upstream-freebsd/lib/msun/src/s_fmin.c \
+    upstream-freebsd/lib/msun/src/s_fminf.c \
+    upstream-freebsd/lib/msun/src/s_frexp.c \
+    upstream-freebsd/lib/msun/src/s_frexpf.c \
+    upstream-freebsd/lib/msun/src/s_ilogb.c \
+    upstream-freebsd/lib/msun/src/s_ilogbf.c \
+    upstream-freebsd/lib/msun/src/s_isfinite.c \
+    upstream-freebsd/lib/msun/src/s_isnan.c \
+    upstream-freebsd/lib/msun/src/s_isnormal.c \
+    upstream-freebsd/lib/msun/src/s_llrint.c \
+    upstream-freebsd/lib/msun/src/s_llrintf.c \
+    upstream-freebsd/lib/msun/src/s_llround.c \
+    upstream-freebsd/lib/msun/src/s_llroundf.c \
+    upstream-freebsd/lib/msun/src/s_log1p.c \
+    upstream-freebsd/lib/msun/src/s_log1pf.c \
+    upstream-freebsd/lib/msun/src/s_logb.c \
+    upstream-freebsd/lib/msun/src/s_logbf.c \
+    upstream-freebsd/lib/msun/src/s_lrint.c \
+    upstream-freebsd/lib/msun/src/s_lrintf.c \
+    upstream-freebsd/lib/msun/src/s_lround.c \
+    upstream-freebsd/lib/msun/src/s_lroundf.c \
+    upstream-freebsd/lib/msun/src/s_modf.c \
+    upstream-freebsd/lib/msun/src/s_modff.c \
+    upstream-freebsd/lib/msun/src/s_nan.c \
+    upstream-freebsd/lib/msun/src/s_nearbyint.c \
+    upstream-freebsd/lib/msun/src/s_nextafter.c \
+    upstream-freebsd/lib/msun/src/s_nextafterf.c \
+    upstream-freebsd/lib/msun/src/s_nexttowardf.c \
+    upstream-freebsd/lib/msun/src/s_remquo.c \
+    upstream-freebsd/lib/msun/src/s_remquof.c \
+    upstream-freebsd/lib/msun/src/s_rint.c \
+    upstream-freebsd/lib/msun/src/s_rintf.c \
+    upstream-freebsd/lib/msun/src/s_round.c \
+    upstream-freebsd/lib/msun/src/s_roundf.c \
+    upstream-freebsd/lib/msun/src/s_scalbln.c \
+    upstream-freebsd/lib/msun/src/s_scalbn.c \
+    upstream-freebsd/lib/msun/src/s_scalbnf.c \
+    upstream-freebsd/lib/msun/src/s_signbit.c \
+    upstream-freebsd/lib/msun/src/s_signgam.c \
+    upstream-freebsd/lib/msun/src/s_significand.c \
+    upstream-freebsd/lib/msun/src/s_significandf.c \
+    upstream-freebsd/lib/msun/src/s_sin.c \
+    upstream-freebsd/lib/msun/src/s_sinf.c \
+    upstream-freebsd/lib/msun/src/s_tan.c \
+    upstream-freebsd/lib/msun/src/s_tanf.c \
+    upstream-freebsd/lib/msun/src/s_tanh.c \
+    upstream-freebsd/lib/msun/src/s_tanhf.c \
+    upstream-freebsd/lib/msun/src/s_tgammaf.c \
+    upstream-freebsd/lib/msun/src/s_trunc.c \
+    upstream-freebsd/lib/msun/src/s_truncf.c \
+    upstream-freebsd/lib/msun/src/w_cabs.c \
+    upstream-freebsd/lib/msun/src/w_cabsf.c \
+    upstream-freebsd/lib/msun/src/w_drem.c \
+    upstream-freebsd/lib/msun/src/w_dremf.c \
 
-  libm_common_includes = $(LOCAL_PATH)/arm
-endif
+libm_common_src_files += fake_long_double.c
 
-ifeq ($(TARGET_OS)-$(TARGET_ARCH),linux-x86)
-  libm_common_src_files += \
-	i387/fenv.c \
-	i387/s_scalbnl.S \
-	i387/s_scalbn.S \
-	i387/s_scalbnf.S \
-	i387/e_sqrtf.S
+# TODO: on Android, "long double" is "double".
+#    upstream-freebsd/lib/msun/src/e_acosl.c \
+#    upstream-freebsd/lib/msun/src/e_asinl.c \
+#    upstream-freebsd/lib/msun/src/e_atan2l.c \
+#    upstream-freebsd/lib/msun/src/e_fmodl.c \
+#    upstream-freebsd/lib/msun/src/e_hypotl.c \
+#    upstream-freebsd/lib/msun/src/e_remainderl.c \
+#    upstream-freebsd/lib/msun/src/e_sqrtl.c \
+#    upstream-freebsd/lib/msun/src/s_atanl.c \
+#    upstream-freebsd/lib/msun/src/s_cbrtl.c \
+#    upstream-freebsd/lib/msun/src/s_ceill.c \
+#    upstream-freebsd/lib/msun/src/s_copysignl.c \
+#    upstream-freebsd/lib/msun/src/s_cosl.c \
+#    upstream-freebsd/lib/msun/src/s_fabsl.c \
+#    upstream-freebsd/lib/msun/src/s_floorl.c \
+#    upstream-freebsd/lib/msun/src/s_fmal.c \
+#    upstream-freebsd/lib/msun/src/s_fmaxl.c \
+#    upstream-freebsd/lib/msun/src/s_fminl.c \
+#    upstream-freebsd/lib/msun/src/s_frexpl.c \
+#    upstream-freebsd/lib/msun/src/s_ilogbl.c \
+#    upstream-freebsd/lib/msun/src/s_llrintl.c \
+#    upstream-freebsd/lib/msun/src/s_llroundl.c \
+#    upstream-freebsd/lib/msun/src/s_logbl.c \
+#    upstream-freebsd/lib/msun/src/s_lrintl.c \
+#    upstream-freebsd/lib/msun/src/s_lroundl.c \
+#    upstream-freebsd/lib/msun/src/s_modfl.c \
+#    upstream-freebsd/lib/msun/src/s_nextafterl.c \
+#    upstream-freebsd/lib/msun/src/s_nexttoward.c \
+#    upstream-freebsd/lib/msun/src/s_remquol.c \
+#    upstream-freebsd/lib/msun/src/s_rintl.c \
+#    upstream-freebsd/lib/msun/src/s_roundl.c \
+#    upstream-freebsd/lib/msun/src/s_scalbnl.c \
+#    upstream-freebsd/lib/msun/src/s_sinl.c \
+#    upstream-freebsd/lib/msun/src/s_tanl.c \
+#    upstream-freebsd/lib/msun/src/s_truncl.c \
 
-  libm_common_includes = $(LOCAL_PATH)/i386 $(LOCAL_PATH)/i387
-endif
-ifeq ($(TARGET_ARCH),mips)
-  libm_common_src_files += \
-	mips/fenv.c \
-	src/e_ldexpf.c \
-	src/s_scalbln.c \
-	src/s_scalbn.c \
-	src/s_scalbnf.c \
-	src/e_sqrtf.c
+# TODO: re-enable i387/e_sqrtf.S for x86, and maybe others.
 
-  libm_common_includes = $(LOCAL_PATH)/mips
-  # Need to build *rint* functions
-  libm_common_cflags += -fno-builtin-rintf -fno-builtin-rint
-endif
+libm_common_cflags := -DFLT_EVAL_METHOD=0
+libm_common_includes := $(LOCAL_PATH)/upstream-freebsd/lib/msun/src/
 
-# libm.a
-# ========================================================
+libm_arm_includes := $(LOCAL_PATH)/arm
+libm_arm_src_files := arm/fenv.c
 
+libm_x86_includes := $(LOCAL_PATH)/i386 $(LOCAL_PATH)/i387
+libm_x86_src_files := i387/fenv.c
+
+libm_mips_cflags := -fno-builtin-rintf -fno-builtin-rint
+libm_mips_includes := $(LOCAL_PATH)/mips
+libm_mips_src_files := mips/fenv.c
+
+#
+# libm.a for target.
+#
 include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-    $(libm_common_src_files)
-
-LOCAL_ARM_MODE := arm
-LOCAL_C_INCLUDES += $(libm_common_includes)
-LOCAL_CFLAGS := $(libm_common_cflags)
-
 LOCAL_MODULE:= libm
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := $(libm_common_cflags) $(libm_$(TARGET_ARCH)_cflags)
+LOCAL_C_INCLUDES += $(libm_common_includes) $(libm_$(TARGET_ARCH)_includes)
+LOCAL_SRC_FILES := $(libm_common_src_files) $(libm_$(TARGET_ARCH)_src_files)
 LOCAL_SYSTEM_SHARED_LIBRARIES := libc
-
 include $(BUILD_STATIC_LIBRARY)
 
-# libm.so
-# ========================================================
-
+#
+# libm.so for target.
+#
 include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-    $(libm_common_src_files)
-
-LOCAL_ARM_MODE := arm
-
-LOCAL_C_INCLUDES += $(libm_common_includes)
-LOCAL_CFLAGS := $(libm_common_cflags)
-
 LOCAL_MODULE:= libm
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
 LOCAL_SYSTEM_SHARED_LIBRARIES := libc
-
+LOCAL_WHOLE_STATIC_LIBRARIES := libm
 include $(BUILD_SHARED_LIBRARY)
diff --git a/libm/Makefile-orig b/libm/Makefile-orig
deleted file mode 100644
index 46dd095..0000000
--- a/libm/Makefile-orig
+++ /dev/null
@@ -1,158 +0,0 @@
-#  @(#)Makefile 5.1beta 93/09/24
-# $FreeBSD: src/lib/msun/Makefile,v 1.74 2005/11/06 17:59:40 bde Exp $
-#
-#  ====================================================
-#  Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
-#
-#  Developed at SunPro, a Sun Microsystems, Inc. business.
-#  Permission to use, copy, modify, and distribute this
-#  software is freely granted, provided that this notice
-#  is preserved.
-#  ====================================================
-#
-#
-
-.if ${MACHINE_ARCH} == "i386"
-ARCH_SUBDIR= i387
-.else
-ARCH_SUBDIR= ${MACHINE_ARCH}
-.endif
-
-.include "${ARCH_SUBDIR}/Makefile.inc"
-
-.PATH:	${.CURDIR}/bsdsrc
-.PATH:	${.CURDIR}/man
-.PATH:	${.CURDIR}/src
-
-LIB=	m
-SHLIBDIR?= /lib
-SHLIB_MAJOR= 4
-COMMON_SRCS= b_exp.c b_log.c b_tgamma.c \
-	e_acos.c e_acosf.c e_acosh.c e_acoshf.c e_asin.c e_asinf.c \
-	e_atan2.c e_atan2f.c e_atanh.c e_atanhf.c e_cosh.c e_coshf.c e_exp.c \
-	e_expf.c e_fmod.c e_fmodf.c e_gamma.c e_gamma_r.c e_gammaf.c \
-	e_gammaf_r.c e_hypot.c e_hypotf.c e_j0.c e_j0f.c e_j1.c e_j1f.c \
-	e_jn.c e_jnf.c e_lgamma.c e_lgamma_r.c e_lgammaf.c e_lgammaf_r.c \
-	e_log.c e_log10.c e_log10f.c e_logf.c e_pow.c e_powf.c e_rem_pio2.c \
-	e_rem_pio2f.c e_remainder.c e_remainderf.c e_scalb.c e_scalbf.c \
-	e_sinh.c e_sinhf.c e_sqrt.c e_sqrtf.c fenv.c \
-	k_cos.c k_cosf.c k_rem_pio2.c k_sin.c k_sinf.c \
-	k_tan.c k_tanf.c \
-	s_asinh.c s_asinhf.c s_atan.c s_atanf.c s_cbrt.c s_cbrtf.c \
-	s_ceil.c s_ceilf.c s_ceill.c \
-	s_copysign.c s_copysignf.c s_cos.c s_cosf.c s_erf.c s_erff.c \
-	s_exp2.c s_exp2f.c s_expm1.c s_expm1f.c s_fabsf.c s_fdim.c \
-	s_finite.c s_finitef.c \
-	s_floor.c s_floorf.c s_floorl.c s_fma.c s_fmaf.c \
-	s_fmax.c s_fmaxf.c s_fmaxl.c s_fmin.c \
-	s_fminf.c s_fminl.c s_frexp.c s_frexpf.c s_ilogb.c s_ilogbf.c \
-	s_ilogbl.c s_isfinite.c s_isnan.c s_isnormal.c \
-	s_llrint.c s_llrintf.c s_llround.c s_llroundf.c s_llroundl.c \
-	s_log1p.c s_log1pf.c s_logb.c s_logbf.c s_lrint.c s_lrintf.c \
-	s_lround.c s_lroundf.c s_lroundl.c s_modff.c \
-	s_nearbyint.c s_nextafter.c s_nextafterf.c \
-	s_nexttowardf.c s_remquo.c s_remquof.c \
-	s_rint.c s_rintf.c s_round.c s_roundf.c s_roundl.c \
-	s_scalbln.c s_scalbn.c s_scalbnf.c s_signbit.c \
-	s_signgam.c s_significand.c s_significandf.c s_sin.c s_sinf.c s_tan.c \
-	s_tanf.c s_tanh.c s_tanhf.c s_trunc.c s_truncf.c s_truncl.c \
-	w_cabs.c w_cabsf.c w_drem.c w_dremf.c
-
-# Location of fpmath.h and _fpmath.h
-LIBCDIR=	${.CURDIR}/../libc
-CFLAGS+=	-I${LIBCDIR}/include -I${LIBCDIR}/${MACHINE_ARCH}
-
-# C99 long double functions
-COMMON_SRCS+=	s_copysignl.c s_fabsl.c
-.if ${LDBL_PREC} != 53
-# If long double != double use these; otherwise, we alias the double versions.
-COMMON_SRCS+=	s_fmal.c s_frexpl.c s_nextafterl.c s_nexttoward.c s_scalbnl.c
-.endif
-
-# C99 complex functions
-COMMON_SRCS+=	s_cimag.c s_cimagf.c s_cimagl.c s_conj.c s_conjf.c s_conjl.c \
-	s_creal.c s_crealf.c s_creall.c
-
-# FreeBSD's C library supplies these functions:
-#COMMON_SRCS+=	s_fabs.c s_frexp.c s_isnan.c s_ldexp.c s_modf.c
-
-# Exclude the generic versions of what we provide in the MD area.
-.PATH:	${.CURDIR}/${ARCH_SUBDIR}
-.if defined(ARCH_SRCS)
-.for i in ${ARCH_SRCS}
-COMMON_SRCS:=  ${COMMON_SRCS:N${i:R}.c}
-.endfor
-.endif
-
-SRCS=	${COMMON_SRCS} ${ARCH_SRCS}
-
-INCS=	fenv.h math.h
-
-MAN=	acos.3 acosh.3 asin.3 asinh.3 atan.3 atan2.3 atanh.3 ceil.3 \
-	cimag.3 copysign.3 cos.3 cosh.3 erf.3 exp.3 fabs.3 fdim.3 \
-	feclearexcept.3 feenableexcept.3 fegetenv.3 \
-	fegetround.3 fenv.3 floor.3 \
-	fma.3 fmax.3 fmod.3 hypot.3 ieee.3 ieee_test.3 ilogb.3 j0.3 \
-	lgamma.3 lrint.3 lround.3 math.3 nextafter.3 remainder.3 rint.3 \
-	round.3 scalbn.3 signbit.3 sin.3 sinh.3 sqrt.3 tan.3 tanh.3 trunc.3
-
-MLINKS+=acos.3 acosf.3
-MLINKS+=acosh.3 acoshf.3
-MLINKS+=asin.3 asinf.3
-MLINKS+=asinh.3 asinhf.3
-MLINKS+=atan.3 atanf.3
-MLINKS+=atanh.3 atanhf.3
-MLINKS+=atan2.3 atan2f.3
-MLINKS+=ceil.3 ceilf.3 ceil.3 ceill.3
-MLINKS+=cimag.3 cimagf.3 cimag.3 cimagl.3 \
-	cimag.3 conj.3 cimag.3 conjf.3 cimag.3 conjl.3 \
-	cimag.3 creal.3 cimag.3 crealf.3 cimag.3 creall.3
-MLINKS+=copysign.3 copysignf.3 copysign.3 copysignl.3
-MLINKS+=cos.3 cosf.3
-MLINKS+=cosh.3 coshf.3
-MLINKS+=erf.3 erfc.3 erf.3 erff.3 erf.3 erfcf.3
-MLINKS+=exp.3 expm1.3 exp.3 log.3 exp.3 log10.3 exp.3 log1p.3 exp.3 pow.3 \
-	exp.3 exp2.3 exp.3 exp2f.3 exp.3 expf.3 \
-	exp.3 expm1f.3 exp.3 logf.3 exp.3 powf.3 \
-	exp.3 log10f.3 exp.3 log1pf.3
-MLINKS+=fabs.3 fabsf.3 fabs.3 fabsl.3
-MLINKS+=fdim.3 fdimf.3 fdim.3 fdiml.3
-MLINKS+=feclearexcept.3 fegetexceptflag.3 feclearexcept.3 feraiseexcept.3 \
-	feclearexcept.3 fesetexceptflag.3 feclearexcept.3 fetestexcept.3
-MLINKS+=feenableexcept.3 fedisableexcept.3 feenableexcept.3 fegetexcept.3
-MLINKS+=fegetenv.3 feholdexcept.3 fegetenv.3 fesetenv.3 \
-	fegetenv.3 feupdateenv.3
-MLINKS+=fegetround.3 fesetround.3
-MLINKS+=floor.3 floorf.3 floor.3 floorl.3
-MLINKS+=fma.3 fmaf.3 fma.3 fmal.3
-MLINKS+=fmax.3 fmaxf.3 fmax.3 fmaxl.3 \
-	fmax.3 fmin.3 fmax.3 fminf.3 fmax.3 fminl.3
-MLINKS+=fmod.3 fmodf.3
-MLINKS+=hypot.3 cabs.3 hypot.3 cabsf.3 hypot.3 hypotf.3
-MLINKS+=ieee_test.3 scalb.3 ieee_test.3 scalbf.3
-MLINKS+=ieee_test.3 significand.3 ieee_test.3 significandf.3
-MLINKS+=ilogb.3 ilogbf.3 ilogb.3 ilogbl.3 \
-	ilogb.3 logb.3 ilogb.3 logbf.3
-MLINKS+=j0.3 j1.3 j0.3 jn.3 j0.3 y0.3 j0.3 y1.3 j0.3 y1f.3 j0.3 yn.3
-MLINKS+=j0.3 j0f.3 j0.3 j1f.3 j0.3 jnf.3 j0.3 y0f.3 j0.3 ynf.3
-MLINKS+=lgamma.3 gamma.3 lgamma.3 gammaf.3 lgamma.3 lgammaf.3 lgamma.3 tgamma.3
-MLINKS+=lrint.3 llrint.3 lrint.3 llrintf.3 lrint.3 lrintf.3
-MLINKS+=lround.3 llround.3 lround.3 llroundf.3 lround.3 llroundl.3 \
-	lround.3 lroundf.3 lround.3 lroundl.3
-MLINKS+=nextafter.3 nextafterf.3 nextafter.3 nextafterl.3
-MLINKS+=nextafter.3 nexttoward.3 nextafter.3 nexttowardf.3
-MLINKS+=nextafter.3 nexttowardl.3
-MLINKS+=remainder.3 remainderf.3
-MLINKS+=remainder.3 remquo.3 remainder.3 remquof.3
-MLINKS+=rint.3 rintf.3 rint.3 nearbyint.3 rint.3 nearbyintf.3
-MLINKS+=round.3 roundf.3 round.3 roundl.3
-MLINKS+=scalbn.3 scalbln.3 scalbn.3 scalblnf.3 scalbn.3 scalblnl.3
-MLINKS+=scalbn.3 scalbnf.3 scalbn.3 scalbnl.3
-MLINKS+=sin.3 sinf.3
-MLINKS+=sinh.3 sinhf.3
-MLINKS+=sqrt.3 cbrt.3 sqrt.3 cbrtf.3 sqrt.3 sqrtf.3
-MLINKS+=tan.3 tanf.3
-MLINKS+=tanh.3 tanhf.3
-MLINKS+=trunc.3 truncf.3 trunc.3 truncl.3
-
-.include <bsd.lib.mk>
diff --git a/libm/NOTICE b/libm/NOTICE
index c3968cd..d6d0ad9 100644
--- a/libm/NOTICE
+++ b/libm/NOTICE
@@ -1,13 +1,3 @@
- Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
-
- Developed at SunPro, a Sun Microsystems, Inc. business.
- Permission to use, copy, modify, and distribute this
- software is freely granted, provided that this notice
- is preserved.
- ====================================================
-
--------------------------------------------------------------------
-
 ====================================================
 Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
 
@@ -42,6 +32,35 @@
 -------------------------------------------------------------------
 
 ====================================================
+Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+
+Developed at SunSoft, a Sun Microsystems, Inc. business.
+Permission to use, copy, modify, and distribute this
+software is freely granted, provided that this notice
+is preserved.
+====================================================
+
+Optimized by Bruce D. Evans.
+
+-------------------------------------------------------------------
+
+====================================================
+Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+Copyright (c) 2009-2011, Bruce D. Evans, Steven G. Kargl, David Schultz.
+
+Developed at SunPro, a Sun Microsystems, Inc. business.
+Permission to use, copy, modify, and distribute this
+software is freely granted, provided that this notice
+is preserved.
+====================================================
+
+The argument reduction and testing for exceptional cases was
+written by Steven G. Kargl with input from Bruce D. Evans
+and David A. Schultz.
+
+-------------------------------------------------------------------
+
+====================================================
 Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
 
 Permission to use, copy, modify, and distribute this
@@ -59,6 +78,22 @@
 
 -------------------------------------------------------------------
 
+Copyright (C) 2013 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-------------------------------------------------------------------
+
 Copyright (c) 1985, 1993
    The Regents of the University of California.  All rights reserved.
 
@@ -190,7 +225,7 @@
 
 -------------------------------------------------------------------
 
-Copyright (c) 1993,94 Winning Strategies, Inc.
+Copyright (c) 2001-2011 The FreeBSD Project.
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -201,118 +236,18 @@
 2. Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in the
    documentation and/or other materials provided with the distribution.
-3. All advertising materials mentioning features or use of this software
-   must display the following acknowledgement:
-     This product includes software developed by Winning Strategies, Inc.
-4. The name of the author may not be used to endorse or promote products
-   derived from this software without specific prior written permission
 
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 1993,94 Winning Strategies, Inc.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. All advertising materials mentioning features or use of this software
-   must display the following acknowledgement:
-     This product includes software developed by Winning Strategies, Inc.
-4. The name of the author may not be used to endorse or promote products
-   derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 1994 Winning Strategies, Inc.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. All advertising materials mentioning features or use of this software
-   must display the following acknowledgement:
-     This product includes software developed by Winning Strategies, Inc.
-4. The name of the author may not be used to endorse or promote products
-   derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 1996 The NetBSD Foundation, Inc.
-All rights reserved.
-
-This code is derived from software contributed to The NetBSD Foundation
-by J.T. Conklin.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. All advertising materials mentioning features or use of this software
-   must display the following acknowledgement:
-       This product includes software developed by the NetBSD
-       Foundation, Inc. and its contributors.
-4. Neither the name of The NetBSD Foundation nor the names of its
-   contributors may be used to endorse or promote products derived
-   from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
-``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
-BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
 
 -------------------------------------------------------------------
 
@@ -370,32 +305,6 @@
 
 -------------------------------------------------------------------
 
-Copyright (c) 2003 David Schultz <das@FreeBSD.ORG>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
 Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
 All rights reserved.
 
@@ -580,6 +489,58 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 2004-2011 David Schultz <das@FreeBSD.ORG>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice unmodified, this list of conditions, and the following
+   disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
 Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
 All rights reserved.
 
@@ -606,6 +567,58 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 2005-2008 David Schultz <das@FreeBSD.ORG>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2005-2011 David Schultz <das@FreeBSD.ORG>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
 Copyright (c) 2007 David Schultz
 All rights reserved.
 
@@ -632,6 +645,119 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 2007 David Schultz <das@FreeBSD.ORG>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2007 David Schultz <das@FreeBSD.ORG>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+Derived from s_modf.c, which has the following Copyright:
+====================================================
+Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+
+Developed at SunPro, a Sun Microsystems, Inc. business.
+Permission to use, copy, modify, and distribute this
+software is freely granted, provided that this notice
+is preserved.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2007 Steven G. Kargl
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice unmodified, this list of conditions, and the following
+   disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2007-2008 David Schultz <das@FreeBSD.ORG>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
 Copyright (c) 2008 David Schultz <das@FreeBSD.ORG>
 All rights reserved.
 
@@ -684,6 +810,58 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 2011 David Schultz
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice unmodified, this list of conditions, and the following
+   disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2011 David Schultz <das@FreeBSD.ORG>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
 From: @(#)s_ilogb.c 5.1 93/09/24
 ====================================================
 Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
diff --git a/libm/alpha/Makefile.inc b/libm/alpha/Makefile.inc
deleted file mode 100644
index f75ace9..0000000
--- a/libm/alpha/Makefile.inc
+++ /dev/null
@@ -1,10 +0,0 @@
-# $FreeBSD: src/lib/msun/alpha/Makefile.inc,v 1.2 2005/03/07 04:53:35 das Exp $
-
-ARCH_SRCS = s_copysign.S s_copysignf.S
-LDBL_PREC = 53
-
-# XXX Comment from NetBSD/Alpha:
-# XXX LINT SIGFPEs in e_exp.c's strtod().  FP underflow/denorm software
-# handling is broken (doesn't exist!) on the Alpha port.
-# Stock gcc 2.7.2.1 doesn't understand these options.
-#CFLAGS += -mtrap-precision=i -mfp-trap-mode=su
diff --git a/libm/alpha/_fpmath.h b/libm/alpha/_fpmath.h
deleted file mode 100644
index cfa235c..0000000
--- a/libm/alpha/_fpmath.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * Copyright (c) 2002, 2003 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/libc/alpha/_fpmath.h,v 1.6 2005/03/07 04:55:21 das Exp $
- */
-
-union IEEEl2bits {
-	long double	e;
-	struct {
-		unsigned int	manl	:32;
-		unsigned int	manh	:20;
-		unsigned int	exp	:11;
-		unsigned int	sign	:1;
-	} bits;
-};
-
-#define	mask_nbit_l(u)	((void)0)
-#define	LDBL_IMPLICIT_NBIT
-#define	LDBL_NBIT	0
-
-#define	LDBL_MANH_SIZE	20
-#define	LDBL_MANL_SIZE	32
-
-#define	LDBL_TO_ARRAY32(u, a) do {			\
-	(a)[0] = (uint32_t)(u).bits.manl;		\
-	(a)[1] = (uint32_t)(u).bits.manh;		\
-} while(0)
diff --git a/libm/alpha/fenv.c b/libm/alpha/fenv.c
deleted file mode 100644
index e8ab204..0000000
--- a/libm/alpha/fenv.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*-
- * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/alpha/fenv.c,v 1.2 2005/03/16 19:03:44 das Exp $
- */
-
-#include <sys/cdefs.h>
-#include <machine/sysarch.h>
-#include <fenv.h>
-
-const fenv_t __fe_dfl_env = 0x680e000000000000ULL;
-
-struct mask_args {
-	fenv_t mask;
-};
-
-/*
- * The lower 49 bits of the FPCR are unused by the hardware, so we use
- * the lower order bits to store the kernel's idea of the FP mask as
- * described in the Alpha Architecture Manual.
- */
-int
-fegetenv(fenv_t *envp)
-{
-	struct mask_args p;
-	union __fpcr r;
-
-	/*
-	 * The syscall acts as an implicit exception barrier, so we
-	 * only need to issue an excb after the mf_fpcr to ensure that
-	 * the read is executed before any subsequent FP ops.
-	 */
-	sysarch(ALPHA_GET_FPMASK, (char *)&p);
-	__mf_fpcr(&r.__d);
-	*envp = r.__bits | p.mask;
-	__excb();
-	return (0);
-}
-
-int
-feholdexcept(fenv_t *envp)
-{
-	struct mask_args p;
-	union __fpcr r;
-
-	sysarch(ALPHA_GET_FPMASK, (char *)&p);
-	__mf_fpcr(&r.__d);
-	*envp = r.__bits | p.mask;
-	r.__bits &= ~((fenv_t)FE_ALL_EXCEPT << _FPUSW_SHIFT);
-	__mt_fpcr(r.__d);
-	if (p.mask & FE_ALL_EXCEPT) {
-		p.mask = 0;
-		sysarch(ALPHA_SET_FPMASK, &p);
-	}
-	__excb();
-	return (0);
-}
-
-int
-fesetenv(const fenv_t *envp)
-{
-	struct mask_args p;
-	union __fpcr r;
-
-	p.mask = *envp & FE_ALL_EXCEPT;
-	sysarch(ALPHA_SET_FPMASK, &p);
-	r.__bits = *envp & ~FE_ALL_EXCEPT;
-	__mt_fpcr(r.__d);
-	__excb();
-	return (0);
-}
-
-int
-feupdateenv(const fenv_t *envp)
-{
-	struct mask_args p;
-	union __fpcr oldr, newr;
-
-	p.mask = *envp & FE_ALL_EXCEPT;
-	sysarch(ALPHA_SET_FPMASK, &p);
-	__mf_fpcr(&oldr.__d);
-	newr.__bits = *envp & ~FE_ALL_EXCEPT;
-	__excb();
-	__mt_fpcr(newr.__d);
-	feraiseexcept((oldr.__bits >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
-	return (0); 
-}
-
-int
-__feenableexcept(int mask)
-{
-	struct mask_args p;
-
-	sysarch(ALPHA_GET_FPMASK, &p);
-	p.mask |= (mask & FE_ALL_EXCEPT);
-	sysarch(ALPHA_SET_FPMASK, &p);
-	return (p.mask);
-}
-
-int
-__fedisableexcept(int mask)
-{
-	struct mask_args p;
-
-	sysarch(ALPHA_GET_FPMASK, &p);
-	p.mask &= ~(mask & FE_ALL_EXCEPT);
-	sysarch(ALPHA_SET_FPMASK, &p);
-	return (p.mask);
-}
-
-int
-__fegetexcept(void)
-{
-	struct mask_args p;
-
-	sysarch(ALPHA_GET_FPMASK, &p);
-	return (p.mask);
-}
-
-__weak_reference(__feenableexcept, feenableexcept);
-__weak_reference(__fedisableexcept, fedisableexcept);
-__weak_reference(__fegetexcept, fegetexcept);
diff --git a/libm/alpha/fenv.h b/libm/alpha/fenv.h
deleted file mode 100644
index dc7bcb7..0000000
--- a/libm/alpha/fenv.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/*-
- * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/alpha/fenv.h,v 1.3 2005/03/16 19:03:44 das Exp $
- */
-
-#ifndef	_FENV_H_
-#define	_FENV_H_
-
-#include <sys/_types.h>
-
-typedef	__uint64_t	fenv_t;
-typedef	__uint16_t	fexcept_t;
-
-/* Exception flags */
-#define	FE_INVALID	0x02
-#define	FE_DIVBYZERO	0x04
-#define	FE_OVERFLOW	0x08
-#define	FE_UNDERFLOW	0x10
-#define	FE_INEXACT	0x20
-#define	FE_INTOVF	0x40	/* not maskable */
-#define	FE_ALL_EXCEPT	(FE_DIVBYZERO | FE_INEXACT | FE_INTOVF | \
-			 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
-
-/* Rounding modes */
-#define	FE_TOWARDZERO	0x00
-#define	FE_DOWNWARD	0x01
-#define	FE_TONEAREST	0x02
-#define	FE_UPWARD	0x03
-#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
-			 FE_UPWARD | FE_TOWARDZERO)
-#define	_ROUND_SHIFT	58
-
-#define	_FPUSW_SHIFT	51
-
-#define	__excb()	__asm __volatile("excb")
-#define	__mf_fpcr(__cw)	__asm __volatile("mf_fpcr %0" : "=f" (*(__cw)))
-#define	__mt_fpcr(__cw)	__asm __volatile("mt_fpcr %0" : : "f" (__cw))
-
-union __fpcr {
-	double __d;
-	fenv_t __bits;
-};
-
-__BEGIN_DECLS
-
-/* Default floating-point environment */
-extern const fenv_t	__fe_dfl_env;
-#define	FE_DFL_ENV	(&__fe_dfl_env)
-
-static __inline int
-feclearexcept(int __excepts)
-{
-	union __fpcr __r;
-
-	__excb();
-	__mf_fpcr(&__r.__d);
-	__r.__bits &= ~((fenv_t)__excepts << _FPUSW_SHIFT);
-	__mt_fpcr(__r.__d);
-	__excb();
-	return (0);
-}
-
-static __inline int
-fegetexceptflag(fexcept_t *__flagp, int __excepts)
-{
-	union __fpcr __r;
-
-	__excb();
-	__mf_fpcr(&__r.__d);
-	__excb();
-	*__flagp = (__r.__bits >> _FPUSW_SHIFT) & __excepts;
-	return (0);
-}
-
-static __inline int
-fesetexceptflag(const fexcept_t *__flagp, int __excepts)
-{
-	union __fpcr __r;
-	fenv_t __xflag, __xexcepts;
-
-	__xflag = (fenv_t)*__flagp << _FPUSW_SHIFT;
-	__xexcepts = (fenv_t)__excepts << _FPUSW_SHIFT;
-	__excb();
-	__mf_fpcr(&__r.__d);
-	__r.__bits &= ~__xexcepts;
-	__r.__bits |= __xflag & __xexcepts;
-	__mt_fpcr(__r.__d);
-	__excb();
-	return (0);
-}
-
-static __inline int
-feraiseexcept(int __excepts)
-{
-
-	/*
-	 * XXX Generating exceptions this way does not actually invoke
-	 * a userland trap handler when enabled, but neither do
-	 * arithmetic operations as far as I can tell.  Perhaps there
-	 * are more bugs in the kernel trap handler.
-	 */
-	fexcept_t __ex = __excepts;
-	fesetexceptflag(&__ex, __excepts);
-	return (0);
-}
-
-static __inline int
-fetestexcept(int __excepts)
-{
-	union __fpcr __r;
-
-	__excb();
-	__mf_fpcr(&__r.__d);
-	__excb();
-	return ((__r.__bits >> _FPUSW_SHIFT) & __excepts);
-}
-
-static __inline int
-fegetround(void)
-{
-	union __fpcr __r;
-
-	/*
-	 * No exception barriers should be required here if we assume
-	 * that only fesetround() can change the rounding mode.
-	 */
-	__mf_fpcr(&__r.__d);
-	return ((int)(__r.__bits >> _ROUND_SHIFT) & _ROUND_MASK);
-}
-
-static __inline int
-fesetround(int __round)
-{
-	union __fpcr __r;
-
-	if (__round & ~_ROUND_MASK)
-		return (-1);
-	__excb();
-	__mf_fpcr(&__r.__d);
-	__r.__bits &= ~((fenv_t)_ROUND_MASK << _ROUND_SHIFT);
-	__r.__bits |= (fenv_t)__round << _ROUND_SHIFT;
-	__mt_fpcr(__r.__d);
-	__excb();
-	return (0);
-}
-
-int	fegetenv(fenv_t *__envp);
-int	feholdexcept(fenv_t *__envp);
-int	fesetenv(const fenv_t *__envp);
-int	feupdateenv(const fenv_t *__envp);
-
-#if __BSD_VISIBLE
-
-int	feenableexcept(int __mask);
-int	fedisableexcept(int __mask);
-int	fegetexcept(void);
-
-#endif /* __BSD_VISIBLE */
-
-__END_DECLS
-
-#endif	/* !_FENV_H_ */
diff --git a/libm/alpha/s_copysign.S b/libm/alpha/s_copysign.S
deleted file mode 100644
index 12381bb..0000000
--- a/libm/alpha/s_copysign.S
+++ /dev/null
@@ -1,45 +0,0 @@
-/* $FreeBSD: src/lib/msun/alpha/s_copysign.S,v 1.2 1999/08/28 00:06:07 peter Exp $ */
-/*	From: NetBSD: s_copysign.S,v 1.3 1997/07/30 23:58:38 jtc Exp	*/
-
-/*-
- * Copyright (c) 1996 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by J.T. Conklin.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *        This product includes software developed by the NetBSD
- *        Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- *    contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <machine/asm.h>
-
-LEAF(copysign, 2)
-	cpys	fa1, fa0, fv0
-	RET
-END(copysign)
diff --git a/libm/alpha/s_copysignf.S b/libm/alpha/s_copysignf.S
deleted file mode 100644
index 2e5eda1..0000000
--- a/libm/alpha/s_copysignf.S
+++ /dev/null
@@ -1,45 +0,0 @@
-/* $FreeBSD: src/lib/msun/alpha/s_copysignf.S,v 1.2 1999/08/28 00:06:08 peter Exp $ */
-/*	From: NetBSD: s_copysignf.S,v 1.3 1997/07/30 23:58:41 jtc Exp */
-
-/*-
- * Copyright (c) 1996 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by J.T. Conklin.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *        This product includes software developed by the NetBSD
- *        Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- *    contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <machine/asm.h>
-
-LEAF(copysignf, 2)
-	cpys	fa1, fa0, fv0
-	RET
-END(copysignf)
diff --git a/libm/amd64/Makefile.inc b/libm/amd64/Makefile.inc
deleted file mode 100644
index 43da775..0000000
--- a/libm/amd64/Makefile.inc
+++ /dev/null
@@ -1,5 +0,0 @@
-# $FreeBSD: src/lib/msun/amd64/Makefile.inc,v 1.4 2005/04/16 21:12:55 das Exp $
-
-ARCH_SRCS = e_sqrt.S e_sqrtf.S s_llrint.S s_llrintf.S s_lrint.S s_lrintf.S \
-	    s_remquo.S s_remquof.S s_scalbn.S s_scalbnf.S s_scalbnl.S
-LDBL_PREC = 64
diff --git a/libm/amd64/_fpmath.h b/libm/amd64/_fpmath.h
deleted file mode 100644
index 801ec80..0000000
--- a/libm/amd64/_fpmath.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * Copyright (c) 2002, 2003 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/libc/amd64/_fpmath.h,v 1.6 2005/03/07 04:55:21 das Exp $
- */
-
-union IEEEl2bits {
-	long double	e;
-	struct {
-		unsigned int	manl	:32;
-		unsigned int	manh	:32;
-		unsigned int	exp	:15;
-		unsigned int	sign	:1;
-		unsigned int	junkl	:16;
-		unsigned int	junkh	:32;
-	} bits;
-};
-
-#define	LDBL_NBIT	0x80000000
-#define	mask_nbit_l(u)	((u).bits.manh &= ~LDBL_NBIT)
-
-#define	LDBL_MANH_SIZE	32
-#define	LDBL_MANL_SIZE	32
-
-#define	LDBL_TO_ARRAY32(u, a) do {			\
-	(a)[0] = (uint32_t)(u).bits.manl;		\
-	(a)[1] = (uint32_t)(u).bits.manh;		\
-} while(0)
diff --git a/libm/amd64/e_sqrt.S b/libm/amd64/e_sqrt.S
deleted file mode 100644
index 0429cce..0000000
--- a/libm/amd64/e_sqrt.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/amd64/e_sqrt.S,v 1.2 2005/02/04 14:08:32 das Exp $")
-	
-ENTRY(sqrt)
-	sqrtsd	%xmm0, %xmm0
-	ret
-
diff --git a/libm/amd64/e_sqrtf.S b/libm/amd64/e_sqrtf.S
deleted file mode 100644
index 471fa66..0000000
--- a/libm/amd64/e_sqrtf.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/amd64/e_sqrtf.S,v 1.1 2005/04/16 21:12:55 das Exp $")
-	
-ENTRY(sqrtf)
-	sqrtss	%xmm0, %xmm0
-	ret
diff --git a/libm/amd64/fenv.c b/libm/amd64/fenv.c
deleted file mode 100644
index 2b43678..0000000
--- a/libm/amd64/fenv.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*-
- * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/amd64/fenv.c,v 1.3 2005/03/16 19:03:45 das Exp $
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <machine/fpu.h>
-#include <fenv.h>
-
-const fenv_t __fe_dfl_env = {
-	{ 0xffff0000 | __INITIAL_FPUCW__,
-	  0xffff0000,
-	  0xffffffff,
-	  { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff }
-	},
-	__INITIAL_MXCSR__
-};
-
-int
-fesetexceptflag(const fexcept_t *flagp, int excepts)
-{
-	fenv_t env;
-
-	__fnstenv(&env.__x87);
-	env.__x87.__status &= ~excepts;
-	env.__x87.__status |= *flagp & excepts;
-	__fldenv(env.__x87);
-
-	__stmxcsr(&env.__mxcsr);
-	env.__mxcsr &= ~excepts;
-	env.__mxcsr |= *flagp & excepts;
-	__ldmxcsr(env.__mxcsr);
-
-	return (0);
-}
-
-int
-feraiseexcept(int excepts)
-{
-	fexcept_t ex = excepts;
-
-	fesetexceptflag(&ex, excepts);
-	__fwait();
-	return (0);
-}
-
-int
-fegetenv(fenv_t *envp)
-{
-	int control;
-
-	/*
-	 * fnstenv masks all exceptions, so we need to save and
-	 * restore the control word to avoid this side effect.
-	 */
-	__fnstcw(&control);
-	__fnstenv(&envp->__x87);
-	__stmxcsr(&envp->__mxcsr);
-	__fldcw(control);
-	return (0);
-}
-
-int
-feholdexcept(fenv_t *envp)
-{
-	int mxcsr;
-
-	__stmxcsr(&mxcsr);
-	__fnstenv(&envp->__x87);
-	__fnclex();
-	envp->__mxcsr = mxcsr;
-	mxcsr &= ~FE_ALL_EXCEPT;
-	mxcsr |= FE_ALL_EXCEPT << _SSE_EMASK_SHIFT;
-	__ldmxcsr(mxcsr);
-	return (0);
-}
-
-int
-feupdateenv(const fenv_t *envp)
-{
-	int mxcsr, status;
-
-	__fnstsw(&status);
-	__stmxcsr(&mxcsr);
-	fesetenv(envp);
-	feraiseexcept((mxcsr | status) & FE_ALL_EXCEPT);
-	return (0);
-}
-
-int
-__feenableexcept(int mask)
-{
-	int mxcsr, control, omask;
-
-	mask &= FE_ALL_EXCEPT;
-	__fnstcw(&control);
-	__stmxcsr(&mxcsr);
-	omask = (control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
-	control &= ~mask;
-	__fldcw(control);
-	mxcsr &= ~(mask << _SSE_EMASK_SHIFT);
-	__ldmxcsr(mxcsr);
-	return (~omask);
-}
-
-int
-__fedisableexcept(int mask)
-{
-	int mxcsr, control, omask;
-
-	mask &= FE_ALL_EXCEPT;
-	__fnstcw(&control);
-	__stmxcsr(&mxcsr);
-	omask = (control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
-	control |= mask;
-	__fldcw(control);
-	mxcsr |= mask << _SSE_EMASK_SHIFT;
-	__ldmxcsr(mxcsr);
-	return (~omask);
-}
-
-__weak_reference(__feenableexcept, feenableexcept);
-__weak_reference(__fedisableexcept, fedisableexcept);
diff --git a/libm/amd64/fenv.h b/libm/amd64/fenv.h
deleted file mode 100644
index c4f9432..0000000
--- a/libm/amd64/fenv.h
+++ /dev/null
@@ -1,203 +0,0 @@
-/*-
- * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/amd64/fenv.h,v 1.5 2005/03/16 22:34:14 das Exp $
- */
-
-#ifndef	_FENV_H_
-#define	_FENV_H_
-
-#include <sys/cdefs.h>
-#include <sys/_types.h>
-
-typedef struct {
-	struct {
-		__uint32_t	__control;
-		__uint32_t	__status;
-		__uint32_t	__tag;
-		char		__other[16];
-	} __x87;
-	__uint32_t		__mxcsr;
-} fenv_t;
-
-typedef	__uint16_t	fexcept_t;
-
-/* Exception flags */
-#define	FE_INVALID	0x01
-#define	FE_DENORMAL	0x02
-#define	FE_DIVBYZERO	0x04
-#define	FE_OVERFLOW	0x08
-#define	FE_UNDERFLOW	0x10
-#define	FE_INEXACT	0x20
-#define	FE_ALL_EXCEPT	(FE_DIVBYZERO | FE_DENORMAL | FE_INEXACT | \
-			 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
-
-/* Rounding modes */
-#define	FE_TONEAREST	0x0000
-#define	FE_DOWNWARD	0x0400
-#define	FE_UPWARD	0x0800
-#define	FE_TOWARDZERO	0x0c00
-#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
-			 FE_UPWARD | FE_TOWARDZERO)
-
-/*
- * As compared to the x87 control word, the SSE unit's control word
- * has the rounding control bits offset by 3 and the exception mask
- * bits offset by 7.
- */
-#define	_SSE_ROUND_SHIFT	3
-#define	_SSE_EMASK_SHIFT	7
-
-__BEGIN_DECLS
-
-/* Default floating-point environment */
-extern const fenv_t	__fe_dfl_env;
-#define	FE_DFL_ENV	(&__fe_dfl_env)
-
-#define	__fldcw(__cw)		__asm __volatile("fldcw %0" : : "m" (__cw))
-#define	__fldenv(__env)		__asm __volatile("fldenv %0" : : "m" (__env))
-#define	__fnclex()		__asm __volatile("fnclex")
-#define	__fnstenv(__env)	__asm __volatile("fnstenv %0" : "=m" (*(__env)))
-#define	__fnstcw(__cw)		__asm __volatile("fnstcw %0" : "=m" (*(__cw)))
-#define	__fnstsw(__sw)		__asm __volatile("fnstsw %0" : "=am" (*(__sw)))
-#define	__fwait()		__asm __volatile("fwait")
-#define	__ldmxcsr(__csr)	__asm __volatile("ldmxcsr %0" : : "m" (__csr))
-#define	__stmxcsr(__csr)	__asm __volatile("stmxcsr %0" : "=m" (*(__csr)))
-
-static __inline int
-feclearexcept(int __excepts)
-{
-	fenv_t __env;
-
-	if (__excepts == FE_ALL_EXCEPT) {
-		__fnclex();
-	} else {
-		__fnstenv(&__env.__x87);
-		__env.__x87.__status &= ~__excepts;
-		__fldenv(__env.__x87);
-	}
-	__stmxcsr(&__env.__mxcsr);
-	__env.__mxcsr &= ~__excepts;
-	__ldmxcsr(__env.__mxcsr);
-	return (0);
-}
-
-static __inline int
-fegetexceptflag(fexcept_t *__flagp, int __excepts)
-{
-	int __mxcsr, __status;
-
-	__stmxcsr(&__mxcsr);
-	__fnstsw(&__status);
-	*__flagp = (__mxcsr | __status) & __excepts;
-	return (0);
-}
-
-int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
-int feraiseexcept(int __excepts);
-
-static __inline int
-fetestexcept(int __excepts)
-{
-	int __mxcsr, __status;
-
-	__stmxcsr(&__mxcsr);
-	__fnstsw(&__status);
-	return ((__status | __mxcsr) & __excepts);
-}
-
-static __inline int
-fegetround(void)
-{
-	int __control;
-
-	/*
-	 * We assume that the x87 and the SSE unit agree on the
-	 * rounding mode.  Reading the control word on the x87 turns
-	 * out to be about 5 times faster than reading it on the SSE
-	 * unit on an Opteron 244.
-	 */
-	__fnstcw(&__control);
-	return (__control & _ROUND_MASK);
-}
-
-static __inline int
-fesetround(int __round)
-{
-	int __mxcsr, __control;
-
-	if (__round & ~_ROUND_MASK)
-		return (-1);
-
-	__fnstcw(&__control);
-	__control &= ~_ROUND_MASK;
-	__control |= __round;
-	__fldcw(__control);
-
-	__stmxcsr(&__mxcsr);
-	__mxcsr &= ~(_ROUND_MASK << _SSE_ROUND_SHIFT);
-	__mxcsr |= __round << _SSE_ROUND_SHIFT;
-	__ldmxcsr(__mxcsr);
-
-	return (0);
-}
-
-int fegetenv(fenv_t *__envp);
-int feholdexcept(fenv_t *__envp);
-
-static __inline int
-fesetenv(const fenv_t *__envp)
-{
-
-	__fldenv(__envp->__x87);
-	__ldmxcsr(__envp->__mxcsr);
-	return (0);
-}
-
-int feupdateenv(const fenv_t *__envp);
-
-#if __BSD_VISIBLE
-
-int feenableexcept(int __mask);
-int fedisableexcept(int __mask);
-
-static __inline int
-fegetexcept(void)
-{
-	int __control;
-
-	/*
-	 * We assume that the masks for the x87 and the SSE unit are
-	 * the same.
-	 */
-	__fnstcw(&__control);
-	return (~__control & FE_ALL_EXCEPT);
-}
-
-#endif /* __BSD_VISIBLE */
-
-__END_DECLS
-
-#endif	/* !_FENV_H_ */
diff --git a/libm/amd64/s_llrint.S b/libm/amd64/s_llrint.S
deleted file mode 100644
index b81c73a..0000000
--- a/libm/amd64/s_llrint.S
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/amd64/s_llrint.S,v 1.1 2005/01/15 03:32:28 das Exp $")
-	
-/* sizeof(long) == sizeof(long long) */
-#define	fn	llrint
-#include "s_lrint.S"
diff --git a/libm/amd64/s_llrintf.S b/libm/amd64/s_llrintf.S
deleted file mode 100644
index d62cfcb..0000000
--- a/libm/amd64/s_llrintf.S
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/amd64/s_llrintf.S,v 1.1 2005/04/16 21:12:55 das Exp $")
-	
-/* sizeof(long) == sizeof(long long) */
-#define	fn	llrintf
-#include "s_lrintf.S"
diff --git a/libm/amd64/s_lrint.S b/libm/amd64/s_lrint.S
deleted file mode 100644
index 161b731..0000000
--- a/libm/amd64/s_lrint.S
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <machine/asm.h>
-
-#ifndef fn
-__FBSDID("$FreeBSD: src/lib/msun/amd64/s_lrint.S,v 1.1 2005/01/15 03:32:28 das Exp $")
-#define	fn	lrint
-#endif
-
-ENTRY(fn)
-	cvtsd2si %xmm0, %rax
-	ret
diff --git a/libm/amd64/s_lrintf.S b/libm/amd64/s_lrintf.S
deleted file mode 100644
index 506e834..0000000
--- a/libm/amd64/s_lrintf.S
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <machine/asm.h>
-
-#ifndef fn
-__FBSDID("$FreeBSD: src/lib/msun/amd64/s_lrintf.S,v 1.1 2005/04/16 21:12:55 das Exp $")
-#define	fn	lrintf
-#endif
-
-ENTRY(fn)
-	cvtss2si %xmm0, %rax
-	ret
diff --git a/libm/amd64/s_remquo.S b/libm/amd64/s_remquo.S
deleted file mode 100644
index 19f3b53..0000000
--- a/libm/amd64/s_remquo.S
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Based on public-domain remainder routine by J.T. Conklin <jtc@NetBSD.org>.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/amd64/s_remquo.S,v 1.1 2005/03/25 04:40:44 das Exp $"); 
-	
-ENTRY(remquo)
-	movsd	%xmm0,-8(%rsp)
-	movsd	%xmm1,-16(%rsp)
-	fldl	-16(%rsp)
-	fldl	-8(%rsp)
-1:	fprem1
-	fstsw	%ax
-	btw	$10,%ax
-	jc	1b
-	fstp	%st(1)
-/* Extract the three low-order bits of the quotient from C0,C3,C1. */
-	shrl	$6,%eax
-	movl	%eax,%ecx
-	andl	$0x108,%eax
-	rorl	$7,%eax
-	orl	%eax,%ecx
-	roll	$4,%eax
-	orl	%ecx,%eax
-	andl	$7,%eax
-/* Negate the quotient bits if x*y<0.  Avoid using an unpredictable branch. */
-	movl	-12(%rsp),%ecx
-	xorl	-4(%rsp),%ecx
-	sarl	$16,%ecx
-	sarl	$16,%ecx
-	xorl	%ecx,%eax
-	andl	$1,%ecx
-	addl	%ecx,%eax
-/* Store the quotient and return. */
-	movl	%eax,(%rdi)
-	fstpl	-8(%rsp)
-	movsd	-8(%rsp),%xmm0
-	ret
diff --git a/libm/amd64/s_remquof.S b/libm/amd64/s_remquof.S
deleted file mode 100644
index 02b604f..0000000
--- a/libm/amd64/s_remquof.S
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Based on public-domain remainder routine by J.T. Conklin <jtc@NetBSD.org>.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/amd64/s_remquof.S,v 1.1 2005/03/25 04:40:44 das Exp $"); 
-	
-ENTRY(remquof)
-	movss	%xmm0,-4(%rsp)
-	movss	%xmm1,-8(%rsp)
-	flds	-8(%rsp)
-	flds	-4(%rsp)
-1:	fprem1
-	fstsw	%ax
-	btw	$10,%ax
-	jc	1b
-	fstp	%st(1)
-/* Extract the three low-order bits of the quotient from C0,C3,C1. */
-	shrl	$6,%eax
-	movl	%eax,%ecx
-	andl	$0x108,%eax
-	rorl	$7,%eax
-	orl	%eax,%ecx
-	roll	$4,%eax
-	orl	%ecx,%eax
-	andl	$7,%eax
-/* Negate the quotient bits if x*y<0.  Avoid using an unpredictable branch. */
-	movl	-8(%rsp),%ecx
-	xorl	-4(%rsp),%ecx
-	sarl	$16,%ecx
-	sarl	$16,%ecx
-	xorl	%ecx,%eax
-	andl	$1,%ecx
-	addl	%ecx,%eax
-/* Store the quotient and return. */
-	movl	%eax,(%rdi)
-	fstps	-4(%rsp)
-	movss	-4(%rsp),%xmm0
-	ret
diff --git a/libm/amd64/s_scalbn.S b/libm/amd64/s_scalbn.S
deleted file mode 100644
index 6942e18..0000000
--- a/libm/amd64/s_scalbn.S
+++ /dev/null
@@ -1,39 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/amd64/s_scalbn.S,v 1.1 2005/04/16 21:12:55 das Exp $")
-
-ENTRY(scalbn)
-	movsd	%xmm0,-8(%rsp)
-	movl	%edi,-12(%rsp)
-	fildl	-12(%rsp)
-	fldl	-8(%rsp)
-	fscale
-	fstp	%st(1)
-	fstpl	-8(%rsp)
-	movsd	-8(%rsp),%xmm0
-	ret
diff --git a/libm/amd64/s_scalbnf.S b/libm/amd64/s_scalbnf.S
deleted file mode 100644
index d7b9ab7..0000000
--- a/libm/amd64/s_scalbnf.S
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/amd64/s_scalbnf.S,v 1.2 2005/09/12 20:54:00 das Exp $")
-
-ENTRY(scalbnf)
-	movss	%xmm0,-8(%rsp)
-	movl	%edi,-4(%rsp)
-	fildl	-4(%rsp)
-	flds	-8(%rsp)
-	fscale
-	fstp	%st(1)
-	fstps	-8(%rsp)
-	movss	-8(%rsp),%xmm0
-	ret
-
-.globl CNAME(ldexpf)
-.set	CNAME(ldexpf),CNAME(scalbnf)
diff --git a/libm/amd64/s_scalbnl.S b/libm/amd64/s_scalbnl.S
deleted file mode 100644
index 57629a4..0000000
--- a/libm/amd64/s_scalbnl.S
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Based on code written by J.T. Conklin <jtc@netbsd.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/amd64/s_scalbnl.S,v 1.1 2005/04/16 21:12:55 das Exp $")
-/* RCSID("$NetBSD: s_scalbnf.S,v 1.4 1999/01/02 05:15:40 kristerw Exp $") */
-
-ENTRY(scalbnl)
-	movl	%edi,-4(%rsp)
-	fildl	-4(%rsp)
-	fldt	8(%rsp)
-	fscale
-	fstp	%st(1)
-	ret
-
-.globl	CNAME(ldexpl)
-.set	CNAME(ldexpl),CNAME(scalbnl)
diff --git a/libm/arm/Makefile.inc b/libm/arm/Makefile.inc
deleted file mode 100644
index 6559cc3..0000000
--- a/libm/arm/Makefile.inc
+++ /dev/null
@@ -1,3 +0,0 @@
-# $FreeBSD: src/lib/msun/arm/Makefile.inc,v 1.1 2005/03/07 04:53:35 das Exp $
-
-LDBL_PREC = 53
diff --git a/libm/arm/_fpmath.h b/libm/arm/_fpmath.h
index 79e4346..4c18945 100644
--- a/libm/arm/_fpmath.h
+++ b/libm/arm/_fpmath.h
@@ -23,18 +23,29 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libc/arm/_fpmath.h,v 1.4 2005/03/20 00:53:52 cognet Exp $
+ * $FreeBSD$
  */
 
+#if defined(__VFP_FP__)
+#define	_IEEE_WORD_ORDER	_BYTE_ORDER
+#else
+#define	_IEEE_WORD_ORDER	_BIG_ENDIAN
+#endif
+
 union IEEEl2bits {
 	long double	e;
 	struct {
-#ifndef __ARMEB__
+#if _BYTE_ORDER == _LITTLE_ENDIAN
+#if _IEEE_WORD_ORDER == _LITTLE_ENDIAN
 		unsigned int	manl	:32;
+#endif
 		unsigned int	manh	:20;
 		unsigned int	exp	:11;
 		unsigned int	sign	:1;
-#else
+#if _IEEE_WORD_ORDER == _BIG_ENDIAN
+		unsigned int	manl	:32;
+#endif
+#else	/* _BYTE_ORDER == _LITTLE_ENDIAN */
 		unsigned int		sign	:1;
 		unsigned int		exp	:11;
 		unsigned int		manh	:20;
@@ -44,9 +55,10 @@
 };
 
 #define	LDBL_NBIT	0
+#define	LDBL_IMPLICIT_NBIT
 #define	mask_nbit_l(u)	((void)0)
 
-#define	LDBL_MANH_SIZE	32
+#define	LDBL_MANH_SIZE	20
 #define	LDBL_MANL_SIZE	32
 
 #define	LDBL_TO_ARRAY32(u, a) do {			\
diff --git a/libm/arm/fenv.h b/libm/arm/fenv.h
deleted file mode 100644
index 534b12c..0000000
--- a/libm/arm/fenv.h
+++ /dev/null
@@ -1,218 +0,0 @@
-/*-
- * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/arm/fenv.h,v 1.5 2005/03/16 19:03:45 das Exp $
- */
-
-#ifndef	_FENV_H_
-#define	_FENV_H_
-
-#include <sys/types.h>
-
-__BEGIN_DECLS
-
-typedef	uint32_t	fenv_t;
-typedef	uint32_t	fexcept_t;
-
-/* Exception flags */
-#define	FE_INVALID	0x0001
-#define	FE_DIVBYZERO	0x0002
-#define	FE_OVERFLOW	0x0004
-#define	FE_UNDERFLOW	0x0008
-#define	FE_INEXACT	0x0010
-#define	FE_ALL_EXCEPT	(FE_DIVBYZERO | FE_INEXACT | \
-			 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
-
-/* Rounding modes */
-#define	FE_TONEAREST	0x0000
-#define	FE_TOWARDZERO	0x0001
-#define	FE_UPWARD	0x0002
-#define	FE_DOWNWARD	0x0003
-#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
-			 FE_UPWARD | FE_TOWARDZERO)
-
-/* Default floating-point environment */
-extern const fenv_t	__fe_dfl_env;
-#define	FE_DFL_ENV	(&__fe_dfl_env)
-
-/* We need to be able to map status flag positions to mask flag positions */
-#define _FPUSW_SHIFT	16
-#define	_ENABLE_MASK	(FE_ALL_EXCEPT << _FPUSW_SHIFT)
-
-#ifdef	ARM_HARD_FLOAT
-#define	__rfs(__fpsr)	__asm __volatile("rfs %0" : "=r" (*(__fpsr)))
-#define	__wfs(__fpsr)	__asm __volatile("wfs %0" : : "r" (__fpsr))
-#else
-#define __rfs(__fpsr)
-#define __wfs(__fpsr)
-#endif
-
-static __inline int
-feclearexcept(int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	__fpsr &= ~__excepts;
-	__wfs(__fpsr);
-	return (0);
-}
-
-static __inline int
-fegetexceptflag(fexcept_t *__flagp, int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	*__flagp = __fpsr & __excepts;
-	return (0);
-}
-
-static __inline int
-fesetexceptflag(const fexcept_t *__flagp, int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	__fpsr &= ~__excepts;
-	__fpsr |= *__flagp & __excepts;
-	__wfs(__fpsr);
-	return (0);
-}
-
-static __inline int
-feraiseexcept(int __excepts)
-{
-	fexcept_t __ex = __excepts;
-
-	fesetexceptflag(&__ex, __excepts);	/* XXX */
-	return (0);
-}
-
-static __inline int
-fetestexcept(int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	return (__fpsr & __excepts);
-}
-
-static __inline int
-fegetround(void)
-{
-
-	/*
-	 * Apparently, the rounding mode is specified as part of the
-	 * instruction format on ARM, so the dynamic rounding mode is
-	 * indeterminate.  Some FPUs may differ.
-	 */
-	return (-1);
-}
-
-static __inline int
-fesetround(int __round)
-{
-
-	return (-1);
-}
-
-static __inline int
-fegetenv(fenv_t *__envp)
-{
-
-	__rfs(__envp);
-	return (0);
-}
-
-static __inline int
-feholdexcept(fenv_t *__envp)
-{
-	fenv_t __env;
-
-	__rfs(&__env);
-	*__envp = __env;
-	__env &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
-	__wfs(__env);
-	return (0);
-}
-
-static __inline int
-fesetenv(const fenv_t *__envp)
-{
-
-	__wfs(*__envp);
-	return (0);
-}
-
-static __inline int
-feupdateenv(const fenv_t *__envp)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	__wfs(*__envp);
-	feraiseexcept(__fpsr & FE_ALL_EXCEPT);
-	return (0);
-}
-
-#if __BSD_VISIBLE
-
-static __inline int
-feenableexcept(int __mask)
-{
-	fenv_t __old_fpsr, __new_fpsr;
-
-	__rfs(&__old_fpsr);
-	__new_fpsr = __old_fpsr | (__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT;
-	__wfs(__new_fpsr);
-	return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
-}
-
-static __inline int
-fedisableexcept(int __mask)
-{
-	fenv_t __old_fpsr, __new_fpsr;
-
-	__rfs(&__old_fpsr);
-	__new_fpsr = __old_fpsr & ~((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
-	__wfs(__new_fpsr);
-	return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
-}
-
-static __inline int
-fegetexcept(void)
-{
-	fenv_t __fpsr;
-
-	__rfs(&__fpsr);
-	return ((__fpsr & _ENABLE_MASK) >> _FPUSW_SHIFT);
-}
-
-#endif /* __BSD_VISIBLE */
-
-__END_DECLS
-
-#endif	/* !_FENV_H_ */
diff --git a/libm/bsdsrc/b_exp.c b/libm/bsdsrc/b_exp.c
deleted file mode 100644
index 107bc89..0000000
--- a/libm/bsdsrc/b_exp.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (c) 1985, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)exp.c	8.1 (Berkeley) 6/4/93";
-#endif /* not lint */
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/bsdsrc/b_exp.c,v 1.7 2004/12/16 20:40:37 das Exp $"); */
-
-
-/* EXP(X)
- * RETURN THE EXPONENTIAL OF X
- * DOUBLE PRECISION (IEEE 53 bits, VAX D FORMAT 56 BITS)
- * CODED IN C BY K.C. NG, 1/19/85;
- * REVISED BY K.C. NG on 2/6/85, 2/15/85, 3/7/85, 3/24/85, 4/16/85, 6/14/86.
- *
- * Required system supported functions:
- *	scalb(x,n)
- *	copysign(x,y)
- *	finite(x)
- *
- * Method:
- *	1. Argument Reduction: given the input x, find r and integer k such
- *	   that
- *	                   x = k*ln2 + r,  |r| <= 0.5*ln2 .
- *	   r will be represented as r := z+c for better accuracy.
- *
- *	2. Compute exp(r) by
- *
- *		exp(r) = 1 + r + r*R1/(2-R1),
- *	   where
- *		R1 = x - x^2*(p1+x^2*(p2+x^2*(p3+x^2*(p4+p5*x^2)))).
- *
- *	3. exp(x) = 2^k * exp(r) .
- *
- * Special cases:
- *	exp(INF) is INF, exp(NaN) is NaN;
- *	exp(-INF)=  0;
- *	for finite argument, only exp(0)=1 is exact.
- *
- * Accuracy:
- *	exp(x) returns the exponential of x nearly rounded. In a test run
- *	with 1,156,000 random arguments on a VAX, the maximum observed
- *	error was 0.869 ulps (units in the last place).
- */
-
-#include "mathimpl.h"
-
-static const double p1 = 0x1.555555555553ep-3;
-static const double p2 = -0x1.6c16c16bebd93p-9;
-static const double p3 = 0x1.1566aaf25de2cp-14;
-static const double p4 = -0x1.bbd41c5d26bf1p-20;
-static const double p5 = 0x1.6376972bea4d0p-25;
-static const double ln2hi = 0x1.62e42fee00000p-1;
-static const double ln2lo = 0x1.a39ef35793c76p-33;
-static const double lnhuge = 0x1.6602b15b7ecf2p9;
-static const double lntiny = -0x1.77af8ebeae354p9;
-static const double invln2 = 0x1.71547652b82fep0;
-
-#if 0
-double exp(x)
-double x;
-{
-	double  z,hi,lo,c;
-	int k;
-
-#if !defined(vax)&&!defined(tahoe)
-	if(x!=x) return(x);	/* x is NaN */
-#endif	/* !defined(vax)&&!defined(tahoe) */
-	if( x <= lnhuge ) {
-		if( x >= lntiny ) {
-
-		    /* argument reduction : x --> x - k*ln2 */
-
-			k=invln2*x+copysign(0.5,x);	/* k=NINT(x/ln2) */
-
-		    /* express x-k*ln2 as hi-lo and let x=hi-lo rounded */
-
-			hi=x-k*ln2hi;
-			x=hi-(lo=k*ln2lo);
-
-		    /* return 2^k*[1+x+x*c/(2+c)]  */
-			z=x*x;
-			c= x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5))));
-			return  scalb(1.0+(hi-(lo-(x*c)/(2.0-c))),k);
-
-		}
-		/* end of x > lntiny */
-
-		else
-		     /* exp(-big#) underflows to zero */
-		     if(finite(x))  return(scalb(1.0,-5000));
-
-		     /* exp(-INF) is zero */
-		     else return(0.0);
-	}
-	/* end of x < lnhuge */
-
-	else
-	/* exp(INF) is INF, exp(+big#) overflows to INF */
-	    return( finite(x) ?  scalb(1.0,5000)  : x);
-}
-#endif
-
-/* returns exp(r = x + c) for |c| < |x| with no overlap.  */
-
-double __exp__D(x, c)
-double x, c;
-{
-	double  z,hi,lo;
-	int k;
-
-	if (x != x)	/* x is NaN */
-		return(x);
-	if ( x <= lnhuge ) {
-		if ( x >= lntiny ) {
-
-		    /* argument reduction : x --> x - k*ln2 */
-			z = invln2*x;
-			k = z + copysign(.5, x);
-
-		    /* express (x+c)-k*ln2 as hi-lo and let x=hi-lo rounded */
-
-			hi=(x-k*ln2hi);			/* Exact. */
-			x= hi - (lo = k*ln2lo-c);
-		    /* return 2^k*[1+x+x*c/(2+c)]  */
-			z=x*x;
-			c= x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5))));
-			c = (x*c)/(2.0-c);
-
-			return  scalb(1.+(hi-(lo - c)), k);
-		}
-		/* end of x > lntiny */
-
-		else
-		     /* exp(-big#) underflows to zero */
-		     if(finite(x))  return(scalb(1.0,-5000));
-
-		     /* exp(-INF) is zero */
-		     else return(0.0);
-	}
-	/* end of x < lnhuge */
-
-	else
-	/* exp(INF) is INF, exp(+big#) overflows to INF */
-	    return( finite(x) ?  scalb(1.0,5000)  : x);
-}
diff --git a/libm/bsdsrc/b_log.c b/libm/bsdsrc/b_log.c
deleted file mode 100644
index d4e5f65..0000000
--- a/libm/bsdsrc/b_log.c
+++ /dev/null
@@ -1,473 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)log.c	8.2 (Berkeley) 11/30/93";
-#endif /* not lint */
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/bsdsrc/b_log.c,v 1.8 2005/09/19 11:28:19 bde Exp $"); */
-
-#include <math.h>
-#include <errno.h>
-
-#include "mathimpl.h"
-
-/* Table-driven natural logarithm.
- *
- * This code was derived, with minor modifications, from:
- *	Peter Tang, "Table-Driven Implementation of the
- *	Logarithm in IEEE Floating-Point arithmetic." ACM Trans.
- *	Math Software, vol 16. no 4, pp 378-400, Dec 1990).
- *
- * Calculates log(2^m*F*(1+f/F)), |f/j| <= 1/256,
- * where F = j/128 for j an integer in [0, 128].
- *
- * log(2^m) = log2_hi*m + log2_tail*m
- * since m is an integer, the dominant term is exact.
- * m has at most 10 digits (for subnormal numbers),
- * and log2_hi has 11 trailing zero bits.
- *
- * log(F) = logF_hi[j] + logF_lo[j] is in tabular form in log_table.h
- * logF_hi[] + 512 is exact.
- *
- * log(1+f/F) = 2*f/(2*F + f) + 1/12 * (2*f/(2*F + f))**3 + ...
- * the leading term is calculated to extra precision in two
- * parts, the larger of which adds exactly to the dominant
- * m and F terms.
- * There are two cases:
- *	1. when m, j are non-zero (m | j), use absolute
- *	   precision for the leading term.
- *	2. when m = j = 0, |1-x| < 1/256, and log(x) ~= (x-1).
- *	   In this case, use a relative precision of 24 bits.
- * (This is done differently in the original paper)
- *
- * Special cases:
- *	0	return signalling -Inf
- *	neg	return signalling NaN
- *	+Inf	return +Inf
-*/
-
-#define N 128
-
-/* Table of log(Fj) = logF_head[j] + logF_tail[j], for Fj = 1+j/128.
- * Used for generation of extend precision logarithms.
- * The constant 35184372088832 is 2^45, so the divide is exact.
- * It ensures correct reading of logF_head, even for inaccurate
- * decimal-to-binary conversion routines.  (Everybody gets the
- * right answer for integers less than 2^53.)
- * Values for log(F) were generated using error < 10^-57 absolute
- * with the bc -l package.
-*/
-static double	A1 = 	  .08333333333333178827;
-static double	A2 = 	  .01250000000377174923;
-static double	A3 =	 .002232139987919447809;
-static double	A4 =	.0004348877777076145742;
-
-static double logF_head[N+1] = {
-	0.,
-	.007782140442060381246,
-	.015504186535963526694,
-	.023167059281547608406,
-	.030771658666765233647,
-	.038318864302141264488,
-	.045809536031242714670,
-	.053244514518837604555,
-	.060624621816486978786,
-	.067950661908525944454,
-	.075223421237524235039,
-	.082443669210988446138,
-	.089612158689760690322,
-	.096729626458454731618,
-	.103796793681567578460,
-	.110814366340264314203,
-	.117783035656430001836,
-	.124703478501032805070,
-	.131576357788617315236,
-	.138402322859292326029,
-	.145182009844575077295,
-	.151916042025732167530,
-	.158605030176659056451,
-	.165249572895390883786,
-	.171850256926518341060,
-	.178407657472689606947,
-	.184922338493834104156,
-	.191394852999565046047,
-	.197825743329758552135,
-	.204215541428766300668,
-	.210564769107350002741,
-	.216873938300523150246,
-	.223143551314024080056,
-	.229374101064877322642,
-	.235566071312860003672,
-	.241719936886966024758,
-	.247836163904594286577,
-	.253915209980732470285,
-	.259957524436686071567,
-	.265963548496984003577,
-	.271933715484010463114,
-	.277868451003087102435,
-	.283768173130738432519,
-	.289633292582948342896,
-	.295464212893421063199,
-	.301261330578199704177,
-	.307025035294827830512,
-	.312755710004239517729,
-	.318453731118097493890,
-	.324119468654316733591,
-	.329753286372579168528,
-	.335355541920762334484,
-	.340926586970454081892,
-	.346466767346100823488,
-	.351976423156884266063,
-	.357455888922231679316,
-	.362905493689140712376,
-	.368325561158599157352,
-	.373716409793814818840,
-	.379078352934811846353,
-	.384411698910298582632,
-	.389716751140440464951,
-	.394993808240542421117,
-	.400243164127459749579,
-	.405465108107819105498,
-	.410659924985338875558,
-	.415827895143593195825,
-	.420969294644237379543,
-	.426084395310681429691,
-	.431173464818130014464,
-	.436236766774527495726,
-	.441274560805140936281,
-	.446287102628048160113,
-	.451274644139630254358,
-	.456237433481874177232,
-	.461175715122408291790,
-	.466089729924533457960,
-	.470979715219073113985,
-	.475845904869856894947,
-	.480688529345570714212,
-	.485507815781602403149,
-	.490303988045525329653,
-	.495077266798034543171,
-	.499827869556611403822,
-	.504556010751912253908,
-	.509261901790523552335,
-	.513945751101346104405,
-	.518607764208354637958,
-	.523248143765158602036,
-	.527867089620485785417,
-	.532464798869114019908,
-	.537041465897345915436,
-	.541597282432121573947,
-	.546132437597407260909,
-	.550647117952394182793,
-	.555141507540611200965,
-	.559615787935399566777,
-	.564070138285387656651,
-	.568504735352689749561,
-	.572919753562018740922,
-	.577315365035246941260,
-	.581691739635061821900,
-	.586049045003164792433,
-	.590387446602107957005,
-	.594707107746216934174,
-	.599008189645246602594,
-	.603290851438941899687,
-	.607555250224322662688,
-	.611801541106615331955,
-	.616029877215623855590,
-	.620240409751204424537,
-	.624433288012369303032,
-	.628608659422752680256,
-	.632766669570628437213,
-	.636907462236194987781,
-	.641031179420679109171,
-	.645137961373620782978,
-	.649227946625615004450,
-	.653301272011958644725,
-	.657358072709030238911,
-	.661398482245203922502,
-	.665422632544505177065,
-	.669430653942981734871,
-	.673422675212350441142,
-	.677398823590920073911,
-	.681359224807238206267,
-	.685304003098281100392,
-	.689233281238557538017,
-	.693147180560117703862
-};
-
-static double logF_tail[N+1] = {
-	0.,
-	-.00000000000000543229938420049,
-	 .00000000000000172745674997061,
-	-.00000000000001323017818229233,
-	-.00000000000001154527628289872,
-	-.00000000000000466529469958300,
-	 .00000000000005148849572685810,
-	-.00000000000002532168943117445,
-	-.00000000000005213620639136504,
-	-.00000000000001819506003016881,
-	 .00000000000006329065958724544,
-	 .00000000000008614512936087814,
-	-.00000000000007355770219435028,
-	 .00000000000009638067658552277,
-	 .00000000000007598636597194141,
-	 .00000000000002579999128306990,
-	-.00000000000004654729747598444,
-	-.00000000000007556920687451336,
-	 .00000000000010195735223708472,
-	-.00000000000017319034406422306,
-	-.00000000000007718001336828098,
-	 .00000000000010980754099855238,
-	-.00000000000002047235780046195,
-	-.00000000000008372091099235912,
-	 .00000000000014088127937111135,
-	 .00000000000012869017157588257,
-	 .00000000000017788850778198106,
-	 .00000000000006440856150696891,
-	 .00000000000016132822667240822,
-	-.00000000000007540916511956188,
-	-.00000000000000036507188831790,
-	 .00000000000009120937249914984,
-	 .00000000000018567570959796010,
-	-.00000000000003149265065191483,
-	-.00000000000009309459495196889,
-	 .00000000000017914338601329117,
-	-.00000000000001302979717330866,
-	 .00000000000023097385217586939,
-	 .00000000000023999540484211737,
-	 .00000000000015393776174455408,
-	-.00000000000036870428315837678,
-	 .00000000000036920375082080089,
-	-.00000000000009383417223663699,
-	 .00000000000009433398189512690,
-	 .00000000000041481318704258568,
-	-.00000000000003792316480209314,
-	 .00000000000008403156304792424,
-	-.00000000000034262934348285429,
-	 .00000000000043712191957429145,
-	-.00000000000010475750058776541,
-	-.00000000000011118671389559323,
-	 .00000000000037549577257259853,
-	 .00000000000013912841212197565,
-	 .00000000000010775743037572640,
-	 .00000000000029391859187648000,
-	-.00000000000042790509060060774,
-	 .00000000000022774076114039555,
-	 .00000000000010849569622967912,
-	-.00000000000023073801945705758,
-	 .00000000000015761203773969435,
-	 .00000000000003345710269544082,
-	-.00000000000041525158063436123,
-	 .00000000000032655698896907146,
-	-.00000000000044704265010452446,
-	 .00000000000034527647952039772,
-	-.00000000000007048962392109746,
-	 .00000000000011776978751369214,
-	-.00000000000010774341461609578,
-	 .00000000000021863343293215910,
-	 .00000000000024132639491333131,
-	 .00000000000039057462209830700,
-	-.00000000000026570679203560751,
-	 .00000000000037135141919592021,
-	-.00000000000017166921336082431,
-	-.00000000000028658285157914353,
-	-.00000000000023812542263446809,
-	 .00000000000006576659768580062,
-	-.00000000000028210143846181267,
-	 .00000000000010701931762114254,
-	 .00000000000018119346366441110,
-	 .00000000000009840465278232627,
-	-.00000000000033149150282752542,
-	-.00000000000018302857356041668,
-	-.00000000000016207400156744949,
-	 .00000000000048303314949553201,
-	-.00000000000071560553172382115,
-	 .00000000000088821239518571855,
-	-.00000000000030900580513238244,
-	-.00000000000061076551972851496,
-	 .00000000000035659969663347830,
-	 .00000000000035782396591276383,
-	-.00000000000046226087001544578,
-	 .00000000000062279762917225156,
-	 .00000000000072838947272065741,
-	 .00000000000026809646615211673,
-	-.00000000000010960825046059278,
-	 .00000000000002311949383800537,
-	-.00000000000058469058005299247,
-	-.00000000000002103748251144494,
-	-.00000000000023323182945587408,
-	-.00000000000042333694288141916,
-	-.00000000000043933937969737844,
-	 .00000000000041341647073835565,
-	 .00000000000006841763641591466,
-	 .00000000000047585534004430641,
-	 .00000000000083679678674757695,
-	-.00000000000085763734646658640,
-	 .00000000000021913281229340092,
-	-.00000000000062242842536431148,
-	-.00000000000010983594325438430,
-	 .00000000000065310431377633651,
-	-.00000000000047580199021710769,
-	-.00000000000037854251265457040,
-	 .00000000000040939233218678664,
-	 .00000000000087424383914858291,
-	 .00000000000025218188456842882,
-	-.00000000000003608131360422557,
-	-.00000000000050518555924280902,
-	 .00000000000078699403323355317,
-	-.00000000000067020876961949060,
-	 .00000000000016108575753932458,
-	 .00000000000058527188436251509,
-	-.00000000000035246757297904791,
-	-.00000000000018372084495629058,
-	 .00000000000088606689813494916,
-	 .00000000000066486268071468700,
-	 .00000000000063831615170646519,
-	 .00000000000025144230728376072,
-	-.00000000000017239444525614834
-};
-
-#if 0
-double
-#ifdef _ANSI_SOURCE
-log(double x)
-#else
-log(x) double x;
-#endif
-{
-	int m, j;
-	double F, f, g, q, u, u2, v, zero = 0.0, one = 1.0;
-	volatile double u1;
-
-	/* Catch special cases */
-	if (x <= 0)
-		if (x == zero)	/* log(0) = -Inf */
-			return (-one/zero);
-		else		/* log(neg) = NaN */
-			return (zero/zero);
-	else if (!finite(x))
-		return (x+x);		/* x = NaN, Inf */
-
-	/* Argument reduction: 1 <= g < 2; x/2^m = g;	*/
-	/* y = F*(1 + f/F) for |f| <= 2^-8		*/
-
-	m = logb(x);
-	g = ldexp(x, -m);
-	if (m == -1022) {
-		j = logb(g), m += j;
-		g = ldexp(g, -j);
-	}
-	j = N*(g-1) + .5;
-	F = (1.0/N) * j + 1;	/* F*128 is an integer in [128, 512] */
-	f = g - F;
-
-	/* Approximate expansion for log(1+f/F) ~= u + q */
-	g = 1/(2*F+f);
-	u = 2*f*g;
-	v = u*u;
-	q = u*v*(A1 + v*(A2 + v*(A3 + v*A4)));
-
-    /* case 1: u1 = u rounded to 2^-43 absolute.  Since u < 2^-8,
-     * 	       u1 has at most 35 bits, and F*u1 is exact, as F has < 8 bits.
-     *         It also adds exactly to |m*log2_hi + log_F_head[j] | < 750
-    */
-	if (m | j)
-		u1 = u + 513, u1 -= 513;
-
-    /* case 2:	|1-x| < 1/256. The m- and j- dependent terms are zero;
-     * 		u1 = u to 24 bits.
-    */
-	else
-		u1 = u, TRUNC(u1);
-	u2 = (2.0*(f - F*u1) - u1*f) * g;
-			/* u1 + u2 = 2f/(2F+f) to extra precision.	*/
-
-	/* log(x) = log(2^m*F*(1+f/F)) =				*/
-	/* (m*log2_hi+logF_head[j]+u1) + (m*log2_lo+logF_tail[j]+q);	*/
-	/* (exact) + (tiny)						*/
-
-	u1 += m*logF_head[N] + logF_head[j];		/* exact */
-	u2 = (u2 + logF_tail[j]) + q;			/* tiny */
-	u2 += logF_tail[N]*m;
-	return (u1 + u2);
-}
-#endif
-
-/*
- * Extra precision variant, returning struct {double a, b;};
- * log(x) = a+b to 63 bits, with a rounded to 26 bits.
- */
-struct Double
-#ifdef _ANSI_SOURCE
-__log__D(double x)
-#else
-__log__D(x) double x;
-#endif
-{
-	int m, j;
-	double F, f, g, q, u, v, u2;
-	volatile double u1;
-	struct Double r;
-
-	/* Argument reduction: 1 <= g < 2; x/2^m = g;	*/
-	/* y = F*(1 + f/F) for |f| <= 2^-8		*/
-
-	m = logb(x);
-	g = ldexp(x, -m);
-	if (m == -1022) {
-		j = logb(g), m += j;
-		g = ldexp(g, -j);
-	}
-	j = N*(g-1) + .5;
-	F = (1.0/N) * j + 1;
-	f = g - F;
-
-	g = 1/(2*F+f);
-	u = 2*f*g;
-	v = u*u;
-	q = u*v*(A1 + v*(A2 + v*(A3 + v*A4)));
-	if (m | j)
-		u1 = u + 513, u1 -= 513;
-	else
-		u1 = u, TRUNC(u1);
-	u2 = (2.0*(f - F*u1) - u1*f) * g;
-
-	u1 += m*logF_head[N] + logF_head[j];
-
-	u2 +=  logF_tail[j]; u2 += q;
-	u2 += logF_tail[N]*m;
-	r.a = u1 + u2;			/* Only difference is here */
-	TRUNC(r.a);
-	r.b = (u1 - r.a) + u2;
-	return (r);
-}
diff --git a/libm/bsdsrc/b_tgamma.c b/libm/bsdsrc/b_tgamma.c
deleted file mode 100644
index ff6c5ac..0000000
--- a/libm/bsdsrc/b_tgamma.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/*-
- * Copyright (c) 1992, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)gamma.c	8.1 (Berkeley) 6/4/93";
-#endif /* not lint */
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/bsdsrc/b_tgamma.c,v 1.7 2005/09/19 11:28:19 bde Exp $"); */
-
-/*
- * This code by P. McIlroy, Oct 1992;
- *
- * The financial support of UUNET Communications Services is greatfully
- * acknowledged.
- */
-
-//#include <math.h>
-#include "../include/math.h"
-#include "mathimpl.h"
-#include <errno.h>
-
-/* METHOD:
- * x < 0: Use reflection formula, G(x) = pi/(sin(pi*x)*x*G(x))
- * 	At negative integers, return +Inf, and set errno.
- *
- * x < 6.5:
- *	Use argument reduction G(x+1) = xG(x) to reach the
- *	range [1.066124,2.066124].  Use a rational
- *	approximation centered at the minimum (x0+1) to
- *	ensure monotonicity.
- *
- * x >= 6.5: Use the asymptotic approximation (Stirling's formula)
- *	adjusted for equal-ripples:
- *
- *	log(G(x)) ~= (x-.5)*(log(x)-1) + .5(log(2*pi)-1) + 1/x*P(1/(x*x))
- *
- *	Keep extra precision in multiplying (x-.5)(log(x)-1), to
- *	avoid premature round-off.
- *
- * Special values:
- *	non-positive integer:	Set overflow trap; return +Inf;
- *	x > 171.63:		Set overflow trap; return +Inf;
- *	NaN: 			Set invalid trap;  return NaN
- *
- * Accuracy: Gamma(x) is accurate to within
- *	x > 0:  error provably < 0.9ulp.
- *	Maximum observed in 1,000,000 trials was .87ulp.
- *	x < 0:
- *	Maximum observed error < 4ulp in 1,000,000 trials.
- */
-
-static double neg_gam(double);
-static double small_gam(double);
-static double smaller_gam(double);
-static struct Double large_gam(double);
-static struct Double ratfun_gam(double, double);
-
-/*
- * Rational approximation, A0 + x*x*P(x)/Q(x), on the interval
- * [1.066.., 2.066..] accurate to 4.25e-19.
- */
-#define LEFT -.3955078125	/* left boundary for rat. approx */
-#define x0 .461632144968362356785	/* xmin - 1 */
-
-#define a0_hi 0.88560319441088874992
-#define a0_lo -.00000000000000004996427036469019695
-#define P0	 6.21389571821820863029017800727e-01
-#define P1	 2.65757198651533466104979197553e-01
-#define P2	 5.53859446429917461063308081748e-03
-#define P3	 1.38456698304096573887145282811e-03
-#define P4	 2.40659950032711365819348969808e-03
-#define Q0	 1.45019531250000000000000000000e+00
-#define Q1	 1.06258521948016171343454061571e+00
-#define Q2	-2.07474561943859936441469926649e-01
-#define Q3	-1.46734131782005422506287573015e-01
-#define Q4	 3.07878176156175520361557573779e-02
-#define Q5	 5.12449347980666221336054633184e-03
-#define Q6	-1.76012741431666995019222898833e-03
-#define Q7	 9.35021023573788935372153030556e-05
-#define Q8	 6.13275507472443958924745652239e-06
-/*
- * Constants for large x approximation (x in [6, Inf])
- * (Accurate to 2.8*10^-19 absolute)
- */
-#define lns2pi_hi 0.418945312500000
-#define lns2pi_lo -.000006779295327258219670263595
-#define Pa0	 8.33333333333333148296162562474e-02
-#define Pa1	-2.77777777774548123579378966497e-03
-#define Pa2	 7.93650778754435631476282786423e-04
-#define Pa3	-5.95235082566672847950717262222e-04
-#define Pa4	 8.41428560346653702135821806252e-04
-#define Pa5	-1.89773526463879200348872089421e-03
-#define Pa6	 5.69394463439411649408050664078e-03
-#define Pa7	-1.44705562421428915453880392761e-02
-
-static const double zero = 0., one = 1.0, tiny = 1e-300;
-
-double
-tgamma(x)
-	double x;
-{
-	struct Double u;
-
-	if (x >= 6) {
-		if(x > 171.63)
-			return(one/zero);
-		u = large_gam(x);
-		return(__exp__D(u.a, u.b));
-	} else if (x >= 1.0 + LEFT + x0)
-		return (small_gam(x));
-	else if (x > 1.e-17)
-		return (smaller_gam(x));
-	else if (x > -1.e-17) {
-		if (x == 0.0)
-			return (one/x);
-		one+1e-20;		/* Raise inexact flag. */
-		return (one/x);
-	} else if (!finite(x))
-		return (x*x);		/* x = NaN, -Inf */
-	else
-		return (neg_gam(x));
-}
-/*
- * Accurate to max(ulp(1/128) absolute, 2^-66 relative) error.
- */
-static struct Double
-large_gam(x)
-	double x;
-{
-	double z, p;
-	struct Double t, u, v;
-
-	z = one/(x*x);
-	p = Pa0+z*(Pa1+z*(Pa2+z*(Pa3+z*(Pa4+z*(Pa5+z*(Pa6+z*Pa7))))));
-	p = p/x;
-
-	u = __log__D(x);
-	u.a -= one;
-	v.a = (x -= .5);
-	TRUNC(v.a);
-	v.b = x - v.a;
-	t.a = v.a*u.a;			/* t = (x-.5)*(log(x)-1) */
-	t.b = v.b*u.a + x*u.b;
-	/* return t.a + t.b + lns2pi_hi + lns2pi_lo + p */
-	t.b += lns2pi_lo; t.b += p;
-	u.a = lns2pi_hi + t.b; u.a += t.a;
-	u.b = t.a - u.a;
-	u.b += lns2pi_hi; u.b += t.b;
-	return (u);
-}
-/*
- * Good to < 1 ulp.  (provably .90 ulp; .87 ulp on 1,000,000 runs.)
- * It also has correct monotonicity.
- */
-static double
-small_gam(x)
-	double x;
-{
-	double y, ym1, t;
-	struct Double yy, r;
-	y = x - one;
-	ym1 = y - one;
-	if (y <= 1.0 + (LEFT + x0)) {
-		yy = ratfun_gam(y - x0, 0);
-		return (yy.a + yy.b);
-	}
-	r.a = y;
-	TRUNC(r.a);
-	yy.a = r.a - one;
-	y = ym1;
-	yy.b = r.b = y - yy.a;
-	/* Argument reduction: G(x+1) = x*G(x) */
-	for (ym1 = y-one; ym1 > LEFT + x0; y = ym1--, yy.a--) {
-		t = r.a*yy.a;
-		r.b = r.a*yy.b + y*r.b;
-		r.a = t;
-		TRUNC(r.a);
-		r.b += (t - r.a);
-	}
-	/* Return r*tgamma(y). */
-	yy = ratfun_gam(y - x0, 0);
-	y = r.b*(yy.a + yy.b) + r.a*yy.b;
-	y += yy.a*r.a;
-	return (y);
-}
-/*
- * Good on (0, 1+x0+LEFT].  Accurate to 1ulp.
- */
-static double
-smaller_gam(x)
-	double x;
-{
-	double t, d;
-	struct Double r, xx;
-	if (x < x0 + LEFT) {
-		t = x, TRUNC(t);
-		d = (t+x)*(x-t);
-		t *= t;
-		xx.a = (t + x), TRUNC(xx.a);
-		xx.b = x - xx.a; xx.b += t; xx.b += d;
-		t = (one-x0); t += x;
-		d = (one-x0); d -= t; d += x;
-		x = xx.a + xx.b;
-	} else {
-		xx.a =  x, TRUNC(xx.a);
-		xx.b = x - xx.a;
-		t = x - x0;
-		d = (-x0 -t); d += x;
-	}
-	r = ratfun_gam(t, d);
-	d = r.a/x, TRUNC(d);
-	r.a -= d*xx.a; r.a -= d*xx.b; r.a += r.b;
-	return (d + r.a/x);
-}
-/*
- * returns (z+c)^2 * P(z)/Q(z) + a0
- */
-static struct Double
-ratfun_gam(z, c)
-	double z, c;
-{
-	double p, q;
-	struct Double r, t;
-
-	q = Q0 +z*(Q1+z*(Q2+z*(Q3+z*(Q4+z*(Q5+z*(Q6+z*(Q7+z*Q8)))))));
-	p = P0 + z*(P1 + z*(P2 + z*(P3 + z*P4)));
-
-	/* return r.a + r.b = a0 + (z+c)^2*p/q, with r.a truncated to 26 bits. */
-	p = p/q;
-	t.a = z, TRUNC(t.a);		/* t ~= z + c */
-	t.b = (z - t.a) + c;
-	t.b *= (t.a + z);
-	q = (t.a *= t.a);		/* t = (z+c)^2 */
-	TRUNC(t.a);
-	t.b += (q - t.a);
-	r.a = p, TRUNC(r.a);		/* r = P/Q */
-	r.b = p - r.a;
-	t.b = t.b*p + t.a*r.b + a0_lo;
-	t.a *= r.a;			/* t = (z+c)^2*(P/Q) */
-	r.a = t.a + a0_hi, TRUNC(r.a);
-	r.b = ((a0_hi-r.a) + t.a) + t.b;
-	return (r);			/* r = a0 + t */
-}
-
-static double
-neg_gam(x)
-	double x;
-{
-	int sgn = 1;
-	struct Double lg, lsine;
-	double y, z;
-
-	y = floor(x + .5);
-	if (y == x)		/* Negative integer. */
-		return (one/zero);
-	z = fabs(x - y);
-	y = .5*ceil(x);
-	if (y == ceil(y))
-		sgn = -1;
-	if (z < .25)
-		z = sin(M_PI*z);
-	else
-		z = cos(M_PI*(0.5-z));
-	/* Special case: G(1-x) = Inf; G(x) may be nonzero. */
-	if (x < -170) {
-		if (x < -190)
-			return ((double)sgn*tiny*tiny);
-		y = one - x;		/* exact: 128 < |x| < 255 */
-		lg = large_gam(y);
-		lsine = __log__D(M_PI/z);	/* = TRUNC(log(u)) + small */
-		lg.a -= lsine.a;		/* exact (opposite signs) */
-		lg.b -= lsine.b;
-		y = -(lg.a + lg.b);
-		z = (y + lg.a) + lg.b;
-		y = __exp__D(y, z);
-		if (sgn < 0) y = -y;
-		return (y);
-	}
-	y = one-x;
-	if (one-y == x)
-		y = tgamma(y);
-	else		/* 1-x is inexact */
-		y = -x*tgamma(-x);
-	if (sgn < 0) y = -y;
-	return (M_PI / (y*z));
-}
diff --git a/libm/bsdsrc/mathimpl.h b/libm/bsdsrc/mathimpl.h
deleted file mode 100644
index 2a3b246..0000000
--- a/libm/bsdsrc/mathimpl.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 1988, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *	@(#)mathimpl.h	8.1 (Berkeley) 6/4/93
- * $FreeBSD: src/lib/msun/bsdsrc/mathimpl.h,v 1.7 2005/11/18 05:03:12 bde Exp $
- */
-
-#ifndef _MATHIMPL_H_
-#define	_MATHIMPL_H_
-
-#include <sys/cdefs.h>
-#include <math.h>
-
-#include "../src/math_private.h"
-
-/*
- * TRUNC() is a macro that sets the trailing 27 bits in the mantissa of an
- * IEEE double variable to zero.  It must be expression-like for syntactic
- * reasons, and we implement this expression using an inline function
- * instead of a pure macro to avoid depending on the gcc feature of
- * statement-expressions.
- */
-#define	TRUNC(d)	(_b_trunc(&(d)))
-
-static __inline void
-_b_trunc(volatile double *_dp)
-{
-	uint32_t _lw;
-
-	GET_LOW_WORD(_lw, *_dp);
-	SET_LOW_WORD(*_dp, _lw & 0xf8000000);
-}
-
-struct Double {
-	double	a;
-	double	b;
-};
-
-/*
- * Functions internal to the math package, yet not static.
- */
-double	__exp__D(double, double);
-struct Double __log__D(double);
-
-#endif /* !_MATHIMPL_H_ */
diff --git a/libm/digittoint.c b/libm/digittoint.c
new file mode 100644
index 0000000..1824788
--- /dev/null
+++ b/libm/digittoint.c
@@ -0,0 +1,46 @@
+/*-
+ * Copyright (c) 2007 David Schultz
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/cdefs.h>
+
+/* digittoint is in the FreeBSD C library, but implemented in terms of locale stuff. */
+__LIBC_HIDDEN__ int digittoint(char ch) {
+  int d = ch - '0';
+  if ((unsigned) d < 10) {
+    return d;
+  }
+  d = ch - 'a';
+  if ((unsigned) d < 6) {
+    return d + 10;
+  }
+  d = ch - 'A';
+  if ((unsigned) d < 6) {
+    return d + 10;
+  }
+  return -1;
+}
diff --git a/libm/fake_long_double.c b/libm/fake_long_double.c
new file mode 100644
index 0000000..fab32fe
--- /dev/null
+++ b/libm/fake_long_double.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <float.h>
+#include <math.h>
+
+extern int __isinf(double); /* isinf.c */
+int (isinf)(double a1) { return __isinf(a1); }
+
+/*
+ * The BSD "long double" functions are broken when sizeof(long double) == sizeof(double).
+ * Android works around those cases by replacing the broken functions with our own trivial stubs
+ * that call the regular "double" function.
+ */
+
+int __fpclassifyl(long double a1) { return __fpclassifyd(a1); }
+int __isfinitel(long double a1) { return __isfinite(a1); }
+int __isinfl(long double a1) { return __isinf(a1); }
+int __isnanl(long double a1) { return isnan(a1); }
+int __isnormall(long double a1) { return __isnormal(a1); }
+int __signbitl(long double a1) { return __signbit(a1); }
+
+long double acoshl(long double a1) { return acosh(a1); }
+long double asinhl(long double a1) { return asinh(a1); }
+long double atanhl(long double a1) { return atanh(a1); }
+long double cbrtl(long double a1) { return cbrt(a1); }
+long double copysignl(long double a1, long double a2) { return copysign(a1, a2); }
+long double coshl(long double a1) { return cosh(a1); }
+long double cosl(long double a1) { return cos(a1); }
+long double erfcl(long double a1) { return erfc(a1); }
+long double erfl(long double a1) { return erf(a1); }
+long double expm1l(long double a1) { return expm1(a1); }
+long double fabsl(long double a1) { return fabs(a1); }
+long double fmaxl(long double a1, long double a2) { return fmax(a1, a2); }
+long double fmodl(long double a1, long double a2) { return fmod(a1, a2); }
+long double fminl(long double a1, long double a2) { return fmin(a1, a2); }
+int ilogbl(long double a1) { return ilogb(a1); }
+long double lgammal(long double a1) { return lgamma(a1); }
+long long llrintl(long double a1) { return llrint(a1); }
+long double log10l(long double a1) { return log10(a1); }
+long double log1pl(long double a1) { return log1p(a1); }
+long double log2l(long double a1) { return log2(a1); }
+long double logbl(long double a1) { return logb(a1); }
+long double logl(long double a1) { return log(a1); }
+long lrintl(long double a1) { return lrint(a1); }
+long long llroundl(long double a1) { return llround(a1); }
+long lroundl(long double a1) { return lround(a1); }
+long double modfl(long double a1, long double* a2) { return modf(a1, (double*) a2); }
+long double powl(long double a1, long double a2) { return pow(a1, a2); }
+long double rintl(long double a1) { return rint(a1); }
+long double roundl(long double a1) { return round(a1); }
+long double scalbnl(long double a1, int a2) { return scalbn(a1, a2); }
+long double significandl(long double a1) { return significand(a1); }
+long double sinhl(long double a1) { return sinh(a1); }
+long double sinl(long double a1) { return sin(a1); }
+long double sqrtl(long double a1) { return sqrt(a1); }
+long double tanhl(long double a1) { return tanh(a1); }
+long double tanl(long double a1) { return tan(a1); }
+long double tgammal(long double a1) { return tgamma(a1); }
diff --git a/libm/fpclassify.c b/libm/fpclassify.c
index baf116c..a039138 100644
--- a/libm/fpclassify.c
+++ b/libm/fpclassify.c
@@ -32,7 +32,7 @@
 #include <math.h>
 #include <stdint.h>
 
-#include "src/fpmath.h"
+#include "fpmath.h"
 
 int
 __fpclassifyf(float f)
diff --git a/libm/fpmath.h b/libm/fpmath.h
new file mode 100644
index 0000000..f3753c1
--- /dev/null
+++ b/libm/fpmath.h
@@ -0,0 +1,84 @@
+/*-
+ * Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
+ * Copyright (c) 2002 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/lib/libc/include/fpmath.h,v 1.3 2005/02/06 03:23:31 das Exp $
+ */
+
+#include <endian.h>
+#include "_fpmath.h"
+
+union IEEEf2bits {
+	float	f;
+	struct {
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+		unsigned int	man	:23;
+		unsigned int	exp	:8;
+		unsigned int	sign	:1;
+#else /* _BIG_ENDIAN */
+		unsigned int	sign	:1;
+		unsigned int	exp	:8;
+		unsigned int	man	:23;
+#endif
+	} bits;
+};
+
+#define	DBL_MANH_SIZE	20
+#define	DBL_MANL_SIZE	32
+
+union IEEEd2bits {
+	double	d;
+	struct {
+/* #ifdef __ARMEB__ */
+#if (__BYTE_ORDER == __BIG_ENDIAN) || (defined(__arm__) && !defined(__VFP_FP__))
+		unsigned int	manh	:20;
+		unsigned int	exp	:11;
+		unsigned int	sign	:1;
+		unsigned int	manl	:32;
+#elif  __BYTE_ORDER == __LITTLE_ENDIAN
+		unsigned int	manl	:32;
+		unsigned int	manh	:20;
+		unsigned int	exp	:11;
+		unsigned int	sign	:1;
+#elif __BYTE_ORDER == __BIG_ENDIAN
+		unsigned int	sign	:1;
+		unsigned int	exp	:11;
+		unsigned int	manh	:20;
+		unsigned int	manl	:32;
+#endif
+	} bits;
+};
+
+/*
+ * The BSD "long double" functions are broken when sizeof(long double) == sizeof(double).
+ * Android works around those cases by replacing the broken functions with our own trivial stubs
+ * that call the regular "double" function.
+ */
+#define __fpclassifyl __broken__fpclassify
+#define __isfinitel __broken__isfinitel
+#define __isinfl __broken__isinfl
+#define __isnanl __broken__isnanl
+#define __isnormall __broken__isnormall
+#define __signbitl __broken_signbitl
diff --git a/libm/i386/_fpmath.h b/libm/i386/_fpmath.h
index 92719d9..4f1f5f4 100644
--- a/libm/i386/_fpmath.h
+++ b/libm/i386/_fpmath.h
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libc/i386/_fpmath.h,v 1.5 2005/03/07 04:55:22 das Exp $
+ * $FreeBSD$
  */
 
 union IEEEl2bits {
@@ -35,6 +35,11 @@
 		unsigned int	sign	:1;
 		unsigned int	junk	:16;
 	} bits;
+	struct {
+		unsigned long long man	:64;
+		unsigned int 	expsign	:16;
+		unsigned int	junk	:16;
+	} xbits;
 };
 
 #define	LDBL_NBIT	0x80000000
@@ -46,4 +51,4 @@
 #define	LDBL_TO_ARRAY32(u, a) do {			\
 	(a)[0] = (uint32_t)(u).bits.manl;		\
 	(a)[1] = (uint32_t)(u).bits.manh;		\
-} while(0)
+} while (0)
diff --git a/libm/i387/Makefile.inc b/libm/i387/Makefile.inc
deleted file mode 100644
index d83a56b..0000000
--- a/libm/i387/Makefile.inc
+++ /dev/null
@@ -1,18 +0,0 @@
-# $FreeBSD: src/lib/msun/i387/Makefile.inc,v 1.7 2005/04/16 21:12:55 das Exp $
-
-ARCH_SRCS = e_exp.S e_fmod.S e_log.S e_log10.S \
-	    e_remainder.S e_scalb.S e_sqrt.S s_ceil.S s_copysign.S \
-	    s_cos.S s_finite.S s_floor.S s_llrint.S s_logb.S s_lrint.S \
-	    s_remquo.S s_rint.S s_scalbn.S s_significand.S s_sin.S s_tan.S \
-	    s_trunc.S
-
-# float counterparts
-ARCH_SRCS+= e_log10f.S e_logf.S e_remainderf.S e_scalbf.S \
-	    e_sqrtf.S s_ceilf.S s_copysignf.S s_floorf.S \
-	    s_llrintf.S s_logbf.S s_lrintf.S \
-	    s_remquof.S s_rintf.S s_scalbnf.S s_significandf.S s_truncf.S
-
-# long double counterparts
-ARCH_SRCS+= s_ceill.S s_copysignl.S s_floorl.S s_scalbnl.S s_truncl.S
-
-LDBL_PREC = 64	# XXX 64-bit format, but truncated to 53 bits
diff --git a/libm/i387/e_exp.S b/libm/i387/e_exp.S
deleted file mode 100644
index 008a6e1..0000000
--- a/libm/i387/e_exp.S
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 1993,94 Winning Strategies, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by Winning Strategies, Inc.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Written by:
- *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
- */
-
-#include <machine/asm.h>
-
-RCSID("$FreeBSD: src/lib/msun/i387/e_exp.S,v 1.11 2005/10/30 12:21:02 bde Exp $")
-
-/* e^x = 2^(x * log2(e)) */
-ENTRY(exp)
-	/*
-	 * If x is +-Inf, then the subtraction would give Inf-Inf = NaN.
-	 * Avoid this.  Also avoid it if x is NaN for convenience.
-	 */
-	movl	8(%esp),%eax
-	andl	$0x7fffffff,%eax
-	cmpl	$0x7ff00000,%eax
-	jae	x_Inf_or_NaN
-
-	fldl	4(%esp)
-
-	/*
-	 * Extended precision is needed to reduce the maximum error from
-	 * hundreds of ulps to less than 1 ulp.  Switch to it if necessary.
-	 * We may as well set the rounding mode to to-nearest and mask traps
-	 * if we switch.
-	 */
-	fstcw	4(%esp)
-	movl	4(%esp),%eax
-	andl	$0x0300,%eax
-	cmpl	$0x0300,%eax		/* RC == 0 && PC == 3? */
-	je	1f			/* jump if mode is good */
-	movl	$0x137f,8(%esp)
-	fldcw	8(%esp)
-1:
-	fldl2e
-	fmulp				/* x * log2(e) */
-	fst	%st(1)
-	frndint				/* int(x * log2(e)) */
-	fst	%st(2)
-	fsubrp				/* fract(x * log2(e)) */
-	f2xm1				/* 2^(fract(x * log2(e))) - 1 */ 
-	fld1
-	faddp				/* 2^(fract(x * log2(e))) */
-	fscale				/* e^x */
-	fstp	%st(1)
-	je	1f
-	fldcw	4(%esp)
-1:
-	ret
-
-x_Inf_or_NaN:
-	/*
-	 * Return 0 if x is -Inf.  Otherwise just return x; when x is Inf
-	 * this gives Inf, and when x is a NaN this gives the same result
-	 * as (x + x) (x quieted).
-	 */
-	cmpl	$0xfff00000,8(%esp)
-	jne	x_not_minus_Inf
-	cmpl	$0,4(%esp)
-	jne	x_not_minus_Inf
-	fldz
-	ret
-
-x_not_minus_Inf:
-	fldl	4(%esp)
-	ret
diff --git a/libm/i387/e_fmod.S b/libm/i387/e_fmod.S
deleted file mode 100644
index 233476f..0000000
--- a/libm/i387/e_fmod.S
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 1993,94 Winning Strategies, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by Winning Strategies, Inc.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Written by:
- *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
- */
-
-#include <machine/asm.h>
-
-RCSID("$FreeBSD: src/lib/msun/i387/e_fmod.S,v 1.8 2005/02/04 14:08:32 das Exp $")
-
-ENTRY(fmod)
-	fldl	12(%esp)
-	fldl	4(%esp)
-1:	fprem
-	fstsw	%ax
-	sahf
-	jp	1b
-	fstp	%st(1)
-	ret
diff --git a/libm/i387/e_log.S b/libm/i387/e_log.S
deleted file mode 100644
index caaac87..0000000
--- a/libm/i387/e_log.S
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 1993,94 Winning Strategies, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by Winning Strategies, Inc.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Written by:
- *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
- */
-
-#include <machine/asm.h>
-
-RCSID("$FreeBSD: src/lib/msun/i387/e_log.S,v 1.7 2005/02/04 14:08:32 das Exp $")
-
-ENTRY(log)
-	fldln2
-	fldl	4(%esp)
-	fyl2x
-	ret
diff --git a/libm/i387/e_log10.S b/libm/i387/e_log10.S
deleted file mode 100644
index 7695ef6..0000000
--- a/libm/i387/e_log10.S
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 1993,94 Winning Strategies, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by Winning Strategies, Inc.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Written by:
- *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
- */
-
-#include <machine/asm.h>
-
-RCSID("$FreeBSD: src/lib/msun/i387/e_log10.S,v 1.7 2005/02/04 14:08:32 das Exp $")
-
-ENTRY(log10)
-	fldlg2
-	fldl	4(%esp)
-	fyl2x
-	ret
diff --git a/libm/i387/e_log10f.S b/libm/i387/e_log10f.S
deleted file mode 100644
index 2dd6708..0000000
--- a/libm/i387/e_log10f.S
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-
-__FBSDID("$FreeBSD: src/lib/msun/i387/e_log10f.S,v 1.2 2005/02/04 14:08:32 das Exp $");
-/* RCSID("$NetBSD: e_log10f.S,v 1.1 1996/07/03 16:50:22 jtc Exp $") */
-
-ENTRY(log10f)
-	fldlg2
-	flds	4(%esp)
-	fyl2x
-	ret
diff --git a/libm/i387/e_logf.S b/libm/i387/e_logf.S
deleted file mode 100644
index 9f3bd00..0000000
--- a/libm/i387/e_logf.S
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-
-__FBSDID("$FreeBSD: src/lib/msun/i387/e_logf.S,v 1.2 2005/02/04 14:08:32 das Exp $");
-/* RCSID("$NetBSD: e_logf.S,v 1.2 1996/07/06 00:15:45 jtc Exp $") */
-
-ENTRY(logf)
-	fldln2
-	flds	4(%esp)
-	fyl2x
-	ret
diff --git a/libm/i387/e_remainder.S b/libm/i387/e_remainder.S
deleted file mode 100644
index 5f0d679..0000000
--- a/libm/i387/e_remainder.S
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 1993,94 Winning Strategies, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by Winning Strategies, Inc.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Written by:
- *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
- */
-
-#include <machine/asm.h>
-
-RCSID("$FreeBSD: src/lib/msun/i387/e_remainder.S,v 1.8 2005/02/04 14:08:32 das Exp $")
-
-ENTRY(remainder)
-	fldl	12(%esp)
-	fldl	4(%esp)
-1:	fprem1
-	fstsw	%ax
-	sahf
-	jp	1b
-	fstp	%st(1)
-	ret
diff --git a/libm/i387/e_remainderf.S b/libm/i387/e_remainderf.S
deleted file mode 100644
index 6d1ca79..0000000
--- a/libm/i387/e_remainderf.S
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-
-__FBSDID("$FreeBSD: src/lib/msun/i387/e_remainderf.S,v 1.2 2005/02/04 14:08:32 das Exp $");
-/* RCSID("$NetBSD: e_remainderf.S,v 1.2 1995/05/08 23:49:47 jtc Exp $") */
-
-ENTRY(remainderf)
-	flds	8(%esp)
-	flds	4(%esp)
-1:	fprem1
-	fstsw	%ax
-	sahf
-	jp	1b
-	fstp	%st(1)
-	ret
diff --git a/libm/i387/e_scalb.S b/libm/i387/e_scalb.S
deleted file mode 100644
index dd8657f..0000000
--- a/libm/i387/e_scalb.S
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 1994 Winning Strategies, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by Winning Strategies, Inc.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Written by:
- *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
- */
-
-#include <machine/asm.h>
-
-RCSID("$FreeBSD: src/lib/msun/i387/e_scalb.S,v 1.8 2005/02/04 14:08:32 das Exp $")
-
-ENTRY(scalb)
-	fldl	12(%esp)
-	fldl	4(%esp)
-	fscale
-	fstp	%st(1)
-	ret
diff --git a/libm/i387/e_scalbf.S b/libm/i387/e_scalbf.S
deleted file mode 100644
index 9de0d70..0000000
--- a/libm/i387/e_scalbf.S
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-
-__FBSDID("$FreeBSD: src/lib/msun/i387/e_scalbf.S,v 1.2 2005/02/04 14:08:32 das Exp $");
-/* RCSID("$NetBSD: e_scalbf.S,v 1.1 1996/07/03 16:50:24 jtc Exp $") */
-
-ENTRY(scalbf)
-	flds	8(%esp)
-	flds	4(%esp)
-	fscale
-	ret
diff --git a/libm/i387/e_sqrt.S b/libm/i387/e_sqrt.S
deleted file mode 100644
index b7e9621..0000000
--- a/libm/i387/e_sqrt.S
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 1993,94 Winning Strategies, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by Winning Strategies, Inc.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Written by:
- *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
- */
-
-#include <machine/asm.h>
-
-RCSID("$FreeBSD: src/lib/msun/i387/e_sqrt.S,v 1.7 2005/02/04 14:08:32 das Exp $")
-
-ENTRY(sqrt)
-	fldl	4(%esp)
-	fsqrt
-	ret
diff --git a/libm/i387/e_sqrtf.S b/libm/i387/e_sqrtf.S
deleted file mode 100644
index 86c56a9..0000000
--- a/libm/i387/e_sqrtf.S
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-
-__FBSDID("$FreeBSD: src/lib/msun/i387/e_sqrtf.S,v 1.2 2005/02/04 14:08:32 das Exp $");
-/* RCSID("$NetBSD: e_sqrtf.S,v 1.2 1995/05/08 23:50:14 jtc Exp $") */
-
-ENTRY(sqrtf)
-	flds	4(%esp)
-	fsqrt
-	ret
diff --git a/libm/i387/s_ceil.S b/libm/i387/s_ceil.S
deleted file mode 100644
index 8e73b38..0000000
--- a/libm/i387/s_ceil.S
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 1993,94 Winning Strategies, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by Winning Strategies, Inc.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Written by:
- *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
- */
-
-#include <machine/asm.h>
-
-RCSID("$FreeBSD: src/lib/msun/i387/s_ceil.S,v 1.7 1999/08/28 00:06:11 peter Exp $")
-
-ENTRY(ceil)
-	pushl	%ebp
-	movl	%esp,%ebp
-	subl	$8,%esp
-
-	fstcw	-4(%ebp)		/* store fpu control word */
-	movw	-4(%ebp),%dx
-	orw	$0x0800,%dx		/* round towards +oo */
-	andw	$0xfbff,%dx
-	movw	%dx,-8(%ebp)
-	fldcw	-8(%ebp)		/* load modfied control word */
-
-	fldl	8(%ebp);		/* round */
-	frndint
-
-	fldcw	-4(%ebp)		/* restore original control word */
-
-	leave
-	ret
diff --git a/libm/i387/s_ceilf.S b/libm/i387/s_ceilf.S
deleted file mode 100644
index 152ca7b..0000000
--- a/libm/i387/s_ceilf.S
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-
-__FBSDID("$FreeBSD: src/lib/msun/i387/s_ceilf.S,v 1.2 2005/05/06 15:44:20 deischen Exp $");
-/* RCSID("$NetBSD: s_ceilf.S,v 1.3 1995/05/08 23:52:44 jtc Exp $") */
-
-ENTRY(ceilf)
-	pushl	%ebp
-	movl	%esp,%ebp
-	subl	$8,%esp
-
-	fstcw	-4(%ebp)		/* store fpu control word */
-	movw	-4(%ebp),%dx
-	orw	$0x0800,%dx		/* round towards +oo */
-	andw	$0xfbff,%dx
-	movw	%dx,-8(%ebp)
-	fldcw	-8(%ebp)		/* load modfied control word */
-
-	flds	8(%ebp);		/* round */
-	frndint
-
-	fldcw	-4(%ebp)		/* restore original control word */
-
-	leave
-	ret
diff --git a/libm/i387/s_ceill.S b/libm/i387/s_ceill.S
deleted file mode 100644
index b6c3c41..0000000
--- a/libm/i387/s_ceill.S
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Based on code written by J.T. Conklin <jtc@NetBSD.org>.
- * Public domain.
- */
-	
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/i387/s_ceill.S,v 1.1 2005/04/16 21:12:55 das Exp $")
-
-ENTRY(ceill)
-	pushl	%ebp
-	movl	%esp,%ebp
-	subl	$8,%esp
-
-	fstcw	-4(%ebp)		/* store fpu control word */
-	movw	-4(%ebp),%dx
-	orw	$0x0800,%dx		/* round towards +oo */
-	andw	$0xfbff,%dx
-	movw	%dx,-8(%ebp)
-	fldcw	-8(%ebp)		/* load modfied control word */
-
-	fldt	8(%ebp)			/* round */
-	frndint
-
-	fldcw	-4(%ebp)		/* restore original control word */
-
-	leave
-	ret
diff --git a/libm/i387/s_copysign.S b/libm/i387/s_copysign.S
deleted file mode 100644
index 6ecc770..0000000
--- a/libm/i387/s_copysign.S
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 1993,94 Winning Strategies, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by Winning Strategies, Inc.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Written by:
- *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
- */
-
-#include <machine/asm.h>
-
-RCSID("$FreeBSD: src/lib/msun/i387/s_copysign.S,v 1.6 1999/08/28 00:06:11 peter Exp $")
-
-ENTRY(copysign)
-	movl	16(%esp),%edx
-	andl	$0x80000000,%edx
-	movl	8(%esp),%eax
-	andl	$0x7fffffff,%eax
-	orl	%edx,%eax
-	movl	%eax,8(%esp)
-	fldl	4(%esp)
-	ret
diff --git a/libm/i387/s_copysignf.S b/libm/i387/s_copysignf.S
deleted file mode 100644
index c3fc898..0000000
--- a/libm/i387/s_copysignf.S
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-
-__FBSDID("$FreeBSD: src/lib/msun/i387/s_copysignf.S,v 1.1 2005/01/13 18:58:25 das Exp $");
-/* RCSID("$NetBSD: s_copysignf.S,v 1.3 1995/05/08 23:53:25 jtc Exp $") */
-
-ENTRY(copysignf)
-	movl	8(%esp),%edx
-	andl	$0x80000000,%edx
-	movl	4(%esp),%eax
-	andl	$0x7fffffff,%eax
-	orl	%edx,%eax
-	movl	%eax,4(%esp)
-	flds	4(%esp)
-	ret
diff --git a/libm/i387/s_copysignl.S b/libm/i387/s_copysignl.S
deleted file mode 100644
index 4c3a374..0000000
--- a/libm/i387/s_copysignl.S
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Based on code written by J.T. Conklin <jtc@NetBSD.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/i387/s_copysignl.S,v 1.1 2005/04/16 21:12:55 das Exp $")
-
-ENTRY(copysignl)
-	movl	24(%esp),%edx
-	andl	$0x8000,%edx
-	movl	12(%esp),%eax
-	andl	$0x7fff,%eax
-	orl	%edx,%eax
-	movl	%eax,12(%esp)
-	fldt	4(%esp)
-	ret
diff --git a/libm/i387/s_cos.S b/libm/i387/s_cos.S
deleted file mode 100644
index c38cb7b..0000000
--- a/libm/i387/s_cos.S
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 1994 Winning Strategies, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by Winning Strategies, Inc.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Written by:
- *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
- */
-
-#include <machine/asm.h>
-
-RCSID("$FreeBSD: src/lib/msun/i387/s_cos.S,v 1.6 1999/08/28 00:06:12 peter Exp $")
-
-ENTRY(cos)
-	fldl	4(%esp)
-	fcos
-	fnstsw	%ax
-	andw	$0x400,%ax
-	jnz	1f
-	ret	
-1:	fldpi
-	fadd	%st(0)
-	fxch	%st(1)
-2:	fprem1
-	fnstsw	%ax
-	andw	$0x400,%ax
-	jnz	2b
-	fstp	%st(1)
-	fcos
-	ret
diff --git a/libm/i387/s_finite.S b/libm/i387/s_finite.S
deleted file mode 100644
index 4835b0e..0000000
--- a/libm/i387/s_finite.S
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 1993,94 Winning Strategies, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by Winning Strategies, Inc.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Written by:
- *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
- */
-
-#include <machine/asm.h>
-
-RCSID("$FreeBSD: src/lib/msun/i387/s_finite.S,v 1.7 1999/08/28 00:06:12 peter Exp $")
-
-ENTRY(finite)
-	movl	8(%esp),%eax
-	andl	$0x7ff00000, %eax
-	cmpl	$0x7ff00000, %eax
-	setneb	%al
-	andl	$0x000000ff, %eax
-	ret
diff --git a/libm/i387/s_floor.S b/libm/i387/s_floor.S
deleted file mode 100644
index 722f83d..0000000
--- a/libm/i387/s_floor.S
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 1993,94 Winning Strategies, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by Winning Strategies, Inc.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Written by:
- *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
- */
-
-#include <machine/asm.h>
-
-RCSID("$FreeBSD: src/lib/msun/i387/s_floor.S,v 1.7 1999/08/28 00:06:12 peter Exp $")
-
-ENTRY(floor)
-	pushl	%ebp
-	movl	%esp,%ebp
-	subl	$8,%esp
-
-	fstcw	-4(%ebp)		/* store fpu control word */
-	movw	-4(%ebp),%dx
-	orw	$0x0400,%dx		/* round towards -oo */
-	andw	$0xf7ff,%dx
-	movw	%dx,-8(%ebp)
-	fldcw	-8(%ebp)		/* load modfied control word */
-
-	fldl	8(%ebp);		/* round */
-	frndint
-
-	fldcw	-4(%ebp)		/* restore original control word */
-
-	leave
-	ret
diff --git a/libm/i387/s_floorf.S b/libm/i387/s_floorf.S
deleted file mode 100644
index 5d39acd..0000000
--- a/libm/i387/s_floorf.S
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-
-__FBSDID("$FreeBSD: src/lib/msun/i387/s_floorf.S,v 1.2 2005/05/06 15:44:20 deischen Exp $");
-/* RCSID("$NetBSD: s_floorf.S,v 1.3 1995/05/09 00:04:32 jtc Exp $") */
-
-ENTRY(floorf)
-	pushl	%ebp
-	movl	%esp,%ebp
-	subl	$8,%esp
-
-	fstcw	-4(%ebp)		/* store fpu control word */
-	movw	-4(%ebp),%dx
-	orw	$0x0400,%dx		/* round towards -oo */
-	andw	$0xf7ff,%dx
-	movw	%dx,-8(%ebp)
-	fldcw	-8(%ebp)		/* load modfied control word */
-
-	flds	8(%ebp);		/* round */
-	frndint
-
-	fldcw	-4(%ebp)		/* restore original control word */
-
-	leave
-	ret
diff --git a/libm/i387/s_floorl.S b/libm/i387/s_floorl.S
deleted file mode 100644
index 3cde335..0000000
--- a/libm/i387/s_floorl.S
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Based on code written by J.T. Conklin <jtc@NetBSD.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/i387/s_floorl.S,v 1.1 2005/04/16 21:12:55 das Exp $")
-
-ENTRY(floorl)
-	pushl	%ebp
-	movl	%esp,%ebp
-	subl	$8,%esp
-
-	fstcw	-4(%ebp)		/* store fpu control word */
-	movw	-4(%ebp),%dx
-	orw	$0x0400,%dx		/* round towards -oo */
-	andw	$0xf7ff,%dx
-	movw	%dx,-8(%ebp)
-	fldcw	-8(%ebp)		/* load modfied control word */
-
-	fldt	8(%ebp)			/* round */
-	frndint
-
-	fldcw	-4(%ebp)		/* restore original control word */
-
-	leave
-	ret
diff --git a/libm/i387/s_llrint.S b/libm/i387/s_llrint.S
deleted file mode 100644
index b266e5c..0000000
--- a/libm/i387/s_llrint.S
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/i387/s_llrint.S,v 1.1 2005/01/11 23:10:53 das Exp $"); 
-	
-ENTRY(llrint)
-	fldl	4(%esp)
-	subl	$8,%esp
-	fistpll	(%esp)
-	popl	%eax
-	popl	%edx
-	ret
diff --git a/libm/i387/s_llrintf.S b/libm/i387/s_llrintf.S
deleted file mode 100644
index e1edb09..0000000
--- a/libm/i387/s_llrintf.S
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/i387/s_llrintf.S,v 1.1 2005/04/16 21:12:55 das Exp $")
-	
-ENTRY(llrintf)
-	flds	4(%esp)
-	subl	$8,%esp
-	fistpll	(%esp)
-	popl	%eax
-	popl	%edx
-	ret
diff --git a/libm/i387/s_logb.S b/libm/i387/s_logb.S
deleted file mode 100644
index d3f8d9d..0000000
--- a/libm/i387/s_logb.S
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 1993,94 Winning Strategies, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by Winning Strategies, Inc.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Written by:
- *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
- */
-
-#include <machine/asm.h>
-
-RCSID("$FreeBSD: src/lib/msun/i387/s_logb.S,v 1.7 2000/06/06 12:12:36 bde Exp $")
-
-ENTRY(logb)
-	fldl	4(%esp)
-	fxtract
-	fstp	%st
-	ret
diff --git a/libm/i387/s_logbf.S b/libm/i387/s_logbf.S
deleted file mode 100644
index 26bc484..0000000
--- a/libm/i387/s_logbf.S
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-
-__FBSDID("$FreeBSD: src/lib/msun/i387/s_logbf.S,v 1.1 2005/01/13 18:58:25 das Exp $");
-/* RCSID("$NetBSD: s_logbf.S,v 1.3 1995/05/09 00:15:12 jtc Exp $") */
-
-ENTRY(logbf)
-	flds	4(%esp)
-	fxtract
-	fstp	%st
-	ret
diff --git a/libm/i387/s_lrint.S b/libm/i387/s_lrint.S
deleted file mode 100644
index 022783c..0000000
--- a/libm/i387/s_lrint.S
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/i387/s_lrint.S,v 1.1 2005/01/11 23:10:53 das Exp $"); 
-	
-ENTRY(lrint)
-	fldl	4(%esp)
-	subl	$4,%esp
-	fistpl	(%esp)
-	popl	%eax
-	ret
diff --git a/libm/i387/s_lrintf.S b/libm/i387/s_lrintf.S
deleted file mode 100644
index ac126f0..0000000
--- a/libm/i387/s_lrintf.S
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/i387/s_lrintf.S,v 1.1 2005/04/16 21:12:55 das Exp $")
-	
-ENTRY(lrintf)
-	flds	4(%esp)
-	subl	$4,%esp
-	fistpl	(%esp)
-	popl	%eax
-	ret
diff --git a/libm/i387/s_remquo.S b/libm/i387/s_remquo.S
deleted file mode 100644
index f752839..0000000
--- a/libm/i387/s_remquo.S
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Based on public-domain remainder routine by J.T. Conklin <jtc@NetBSD.org>.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/i387/s_remquo.S,v 1.1 2005/03/25 04:40:44 das Exp $"); 
-	
-ENTRY(remquo)
-	fldl	12(%esp)
-	fldl	4(%esp)
-1:	fprem1
-	fstsw	%ax
-	sahf
-	jp	1b
-	fstp	%st(1)
-/* Extract the three low-order bits of the quotient from C0,C3,C1. */
-	shrl	$6,%eax
-	movl	%eax,%ecx
-	andl	$0x108,%eax
-	rorl	$7,%eax
-	orl	%eax,%ecx
-	roll	$4,%eax
-	orl	%ecx,%eax
-	andl	$7,%eax
-/* Negate the quotient bits if x*y<0.  Avoid using an unpredictable branch. */
-	movl	16(%esp),%ecx
-	xorl	8(%esp),%ecx
-	sarl	$16,%ecx
-	sarl	$16,%ecx
-	xorl	%ecx,%eax
-	andl	$1,%ecx
-	addl	%ecx,%eax
-/* Store the quotient and return. */
-	movl	20(%esp),%ecx
-	movl	%eax,(%ecx)
-	ret
diff --git a/libm/i387/s_remquof.S b/libm/i387/s_remquof.S
deleted file mode 100644
index 40d24b8..0000000
--- a/libm/i387/s_remquof.S
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Based on public-domain remainder routine by J.T. Conklin <jtc@NetBSD.org>.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/i387/s_remquof.S,v 1.1 2005/03/25 04:40:44 das Exp $"); 
-	
-ENTRY(remquof)
-	flds	8(%esp)
-	flds	4(%esp)
-1:	fprem1
-	fstsw	%ax
-	sahf
-	jp	1b
-	fstp	%st(1)
-/* Extract the three low-order bits of the quotient from C0,C3,C1. */
-	shrl	$6,%eax
-	movl	%eax,%ecx
-	andl	$0x108,%eax
-	rorl	$7,%eax
-	orl	%eax,%ecx
-	roll	$4,%eax
-	orl	%ecx,%eax
-	andl	$7,%eax
-/* Negate the quotient bits if x*y<0.  Avoid using an unpredictable branch. */
-	movl	8(%esp),%ecx
-	xorl	4(%esp),%ecx
-	sarl	$16,%ecx
-	sarl	$16,%ecx
-	xorl	%ecx,%eax
-	andl	$1,%ecx
-	addl	%ecx,%eax
-/* Store the quotient and return. */
-	movl	12(%esp),%ecx
-	movl	%eax,(%ecx)
-	ret
diff --git a/libm/i387/s_rint.S b/libm/i387/s_rint.S
deleted file mode 100644
index ccda314..0000000
--- a/libm/i387/s_rint.S
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 1993,94 Winning Strategies, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by Winning Strategies, Inc.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Written by:
- *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
- */
-
-#include <machine/asm.h>
-
-RCSID("$FreeBSD: src/lib/msun/i387/s_rint.S,v 1.6 1999/08/28 00:06:13 peter Exp $")
-
-ENTRY(rint)
-	fldl	4(%esp)
-	frndint
-	ret
diff --git a/libm/i387/s_rintf.S b/libm/i387/s_rintf.S
deleted file mode 100644
index ad45267..0000000
--- a/libm/i387/s_rintf.S
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-
-__FBSDID("$FreeBSD: src/lib/msun/i387/s_rintf.S,v 1.1 2005/01/13 18:58:25 das Exp $");
-/* RCSID("$NetBSD: s_rintf.S,v 1.3 1995/05/09 00:17:22 jtc Exp $") */
-
-ENTRY(rintf)
-	flds	4(%esp)
-	frndint
-	ret
diff --git a/libm/i387/s_scalbn.S b/libm/i387/s_scalbn.S
deleted file mode 100644
index 4600603..0000000
--- a/libm/i387/s_scalbn.S
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 1994 Winning Strategies, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by Winning Strategies, Inc.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Written by:
- *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
- */
-
-#include <machine/asm.h>
-
-RCSID("$FreeBSD: src/lib/msun/i387/s_scalbn.S,v 1.7 1999/08/28 00:06:13 peter Exp $")
-
-ENTRY(scalbn)
-	fildl	12(%esp)
-	fldl	4(%esp)
-	fscale
-	fstp	%st(1)
-	ret
diff --git a/libm/i387/s_scalbnf.S b/libm/i387/s_scalbnf.S
deleted file mode 100644
index 3e1ac41..0000000
--- a/libm/i387/s_scalbnf.S
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-
-__FBSDID("$FreeBSD: src/lib/msun/i387/s_scalbnf.S,v 1.2 2005/03/07 04:52:43 das Exp $");
-/* RCSID("$NetBSD: s_scalbnf.S,v 1.4 1999/01/02 05:15:40 kristerw Exp $") */
-
-ENTRY(scalbnf)
-	fildl	8(%esp)
-	flds	4(%esp)
-	fscale
-	fstp	%st(1)		/* bug fix for fp stack overflow */
-	ret
-
-.globl CNAME(ldexpf)
-.set	CNAME(ldexpf),CNAME(scalbnf)
diff --git a/libm/i387/s_scalbnl.S b/libm/i387/s_scalbnl.S
deleted file mode 100644
index 512ab61..0000000
--- a/libm/i387/s_scalbnl.S
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-
-__FBSDID("$FreeBSD: src/lib/msun/i387/s_scalbnl.S,v 1.1 2005/03/07 04:52:57 das Exp $");
-/* RCSID("$NetBSD: s_scalbnf.S,v 1.4 1999/01/02 05:15:40 kristerw Exp $") */
-
-ENTRY(scalbnl)
-	fildl	16(%esp)
-	fldt	4(%esp)
-	fscale
-	fstp	%st(1)
-	ret
-
-.globl CNAME(ldexpl)
-.set	CNAME(ldexpl),CNAME(scalbnl)
diff --git a/libm/i387/s_significand.S b/libm/i387/s_significand.S
deleted file mode 100644
index eddbc82..0000000
--- a/libm/i387/s_significand.S
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 1993,94 Winning Strategies, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by Winning Strategies, Inc.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Written by:
- *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
- */
-
-#include <machine/asm.h>
-
-RCSID("$FreeBSD: src/lib/msun/i387/s_significand.S,v 1.7 2000/06/06 12:12:36 bde Exp $")
-
-ENTRY(significand)
-	fldl	4(%esp)
-	fxtract
-	fstp	%st(1)
-	ret
diff --git a/libm/i387/s_significandf.S b/libm/i387/s_significandf.S
deleted file mode 100644
index 6096ef0..0000000
--- a/libm/i387/s_significandf.S
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-
-__FBSDID("$FreeBSD: src/lib/msun/i387/s_significandf.S,v 1.1 2005/01/13 18:58:25 das Exp $");
-/* RCSID("$NetBSD: s_significandf.S,v 1.3 1995/05/09 00:24:07 jtc Exp $") */
-
-ENTRY(significandf)
-	flds	4(%esp)
-	fxtract
-	fstp	%st(1)
-	ret
diff --git a/libm/i387/s_sin.S b/libm/i387/s_sin.S
deleted file mode 100644
index c3d65fd..0000000
--- a/libm/i387/s_sin.S
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 1994 Winning Strategies, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by Winning Strategies, Inc.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Written by:
- *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
- */
-
-#include <machine/asm.h>
-
-RCSID("$FreeBSD: src/lib/msun/i387/s_sin.S,v 1.6 1999/08/28 00:06:14 peter Exp $")
-
-ENTRY(sin)
-	fldl	4(%esp)
-	fsin
-	fnstsw	%ax
-	andw	$0x400,%ax
-	jnz	1f
-	ret
-1:	fldpi
-	fadd	%st(0)
-	fxch	%st(1)
-2:	fprem1
-	fnstsw	%ax
-	andw	$0x400,%ax
-	jnz	2b
-	fstp	%st(1)
-	fsin
-	ret
diff --git a/libm/i387/s_tan.S b/libm/i387/s_tan.S
deleted file mode 100644
index 925e11a..0000000
--- a/libm/i387/s_tan.S
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 1994 Winning Strategies, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by Winning Strategies, Inc.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Written by:
- *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
- */
-
-#include <machine/asm.h>
-
-RCSID("$FreeBSD: src/lib/msun/i387/s_tan.S,v 1.6 1999/08/28 00:06:14 peter Exp $")
-
-ENTRY(tan)
-	fldl	4(%esp)
-	fptan
-	fnstsw	%ax
-	andw	$0x400,%ax
-	jnz	1f
-	fstp	%st(0)
-	ret
-1:	fldpi
-	fadd	%st(0)
-	fxch	%st(1)
-2:	fprem1
-	fstsw	%ax
-	andw	$0x400,%ax
-	jnz	2b
-	fstp	%st(1)
-	fptan
-	fstp	%st(0)
-	ret
diff --git a/libm/i387/s_trunc.S b/libm/i387/s_trunc.S
deleted file mode 100644
index 1d78e1c..0000000
--- a/libm/i387/s_trunc.S
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Based on code written by J.T. Conklin <jtc@NetBSD.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/i387/s_trunc.S,v 1.1 2005/04/16 21:12:55 das Exp $")
-
-ENTRY(trunc)
-	pushl	%ebp
-	movl	%esp,%ebp
-	subl	$8,%esp
-
-	fstcw	-4(%ebp)		/* store fpu control word */
-	movw	-4(%ebp),%dx
-	orw	$0x0c00,%dx		/* round towards -oo */
-	movw	%dx,-8(%ebp)
-	fldcw	-8(%ebp)		/* load modfied control word */
-
-	fldl	8(%ebp)			/* round */
-	frndint
-
-	fldcw	-4(%ebp)		/* restore original control word */
-
-	leave
-	ret
diff --git a/libm/i387/s_truncf.S b/libm/i387/s_truncf.S
deleted file mode 100644
index 8afaf3e..0000000
--- a/libm/i387/s_truncf.S
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Based on code written by J.T. Conklin <jtc@NetBSD.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/i387/s_truncf.S,v 1.2 2005/05/06 15:44:20 deischen Exp $")
-
-ENTRY(truncf)
-	pushl	%ebp
-	movl	%esp,%ebp
-	subl	$8,%esp
-
-	fstcw	-4(%ebp)		/* store fpu control word */
-	movw	-4(%ebp),%dx
-	orw	$0x0c00,%dx		/* round towards -oo */
-	movw	%dx,-8(%ebp)
-	fldcw	-8(%ebp)		/* load modfied control word */
-
-	flds	8(%ebp)			/* round */
-	frndint
-
-	fldcw	-4(%ebp)		/* restore original control word */
-
-	leave
-	ret
diff --git a/libm/i387/s_truncl.S b/libm/i387/s_truncl.S
deleted file mode 100644
index cd5df1c..0000000
--- a/libm/i387/s_truncl.S
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Based on code written by J.T. Conklin <jtc@NetBSD.org>.
- * Public domain.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/i387/s_truncl.S,v 1.1 2005/04/16 21:12:55 das Exp $")
-
-ENTRY(truncl)
-	pushl	%ebp
-	movl	%esp,%ebp
-	subl	$8,%esp
-
-	fstcw	-4(%ebp)		/* store fpu control word */
-	movw	-4(%ebp),%dx
-	orw	$0x0c00,%dx		/* round towards -oo */
-	movw	%dx,-8(%ebp)
-	fldcw	-8(%ebp)		/* load modfied control word */
-
-	fldt	8(%ebp)			/* round */
-	frndint
-
-	fldcw	-4(%ebp)		/* restore original control word */
-
-	leave
-	ret
diff --git a/libm/ia64/Makefile.inc b/libm/ia64/Makefile.inc
deleted file mode 100644
index fdf2267..0000000
--- a/libm/ia64/Makefile.inc
+++ /dev/null
@@ -1,4 +0,0 @@
-# $FreeBSD: src/lib/msun/ia64/Makefile.inc,v 1.2 2005/03/07 04:54:02 das Exp $
-
-ARCH_SRCS = s_fma.S s_fmaf.S s_fmal.S
-LDBL_PREC = 64
diff --git a/libm/ia64/_fpmath.h b/libm/ia64/_fpmath.h
deleted file mode 100644
index b0e75ed..0000000
--- a/libm/ia64/_fpmath.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
- * Copyright (c) 2002, 2003 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/libc/ia64/_fpmath.h,v 1.6 2005/03/07 04:55:40 das Exp $
- */
-
-#include <sys/endian.h>
-
-union IEEEl2bits {
-	long double	e;
-	struct {
-#if _BYTE_ORDER == _LITTLE_ENDIAN
-		unsigned int	manl	:32;
-		unsigned int	manh	:32;
-		unsigned int	exp	:15;
-		unsigned int	sign	:1;
-		unsigned long	junk	:48;
-#else /* _BIG_ENDIAN */
-		unsigned long	junk	:48;
-		unsigned int	sign	:1;
-		unsigned int	exp	:15;
-		unsigned int	manh	:32;
-		unsigned int	manl	:32;
-#endif
-	} bits;
-};
-
-#if _BYTE_ORDER == _LITTLE_ENDIAN
-#define	LDBL_NBIT	0x80000000
-#define	mask_nbit_l(u)	((u).bits.manh &= ~LDBL_NBIT)
-#else /* _BIG_ENDIAN */
-/*
- * XXX This doesn't look right.  Very few machines have a different
- *     endianness for integers and floating-point, and in nextafterl()
- *     we assume that none do.  If you have an environment for testing
- *     this, please let me know. --das
- */
-#define	LDBL_NBIT	0x80
-#define	mask_nbit_l(u)	((u).bits.manh &= ~LDBL_NBIT)
-#endif
-
-#define	LDBL_MANH_SIZE	32
-#define	LDBL_MANL_SIZE	32
-
-#define	LDBL_TO_ARRAY32(u, a) do {			\
-	(a)[0] = (uint32_t)(u).bits.manl;		\
-	(a)[1] = (uint32_t)(u).bits.manh;		\
-} while(0)
diff --git a/libm/ia64/fenv.c b/libm/ia64/fenv.c
deleted file mode 100644
index 182d37e..0000000
--- a/libm/ia64/fenv.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/ia64/fenv.c,v 1.2 2004/06/11 02:35:30 das Exp $
- */
-
-#include <sys/types.h>
-#include <fenv.h>
-
-const fenv_t __fe_dfl_env = 0x0009804c8a70033fULL;
-
-/*
- * It doesn't pay to inline feupdateenv() because it includes one of
- * the rare uses of feraiseexcept() where the argument is not a
- * constant.  Thus, no dead code elimination can occur, resulting in
- * significant bloat.
- */
-int
-feupdateenv(const fenv_t *envp)
-{
-	fenv_t fpsr;
-
-	__stfpsr(&fpsr);
-	__ldfpsr(*envp);
-	feraiseexcept((fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
-	return (0);
-}
diff --git a/libm/ia64/fenv.h b/libm/ia64/fenv.h
deleted file mode 100644
index 8c6b65b..0000000
--- a/libm/ia64/fenv.h
+++ /dev/null
@@ -1,242 +0,0 @@
-/*-
- * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/ia64/fenv.h,v 1.4 2005/03/16 19:03:45 das Exp $
- */
-
-#ifndef	_FENV_H_
-#define	_FENV_H_
-
-#include <sys/_types.h>
-
-typedef	__uint64_t	fenv_t;
-typedef	__uint16_t	fexcept_t;
-
-/* Exception flags */
-#define	FE_INVALID	0x01
-#define	FE_DENORMAL	0x02
-#define	FE_DIVBYZERO	0x04
-#define	FE_OVERFLOW	0x08
-#define	FE_UNDERFLOW	0x10
-#define	FE_INEXACT	0x20
-#define	FE_ALL_EXCEPT	(FE_DIVBYZERO | FE_DENORMAL | FE_INEXACT | \
-			 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
-
-/* Rounding modes */
-#define	FE_TONEAREST	0x0000
-#define	FE_DOWNWARD	0x0400
-#define	FE_UPWARD	0x0800
-#define	FE_TOWARDZERO	0x0c00
-#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
-			 FE_UPWARD | FE_TOWARDZERO)
-
-__BEGIN_DECLS
-
-/* Default floating-point environment */
-extern const fenv_t	__fe_dfl_env;
-#define	FE_DFL_ENV	(&__fe_dfl_env)
-
-#define	_FPUSW_SHIFT	13
-
-#define	__stfpsr(__r)	__asm __volatile("mov %0=ar.fpsr" : "=r" (*(__r)))
-#define	__ldfpsr(__r)	__asm __volatile("mov ar.fpsr=%0;;" : : "r" (__r))
-
-static __inline int
-feclearexcept(int __excepts)
-{
-	fenv_t __fpsr;
-
-	__stfpsr(&__fpsr);
-	__fpsr &= ~((fenv_t)__excepts << _FPUSW_SHIFT);
-	__ldfpsr(__fpsr);
-	return (0);
-}
-
-static __inline int
-fegetexceptflag(fexcept_t *__flagp, int __excepts)
-{
-	fenv_t __fpsr;
-
-	__stfpsr(&__fpsr);
-	*__flagp = (fexcept_t)(__fpsr >> _FPUSW_SHIFT) & __excepts;
-	return (0);
-}
-
-static __inline int
-fesetexceptflag(const fexcept_t *__flagp, int __excepts)
-{
-	fenv_t __fpsr;
-
-	__stfpsr(&__fpsr);
-	__fpsr &= ~((fenv_t)__excepts << _FPUSW_SHIFT);
-	__fpsr |= (fenv_t)(__excepts & *__flagp) << _FPUSW_SHIFT;
-	__ldfpsr(__fpsr);
-	return (0);
-}
-
-/*
- * It is worthwhile to use the inline version of this function iff it
- * is called with arguments that are compile-time constants (due to
- * dead code elimination).  Unfortunately, gcc isn't smart enough to
- * figure this out automatically, and there's no way to tell it.
- * We assume that constant arguments will be the common case.
- */
-static __inline int
-feraiseexcept(int __excepts)
-{
-	volatile double d;
-
-	/*
-	 * With a compiler that supports the FENV_ACCESS pragma
-	 * properly, simple expressions like '0.0 / 0.0' should
-	 * be sufficient to generate traps.  Unfortunately, we
-	 * need to bring a volatile variable into the equation
-	 * to prevent incorrect optimizations.
-	 */
-	if (__excepts & FE_INVALID) {
-		d = 0.0;
-		d = 0.0 / d;
-	}
-	if (__excepts & FE_DIVBYZERO) {
-		d = 0.0;
-		d = 1.0 / d;
-	}
-	if (__excepts & FE_OVERFLOW) {
-		d = 0x1.ffp1023;
-		d *= 2.0;
-	}
-	if (__excepts & FE_UNDERFLOW) {
-		d = 0x1p-1022;
-		d /= 0x1p1023;
-	}
-	if (__excepts & FE_INEXACT) {
-		d = 0x1p-1022;
-		d += 1.0;
-	}
-	return (0);
-}
-
-static __inline int
-fetestexcept(int __excepts)
-{
-	fenv_t __fpsr;
-
-	__stfpsr(&__fpsr);
-	return ((__fpsr >> _FPUSW_SHIFT) & __excepts);
-}
-
-
-static __inline int
-fegetround(void)
-{
-	fenv_t __fpsr;
-
-	__stfpsr(&__fpsr);
-	return (__fpsr & _ROUND_MASK);
-}
-
-static __inline int
-fesetround(int __round)
-{
-	fenv_t __fpsr;
-
-	if (__round & ~_ROUND_MASK)
-		return (-1);
-	__stfpsr(&__fpsr);
-	__fpsr &= ~_ROUND_MASK;
-	__fpsr |= __round;
-	__ldfpsr(__fpsr);
-	return (0);
-}
-
-static __inline int
-fegetenv(fenv_t *__envp)
-{
-
-	__stfpsr(__envp);
-	return (0);
-}
-
-static __inline int
-feholdexcept(fenv_t *__envp)
-{
-	fenv_t __fpsr;
-
-	__stfpsr(&__fpsr);
-	*__envp = __fpsr;
-	__fpsr &= ~((fenv_t)FE_ALL_EXCEPT << _FPUSW_SHIFT);
-	__fpsr |= FE_ALL_EXCEPT;
-	__ldfpsr(__fpsr);
-	return (0);
-}
-
-static __inline int
-fesetenv(const fenv_t *__envp)
-{
-
-	__ldfpsr(*__envp);
-	return (0);
-}
-
-int feupdateenv(const fenv_t *__envp);
-
-#if __BSD_VISIBLE
-
-static __inline int
-feenableexcept(int __mask)
-{
-	fenv_t __newfpsr, __oldfpsr;
-
-	__stfpsr(&__oldfpsr);
-	__newfpsr = __oldfpsr & ~(__mask & FE_ALL_EXCEPT);
-	__ldfpsr(__newfpsr);
-	return (~__oldfpsr & FE_ALL_EXCEPT);
-}
-
-static __inline int
-fedisableexcept(int __mask)
-{
-	fenv_t __newfpsr, __oldfpsr;
-
-	__stfpsr(&__oldfpsr);
-	__newfpsr = __oldfpsr | (__mask & FE_ALL_EXCEPT);
-	__ldfpsr(__newfpsr);
-	return (~__oldfpsr & FE_ALL_EXCEPT);
-}
-
-static __inline int
-fegetexcept(void)
-{
-	fenv_t __fpsr;
-
-	__stfpsr(&__fpsr);
-	return (~__fpsr & FE_ALL_EXCEPT);
-}
-
-#endif /* __BSD_VISIBLE */
-
-__END_DECLS
-
-#endif	/* !_FENV_H_ */
diff --git a/libm/ia64/s_fma.S b/libm/ia64/s_fma.S
deleted file mode 100644
index 2da6c17..0000000
--- a/libm/ia64/s_fma.S
+++ /dev/null
@@ -1,34 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/ia64/s_fma.S,v 1.1 2005/01/22 09:53:18 das Exp $")
-
-ENTRY(fma, 3)
-{
-	fma.d		f8 = f8, f9, f10
-	br.ret.sptk	b0
-}
diff --git a/libm/ia64/s_fmaf.S b/libm/ia64/s_fmaf.S
deleted file mode 100644
index 320051b..0000000
--- a/libm/ia64/s_fmaf.S
+++ /dev/null
@@ -1,34 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/ia64/s_fmaf.S,v 1.1 2005/01/22 09:53:18 das Exp $")
-
-ENTRY(fmaf, 3)
-{
-	fma.s		f8 = f8, f9, f10
-	br.ret.sptk	b0
-}
diff --git a/libm/ia64/s_fmal.S b/libm/ia64/s_fmal.S
deleted file mode 100644
index 7b8c407..0000000
--- a/libm/ia64/s_fmal.S
+++ /dev/null
@@ -1,34 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/ia64/s_fmal.S,v 1.1 2005/03/07 04:53:11 das Exp $")
-
-ENTRY(fmal, 3)
-{
-	fma		f8 = f8, f9, f10
-	br.ret.sptk	b0
-}
diff --git a/libm/include/alpha/fenv.h b/libm/include/alpha/fenv.h
deleted file mode 100644
index dc7bcb7..0000000
--- a/libm/include/alpha/fenv.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/*-
- * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/alpha/fenv.h,v 1.3 2005/03/16 19:03:44 das Exp $
- */
-
-#ifndef	_FENV_H_
-#define	_FENV_H_
-
-#include <sys/_types.h>
-
-typedef	__uint64_t	fenv_t;
-typedef	__uint16_t	fexcept_t;
-
-/* Exception flags */
-#define	FE_INVALID	0x02
-#define	FE_DIVBYZERO	0x04
-#define	FE_OVERFLOW	0x08
-#define	FE_UNDERFLOW	0x10
-#define	FE_INEXACT	0x20
-#define	FE_INTOVF	0x40	/* not maskable */
-#define	FE_ALL_EXCEPT	(FE_DIVBYZERO | FE_INEXACT | FE_INTOVF | \
-			 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
-
-/* Rounding modes */
-#define	FE_TOWARDZERO	0x00
-#define	FE_DOWNWARD	0x01
-#define	FE_TONEAREST	0x02
-#define	FE_UPWARD	0x03
-#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
-			 FE_UPWARD | FE_TOWARDZERO)
-#define	_ROUND_SHIFT	58
-
-#define	_FPUSW_SHIFT	51
-
-#define	__excb()	__asm __volatile("excb")
-#define	__mf_fpcr(__cw)	__asm __volatile("mf_fpcr %0" : "=f" (*(__cw)))
-#define	__mt_fpcr(__cw)	__asm __volatile("mt_fpcr %0" : : "f" (__cw))
-
-union __fpcr {
-	double __d;
-	fenv_t __bits;
-};
-
-__BEGIN_DECLS
-
-/* Default floating-point environment */
-extern const fenv_t	__fe_dfl_env;
-#define	FE_DFL_ENV	(&__fe_dfl_env)
-
-static __inline int
-feclearexcept(int __excepts)
-{
-	union __fpcr __r;
-
-	__excb();
-	__mf_fpcr(&__r.__d);
-	__r.__bits &= ~((fenv_t)__excepts << _FPUSW_SHIFT);
-	__mt_fpcr(__r.__d);
-	__excb();
-	return (0);
-}
-
-static __inline int
-fegetexceptflag(fexcept_t *__flagp, int __excepts)
-{
-	union __fpcr __r;
-
-	__excb();
-	__mf_fpcr(&__r.__d);
-	__excb();
-	*__flagp = (__r.__bits >> _FPUSW_SHIFT) & __excepts;
-	return (0);
-}
-
-static __inline int
-fesetexceptflag(const fexcept_t *__flagp, int __excepts)
-{
-	union __fpcr __r;
-	fenv_t __xflag, __xexcepts;
-
-	__xflag = (fenv_t)*__flagp << _FPUSW_SHIFT;
-	__xexcepts = (fenv_t)__excepts << _FPUSW_SHIFT;
-	__excb();
-	__mf_fpcr(&__r.__d);
-	__r.__bits &= ~__xexcepts;
-	__r.__bits |= __xflag & __xexcepts;
-	__mt_fpcr(__r.__d);
-	__excb();
-	return (0);
-}
-
-static __inline int
-feraiseexcept(int __excepts)
-{
-
-	/*
-	 * XXX Generating exceptions this way does not actually invoke
-	 * a userland trap handler when enabled, but neither do
-	 * arithmetic operations as far as I can tell.  Perhaps there
-	 * are more bugs in the kernel trap handler.
-	 */
-	fexcept_t __ex = __excepts;
-	fesetexceptflag(&__ex, __excepts);
-	return (0);
-}
-
-static __inline int
-fetestexcept(int __excepts)
-{
-	union __fpcr __r;
-
-	__excb();
-	__mf_fpcr(&__r.__d);
-	__excb();
-	return ((__r.__bits >> _FPUSW_SHIFT) & __excepts);
-}
-
-static __inline int
-fegetround(void)
-{
-	union __fpcr __r;
-
-	/*
-	 * No exception barriers should be required here if we assume
-	 * that only fesetround() can change the rounding mode.
-	 */
-	__mf_fpcr(&__r.__d);
-	return ((int)(__r.__bits >> _ROUND_SHIFT) & _ROUND_MASK);
-}
-
-static __inline int
-fesetround(int __round)
-{
-	union __fpcr __r;
-
-	if (__round & ~_ROUND_MASK)
-		return (-1);
-	__excb();
-	__mf_fpcr(&__r.__d);
-	__r.__bits &= ~((fenv_t)_ROUND_MASK << _ROUND_SHIFT);
-	__r.__bits |= (fenv_t)__round << _ROUND_SHIFT;
-	__mt_fpcr(__r.__d);
-	__excb();
-	return (0);
-}
-
-int	fegetenv(fenv_t *__envp);
-int	feholdexcept(fenv_t *__envp);
-int	fesetenv(const fenv_t *__envp);
-int	feupdateenv(const fenv_t *__envp);
-
-#if __BSD_VISIBLE
-
-int	feenableexcept(int __mask);
-int	fedisableexcept(int __mask);
-int	fegetexcept(void);
-
-#endif /* __BSD_VISIBLE */
-
-__END_DECLS
-
-#endif	/* !_FENV_H_ */
diff --git a/libm/include/amd64/fenv.h b/libm/include/amd64/fenv.h
deleted file mode 100644
index c4f9432..0000000
--- a/libm/include/amd64/fenv.h
+++ /dev/null
@@ -1,203 +0,0 @@
-/*-
- * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/amd64/fenv.h,v 1.5 2005/03/16 22:34:14 das Exp $
- */
-
-#ifndef	_FENV_H_
-#define	_FENV_H_
-
-#include <sys/cdefs.h>
-#include <sys/_types.h>
-
-typedef struct {
-	struct {
-		__uint32_t	__control;
-		__uint32_t	__status;
-		__uint32_t	__tag;
-		char		__other[16];
-	} __x87;
-	__uint32_t		__mxcsr;
-} fenv_t;
-
-typedef	__uint16_t	fexcept_t;
-
-/* Exception flags */
-#define	FE_INVALID	0x01
-#define	FE_DENORMAL	0x02
-#define	FE_DIVBYZERO	0x04
-#define	FE_OVERFLOW	0x08
-#define	FE_UNDERFLOW	0x10
-#define	FE_INEXACT	0x20
-#define	FE_ALL_EXCEPT	(FE_DIVBYZERO | FE_DENORMAL | FE_INEXACT | \
-			 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
-
-/* Rounding modes */
-#define	FE_TONEAREST	0x0000
-#define	FE_DOWNWARD	0x0400
-#define	FE_UPWARD	0x0800
-#define	FE_TOWARDZERO	0x0c00
-#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
-			 FE_UPWARD | FE_TOWARDZERO)
-
-/*
- * As compared to the x87 control word, the SSE unit's control word
- * has the rounding control bits offset by 3 and the exception mask
- * bits offset by 7.
- */
-#define	_SSE_ROUND_SHIFT	3
-#define	_SSE_EMASK_SHIFT	7
-
-__BEGIN_DECLS
-
-/* Default floating-point environment */
-extern const fenv_t	__fe_dfl_env;
-#define	FE_DFL_ENV	(&__fe_dfl_env)
-
-#define	__fldcw(__cw)		__asm __volatile("fldcw %0" : : "m" (__cw))
-#define	__fldenv(__env)		__asm __volatile("fldenv %0" : : "m" (__env))
-#define	__fnclex()		__asm __volatile("fnclex")
-#define	__fnstenv(__env)	__asm __volatile("fnstenv %0" : "=m" (*(__env)))
-#define	__fnstcw(__cw)		__asm __volatile("fnstcw %0" : "=m" (*(__cw)))
-#define	__fnstsw(__sw)		__asm __volatile("fnstsw %0" : "=am" (*(__sw)))
-#define	__fwait()		__asm __volatile("fwait")
-#define	__ldmxcsr(__csr)	__asm __volatile("ldmxcsr %0" : : "m" (__csr))
-#define	__stmxcsr(__csr)	__asm __volatile("stmxcsr %0" : "=m" (*(__csr)))
-
-static __inline int
-feclearexcept(int __excepts)
-{
-	fenv_t __env;
-
-	if (__excepts == FE_ALL_EXCEPT) {
-		__fnclex();
-	} else {
-		__fnstenv(&__env.__x87);
-		__env.__x87.__status &= ~__excepts;
-		__fldenv(__env.__x87);
-	}
-	__stmxcsr(&__env.__mxcsr);
-	__env.__mxcsr &= ~__excepts;
-	__ldmxcsr(__env.__mxcsr);
-	return (0);
-}
-
-static __inline int
-fegetexceptflag(fexcept_t *__flagp, int __excepts)
-{
-	int __mxcsr, __status;
-
-	__stmxcsr(&__mxcsr);
-	__fnstsw(&__status);
-	*__flagp = (__mxcsr | __status) & __excepts;
-	return (0);
-}
-
-int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
-int feraiseexcept(int __excepts);
-
-static __inline int
-fetestexcept(int __excepts)
-{
-	int __mxcsr, __status;
-
-	__stmxcsr(&__mxcsr);
-	__fnstsw(&__status);
-	return ((__status | __mxcsr) & __excepts);
-}
-
-static __inline int
-fegetround(void)
-{
-	int __control;
-
-	/*
-	 * We assume that the x87 and the SSE unit agree on the
-	 * rounding mode.  Reading the control word on the x87 turns
-	 * out to be about 5 times faster than reading it on the SSE
-	 * unit on an Opteron 244.
-	 */
-	__fnstcw(&__control);
-	return (__control & _ROUND_MASK);
-}
-
-static __inline int
-fesetround(int __round)
-{
-	int __mxcsr, __control;
-
-	if (__round & ~_ROUND_MASK)
-		return (-1);
-
-	__fnstcw(&__control);
-	__control &= ~_ROUND_MASK;
-	__control |= __round;
-	__fldcw(__control);
-
-	__stmxcsr(&__mxcsr);
-	__mxcsr &= ~(_ROUND_MASK << _SSE_ROUND_SHIFT);
-	__mxcsr |= __round << _SSE_ROUND_SHIFT;
-	__ldmxcsr(__mxcsr);
-
-	return (0);
-}
-
-int fegetenv(fenv_t *__envp);
-int feholdexcept(fenv_t *__envp);
-
-static __inline int
-fesetenv(const fenv_t *__envp)
-{
-
-	__fldenv(__envp->__x87);
-	__ldmxcsr(__envp->__mxcsr);
-	return (0);
-}
-
-int feupdateenv(const fenv_t *__envp);
-
-#if __BSD_VISIBLE
-
-int feenableexcept(int __mask);
-int fedisableexcept(int __mask);
-
-static __inline int
-fegetexcept(void)
-{
-	int __control;
-
-	/*
-	 * We assume that the masks for the x87 and the SSE unit are
-	 * the same.
-	 */
-	__fnstcw(&__control);
-	return (~__control & FE_ALL_EXCEPT);
-}
-
-#endif /* __BSD_VISIBLE */
-
-__END_DECLS
-
-#endif	/* !_FENV_H_ */
diff --git a/libm/include/arm/fenv.h b/libm/include/arm/fenv.h
index e7a8860..a96f99e 100644
--- a/libm/include/arm/fenv.h
+++ b/libm/include/arm/fenv.h
@@ -26,192 +26,151 @@
  * $FreeBSD: src/lib/msun/arm/fenv.h,v 1.5 2005/03/16 19:03:45 das Exp $
  */
 
-#ifndef	_FENV_H_
-#define	_FENV_H_
+/*
+ * Rewritten for Android.
+ *
+ * The ARM FPSCR is described here:
+ * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0344b/Chdfafia.html
+ */
 
-#include <sys/_types.h>
+#ifndef _FENV_H_
+#define _FENV_H_
 
-typedef	__uint32_t	fenv_t;
-typedef	__uint32_t	fexcept_t;
+#include <sys/types.h>
 
-/* Exception flags */
-#define	FE_INVALID	0x0001
-#define	FE_DIVBYZERO	0x0002
-#define	FE_OVERFLOW	0x0004
-#define	FE_UNDERFLOW	0x0008
-#define	FE_INEXACT	0x0010
-#define	FE_ALL_EXCEPT	(FE_DIVBYZERO | FE_INEXACT | \
-			 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
-
-/* Rounding modes */
-#define	FE_TONEAREST	0x0000
-#define	FE_TOWARDZERO	0x0001
-#define	FE_UPWARD	0x0002
-#define	FE_DOWNWARD	0x0003
-#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
-			 FE_UPWARD | FE_TOWARDZERO)
 __BEGIN_DECLS
 
-/* Default floating-point environment */
-extern const fenv_t	__fe_dfl_env;
-#define	FE_DFL_ENV	(&__fe_dfl_env)
+typedef __uint32_t fenv_t;
+typedef __uint32_t fexcept_t;
 
-/* We need to be able to map status flag positions to mask flag positions */
-#define _FPUSW_SHIFT	16
-#define	_ENABLE_MASK	(FE_ALL_EXCEPT << _FPUSW_SHIFT)
+/* Exception flags. */
+#define FE_INVALID    0x01
+#define FE_DIVBYZERO  0x02
+#define FE_OVERFLOW   0x04
+#define FE_UNDERFLOW  0x08
+#define FE_INEXACT    0x10
+#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
+#define _FPSCR_ENABLE_SHIFT 8
+#define _FPSCR_ENABLE_MASK (FE_ALL_EXCEPT << _FPSCR_ENABLE_SHIFT)
 
-#ifdef	ARM_HARD_FLOAT
-#define	__rfs(__fpsr)	__asm __volatile("rfs %0" : "=r" (*(__fpsr)))
-#define	__wfs(__fpsr)	__asm __volatile("wfs %0" : : "r" (__fpsr))
-#else
-#define __rfs(__fpsr)
-#define __wfs(__fpsr)
-#endif
+/* Rounding modes. */
+#define FE_TONEAREST  0x0
+#define FE_UPWARD     0x1
+#define FE_DOWNWARD   0x2
+#define FE_TOWARDZERO 0x3
+#define _FPSCR_RMODE_SHIFT 22
 
-static __inline int
-feclearexcept(int __excepts)
-{
-	fexcept_t __fpsr;
+/* Default floating-point environment. */
+extern const fenv_t __fe_dfl_env;
+#define FE_DFL_ENV (&__fe_dfl_env)
 
-	__rfs(&__fpsr);
-	__fpsr &= ~__excepts;
-	__wfs(__fpsr);
-	return (0);
+static __inline int fegetenv(fenv_t* __envp) {
+  fenv_t _fpscr;
+  __asm__ __volatile__("vmrs %0,fpscr" : "=r" (_fpscr));
+  *__envp = _fpscr;
+  return 0;
 }
 
-static __inline int
-fegetexceptflag(fexcept_t *__flagp, int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	*__flagp = __fpsr & __excepts;
-	return (0);
+static __inline int fesetenv(const fenv_t* __envp) {
+  fenv_t _fpscr = *__envp;
+  __asm__ __volatile__("vmsr fpscr,%0" : :"ri" (_fpscr));
+  return 0;
 }
 
-static __inline int
-fesetexceptflag(const fexcept_t *__flagp, int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	__fpsr &= ~__excepts;
-	__fpsr |= *__flagp & __excepts;
-	__wfs(__fpsr);
-	return (0);
+static __inline int feclearexcept(int __excepts) {
+  fexcept_t __fpscr;
+  fegetenv(&__fpscr);
+  __fpscr &= ~__excepts;
+  fesetenv(&__fpscr);
+  return 0;
 }
 
-static __inline int
-feraiseexcept(int __excepts)
-{
-	fexcept_t __ex = __excepts;
-
-	fesetexceptflag(&__ex, __excepts);	/* XXX */
-	return (0);
+static __inline int fegetexceptflag(fexcept_t* __flagp, int __excepts) {
+  fexcept_t __fpscr;
+  fegetenv(&__fpscr);
+  *__flagp = __fpscr & __excepts;
+  return 0;
 }
 
-static __inline int
-fetestexcept(int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	return (__fpsr & __excepts);
+static __inline int fesetexceptflag(const fexcept_t* __flagp, int __excepts) {
+  fexcept_t __fpscr;
+  fegetenv(&__fpscr);
+  __fpscr &= ~__excepts;
+  __fpscr |= *__flagp & __excepts;
+  fesetenv(&__fpscr);
+  return 0;
 }
 
-static __inline int
-fegetround(void)
-{
-
-	/*
-	 * Apparently, the rounding mode is specified as part of the
-	 * instruction format on ARM, so the dynamic rounding mode is
-	 * indeterminate.  Some FPUs may differ.
-	 */
-	return (-1);
+static __inline int feraiseexcept(int __excepts) {
+  fexcept_t __ex = __excepts;
+  fesetexceptflag(&__ex, __excepts);
+  return 0;
 }
 
-static __inline int
-fesetround(int __round)
-{
-
-	return (-1);
+static __inline int fetestexcept(int __excepts) {
+  fexcept_t __fpscr;
+  fegetenv(&__fpscr);
+  return (__fpscr & __excepts);
 }
 
-static __inline int
-fegetenv(fenv_t *__envp)
-{
-
-	__rfs(__envp);
-	return (0);
+static __inline int fegetround(void) {
+  fenv_t _fpscr;
+  fegetenv(&_fpscr);
+  return ((_fpscr >> _FPSCR_RMODE_SHIFT) & 0x3);
 }
 
-static __inline int
-feholdexcept(fenv_t *__envp)
-{
-	fenv_t __env;
-
-	__rfs(&__env);
-	*__envp = __env;
-	__env &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
-	__wfs(__env);
-	return (0);
+static __inline int fesetround(int __round) {
+  fenv_t _fpscr;
+  fegetenv(&_fpscr);
+  _fpscr &= ~(0x3 << _FPSCR_RMODE_SHIFT);
+  _fpscr |= (__round << _FPSCR_RMODE_SHIFT);
+  fesetenv(&_fpscr);
+  return 0;
 }
 
-static __inline int
-fesetenv(const fenv_t *__envp)
-{
-
-	__wfs(*__envp);
-	return (0);
+static __inline int feholdexcept(fenv_t* __envp) {
+  fenv_t __env;
+  fegetenv(&__env);
+  *__envp = __env;
+  __env &= ~(FE_ALL_EXCEPT | _FPSCR_ENABLE_MASK);
+  fesetenv(&__env);
+  return 0;
 }
 
-static __inline int
-feupdateenv(const fenv_t *__envp)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	__wfs(*__envp);
-	feraiseexcept(__fpsr & FE_ALL_EXCEPT);
-	return (0);
+static __inline int feupdateenv(const fenv_t* __envp) {
+  fexcept_t __fpscr;
+  fegetenv(&__fpscr);
+  fesetenv(__envp);
+  feraiseexcept(__fpscr & FE_ALL_EXCEPT);
+  return 0;
 }
 
 #if __BSD_VISIBLE
 
-static __inline int
-feenableexcept(int __mask)
-{
-	fenv_t __old_fpsr, __new_fpsr;
-
-	__rfs(&__old_fpsr);
-	__new_fpsr = __old_fpsr | (__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT;
-	__wfs(__new_fpsr);
-	return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
+static __inline int feenableexcept(int __mask) {
+  fenv_t __old_fpscr, __new_fpscr;
+  fegetenv(&__old_fpscr);
+  __new_fpscr = __old_fpscr | (__mask & FE_ALL_EXCEPT) << _FPSCR_ENABLE_SHIFT;
+  fesetenv(&__new_fpscr);
+  return ((__old_fpscr >> _FPSCR_ENABLE_SHIFT) & FE_ALL_EXCEPT);
 }
 
-static __inline int
-fedisableexcept(int __mask)
-{
-	fenv_t __old_fpsr, __new_fpsr;
-
-	__rfs(&__old_fpsr);
-	__new_fpsr = __old_fpsr & ~((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
-	__wfs(__new_fpsr);
-	return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
+static __inline int fedisableexcept(int __mask) {
+  fenv_t __old_fpscr, __new_fpscr;
+  fegetenv(&__old_fpscr);
+  __new_fpscr = __old_fpscr & ~((__mask & FE_ALL_EXCEPT) << _FPSCR_ENABLE_SHIFT);
+  fesetenv(&__new_fpscr);
+  return ((__old_fpscr >> _FPSCR_ENABLE_SHIFT) & FE_ALL_EXCEPT);
 }
 
-static __inline int
-fegetexcept(void)
-{
-	fenv_t __fpsr;
-
-	__rfs(&__fpsr);
-	return ((__fpsr & _ENABLE_MASK) >> _FPUSW_SHIFT);
+static __inline int fegetexcept(void) {
+  fenv_t __fpscr;
+  fegetenv(&__fpscr);
+  return ((__fpscr & _FPSCR_ENABLE_MASK) >> _FPSCR_ENABLE_SHIFT);
 }
 
 #endif /* __BSD_VISIBLE */
 
 __END_DECLS
 
-#endif	/* !_FENV_H_ */
+#endif /* !_FENV_H_ */
diff --git a/libm/include/complex.h b/libm/include/complex.h
new file mode 100644
index 0000000..0702541
--- /dev/null
+++ b/libm/include/complex.h
@@ -0,0 +1,92 @@
+/*-
+ * Copyright (c) 2001-2011 The FreeBSD Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _COMPLEX_H
+#define	_COMPLEX_H
+
+#include <sys/cdefs.h>
+
+#ifdef __GNUC__
+#if __STDC_VERSION__ < 199901
+#define	_Complex	__complex__
+#endif
+#define	_Complex_I	((float _Complex)1.0i)
+#endif
+
+#ifdef __generic
+_Static_assert(__generic(_Complex_I, float _Complex, 1, 0),
+    "_Complex_I must be of type float _Complex");
+#endif
+
+#define	complex		_Complex
+#define	I		_Complex_I
+
+__BEGIN_DECLS
+
+double		cabs(double complex);
+float		cabsf(float complex);
+long double	cabsl(long double complex);
+double		carg(double complex);
+float		cargf(float complex);
+long double	cargl(long double complex);
+double complex	ccos(double complex);
+float complex	ccosf(float complex);
+double complex	ccosh(double complex);
+float complex	ccoshf(float complex);
+double complex	cexp(double complex);
+float complex	cexpf(float complex);
+double		cimag(double complex) __pure2;
+float		cimagf(float complex) __pure2;
+long double	cimagl(long double complex) __pure2;
+double complex	conj(double complex) __pure2;
+float complex	conjf(float complex) __pure2;
+long double complex
+		conjl(long double complex) __pure2;
+float complex	cprojf(float complex) __pure2;
+double complex	cproj(double complex) __pure2;
+long double complex
+		cprojl(long double complex) __pure2;
+double		creal(double complex) __pure2;
+float		crealf(float complex) __pure2;
+long double	creall(long double complex) __pure2;
+double complex	csin(double complex);
+float complex	csinf(float complex);
+double complex	csinh(double complex);
+float complex	csinhf(float complex);
+double complex	csqrt(double complex);
+float complex	csqrtf(float complex);
+long double complex
+		csqrtl(long double complex);
+double complex	ctan(double complex);
+float complex	ctanf(float complex);
+double complex	ctanh(double complex);
+float complex	ctanhf(float complex);
+
+__END_DECLS
+
+#endif /* _COMPLEX_H */
diff --git a/libm/include/i387/fenv.h b/libm/include/i387/fenv.h
index 4e322b7..c0421c0 100644
--- a/libm/include/i387/fenv.h
+++ b/libm/include/i387/fenv.h
@@ -29,8 +29,7 @@
 #ifndef	_FENV_H_
 #define	_FENV_H_
 
-#include <sys/cdefs.h>
-#include <sys/_types.h>
+#include <sys/types.h>
 
 __BEGIN_DECLS
 
diff --git a/libm/include/ia64/fenv.h b/libm/include/ia64/fenv.h
deleted file mode 100644
index 8c6b65b..0000000
--- a/libm/include/ia64/fenv.h
+++ /dev/null
@@ -1,242 +0,0 @@
-/*-
- * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/ia64/fenv.h,v 1.4 2005/03/16 19:03:45 das Exp $
- */
-
-#ifndef	_FENV_H_
-#define	_FENV_H_
-
-#include <sys/_types.h>
-
-typedef	__uint64_t	fenv_t;
-typedef	__uint16_t	fexcept_t;
-
-/* Exception flags */
-#define	FE_INVALID	0x01
-#define	FE_DENORMAL	0x02
-#define	FE_DIVBYZERO	0x04
-#define	FE_OVERFLOW	0x08
-#define	FE_UNDERFLOW	0x10
-#define	FE_INEXACT	0x20
-#define	FE_ALL_EXCEPT	(FE_DIVBYZERO | FE_DENORMAL | FE_INEXACT | \
-			 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
-
-/* Rounding modes */
-#define	FE_TONEAREST	0x0000
-#define	FE_DOWNWARD	0x0400
-#define	FE_UPWARD	0x0800
-#define	FE_TOWARDZERO	0x0c00
-#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
-			 FE_UPWARD | FE_TOWARDZERO)
-
-__BEGIN_DECLS
-
-/* Default floating-point environment */
-extern const fenv_t	__fe_dfl_env;
-#define	FE_DFL_ENV	(&__fe_dfl_env)
-
-#define	_FPUSW_SHIFT	13
-
-#define	__stfpsr(__r)	__asm __volatile("mov %0=ar.fpsr" : "=r" (*(__r)))
-#define	__ldfpsr(__r)	__asm __volatile("mov ar.fpsr=%0;;" : : "r" (__r))
-
-static __inline int
-feclearexcept(int __excepts)
-{
-	fenv_t __fpsr;
-
-	__stfpsr(&__fpsr);
-	__fpsr &= ~((fenv_t)__excepts << _FPUSW_SHIFT);
-	__ldfpsr(__fpsr);
-	return (0);
-}
-
-static __inline int
-fegetexceptflag(fexcept_t *__flagp, int __excepts)
-{
-	fenv_t __fpsr;
-
-	__stfpsr(&__fpsr);
-	*__flagp = (fexcept_t)(__fpsr >> _FPUSW_SHIFT) & __excepts;
-	return (0);
-}
-
-static __inline int
-fesetexceptflag(const fexcept_t *__flagp, int __excepts)
-{
-	fenv_t __fpsr;
-
-	__stfpsr(&__fpsr);
-	__fpsr &= ~((fenv_t)__excepts << _FPUSW_SHIFT);
-	__fpsr |= (fenv_t)(__excepts & *__flagp) << _FPUSW_SHIFT;
-	__ldfpsr(__fpsr);
-	return (0);
-}
-
-/*
- * It is worthwhile to use the inline version of this function iff it
- * is called with arguments that are compile-time constants (due to
- * dead code elimination).  Unfortunately, gcc isn't smart enough to
- * figure this out automatically, and there's no way to tell it.
- * We assume that constant arguments will be the common case.
- */
-static __inline int
-feraiseexcept(int __excepts)
-{
-	volatile double d;
-
-	/*
-	 * With a compiler that supports the FENV_ACCESS pragma
-	 * properly, simple expressions like '0.0 / 0.0' should
-	 * be sufficient to generate traps.  Unfortunately, we
-	 * need to bring a volatile variable into the equation
-	 * to prevent incorrect optimizations.
-	 */
-	if (__excepts & FE_INVALID) {
-		d = 0.0;
-		d = 0.0 / d;
-	}
-	if (__excepts & FE_DIVBYZERO) {
-		d = 0.0;
-		d = 1.0 / d;
-	}
-	if (__excepts & FE_OVERFLOW) {
-		d = 0x1.ffp1023;
-		d *= 2.0;
-	}
-	if (__excepts & FE_UNDERFLOW) {
-		d = 0x1p-1022;
-		d /= 0x1p1023;
-	}
-	if (__excepts & FE_INEXACT) {
-		d = 0x1p-1022;
-		d += 1.0;
-	}
-	return (0);
-}
-
-static __inline int
-fetestexcept(int __excepts)
-{
-	fenv_t __fpsr;
-
-	__stfpsr(&__fpsr);
-	return ((__fpsr >> _FPUSW_SHIFT) & __excepts);
-}
-
-
-static __inline int
-fegetround(void)
-{
-	fenv_t __fpsr;
-
-	__stfpsr(&__fpsr);
-	return (__fpsr & _ROUND_MASK);
-}
-
-static __inline int
-fesetround(int __round)
-{
-	fenv_t __fpsr;
-
-	if (__round & ~_ROUND_MASK)
-		return (-1);
-	__stfpsr(&__fpsr);
-	__fpsr &= ~_ROUND_MASK;
-	__fpsr |= __round;
-	__ldfpsr(__fpsr);
-	return (0);
-}
-
-static __inline int
-fegetenv(fenv_t *__envp)
-{
-
-	__stfpsr(__envp);
-	return (0);
-}
-
-static __inline int
-feholdexcept(fenv_t *__envp)
-{
-	fenv_t __fpsr;
-
-	__stfpsr(&__fpsr);
-	*__envp = __fpsr;
-	__fpsr &= ~((fenv_t)FE_ALL_EXCEPT << _FPUSW_SHIFT);
-	__fpsr |= FE_ALL_EXCEPT;
-	__ldfpsr(__fpsr);
-	return (0);
-}
-
-static __inline int
-fesetenv(const fenv_t *__envp)
-{
-
-	__ldfpsr(*__envp);
-	return (0);
-}
-
-int feupdateenv(const fenv_t *__envp);
-
-#if __BSD_VISIBLE
-
-static __inline int
-feenableexcept(int __mask)
-{
-	fenv_t __newfpsr, __oldfpsr;
-
-	__stfpsr(&__oldfpsr);
-	__newfpsr = __oldfpsr & ~(__mask & FE_ALL_EXCEPT);
-	__ldfpsr(__newfpsr);
-	return (~__oldfpsr & FE_ALL_EXCEPT);
-}
-
-static __inline int
-fedisableexcept(int __mask)
-{
-	fenv_t __newfpsr, __oldfpsr;
-
-	__stfpsr(&__oldfpsr);
-	__newfpsr = __oldfpsr | (__mask & FE_ALL_EXCEPT);
-	__ldfpsr(__newfpsr);
-	return (~__oldfpsr & FE_ALL_EXCEPT);
-}
-
-static __inline int
-fegetexcept(void)
-{
-	fenv_t __fpsr;
-
-	__stfpsr(&__fpsr);
-	return (~__fpsr & FE_ALL_EXCEPT);
-}
-
-#endif /* __BSD_VISIBLE */
-
-__END_DECLS
-
-#endif	/* !_FENV_H_ */
diff --git a/libm/include/math.h b/libm/include/math.h
index a86a16f..b13eca9 100644
--- a/libm/include/math.h
+++ b/libm/include/math.h
@@ -11,18 +11,16 @@
 
 /*
  * from: @(#)fdlibm.h 5.1 93/09/24
- * $FreeBSD: src/lib/msun/src/math.h,v 1.61 2005/04/16 21:12:47 das Exp $
+ * $FreeBSD$
  */
 
 #ifndef _MATH_H_
 #define	_MATH_H_
 
 #include <sys/cdefs.h>
-#include <sys/types.h>
+#include <sys/_types.h>
 #include <limits.h>
 
-#define __pure2
-
 /*
  * ANSI/POSIX
  */
@@ -36,37 +34,29 @@
 	float		__uf;
 } __nan;
 
-/* #if __GNUC_PREREQ__(3, 3) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800) */
-#if 1
+#if __GNUC_PREREQ__(3, 3) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800)
 #define	__MATH_BUILTIN_CONSTANTS
 #endif
 
-/* #if __GNUC_PREREQ__(3, 0) && !defined(__INTEL_COMPILER) */
-#if 1
+#if __GNUC_PREREQ__(3, 0) && !defined(__INTEL_COMPILER)
 #define	__MATH_BUILTIN_RELOPS
 #endif
 
-/* #ifdef __MATH_BUILTIN_CONSTANTS */
-#if 1
+#ifdef __MATH_BUILTIN_CONSTANTS
 #define	HUGE_VAL	__builtin_huge_val()
 #else
 #define	HUGE_VAL	(__infinity.__ud)
 #endif
 
-/* #if __ISO_C_VISIBLE >= 1999 */
-#if 0
-#define	FP_ILOGB0	(-__INT_MAX)
-#define	FP_ILOGBNAN	__INT_MAX
-#else
-#define	FP_ILOGB0	(-INT_MAX)
-#define	FP_ILOGBNAN	INT_MAX
-#endif
+#if __ISO_C_VISIBLE >= 1999
+#define	FP_ILOGB0	(-INT_MAX) /* Android-changed */
+#define	FP_ILOGBNAN	INT_MAX /* Android-changed */
 
 #ifdef __MATH_BUILTIN_CONSTANTS
 #define	HUGE_VALF	__builtin_huge_valf()
 #define	HUGE_VALL	__builtin_huge_vall()
-#define	INFINITY	__builtin_inf()
-#define	NAN		__builtin_nan("")
+#define	INFINITY	__builtin_inff()
+#define	NAN		__builtin_nanf("")
 #else
 #define	HUGE_VALF	(float)HUGE_VAL
 #define	HUGE_VALL	(long double)HUGE_VAL
@@ -78,14 +68,11 @@
 #define	MATH_ERREXCEPT	2
 #define	math_errhandling	MATH_ERREXCEPT
 
-/* XXX We need a <machine/math.h>. */
-#if defined(__ia64__) || defined(__sparc64__)
-#define	FP_FAST_FMA
-#endif
+#define	FP_FAST_FMAF	1
 #ifdef __ia64__
-#define	FP_FAST_FMAL
+#define	FP_FAST_FMA	1
+#define	FP_FAST_FMAL	1
 #endif
-#define	FP_FAST_FMAF
 
 /* Symbolic constants to classify floating point numbers. */
 #define	FP_INFINITE	0x01
@@ -104,10 +91,10 @@
     : __isfinitel(x))
 #define	isinf(x)					\
     ((sizeof (x) == sizeof (float)) ? __isinff(x)	\
-    : (sizeof (x) == sizeof (double)) ? __isinf(x)	\
+    : (sizeof (x) == sizeof (double)) ? isinf(x)	\
     : __isinfl(x))
 #define	isnan(x)					\
-    ((sizeof (x) == sizeof (float)) ? isnanf(x)		\
+    ((sizeof (x) == sizeof (float)) ? __isnanf(x)	\
     : (sizeof (x) == sizeof (double)) ? isnan(x)	\
     : __isnanl(x))
 #define	isnormal(x)					\
@@ -137,16 +124,14 @@
     : (sizeof (x) == sizeof (double)) ? __signbit(x)	\
     : __signbitl(x))
 
-#if 0
 typedef	__double_t	double_t;
 typedef	__float_t	float_t;
-#endif 
-/* #endif */ /* __ISO_C_VISIBLE >= 1999 */
+#endif /* __ISO_C_VISIBLE >= 1999 */
 
 /*
  * XOPEN/SVID
  */
-/* #if __BSD_VISIBLE || __XSI_VISIBLE */
+#if __BSD_VISIBLE || __XSI_VISIBLE
 #define	M_E		2.7182818284590452354	/* e */
 #define	M_LOG2E		1.4426950408889634074	/* log 2e */
 #define	M_LOG10E	0.43429448190325182765	/* log 10e */
@@ -163,7 +148,7 @@
 
 #define	MAXFLOAT	((float)3.40282346638528860e+38)
 extern int signgam;
-/* #endif */ /* __BSD_VISIBLE || __XSI_VISIBLE */
+#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
 
 #if __BSD_VISIBLE
 #if 0
@@ -190,8 +175,8 @@
 int	__isfinite(double) __pure2;
 int	__isfinitel(long double) __pure2;
 int	__isinff(float) __pure2;
-int     __isinf(double) __pure2;
 int	__isinfl(long double) __pure2;
+int	__isnanf(float) __pure2;
 int	__isnanl(long double) __pure2;
 int	__isnormalf(float) __pure2;
 int	__isnormal(double) __pure2;
@@ -230,7 +215,7 @@
 /*
  * These functions are not in C90.
  */
-/* #if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE */
+#if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE
 double	acosh(double);
 double	asinh(double);
 double	atanh(double);
@@ -242,12 +227,13 @@
 double	fma(double, double, double);
 double	hypot(double, double);
 int	ilogb(double) __pure2;
-/* int	(isinf)(double) __pure2; */
+int	(isinf)(double) __pure2;
 int	(isnan)(double) __pure2;
 double	lgamma(double);
 long long llrint(double);
 long long llround(double);
 double	log1p(double);
+double	log2(double);
 double	logb(double);
 long	lrint(double);
 long	lround(double);
@@ -256,23 +242,26 @@
 double	remainder(double, double);
 double	remquo(double, double, int *);
 double	rint(double);
-/* #endif */ /* __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE */
+#endif /* __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE */
 
-/* #if __BSD_VISIBLE || __XSI_VISIBLE */
+#if __BSD_VISIBLE || __XSI_VISIBLE
 double	j0(double);
 double	j1(double);
 double	jn(int, double);
-double	scalb(double, double);
 double	y0(double);
 double	y1(double);
 double	yn(int, double);
 
-/* #if __XSI_VISIBLE <= 500 || __BSD_VISIBLE */
+#if __XSI_VISIBLE <= 500 || __BSD_VISIBLE
 double	gamma(double);
-/* #endif */
-/* #endif */ /* __BSD_VISIBLE || __XSI_VISIBLE */
+#endif
 
-/* #if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 */
+#if __XSI_VISIBLE <= 600 || __BSD_VISIBLE
+double	scalb(double, double);
+#endif
+#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
+
+#if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999
 double	copysign(double, double) __pure2;
 double	fdim(double, double);
 double	fmax(double, double) __pure2;
@@ -283,12 +272,12 @@
 double	scalbn(double, int);
 double	tgamma(double);
 double	trunc(double);
-/* #endif */
+#endif
 
 /*
  * BSD math library entry points
  */
-/* #if __BSD_VISIBLE */
+#if __BSD_VISIBLE
 double	drem(double, double);
 int	finite(double) __pure2;
 int	isnanf(float) __pure2;
@@ -304,10 +293,10 @@
  * IEEE Test Vector
  */
 double	significand(double);
-/* #endif */ /* __BSD_VISIBLE */
+#endif /* __BSD_VISIBLE */
 
 /* float versions of ANSI/POSIX functions */
-/*#if __ISO_C_VISIBLE >= 1999 */
+#if __ISO_C_VISIBLE >= 1999
 float	acosf(float);
 float	asinf(float);
 float	atanf(float);
@@ -328,6 +317,7 @@
 float	ldexpf(float, int);
 float	log10f(float);
 float	log1pf(float);
+float	log2f(float);
 float	logf(float);
 float	modff(float, float *);	/* fundamentally !__pure2 */
 
@@ -370,12 +360,12 @@
 float	fmaf(float, float, float);
 float	fmaxf(float, float) __pure2;
 float	fminf(float, float) __pure2;
-/* #endif */
+#endif
 
 /*
  * float versions of BSD math library entry points
  */
-/* #if __BSD_VISIBLE */
+#if __BSD_VISIBLE
 float	dremf(float, float);
 int	finitef(float) __pure2;
 float	gammaf(float);
@@ -399,98 +389,92 @@
  * float version of IEEE Test Vector
  */
 float	significandf(float);
-/* #endif */	/* __BSD_VISIBLE */ 
+#endif	/* __BSD_VISIBLE */
 
 /*
  * long double versions of ISO/POSIX math functions
  */
-/* #if __ISO_C_VISIBLE >= 1999 */
-#if 0
-long double	acoshl(long double);
+#if __ISO_C_VISIBLE >= 1999
 long double	acosl(long double);
-long double	asinhl(long double);
 long double	asinl(long double);
 long double	atan2l(long double, long double);
-long double	atanhl(long double);
 long double	atanl(long double);
 long double	cbrtl(long double);
-#endif
 long double	ceill(long double);
 long double	copysignl(long double, long double) __pure2;
-#if 0
-long double	coshl(long double);
 long double	cosl(long double);
-long double	erfcl(long double);
-long double	erfl(long double);
 long double	exp2l(long double);
 long double	expl(long double);
-long double	expm1l(long double);
-#endif
 long double	fabsl(long double) __pure2;
 long double	fdiml(long double, long double);
 long double	floorl(long double);
 long double	fmal(long double, long double, long double);
 long double	fmaxl(long double, long double) __pure2;
 long double	fminl(long double, long double) __pure2;
-#if 0
 long double	fmodl(long double, long double);
-#endif
 long double	frexpl(long double value, int *); /* fundamentally !__pure2 */
-#if 0
 long double	hypotl(long double, long double);
-#endif
 int		ilogbl(long double) __pure2;
 long double	ldexpl(long double, int);
-#if 0
-long double	lgammal(long double);
 long long	llrintl(long double);
-#endif
 long long	llroundl(long double);
-#if 0
-long double	log10l(long double);
-long double	log1pl(long double);
-long double	log2l(long double);
 long double	logbl(long double);
-long double	logl(long double);
 long		lrintl(long double);
-#endif
 long		lroundl(long double);
-#if 0
 long double	modfl(long double, long double *); /* fundamentally !__pure2 */
 long double	nanl(const char *) __pure2;
 long double	nearbyintl(long double);
-#endif
 long double	nextafterl(long double, long double);
 double		nexttoward(double, long double);
 float		nexttowardf(float, long double);
 long double	nexttowardl(long double, long double);
-#if 0
-long double	powl(long double, long double);
 long double	remainderl(long double, long double);
 long double	remquol(long double, long double, int *);
 long double	rintl(long double);
-#endif
 long double	roundl(long double);
 long double	scalblnl(long double, long);
 long double	scalbnl(long double, int);
-#if 0
-long double	sinhl(long double);
 long double	sinl(long double);
 long double	sqrtl(long double);
-long double	tanhl(long double);
 long double	tanl(long double);
-long double	tgammal(long double);
-#endif
 long double	truncl(long double);
 
-/* BIONIC: GLibc compatibility - required by the ARM toolchain */
-#ifdef _GNU_SOURCE
-void  sincos(double x, double *sin, double *cos);
-void  sincosf(float x, float *sin, float *cos);
-void  sincosl(long double x, long double *sin, long double *cos);
-#endif
-
-/* #endif */ /* __ISO_C_VISIBLE >= 1999 */
+#endif /* __ISO_C_VISIBLE >= 1999 */
 __END_DECLS
 
 #endif /* !_MATH_H_ */
+
+/* separate header for cmath */
+#ifndef _MATH_EXTRA_H_
+#if __ISO_C_VISIBLE >= 1999
+#if _DECLARE_C99_LDBL_MATH
+
+#define _MATH_EXTRA_H_
+
+/*
+ * extra long double versions of math functions for C99 and cmath
+ */
+__BEGIN_DECLS
+
+long double	acoshl(long double);
+long double	asinhl(long double);
+long double	atanhl(long double);
+long double	coshl(long double);
+long double	erfcl(long double);
+long double	erfl(long double);
+long double	expm1l(long double);
+long double	lgammal(long double);
+long double	log10l(long double);
+long double	log1pl(long double);
+long double	log2l(long double);
+long double	logl(long double);
+long double	powl(long double, long double);
+long double	sinhl(long double);
+long double	tanhl(long double);
+long double	tgammal(long double);
+
+__END_DECLS
+
+#endif /* !_DECLARE_C99_LDBL_MATH */
+#endif /* __ISO_C_VISIBLE >= 1999 */
+#endif /* !_MATH_EXTRA_H_ */
diff --git a/libm/include/mips/fenv.h b/libm/include/mips/fenv.h
index e7a8860..ed69cf8 100644
--- a/libm/include/mips/fenv.h
+++ b/libm/include/mips/fenv.h
@@ -26,192 +26,200 @@
  * $FreeBSD: src/lib/msun/arm/fenv.h,v 1.5 2005/03/16 19:03:45 das Exp $
  */
 
-#ifndef	_FENV_H_
-#define	_FENV_H_
+/*
+   Rewritten for Android.
+*/
 
-#include <sys/_types.h>
+/* MIPS FPU floating point control register bits.
+ *
+ * 31-25  -> floating point conditions code bits set by FP compare
+ *           instructions
+ * 24     -> flush denormalized results to zero instead of
+ *           causing unimplemented operation exception.
+ * 23     -> Condition bit
+ * 22     -> In conjunction with FS detects denormalized
+ *           operands and replaces them internally with 0.
+ * 21     -> In conjunction with FS forces denormalized operands
+ *           to the closest normalized value.
+ * 20-18  -> reserved (read as 0, write with 0)
+ * 17     -> cause bit for unimplemented operation
+ * 16     -> cause bit for invalid exception
+ * 15     -> cause bit for division by zero exception
+ * 14     -> cause bit for overflow exception
+ * 13     -> cause bit for underflow exception
+ * 12     -> cause bit for inexact exception
+ * 11     -> enable exception for invalid exception
+ * 10     -> enable exception for division by zero exception
+ *  9     -> enable exception for overflow exception
+ *  8     -> enable exception for underflow exception
+ *  7     -> enable exception for inexact exception
+ *  6     -> flag invalid exception
+ *  5     -> flag division by zero exception
+ *  4     -> flag overflow exception
+ *  3     -> flag underflow exception
+ *  2     -> flag inexact exception
+ *  1-0   -> rounding control
+ *
+ *
+ * Rounding Control:
+ * 00 - rounding to nearest (RN)
+ * 01 - rounding toward zero (RZ)
+ * 10 - rounding (up) toward plus infinity (RP)
+ * 11 - rounding (down)toward minus infinity (RM)
+ */
 
-typedef	__uint32_t	fenv_t;
-typedef	__uint32_t	fexcept_t;
+#ifndef _FENV_H_
+#define _FENV_H_
 
-/* Exception flags */
-#define	FE_INVALID	0x0001
-#define	FE_DIVBYZERO	0x0002
-#define	FE_OVERFLOW	0x0004
-#define	FE_UNDERFLOW	0x0008
-#define	FE_INEXACT	0x0010
-#define	FE_ALL_EXCEPT	(FE_DIVBYZERO | FE_INEXACT | \
-			 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
+#include <sys/types.h>
 
-/* Rounding modes */
-#define	FE_TONEAREST	0x0000
-#define	FE_TOWARDZERO	0x0001
-#define	FE_UPWARD	0x0002
-#define	FE_DOWNWARD	0x0003
-#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
-			 FE_UPWARD | FE_TOWARDZERO)
 __BEGIN_DECLS
 
+typedef __uint32_t    fenv_t;
+typedef __uint32_t    fexcept_t;
+
+/* Exception flags */
+#define FE_INVALID      0x40
+#define FE_DIVBYZERO    0x20
+#define FE_OVERFLOW     0x10
+#define FE_UNDERFLOW    0x08
+#define FE_INEXACT      0x04
+#define FE_ALL_EXCEPT   (FE_DIVBYZERO | FE_INEXACT | \
+                         FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
+#define _FCSR_CAUSE_SHIFT  10
+#define _ENABLE_SHIFT 5
+#define _FCSR_ENABLE_MASK (FE_ALL_EXCEPT << _ENABLE_SHIFT)
+
+/* Rounding modes */
+#define FE_TONEAREST    0x0000
+#define FE_TOWARDZERO   0x0001
+#define FE_UPWARD       0x0002
+#define FE_DOWNWARD     0x0003
+#define _FCSR_RMODE_SHIFT 0
+#define _FCSR_RMASK       0x3
 /* Default floating-point environment */
-extern const fenv_t	__fe_dfl_env;
-#define	FE_DFL_ENV	(&__fe_dfl_env)
+extern const fenv_t    __fe_dfl_env;
+#define FE_DFL_ENV    (&__fe_dfl_env)
 
-/* We need to be able to map status flag positions to mask flag positions */
-#define _FPUSW_SHIFT	16
-#define	_ENABLE_MASK	(FE_ALL_EXCEPT << _FPUSW_SHIFT)
-
-#ifdef	ARM_HARD_FLOAT
-#define	__rfs(__fpsr)	__asm __volatile("rfs %0" : "=r" (*(__fpsr)))
-#define	__wfs(__fpsr)	__asm __volatile("wfs %0" : : "r" (__fpsr))
-#else
-#define __rfs(__fpsr)
-#define __wfs(__fpsr)
+static __inline int fegetenv(fenv_t* __envp) {
+   fenv_t _fcsr = 0;
+#ifdef  __mips_hard_float
+   __asm__ __volatile__("cfc1 %0,$31" : "=r" (_fcsr));
 #endif
-
-static __inline int
-feclearexcept(int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	__fpsr &= ~__excepts;
-	__wfs(__fpsr);
-	return (0);
+   *__envp = _fcsr;
+   return 0;
 }
 
-static __inline int
-fegetexceptflag(fexcept_t *__flagp, int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	*__flagp = __fpsr & __excepts;
-	return (0);
+static __inline int fesetenv(const fenv_t* __envp) {
+  fenv_t _fcsr = *__envp;
+#ifdef  __mips_hard_float
+  __asm__ __volatile__("ctc1 %0,$31" : : "r" (_fcsr));
+#endif
+  return 0;
 }
 
-static __inline int
-fesetexceptflag(const fexcept_t *__flagp, int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	__fpsr &= ~__excepts;
-	__fpsr |= *__flagp & __excepts;
-	__wfs(__fpsr);
-	return (0);
+static __inline int feclearexcept(int __excepts) {
+  fexcept_t __fcsr;
+  fegetenv(&__fcsr);
+  __excepts &= FE_ALL_EXCEPT;
+  __fcsr &= ~(__excepts | (__excepts << _FCSR_CAUSE_SHIFT));
+  fesetenv(&__fcsr);
+  return 0;
 }
 
-static __inline int
-feraiseexcept(int __excepts)
-{
-	fexcept_t __ex = __excepts;
-
-	fesetexceptflag(&__ex, __excepts);	/* XXX */
-	return (0);
+static __inline int fegetexceptflag(fexcept_t* __flagp, int __excepts) {
+  fexcept_t __fcsr;
+  fegetenv(&__fcsr);
+  *__flagp = __fcsr & __excepts & FE_ALL_EXCEPT;
+  return 0;
 }
 
-static __inline int
-fetestexcept(int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	return (__fpsr & __excepts);
+static __inline int fesetexceptflag(const fexcept_t* __flagp, int __excepts) {
+  fexcept_t __fcsr;
+  fegetenv(&__fcsr);
+  /* Ensure that flags are all legal */
+  __excepts &= FE_ALL_EXCEPT;
+  __fcsr &= ~__excepts;
+  __fcsr |= *__flagp & __excepts;
+  fesetenv(&__fcsr);
+  return 0;
 }
 
-static __inline int
-fegetround(void)
-{
-
-	/*
-	 * Apparently, the rounding mode is specified as part of the
-	 * instruction format on ARM, so the dynamic rounding mode is
-	 * indeterminate.  Some FPUs may differ.
-	 */
-	return (-1);
+static __inline int feraiseexcept(int __excepts) {
+  fexcept_t __fcsr;
+  fegetenv(&__fcsr);
+  /* Ensure that flags are all legal */
+  __excepts &= FE_ALL_EXCEPT;
+  /* Cause bit needs to be set as well for generating the exception*/
+  __fcsr |= __excepts | (__excepts << _FCSR_CAUSE_SHIFT);
+  fesetenv(&__fcsr);
+  return 0;
 }
 
-static __inline int
-fesetround(int __round)
-{
-
-	return (-1);
+static __inline int fetestexcept(int __excepts) {
+  fexcept_t __FCSR;
+  fegetenv(&__FCSR);
+  return (__FCSR & __excepts & FE_ALL_EXCEPT);
 }
 
-static __inline int
-fegetenv(fenv_t *__envp)
-{
-
-	__rfs(__envp);
-	return (0);
+static __inline int fegetround(void) {
+  fenv_t _fcsr;
+  fegetenv(&_fcsr);
+  return (_fcsr & _FCSR_RMASK);
 }
 
-static __inline int
-feholdexcept(fenv_t *__envp)
-{
-	fenv_t __env;
-
-	__rfs(&__env);
-	*__envp = __env;
-	__env &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
-	__wfs(__env);
-	return (0);
+static __inline int fesetround(int __round) {
+  fenv_t _fcsr;
+  fegetenv(&_fcsr);
+  _fcsr &= ~_FCSR_RMASK;
+  _fcsr |= (__round & _FCSR_RMASK ) ;
+  fesetenv(&_fcsr);
+  return 0;
 }
 
-static __inline int
-fesetenv(const fenv_t *__envp)
-{
-
-	__wfs(*__envp);
-	return (0);
+static __inline int feholdexcept(fenv_t* __envp) {
+  fenv_t __env;
+  fegetenv(&__env);
+  *__envp = __env;
+  __env &= ~(FE_ALL_EXCEPT | _FCSR_ENABLE_MASK);
+  fesetenv(&__env);
+  return 0;
 }
 
-static __inline int
-feupdateenv(const fenv_t *__envp)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	__wfs(*__envp);
-	feraiseexcept(__fpsr & FE_ALL_EXCEPT);
-	return (0);
+static __inline int feupdateenv(const fenv_t* __envp) {
+  fexcept_t __fcsr;
+  fegetenv(&__fcsr);
+  fesetenv(__envp);
+  feraiseexcept(__fcsr & FE_ALL_EXCEPT);
+  return 0;
 }
 
 #if __BSD_VISIBLE
 
-static __inline int
-feenableexcept(int __mask)
-{
-	fenv_t __old_fpsr, __new_fpsr;
-
-	__rfs(&__old_fpsr);
-	__new_fpsr = __old_fpsr | (__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT;
-	__wfs(__new_fpsr);
-	return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
+static __inline int feenableexcept(int __mask) {
+  fenv_t __old_fcsr, __new_fcsr;
+  fegetenv(&__old_fcsr);
+  __new_fcsr = __old_fcsr | (__mask & FE_ALL_EXCEPT) << _ENABLE_SHIFT;
+  fesetenv(&__new_fcsr);
+  return ((__old_fcsr >> _ENABLE_SHIFT) & FE_ALL_EXCEPT);
 }
 
-static __inline int
-fedisableexcept(int __mask)
-{
-	fenv_t __old_fpsr, __new_fpsr;
-
-	__rfs(&__old_fpsr);
-	__new_fpsr = __old_fpsr & ~((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
-	__wfs(__new_fpsr);
-	return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
+static __inline int fedisableexcept(int __mask) {
+  fenv_t __old_fcsr, __new_fcsr;
+  fegetenv(&__old_fcsr);
+  __new_fcsr = __old_fcsr & ~((__mask & FE_ALL_EXCEPT) << _ENABLE_SHIFT);
+  fesetenv(&__new_fcsr);
+  return ((__old_fcsr >> _ENABLE_SHIFT) & FE_ALL_EXCEPT);
 }
 
-static __inline int
-fegetexcept(void)
-{
-	fenv_t __fpsr;
-
-	__rfs(&__fpsr);
-	return ((__fpsr & _ENABLE_MASK) >> _FPUSW_SHIFT);
+static __inline int fegetexcept(void) {
+  fenv_t __fcsr;
+  fegetenv(&__fcsr);
+  return ((__fcsr & _FCSR_ENABLE_MASK) >> _ENABLE_SHIFT);
 }
 
 #endif /* __BSD_VISIBLE */
 
 __END_DECLS
 
-#endif	/* !_FENV_H_ */
+#endif /* !_FENV_H_ */
diff --git a/libm/include/powerpc/fenv.h b/libm/include/powerpc/fenv.h
deleted file mode 100644
index 3fd2389..0000000
--- a/libm/include/powerpc/fenv.h
+++ /dev/null
@@ -1,263 +0,0 @@
-/*-
- * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/powerpc/fenv.h,v 1.3 2005/03/16 19:03:45 das Exp $
- */
-
-#ifndef	_FENV_H_
-#define	_FENV_H_
-
-#include <sys/_types.h>
-
-typedef	__uint32_t	fenv_t;
-typedef	__uint32_t	fexcept_t;
-
-/* Exception flags */
-#define	FE_INEXACT	0x02000000
-#define	FE_DIVBYZERO	0x04000000
-#define	FE_UNDERFLOW	0x08000000
-#define	FE_OVERFLOW	0x10000000
-#define	FE_INVALID	0x20000000	/* all types of invalid FP ops */
-
-/*
- * The PowerPC architecture has extra invalid flags that indicate the
- * specific type of invalid operation occurred.  These flags may be
- * tested, set, and cleared---but not masked---separately.  All of
- * these bits are cleared when FE_INVALID is cleared, but only
- * FE_VXSOFT is set when FE_INVALID is explicitly set in software.
- */
-#define	FE_VXCVI	0x00000100	/* invalid integer convert */
-#define	FE_VXSQRT	0x00000200	/* square root of a negative */
-#define	FE_VXSOFT	0x00000400	/* software-requested exception */
-#define	FE_VXVC		0x00080000	/* ordered comparison involving NaN */
-#define	FE_VXIMZ	0x00100000	/* inf * 0 */
-#define	FE_VXZDZ	0x00200000	/* 0 / 0 */
-#define	FE_VXIDI	0x00400000	/* inf / inf */
-#define	FE_VXISI	0x00800000	/* inf - inf */
-#define	FE_VXSNAN	0x01000000	/* operation on a signalling NaN */
-#define	FE_ALL_INVALID	(FE_VXCVI | FE_VXSQRT | FE_VXSOFT | FE_VXVC | \
-			 FE_VXIMZ | FE_VXZDZ | FE_VXIDI | FE_VXISI | \
-			 FE_VXSNAN | FE_INVALID)
-#define	FE_ALL_EXCEPT	(FE_DIVBYZERO | FE_INEXACT | \
-			 FE_ALL_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
-
-/* Rounding modes */
-#define	FE_TONEAREST	0x0000
-#define	FE_TOWARDZERO	0x0001
-#define	FE_UPWARD	0x0002
-#define	FE_DOWNWARD	0x0003
-#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
-			 FE_UPWARD | FE_TOWARDZERO)
-
-__BEGIN_DECLS
-
-/* Default floating-point environment */
-extern const fenv_t	__fe_dfl_env;
-#define	FE_DFL_ENV	(&__fe_dfl_env)
-
-/* We need to be able to map status flag positions to mask flag positions */
-#define	_FPUSW_SHIFT	22
-#define	_ENABLE_MASK	((FE_DIVBYZERO | FE_INEXACT | FE_INVALID | \
-			 FE_OVERFLOW | FE_UNDERFLOW) >> _FPUSW_SHIFT)
-
-#define	__mffs(__env)	__asm __volatile("mffs %0" : "=f" (*(__env)))
-#define	__mtfsf(__env)	__asm __volatile("mtfsf 255,%0" : : "f" (__env))
-
-union __fpscr {
-	double __d;
-	struct {
-		__uint32_t __junk;
-		fenv_t __reg;
-	} __bits;
-};
-
-static __inline int
-feclearexcept(int __excepts)
-{
-	union __fpscr __r;
-
-	if (__excepts & FE_INVALID)
-		__excepts |= FE_ALL_INVALID;
-	__mffs(&__r.__d);
-	__r.__bits.__reg &= ~__excepts;
-	__mtfsf(__r.__d);
-	return (0);
-}
-
-static __inline int
-fegetexceptflag(fexcept_t *__flagp, int __excepts)
-{
-	union __fpscr __r;
-
-	__mffs(&__r.__d);
-	*__flagp = __r.__bits.__reg & __excepts;
-	return (0);
-}
-
-static __inline int
-fesetexceptflag(const fexcept_t *__flagp, int __excepts)
-{
-	union __fpscr __r;
-
-	if (__excepts & FE_INVALID)
-		__excepts |= FE_ALL_EXCEPT;
-	__mffs(&__r.__d);
-	__r.__bits.__reg &= ~__excepts;
-	__r.__bits.__reg |= *__flagp & __excepts;
-	__mtfsf(__r.__d);
-	return (0);
-}
-
-static __inline int
-feraiseexcept(int __excepts)
-{
-	union __fpscr __r;
-
-	if (__excepts & FE_INVALID)
-		__excepts |= FE_VXSOFT;
-	__mffs(&__r.__d);
-	__r.__bits.__reg |= __excepts;
-	__mtfsf(__r.__d);
-	return (0);
-}
-
-static __inline int
-fetestexcept(int __excepts)
-{
-	union __fpscr __r;
-
-	__mffs(&__r.__d);
-	return (__r.__bits.__reg & __excepts);
-}
-
-static __inline int
-fegetround(void)
-{
-	union __fpscr __r;
-
-	__mffs(&__r.__d);
-	return (__r.__bits.__reg & _ROUND_MASK);
-}
-
-static __inline int
-fesetround(int __round)
-{
-	union __fpscr __r;
-
-	if (__round & ~_ROUND_MASK)
-		return (-1);
-	__mffs(&__r.__d);
-	__r.__bits.__reg &= ~_ROUND_MASK;
-	__r.__bits.__reg |= __round;
-	__mtfsf(__r.__d);
-	return (0);
-}
-
-static __inline int
-fegetenv(fenv_t *__envp)
-{
-	union __fpscr __r;
-
-	__mffs(&__r.__d);
-	*__envp = __r.__bits.__reg;
-	return (0);
-}
-
-static __inline int
-feholdexcept(fenv_t *__envp)
-{
-	union __fpscr __r;
-
-	__mffs(&__r.__d);
-	*__envp = __r.__d;
-	__r.__bits.__reg &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
-	__mtfsf(__r.__d);
-	return (0);
-}
-
-static __inline int
-fesetenv(const fenv_t *__envp)
-{
-	union __fpscr __r;
-
-	__r.__bits.__reg = *__envp;
-	__mtfsf(__r.__d);
-	return (0);
-}
-
-static __inline int
-feupdateenv(const fenv_t *__envp)
-{
-	union __fpscr __r;
-
-	__mffs(&__r.__d);
-	__r.__bits.__reg &= FE_ALL_EXCEPT;
-	__r.__bits.__reg |= *__envp;
-	__mtfsf(__r.__d);
-	return (0);
-}
-
-#if __BSD_VISIBLE
-
-static __inline int
-feenableexcept(int __mask)
-{
-	union __fpscr __r;
-	fenv_t __oldmask;
-
-	__mffs(&__r.__d);
-	__oldmask = __r.__bits.__reg;
-	__r.__bits.__reg |= (__mask & FE_ALL_EXCEPT) >> _FPUSW_SHIFT;
-	__mtfsf(__r.__d);
-	return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT);
-}
-
-static __inline int
-fedisableexcept(int __mask)
-{
-	union __fpscr __r;
-	fenv_t __oldmask;
-
-	__mffs(&__r.__d);
-	__oldmask = __r.__bits.__reg;
-	__r.__bits.__reg &= ~((__mask & FE_ALL_EXCEPT) >> _FPUSW_SHIFT);
-	__mtfsf(__r.__d);
-	return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT);
-}
-
-static __inline int
-fegetexcept(void)
-{
-	union __fpscr __r;
-
-	__mffs(&__r.__d);
-	return ((__r.__bits.__reg & _ENABLE_MASK) << _FPUSW_SHIFT);
-}
-
-#endif /* __BSD_VISIBLE */
-
-__END_DECLS
-
-#endif	/* !_FENV_H_ */
diff --git a/libm/include/sparc64/fenv.h b/libm/include/sparc64/fenv.h
deleted file mode 100644
index 684c4a2..0000000
--- a/libm/include/sparc64/fenv.h
+++ /dev/null
@@ -1,254 +0,0 @@
-/*-
- * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/sparc64/fenv.h,v 1.3 2005/03/16 19:03:46 das Exp $
- */
-
-#ifndef	_FENV_H_
-#define	_FENV_H_
-
-#include <sys/_types.h>
-
-typedef	__uint64_t	fenv_t;
-typedef	__uint64_t	fexcept_t;
-
-/* Exception flags */
-#define	FE_INVALID	0x00000200
-#define	FE_DIVBYZERO	0x00000040
-#define	FE_OVERFLOW	0x00000100
-#define	FE_UNDERFLOW	0x00000080
-#define	FE_INEXACT	0x00000020
-#define	FE_ALL_EXCEPT	(FE_DIVBYZERO | FE_INEXACT | \
-			 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
-
-/*
- * Rounding modes
- *
- * We can't just use the hardware bit values here, because that would
- * make FE_UPWARD and FE_DOWNWARD negative, which is not allowed.
- */
-#define	FE_TONEAREST	0x0
-#define	FE_TOWARDZERO	0x1
-#define	FE_UPWARD	0x2
-#define	FE_DOWNWARD	0x3
-#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
-			 FE_UPWARD | FE_TOWARDZERO)
-#define	_ROUND_SHIFT	30
-
-__BEGIN_DECLS
-
-/* Default floating-point environment */
-extern const fenv_t	__fe_dfl_env;
-#define	FE_DFL_ENV	(&__fe_dfl_env)
-
-/* We need to be able to map status flag positions to mask flag positions */
-#define _FPUSW_SHIFT	18
-#define	_ENABLE_MASK	(FE_ALL_EXCEPT << _FPUSW_SHIFT)
-
-#define	__ldxfsr(__r)	__asm __volatile("ldx %0, %%fsr" : : "m" (__r))
-#define	__stxfsr(__r)	__asm __volatile("stx %%fsr, %0" : "=m" (*(__r)))
-
-static __inline int
-feclearexcept(int __excepts)
-{
-	fexcept_t __r;
-
-	__stxfsr(&__r);
-	__r &= ~__excepts;
-	__ldxfsr(__r);
-	return (0);
-}
-
-static __inline int
-fegetexceptflag(fexcept_t *__flagp, int __excepts)
-{
-	fexcept_t __r;
-
-	__stxfsr(&__r);
-	*__flagp = __r & __excepts;
-	return (0);
-}
-
-static __inline int
-fesetexceptflag(const fexcept_t *__flagp, int __excepts)
-{
-	fexcept_t __r;
-
-	__stxfsr(&__r);
-	__r &= ~__excepts;
-	__r |= *__flagp & __excepts;
-	__ldxfsr(__r);
-	return (0);
-}
-
-/*
- * In contrast with the ia64 platform, it seems to be worthwhile to
- * inline this function on sparc64 even when the arguments are not
- * compile-time constants.  Perhaps this depends on the register window.
- */
-static __inline int
-feraiseexcept(int __excepts)
-{
-	volatile double d;
-
-	/*
-	 * With a compiler that supports the FENV_ACCESS pragma
-	 * properly, simple expressions like '0.0 / 0.0' should
-	 * be sufficient to generate traps.  Unfortunately, we
-	 * need to bring a volatile variable into the equation
-	 * to prevent incorrect optimizations.
-	 */
-	if (__excepts & FE_INVALID) {
-		d = 0.0;
-		d = 0.0 / d;
-	}
-	if (__excepts & FE_DIVBYZERO) {
-		d = 0.0;
-		d = 1.0 / d;
-	}
-	if (__excepts & FE_OVERFLOW) {
-		d = 0x1.ffp1023;
-		d *= 2.0;
-	}
-	if (__excepts & FE_UNDERFLOW) {
-		d = 0x1p-1022;
-		d /= 0x1p1023;
-	}
-	if (__excepts & FE_INEXACT) {
-		d = 0x1p-1022;
-		d += 1.0;
-	}
-	return (0);
-}
-
-static __inline int
-fetestexcept(int __excepts)
-{
-	fexcept_t __r;
-
-	__stxfsr(&__r);
-	return (__r & __excepts);
-}
-
-static __inline int
-fegetround(void)
-{
-	fenv_t __r;
-
-	__stxfsr(&__r);
-	return ((__r >> _ROUND_SHIFT) & _ROUND_MASK);
-}
-
-static __inline int
-fesetround(int __round)
-{
-	fenv_t __r;
-
-	if (__round & ~_ROUND_MASK)
-		return (-1);
-	__stxfsr(&__r);
-	__r &= ~(_ROUND_MASK << _ROUND_SHIFT);
-	__r |= __round << _ROUND_SHIFT;
-	__ldxfsr(__r);
-	return (0);
-}
-
-static __inline int
-fegetenv(fenv_t *__envp)
-{
-
-	__stxfsr(__envp);
-	return (0);
-}
-
-static __inline int
-feholdexcept(fenv_t *__envp)
-{
-	fenv_t __r;
-
-	__stxfsr(&__r);
-	*__envp = __r;
-	__r &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
-	__ldxfsr(__r);
-	return (0);
-}
-
-static __inline int
-fesetenv(const fenv_t *__envp)
-{
-
-	__ldxfsr(*__envp);
-	return (0);
-}
-
-static __inline int
-feupdateenv(const fenv_t *__envp)
-{
-	fexcept_t __r;
-
-	__stxfsr(&__r);
-	__ldxfsr(*__envp);
-	feraiseexcept(__r & FE_ALL_EXCEPT);
-	return (0);
-}
-
-#if __BSD_VISIBLE
-
-static __inline int
-feenableexcept(int __mask)
-{
-	fenv_t __old_r, __new_r;
-
-	__stxfsr(&__old_r);
-	__new_r = __old_r | ((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
-	__ldxfsr(__new_r);
-	return ((__old_r >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
-}
-
-static __inline int
-fedisableexcept(int __mask)
-{
-	fenv_t __old_r, __new_r;
-
-	__stxfsr(&__old_r);
-	__new_r = __old_r & ~((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
-	__ldxfsr(__new_r);
-	return ((__old_r >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
-}
-
-static __inline int
-fegetexcept(void)
-{
-	fenv_t __r;
-
-	__stxfsr(&__r);
-	return ((__r & _ENABLE_MASK) >> _FPUSW_SHIFT);
-}
-
-#endif /* __BSD_VISIBLE */
-
-__END_DECLS
-
-#endif	/* !_FENV_H_ */
diff --git a/libm/isinf.c b/libm/isinf.c
index 2da8f58..c917f16 100644
--- a/libm/isinf.c
+++ b/libm/isinf.c
@@ -28,7 +28,7 @@
 
 #include <math.h>
 #include <sys/cdefs.h>
-#include "src/fpmath.h"
+#include "fpmath.h"
 
 /*
  * XXX These routines belong in libm, but they must remain in libc for
@@ -66,4 +66,3 @@
 	return (u.bits.exp == 2047 && u.bits.manl == 0 && u.bits.manh == 0);
 #endif
 }
-
diff --git a/libm/man/acos.3 b/libm/man/acos.3
deleted file mode 100644
index 9f03d60..0000000
--- a/libm/man/acos.3
+++ /dev/null
@@ -1,92 +0,0 @@
-.\" Copyright (c) 1991 The Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)acos.3	5.1 (Berkeley) 5/2/91
-.\" $FreeBSD: src/lib/msun/man/acos.3,v 1.13 2005/01/14 23:28:28 das Exp $
-.\"
-.Dd January 14, 2005
-.Dt ACOS 3
-.Os
-.Sh NAME
-.Nm acos ,
-.Nm acosf
-.Nd arc cosine functions
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn acos "double x"
-.Ft float
-.Fn acosf "float x"
-.Sh DESCRIPTION
-The
-.Fn acos
-and the
-.Fn acosf
-functions compute the principal value of the arc cosine of
-.Fa x .
-A domain error occurs for arguments not in the range
-.Bq -1 , +1 .
-For a discussion of error due to roundoff, see
-.Xr math 3 .
-.Sh RETURN VALUES
-The
-.Fn acos
-and the
-.Fn acosf
-functions return the arc cosine in the range
-.Bq 0 , \*(Pi
-radians.
-If:
-.Bd -unfilled -offset indent
-.Pf \&| Ns Ar x Ns \&| > 1 ,
-.Ed
-.Pp
-.Fn acos x
-raises an invalid exception and returns an \*(Na.
-.Sh SEE ALSO
-.Xr asin 3 ,
-.Xr atan 3 ,
-.Xr atan2 3 ,
-.Xr cos 3 ,
-.Xr cosh 3 ,
-.Xr fenv 3 ,
-.Xr math 3 ,
-.Xr sin 3 ,
-.Xr sinh 3 ,
-.Xr tan 3 ,
-.Xr tanh 3
-.Sh STANDARDS
-The
-.Fn acos
-function conforms to
-.St -isoC .
diff --git a/libm/man/acosh.3 b/libm/man/acosh.3
deleted file mode 100644
index 62534ab..0000000
--- a/libm/man/acosh.3
+++ /dev/null
@@ -1,82 +0,0 @@
-.\" Copyright (c) 1991 Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)acosh.3	5.2 (Berkeley) 5/6/91
-.\" $FreeBSD: src/lib/msun/man/acosh.3,v 1.11 2005/01/14 23:28:28 das Exp $
-.\"
-.Dd January 14, 2005
-.Dt ACOSH 3
-.Os
-.Sh NAME
-.Nm acosh ,
-.Nm acoshf
-.Nd inverse hyperbolic cosine functions
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn acosh "double x"
-.Ft float
-.Fn acoshf "float x"
-.Sh DESCRIPTION
-The
-.Fn acosh
-and the
-.Fn acoshf
-functions compute the inverse hyperbolic cosine
-of the real
-argument
-.Ar x .
-For a discussion of error due to roundoff, see
-.Xr math 3 .
-.Sh RETURN VALUES
-The
-.Fn acosh
-and the
-.Fn acoshf
-functions
-return the inverse hyperbolic cosine of
-.Ar x .
-If the argument is less than 1,
-.Fn acosh
-raises an invalid exception and returns an \*(Na.
-.Sh SEE ALSO
-.Xr asinh 3 ,
-.Xr atanh 3 ,
-.Xr exp 3 ,
-.Xr fenv 3 ,
-.Xr math 3
-.Sh HISTORY
-The
-.Fn acosh
-function appeared in
-.Bx 4.3 .
diff --git a/libm/man/asin.3 b/libm/man/asin.3
deleted file mode 100644
index 1018990..0000000
--- a/libm/man/asin.3
+++ /dev/null
@@ -1,94 +0,0 @@
-.\" Copyright (c) 1991 The Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)asin.3	5.1 (Berkeley) 5/2/91
-.\" $FreeBSD: src/lib/msun/man/asin.3,v 1.15 2005/01/14 23:28:28 das Exp $
-.\"
-.Dd January 14, 2005
-.Dt ASIN 3
-.Os
-.Sh NAME
-.Nm asin ,
-.Nm asinf
-.Nd arc sine functions
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn asin "double x"
-.Ft float
-.Fn asinf "float x"
-.Sh DESCRIPTION
-The
-.Fn asin
-and the
-.Fn asinf
-functions compute the principal value of the arc sine of
-.Fa x .
-A domain error occurs for arguments not in the range
-.Bq -1 , +1 .
-For a discussion of error due to roundoff, see
-.Xr math 3 .
-.Sh RETURN VALUES
-The
-.Fn asin
-and the
-.Fn asinf
-functions return the arc sine in the range
-.Bk -words
-.Bq -\*(Pi/2 , +\*(Pi/2
-.Ek
-radians.
-If:
-.Bd -unfilled -offset indent
-.Pf \&| Ns Ar x Ns \&| > 1
-.Ed
-.Pp
-.Fn asin x
-raises an invalid exception and returns an \*(Na.
-.Sh SEE ALSO
-.Xr acos 3 ,
-.Xr atan 3 ,
-.Xr atan2 3 ,
-.Xr cos 3 ,
-.Xr cosh 3 ,
-.Xr fenv 3 ,
-.Xr math 3 ,
-.Xr sin 3 ,
-.Xr sinh 3 ,
-.Xr tan 3 ,
-.Xr tanh 3
-.Sh STANDARDS
-The
-.Fn asin
-function conforms to
-.St -isoC .
diff --git a/libm/man/asinh.3 b/libm/man/asinh.3
deleted file mode 100644
index 6a0d9a0..0000000
--- a/libm/man/asinh.3
+++ /dev/null
@@ -1,78 +0,0 @@
-.\" Copyright (c) 1985, 1991 Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)asinh.3	6.4 (Berkeley) 5/6/91
-.\" $FreeBSD: src/lib/msun/man/asinh.3,v 1.10 2001/10/13 12:23:22 bde Exp $
-.\"
-.Dd May 6, 1991
-.Dt ASINH 3
-.Os
-.Sh NAME
-.Nm asinh ,
-.Nm asinhf
-.Nd inverse hyperbolic sine functions
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn asinh "double x"
-.Ft float
-.Fn asinhf "float x"
-.Sh DESCRIPTION
-The
-.Fn asinh
-and the
-.Fn asinhf
-functions compute the inverse hyperbolic sine
-of the real
-argument
-.Ar x .
-For a discussion of error due to roundoff, see
-.Xr math 3 .
-.Sh RETURN VALUES
-The
-.Fn asinh
-and the
-.Fn asinhf
-functions
-return the inverse hyperbolic sine of
-.Ar x .
-.Sh SEE ALSO
-.Xr acosh 3 ,
-.Xr atanh 3 ,
-.Xr exp 3 ,
-.Xr math 3
-.Sh HISTORY
-The
-.Fn asinh
-function appeared in
-.Bx 4.3 .
diff --git a/libm/man/atan.3 b/libm/man/atan.3
deleted file mode 100644
index c4cefed..0000000
--- a/libm/man/atan.3
+++ /dev/null
@@ -1,84 +0,0 @@
-.\" Copyright (c) 1991 The Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)atan.3	5.1 (Berkeley) 5/2/91
-.\" $FreeBSD: src/lib/msun/man/atan.3,v 1.10 2001/10/13 12:23:22 bde Exp $
-.\"
-.Dd May 2, 1991
-.Dt ATAN 3
-.Os
-.Sh NAME
-.Nm atan ,
-.Nm atanf
-.Nd arc tangent functions of one variable
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn atan "double x"
-.Ft float
-.Fn atanf "float x"
-.Sh DESCRIPTION
-The
-.Fn atan
-and the
-.Fn atanf
-functions compute the principal value of the arc tangent of
-.Fa x .
-For a discussion of error due to roundoff, see
-.Xr math 3 .
-.Sh RETURN VALUES
-The
-.Fn atan
-and the
-.Fn atanf
-function returns the arc tangent in the range
-.Bk -words
-.Bq -\*(Pi/2 , +\*(Pi/2
-.Ek
-radians.
-.Sh SEE ALSO
-.Xr acos 3 ,
-.Xr asin 3 ,
-.Xr atan2 3 ,
-.Xr cos 3 ,
-.Xr cosh 3 ,
-.Xr math 3 ,
-.Xr sin 3 ,
-.Xr sinh 3 ,
-.Xr tan 3 ,
-.Xr tanh 3
-.Sh STANDARDS
-The
-.Fn atan
-function conforms to
-.St -isoC .
diff --git a/libm/man/atan2.3 b/libm/man/atan2.3
deleted file mode 100644
index 421e17d..0000000
--- a/libm/man/atan2.3
+++ /dev/null
@@ -1,187 +0,0 @@
-.\" Copyright (c) 1991 The Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)atan2.3	5.1 (Berkeley) 5/2/91
-.\" $FreeBSD: src/lib/msun/man/atan2.3,v 1.14 2005/01/28 21:13:34 ru Exp $
-.\"
-.Dd January 14, 2005
-.Dt ATAN2 3
-.Os
-.Sh NAME
-.Nm atan2 ,
-.Nm atan2f
-.Nd arc tangent functions of two variables
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn atan2 "double y" "double x"
-.Ft float
-.Fn atan2f "float y" "float x"
-.Sh DESCRIPTION
-The
-.Fn atan2
-and the
-.Fn atan2f
-functions compute the principal value of the arc tangent of
-.Fa y/ Ns Ar x ,
-using the signs of both arguments to determine the quadrant of
-the return value.
-.Sh RETURN VALUES
-The
-.Fn atan2
-and the
-.Fn atan2f
-functions, if successful,
-return the arc tangent of
-.Fa y/ Ns Ar x
-in the range
-.Bk -words
-.Bq \&- Ns \*(Pi , \&+ Ns \*(Pi
-.Ek
-radians.
-Here are some of the special cases:
-.Bl -column atan_(y,x)_:=____  sign(y)_(Pi_atan2(Xy_xX))___
-.It Fn atan2 y x No := Ta
-.Fn atan y/x Ta
-if
-.Ar x
-> 0,
-.It Ta sign( Ns Ar y Ns )*(\*(Pi -
-.Fn atan "\\*(Bay/x\\*(Ba" ) Ta
-if
-.Ar x
-< 0,
-.It Ta
-.No 0 Ta
-if x = y = 0, or
-.It Ta
-.Pf sign( Ar y Ns )*\\*(Pi/2 Ta
-if
-.Ar x
-= 0 \(!=
-.Ar y .
-.El
-.Sh NOTES
-The function
-.Fn atan2
-defines "if x > 0,"
-.Fn atan2 0 0
-= 0 despite that previously
-.Fn atan2 0 0
-may have generated an error message.
-The reasons for assigning a value to
-.Fn atan2 0 0
-are these:
-.Bl -enum -offset indent
-.It
-Programs that test arguments to avoid computing
-.Fn atan2 0 0
-must be indifferent to its value.
-Programs that require it to be invalid are vulnerable
-to diverse reactions to that invalidity on diverse computer systems.
-.It
-The
-.Fn atan2
-function is used mostly to convert from rectangular (x,y)
-to polar
-.if n\
-(r,theta)
-.if t\
-(r,\(*h)
-coordinates that must satisfy x =
-.if n\
-r\(**cos theta
-.if t\
-r\(**cos\(*h
-and y =
-.if n\
-r\(**sin theta.
-.if t\
-r\(**sin\(*h.
-These equations are satisfied when (x=0,y=0)
-is mapped to
-.if n \
-(r=0,theta=0).
-.if t \
-(r=0,\(*h=0).
-In general, conversions to polar coordinates
-should be computed thus:
-.Bd -unfilled -offset indent
-.if n \{\
-r	:= hypot(x,y);  ... := sqrt(x\(**x+y\(**y)
-theta	:= atan2(y,x).
-.\}
-.if t \{\
-r	:= hypot(x,y);  ... := \(sr(x\u\s82\s10\d+y\u\s82\s10\d)
-\(*h	:= atan2(y,x).
-.\}
-.Ed
-.It
-The foregoing formulas need not be altered to cope in a
-reasonable way with signed zeros and infinities
-on a machine that conforms to
-.Tn IEEE 754 ;
-the versions of
-.Xr hypot 3
-and
-.Fn atan2
-provided for
-such a machine are designed to handle all cases.
-That is why
-.Fn atan2 \(+-0 \-0
-= \(+-\*(Pi
-for instance.
-In general the formulas above are equivalent to these:
-.Bd -unfilled -offset indent
-.if n \
-r := sqrt(x\(**x+y\(**y); if r = 0 then x := copysign(1,x);
-.if t \
-r := \(sr(x\(**x+y\(**y);\0\0if r = 0 then x := copysign(1,x);
-.Ed
-.El
-.Sh SEE ALSO
-.Xr acos 3 ,
-.Xr asin 3 ,
-.Xr atan 3 ,
-.Xr cos 3 ,
-.Xr cosh 3 ,
-.Xr math 3 ,
-.Xr sin 3 ,
-.Xr sinh 3 ,
-.Xr tan 3 ,
-.Xr tanh 3
-.Sh STANDARDS
-The
-.Fn atan2
-function conforms to
-.St -isoC .
diff --git a/libm/man/atanh.3 b/libm/man/atanh.3
deleted file mode 100644
index 3dcc01a..0000000
--- a/libm/man/atanh.3
+++ /dev/null
@@ -1,85 +0,0 @@
-.\" Copyright (c) 1985, 1991 Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)atanh.3	5.2 (Berkeley) 5/6/91
-.\" $FreeBSD: src/lib/msun/man/atanh.3,v 1.13 2005/01/28 21:14:16 ru Exp $
-.\"
-.Dd January 14, 2005
-.Dt ATANH 3
-.Os
-.Sh NAME
-.Nm atanh ,
-.Nm atanhf
-.Nd inverse hyperbolic tangent functions
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn atanh "double x"
-.Ft float
-.Fn atanhf "float x"
-.Sh DESCRIPTION
-The
-.Fn atanh
-and the
-.Fn atanhf
-functions compute the inverse hyperbolic tangent
-of the real
-argument
-.Ar x .
-For a discussion of error due to roundoff, see
-.Xr math 3 .
-.Sh RETURN VALUES
-The
-.Fn atanh
-and the
-.Fn atanhf
-functions
-return the inverse hyperbolic tangent of
-.Ar x
-if successful.
-If the argument has absolute value 1, a divide-by-zero exception
-is raised and an infinity is returned.
-If
-.Ar |x|
-> 1, an invalid exception is raised and an \*(Na is returned.
-.Sh SEE ALSO
-.Xr acosh 3 ,
-.Xr asinh 3 ,
-.Xr exp 3 ,
-.Xr fenv 3 ,
-.Xr math 3
-.Sh HISTORY
-The
-.Fn atanh
-function appeared in
-.Bx 4.3 .
diff --git a/libm/man/ceil.3 b/libm/man/ceil.3
deleted file mode 100644
index 557903e..0000000
--- a/libm/man/ceil.3
+++ /dev/null
@@ -1,82 +0,0 @@
-.\" Copyright (c) 1991 The Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)ceil.3	5.1 (Berkeley) 5/2/91
-.\" $FreeBSD: src/lib/msun/man/ceil.3,v 1.15 2005/01/13 20:33:42 stefanf Exp $
-.\"
-.Dd January 13, 2005
-.Dt CEIL 3
-.Os
-.Sh NAME
-.Nm ceil ,
-.Nm ceilf ,
-.Nm ceill
-.Nd smallest integral value greater than or equal to x
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn ceil "double x"
-.Ft float
-.Fn ceilf "float x"
-.Ft "long double"
-.Fn ceill "long double x"
-.Sh DESCRIPTION
-The
-.Fn ceil ,
-.Fn ceilf
-and
-.Fn ceill
-functions return the smallest integral value
-greater than or equal to
-.Fa x ,
-expressed as a floating-point number.
-.Sh SEE ALSO
-.Xr abs 3 ,
-.Xr fabs 3 ,
-.Xr floor 3 ,
-.Xr ieee 3 ,
-.Xr math 3 ,
-.Xr rint 3 ,
-.Xr round 3 ,
-.Xr trunc 3
-.Sh STANDARDS
-The
-.Fn ceil
-function conforms to
-.St -isoC .
-The
-.Fn ceilf
-and
-.Fn ceill
-functions conform to
-.St -isoC-99 .
diff --git a/libm/man/cimag.3 b/libm/man/cimag.3
deleted file mode 100644
index 069e848..0000000
--- a/libm/man/cimag.3
+++ /dev/null
@@ -1,96 +0,0 @@
-.\" Copyright (c) 2004 Stefan Farfeleder
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD: src/lib/msun/man/cimag.3,v 1.2 2005/01/13 10:43:01 ru Exp $
-.\"
-.Dd August 7, 2004
-.Dt CIMAG 3
-.Os
-.Sh NAME
-.Nm cimag , cimagf , cimagl ,
-.Nm conj , conjf , conjl ,
-.Nm creal , crealf , creall
-.Nd "functions to manipulate complex numbers"
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In complex.h
-.Ft double
-.Fn cimag "double complex z"
-.Ft float
-.Fn cimagf "float complex z"
-.Ft "long double"
-.Fn cimagl "long double complex z"
-.Ft "double complex"
-.Fn conj "double complex z"
-.Ft "float complex"
-.Fn conjf "float complex z"
-.Ft "long double complex"
-.Fn conjl "long double complex z"
-.Ft double
-.Fn creal "double complex z"
-.Ft float
-.Fn crealf "float complex z"
-.Ft "long double"
-.Fn creall "long double complex z"
-.Sh DESCRIPTION
-Let
-.Sm off
-.Fa a + b * Em i
-.Sm on
-denote the complex number
-.Fa z .
-.Pp
-The
-.Fn cimag
-functions return the imaginary part
-.Fa b .
-.Pp
-The
-.Fn conj
-functions return the complex conjugate
-.Sm off
-.Fa a - b * Em i .
-.Sm on
-.Pp
-The
-.Fn creal
-functions return the real part
-.Fa a .
-.Sh STANDARDS
-The
-.Fn cimag ,
-.Fn conj
-and
-.Fn creal
-functions conform to
-.St -isoC-99 .
-.Sh HISTORY
-The
-.Fn cimag ,
-.Fn conj
-and
-.Fn creal
-functions first appeared in
-.Fx 5.3 .
diff --git a/libm/man/copysign.3 b/libm/man/copysign.3
deleted file mode 100644
index c3ce3dc..0000000
--- a/libm/man/copysign.3
+++ /dev/null
@@ -1,90 +0,0 @@
-.\" Copyright (c) 1985, 1991 Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)ieee.3	6.4 (Berkeley) 5/6/91
-.\" $FreeBSD: src/lib/msun/man/copysign.3,v 1.1 2005/01/27 05:46:16 das Exp $
-.\"
-.Dd January 26, 2005
-.Dt COPYSIGN 3
-.Os
-.Sh NAME
-.Nm copysign ,
-.Nm copysignf ,
-.Nm copysignl
-.Nd copy sign
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn copysign "double x" "double y"
-.Ft float
-.Fn copysignf "float x" "float y"
-.Ft long double
-.Fn copysignl "long double x" "long double y"
-.Sh DESCRIPTION
-The
-.Fn copysign ,
-.Fn copysignf
-and
-.Fn copysignl
-functions
-return
-.Fa x
-with its sign changed to
-.Fa y Ns 's .
-.Sh SEE ALSO
-.Xr fabs 3 ,
-.Xr fdim 3 ,
-.Xr ieee 3 ,
-.Xr math 3
-.Sh STANDARDS
-The
-.Fn copysign ,
-.Fn copysignf ,
-and
-.Fn copysignl
-routines conform to
-.St -isoC-99 .
-They implement the Copysign function recommended by
-.St -ieee754 .
-.Sh HISTORY
-The
-.Fn copysign ,
-.Fn copysignf ,
-and
-.Fn copysignl
-functions appeared in
-.Bx 4.3 ,
-.Fx 2.0 ,
-and
-.Fx 5.3 ,
-respectively.
diff --git a/libm/man/cos.3 b/libm/man/cos.3
deleted file mode 100644
index 8e0bd91..0000000
--- a/libm/man/cos.3
+++ /dev/null
@@ -1,83 +0,0 @@
-.\" Copyright (c) 1991 The Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)cos.3	5.1 (Berkeley) 5/2/91
-.\" $FreeBSD: src/lib/msun/man/cos.3,v 1.11 2001/10/13 12:23:23 bde Exp $
-.\"
-.Dd May 2, 1991
-.Dt COS 3
-.Os
-.Sh NAME
-.Nm cos ,
-.Nm cosf
-.Nd cosine functions
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn cos "double x"
-.Ft float
-.Fn cosf "float x"
-.Sh DESCRIPTION
-The
-.Fn cos
-and the
-.Fn cosf
-functions compute the cosine of
-.Fa x
-(measured in radians).
-A large magnitude argument may yield a result with little or no
-significance.
-For a discussion of error due to roundoff, see
-.Xr math 3 .
-.Sh RETURN VALUES
-The
-.Fn cos
-and the
-.Fn cosf
-functions return the cosine value.
-.Sh SEE ALSO
-.Xr acos 3 ,
-.Xr asin 3 ,
-.Xr atan 3 ,
-.Xr atan2 3 ,
-.Xr cosh 3 ,
-.Xr math 3 ,
-.Xr sin 3 ,
-.Xr sinh 3 ,
-.Xr tan 3 ,
-.Xr tanh 3
-.Sh STANDARDS
-The
-.Fn cos
-function conforms to
-.St -isoC .
diff --git a/libm/man/cosh.3 b/libm/man/cosh.3
deleted file mode 100644
index 947c33e..0000000
--- a/libm/man/cosh.3
+++ /dev/null
@@ -1,72 +0,0 @@
-.\" Copyright (c) 1989, 1991 The Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)cosh.3	5.1 (Berkeley) 5/2/91
-.\" $FreeBSD: src/lib/msun/man/cosh.3,v 1.12 2005/01/14 23:28:28 das Exp $
-.\"
-.Dd January 14, 2005
-.Dt COSH 3
-.Os
-.Sh NAME
-.Nm cosh ,
-.Nm coshf
-.Nd hyperbolic cosine functions
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn cosh "double x"
-.Ft float
-.Fn coshf "float x"
-.Sh DESCRIPTION
-The
-.Fn cosh
-and the
-.Fn coshf
-functions compute the hyperbolic cosine of
-.Fa x .
-.Sh SEE ALSO
-.Xr acos 3 ,
-.Xr asin 3 ,
-.Xr atan 3 ,
-.Xr atan2 3 ,
-.Xr cos 3 ,
-.Xr math 3 ,
-.Xr sin 3 ,
-.Xr sinh 3 ,
-.Xr tan 3 ,
-.Xr tanh 3
-.Sh STANDARDS
-The
-.Fn cosh
-function conforms to
-.St -isoC .
diff --git a/libm/man/erf.3 b/libm/man/erf.3
deleted file mode 100644
index 824787f..0000000
--- a/libm/man/erf.3
+++ /dev/null
@@ -1,97 +0,0 @@
-.\" Copyright (c) 1985, 1991 Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)erf.3	6.4 (Berkeley) 4/20/91
-.\" $FreeBSD: src/lib/msun/man/erf.3,v 1.11 2004/07/02 23:52:20 ru Exp $
-.\"
-.Dd April 20, 1991
-.Dt ERF 3
-.Os
-.Sh NAME
-.Nm erf ,
-.Nm erff ,
-.Nm erfc ,
-.Nm erfcf
-.Nd error function operators
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn erf "double x"
-.Ft float
-.Fn erff "float x"
-.Ft double
-.Fn erfc "double x"
-.Ft float
-.Fn erfcf "float x"
-.Sh DESCRIPTION
-These functions calculate the error function of
-.Fa x .
-.Pp
-The
-.Fn erf
-and the
-.Fn erff
-functions calculate the error function of x; where
-.Bd -ragged -offset indent
-.if n \{\
-erf(x) = 2/sqrt(pi)\(**\|integral from 0 to x of exp(\-t\(**t) dt.
-\}
-.if t \{\
-erf\|(x) :=
-(2/\(sr\(*p)\|\(is\d\s8\z0\s10\u\u\s8x\s10\d\|exp(\-t\u\s82\s10\d)\|dt.
-\}
-.Ed
-.Pp
-The
-.Fn erfc
-and the
-.Fn erfcf
-functions calculate the complementary error function of
-.Fa x ;
-that is
-.Fn erfc
-subtracts the result of the error function
-.Fn erf x
-from 1.0.
-This is useful, since for large
-.Fa x
-places disappear.
-.Sh SEE ALSO
-.Xr math 3
-.Sh HISTORY
-The
-.Fn erf
-and
-.Fn erfc
-functions appeared in
-.Bx 4.3 .
diff --git a/libm/man/exp.3 b/libm/man/exp.3
deleted file mode 100644
index f6aed8f..0000000
--- a/libm/man/exp.3
+++ /dev/null
@@ -1,236 +0,0 @@
-.\" Copyright (c) 1985, 1991 Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)exp.3	6.12 (Berkeley) 7/31/91
-.\" $FreeBSD: src/lib/msun/man/exp.3,v 1.22 2005/04/05 02:57:28 das Exp $
-.\"
-.Dd April 5, 2005
-.Dt EXP 3
-.Os
-.Sh NAME
-.Nm exp ,
-.Nm expf ,
-.\" The sorting error is intentional.  exp and expf should be adjacent.
-.Nm exp2 ,
-.Nm exp2f ,
-.Nm expm1 ,
-.Nm expm1f ,
-.Nm log ,
-.Nm logf ,
-.Nm log10 ,
-.Nm log10f ,
-.Nm log1p ,
-.Nm log1pf ,
-.Nm pow ,
-.Nm powf
-.Nd exponential, logarithm, power functions
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn exp "double x"
-.Ft float
-.Fn expf "float x"
-.Ft double
-.Fn exp2 "double x"
-.Ft float
-.Fn exp2f "float x"
-.Ft double
-.Fn expm1 "double x"
-.Ft float
-.Fn expm1f "float x"
-.Ft double
-.Fn log "double x"
-.Ft float
-.Fn logf "float x"
-.Ft double
-.Fn log10 "double x"
-.Ft float
-.Fn log10f "float x"
-.Ft double
-.Fn log1p "double x"
-.Ft float
-.Fn log1pf "float x"
-.Ft double
-.Fn pow "double x" "double y"
-.Ft float
-.Fn powf "float x" "float y"
-.Sh DESCRIPTION
-The
-.Fn exp
-and the
-.Fn expf
-functions compute the base
-.Ms e
-exponential value of the given argument
-.Fa x .
-.Pp
-The
-.Fn exp2
-and the
-.Fn exp2f
-functions compute the base 2 exponential of the given argument
-.Fa x .
-.Pp
-The
-.Fn expm1
-and the
-.Fn expm1f
-functions compute the value exp(x)\-1 accurately even for tiny argument
-.Fa x .
-.Pp
-The
-.Fn log
-and the
-.Fn logf
-functions compute the value of the natural logarithm of argument
-.Fa x .
-.Pp
-The
-.Fn log10
-and the
-.Fn log10f
-functions compute the value of the logarithm of argument
-.Fa x
-to base 10.
-.Pp
-The
-.Fn log1p
-and the
-.Fn log1pf
-functions compute
-the value of log(1+x) accurately even for tiny argument
-.Fa x .
-.Pp
-The
-.Fn pow
-and the
-.Fn powf
-functions compute the value
-of
-.Ar x
-to the exponent
-.Ar y .
-.Sh ERROR (due to Roundoff etc.)
-The values of
-.Fn exp 0 ,
-.Fn expm1 0 ,
-.Fn exp2 integer ,
-and
-.Fn pow integer integer
-are exact provided that they are representable.
-.\" XXX Is this really true for pow()?
-Otherwise the error in these functions is generally below one
-.Em ulp .
-.Sh RETURN VALUES
-These functions will return the appropriate computation unless an error
-occurs or an argument is out of range.
-The functions
-.Fn pow x y
-and
-.Fn powf x y
-raise an invalid exception and return an \*(Na if
-.Fa x
-< 0 and
-.Fa y
-is not an integer.
-An attempt to take the logarithm of \*(Pm0 will result in
-a divide-by-zero exception, and an infinity will be returned.
-An attempt to take the logarithm of a negative number will
-result in an invalid exception, and an \*(Na will be generated.
-.Sh NOTES
-The functions exp(x)\-1 and log(1+x) are called
-expm1 and logp1 in
-.Tn BASIC
-on the Hewlett\-Packard
-.Tn HP Ns \-71B
-and
-.Tn APPLE
-Macintosh,
-.Tn EXP1
-and
-.Tn LN1
-in Pascal, exp1 and log1 in C
-on
-.Tn APPLE
-Macintoshes, where they have been provided to make
-sure financial calculations of ((1+x)**n\-1)/x, namely
-expm1(n\(**log1p(x))/x, will be accurate when x is tiny.
-They also provide accurate inverse hyperbolic functions.
-.Pp
-The function
-.Fn pow x 0
-returns x**0 = 1 for all x including x = 0, \*(If, and \*(Na .
-Previous implementations of pow may
-have defined x**0 to be undefined in some or all of these
-cases.
-Here are reasons for returning x**0 = 1 always:
-.Bl -enum -width indent
-.It
-Any program that already tests whether x is zero (or
-infinite or \*(Na) before computing x**0 cannot care
-whether 0**0 = 1 or not.
-Any program that depends
-upon 0**0 to be invalid is dubious anyway since that
-expression's meaning and, if invalid, its consequences
-vary from one computer system to another.
-.It
-Some Algebra texts (e.g.\& Sigler's) define x**0 = 1 for
-all x, including x = 0.
-This is compatible with the convention that accepts a[0]
-as the value of polynomial
-.Bd -literal -offset indent
-p(x) = a[0]\(**x**0 + a[1]\(**x**1 + a[2]\(**x**2 +...+ a[n]\(**x**n
-.Ed
-.Pp
-at x = 0 rather than reject a[0]\(**0**0 as invalid.
-.It
-Analysts will accept 0**0 = 1 despite that x**y can
-approach anything or nothing as x and y approach 0
-independently.
-The reason for setting 0**0 = 1 anyway is this:
-.Bd -ragged -offset indent
-If x(z) and y(z) are
-.Em any
-functions analytic (expandable
-in power series) in z around z = 0, and if there
-x(0) = y(0) = 0, then x(z)**y(z) \(-> 1 as z \(-> 0.
-.Ed
-.It
-If 0**0 = 1, then
-\*(If**0 = 1/0**0 = 1 too; and
-then \*(Na**0 = 1 too because x**0 = 1 for all finite
-and infinite x, i.e., independently of x.
-.El
-.Sh SEE ALSO
-.Xr fenv 3 ,
-.Xr math 3
diff --git a/libm/man/fabs.3 b/libm/man/fabs.3
deleted file mode 100644
index 56b3a23..0000000
--- a/libm/man/fabs.3
+++ /dev/null
@@ -1,87 +0,0 @@
-.\" Copyright (c) 1991 The Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\"	@(#)fabs.3	5.1 (Berkeley) 5/2/91
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)fabs.3	5.1 (Berkeley) 5/2/91
-.\" $FreeBSD: src/lib/msun/man/fabs.3,v 1.11 2004/07/01 18:20:57 ru Exp $
-.\"
-.Dd October 25, 2003
-.Dt FABS 3
-.Os
-.Sh NAME
-.Nm fabs ,
-.Nm fabsf ,
-.Nm fabsl
-.Nd floating-point absolute value functions
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn fabs "double x"
-.Ft float
-.Fn fabsf "float x"
-.Ft long double
-.Fn fabsl "long double x"
-.Sh DESCRIPTION
-The
-.Fn fabs ,
-.Fn fabsf
-and
-.Fn fabsl
-functions compute the absolute value of a floating-point number
-.Fa x .
-.Sh RETURN VALUES
-The
-.Fn fabs ,
-.Fn fabsf
-and
-.Fn fabsl
-functions return the absolute value of
-.Fa x .
-.Sh SEE ALSO
-.Xr abs 3 ,
-.Xr ceil 3 ,
-.Xr floor 3 ,
-.Xr ieee 3 ,
-.Xr math 3 ,
-.Xr rint 3
-.Sh STANDARDS
-The
-.Fn fabs
-function conforms to
-.St -isoC .
-The
-.Fn fabsf
-and
-.Fn fabsl
-functions conform to
-.St -isoC-99 .
diff --git a/libm/man/fdim.3 b/libm/man/fdim.3
deleted file mode 100644
index ca4e5ec..0000000
--- a/libm/man/fdim.3
+++ /dev/null
@@ -1,86 +0,0 @@
-.\" Copyright (c) 2004 David Schultz <das@FreeBSD.org>
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD: src/lib/msun/man/fdim.3,v 1.1 2004/06/30 07:04:01 das Exp $
-.\"
-.Dd June 29, 2004
-.Dt FDIM 3
-.Os
-.Sh NAME
-.Nm fdim ,
-.Nm fdimf ,
-.Nm fdiml
-.Nd positive difference functions
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn fdim "double x" "double y"
-.Ft float
-.Fn fdimf "float x" "float y"
-.Ft long double
-.Fn fdiml "long double x" "long double y"
-.Sh DESCRIPTION
-The
-.Fn fdim ,
-.Fn fdimf ,
-and
-.Fn fdiml
-functions return the positive difference between
-.Fa x
-and
-.Fa y .
-That is, if
-.Fa x\- Ns Fa y
-is positive, then
-.Fa x\- Ns Fa y
-is returned.
-If either
-.Fa x
-or
-.Fa y
-is an \*(Na, then an \*(Na is returned.
-Otherwise, the result is
-.Li +0.0 .
-.Pp
-Overflow or underflow may occur iff the exact result is not
-representable in the return type.
-No other exceptions are raised.
-.Sh SEE ALSO
-.Xr fabs 3 ,
-.Xr fmax 3 ,
-.Xr fmin 3 ,
-.Xr math 3
-.Sh STANDARDS
-The
-.Fn fdim ,
-.Fn fdimf ,
-and
-.Fn fdiml
-functions conform to
-.St -isoC-99 .
-.Sh HISTORY
-These routines first appeared in
-.Fx 5.3 .
diff --git a/libm/man/feclearexcept.3 b/libm/man/feclearexcept.3
deleted file mode 100644
index 073de67..0000000
--- a/libm/man/feclearexcept.3
+++ /dev/null
@@ -1,139 +0,0 @@
-.\" Copyright (c) 2004 David Schultz <das@FreeBSD.org>
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD: src/lib/msun/man/feclearexcept.3,v 1.3 2005/01/14 09:12:05 ru Exp $
-.\"
-.Dd May 8, 2004
-.Dt FECLEAREXCEPT 3
-.Os
-.Sh NAME
-.Nm feclearexcept ,
-.Nm fegetexceptflag ,
-.Nm feraiseexcept ,
-.Nm fesetexceptflag ,
-.Nm fetestexcept
-.Nd floating-point exception flag manipulation
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In fenv.h
-.Fd "#pragma STDC FENV_ACCESS ON"
-.Ft int
-.Fn feclearexcept "int excepts"
-.Ft int
-.Fn fegetexceptflag "fexcept_t *flagp" "int excepts"
-.Ft int
-.Fn feraiseexcept "int excepts"
-.Ft int
-.Fn fesetexceptflag "const fexcept_t *flagp" "int excepts"
-.Ft int
-.Fn fetestexcept "int excepts"
-.Sh DESCRIPTION
-The
-.Fn feclearexcept
-routine clears the floating-point exception flags specified by
-.Fa excepts ,
-whereas
-.Fn feraiseexcept
-raises the specified exceptions.
-Raising an exception causes the corresponding flag to be set,
-and a
-.Dv SIGFPE
-is delivered to the process if the exception is unmasked.
-.Pp
-The
-.Fn fetestexcept
-function determines which flags are currently set, of those specified by
-.Fa excepts .
-.Pp
-The
-.Fn fegetexceptflag
-function stores the state of the exception flags specified in
-.Fa excepts
-in the opaque object pointed to by
-.Fa flagp .
-Similarly,
-.Fn fesetexceptflag
-changes the specified exception flags to reflect the state stored in
-the object pointed to by
-.Fa flagp .
-Note that the flags restored with
-.Fn fesetexceptflag
-must be a (not necessarily proper) subset of the flags recorded by
-a prior call to
-.Fn fegetexceptflag .
-.Pp
-For all of these functions, the possible types of exceptions
-include those described in
-.Xr fenv 3 .
-Some architectures may define other types of floating-point exceptions.
-.Sh IMPLEMENTATION NOTES
-On some architectures, raising an overflow or underflow exception
-also causes an inexact exception to be raised.
-In these cases, the overflow or underflow will be raised first.
-.Pp
-The
-.Fn fegetexceptflag
-and
-.Fn fesetexceptflag
-routines are preferred to
-.Fn fetestexcept
-and
-.Fn feraiseexcept ,
-respectively, for saving and restoring exception flags.
-The latter do not re-raise exceptions and may preserve
-architecture-specific information such as addresses where
-exceptions occurred.
-.Sh RETURN VALUES
-The
-.Fn feclearexcept ,
-.Fn fegetexceptflag ,
-.Fn feraiseexcept ,
-and
-.Fn fesetexceptflag
-functions return 0 upon success, and non-zero otherwise.
-The
-.Fn fetestexcept
-function returns the bitwise OR of the values of the current exception
-flags that were requested.
-.Sh SEE ALSO
-.Xr sigaction 2 ,
-.Xr feholdexcept 3 ,
-.Xr fenv 3 ,
-.Xr feupdateenv 3 ,
-.Xr fpgetsticky 3 ,
-.Xr fpresetsticky 3
-.Sh STANDARDS
-The
-.Fn feclearexcept ,
-.Fn fegetexceptflag ,
-.Fn feraiseexcept ,
-.Fn fesetexceptflag ,
-and
-.Fn fetestexcept
-routines conform to
-.St -isoC-99 .
-.Sh HISTORY
-These functions first appeared in
-.Fx 5.3 .
diff --git a/libm/man/feenableexcept.3 b/libm/man/feenableexcept.3
deleted file mode 100644
index 0b790e7..0000000
--- a/libm/man/feenableexcept.3
+++ /dev/null
@@ -1,98 +0,0 @@
-.\" Copyright (c) 2004 David Schultz <das@FreeBSD.org>
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD: src/lib/msun/man/feenableexcept.3,v 1.1 2005/03/16 19:04:28 das Exp $
-.\"
-.Dd March 16, 2005
-.Dt FEENABLEEXCEPT 3
-.Os
-.Sh NAME
-.Nm feenableexcept ,
-.Nm fedisableexcept ,
-.Nm fegetexcept
-.Nd floating-point exception masking
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In fenv.h
-.Fd "#pragma STDC FENV_ACCESS ON"
-.Ft int
-.Fn feenableexcept "int excepts"
-.Ft int
-.Fn fedisableexcept "int excepts"
-.Ft int
-.Fn fegetexcept "void"
-.Sh DESCRIPTION
-The
-.Fn feenableexcept
-and
-.Fn fedisableexcept
-functions
-unmask and mask (respectively) exceptions specified in
-.Fa excepts .
-The
-.Fn fegetexcept
-function
-returns the current exception mask.
-All exceptions are masked by default.
-.Pp
-Floating-point operations that produce unmasked exceptions will trap, and a
-.Dv SIGFPE
-will be delivered to the process.
-By installing a signal handler for
-.Dv SIGFPE ,
-applications can take appropriate action immediately without
-testing the exception flags after every operation.
-Note that the trap may not be immediate, but it should occur
-before the next floating-point instruction is executed.
-.Pp
-For all of these functions, the possible types of exceptions
-include those described in
-.Xr fenv 3 .
-Some architectures may define other types of floating-point exceptions.
-.Sh RETURN VALUES
-The
-.Fn feenableexcept ,
-.Fn fedisableexcept ,
-and
-.Fn fegetexcept
-functions return a bitmap of the exceptions that were unmasked
-prior to the call.
-.Sh SEE ALSO
-.Xr sigaction 2 ,
-.Xr feclearexcept 3 ,
-.Xr feholdexcept 3 ,
-.Xr fenv 3 ,
-.Xr feupdateenv 3
-.Sh BUGS
-Functions in the standard library may trigger exceptions multiple
-times as a result of intermediate computations;
-however, they generally do not trigger spurious exceptions.
-.Pp
-No interface is provided to permit exceptions to be handled in
-nontrivial ways.
-There is no uniform way for an exception handler to access
-information about the exception-causing instruction, or
-to determine whether that instruction should be reexecuted
-after returning from the handler.
diff --git a/libm/man/fegetenv.3 b/libm/man/fegetenv.3
deleted file mode 100644
index 2e386ad..0000000
--- a/libm/man/fegetenv.3
+++ /dev/null
@@ -1,113 +0,0 @@
-.\" Copyright (c) 2004 David Schultz <das@FreeBSD.org>
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD: src/lib/msun/man/fegetenv.3,v 1.1 2004/06/06 10:06:26 das Exp $
-.\"
-.Dd May 8, 2004
-.Dt FEGETENV 3
-.Os
-.Sh NAME
-.Nm fegetenv ,
-.Nm feholdexcept ,
-.Nm fesetenv ,
-.Nm feupdateenv
-.Nd floating-point environment save and restore
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In fenv.h
-.Fd "#pragma STDC FENV_ACCESS ON"
-.Ft int
-.Fn fegetenv "fenv_t *envp"
-.Ft int
-.Fn feholdexcept "fenv_t *envp"
-.Ft int
-.Fn fesetenv "const fenv_t *envp"
-.Ft int
-.Fn feupdateenv "const fenv_t *envp"
-.Sh DESCRIPTION
-The floating-point environment includes exception flags and masks, the
-current rounding mode, and other architecture-specific settings.
-However, it does not include the floating-point register file.
-.Pp
-The
-.Fn fegetenv
-function stores the current floating-point environment in the object
-pointed to by
-.Fa envp ,
-whereas
-.Fn feholdexcept
-saves the current environment, then clears all exception flags
-and masks all floating-point exceptions.
-.Pp
-The
-.Fn fesetenv
-function restores a previously saved environment.
-The
-.Fn feupdateenv
-function restores a saved environment as well, but it also
-raises any exceptions that were set in the environment it
-replaces.
-.Pp
-The
-.Fn feholdexcept
-function is often used with
-.Fn feupdateenv
-or
-.Fn fesetenv
-to suppress spurious exceptions that occur as a result of
-intermediate computations.
-An example in
-.Xr fenv 3
-demonstrates how to do this.
-.Sh RETURN VALUES
-The
-.Fn fegetenv ,
-.Fn feholdexcept ,
-.Fn fesetenv ,
-and
-.Fn feupdateenv
-functions return 0 if they succeed, and non-zero otherwise.
-.Sh SEE ALSO
-.Xr feclearexcept 3 ,
-.Xr fenv 3 ,
-.Xr feraiseexcept 3 ,
-.Xr fesetenv 3 ,
-.Xr fetestexcept 3 ,
-.Xr fpgetmask 3 ,
-.Xr fpgetprec 3 ,
-.Xr fpsetmask 3 ,
-.Xr fpsetprec 3
-.Sh STANDARDS
-The
-.Fn fegetenv ,
-.Fn feholdexcept ,
-.Fn fesetenv ,
-and
-.Fn feupdateenv
-functions conform to
-.St -isoC-99 .
-.Sh HISTORY
-These routines first appeared in
-.Fx 5.3 .
diff --git a/libm/man/fegetround.3 b/libm/man/fegetround.3
deleted file mode 100644
index 9384158..0000000
--- a/libm/man/fegetround.3
+++ /dev/null
@@ -1,83 +0,0 @@
-.\" Copyright (c) 2004 David Schultz <das@FreeBSD.org>
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD: src/lib/msun/man/fegetround.3,v 1.2 2005/01/14 09:12:05 ru Exp $
-.\"
-.Dd May 8, 2004
-.Dt FEGETROUND 3
-.Os
-.Sh NAME
-.Nm fegetround ,
-.Nm fesetround
-.Nd floating-point rounding control
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In fenv.h
-.Fd "#pragma STDC FENV_ACCESS ON"
-.Ft int
-.Fn fegetround void
-.Ft int
-.Fn fesetround "int round"
-.Sh DESCRIPTION
-The
-.Fn fegetround
-function determines the current floating-point rounding mode,
-and the
-.Fn fesetround
-function sets the current rounding mode to
-.Fa round .
-The rounding mode is one of
-.Dv FE_TONEAREST , FE_DOWNWARD , FE_UPWARD ,
-or
-.Dv FE_TOWARDZERO ,
-as described in
-.Xr fenv 3 .
-.Sh RETURN VALUES
-The
-.Fn fegetround
-routine returns the current rounding mode.
-The
-.Fn fesetround
-function returns 0 on success and non-zero otherwise;
-however, the present implementation always succeeds.
-.Sh SEE ALSO
-.Xr fenv 3 ,
-.Xr fpgetround 3 ,
-.Xr fpsetround 3
-.Sh STANDARDS
-The
-.Fn fegetround
-and
-.Fn fesetround
-functions conform to
-.St -isoC-99 .
-.Sh HISTORY
-These routines first appeared in
-.Fx 5.3 .
-They supersede the non-standard
-.Xr fpgetround 3
-and
-.Xr fpsetround 3
-functions.
diff --git a/libm/man/fenv.3 b/libm/man/fenv.3
deleted file mode 100644
index 33ad541..0000000
--- a/libm/man/fenv.3
+++ /dev/null
@@ -1,289 +0,0 @@
-.\" Copyright (c) 2004 David Schultz <das@FreeBSD.org>
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD: src/lib/msun/man/fenv.3,v 1.5 2005/06/15 19:04:04 ru Exp $
-.\"
-.Dd March 16, 2005
-.Dt FENV 3
-.Os
-.Sh NAME
-.Nm feclearexcept ,
-.Nm fegetexceptflag ,
-.Nm feraiseexcept ,
-.Nm fesetexceptflag ,
-.Nm fetestexcept ,
-.Nm fegetround ,
-.Nm fesetround ,
-.Nm fegetenv ,
-.Nm feholdexcept ,
-.Nm fesetenv ,
-.Nm feupdateenv ,
-.Nm feenableexcept ,
-.Nm fedisableexcept ,
-.Nm fegetexcept
-.Nd floating-point environment control
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In fenv.h
-.Fd "#pragma STDC FENV_ACCESS ON"
-.Ft int
-.Fn feclearexcept "int excepts"
-.Ft int
-.Fn fegetexceptflag "fexcept_t *flagp" "int excepts"
-.Ft int
-.Fn feraiseexcept "int excepts"
-.Ft int
-.Fn fesetexceptflag "const fexcept_t *flagp" "int excepts"
-.Ft int
-.Fn fetestexcept "int excepts"
-.Ft int
-.Fn fegetround void
-.Ft int
-.Fn fesetround "int round"
-.Ft int
-.Fn fegetenv "fenv_t *envp"
-.Ft int
-.Fn feholdexcept "fenv_t *envp"
-.Ft int
-.Fn fesetenv "const fenv_t *envp"
-.Ft int
-.Fn feupdateenv "const fenv_t *envp"
-.Ft int
-.Fn feenableexcept "int excepts"
-.Ft int
-.Fn fedisableexcept "int excepts"
-.Ft int
-.Fn fegetexcept void
-.Sh DESCRIPTION
-The
-.In fenv.h
-routines manipulate the floating-point environment,
-which includes the exception flags and rounding modes defined in
-.St -ieee754 .
-.Ss Exceptions
-Exception flags are set as side-effects of floating-point arithmetic
-operations and math library routines, and they remain set until
-explicitly cleared.
-The following macros expand to bit flags of type
-.Vt int
-representing the five standard floating-point exceptions.
-.Bl -tag -width ".Dv FE_DIVBYZERO"
-.It Dv FE_DIVBYZERO
-A divide-by-zero exception occurs when the program attempts to
-divide a finite non-zero number by zero.
-.It Dv FE_INEXACT
-An inexact exception is raised whenever there is a loss of precision
-due to rounding.
-.It Dv FE_INVALID
-Invalid operation exceptions occur when a program attempts to
-perform calculations for which there is no reasonable representable
-answer.
-For instance, subtraction of infinities, division of zero by zero,
-ordered comparison involving \*(Nas, and taking the square root of a
-negative number are all invalid operations.
-.It Dv FE_OVERFLOW
-An overflow exception occurs when the magnitude of the result of a
-computation is too large to fit in the destination type.
-.It Dv FE_UNDERFLOW
-Underflow occurs when the result of a computation is too close to zero
-to be represented as a non-zero value in the destination type.
-.El
-.Pp
-Additionally, the
-.Dv FE_ALL_EXCEPT
-macro expands to the bitwise OR of the above flags and any
-architecture-specific flags.
-Combinations of these flags are passed to the
-.Fn feclearexcept ,
-.Fn fegetexceptflag ,
-.Fn feraiseexcept ,
-.Fn fesetexceptflag ,
-and
-.Fn fetestexcept
-functions to clear, save, raise, restore, and examine the
-processor's floating-point exception flags, respectively.
-.Pp
-Exceptions may be
-.Em unmasked
-with
-.Fn feenableexcept
-and masked with
-.Fn fedisableexcept .
-Unmasked exceptions cause a trap when they are produced, and
-all exceptions are masked by default.
-The current mask can be tested with
-.Fn fegetexcept .
-.Ss Rounding Modes
-.St -ieee754
-specifies four rounding modes.
-These modes control the direction in which results are rounded
-from their exact values in order to fit them into binary
-floating-point variables.
-The four modes correspond with the following symbolic constants.
-.Bl -tag -width ".Dv FE_TOWARDZERO"
-.It Dv FE_TONEAREST
-Results are rounded to the closest representable value.
-If the exact result is exactly half way between two representable
-values, the value whose last binary digit is even (zero) is chosen.
-This is the default mode.
-.It Dv FE_DOWNWARD
-Results are rounded towards negative \*[If].
-.It Dv FE_UPWARD
-Results are rounded towards positive \*[If].
-.It Dv FE_TOWARDZERO
-Results are rounded towards zero.
-.El
-.Pp
-The
-.Fn fegetround
-and
-.Fn fesetround
-functions query and set the rounding mode.
-.Ss Environment Control
-The
-.Fn fegetenv
-and
-.Fn fesetenv
-functions save and restore the floating-point environment,
-which includes exception flags, the current exception mask,
-the rounding mode, and possibly other implementation-specific
-state.
-The
-.Fn feholdexcept
-function behaves like
-.Fn fegetenv ,
-but with the additional effect of clearing the exception flags and
-installing a
-.Em non-stop
-mode.
-In non-stop mode, floating-point operations will set exception flags
-as usual, but no
-.Dv SIGFPE
-signals will be generated as a result.
-Non-stop mode is the default, but it may be altered by
-non-standard mechanisms.
-.\" XXX Mention fe[gs]etmask() here after the interface is finalized
-.\" XXX and ready to be officially documented.
-The
-.Fn feupdateenv
-function restores a saved environment similarly to
-.Fn fesetenv ,
-but it also re-raises any floating-point exceptions from the old
-environment.
-.Pp
-The macro
-.Dv FE_DFL_ENV
-expands to a pointer to the default environment.
-.Sh CAVEATS
-The FENV_ACCESS pragma can be enabled with
-.Dl "#pragma STDC FENV_ACCESS ON"
-and disabled with the
-.Dl "#pragma STDC FENV_ACCESS OFF"
-directive.
-This lexically-scoped annotation tells the compiler that the program
-may access the floating-point environment, so optimizations that would
-violate strict IEEE-754 semantics are disabled.
-If execution reaches a block of code for which
-.Dv FENV_ACCESS
-is off, the floating-point environment will become undefined.
-.Sh EXAMPLES
-The following routine computes the square root function.
-It explicitly raises an invalid exception on appropriate inputs using
-.Fn feraiseexcept .
-It also defers inexact exceptions while it computes intermediate
-values, and then it allows an inexact exception to be raised only if
-the final answer is inexact.
-.Bd -literal -offset indent
-#pragma STDC FENV_ACCESS ON
-double sqrt(double n) {
-	double x = 1.0;
-	fenv_t env;
-
-	if (isnan(n) || n < 0.0) {
-		feraiseexcept(FE_INVALID);
-		return (NAN);
-	}
-	if (isinf(n) || n == 0.0)
-		return (n);
-	feholdexcept(&env);
-	while (fabs((x * x) - n) > DBL_EPSILON * 2 * x)
-		x = (x / 2) + (n / (2 * x));
-	if (x * x == n)
-		feclearexcept(FE_INEXACT);
-	feupdateenv(&env);
-	return (x);
-}
-.Ed
-.Sh SEE ALSO
-.Xr cc 1 ,
-.Xr feclearexcept 3 ,
-.Xr fedisableexcept 3 ,
-.Xr feenableexcept 3 ,
-.Xr fegetenv 3 ,
-.Xr fegetexcept 3 ,
-.Xr fegetexceptflag 3 ,
-.Xr fegetround 3 ,
-.Xr feholdexcept 3 ,
-.Xr feraiseexcept 3 ,
-.Xr fesetenv 3 ,
-.Xr fesetexceptflag 3 ,
-.Xr fesetround 3 ,
-.Xr fetestexcept 3 ,
-.Xr feupdateenv 3 ,
-.Xr fpgetprec 3 ,
-.Xr fpsetprec 3
-.Sh STANDARDS
-Except as noted below,
-.In fenv.h
-conforms to
-.St -isoC-99 .
-The
-.Fn feenableexcept ,
-.Fn fedisableexcept ,
-and
-.Fn fegetexcept
-routines are extensions.
-.Sh HISTORY
-The
-.In fenv.h
-header first appeared in
-.Fx 5.3 .
-It supersedes the non-standard routines defined in
-.In ieeefp.h
-and documented in
-.Xr fpgetround 3 .
-.Sh BUGS
-The
-.Dv FENV_ACCESS
-pragma is unimplemented in the system compiler.
-However, non-constant expressions generally produce the correct
-side-effects at low optimization levels.
-.Pp
-On the Alpha platform,
-.Xr cc 1
-must be passed the
-.Fl mieee-with-inexact mfp-rounding-mode=d
-options in order to generate code that has the standard
-side-effects and uses the specified rounding modes.
diff --git a/libm/man/floor.3 b/libm/man/floor.3
deleted file mode 100644
index 1f02daf..0000000
--- a/libm/man/floor.3
+++ /dev/null
@@ -1,82 +0,0 @@
-.\" Copyright (c) 1985, 1991 The Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)floor.3	6.5 (Berkeley) 4/19/91
-.\" $FreeBSD: src/lib/msun/man/floor.3,v 1.17 2005/01/13 09:35:47 ru Exp $
-.\"
-.Dd January 13, 2005
-.Dt FLOOR 3
-.Os
-.Sh NAME
-.Nm floor ,
-.Nm floorf ,
-.Nm floorl
-.Nd largest integral value less than or equal to x
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn floor "double x"
-.Ft float
-.Fn floorf "float x"
-.Ft "long double"
-.Fn floorl "long double x"
-.Sh DESCRIPTION
-The
-.Fn floor ,
-.Fn floorf
-and
-.Fn floorl
-functions return the largest integral value
-less than or equal to
-.Fa x ,
-expressed as a floating-point number.
-.Sh SEE ALSO
-.Xr abs 3 ,
-.Xr ceil 3 ,
-.Xr fabs 3 ,
-.Xr ieee 3 ,
-.Xr math 3 ,
-.Xr rint 3 ,
-.Xr round 3 ,
-.Xr trunc 3
-.Sh STANDARDS
-The
-.Fn floor
-function conforms to
-.St -isoC .
-The
-.Fn floorf
-and
-.Fn floorl
-functions conform to
-.St -isoC-99 .
diff --git a/libm/man/fma.3 b/libm/man/fma.3
deleted file mode 100644
index 078a6e2..0000000
--- a/libm/man/fma.3
+++ /dev/null
@@ -1,116 +0,0 @@
-.\" Copyright (c) 2005 David Schultz <das@FreeBSD.org>
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD: src/lib/msun/man/fma.3,v 1.3 2005/11/24 09:25:10 joel Exp $
-.\"
-.Dd January 22, 2005
-.Dt FMA 3
-.Os
-.Sh NAME
-.Nm fma ,
-.Nm fmaf ,
-.Nm fmal
-.Nd fused multiply-add
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn fma "double x" "double y" "double z"
-.Ft float
-.Fn fmaf "float x" "float y" "float z"
-.Ft long double
-.Fn fmal "long double x" "long double y" "long double z"
-.Sh DESCRIPTION
-The
-.Fn fma ,
-.Fn fmaf ,
-and
-.Fn fmal
-functions return
-.No "(x * y) + z" ,
-computed with only one rounding error.
-Using the ordinary multiplication and addition operators, by contrast,
-results in two roundings: one for the intermediate product and one for
-the final result.
-.Pp
-For instance, the expression
-.No "1.2e100 * 2.0e208 - 1.4e308"
-produces \*(If due to overflow in the intermediate product, whereas
-.No "fma(1.2e100, 2.0e208, -1.4e308)"
-returns approximately 1.0e308.
-.Pp
-The fused multiply-add operation is often used to improve the
-accuracy of calculations such as dot products.
-It may also be used to improve performance on machines that implement
-it natively.
-The macros
-.Dv FP_FAST_FMA ,
-.Dv FP_FAST_FMAF
-and
-.Dv FP_FAST_FMAL
-may be defined in
-.In math.h
-to indicate that
-.Fn fma ,
-.Fn fmaf ,
-and
-.Fn fmal
-(respectively) have comparable or faster speed than a multiply
-operation followed by an add operation.
-.Sh IMPLEMENTATION NOTES
-In general, these routines will behave as one would expect if
-.No "x * y + z"
-were computed with unbounded precision and range,
-then rounded to the precision of the return type.
-However, on some platforms, if
-.Fa z
-is \*(Na, these functions may not raise an exception even
-when the computation of
-.No "x * y"
-would have otherwise generated an invalid exception.
-.Sh SEE ALSO
-.Xr fenv 3 ,
-.Xr math 3
-.Sh STANDARDS
-The
-.Fn fma ,
-.Fn fmaf ,
-and
-.Fn fmal
-functions conform to
-.St -isoC-99 .
-A fused multiply-add operation with virtually identical
-characteristics appears in IEEE draft standard 754R.
-.Sh HISTORY
-The
-.Fn fma
-and
-.Fn fmaf
-routines first appeared in
-.Fx 5.4 ,
-and
-.Fn fmal
-appeared in
-.Fx 6.0 .
diff --git a/libm/man/fmax.3 b/libm/man/fmax.3
deleted file mode 100644
index 03249a3..0000000
--- a/libm/man/fmax.3
+++ /dev/null
@@ -1,97 +0,0 @@
-.\" Copyright (c) 2004 David Schultz <das@FreeBSD.org>
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD: src/lib/msun/man/fmax.3,v 1.2 2005/01/14 09:12:05 ru Exp $
-.\"
-.Dd June 29, 2004
-.Dt FMAX 3
-.Os
-.Sh NAME
-.Nm fmax ,
-.Nm fmaxf ,
-.Nm fmaxl ,
-.Nm fmin ,
-.Nm fminf ,
-.Nm fminl
-.Nd floating-point maximum and minimum functions
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn fmax "double x" "double y"
-.Ft float
-.Fn fmaxf "float x" "float y"
-.Ft "long double"
-.Fn fmaxl "long double x" "long double y"
-.Ft double
-.Fn fmin "double x" "double y"
-.Ft float
-.Fn fminf "float x" "float y"
-.Ft "long double"
-.Fn fminl "long double x" "long double y"
-.Sh DESCRIPTION
-The
-.Fn fmax ,
-.Fn fmaxf ,
-and
-.Fn fmaxl
-functions return the larger of
-.Fa x
-and
-.Fa y ,
-and likewise, the
-.Fn fmin ,
-.Fn fminf ,
-and
-.Fn fminl
-functions return the smaller of
-.Fa x
-and
-.Fa y .
-They treat
-.Li +0.0
-as being larger than
-.Li -0.0 .
-If one argument is an \*(Na, then the other argument is returned.
-If both arguments are \*(Nas, then the result is an \*(Na.
-These routines do not raise any floating-point exceptions.
-.Sh SEE ALSO
-.Xr fabs 3 ,
-.Xr fdim 3 ,
-.Xr math 3
-.Sh STANDARDS
-The
-.Fn fmax ,
-.Fn fmaxf ,
-.Fn fmaxl ,
-.Fn fmin ,
-.Fn fminf ,
-and
-.Fn fminl
-functions conform to
-.St -isoC-99 .
-.Sh HISTORY
-These routines first appeared in
-.Fx 5.3 .
diff --git a/libm/man/fmod.3 b/libm/man/fmod.3
deleted file mode 100644
index c0d4ed8..0000000
--- a/libm/man/fmod.3
+++ /dev/null
@@ -1,87 +0,0 @@
-.\" Copyright (c) 1991 The Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)fmod.3	5.1 (Berkeley) 5/2/91
-.\" $FreeBSD: src/lib/msun/man/fmod.3,v 1.8 2001/10/13 12:23:23 bde Exp $
-.\"
-.Dd May 2, 1991
-.Dt FMOD 3
-.Os
-.Sh NAME
-.Nm fmod ,
-.Nm fmodf
-.Nd floating-point remainder functions
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn fmod "double x" "double y"
-.Ft float
-.Fn fmodf "float x" "float y"
-.Sh DESCRIPTION
-The
-.Fn fmod
-and the
-.Fn fmodf
-functions compute the floating-point remainder of
-.Fa x Ns / Fa y .
-.Sh RETURN VALUES
-The
-.Fn fmod
-and the
-.Fn fmodf
-functions return the value
-.Sm off
-.Fa x - Em i * Fa y ,
-.Sm on
-for some integer
-.Em i
-such that, if
-.Fa y
-is non-zero, the result has the same sign as
-.Fa x
-and magnitude less than the magnitude of
-.Fa y .
-If
-.Fa y
-is zero, whether a domain error occurs or the
-.Fn fmod
-and the
-.Fn fmodf
-function returns zero is implementation-defined.
-.Sh SEE ALSO
-.Xr math 3
-.Sh STANDARDS
-The
-.Fn fmod
-function conforms to
-.St -isoC .
diff --git a/libm/man/hypot.3 b/libm/man/hypot.3
deleted file mode 100644
index a92a2a6..0000000
--- a/libm/man/hypot.3
+++ /dev/null
@@ -1,134 +0,0 @@
-.\" Copyright (c) 1985, 1991 Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)hypot.3	6.7 (Berkeley) 5/6/91
-.\" $FreeBSD: src/lib/msun/man/hypot.3,v 1.13 2005/01/14 23:28:28 das Exp $
-.\"
-.Dd January 14, 2005
-.Dt HYPOT 3
-.Os
-.Sh NAME
-.Nm hypot ,
-.Nm hypotf ,
-.Nm cabs ,
-.Nm cabsf
-.Nd Euclidean distance and complex absolute value functions
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn hypot "double x" "double y"
-.Ft float
-.Fn hypotf "float x" "float y"
-.In complex.h
-.Ft double
-.Fn cabs "double complex z"
-.Ft float
-.Fn cabsf "float complex z"
-.Sh DESCRIPTION
-The
-.Fn hypot
-and
-.Fn hypotf
-functions
-compute the
-sqrt(x*x+y*y)
-in such a way that underflow will not happen, and overflow
-occurs only if the final result deserves it.
-The
-.Fn cabs
-and
-.Fn cabsf
-functions compute the complex absolute value of
-.Fa z .
-.Pp
-.Fn hypot "\*(If" "v"
-=
-.Fn hypot "v" "\*(If"
-= +\*(If for all
-.Fa v ,
-including \*(Na.
-.Sh ERROR (due to Roundoff, etc.)
-Below 0.97
-.Em ulps .
-Consequently
-.Fn hypot "5.0" "12.0"
-= 13.0
-exactly;
-in general, hypot and cabs return an integer whenever an
-integer might be expected.
-.Pp
-The same cannot be said for the shorter and faster version of hypot
-and cabs that is provided in the comments in cabs.c; its error can
-exceed 1.2
-.Em ulps .
-.Sh NOTES
-As might be expected,
-.Fn hypot "v" "\*(Na"
-and
-.Fn hypot "\*(Na" "v"
-are \*(Na for all
-.Em finite
-.Fa v .
-But programmers
-might be surprised at first to discover that
-.Fn hypot "\(+-\*(If" "\*(Na"
-= +\*(If.
-This is intentional; it happens because
-.Fn hypot "\*(If" "v"
-= +\*(If
-for
-.Em all
-.Fa v ,
-finite or infinite.
-Hence
-.Fn hypot "\*(If" "v"
-is independent of
-.Fa v .
-Unlike the reserved operand fault on a
-.Tn VAX ,
-the
-.Tn IEEE
-\*(Na is designed to
-disappear when it turns out to be irrelevant, as it does in
-.Fn hypot "\*(If" "\*(Na" .
-.Sh SEE ALSO
-.Xr math 3 ,
-.Xr sqrt 3
-.Sh HISTORY
-Both a
-.Fn hypot
-function and a
-.Fn cabs
-function
-appeared in
-.At v7 .
diff --git a/libm/man/ieee.3 b/libm/man/ieee.3
deleted file mode 100644
index 3b7087d..0000000
--- a/libm/man/ieee.3
+++ /dev/null
@@ -1,448 +0,0 @@
-.\" Copyright (c) 1985 Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)ieee.3	6.4 (Berkeley) 5/6/91
-.\" $FreeBSD: src/lib/msun/man/ieee.3,v 1.22 2005/06/16 21:55:45 ru Exp $
-.\"
-.Dd January 26, 2005
-.Dt IEEE 3
-.Os
-.Sh NAME
-.Nm ieee
-.Nd IEEE standard 754 for floating-point arithmetic
-.Sh DESCRIPTION
-The IEEE Standard 754 for Binary Floating-Point Arithmetic
-defines representations of floating-point numbers and abstract
-properties of arithmetic operations relating to precision,
-rounding, and exceptional cases, as described below.
-.Ss IEEE STANDARD 754 Floating-Point Arithmetic
-Radix: Binary.
-.Pp
-Overflow and underflow:
-.Bd -ragged -offset indent -compact
-Overflow goes by default to a signed \*(If.
-Underflow is
-.Em gradual .
-.Ed
-.Pp
-Zero is represented ambiguously as +0 or \-0.
-.Bd -ragged -offset indent -compact
-Its sign transforms correctly through multiplication or
-division, and is preserved by addition of zeros
-with like signs; but x\-x yields +0 for every
-finite x.
-The only operations that reveal zero's
-sign are division by zero and
-.Fn copysign x \(+-0 .
-In particular, comparison (x > y, x \(>= y, etc.)\&
-cannot be affected by the sign of zero; but if
-finite x = y then \*(If = 1/(x\-y) \(!= \-1/(y\-x) = \-\*(If.
-.Ed
-.Pp
-Infinity is signed.
-.Bd -ragged -offset indent -compact
-It persists when added to itself
-or to any finite number.
-Its sign transforms
-correctly through multiplication and division, and
-(finite)/\(+-\*(If\0=\0\(+-0
-(nonzero)/0 = \(+-\*(If.
-But
-\*(If\-\*(If, \*(If\(**0 and \*(If/\*(If
-are, like 0/0 and sqrt(\-3),
-invalid operations that produce \*(Na. ...
-.Ed
-.Pp
-Reserved operands (\*(Nas):
-.Bd -ragged -offset indent -compact
-An \*(Na is
-.Em ( N Ns ot Em a N Ns umber ) .
-Some \*(Nas, called Signaling \*(Nas, trap any floating-point operation
-performed upon them; they are used to mark missing
-or uninitialized values, or nonexistent elements
-of arrays.
-The rest are Quiet \*(Nas; they are
-the default results of Invalid Operations, and
-propagate through subsequent arithmetic operations.
-If x \(!= x then x is \*(Na; every other predicate
-(x > y, x = y, x < y, ...) is FALSE if \*(Na is involved.
-.Ed
-.Pp
-Rounding:
-.Bd -ragged -offset indent -compact
-Every algebraic operation (+, \-, \(**, /,
-\(sr)
-is rounded by default to within half an
-.Em ulp ,
-and when the rounding error is exactly half an
-.Em ulp
-then
-the rounded value's least significant bit is zero.
-(An
-.Em ulp
-is one
-.Em U Ns nit
-in the
-.Em L Ns ast
-.Em P Ns lace . )
-This kind of rounding is usually the best kind,
-sometimes provably so; for instance, for every
-x = 1.0, 2.0, 3.0, 4.0, ..., 2.0**52, we find
-(x/3.0)\(**3.0 == x and (x/10.0)\(**10.0 == x and ...
-despite that both the quotients and the products
-have been rounded.
-Only rounding like IEEE 754 can do that.
-But no single kind of rounding can be
-proved best for every circumstance, so IEEE 754
-provides rounding towards zero or towards
-+\*(If or towards \-\*(If
-at the programmer's option.
-.Ed
-.Pp
-Exceptions:
-.Bd -ragged -offset indent -compact
-IEEE 754 recognizes five kinds of floating-point exceptions,
-listed below in declining order of probable importance.
-.Bl -column -offset indent "Invalid Operation" "Gradual Underflow"
-.Em "Exception	Default Result"
-Invalid Operation	\*(Na, or FALSE
-Overflow	\(+-\*(If
-Divide by Zero	\(+-\*(If
-Underflow	Gradual Underflow
-Inexact	Rounded value
-.El
-.Pp
-NOTE: An Exception is not an Error unless handled
-badly.
-What makes a class of exceptions exceptional
-is that no single default response can be satisfactory
-in every instance.
-On the other hand, if a default
-response will serve most instances satisfactorily,
-the unsatisfactory instances cannot justify aborting
-computation every time the exception occurs.
-.Ed
-.Ss Data Formats
-Single-precision:
-.Bd -ragged -offset indent -compact
-Type name:
-.Vt float
-.Pp
-Wordsize: 32 bits.
-.Pp
-Precision: 24 significant bits,
-roughly like 7 significant decimals.
-.Bd -ragged -offset indent -compact
-If x and x' are consecutive positive single-precision
-numbers (they differ by 1
-.Em ulp ) ,
-then
-.Bd -ragged -compact
-5.9e\-08 < 0.5**24 < (x'\-x)/x \(<= 0.5**23 < 1.2e\-07.
-.Ed
-.Ed
-.Pp
-.Bl -column "XXX" -compact
-Range:	Overflow threshold  = 2.0**128 = 3.4e38
-	Underflow threshold = 0.5**126 = 1.2e\-38
-.El
-.Bd -ragged -offset indent -compact
-Underflowed results round to the nearest
-integer multiple of 0.5**149 = 1.4e\-45.
-.Ed
-.Ed
-.Pp
-Double-precision:
-.Bd -ragged -offset indent -compact
-Type name:
-.Vt double
-.Bd -ragged -offset indent -compact
-On some architectures,
-.Vt long double
-is the the same as
-.Vt double .
-.Ed
-.Pp
-Wordsize: 64 bits.
-.Pp
-Precision: 53 significant bits,
-roughly like 16 significant decimals.
-.Bd -ragged -offset indent -compact
-If x and x' are consecutive positive double-precision
-numbers (they differ by 1
-.Em ulp ) ,
-then
-.Bd -ragged -compact
-1.1e\-16 < 0.5**53 < (x'\-x)/x \(<= 0.5**52 < 2.3e\-16.
-.Ed
-.Ed
-.Pp
-.Bl -column "XXX" -compact
-Range:	Overflow threshold  = 2.0**1024 = 1.8e308
-	Underflow threshold = 0.5**1022 = 2.2e\-308
-.El
-.Bd -ragged -offset indent -compact
-Underflowed results round to the nearest
-integer multiple of 0.5**1074 = 4.9e\-324.
-.Ed
-.Ed
-.Pp
-Extended-precision:
-.Bd -ragged -offset indent -compact
-Type name:
-.Vt long double
-(when supported by the hardware)
-.Pp
-Wordsize: 96 bits.
-.Pp
-Precision: 64 significant bits,
-roughly like 19 significant decimals.
-.Bd -ragged -offset indent -compact
-If x and x' are consecutive positive double-precision
-numbers (they differ by 1
-.Em ulp ) ,
-then
-.Bd -ragged -compact
-1.0e\-19 < 0.5**63 < (x'\-x)/x \(<= 0.5**62 < 2.2e\-19.
-.Ed
-.Ed
-.Pp
-.Bl -column "XXX" -compact
-Range:	Overflow threshold  = 2.0**16384 = 1.2e4932
-	Underflow threshold = 0.5**16382 = 3.4e\-4932
-.El
-.Bd -ragged -offset indent -compact
-Underflowed results round to the nearest
-integer multiple of 0.5**16445 = 5.7e\-4953.
-.Ed
-.Ed
-.Pp
-Quad-extended-precision:
-.Bd -ragged -offset indent -compact
-Type name:
-.Vt long double
-(when supported by the hardware)
-.Pp
-Wordsize: 128 bits.
-.Pp
-Precision: 113 significant bits,
-roughly like 34 significant decimals.
-.Bd -ragged -offset indent -compact
-If x and x' are consecutive positive double-precision
-numbers (they differ by 1
-.Em ulp ) ,
-then
-.Bd -ragged -compact
-9.6e\-35 < 0.5**113 < (x'\-x)/x \(<= 0.5**112 < 2.0e\-34.
-.Ed
-.Ed
-.Pp
-.Bl -column "XXX" -compact
-Range:	Overflow threshold  = 2.0**16384 = 1.2e4932
-	Underflow threshold = 0.5**16382 = 3.4e\-4932
-.El
-.Bd -ragged -offset indent -compact
-Underflowed results round to the nearest
-integer multiple of 0.5**16494 = 6.5e\-4966.
-.Ed
-.Ed
-.Ss Additional Information Regarding Exceptions
-.Pp
-For each kind of floating-point exception, IEEE 754
-provides a Flag that is raised each time its exception
-is signaled, and stays raised until the program resets
-it.
-Programs may also test, save and restore a flag.
-Thus, IEEE 754 provides three ways by which programs
-may cope with exceptions for which the default result
-might be unsatisfactory:
-.Bl -enum
-.It
-Test for a condition that might cause an exception
-later, and branch to avoid the exception.
-.It
-Test a flag to see whether an exception has occurred
-since the program last reset its flag.
-.It
-Test a result to see whether it is a value that only
-an exception could have produced.
-.Pp
-CAUTION: The only reliable ways to discover
-whether Underflow has occurred are to test whether
-products or quotients lie closer to zero than the
-underflow threshold, or to test the Underflow
-flag.
-(Sums and differences cannot underflow in
-IEEE 754; if x \(!= y then x\-y is correct to
-full precision and certainly nonzero regardless of
-how tiny it may be.)
-Products and quotients that
-underflow gradually can lose accuracy gradually
-without vanishing, so comparing them with zero
-(as one might on a VAX) will not reveal the loss.
-Fortunately, if a gradually underflowed value is
-destined to be added to something bigger than the
-underflow threshold, as is almost always the case,
-digits lost to gradual underflow will not be missed
-because they would have been rounded off anyway.
-So gradual underflows are usually
-.Em provably
-ignorable.
-The same cannot be said of underflows flushed to 0.
-.El
-.Pp
-At the option of an implementor conforming to IEEE 754,
-other ways to cope with exceptions may be provided:
-.Bl -enum
-.It
-ABORT.
-This mechanism classifies an exception in
-advance as an incident to be handled by means
-traditionally associated with error-handling
-statements like "ON ERROR GO TO ...".
-Different
-languages offer different forms of this statement,
-but most share the following characteristics:
-.Bl -dash
-.It
-No means is provided to substitute a value for
-the offending operation's result and resume
-computation from what may be the middle of an
-expression.
-An exceptional result is abandoned.
-.It
-In a subprogram that lacks an error-handling
-statement, an exception causes the subprogram to
-abort within whatever program called it, and so
-on back up the chain of calling subprograms until
-an error-handling statement is encountered or the
-whole task is aborted and memory is dumped.
-.El
-.It
-STOP.
-This mechanism, requiring an interactive
-debugging environment, is more for the programmer
-than the program.
-It classifies an exception in
-advance as a symptom of a programmer's error; the
-exception suspends execution as near as it can to
-the offending operation so that the programmer can
-look around to see how it happened.
-Quite often
-the first several exceptions turn out to be quite
-unexceptionable, so the programmer ought ideally
-to be able to resume execution after each one as if
-execution had not been stopped.
-.It
-\&... Other ways lie beyond the scope of this document.
-.El
-.Pp
-Ideally, each
-elementary function should act as if it were indivisible, or
-atomic, in the sense that ...
-.Bl -enum
-.It
-No exception should be signaled that is not deserved by
-the data supplied to that function.
-.It
-Any exception signaled should be identified with that
-function rather than with one of its subroutines.
-.It
-The internal behavior of an atomic function should not
-be disrupted when a calling program changes from
-one to another of the five or so ways of handling
-exceptions listed above, although the definition
-of the function may be correlated intentionally
-with exception handling.
-.El
-.Pp
-The functions in
-.Nm libm
-are only approximately atomic.
-They signal no inappropriate exception except possibly ...
-.Bl -tag -width indent -offset indent -compact
-.It Xo
-Over/Underflow
-.Xc
-when a result, if properly computed, might have lain barely within range, and
-.It Xo
-Inexact in
-.Fn cabs ,
-.Fn cbrt ,
-.Fn hypot ,
-.Fn log10
-and
-.Fn pow
-.Xc
-when it happens to be exact, thanks to fortuitous cancellation of errors.
-.El
-Otherwise, ...
-.Bl -tag -width indent -offset indent -compact
-.It Xo
-Invalid Operation is signaled only when
-.Xc
-any result but \*(Na would probably be misleading.
-.It Xo
-Overflow is signaled only when
-.Xc
-the exact result would be finite but beyond the overflow threshold.
-.It Xo
-Divide-by-Zero is signaled only when
-.Xc
-a function takes exactly infinite values at finite operands.
-.It Xo
-Underflow is signaled only when
-.Xc
-the exact result would be nonzero but tinier than the underflow threshold.
-.It Xo
-Inexact is signaled only when
-.Xc
-greater range or precision would be needed to represent the exact result.
-.El
-.Sh SEE ALSO
-.Xr fenv 3 ,
-.Xr ieee_test 3 ,
-.Xr math 3
-.Pp
-An explanation of IEEE 754 and its proposed extension p854
-was published in the IEEE magazine MICRO in August 1984 under
-the title "A Proposed Radix- and Word-length-independent
-Standard for Floating-point Arithmetic" by
-.An "W. J. Cody"
-et al.
-The manuals for Pascal, C and BASIC on the Apple Macintosh
-document the features of IEEE 754 pretty well.
-Articles in the IEEE magazine COMPUTER vol.\& 14 no.\& 3 (Mar.\&
-1981), and in the ACM SIGNUM Newsletter Special Issue of
-Oct.\& 1979, may be helpful although they pertain to
-superseded drafts of the standard.
-.Sh STANDARDS
-.St -ieee754
diff --git a/libm/man/ieee_test.3 b/libm/man/ieee_test.3
deleted file mode 100644
index debb6c8..0000000
--- a/libm/man/ieee_test.3
+++ /dev/null
@@ -1,93 +0,0 @@
-.\" Copyright (c) 1985, 1991 Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)ieee.3	6.4 (Berkeley) 5/6/91
-.\" $FreeBSD: src/lib/msun/man/ieee_test.3,v 1.13 2005/11/17 13:00:00 ru Exp $
-.\"
-.Dd November 6, 2005
-.Dt IEEE_TEST 3
-.Os
-.Sh NAME
-.Nm scalb ,
-.Nm scalbf ,
-.Nm significand ,
-.Nm significandf
-.Nd IEEE test functions
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn scalb "double x" "double n"
-.Ft float
-.Fn scalbf "float x" "float n"
-.Ft double
-.Fn significand "double x"
-.Ft float
-.Fn significandf "float x"
-.Sh DESCRIPTION
-These functions allow users to test conformance to
-.St -ieee754 .
-Their use is not otherwise recommended.
-.Pp
-.Fn scalb x n
-and
-.Fn scalbf x n
-return
-.Fa x Ns \(**(2** Ns Fa n )
-computed by exponent manipulation.
-If
-.Fa n
-is not an integer, \*(Pm\*(If, or an \*(Na, the result is unspecified.
-.Pp
-.Fn significand x
-and
-.Fn significandf x
-return
-.Fa sig ,
-where
-.Fa x
-:=
-.Fa sig No \(** 2** Ns Fa n
-with 1 \(<=
-.Fa sig
-< 2.
-.Fn significand x
-and
-.Fn significandf x
-are not defined when
-.Fa x
-is 0, \*(Pm\*(If, or \*(Na.
-.Sh SEE ALSO
-.Xr ieee 3 ,
-.Xr math 3
-.Sh STANDARDS
-.St -ieee754
diff --git a/libm/man/ilogb.3 b/libm/man/ilogb.3
deleted file mode 100644
index 00ac754..0000000
--- a/libm/man/ilogb.3
+++ /dev/null
@@ -1,127 +0,0 @@
-.\" Copyright (c) 1985, 1991 Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)ieee.3	6.4 (Berkeley) 5/6/91
-.\" $FreeBSD: src/lib/msun/man/ilogb.3,v 1.3 2005/11/17 13:00:00 ru Exp $
-.\"
-.Dd November 6, 2005
-.Dt ILOGB 3
-.Os
-.Sh NAME
-.Nm ilogb ,
-.Nm ilogbf ,
-.Nm ilogbl ,
-.Nm logb ,
-.Nm logbf
-.Nd extract exponent
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft int
-.Fn ilogb "double x"
-.Ft int
-.Fn ilogbf "float x"
-.Ft int
-.Fn ilogbl "long double x"
-.Ft double
-.Fn logb "double x"
-.Ft float
-.Fn logbf "float x"
-.Sh DESCRIPTION
-.Fn ilogb ,
-.Fn ilogbf
-and
-.Fn ilogbl
-return
-.Fa x Ns 's exponent
-in integer format.
-.Fn ilogb \*(Pm\*(If
-returns
-.Dv INT_MAX ,
-.Fn ilogb \*(Pm\*(Na
-returns
-.Dv FP_ILOGBNAN ,
-and
-.Fn ilogb 0
-returns
-.Dv FP_ILOGB0 .
-.Pp
-.Fn logb x
-and
-.Fn logbf x
-return
-.Fa x Ns 's exponent
-in floating\-point format with the same precision as
-.Fa x .
-.Fn logb \*(Pm\*(If
-returns +\*(If, and
-.Fn logb 0
-returns -\*(If with a division by zero exception.
-.Sh SEE ALSO
-.Xr frexp 3 ,
-.Xr ieee 3 ,
-.Xr math 3 ,
-.Xr scalbn 3
-.Sh STANDARDS
-The
-.Fn ilogb ,
-.Fn ilogbf ,
-.Fn ilogbl ,
-.Fn logb
-and
-.Fn logbf
-routines conform to
-.St -isoC-99 .
-.Fn logb
-and
-.Fn logbf
-implement the logb function recommended by
-.St -ieee754 .
-.Sh HISTORY
-The
-.Fn logb
-function appeared in
-.Bx 4.3 .
-The
-.Fn ilogb
-function appeared in
-.Fx 1.1.5 .
-The
-.Fn ilogbf
-and
-.Fn logbf
-functions appeared in
-.Fx 2.0 .
-The
-.Fn ilogbl
-function appeared in
-.Fx 5.4 .
diff --git a/libm/man/j0.3 b/libm/man/j0.3
deleted file mode 100644
index 76cd51c..0000000
--- a/libm/man/j0.3
+++ /dev/null
@@ -1,142 +0,0 @@
-.\" Copyright (c) 1985, 1991 Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)j0.3	6.7 (Berkeley) 4/19/91
-.\" $FreeBSD: src/lib/msun/man/j0.3,v 1.13 2005/01/14 23:28:28 das Exp $
-.\"
-.Dd January 14, 2005
-.Dt J0 3
-.Os
-.Sh NAME
-.Nm j0 ,
-.Nm j0f ,
-.Nm j1 ,
-.Nm j1f ,
-.Nm jn ,
-.Nm jnf ,
-.Nm y0 ,
-.Nm y0f ,
-.Nm y1 ,
-.Nm y1f ,
-.Nm yn ,
-.Nm ynf
-.Nd Bessel functions of first and second kind
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn j0 "double x"
-.Ft float
-.Fn j0f "float x"
-.Ft double
-.Fn j1 "double x"
-.Ft float
-.Fn j1f "float x"
-.Ft double
-.Fn jn "int n" "double x"
-.Ft float
-.Fn jnf "int n" "float x"
-.Ft double
-.Fn y0 "double x"
-.Ft float
-.Fn y0f "float x"
-.Ft double
-.Fn y1 "double x"
-.Ft float
-.Fn y1f "float x"
-.Ft double
-.Fn yn "int n" "double x"
-.Ft float
-.Fn ynf "int n" "float x"
-.Sh DESCRIPTION
-The functions
-.Fn j0 ,
-.Fn j0f ,
-.Fn j1
-and
-.Fn j1f
-compute the
-.Em Bessel function of the first kind of the order
-0 and the
-.Em order
-1, respectively,
-for the
-real value
-.Fa x ;
-the functions
-.Fn jn
-and
-.Fn jnf
-compute the
-.Em Bessel function of the first kind of the integer
-.Em order
-.Fa n
-for the real value
-.Fa x .
-.Pp
-The functions
-.Fn y0 ,
-.Fn y0f ,
-.Fn y1 ,
-and
-.Fn y1f
-compute the linearly independent
-.Em Bessel function of the second kind of the order
-0 and the
-.Em order
-1, respectively,
-for the
-positive
-.Em real
-value
-.Fa x ;
-the functions
-.Fn yn
-and
-.Fn ynf
-compute the
-.Em Bessel function of the second kind for the integer
-.Em order
-.Fa n
-for the positive
-.Em real
-value
-.Fa x .
-.Sh RETURN VALUES
-If these functions are successful,
-the computed value is returned.
-.Sh SEE ALSO
-.Xr math 3
-.Sh HISTORY
-This set of functions
-appeared in
-.At v7 .
diff --git a/libm/man/lgamma.3 b/libm/man/lgamma.3
deleted file mode 100644
index 0064a48..0000000
--- a/libm/man/lgamma.3
+++ /dev/null
@@ -1,185 +0,0 @@
-.\" Copyright (c) 1985, 1991 Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)lgamma.3	6.6 (Berkeley) 12/3/92
-.\" $FreeBSD: src/lib/msun/man/lgamma.3,v 1.22 2005/01/16 16:46:14 ru Exp $
-.\"
-.Dd January 14, 2005
-.Dt LGAMMA 3
-.Os
-.Sh NAME
-.Nm lgamma ,
-.Nm lgamma_r ,
-.Nm lgammaf ,
-.Nm lgammaf_r ,
-.Nm gamma ,
-.Nm gamma_r ,
-.Nm gammaf ,
-.Nm gammaf_r ,
-.Nm tgamma
-.Nd log gamma functions, gamma function
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft extern int
-.Fa signgam ;
-.sp
-.Ft double
-.Fn lgamma "double x"
-.Ft double
-.Fn lgamma_r "double x" "int *signgamp"
-.Ft float
-.Fn lgammaf "float x"
-.Ft float
-.Fn lgammaf_r "float x" "int *signgamp"
-.Ft double
-.Fn gamma "double x"
-.Ft double
-.Fn gamma_r "double x" "int *signgamp"
-.Ft float
-.Fn gammaf "float x"
-.Ft float
-.Fn gammaf_r "float x" "int *signgamp"
-.Ft double
-.Fn tgamma "double x"
-.Sh DESCRIPTION
-.Fn lgamma x
-and
-.Fn lgammaf x
-.if t \{\
-return ln\||\(*G(x)| where
-.Bd -unfilled -offset indent
-\(*G(x) = \(is\d\s8\z0\s10\u\u\s8\(if\s10\d t\u\s8x\-1\s10\d e\u\s8\-t\s10\d dt	for x > 0 and
-\(*G(x) = \(*p/(\(*G(1\-x)\|sin(\(*px))	for x < 1.
-.Ed
-.\}
-.if n \
-return ln\||\(*G(x)|.
-.Pp
-The external integer
-.Fa signgam
-returns the sign of \(*G(x).
-.Pp
-.Fn lgamma_r x signgamp
-and
-.Fn lgammaf_r x signgamp
-provide the same functionality as
-.Fn lgamma x
-and
-.Fn lgammaf x
-but the caller must provide an integer to store the sign of \(*G(x).
-.Pp
-.Fn gamma ,
-.Fn gammaf ,
-.Fn gamma_r ,
-and
-.Fn gammaf_r
-are deprecated aliases for
-.Fn lgamma ,
-.Fn lgammaf ,
-.Fn lgamma_r ,
-and
-.Fn lgammaf_r ,
-respectively.
-.Fn tgamma x
-returns \(*G(x), with no effect on
-.Fa signgam .
-.Sh IDIOSYNCRASIES
-Do not use the expression
-.Dq Li signgam\(**exp(lgamma(x))
-to compute g := \(*G(x).
-Instead use a program like this (in C):
-.Bd -literal -offset indent
-lg = lgamma(x); g = signgam\(**exp(lg);
-.Ed
-.Pp
-Only after
-.Fn lgamma
-or
-.Fn lgammaf
-has returned can signgam be correct.
-.Pp
-For arguments in its range,
-.Fn tgamma
-is preferred, as for positive arguments
-it is accurate to within one unit in the last place.
-Exponentiation of
-.Fn lgamma
-will lose up to 10 significant bits.
-.Sh RETURN VALUES
-.Fn gamma ,
-.Fn gamma_r ,
-.Fn gammaf ,
-.Fn gammaf_r ,
-.Fn lgamma ,
-.Fn lgamma_r ,
-.Fn lgammaf ,
-and
-.Fn lgammaf_r
-return appropriate values unless an argument is out of range.
-Overflow will occur for sufficiently large positive values, and
-non-positive integers.
-For large non-integer negative values,
-.Fn tgamma
-will underflow.
-.Sh SEE ALSO
-.Xr math 3
-.Sh STANDARDS
-The
-.Fn lgamma
-and
-.Fn tgamma
-functions are expected to conform to
-.St -isoC-99 .
-.Sh HISTORY
-The
-.Fn lgamma
-function appeared in
-.Bx 4.3 .
-The
-.Fn gamma
-function appeared in
-.Bx 4.4
-as a function which computed \(*G(x).
-This version was used in
-.Fx 1.1 .
-The name
-.Fn gamma
-was originally dedicated to the
-.Fn lgamma
-function,
-and that usage was restored by switching to Sun's fdlibm in
-.Fx 1.1.5 .
-The
-.Fn tgamma
-function appeared in
-.Fx 5.0 .
diff --git a/libm/man/lrint.3 b/libm/man/lrint.3
deleted file mode 100644
index d7de093..0000000
--- a/libm/man/lrint.3
+++ /dev/null
@@ -1,94 +0,0 @@
-.\" Copyright (c) 2005 David Schultz <das@FreeBSD.org>
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD: src/lib/msun/man/lrint.3,v 1.2 2005/01/13 10:43:01 ru Exp $
-.\"
-.Dd January 11, 2005
-.Dt LRINT 3
-.Os
-.Sh NAME
-.Nm llrint ,
-.Nm llrintf ,
-.Nm lrint ,
-.Nm lrintf
-.Nd "convert to integer"
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft "long long"
-.Fn llrint "double x"
-.Ft "long long"
-.Fn llrintf "float x"
-.Ft long
-.Fn lrint "double x"
-.Ft long
-.Fn lrintf "float x"
-.Sh DESCRIPTION
-The
-.Fn lrint
-function returns the integer nearest to its argument
-.Fa x
-according to the current rounding mode.
-If the rounded result is too large to be represented as a
-.Vt long
-value, an invalid exception is raised and the return value is undefined.
-Otherwise, if
-.Fa x
-is not an integer,
-.Fn lrint
-raises an inexact exception.
-When the rounded result is representable as a
-.Vt long ,
-the expression
-.Fn lrint x
-is equivalent to
-.Po Vt long Pc Ns Fn rint x
-(although the former may be more efficient).
-.Pp
-The
-.Fn llrint ,
-.Fn llrintf ,
-and
-.Fn lrintf
-functions differ from
-.Fn lrint
-only in their input and output types.
-.Sh SEE ALSO
-.Xr lround 3 ,
-.Xr math 3 ,
-.Xr rint 3 ,
-.Xr round 3
-.Sh STANDARDS
-The
-.Fn llrint ,
-.Fn llrintf ,
-.Fn lrint ,
-and
-.Fn lrintf
-functions conform to
-.St -isoC-99 .
-.Sh HISTORY
-These routines first appeared in
-.Fx 5.4 .
diff --git a/libm/man/lround.3 b/libm/man/lround.3
deleted file mode 100644
index d3e53c2..0000000
--- a/libm/man/lround.3
+++ /dev/null
@@ -1,112 +0,0 @@
-.\" Copyright (c) 2005 David Schultz <das@FreeBSD.org>
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD: src/lib/msun/man/lround.3,v 1.4 2005/06/15 19:04:04 ru Exp $
-.\"
-.Dd April 7, 2005
-.Dt LROUND 3
-.Os
-.Sh NAME
-.Nm llround ,
-.Nm llroundf ,
-.Nm llroundl ,
-.Nm lround ,
-.Nm lroundf ,
-.Nm lroundl
-.Nd "convert to nearest integral value"
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft "long long"
-.Fn llround "double x"
-.Ft "long long"
-.Fn llroundf "float x"
-.Ft "long long"
-.Fn llroundl "long double x"
-.Ft long
-.Fn lround "double x"
-.Ft long
-.Fn lroundf "float x"
-.Ft long
-.Fn lroundl "long double x"
-.Sh DESCRIPTION
-The
-.Fn lround
-function returns the integer nearest to its argument
-.Fa x ,
-rounding away from zero in halfway cases.
-If the rounded result is too large to be represented as a
-.Vt long
-value, an invalid exception is raised and the return value is undefined.
-Otherwise, if
-.Fa x
-is not an integer,
-.Fn lround
-may raise an inexact exception.
-When the rounded result is representable as a
-.Vt long ,
-the expression
-.Fn lround x
-is equivalent to
-.Po Vt long Pc Ns Fn round x
-(although the former may be more efficient).
-.Pp
-The
-.Fn llround ,
-.Fn llroundf ,
-.Fn llroundl ,
-.Fn lroundf
-and
-.Fn lroundl
-functions differ from
-.Fn lround
-only in their input and output types.
-.Sh SEE ALSO
-.Xr lrint 3 ,
-.Xr math 3 ,
-.Xr rint 3 ,
-.Xr round 3
-.Sh STANDARDS
-The
-.Fn llround ,
-.Fn llroundf ,
-.Fn llroundl ,
-.Fn lround ,
-.Fn lroundf ,
-and
-.Fn lroundl
-functions conform to
-.St -isoC-99 .
-.Sh HISTORY
-The
-.Vt float
-and
-.Vt double
-versions of these routines first appeared in
-.Fx 5.4 .
-The
-.Vt "long double"
-versions appeared in
-.Fx 6.0 .
diff --git a/libm/man/math.3 b/libm/man/math.3
deleted file mode 100644
index 828b5e0..0000000
--- a/libm/man/math.3
+++ /dev/null
@@ -1,242 +0,0 @@
-.\" Copyright (c) 1985 Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"	from: @(#)math.3	6.10 (Berkeley) 5/6/91
-.\" $FreeBSD: src/lib/msun/man/math.3,v 1.27 2005/11/17 13:00:00 ru Exp $
-.\"
-.Dd November 6, 2005
-.Dt MATH 3
-.Os
-.if n \{\
-.char \[sr] "sqrt
-.\}
-.Sh NAME
-.Nm math
-.Nd "floating-point mathematical library"
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Sh DESCRIPTION
-These functions constitute the C math library.
-.Sh "LIST OF FUNCTIONS"
-Each of the following
-.Vt double
-functions has a
-.Vt float
-counterpart with an
-.Ql f
-appended to the name and a
-.Vt "long double"
-counterpart with an
-.Ql l
-appended.
-As an example, the
-.Vt float
-and
-.Vt "long double"
-counterparts of
-.Ft double
-.Fn acos "double x"
-are
-.Ft float
-.Fn acosf "float x"
-and
-.Ft "long double"
-.Fn acosl "long double x" ,
-respectively.
-.de Cl
-.Bl -column "isgreaterequal" "bessel function of the second kind of the order 0"
-.Em "Name	Description"
-..
-.Ss Algebraic Functions
-.Cl
-cbrt	cube root
-fma	fused multiply-add
-hypot	Euclidean distance
-sqrt	square root
-.El
-.Ss Classification Functions
-.Cl
-fpclassify	classify a floating-point value
-isfinite	determine whether a value is finite
-isinf	determine whether a value is infinite
-isnan	determine whether a value is \*(Na
-isnormal	determine whether a value is normalized
-.El
-.Ss Exponent Manipulation Functions
-.Cl
-frexp	extract exponent and mantissa
-ilogb	extract exponent
-ldexp	multiply by power of 2
-logb	extract exponent
-scalbln	adjust exponent
-scalbn	adjust exponent
-.El
-.Ss Extremum- and Sign-Related Functions
-.Cl
-copysign	copy sign bit
-fabs	absolute value
-fdim	positive difference
-fmax	maximum function
-fmin	minimum function
-signbit	extract sign bit
-.El
-.\" .Ss Not a Number
-.\" .Cl
-.\" nan	return quiet \*(Na)	0
-.\" .El
-.Ss Residue and Rounding Functions
-.Cl
-ceil	integer no less than
-floor	integer no greater than
-fmod	positive remainder
-llrint	round to integer in fixed-point format
-llround	round to nearest integer in fixed-point format
-lrint	round to integer in fixed-point format
-lround	round to nearest integer in fixed-point format
-modf	extract integer and fractional parts
-nearbyint	round to integer (silent)
-nextafter	next representable value
-nexttoward	next representable value
-remainder	remainder
-remquo	remainder with partial quotient
-rint	round to integer
-round	round to nearest integer
-trunc	integer no greater in magnitude than
-.El
-.Pp
-The
-.Fn ceil ,
-.Fn floor ,
-.Fn llround ,
-.Fn lround ,
-.Fn round ,
-and
-.Fn trunc
-functions round in predetermined directions, whereas
-.Fn llrint ,
-.Fn lrint ,
-and
-.Fn rint
-round according to the current (dynamic) rounding mode.
-For more information on controlling the dynamic rounding mode, see
-.Xr fenv 3
-and
-.Xr fesetround 3 .
-.Ss Silent Order Predicates
-.Cl
-isgreater	greater than relation
-isgreaterequal	greater than or equal to relation
-isless	less than relation
-islessequal	less than or equal to relation
-islessgreater	less than or greater than relation
-isunordered	unordered relation
-.El
-.Ss Transcendental Functions
-.Cl
-acos	inverse cosine
-acosh	inverse hyperbolic cosine
-asin	inverse sine
-asinh	inverse hyperbolic sine
-atan	inverse tangent
-atanh	inverse hyperbolic tangent
-atan2	atan(y/x); complex argument
-cos	cosine
-cosh	hyperbolic cosine
-erf	error function
-erfc	complementary error function
-exp	exponential base e
-exp2	exponential base 2
-expm1	exp(x)\-1
-j0	Bessel function of the first kind of the order 0
-j1	Bessel function of the first kind of the order 1
-jn	Bessel function of the first kind of the order n
-lgamma	log gamma function
-log	natural logarithm
-log10	logarithm to base 10
-log1p	log(1+x)
-.\" log2	base 2 logarithm
-pow	exponential x**y
-sin	trigonometric function
-sinh	hyperbolic function
-tan	trigonometric function
-tanh	hyperbolic function
-tgamma	gamma function
-y0	Bessel function of the second kind of the order 0
-y1	Bessel function of the second kind of the order 1
-yn	Bessel function of the second kind of the order n
-.El
-.Pp
-Unlike the algebraic functions listed earlier, the routines
-in this section may not produce a result that is correctly rounded,
-so reproducible results cannot be guaranteed across platforms.
-For most of these functions, however, incorrect rounding occurs
-rarely, and then only in very-close-to-halfway cases.
-.Sh SEE ALSO
-.Xr fenv 3 ,
-.Xr ieee 3
-.Sh HISTORY
-A math library with many of the present functions appeared in
-.At v7 .
-The library was substantially rewritten for
-.Bx 4.3
-to provide
-better accuracy and speed on machines supporting either VAX
-or IEEE 754 floating-point.
-Most of this library was replaced with FDLIBM, developed at Sun
-Microsystems, in
-.Fx 1.1.5 .
-Additional routines, including ones for
-.Vt float
-and
-.Vt long double
-values, were written for or imported into subsequent versions of FreeBSD.
-.Sh BUGS
-The
-.Fn log2
-and
-.Fn nan
-functions are missing, and many functions are not available in their
-.Vt "long double"
-variants.
-.Pp
-Many of the routines to compute transcendental functions produce
-inaccurate results in other than the default rounding mode.
-.Pp
-On some architectures, trigonometric argument reduction is not
-performed accurately, resulting in errors greater than 1
-.Em ulp
-for large arguments to
-.Fn cos ,
-.Fn sin ,
-and
-.Fn tan .
diff --git a/libm/man/nextafter.3 b/libm/man/nextafter.3
deleted file mode 100644
index 1c94fb7..0000000
--- a/libm/man/nextafter.3
+++ /dev/null
@@ -1,100 +0,0 @@
-.\" Copyright (c) 1985, 1991 Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)ieee.3	6.4 (Berkeley) 5/6/91
-.\" $FreeBSD: src/lib/msun/man/nextafter.3,v 1.2 2005/03/07 05:00:29 das Exp $
-.\"
-.Dd May 4, 2005
-.Dt NEXTAFTER 3
-.Os
-.Sh NAME
-.Nm nextafter ,
-.Nm nextafterf ,
-.Nm nextafterl ,
-.Nm nexttoward ,
-.Nm nexttowardf ,
-.Nm nexttowardl
-.Nd next representable value
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn nextafter "double x" "double y"
-.Ft float
-.Fn nextafterf "float x" "float y"
-.Ft long double
-.Fn nextafterl "long double x" "long double y"
-.Ft double
-.Fn nexttoward "double x" "long double y"
-.Ft float
-.Fn nexttowardf "float x" "long double y"
-.Ft long double
-.Fn nexttowardl "long double x" "long double y"
-.Sh DESCRIPTION
-These functions
-return the next machine representable number from
-.Fa x
-in direction
-.Fa y .
-.Sh SEE ALSO
-.Xr ieee 3 ,
-.Xr math 3
-.Sh STANDARDS
-The
-.Fn nextafter ,
-.Fn nextafterf ,
-.Fn nextafterl ,
-.Fn nexttoward ,
-.Fn nexttowardf ,
-and
-.Fn nexttowardl
-routines conform to
-.St -isoC-99 .
-They implement the Nextafter function recommended by
-.St -ieee754 ,
-with the extension that
-.Fn nextafter +0.0, -0.0
-returns
-.Li -0.0 ,
-and
-.Fn nextafter -0.0, +0.0
-returns
-.Li +0.0 .
-.Sh HISTORY
-The
-.Fn nextafter
-function appeared in
-.Bx 4.3 ,
-and
-.Fn nextafterf
-appeared in
-.Fx 2.0 .
diff --git a/libm/man/remainder.3 b/libm/man/remainder.3
deleted file mode 100644
index 9b621e3..0000000
--- a/libm/man/remainder.3
+++ /dev/null
@@ -1,146 +0,0 @@
-.\" Copyright (c) 1985, 1991 Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)ieee.3	6.4 (Berkeley) 5/6/91
-.\" $FreeBSD: src/lib/msun/man/remainder.3,v 1.4 2005/11/24 09:25:10 joel Exp $
-.\"
-.Dd March 24, 2005
-.Dt REMAINDER 3
-.Os
-.Sh NAME
-.Nm remainder ,
-.Nm remainderf ,
-.Nm remquo ,
-.Nm remquof
-.Nd minimal residue functions
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn remainder "double x" "double y"
-.Ft float
-.Fn remainderf "float x" "float y"
-.Ft double
-.Fn remquo "double x" "double y" "int *quo"
-.Ft float
-.Fn remquof "float x" "float y" "int *quo"
-.Sh DESCRIPTION
-.Fn remainder ,
-.Fn remainderf ,
-.Fn remquo ,
-and
-.Fn remquof
-return the remainder
-.Fa r
-:=
-.Fa x
-\-
-.Fa n\(**y
-where
-.Fa n
-is the integer nearest the exact value of
-.Bk -words
-.Fa x Ns / Ns Fa y ;
-.Ek
-moreover if
-.Pf \\*(Ba Fa n
-\-
-.Sm off
-.Fa x No / Fa y No \\*(Ba
-.Sm on
-=
-1/2
-then
-.Fa n
-is even.
-Consequently
-the remainder is computed exactly and
-.Sm off
-.Pf \\*(Ba Fa r No \\*(Ba
-.Sm on
-\*(Le
-.Sm off
-.Pf \\*(Ba Fa y No \\*(Ba/2 .
-.Sm on
-But attempting to take the remainder when
-.Fa y
-is 0 or
-.Fa x
-is \*(Pm\*(If is an invalid operation that produces a \*(Na.
-.Pp
-The
-.Fn remquo
-and
-.Fn remquof
-functions also store the last
-.Va k
-bits of
-.Fa n
-in the location pointed to by
-.Fa quo ,
-provided that
-.Fa n
-exists.
-The number of bits
-.Va k
-is platform-specific, but is guaranteed to be at least 3.
-.Sh SEE ALSO
-.Xr fmod 3 ,
-.Xr ieee 3 ,
-.Xr math 3
-.Sh STANDARDS
-The
-.Fn remainder ,
-.Fn remainderf ,
-.Fn remquo ,
-and
-.Fn remquof
-routines conform to
-.St -isoC-99 .
-The remainder is as defined in
-.St -ieee754 .
-.Sh HISTORY
-The
-.Fn remainder
-and
-.Fn remainderf
-functions appeared in
-.Bx 4.3
-and
-.Fx 2.0 ,
-respectively.
-The
-.Fn remquo
-and
-.Fn remquof
-functions were added in
-.Fx 6.0 .
diff --git a/libm/man/rint.3 b/libm/man/rint.3
deleted file mode 100644
index ee55fea..0000000
--- a/libm/man/rint.3
+++ /dev/null
@@ -1,103 +0,0 @@
-.\" Copyright (c) 1985, 1991 Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)rint.3	5.1 (Berkeley) 5/2/91
-.\" $FreeBSD: src/lib/msun/man/rint.3,v 1.11 2005/01/11 23:12:17 das Exp $
-.\"
-.Dd July 5, 2004
-.Dt RINT 3
-.Os
-.Sh NAME
-.Nm nearbyint ,
-.Nm nearbyintf ,
-.Nm rint ,
-.Nm rintf
-.Nd round to integral value in floating-point format
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn nearbyint "double x"
-.Ft float
-.Fn nearbyintf "float x"
-.Ft double
-.Fn rint "double x"
-.Ft float
-.Fn rintf "float x"
-.Sh DESCRIPTION
-The
-.Fn rint
-and the
-.Fn rintf
-functions return the integral value nearest to
-.Fa x
-according to the prevailing rounding mode.
-These functions raise an inexact exception when the original argument
-is not an exact integer.
-.Pp
-The
-.Fn nearbyint
-and
-.Fn nearbyintf
-functions perform the same operation, except that they do not raise
-an inexact exception.
-.Sh SEE ALSO
-.Xr abs 3 ,
-.Xr ceil 3 ,
-.Xr fabs 3 ,
-.Xr fenv 3 ,
-.Xr floor 3 ,
-.Xr ieee 3 ,
-.Xr lrint 3 ,
-.Xr lround 3 ,
-.Xr math 3 ,
-.Xr round 3
-.Sh STANDARDS
-The
-.Fn nearbyint ,
-.Fn nearbyintf ,
-.Fn rint ,
-and
-.Fn rintf
-functions conform to
-.St -isoC-99 .
-.Sh HISTORY
-A
-.Fn rint
-function appeared in
-.At v6 .
-The
-.Fn nearbyint
-and
-.Fn nearbyintf
-functions appeared in
-.Fx 5.3 .
diff --git a/libm/man/round.3 b/libm/man/round.3
deleted file mode 100644
index b077d77..0000000
--- a/libm/man/round.3
+++ /dev/null
@@ -1,80 +0,0 @@
-.\" Copyright (c) 2003, Steven G. Kargl
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD: src/lib/msun/man/round.3,v 1.6 2005/06/15 19:04:04 ru Exp $
-.\"
-.Dd April 7, 2005
-.Dt ROUND 3
-.Os
-.Sh NAME
-.Nm round ,
-.Nm roundf ,
-.Nm roundl
-.Nd round to nearest integral value
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn round "double x"
-.Ft float
-.Fn roundf "float x"
-.Ft "long double"
-.Fn roundl "long double x"
-.Sh DESCRIPTION
-The
-.Fn round ,
-.Fn roundf ,
-and
-.Fn roundl
-functions return the nearest integral value to
-.Fa x ;
-if
-.Fa x
-lies halfway between two integral values, then these
-functions return the integral value with the larger
-absolute value (i.e., they round away from zero).
-.Sh SEE ALSO
-.Xr ceil 3 ,
-.Xr floor 3 ,
-.Xr ieee 3 ,
-.Xr lrint 3 ,
-.Xr lround 3 ,
-.Xr math 3 ,
-.Xr rint 3 ,
-.Xr trunc 3
-.Sh STANDARDS
-These functions conform to
-.St -isoC-99 .
-.Sh HISTORY
-The
-.Fn round
-and
-.Fn roundf
-functions appeared in
-.Fx 5.3 .
-The
-.Fn roundl
-function appeared in
-.Fx 6.0 .
diff --git a/libm/man/scalbn.3 b/libm/man/scalbn.3
deleted file mode 100644
index 923caab..0000000
--- a/libm/man/scalbn.3
+++ /dev/null
@@ -1,95 +0,0 @@
-.\" Copyright (c) 1985, 1991 Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)ieee.3	6.4 (Berkeley) 5/6/91
-.\" $FreeBSD: src/lib/msun/man/scalbn.3,v 1.3 2005/11/24 09:25:10 joel Exp $
-.\"
-.Dd March 4, 2005
-.Dt SCALBN 3
-.Os
-.Sh NAME
-.Nm scalbln ,
-.Nm scalblnf ,
-.Nm scalblnl ,
-.Nm scalbn ,
-.Nm scalbnf ,
-.Nm scalbnl
-.Nd adjust exponent
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn scalbln "double x" "long n"
-.Ft float
-.Fn scalblnf "float x" "long n"
-.Ft long double
-.Fn scalblnl "long double x" "long n"
-.Ft double
-.Fn scalbn "double x" "int n"
-.Ft float
-.Fn scalbnf "float x" "int n"
-.Ft long double
-.Fn scalbnl "long double x" "int n"
-.Sh DESCRIPTION
-These routines return
-.Fa x Ns \(**(2** Ns Fa n )
-computed by exponent manipulation.
-.Sh SEE ALSO
-.Xr ieee 3 ,
-.Xr math 3
-.Sh STANDARDS
-These routines conform to
-.St -isoC-99 ,
-and they implement the Scalb function recommended by
-.St -ieee754 .
-.Sh HISTORY
-The
-.Fn scalbn
-and
-.Fn scalbnf
-functions appeared in
-.Bx 4.3
-and
-.Fx 2.0 ,
-respectively.
-The
-.Fn scalbln
-and
-.Fn scalblnf
-functions first appeared in
-.Fx 5.3 ,
-and
-.Fn scalblnl
-and
-.Fn scalbln
-in
-.Fx 6.0 .
diff --git a/libm/man/signbit.3 b/libm/man/signbit.3
deleted file mode 100644
index b749671..0000000
--- a/libm/man/signbit.3
+++ /dev/null
@@ -1,57 +0,0 @@
-.\" Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD: src/lib/msun/man/signbit.3,v 1.1 2004/07/19 08:16:10 das Exp $
-.\"
-.Dd July 18, 2004
-.Dt SIGNBIT 3
-.Os
-.Sh NAME
-.Nm signbit
-.Nd "determine whether a floating-point number's sign is negative"
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft int
-.Fn signbit "real-floating x"
-.Sh DESCRIPTION
-The
-.Fn signbit
-macro takes an argument of
-.Fa x
-and returns non-zero if the value of its sign is negative, otherwise 0.
-.Sh SEE ALSO
-.Xr fpclassify 3 ,
-.Xr math 3
-.Sh STANDARDS
-The
-.Fn signbit
-macro conforms to
-.St -isoC-99 .
-.Sh HISTORY
-The
-.Fn signbit
-macro was added in
-.Fx 5.1 .
diff --git a/libm/man/sin.3 b/libm/man/sin.3
deleted file mode 100644
index 3a408a7..0000000
--- a/libm/man/sin.3
+++ /dev/null
@@ -1,82 +0,0 @@
-.\" Copyright (c) 1991 The Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\"	@(#)sin.3	6.7 (Berkeley) 4/19/91
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)sin.3	6.7 (Berkeley) 4/19/91
-.\" $FreeBSD: src/lib/msun/man/sin.3,v 1.9 2001/10/13 12:23:23 bde Exp $
-.\"
-.Dd April 19, 1991
-.Dt SIN 3
-.Os
-.Sh NAME
-.Nm sin ,
-.Nm sinf
-.Nd sine functions
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn sin "double x"
-.Ft float
-.Fn sinf "float x"
-.Sh DESCRIPTION
-The
-.Fn sin
-and the
-.Fn sinf
-functions compute the sine of
-.Fa x
-(measured in radians).
-A large magnitude argument may yield a result with little
-or no significance.
-.Sh RETURN VALUES
-The
-.Fn sin
-and the
-.Fn sinf
-functions return the sine value.
-.Sh SEE ALSO
-.Xr acos 3 ,
-.Xr asin 3 ,
-.Xr atan 3 ,
-.Xr atan2 3 ,
-.Xr cos 3 ,
-.Xr cosh 3 ,
-.Xr math 3 ,
-.Xr sinh 3 ,
-.Xr tan 3 ,
-.Xr tanh 3
-.Sh STANDARDS
-The
-.Fn sin
-function conforms to
-.St -isoC .
diff --git a/libm/man/sinh.3 b/libm/man/sinh.3
deleted file mode 100644
index 8347862..0000000
--- a/libm/man/sinh.3
+++ /dev/null
@@ -1,71 +0,0 @@
-.\" Copyright (c) 1991 The Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"	from: @(#)sinh.3	6.6 (Berkeley) 4/19/91
-.\" $FreeBSD: src/lib/msun/man/sinh.3,v 1.12 2005/01/14 23:28:28 das Exp $
-.Dd January 14, 2005
-.Dt SINH 3
-.Os
-.Sh NAME
-.Nm sinh ,
-.Nm sinhf
-.Nd hyperbolic sine function
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn sinh "double x"
-.Ft float
-.Fn sinhf "float x"
-.Sh DESCRIPTION
-The
-.Fn sinh
-and the
-.Fn sinhf
-functions compute the hyperbolic sine of
-.Fa x .
-.Sh SEE ALSO
-.Xr acos 3 ,
-.Xr asin 3 ,
-.Xr atan 3 ,
-.Xr atan2 3 ,
-.Xr cos 3 ,
-.Xr cosh 3 ,
-.Xr math 3 ,
-.Xr sin 3 ,
-.Xr tan 3 ,
-.Xr tanh 3
-.Sh STANDARDS
-The
-.Fn sinh
-function conforms to
-.St -isoC .
diff --git a/libm/man/sqrt.3 b/libm/man/sqrt.3
deleted file mode 100644
index 22f8b7b..0000000
--- a/libm/man/sqrt.3
+++ /dev/null
@@ -1,100 +0,0 @@
-.\" Copyright (c) 1985, 1991 Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)sqrt.3	6.4 (Berkeley) 5/6/91
-.\" $FreeBSD: src/lib/msun/man/sqrt.3,v 1.12 2005/01/14 23:28:28 das Exp $
-.\"
-.Dd May 6, 1991
-.Dt SQRT 3
-.Os
-.Sh NAME
-.Nm cbrt ,
-.Nm cbrtf ,
-.Nm sqrt ,
-.Nm sqrtf
-.Nd cube root and square root functions
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn cbrt "double x"
-.Ft float
-.Fn cbrtf "float x"
-.Ft double
-.Fn sqrt "double x"
-.Ft float
-.Fn sqrtf "float x"
-.Sh DESCRIPTION
-The
-.Fn cbrt
-and the
-.Fn cbrtf
-functions compute
-the cube root of
-.Ar x .
-.Pp
-The
-.Fn sqrt
-and the
-.Fn sqrtf
-functions compute the
-non-negative square root of x.
-.Sh RETURN VALUES
-The
-.Fn cbrt
-and the
-.Fn cbrtf
-functions return the requested cube root.
-The
-.Fn sqrt
-and the
-.Fn sqrtf
-functions return the requested square root
-unless an error occurs.
-An attempt to take the
-.Fn sqrt
-of negative
-.Fa x
-raises an invalid exception and causes an \*(Na to be returned.
-.Sh SEE ALSO
-.Xr fenv 3 ,
-.Xr math 3
-.Sh STANDARDS
-The
-.Fn sqrt
-function conforms to
-.St -isoC .
-.Sh HISTORY
-The
-.Fn cbrt
-function appeared in
-.Bx 4.3 .
diff --git a/libm/man/tan.3 b/libm/man/tan.3
deleted file mode 100644
index 5995a3b..0000000
--- a/libm/man/tan.3
+++ /dev/null
@@ -1,81 +0,0 @@
-.\" Copyright (c) 1991 The Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)tan.3	5.1 (Berkeley) 5/2/91
-.\" $FreeBSD: src/lib/msun/man/tan.3,v 1.9 2001/10/13 12:23:23 bde Exp $
-.\"
-.Dd May 2, 1991
-.Dt TAN 3
-.Os
-.Sh NAME
-.Nm tan ,
-.Nm tanf
-.Nd tangent functions
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn tan "double x"
-.Ft float
-.Fn tanf "float x"
-.Sh DESCRIPTION
-The
-.Fn tan
-and the
-.Fn tanf
-functions compute the tangent of
-.Fa x
-(measured in radians).
-A large magnitude argument may yield a result
-with little or no significance.
-For a discussion of error due to roundoff, see
-.Xr math 3 .
-.Sh RETURN VALUES
-The
-.Fn tan
-function returns the tangent value.
-.Sh SEE ALSO
-.Xr acos 3 ,
-.Xr asin 3 ,
-.Xr atan 3 ,
-.Xr atan2 3 ,
-.Xr cos 3 ,
-.Xr cosh 3 ,
-.Xr math 3 ,
-.Xr sin 3 ,
-.Xr sinh 3 ,
-.Xr tanh 3
-.Sh STANDARDS
-The
-.Fn tan
-function conforms to
-.St -isoC .
diff --git a/libm/man/tanh.3 b/libm/man/tanh.3
deleted file mode 100644
index 391bc15..0000000
--- a/libm/man/tanh.3
+++ /dev/null
@@ -1,80 +0,0 @@
-.\" Copyright (c) 1991 The Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     from: @(#)tanh.3	5.1 (Berkeley) 5/2/91
-.\" $FreeBSD: src/lib/msun/man/tanh.3,v 1.10 2001/10/13 12:23:23 bde Exp $
-.\"
-.Dd May 2, 1991
-.Dt TANH 3
-.Os
-.Sh NAME
-.Nm tanh ,
-.Nm tanhf
-.Nd hyperbolic tangent functions
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn tanh "double x"
-.Ft float
-.Fn tanhf "float x"
-.Sh DESCRIPTION
-The
-.Fn tanh
-and the
-.Fn tanhf
-functions compute the hyperbolic tangent of
-.Fa x .
-For a discussion of error due to roundoff, see
-.Xr math 3 .
-.Sh RETURN VALUES
-The
-.Fn tanh
-and the
-.Fn tanhf
-functions return the hyperbolic tangent value.
-.Sh SEE ALSO
-.Xr acos 3 ,
-.Xr asin 3 ,
-.Xr atan 3 ,
-.Xr atan2 3 ,
-.Xr cos 3 ,
-.Xr cosh 3 ,
-.Xr math 3 ,
-.Xr sin 3 ,
-.Xr sinh 3 ,
-.Xr tan 3
-.Sh STANDARDS
-The
-.Fn tanh
-function conforms to
-.St -isoC .
diff --git a/libm/man/trunc.3 b/libm/man/trunc.3
deleted file mode 100644
index cb6c26f..0000000
--- a/libm/man/trunc.3
+++ /dev/null
@@ -1,80 +0,0 @@
-.\" Copyright (c) 2004, 2005 David Schultz <das@FreeBSD.org>
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD: src/lib/msun/man/trunc.3,v 1.3 2005/06/15 19:04:04 ru Exp $
-.\"
-.Dd April 16, 2005
-.Dt TRUNC 3
-.Os
-.Sh NAME
-.Nm trunc ,
-.Nm truncf ,
-.Nm truncl
-.Nd nearest integral value with magnitude less than or equal to |x|
-.Sh LIBRARY
-.Lb libm
-.Sh SYNOPSIS
-.In math.h
-.Ft double
-.Fn trunc "double x"
-.Ft float
-.Fn truncf "float x"
-.Ft "long double"
-.Fn truncl "long double x"
-.Sh DESCRIPTION
-The
-.Fn trunc ,
-.Fn truncf ,
-and
-.Fn truncl
-functions return the nearest integral value with magnitude less than
-or equal to
-.Pf | Fa x Ns | .
-They are equivalent to
-.Fn rint ,
-.Fn rintf ,
-and
-.Fn rintl ,
-respectively, in the
-.Dv FE_TOWARDZERO
-rounding mode.
-.Sh SEE ALSO
-.Xr ceil 3 ,
-.Xr fesetround 3 ,
-.Xr floor 3 ,
-.Xr math 3 ,
-.Xr nextafter 3 ,
-.Xr rint 3 ,
-.Xr round 3
-.Sh STANDARDS
-The
-.Fn trunc ,
-.Fn truncf ,
-and
-.Fn truncl
-functions conform to
-.St -isoC-99 .
-.Sh HISTORY
-These routines first appeared in
-.Fx 5.3 .
diff --git a/libm/mips/Makefile.inc b/libm/mips/Makefile.inc
deleted file mode 100644
index 9bbfaa1..0000000
--- a/libm/mips/Makefile.inc
+++ /dev/null
@@ -1,3 +0,0 @@
-# $FreeBSD: src/lib/msun/mips/Makefile.inc,v 1.1 2008/04/26 12:20:29 imp Exp $
-
-LDBL_PREC = 53
diff --git a/libm/mips/_fpmath.h b/libm/mips/_fpmath.h
index cb6e8c0..f006a58 100644
--- a/libm/mips/_fpmath.h
+++ b/libm/mips/_fpmath.h
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libc/mips/_fpmath.h,v 1.1 2008/04/26 12:07:59 imp Exp $
+ * $FreeBSD$
  */
 
 union IEEEl2bits {
diff --git a/libm/mips/fenv.h b/libm/mips/fenv.h
deleted file mode 100644
index 583d002..0000000
--- a/libm/mips/fenv.h
+++ /dev/null
@@ -1,220 +0,0 @@
-/*-
- * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/mips/fenv.h,v 1.1 2008/04/26 12:20:29 imp Exp $
- */
-
-#ifndef	_FENV_H_
-#define	_FENV_H_
-
-#include <sys/cdefs.h>
-#include <sys/_types.h>
-
-__BEGIN_DECLS
-
-typedef	__uint32_t	fenv_t;
-typedef	__uint32_t	fexcept_t;
-
-/* Exception flags */
-#define	FE_INVALID	0x0001
-#define	FE_DIVBYZERO	0x0002
-#define	FE_OVERFLOW	0x0004
-#define	FE_UNDERFLOW	0x0008
-#define	FE_INEXACT	0x0010
-#define	FE_ALL_EXCEPT	(FE_DIVBYZERO | FE_INEXACT | \
-			 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
-
-/* Rounding modes */
-#define	FE_TONEAREST	0x0000
-#define	FE_TOWARDZERO	0x0001
-#define	FE_UPWARD	0x0002
-#define	FE_DOWNWARD	0x0003
-#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
-			 FE_UPWARD | FE_TOWARDZERO)
-
-/* Default floating-point environment */
-extern const fenv_t	__fe_dfl_env;
-#define	FE_DFL_ENV	(&__fe_dfl_env)
-
-/* We need to be able to map status flag positions to mask flag positions */
-#define _FPUSW_SHIFT	16
-#define	_ENABLE_MASK	(FE_ALL_EXCEPT << _FPUSW_SHIFT)
-
-#ifdef	ARM_HARD_FLOAT
-#define	__rfs(__fpsr)	__asm __volatile("rfs %0" : "=r" (*(__fpsr)))
-#define	__wfs(__fpsr)	__asm __volatile("wfs %0" : : "r" (__fpsr))
-#else
-#define __rfs(__fpsr)
-#define __wfs(__fpsr)
-#endif
-
-static __inline int
-feclearexcept(int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	__fpsr &= ~__excepts;
-	__wfs(__fpsr);
-	return (0);
-}
-
-static __inline int
-fegetexceptflag(fexcept_t *__flagp, int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	*__flagp = __fpsr & __excepts;
-	return (0);
-}
-
-static __inline int
-fesetexceptflag(const fexcept_t *__flagp, int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	__fpsr &= ~__excepts;
-	__fpsr |= *__flagp & __excepts;
-	__wfs(__fpsr);
-	return (0);
-}
-
-static __inline int
-feraiseexcept(int __excepts)
-{
-	fexcept_t __ex = __excepts;
-
-	fesetexceptflag(&__ex, __excepts);	/* XXX */
-	return (0);
-}
-
-static __inline int
-fetestexcept(int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	return (__fpsr & __excepts);
-}
-
-static __inline int
-fegetround(void)
-{
-
-	/*
-	 * Apparently, the rounding mode is specified as part of the
-	 * instruction format on ARM, so the dynamic rounding mode is
-	 * indeterminate.  Some FPUs may differ.
-	 */
-	return (-1);
-}
-
-static __inline int
-fesetround(int __round)
-{
-
-	return (-1);
-}
-
-static __inline int
-fegetenv(fenv_t *__envp)
-{
-
-	__rfs(__envp);
-	return (0);
-}
-
-static __inline int
-feholdexcept(fenv_t *__envp)
-{
-	fenv_t __env;
-
-	__rfs(&__env);
-	*__envp = __env;
-	__env &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
-	__wfs(__env);
-	return (0);
-}
-
-static __inline int
-fesetenv(const fenv_t *__envp)
-{
-
-	__wfs(*__envp);
-	return (0);
-}
-
-static __inline int
-feupdateenv(const fenv_t *__envp)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	__wfs(*__envp);
-	feraiseexcept(__fpsr & FE_ALL_EXCEPT);
-	return (0);
-}
-
-#if __BSD_VISIBLE
-
-static __inline int
-feenableexcept(int __mask)
-{
-	fenv_t __old_fpsr, __new_fpsr;
-
-	__rfs(&__old_fpsr);
-	__new_fpsr = __old_fpsr | (__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT;
-	__wfs(__new_fpsr);
-	return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
-}
-
-static __inline int
-fedisableexcept(int __mask)
-{
-	fenv_t __old_fpsr, __new_fpsr;
-
-	__rfs(&__old_fpsr);
-	__new_fpsr = __old_fpsr & ~((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
-	__wfs(__new_fpsr);
-	return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
-}
-
-static __inline int
-fegetexcept(void)
-{
-	fenv_t __fpsr;
-
-	__rfs(&__fpsr);
-	return ((__fpsr & _ENABLE_MASK) >> _FPUSW_SHIFT);
-}
-
-#endif /* __BSD_VISIBLE */
-
-__END_DECLS
-
-#endif	/* !_FENV_H_ */
-
diff --git a/libm/powerpc/Makefile.inc b/libm/powerpc/Makefile.inc
deleted file mode 100644
index 7eb3700..0000000
--- a/libm/powerpc/Makefile.inc
+++ /dev/null
@@ -1,3 +0,0 @@
-# $FreeBSD: src/lib/msun/powerpc/Makefile.inc,v 1.1 2005/03/07 04:53:36 das Exp $
-
-LDBL_PREC = 53
diff --git a/libm/powerpc/_fpmath.h b/libm/powerpc/_fpmath.h
deleted file mode 100644
index 5285cb9..0000000
--- a/libm/powerpc/_fpmath.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * Copyright (c) 2003 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/libc/powerpc/_fpmath.h,v 1.7 2005/03/07 04:55:22 das Exp $
- */
-
-union IEEEl2bits {
-	long double	e;
-	struct {
-		unsigned int		sign	:1;
-		unsigned int		exp	:11;
-		unsigned int		manh	:20;
-		unsigned int		manl	:32;
-	} bits;
-};
-
-#define	mask_nbit_l(u)	((void)0)
-#define	LDBL_IMPLICIT_NBIT
-#define	LDBL_NBIT	0
-
-#define	LDBL_MANH_SIZE	20
-#define	LDBL_MANL_SIZE	32
-
-#define	LDBL_TO_ARRAY32(u, a) do {			\
-	(a)[0] = (uint32_t)(u).bits.manl;		\
-	(a)[1] = (uint32_t)(u).bits.manh;		\
-} while(0)
diff --git a/libm/powerpc/fenv.c b/libm/powerpc/fenv.c
deleted file mode 100644
index a8fa87a..0000000
--- a/libm/powerpc/fenv.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/*-
- * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/powerpc/fenv.c,v 1.1 2004/06/06 10:05:10 das Exp $
- */
-
-#include <fenv.h>
-
-const fenv_t __fe_dfl_env = 0x00000000;
diff --git a/libm/powerpc/fenv.h b/libm/powerpc/fenv.h
deleted file mode 100644
index 3fd2389..0000000
--- a/libm/powerpc/fenv.h
+++ /dev/null
@@ -1,263 +0,0 @@
-/*-
- * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/powerpc/fenv.h,v 1.3 2005/03/16 19:03:45 das Exp $
- */
-
-#ifndef	_FENV_H_
-#define	_FENV_H_
-
-#include <sys/_types.h>
-
-typedef	__uint32_t	fenv_t;
-typedef	__uint32_t	fexcept_t;
-
-/* Exception flags */
-#define	FE_INEXACT	0x02000000
-#define	FE_DIVBYZERO	0x04000000
-#define	FE_UNDERFLOW	0x08000000
-#define	FE_OVERFLOW	0x10000000
-#define	FE_INVALID	0x20000000	/* all types of invalid FP ops */
-
-/*
- * The PowerPC architecture has extra invalid flags that indicate the
- * specific type of invalid operation occurred.  These flags may be
- * tested, set, and cleared---but not masked---separately.  All of
- * these bits are cleared when FE_INVALID is cleared, but only
- * FE_VXSOFT is set when FE_INVALID is explicitly set in software.
- */
-#define	FE_VXCVI	0x00000100	/* invalid integer convert */
-#define	FE_VXSQRT	0x00000200	/* square root of a negative */
-#define	FE_VXSOFT	0x00000400	/* software-requested exception */
-#define	FE_VXVC		0x00080000	/* ordered comparison involving NaN */
-#define	FE_VXIMZ	0x00100000	/* inf * 0 */
-#define	FE_VXZDZ	0x00200000	/* 0 / 0 */
-#define	FE_VXIDI	0x00400000	/* inf / inf */
-#define	FE_VXISI	0x00800000	/* inf - inf */
-#define	FE_VXSNAN	0x01000000	/* operation on a signalling NaN */
-#define	FE_ALL_INVALID	(FE_VXCVI | FE_VXSQRT | FE_VXSOFT | FE_VXVC | \
-			 FE_VXIMZ | FE_VXZDZ | FE_VXIDI | FE_VXISI | \
-			 FE_VXSNAN | FE_INVALID)
-#define	FE_ALL_EXCEPT	(FE_DIVBYZERO | FE_INEXACT | \
-			 FE_ALL_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
-
-/* Rounding modes */
-#define	FE_TONEAREST	0x0000
-#define	FE_TOWARDZERO	0x0001
-#define	FE_UPWARD	0x0002
-#define	FE_DOWNWARD	0x0003
-#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
-			 FE_UPWARD | FE_TOWARDZERO)
-
-__BEGIN_DECLS
-
-/* Default floating-point environment */
-extern const fenv_t	__fe_dfl_env;
-#define	FE_DFL_ENV	(&__fe_dfl_env)
-
-/* We need to be able to map status flag positions to mask flag positions */
-#define	_FPUSW_SHIFT	22
-#define	_ENABLE_MASK	((FE_DIVBYZERO | FE_INEXACT | FE_INVALID | \
-			 FE_OVERFLOW | FE_UNDERFLOW) >> _FPUSW_SHIFT)
-
-#define	__mffs(__env)	__asm __volatile("mffs %0" : "=f" (*(__env)))
-#define	__mtfsf(__env)	__asm __volatile("mtfsf 255,%0" : : "f" (__env))
-
-union __fpscr {
-	double __d;
-	struct {
-		__uint32_t __junk;
-		fenv_t __reg;
-	} __bits;
-};
-
-static __inline int
-feclearexcept(int __excepts)
-{
-	union __fpscr __r;
-
-	if (__excepts & FE_INVALID)
-		__excepts |= FE_ALL_INVALID;
-	__mffs(&__r.__d);
-	__r.__bits.__reg &= ~__excepts;
-	__mtfsf(__r.__d);
-	return (0);
-}
-
-static __inline int
-fegetexceptflag(fexcept_t *__flagp, int __excepts)
-{
-	union __fpscr __r;
-
-	__mffs(&__r.__d);
-	*__flagp = __r.__bits.__reg & __excepts;
-	return (0);
-}
-
-static __inline int
-fesetexceptflag(const fexcept_t *__flagp, int __excepts)
-{
-	union __fpscr __r;
-
-	if (__excepts & FE_INVALID)
-		__excepts |= FE_ALL_EXCEPT;
-	__mffs(&__r.__d);
-	__r.__bits.__reg &= ~__excepts;
-	__r.__bits.__reg |= *__flagp & __excepts;
-	__mtfsf(__r.__d);
-	return (0);
-}
-
-static __inline int
-feraiseexcept(int __excepts)
-{
-	union __fpscr __r;
-
-	if (__excepts & FE_INVALID)
-		__excepts |= FE_VXSOFT;
-	__mffs(&__r.__d);
-	__r.__bits.__reg |= __excepts;
-	__mtfsf(__r.__d);
-	return (0);
-}
-
-static __inline int
-fetestexcept(int __excepts)
-{
-	union __fpscr __r;
-
-	__mffs(&__r.__d);
-	return (__r.__bits.__reg & __excepts);
-}
-
-static __inline int
-fegetround(void)
-{
-	union __fpscr __r;
-
-	__mffs(&__r.__d);
-	return (__r.__bits.__reg & _ROUND_MASK);
-}
-
-static __inline int
-fesetround(int __round)
-{
-	union __fpscr __r;
-
-	if (__round & ~_ROUND_MASK)
-		return (-1);
-	__mffs(&__r.__d);
-	__r.__bits.__reg &= ~_ROUND_MASK;
-	__r.__bits.__reg |= __round;
-	__mtfsf(__r.__d);
-	return (0);
-}
-
-static __inline int
-fegetenv(fenv_t *__envp)
-{
-	union __fpscr __r;
-
-	__mffs(&__r.__d);
-	*__envp = __r.__bits.__reg;
-	return (0);
-}
-
-static __inline int
-feholdexcept(fenv_t *__envp)
-{
-	union __fpscr __r;
-
-	__mffs(&__r.__d);
-	*__envp = __r.__d;
-	__r.__bits.__reg &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
-	__mtfsf(__r.__d);
-	return (0);
-}
-
-static __inline int
-fesetenv(const fenv_t *__envp)
-{
-	union __fpscr __r;
-
-	__r.__bits.__reg = *__envp;
-	__mtfsf(__r.__d);
-	return (0);
-}
-
-static __inline int
-feupdateenv(const fenv_t *__envp)
-{
-	union __fpscr __r;
-
-	__mffs(&__r.__d);
-	__r.__bits.__reg &= FE_ALL_EXCEPT;
-	__r.__bits.__reg |= *__envp;
-	__mtfsf(__r.__d);
-	return (0);
-}
-
-#if __BSD_VISIBLE
-
-static __inline int
-feenableexcept(int __mask)
-{
-	union __fpscr __r;
-	fenv_t __oldmask;
-
-	__mffs(&__r.__d);
-	__oldmask = __r.__bits.__reg;
-	__r.__bits.__reg |= (__mask & FE_ALL_EXCEPT) >> _FPUSW_SHIFT;
-	__mtfsf(__r.__d);
-	return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT);
-}
-
-static __inline int
-fedisableexcept(int __mask)
-{
-	union __fpscr __r;
-	fenv_t __oldmask;
-
-	__mffs(&__r.__d);
-	__oldmask = __r.__bits.__reg;
-	__r.__bits.__reg &= ~((__mask & FE_ALL_EXCEPT) >> _FPUSW_SHIFT);
-	__mtfsf(__r.__d);
-	return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT);
-}
-
-static __inline int
-fegetexcept(void)
-{
-	union __fpscr __r;
-
-	__mffs(&__r.__d);
-	return ((__r.__bits.__reg & _ENABLE_MASK) << _FPUSW_SHIFT);
-}
-
-#endif /* __BSD_VISIBLE */
-
-__END_DECLS
-
-#endif	/* !_FENV_H_ */
diff --git a/libm/sincos.c b/libm/sincos.c
index e9f6dcc..891aa31 100644
--- a/libm/sincos.c
+++ b/libm/sincos.c
@@ -35,20 +35,17 @@
 // Thus we just enforce -O0 when compiling this file.
 #pragma GCC optimize ("O0")
 
-void  sincos(double x, double *psin, double *pcos)
-{
-    *psin = sin(x);
-    *pcos = cos(x);
+void sincos(double x, double* p_sin, double* p_cos) {
+  *p_sin = sin(x);
+  *p_cos = cos(x);
 }
 
-void  sincosf(float x, float *psin, float *pcos)
-{
-    *psin = sinf(x);
-    *pcos = cosf(x);
+void sincosf(float x, float* p_sinf, float* p_cosf) {
+  *p_sinf = sinf(x);
+  *p_cosf = cosf(x);
 }
 
-void  sincosl(long double x, long double *psin, long double *pcos)
-{
-    *psin = sin(x);
-    *pcos = cos(x);
+void sincosl(long double x, long double* p_sinl, long double* p_cosl) {
+  *p_sinl = sinl(x);
+  *p_cosl = cosl(x);
 }
diff --git a/libm/sparc64/Makefile.inc b/libm/sparc64/Makefile.inc
deleted file mode 100644
index e883fa9..0000000
--- a/libm/sparc64/Makefile.inc
+++ /dev/null
@@ -1,4 +0,0 @@
-# $FreeBSD: src/lib/msun/sparc64/Makefile.inc,v 1.2 2005/03/07 04:53:36 das Exp $
-
-ARCH_SRCS= e_sqrt.S e_sqrtf.S
-LDBL_PREC= 113
diff --git a/libm/sparc64/_fpmath.h b/libm/sparc64/_fpmath.h
deleted file mode 100644
index 4afaab9..0000000
--- a/libm/sparc64/_fpmath.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
- * Copyright (c) 2002, 2003 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/libc/sparc64/_fpmath.h,v 1.5 2005/03/07 04:55:22 das Exp $
- */
-
-union IEEEl2bits {
-	long double	e;
-	struct {
-		unsigned int	sign	:1;
-		unsigned int	exp	:15;
-		unsigned long	manh	:48;
-		unsigned long	manl	:64;
-	} bits;
-};
-
-#define	mask_nbit_l(u)	((void)0)
-#define	LDBL_IMPLICIT_NBIT
-#define	LDBL_NBIT	0
-
-#define	LDBL_MANH_SIZE	48
-#define	LDBL_MANL_SIZE	64
-
-#define	LDBL_TO_ARRAY32(u, a) do {			\
-	(a)[0] = (uint32_t)(u).bits.manl;		\
-	(a)[1] = (uint32_t)((u).bits.manl >> 32);      	\
-	(a)[2] = (uint32_t)(u).bits.manh;		\
-	(a)[3] = (uint32_t)((u).bits.manh >> 32);	\
-} while(0)
diff --git a/libm/sparc64/e_sqrt.S b/libm/sparc64/e_sqrt.S
deleted file mode 100644
index 95f79a6..0000000
--- a/libm/sparc64/e_sqrt.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/sparc64/e_sqrt.S,v 1.1 2005/02/21 18:27:57 das Exp $")
-
-ENTRY(sqrt)
-	retl
-	fsqrtd %f0, %f0
-END(sqrt)
diff --git a/libm/sparc64/e_sqrtf.S b/libm/sparc64/e_sqrtf.S
deleted file mode 100644
index e1f7cf6..0000000
--- a/libm/sparc64/e_sqrtf.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/msun/sparc64/e_sqrtf.S,v 1.1 2005/02/21 18:27:57 das Exp $")
-
-ENTRY(sqrtf)
-	retl
-	fsqrts %f1, %f0
-END(sqrtf)
diff --git a/libm/sparc64/fenv.c b/libm/sparc64/fenv.c
deleted file mode 100644
index 79a0f64..0000000
--- a/libm/sparc64/fenv.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/sparc64/fenv.c,v 1.1 2004/06/06 10:05:57 das Exp $
- */
-
-#include <fenv.h>
-
-/*
- * The FSR_version field may be different on different
- * implementations, but it is immutable and opaque to the
- * application.  Thus, 0 is valid as the default environment.
- */
-const fenv_t __fe_dfl_env = 0;
diff --git a/libm/sparc64/fenv.h b/libm/sparc64/fenv.h
deleted file mode 100644
index 684c4a2..0000000
--- a/libm/sparc64/fenv.h
+++ /dev/null
@@ -1,254 +0,0 @@
-/*-
- * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/sparc64/fenv.h,v 1.3 2005/03/16 19:03:46 das Exp $
- */
-
-#ifndef	_FENV_H_
-#define	_FENV_H_
-
-#include <sys/_types.h>
-
-typedef	__uint64_t	fenv_t;
-typedef	__uint64_t	fexcept_t;
-
-/* Exception flags */
-#define	FE_INVALID	0x00000200
-#define	FE_DIVBYZERO	0x00000040
-#define	FE_OVERFLOW	0x00000100
-#define	FE_UNDERFLOW	0x00000080
-#define	FE_INEXACT	0x00000020
-#define	FE_ALL_EXCEPT	(FE_DIVBYZERO | FE_INEXACT | \
-			 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
-
-/*
- * Rounding modes
- *
- * We can't just use the hardware bit values here, because that would
- * make FE_UPWARD and FE_DOWNWARD negative, which is not allowed.
- */
-#define	FE_TONEAREST	0x0
-#define	FE_TOWARDZERO	0x1
-#define	FE_UPWARD	0x2
-#define	FE_DOWNWARD	0x3
-#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
-			 FE_UPWARD | FE_TOWARDZERO)
-#define	_ROUND_SHIFT	30
-
-__BEGIN_DECLS
-
-/* Default floating-point environment */
-extern const fenv_t	__fe_dfl_env;
-#define	FE_DFL_ENV	(&__fe_dfl_env)
-
-/* We need to be able to map status flag positions to mask flag positions */
-#define _FPUSW_SHIFT	18
-#define	_ENABLE_MASK	(FE_ALL_EXCEPT << _FPUSW_SHIFT)
-
-#define	__ldxfsr(__r)	__asm __volatile("ldx %0, %%fsr" : : "m" (__r))
-#define	__stxfsr(__r)	__asm __volatile("stx %%fsr, %0" : "=m" (*(__r)))
-
-static __inline int
-feclearexcept(int __excepts)
-{
-	fexcept_t __r;
-
-	__stxfsr(&__r);
-	__r &= ~__excepts;
-	__ldxfsr(__r);
-	return (0);
-}
-
-static __inline int
-fegetexceptflag(fexcept_t *__flagp, int __excepts)
-{
-	fexcept_t __r;
-
-	__stxfsr(&__r);
-	*__flagp = __r & __excepts;
-	return (0);
-}
-
-static __inline int
-fesetexceptflag(const fexcept_t *__flagp, int __excepts)
-{
-	fexcept_t __r;
-
-	__stxfsr(&__r);
-	__r &= ~__excepts;
-	__r |= *__flagp & __excepts;
-	__ldxfsr(__r);
-	return (0);
-}
-
-/*
- * In contrast with the ia64 platform, it seems to be worthwhile to
- * inline this function on sparc64 even when the arguments are not
- * compile-time constants.  Perhaps this depends on the register window.
- */
-static __inline int
-feraiseexcept(int __excepts)
-{
-	volatile double d;
-
-	/*
-	 * With a compiler that supports the FENV_ACCESS pragma
-	 * properly, simple expressions like '0.0 / 0.0' should
-	 * be sufficient to generate traps.  Unfortunately, we
-	 * need to bring a volatile variable into the equation
-	 * to prevent incorrect optimizations.
-	 */
-	if (__excepts & FE_INVALID) {
-		d = 0.0;
-		d = 0.0 / d;
-	}
-	if (__excepts & FE_DIVBYZERO) {
-		d = 0.0;
-		d = 1.0 / d;
-	}
-	if (__excepts & FE_OVERFLOW) {
-		d = 0x1.ffp1023;
-		d *= 2.0;
-	}
-	if (__excepts & FE_UNDERFLOW) {
-		d = 0x1p-1022;
-		d /= 0x1p1023;
-	}
-	if (__excepts & FE_INEXACT) {
-		d = 0x1p-1022;
-		d += 1.0;
-	}
-	return (0);
-}
-
-static __inline int
-fetestexcept(int __excepts)
-{
-	fexcept_t __r;
-
-	__stxfsr(&__r);
-	return (__r & __excepts);
-}
-
-static __inline int
-fegetround(void)
-{
-	fenv_t __r;
-
-	__stxfsr(&__r);
-	return ((__r >> _ROUND_SHIFT) & _ROUND_MASK);
-}
-
-static __inline int
-fesetround(int __round)
-{
-	fenv_t __r;
-
-	if (__round & ~_ROUND_MASK)
-		return (-1);
-	__stxfsr(&__r);
-	__r &= ~(_ROUND_MASK << _ROUND_SHIFT);
-	__r |= __round << _ROUND_SHIFT;
-	__ldxfsr(__r);
-	return (0);
-}
-
-static __inline int
-fegetenv(fenv_t *__envp)
-{
-
-	__stxfsr(__envp);
-	return (0);
-}
-
-static __inline int
-feholdexcept(fenv_t *__envp)
-{
-	fenv_t __r;
-
-	__stxfsr(&__r);
-	*__envp = __r;
-	__r &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
-	__ldxfsr(__r);
-	return (0);
-}
-
-static __inline int
-fesetenv(const fenv_t *__envp)
-{
-
-	__ldxfsr(*__envp);
-	return (0);
-}
-
-static __inline int
-feupdateenv(const fenv_t *__envp)
-{
-	fexcept_t __r;
-
-	__stxfsr(&__r);
-	__ldxfsr(*__envp);
-	feraiseexcept(__r & FE_ALL_EXCEPT);
-	return (0);
-}
-
-#if __BSD_VISIBLE
-
-static __inline int
-feenableexcept(int __mask)
-{
-	fenv_t __old_r, __new_r;
-
-	__stxfsr(&__old_r);
-	__new_r = __old_r | ((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
-	__ldxfsr(__new_r);
-	return ((__old_r >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
-}
-
-static __inline int
-fedisableexcept(int __mask)
-{
-	fenv_t __old_r, __new_r;
-
-	__stxfsr(&__old_r);
-	__new_r = __old_r & ~((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
-	__ldxfsr(__new_r);
-	return ((__old_r >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
-}
-
-static __inline int
-fegetexcept(void)
-{
-	fenv_t __r;
-
-	__stxfsr(&__r);
-	return ((__r & _ENABLE_MASK) >> _FPUSW_SHIFT);
-}
-
-#endif /* __BSD_VISIBLE */
-
-__END_DECLS
-
-#endif	/* !_FENV_H_ */
diff --git a/libm/src/e_acos.c b/libm/src/e_acos.c
deleted file mode 100644
index 8ba672a..0000000
--- a/libm/src/e_acos.c
+++ /dev/null
@@ -1,104 +0,0 @@
-
-/* @(#)e_acos.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_acos.c,v 1.10 2005/02/04 18:26:05 das Exp $";
-#endif
-
-/* __ieee754_acos(x)
- * Method :                  
- *	acos(x)  = pi/2 - asin(x)
- *	acos(-x) = pi/2 + asin(x)
- * For |x|<=0.5
- *	acos(x) = pi/2 - (x + x*x^2*R(x^2))	(see asin.c)
- * For x>0.5
- * 	acos(x) = pi/2 - (pi/2 - 2asin(sqrt((1-x)/2)))
- *		= 2asin(sqrt((1-x)/2))  
- *		= 2s + 2s*z*R(z) 	...z=(1-x)/2, s=sqrt(z)
- *		= 2f + (2c + 2s*z*R(z))
- *     where f=hi part of s, and c = (z-f*f)/(s+f) is the correction term
- *     for f so that f+c ~ sqrt(z).
- * For x<-0.5
- *	acos(x) = pi - 2asin(sqrt((1-|x|)/2))
- *		= pi - 0.5*(s+s*z*R(z)), where z=(1-|x|)/2,s=sqrt(z)
- *
- * Special cases:
- *	if x is NaN, return x itself;
- *	if |x|>1, return NaN with invalid signal.
- *
- * Function needed: sqrt
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-one=  1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
-pi =  3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */
-pio2_hi =  1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */
-pio2_lo =  6.12323399573676603587e-17, /* 0x3C91A626, 0x33145C07 */
-pS0 =  1.66666666666666657415e-01, /* 0x3FC55555, 0x55555555 */
-pS1 = -3.25565818622400915405e-01, /* 0xBFD4D612, 0x03EB6F7D */
-pS2 =  2.01212532134862925881e-01, /* 0x3FC9C155, 0x0E884455 */
-pS3 = -4.00555345006794114027e-02, /* 0xBFA48228, 0xB5688F3B */
-pS4 =  7.91534994289814532176e-04, /* 0x3F49EFE0, 0x7501B288 */
-pS5 =  3.47933107596021167570e-05, /* 0x3F023DE1, 0x0DFDF709 */
-qS1 = -2.40339491173441421878e+00, /* 0xC0033A27, 0x1C8A2D4B */
-qS2 =  2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */
-qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */
-qS4 =  7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
-
-double
-__ieee754_acos(double x)
-{
-	double z,p,q,r,w,s,c,df;
-	int32_t hx,ix;
-	GET_HIGH_WORD(hx,x);
-	ix = hx&0x7fffffff;
-	if(ix>=0x3ff00000) {	/* |x| >= 1 */
-	    u_int32_t lx;
-	    GET_LOW_WORD(lx,x);
-	    if(((ix-0x3ff00000)|lx)==0) {	/* |x|==1 */
-		if(hx>0) return 0.0;		/* acos(1) = 0  */
-		else return pi+2.0*pio2_lo;	/* acos(-1)= pi */
-	    }
-	    return (x-x)/(x-x);		/* acos(|x|>1) is NaN */
-	}
-	if(ix<0x3fe00000) {	/* |x| < 0.5 */
-	    if(ix<=0x3c600000) return pio2_hi+pio2_lo;/*if|x|<2**-57*/
-	    z = x*x;
-	    p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
-	    q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
-	    r = p/q;
-	    return pio2_hi - (x - (pio2_lo-x*r));
-	} else  if (hx<0) {		/* x < -0.5 */
-	    z = (one+x)*0.5;
-	    p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
-	    q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
-	    s = sqrt(z);
-	    r = p/q;
-	    w = r*s-pio2_lo;
-	    return pi - 2.0*(s+w);
-	} else {			/* x > 0.5 */
-	    z = (one-x)*0.5;
-	    s = sqrt(z);
-	    df = s;
-	    SET_LOW_WORD(df,0);
-	    c  = (z-df*df)/(s+df);
-	    p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
-	    q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
-	    r = p/q;
-	    w = r*s+c;
-	    return 2.0*(df+w);
-	}
-}
diff --git a/libm/src/e_acosf.c b/libm/src/e_acosf.c
deleted file mode 100644
index a11f48e..0000000
--- a/libm/src/e_acosf.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/* e_acosf.c -- float version of e_acos.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_acosf.c,v 1.7 2002/05/28 17:03:12 alfred Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float
-one =  1.0000000000e+00, /* 0x3F800000 */
-pi =  3.1415925026e+00, /* 0x40490fda */
-pio2_hi =  1.5707962513e+00, /* 0x3fc90fda */
-pio2_lo =  7.5497894159e-08, /* 0x33a22168 */
-pS0 =  1.6666667163e-01, /* 0x3e2aaaab */
-pS1 = -3.2556581497e-01, /* 0xbea6b090 */
-pS2 =  2.0121252537e-01, /* 0x3e4e0aa8 */
-pS3 = -4.0055535734e-02, /* 0xbd241146 */
-pS4 =  7.9153501429e-04, /* 0x3a4f7f04 */
-pS5 =  3.4793309169e-05, /* 0x3811ef08 */
-qS1 = -2.4033949375e+00, /* 0xc019d139 */
-qS2 =  2.0209457874e+00, /* 0x4001572d */
-qS3 = -6.8828397989e-01, /* 0xbf303361 */
-qS4 =  7.7038154006e-02; /* 0x3d9dc62e */
-
-float
-__ieee754_acosf(float x)
-{
-	float z,p,q,r,w,s,c,df;
-	int32_t hx,ix;
-	GET_FLOAT_WORD(hx,x);
-	ix = hx&0x7fffffff;
-	if(ix==0x3f800000) {		/* |x|==1 */
-	    if(hx>0) return 0.0;	/* acos(1) = 0  */
-	    else return pi+(float)2.0*pio2_lo;	/* acos(-1)= pi */
-	} else if(ix>0x3f800000) {	/* |x| >= 1 */
-	    return (x-x)/(x-x);		/* acos(|x|>1) is NaN */
-	}
-	if(ix<0x3f000000) {	/* |x| < 0.5 */
-	    if(ix<=0x23000000) return pio2_hi+pio2_lo;/*if|x|<2**-57*/
-	    z = x*x;
-	    p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
-	    q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
-	    r = p/q;
-	    return pio2_hi - (x - (pio2_lo-x*r));
-	} else  if (hx<0) {		/* x < -0.5 */
-	    z = (one+x)*(float)0.5;
-	    p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
-	    q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
-	    s = __ieee754_sqrtf(z);
-	    r = p/q;
-	    w = r*s-pio2_lo;
-	    return pi - (float)2.0*(s+w);
-	} else {			/* x > 0.5 */
-	    int32_t idf;
-	    z = (one-x)*(float)0.5;
-	    s = __ieee754_sqrtf(z);
-	    df = s;
-	    GET_FLOAT_WORD(idf,df);
-	    SET_FLOAT_WORD(df,idf&0xfffff000);
-	    c  = (z-df*df)/(s+df);
-	    p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
-	    q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
-	    r = p/q;
-	    w = r*s+c;
-	    return (float)2.0*(df+w);
-	}
-}
diff --git a/libm/src/e_acosh.c b/libm/src/e_acosh.c
deleted file mode 100644
index ccb1521..0000000
--- a/libm/src/e_acosh.c
+++ /dev/null
@@ -1,63 +0,0 @@
-
-/* @(#)e_acosh.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- *
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_acosh.c,v 1.8 2005/02/04 18:26:05 das Exp $";
-#endif
-
-/* __ieee754_acosh(x)
- * Method :
- *	Based on 
- *		acosh(x) = log [ x + sqrt(x*x-1) ]
- *	we have
- *		acosh(x) := log(x)+ln2,	if x is large; else
- *		acosh(x) := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else
- *		acosh(x) := log1p(t+sqrt(2.0*t+t*t)); where t=x-1.
- *
- * Special cases:
- *	acosh(x) is NaN with signal if x<1.
- *	acosh(NaN) is NaN without signal.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-one	= 1.0,
-ln2	= 6.93147180559945286227e-01;  /* 0x3FE62E42, 0xFEFA39EF */
-
-double
-__ieee754_acosh(double x)
-{
-	double t;
-	int32_t hx;
-	u_int32_t lx;
-	EXTRACT_WORDS(hx,lx,x);
-	if(hx<0x3ff00000) {		/* x < 1 */
-	    return (x-x)/(x-x);
-	} else if(hx >=0x41b00000) {	/* x > 2**28 */
-	    if(hx >=0x7ff00000) {	/* x is inf of NaN */
-	        return x+x;
-	    } else 
-		return __ieee754_log(x)+ln2;	/* acosh(huge)=log(2x) */
-	} else if(((hx-0x3ff00000)|lx)==0) {
-	    return 0.0;			/* acosh(1) = 0 */
-	} else if (hx > 0x40000000) {	/* 2**28 > x > 2 */
-	    t=x*x;
-	    return __ieee754_log(2.0*x-one/(x+sqrt(t-one)));
-	} else {			/* 1<x<2 */
-	    t = x-one;
-	    return log1p(t+sqrt(2.0*t+t*t));
-	}
-}
diff --git a/libm/src/e_acoshf.c b/libm/src/e_acoshf.c
deleted file mode 100644
index 5257914..0000000
--- a/libm/src/e_acoshf.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* e_acoshf.c -- float version of e_acosh.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_acoshf.c,v 1.7 2002/05/28 17:03:12 alfred Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float
-one	= 1.0,
-ln2	= 6.9314718246e-01;  /* 0x3f317218 */
-
-float
-__ieee754_acoshf(float x)
-{
-	float t;
-	int32_t hx;
-	GET_FLOAT_WORD(hx,x);
-	if(hx<0x3f800000) {		/* x < 1 */
-	    return (x-x)/(x-x);
-	} else if(hx >=0x4d800000) {	/* x > 2**28 */
-	    if(hx >=0x7f800000) {	/* x is inf of NaN */
-	        return x+x;
-	    } else
-		return __ieee754_logf(x)+ln2;	/* acosh(huge)=log(2x) */
-	} else if (hx==0x3f800000) {
-	    return 0.0;			/* acosh(1) = 0 */
-	} else if (hx > 0x40000000) {	/* 2**28 > x > 2 */
-	    t=x*x;
-	    return __ieee754_logf((float)2.0*x-one/(x+__ieee754_sqrtf(t-one)));
-	} else {			/* 1<x<2 */
-	    t = x-one;
-	    return log1pf(t+__ieee754_sqrtf((float)2.0*t+t*t));
-	}
-}
diff --git a/libm/src/e_asin.c b/libm/src/e_asin.c
deleted file mode 100644
index 1ba7026..0000000
--- a/libm/src/e_asin.c
+++ /dev/null
@@ -1,113 +0,0 @@
-
-/* @(#)e_asin.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_asin.c,v 1.11 2005/02/04 18:26:05 das Exp $";
-#endif
-
-/* __ieee754_asin(x)
- * Method :                  
- *	Since  asin(x) = x + x^3/6 + x^5*3/40 + x^7*15/336 + ...
- *	we approximate asin(x) on [0,0.5] by
- *		asin(x) = x + x*x^2*R(x^2)
- *	where
- *		R(x^2) is a rational approximation of (asin(x)-x)/x^3 
- *	and its remez error is bounded by
- *		|(asin(x)-x)/x^3 - R(x^2)| < 2^(-58.75)
- *
- *	For x in [0.5,1]
- *		asin(x) = pi/2-2*asin(sqrt((1-x)/2))
- *	Let y = (1-x), z = y/2, s := sqrt(z), and pio2_hi+pio2_lo=pi/2;
- *	then for x>0.98
- *		asin(x) = pi/2 - 2*(s+s*z*R(z))
- *			= pio2_hi - (2*(s+s*z*R(z)) - pio2_lo)
- *	For x<=0.98, let pio4_hi = pio2_hi/2, then
- *		f = hi part of s;
- *		c = sqrt(z) - f = (z-f*f)/(s+f) 	...f+c=sqrt(z)
- *	and
- *		asin(x) = pi/2 - 2*(s+s*z*R(z))
- *			= pio4_hi+(pio4-2s)-(2s*z*R(z)-pio2_lo)
- *			= pio4_hi+(pio4-2f)-(2s*z*R(z)-(pio2_lo+2c))
- *
- * Special cases:
- *	if x is NaN, return x itself;
- *	if |x|>1, return NaN with invalid signal.
- *
- */
-
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-one =  1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
-huge =  1.000e+300,
-pio2_hi =  1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */
-pio2_lo =  6.12323399573676603587e-17, /* 0x3C91A626, 0x33145C07 */
-pio4_hi =  7.85398163397448278999e-01, /* 0x3FE921FB, 0x54442D18 */
-	/* coefficient for R(x^2) */
-pS0 =  1.66666666666666657415e-01, /* 0x3FC55555, 0x55555555 */
-pS1 = -3.25565818622400915405e-01, /* 0xBFD4D612, 0x03EB6F7D */
-pS2 =  2.01212532134862925881e-01, /* 0x3FC9C155, 0x0E884455 */
-pS3 = -4.00555345006794114027e-02, /* 0xBFA48228, 0xB5688F3B */
-pS4 =  7.91534994289814532176e-04, /* 0x3F49EFE0, 0x7501B288 */
-pS5 =  3.47933107596021167570e-05, /* 0x3F023DE1, 0x0DFDF709 */
-qS1 = -2.40339491173441421878e+00, /* 0xC0033A27, 0x1C8A2D4B */
-qS2 =  2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */
-qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */
-qS4 =  7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
-
-double
-__ieee754_asin(double x)
-{
-	double t=0.0,w,p,q,c,r,s;
-	int32_t hx,ix;
-	GET_HIGH_WORD(hx,x);
-	ix = hx&0x7fffffff;
-	if(ix>= 0x3ff00000) {		/* |x|>= 1 */
-	    u_int32_t lx;
-	    GET_LOW_WORD(lx,x);
-	    if(((ix-0x3ff00000)|lx)==0)
-		    /* asin(1)=+-pi/2 with inexact */
-		return x*pio2_hi+x*pio2_lo;	
-	    return (x-x)/(x-x);		/* asin(|x|>1) is NaN */   
-	} else if (ix<0x3fe00000) {	/* |x|<0.5 */
-	    if(ix<0x3e400000) {		/* if |x| < 2**-27 */
-		if(huge+x>one) return x;/* return x with inexact if x!=0*/
-	    } else 
-		t = x*x;
-		p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
-		q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
-		w = p/q;
-		return x+x*w;
-	}
-	/* 1> |x|>= 0.5 */
-	w = one-fabs(x);
-	t = w*0.5;
-	p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
-	q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
-	s = sqrt(t);
-	if(ix>=0x3FEF3333) { 	/* if |x| > 0.975 */
-	    w = p/q;
-	    t = pio2_hi-(2.0*(s+s*w)-pio2_lo);
-	} else {
-	    w  = s;
-	    SET_LOW_WORD(w,0);
-	    c  = (t-w*w)/(s+w);
-	    r  = p/q;
-	    p  = 2.0*s*r-(pio2_lo-2.0*c);
-	    q  = pio4_hi-2.0*w;
-	    t  = pio4_hi-(p-q);
-	}    
-	if(hx>0) return t; else return -t;    
-}
diff --git a/libm/src/e_asinf.c b/libm/src/e_asinf.c
deleted file mode 100644
index 1405faf..0000000
--- a/libm/src/e_asinf.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* e_asinf.c -- float version of e_asin.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_asinf.c,v 1.9 2005/12/04 13:52:46 bde Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float
-one =  1.0000000000e+00, /* 0x3F800000 */
-huge =  1.000e+30,
-pio2_hi =  1.5707962513e+00, /* 0x3fc90fda */
-pio2_lo =  7.5497894159e-08, /* 0x33a22168 */
-pio4_hi =  7.8539812565e-01, /* 0x3f490fda */
-	/* coefficient for R(x^2) */
-pS0 =  1.6666667163e-01, /* 0x3e2aaaab */
-pS1 = -3.2556581497e-01, /* 0xbea6b090 */
-pS2 =  2.0121252537e-01, /* 0x3e4e0aa8 */
-pS3 = -4.0055535734e-02, /* 0xbd241146 */
-pS4 =  7.9153501429e-04, /* 0x3a4f7f04 */
-pS5 =  3.4793309169e-05, /* 0x3811ef08 */
-qS1 = -2.4033949375e+00, /* 0xc019d139 */
-qS2 =  2.0209457874e+00, /* 0x4001572d */
-qS3 = -6.8828397989e-01, /* 0xbf303361 */
-qS4 =  7.7038154006e-02; /* 0x3d9dc62e */
-
-float
-__ieee754_asinf(float x)
-{
-	float t=0.0,w,p,q,c,r,s;
-	int32_t hx,ix;
-	GET_FLOAT_WORD(hx,x);
-	ix = hx&0x7fffffff;
-	if(ix==0x3f800000) {
-		/* asin(1)=+-pi/2 with inexact */
-	    return x*pio2_hi+x*pio2_lo;
-	} else if(ix> 0x3f800000) {	/* |x|>= 1 */
-	    return (x-x)/(x-x);		/* asin(|x|>1) is NaN */
-	} else if (ix<0x3f000000) {	/* |x|<0.5 */
-	    if(ix<0x32000000) {		/* if |x| < 2**-27 */
-		if(huge+x>one) return x;/* return x with inexact if x!=0*/
-	    } else
-		t = x*x;
-		p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
-		q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
-		w = p/q;
-		return x+x*w;
-	}
-	/* 1> |x|>= 0.5 */
-	w = one-fabsf(x);
-	t = w*(float)0.5;
-	p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
-	q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
-	s = __ieee754_sqrtf(t);
-	if(ix>=0x3F79999A) { 	/* if |x| > 0.975 */
-	    w = p/q;
-	    t = pio2_hi-((float)2.0*(s+s*w)-pio2_lo);
-	} else {
-	    int32_t iw;
-	    w  = s;
-	    GET_FLOAT_WORD(iw,w);
-	    SET_FLOAT_WORD(w,iw&0xfffff000);
-	    c  = (t-w*w)/(s+w);
-	    r  = p/q;
-	    p  = (float)2.0*s*r-(pio2_lo-(float)2.0*c);
-	    q  = pio4_hi-(float)2.0*w;
-	    t  = pio4_hi-(p-q);
-	}
-	if(hx>0) return t; else return -t;
-}
diff --git a/libm/src/e_atan2.c b/libm/src/e_atan2.c
deleted file mode 100644
index 56c05a5..0000000
--- a/libm/src/e_atan2.c
+++ /dev/null
@@ -1,124 +0,0 @@
-
-/* @(#)e_atan2.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- *
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_atan2.c,v 1.10 2005/02/04 18:26:05 das Exp $";
-#endif
-
-/* __ieee754_atan2(y,x)
- * Method :
- *	1. Reduce y to positive by atan2(y,x)=-atan2(-y,x).
- *	2. Reduce x to positive by (if x and y are unexceptional): 
- *		ARG (x+iy) = arctan(y/x)   	   ... if x > 0,
- *		ARG (x+iy) = pi - arctan[y/(-x)]   ... if x < 0,
- *
- * Special cases:
- *
- *	ATAN2((anything), NaN ) is NaN;
- *	ATAN2(NAN , (anything) ) is NaN;
- *	ATAN2(+-0, +(anything but NaN)) is +-0  ;
- *	ATAN2(+-0, -(anything but NaN)) is +-pi ;
- *	ATAN2(+-(anything but 0 and NaN), 0) is +-pi/2;
- *	ATAN2(+-(anything but INF and NaN), +INF) is +-0 ;
- *	ATAN2(+-(anything but INF and NaN), -INF) is +-pi;
- *	ATAN2(+-INF,+INF ) is +-pi/4 ;
- *	ATAN2(+-INF,-INF ) is +-3pi/4;
- *	ATAN2(+-INF, (anything but,0,NaN, and INF)) is +-pi/2;
- *
- * Constants:
- * The hexadecimal values are the intended ones for the following 
- * constants. The decimal values may be used, provided that the 
- * compiler will convert from decimal to binary accurately enough 
- * to produce the hexadecimal values shown.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-tiny  = 1.0e-300,
-zero  = 0.0,
-pi_o_4  = 7.8539816339744827900E-01, /* 0x3FE921FB, 0x54442D18 */
-pi_o_2  = 1.5707963267948965580E+00, /* 0x3FF921FB, 0x54442D18 */
-pi      = 3.1415926535897931160E+00, /* 0x400921FB, 0x54442D18 */
-pi_lo   = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */
-
-double
-__ieee754_atan2(double y, double x)
-{
-	double z;
-	int32_t k,m,hx,hy,ix,iy;
-	u_int32_t lx,ly;
-
-	EXTRACT_WORDS(hx,lx,x);
-	ix = hx&0x7fffffff;
-	EXTRACT_WORDS(hy,ly,y);
-	iy = hy&0x7fffffff;
-	if(((ix|((lx|-lx)>>31))>0x7ff00000)||
-	   ((iy|((ly|-ly)>>31))>0x7ff00000))	/* x or y is NaN */
-	   return x+y;
-	if(((hx-0x3ff00000) | lx)==0) return atan(y);   /* x=1.0 */
-	m = ((hy>>31)&1)|((hx>>30)&2);	/* 2*sign(x)+sign(y) */
-
-    /* when y = 0 */
-	if((iy|ly)==0) {
-	    switch(m) {
-		case 0: 
-		case 1: return y; 	/* atan(+-0,+anything)=+-0 */
-		case 2: return  pi+tiny;/* atan(+0,-anything) = pi */
-		case 3: return -pi-tiny;/* atan(-0,-anything) =-pi */
-	    }
-	}
-    /* when x = 0 */
-	if((ix|lx)==0) return (hy<0)?  -pi_o_2-tiny: pi_o_2+tiny;
-	    
-    /* when x is INF */
-	if(ix==0x7ff00000) {
-	    if(iy==0x7ff00000) {
-		switch(m) {
-		    case 0: return  pi_o_4+tiny;/* atan(+INF,+INF) */
-		    case 1: return -pi_o_4-tiny;/* atan(-INF,+INF) */
-		    case 2: return  3.0*pi_o_4+tiny;/*atan(+INF,-INF)*/
-		    case 3: return -3.0*pi_o_4-tiny;/*atan(-INF,-INF)*/
-		}
-	    } else {
-		switch(m) {
-		    case 0: return  zero  ;	/* atan(+...,+INF) */
-		    case 1: return -zero  ;	/* atan(-...,+INF) */
-		    case 2: return  pi+tiny  ;	/* atan(+...,-INF) */
-		    case 3: return -pi-tiny  ;	/* atan(-...,-INF) */
-		}
-	    }
-	}
-    /* when y is INF */
-	if(iy==0x7ff00000) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny;
-
-    /* compute y/x */
-	k = (iy-ix)>>20;
-	if(k > 60) z=pi_o_2+0.5*pi_lo; 	/* |y/x| >  2**60 */
-	else if(hx<0&&k<-60) z=0.0; 	/* |y|/x < -2**60 */
-	else z=atan(fabs(y/x));		/* safe to do y/x */
-	switch (m) {
-	    case 0: return       z  ;	/* atan(+,+) */
-	    case 1: {
-	    	      u_int32_t zh;
-		      GET_HIGH_WORD(zh,z);
-		      SET_HIGH_WORD(z,zh ^ 0x80000000);
-		    }
-		    return       z  ;	/* atan(-,+) */
-	    case 2: return  pi-(z-pi_lo);/* atan(+,-) */
-	    default: /* case 3 */
-	    	    return  (z-pi_lo)-pi;/* atan(-,-) */
-	}
-}
diff --git a/libm/src/e_atan2f.c b/libm/src/e_atan2f.c
deleted file mode 100644
index 466d5d4..0000000
--- a/libm/src/e_atan2f.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* e_atan2f.c -- float version of e_atan2.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_atan2f.c,v 1.7 2004/06/02 17:09:05 bde Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float
-tiny  = 1.0e-30,
-zero  = 0.0,
-pi_o_4  = 7.8539818525e-01, /* 0x3f490fdb */
-pi_o_2  = 1.5707963705e+00, /* 0x3fc90fdb */
-pi      = 3.1415927410e+00, /* 0x40490fdb */
-pi_lo   = -8.7422776573e-08; /* 0xb3bbbd2e */
-
-float
-__ieee754_atan2f(float y, float x)
-{
-	float z;
-	int32_t k,m,hx,hy,ix,iy;
-
-	GET_FLOAT_WORD(hx,x);
-	ix = hx&0x7fffffff;
-	GET_FLOAT_WORD(hy,y);
-	iy = hy&0x7fffffff;
-	if((ix>0x7f800000)||
-	   (iy>0x7f800000))	/* x or y is NaN */
-	   return x+y;
-	if(hx==0x3f800000) return atanf(y);   /* x=1.0 */
-	m = ((hy>>31)&1)|((hx>>30)&2);	/* 2*sign(x)+sign(y) */
-
-    /* when y = 0 */
-	if(iy==0) {
-	    switch(m) {
-		case 0:
-		case 1: return y; 	/* atan(+-0,+anything)=+-0 */
-		case 2: return  pi+tiny;/* atan(+0,-anything) = pi */
-		case 3: return -pi-tiny;/* atan(-0,-anything) =-pi */
-	    }
-	}
-    /* when x = 0 */
-	if(ix==0) return (hy<0)?  -pi_o_2-tiny: pi_o_2+tiny;
-
-    /* when x is INF */
-	if(ix==0x7f800000) {
-	    if(iy==0x7f800000) {
-		switch(m) {
-		    case 0: return  pi_o_4+tiny;/* atan(+INF,+INF) */
-		    case 1: return -pi_o_4-tiny;/* atan(-INF,+INF) */
-		    case 2: return  (float)3.0*pi_o_4+tiny;/*atan(+INF,-INF)*/
-		    case 3: return (float)-3.0*pi_o_4-tiny;/*atan(-INF,-INF)*/
-		}
-	    } else {
-		switch(m) {
-		    case 0: return  zero  ;	/* atan(+...,+INF) */
-		    case 1: return -zero  ;	/* atan(-...,+INF) */
-		    case 2: return  pi+tiny  ;	/* atan(+...,-INF) */
-		    case 3: return -pi-tiny  ;	/* atan(-...,-INF) */
-		}
-	    }
-	}
-    /* when y is INF */
-	if(iy==0x7f800000) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny;
-
-    /* compute y/x */
-	k = (iy-ix)>>23;
-	if(k > 60) z=pi_o_2+(float)0.5*pi_lo; 	/* |y/x| >  2**60 */
-	else if(hx<0&&k<-60) z=0.0; 	/* |y|/x < -2**60 */
-	else z=atanf(fabsf(y/x));	/* safe to do y/x */
-	switch (m) {
-	    case 0: return       z  ;	/* atan(+,+) */
-	    case 1: {
-	    	      u_int32_t zh;
-		      GET_FLOAT_WORD(zh,z);
-		      SET_FLOAT_WORD(z,zh ^ 0x80000000);
-		    }
-		    return       z  ;	/* atan(-,+) */
-	    case 2: return  pi-(z-pi_lo);/* atan(+,-) */
-	    default: /* case 3 */
-	    	    return  (z-pi_lo)-pi;/* atan(-,-) */
-	}
-}
diff --git a/libm/src/e_atanh.c b/libm/src/e_atanh.c
deleted file mode 100644
index 604875c..0000000
--- a/libm/src/e_atanh.c
+++ /dev/null
@@ -1,63 +0,0 @@
-
-/* @(#)e_atanh.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- *
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_atanh.c,v 1.7 2005/02/04 18:26:05 das Exp $";
-#endif
-
-/* __ieee754_atanh(x)
- * Method :
- *    1.Reduced x to positive by atanh(-x) = -atanh(x)
- *    2.For x>=0.5
- *                  1              2x                          x
- *	atanh(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------)
- *                  2             1 - x                      1 - x
- *	
- * 	For x<0.5
- *	atanh(x) = 0.5*log1p(2x+2x*x/(1-x))
- *
- * Special cases:
- *	atanh(x) is NaN if |x| > 1 with signal;
- *	atanh(NaN) is that NaN with no signal;
- *	atanh(+-1) is +-INF with signal.
- *
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double one = 1.0, huge = 1e300;
-static const double zero = 0.0;
-
-double
-__ieee754_atanh(double x)
-{
-	double t;
-	int32_t hx,ix;
-	u_int32_t lx;
-	EXTRACT_WORDS(hx,lx,x);
-	ix = hx&0x7fffffff;
-	if ((ix|((lx|(-lx))>>31))>0x3ff00000) /* |x|>1 */
-	    return (x-x)/(x-x);
-	if(ix==0x3ff00000) 
-	    return x/zero;
-	if(ix<0x3e300000&&(huge+x)>zero) return x;	/* x<2**-28 */
-	SET_HIGH_WORD(x,ix);
-	if(ix<0x3fe00000) {		/* x < 0.5 */
-	    t = x+x;
-	    t = 0.5*log1p(t+t*x/(one-x));
-	} else 
-	    t = 0.5*log1p((x+x)/(one-x));
-	if(hx>=0) return t; else return -t;
-}
diff --git a/libm/src/e_atanhf.c b/libm/src/e_atanhf.c
deleted file mode 100644
index 64ebd3d..0000000
--- a/libm/src/e_atanhf.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* e_atanhf.c -- float version of e_atanh.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_atanhf.c,v 1.6 2002/05/28 17:03:12 alfred Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float one = 1.0, huge = 1e30;
-
-static const float zero = 0.0;
-
-float
-__ieee754_atanhf(float x)
-{
-	float t;
-	int32_t hx,ix;
-	GET_FLOAT_WORD(hx,x);
-	ix = hx&0x7fffffff;
-	if (ix>0x3f800000) 		/* |x|>1 */
-	    return (x-x)/(x-x);
-	if(ix==0x3f800000)
-	    return x/zero;
-	if(ix<0x31800000&&(huge+x)>zero) return x;	/* x<2**-28 */
-	SET_FLOAT_WORD(x,ix);
-	if(ix<0x3f000000) {		/* x < 0.5 */
-	    t = x+x;
-	    t = (float)0.5*log1pf(t+t*x/(one-x));
-	} else
-	    t = (float)0.5*log1pf((x+x)/(one-x));
-	if(hx>=0) return t; else return -t;
-}
diff --git a/libm/src/e_cosh.c b/libm/src/e_cosh.c
deleted file mode 100644
index 40a943a..0000000
--- a/libm/src/e_cosh.c
+++ /dev/null
@@ -1,86 +0,0 @@
-
-/* @(#)e_cosh.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_cosh.c,v 1.8 2005/02/04 18:26:05 das Exp $";
-#endif
-
-/* __ieee754_cosh(x)
- * Method : 
- * mathematically cosh(x) if defined to be (exp(x)+exp(-x))/2
- *	1. Replace x by |x| (cosh(x) = cosh(-x)). 
- *	2. 
- *		                                        [ exp(x) - 1 ]^2 
- *	    0        <= x <= ln2/2  :  cosh(x) := 1 + -------------------
- *			       			           2*exp(x)
- *
- *		                                  exp(x) +  1/exp(x)
- *	    ln2/2    <= x <= 22     :  cosh(x) := -------------------
- *			       			          2
- *	    22       <= x <= lnovft :  cosh(x) := exp(x)/2 
- *	    lnovft   <= x <= ln2ovft:  cosh(x) := exp(x/2)/2 * exp(x/2)
- *	    ln2ovft  <  x	    :  cosh(x) := huge*huge (overflow)
- *
- * Special cases:
- *	cosh(x) is |x| if x is +INF, -INF, or NaN.
- *	only cosh(0)=1 is exact for finite x.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double one = 1.0, half=0.5, huge = 1.0e300;
-
-double
-__ieee754_cosh(double x)
-{
-	double t,w;
-	int32_t ix;
-	u_int32_t lx;
-
-    /* High word of |x|. */
-	GET_HIGH_WORD(ix,x);
-	ix &= 0x7fffffff;
-
-    /* x is INF or NaN */
-	if(ix>=0x7ff00000) return x*x;	
-
-    /* |x| in [0,0.5*ln2], return 1+expm1(|x|)^2/(2*exp(|x|)) */
-	if(ix<0x3fd62e43) {
-	    t = expm1(fabs(x));
-	    w = one+t;
-	    if (ix<0x3c800000) return w;	/* cosh(tiny) = 1 */
-	    return one+(t*t)/(w+w);
-	}
-
-    /* |x| in [0.5*ln2,22], return (exp(|x|)+1/exp(|x|)/2; */
-	if (ix < 0x40360000) {
-		t = __ieee754_exp(fabs(x));
-		return half*t+half/t;
-	}
-
-    /* |x| in [22, log(maxdouble)] return half*exp(|x|) */
-	if (ix < 0x40862E42)  return half*__ieee754_exp(fabs(x));
-
-    /* |x| in [log(maxdouble), overflowthresold] */
-	GET_LOW_WORD(lx,x);
-	if (ix<0x408633CE ||
-	      ((ix==0x408633ce)&&(lx<=(u_int32_t)0x8fb9f87d))) {
-	    w = __ieee754_exp(half*fabs(x));
-	    t = half*w;
-	    return t*w;
-	}
-
-    /* |x| > overflowthresold, cosh(x) overflow */
-	return huge*huge;
-}
diff --git a/libm/src/e_coshf.c b/libm/src/e_coshf.c
deleted file mode 100644
index f9df9b0..0000000
--- a/libm/src/e_coshf.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/* e_coshf.c -- float version of e_cosh.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_coshf.c,v 1.7 2005/11/13 00:08:23 bde Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float one = 1.0, half=0.5, huge = 1.0e30;
-
-float
-__ieee754_coshf(float x)
-{
-	float t,w;
-	int32_t ix;
-
-	GET_FLOAT_WORD(ix,x);
-	ix &= 0x7fffffff;
-
-    /* x is INF or NaN */
-	if(ix>=0x7f800000) return x*x;
-
-    /* |x| in [0,0.5*ln2], return 1+expm1(|x|)^2/(2*exp(|x|)) */
-	if(ix<0x3eb17218) {
-	    t = expm1f(fabsf(x));
-	    w = one+t;
-	    if (ix<0x39800000) return one;	/* cosh(tiny) = 1 */
-	    return one+(t*t)/(w+w);
-	}
-
-    /* |x| in [0.5*ln2,9], return (exp(|x|)+1/exp(|x|))/2; */
-	if (ix < 0x41100000) {
-		t = __ieee754_expf(fabsf(x));
-		return half*t+half/t;
-	}
-
-    /* |x| in [9, log(maxfloat)] return half*exp(|x|) */
-	if (ix < 0x42b17217)  return half*__ieee754_expf(fabsf(x));
-
-    /* |x| in [log(maxfloat), overflowthresold] */
-	if (ix<=0x42b2d4fc) {
-	    w = __ieee754_expf(half*fabsf(x));
-	    t = half*w;
-	    return t*w;
-	}
-
-    /* |x| > overflowthresold, cosh(x) overflow */
-	return huge*huge;
-}
diff --git a/libm/src/e_exp.c b/libm/src/e_exp.c
deleted file mode 100644
index e261895..0000000
--- a/libm/src/e_exp.c
+++ /dev/null
@@ -1,159 +0,0 @@
-
-/* @(#)e_exp.c 1.6 04/04/22 */
-/*
- * ====================================================
- * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_exp.c,v 1.10 2005/02/04 18:26:05 das Exp $";
-#endif
-
-/* __ieee754_exp(x)
- * Returns the exponential of x.
- *
- * Method
- *   1. Argument reduction:
- *      Reduce x to an r so that |r| <= 0.5*ln2 ~ 0.34658.
- *	Given x, find r and integer k such that
- *
- *               x = k*ln2 + r,  |r| <= 0.5*ln2.  
- *
- *      Here r will be represented as r = hi-lo for better 
- *	accuracy.
- *
- *   2. Approximation of exp(r) by a special rational function on
- *	the interval [0,0.34658]:
- *	Write
- *	    R(r**2) = r*(exp(r)+1)/(exp(r)-1) = 2 + r*r/6 - r**4/360 + ...
- *      We use a special Remes algorithm on [0,0.34658] to generate 
- * 	a polynomial of degree 5 to approximate R. The maximum error 
- *	of this polynomial approximation is bounded by 2**-59. In
- *	other words,
- *	    R(z) ~ 2.0 + P1*z + P2*z**2 + P3*z**3 + P4*z**4 + P5*z**5
- *  	(where z=r*r, and the values of P1 to P5 are listed below)
- *	and
- *	    |                  5          |     -59
- *	    | 2.0+P1*z+...+P5*z   -  R(z) | <= 2 
- *	    |                             |
- *	The computation of exp(r) thus becomes
- *                             2*r
- *		exp(r) = 1 + -------
- *		              R - r
- *                                 r*R1(r)	
- *		       = 1 + r + ----------- (for better accuracy)
- *		                  2 - R1(r)
- *	where
- *			         2       4             10
- *		R1(r) = r - (P1*r  + P2*r  + ... + P5*r   ).
- *	
- *   3. Scale back to obtain exp(x):
- *	From step 1, we have
- *	   exp(x) = 2^k * exp(r)
- *
- * Special cases:
- *	exp(INF) is INF, exp(NaN) is NaN;
- *	exp(-INF) is 0, and
- *	for finite argument, only exp(0)=1 is exact.
- *
- * Accuracy:
- *	according to an error analysis, the error is always less than
- *	1 ulp (unit in the last place).
- *
- * Misc. info.
- *	For IEEE double 
- *	    if x >  7.09782712893383973096e+02 then exp(x) overflow
- *	    if x < -7.45133219101941108420e+02 then exp(x) underflow
- *
- * Constants:
- * The hexadecimal values are the intended ones for the following 
- * constants. The decimal values may be used, provided that the 
- * compiler will convert from decimal to binary accurately enough
- * to produce the hexadecimal values shown.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-one	= 1.0,
-halF[2]	= {0.5,-0.5,},
-huge	= 1.0e+300,
-twom1000= 9.33263618503218878990e-302,     /* 2**-1000=0x01700000,0*/
-o_threshold=  7.09782712893383973096e+02,  /* 0x40862E42, 0xFEFA39EF */
-u_threshold= -7.45133219101941108420e+02,  /* 0xc0874910, 0xD52D3051 */
-ln2HI[2]   ={ 6.93147180369123816490e-01,  /* 0x3fe62e42, 0xfee00000 */
-	     -6.93147180369123816490e-01,},/* 0xbfe62e42, 0xfee00000 */
-ln2LO[2]   ={ 1.90821492927058770002e-10,  /* 0x3dea39ef, 0x35793c76 */
-	     -1.90821492927058770002e-10,},/* 0xbdea39ef, 0x35793c76 */
-invln2 =  1.44269504088896338700e+00, /* 0x3ff71547, 0x652b82fe */
-P1   =  1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */
-P2   = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */
-P3   =  6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
-P4   = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
-P5   =  4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
-
-
-double
-__ieee754_exp(double x)	/* default IEEE double exp */
-{
-	double y,hi=0.0,lo=0.0,c,t;
-	int32_t k=0,xsb;
-	u_int32_t hx;
-
-	GET_HIGH_WORD(hx,x);
-	xsb = (hx>>31)&1;		/* sign bit of x */
-	hx &= 0x7fffffff;		/* high word of |x| */
-
-    /* filter out non-finite argument */
-	if(hx >= 0x40862E42) {			/* if |x|>=709.78... */
-            if(hx>=0x7ff00000) {
-	        u_int32_t lx;
-		GET_LOW_WORD(lx,x);
-		if(((hx&0xfffff)|lx)!=0)
-		     return x+x; 		/* NaN */
-		else return (xsb==0)? x:0.0;	/* exp(+-inf)={inf,0} */
-	    }
-	    if(x > o_threshold) return huge*huge; /* overflow */
-	    if(x < u_threshold) return twom1000*twom1000; /* underflow */
-	}
-
-    /* argument reduction */
-	if(hx > 0x3fd62e42) {		/* if  |x| > 0.5 ln2 */ 
-	    if(hx < 0x3FF0A2B2) {	/* and |x| < 1.5 ln2 */
-		hi = x-ln2HI[xsb]; lo=ln2LO[xsb]; k = 1-xsb-xsb;
-	    } else {
-		k  = (int)(invln2*x+halF[xsb]);
-		t  = k;
-		hi = x - t*ln2HI[0];	/* t*ln2HI is exact here */
-		lo = t*ln2LO[0];
-	    }
-	    x  = hi - lo;
-	} 
-	else if(hx < 0x3e300000)  {	/* when |x|<2**-28 */
-	    if(huge+x>one) return one+x;/* trigger inexact */
-	}
-	else k = 0;
-
-    /* x is now in primary range */
-	t  = x*x;
-	c  = x - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
-	if(k==0) 	return one-((x*c)/(c-2.0)-x); 
-	else 		y = one-((lo-(x*c)/(2.0-c))-hi);
-	if(k >= -1021) {
-	    u_int32_t hy;
-	    GET_HIGH_WORD(hy,y);
-	    SET_HIGH_WORD(y,hy+(k<<20));	/* add k to y's exponent */
-	    return y;
-	} else {
-	    u_int32_t hy;
-	    GET_HIGH_WORD(hy,y);
-	    SET_HIGH_WORD(y,hy+((k+1000)<<20));	/* add k to y's exponent */
-	    return y*twom1000;
-	}
-}
diff --git a/libm/src/e_expf.c b/libm/src/e_expf.c
deleted file mode 100644
index 4e06556..0000000
--- a/libm/src/e_expf.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/* e_expf.c -- float version of e_exp.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_expf.c,v 1.10 2005/11/30 04:56:49 bde Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float
-one	= 1.0,
-halF[2]	= {0.5,-0.5,},
-huge	= 1.0e+30,
-twom100 = 7.8886090522e-31,      /* 2**-100=0x0d800000 */
-o_threshold=  8.8721679688e+01,  /* 0x42b17180 */
-u_threshold= -1.0397208405e+02,  /* 0xc2cff1b5 */
-ln2HI[2]   ={ 6.9314575195e-01,		/* 0x3f317200 */
-	     -6.9314575195e-01,},	/* 0xbf317200 */
-ln2LO[2]   ={ 1.4286067653e-06,  	/* 0x35bfbe8e */
-	     -1.4286067653e-06,},	/* 0xb5bfbe8e */
-invln2 =  1.4426950216e+00, 		/* 0x3fb8aa3b */
-P1   =  1.6666667163e-01, /* 0x3e2aaaab */
-P2   = -2.7777778450e-03, /* 0xbb360b61 */
-P3   =  6.6137559770e-05, /* 0x388ab355 */
-P4   = -1.6533901999e-06, /* 0xb5ddea0e */
-P5   =  4.1381369442e-08; /* 0x3331bb4c */
-
-float
-__ieee754_expf(float x)	/* default IEEE double exp */
-{
-	float y,hi=0.0,lo=0.0,c,t;
-	int32_t k=0,xsb;
-	u_int32_t hx;
-
-	GET_FLOAT_WORD(hx,x);
-	xsb = (hx>>31)&1;		/* sign bit of x */
-	hx &= 0x7fffffff;		/* high word of |x| */
-
-    /* filter out non-finite argument */
-	if(hx >= 0x42b17218) {			/* if |x|>=88.721... */
-	    if(hx>0x7f800000)
-		 return x+x;	 		/* NaN */
-            if(hx==0x7f800000)
-		return (xsb==0)? x:0.0;		/* exp(+-inf)={inf,0} */
-	    if(x > o_threshold) return huge*huge; /* overflow */
-	    if(x < u_threshold) return twom100*twom100; /* underflow */
-	}
-
-    /* argument reduction */
-	if(hx > 0x3eb17218) {		/* if  |x| > 0.5 ln2 */
-	    if(hx < 0x3F851592) {	/* and |x| < 1.5 ln2 */
-		hi = x-ln2HI[xsb]; lo=ln2LO[xsb]; k = 1-xsb-xsb;
-	    } else {
-		k  = invln2*x+halF[xsb];
-		t  = k;
-		hi = x - t*ln2HI[0];	/* t*ln2HI is exact here */
-		lo = t*ln2LO[0];
-	    }
-	    x  = hi - lo;
-	}
-	else if(hx < 0x31800000)  {	/* when |x|<2**-28 */
-	    if(huge+x>one) return one+x;/* trigger inexact */
-	}
-	else k = 0;
-
-    /* x is now in primary range */
-	t  = x*x;
-	c  = x - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
-	if(k==0) 	return one-((x*c)/(c-(float)2.0)-x);
-	else 		y = one-((lo-(x*c)/((float)2.0-c))-hi);
-	if(k >= -125) {
-	    u_int32_t hy;
-	    GET_FLOAT_WORD(hy,y);
-	    SET_FLOAT_WORD(y,hy+(k<<23));	/* add k to y's exponent */
-	    return y;
-	} else {
-	    u_int32_t hy;
-	    GET_FLOAT_WORD(hy,y);
-	    SET_FLOAT_WORD(y,hy+((k+100)<<23));	/* add k to y's exponent */
-	    return y*twom100;
-	}
-}
diff --git a/libm/src/e_fmod.c b/libm/src/e_fmod.c
deleted file mode 100644
index 3b3c169..0000000
--- a/libm/src/e_fmod.c
+++ /dev/null
@@ -1,133 +0,0 @@
-
-/* @(#)e_fmod.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_fmod.c,v 1.9 2005/02/04 18:26:05 das Exp $";
-#endif
-
-/* 
- * __ieee754_fmod(x,y)
- * Return x mod y in exact arithmetic
- * Method: shift and subtract
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double one = 1.0, Zero[] = {0.0, -0.0,};
-
-double
-__ieee754_fmod(double x, double y)
-{
-	int32_t n,hx,hy,hz,ix,iy,sx,i;
-	u_int32_t lx,ly,lz;
-
-	EXTRACT_WORDS(hx,lx,x);
-	EXTRACT_WORDS(hy,ly,y);
-	sx = hx&0x80000000;		/* sign of x */
-	hx ^=sx;		/* |x| */
-	hy &= 0x7fffffff;	/* |y| */
-
-    /* purge off exception values */
-	if((hy|ly)==0||(hx>=0x7ff00000)||	/* y=0,or x not finite */
-	  ((hy|((ly|-ly)>>31))>0x7ff00000))	/* or y is NaN */
-	    return (x*y)/(x*y);
-	if(hx<=hy) {
-	    if((hx<hy)||(lx<ly)) return x;	/* |x|<|y| return x */
-	    if(lx==ly) 
-		return Zero[(u_int32_t)sx>>31];	/* |x|=|y| return x*0*/
-	}
-
-    /* determine ix = ilogb(x) */
-	if(hx<0x00100000) {	/* subnormal x */
-	    if(hx==0) {
-		for (ix = -1043, i=lx; i>0; i<<=1) ix -=1;
-	    } else {
-		for (ix = -1022,i=(hx<<11); i>0; i<<=1) ix -=1;
-	    }
-	} else ix = (hx>>20)-1023;
-
-    /* determine iy = ilogb(y) */
-	if(hy<0x00100000) {	/* subnormal y */
-	    if(hy==0) {
-		for (iy = -1043, i=ly; i>0; i<<=1) iy -=1;
-	    } else {
-		for (iy = -1022,i=(hy<<11); i>0; i<<=1) iy -=1;
-	    }
-	} else iy = (hy>>20)-1023;
-
-    /* set up {hx,lx}, {hy,ly} and align y to x */
-	if(ix >= -1022) 
-	    hx = 0x00100000|(0x000fffff&hx);
-	else {		/* subnormal x, shift x to normal */
-	    n = -1022-ix;
-	    if(n<=31) {
-	        hx = (hx<<n)|(lx>>(32-n));
-	        lx <<= n;
-	    } else {
-		hx = lx<<(n-32);
-		lx = 0;
-	    }
-	}
-	if(iy >= -1022) 
-	    hy = 0x00100000|(0x000fffff&hy);
-	else {		/* subnormal y, shift y to normal */
-	    n = -1022-iy;
-	    if(n<=31) {
-	        hy = (hy<<n)|(ly>>(32-n));
-	        ly <<= n;
-	    } else {
-		hy = ly<<(n-32);
-		ly = 0;
-	    }
-	}
-
-    /* fix point fmod */
-	n = ix - iy;
-	while(n--) {
-	    hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
-	    if(hz<0){hx = hx+hx+(lx>>31); lx = lx+lx;}
-	    else {
-	    	if((hz|lz)==0) 		/* return sign(x)*0 */
-		    return Zero[(u_int32_t)sx>>31];
-	    	hx = hz+hz+(lz>>31); lx = lz+lz;
-	    }
-	}
-	hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
-	if(hz>=0) {hx=hz;lx=lz;}
-
-    /* convert back to floating value and restore the sign */
-	if((hx|lx)==0) 			/* return sign(x)*0 */
-	    return Zero[(u_int32_t)sx>>31];
-	while(hx<0x00100000) {		/* normalize x */
-	    hx = hx+hx+(lx>>31); lx = lx+lx;
-	    iy -= 1;
-	}
-	if(iy>= -1022) {	/* normalize output */
-	    hx = ((hx-0x00100000)|((iy+1023)<<20));
-	    INSERT_WORDS(x,hx|sx,lx);
-	} else {		/* subnormal output */
-	    n = -1022 - iy;
-	    if(n<=20) {
-		lx = (lx>>n)|((u_int32_t)hx<<(32-n));
-		hx >>= n;
-	    } else if (n<=31) {
-		lx = (hx<<(32-n))|(lx>>n); hx = sx;
-	    } else {
-		lx = hx>>(n-32); hx = sx;
-	    }
-	    INSERT_WORDS(x,hx|sx,lx);
-	    x *= one;		/* create necessary signal */
-	}
-	return x;		/* exact output */
-}
diff --git a/libm/src/e_fmodf.c b/libm/src/e_fmodf.c
deleted file mode 100644
index 8b487ac..0000000
--- a/libm/src/e_fmodf.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/* e_fmodf.c -- float version of e_fmod.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_fmodf.c,v 1.6 2002/05/28 17:03:12 alfred Exp $";
-#endif
-
-/*
- * __ieee754_fmodf(x,y)
- * Return x mod y in exact arithmetic
- * Method: shift and subtract
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const float one = 1.0, Zero[] = {0.0, -0.0,};
-
-float
-__ieee754_fmodf(float x, float y)
-{
-	int32_t n,hx,hy,hz,ix,iy,sx,i;
-
-	GET_FLOAT_WORD(hx,x);
-	GET_FLOAT_WORD(hy,y);
-	sx = hx&0x80000000;		/* sign of x */
-	hx ^=sx;		/* |x| */
-	hy &= 0x7fffffff;	/* |y| */
-
-    /* purge off exception values */
-	if(hy==0||(hx>=0x7f800000)||		/* y=0,or x not finite */
-	   (hy>0x7f800000))			/* or y is NaN */
-	    return (x*y)/(x*y);
-	if(hx<hy) return x;			/* |x|<|y| return x */
-	if(hx==hy)
-	    return Zero[(u_int32_t)sx>>31];	/* |x|=|y| return x*0*/
-
-    /* determine ix = ilogb(x) */
-	if(hx<0x00800000) {	/* subnormal x */
-	    for (ix = -126,i=(hx<<8); i>0; i<<=1) ix -=1;
-	} else ix = (hx>>23)-127;
-
-    /* determine iy = ilogb(y) */
-	if(hy<0x00800000) {	/* subnormal y */
-	    for (iy = -126,i=(hy<<8); i>=0; i<<=1) iy -=1;
-	} else iy = (hy>>23)-127;
-
-    /* set up {hx,lx}, {hy,ly} and align y to x */
-	if(ix >= -126)
-	    hx = 0x00800000|(0x007fffff&hx);
-	else {		/* subnormal x, shift x to normal */
-	    n = -126-ix;
-	    hx = hx<<n;
-	}
-	if(iy >= -126)
-	    hy = 0x00800000|(0x007fffff&hy);
-	else {		/* subnormal y, shift y to normal */
-	    n = -126-iy;
-	    hy = hy<<n;
-	}
-
-    /* fix point fmod */
-	n = ix - iy;
-	while(n--) {
-	    hz=hx-hy;
-	    if(hz<0){hx = hx+hx;}
-	    else {
-	    	if(hz==0) 		/* return sign(x)*0 */
-		    return Zero[(u_int32_t)sx>>31];
-	    	hx = hz+hz;
-	    }
-	}
-	hz=hx-hy;
-	if(hz>=0) {hx=hz;}
-
-    /* convert back to floating value and restore the sign */
-	if(hx==0) 			/* return sign(x)*0 */
-	    return Zero[(u_int32_t)sx>>31];
-	while(hx<0x00800000) {		/* normalize x */
-	    hx = hx+hx;
-	    iy -= 1;
-	}
-	if(iy>= -126) {		/* normalize output */
-	    hx = ((hx-0x00800000)|((iy+127)<<23));
-	    SET_FLOAT_WORD(x,hx|sx);
-	} else {		/* subnormal output */
-	    n = -126 - iy;
-	    hx >>= n;
-	    SET_FLOAT_WORD(x,hx|sx);
-	    x *= one;		/* create necessary signal */
-	}
-	return x;		/* exact output */
-}
diff --git a/libm/src/e_gamma.c b/libm/src/e_gamma.c
deleted file mode 100644
index f52ff17..0000000
--- a/libm/src/e_gamma.c
+++ /dev/null
@@ -1,34 +0,0 @@
-
-/* @(#)e_gamma.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- *
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_gamma.c,v 1.7 2005/02/04 18:26:05 das Exp $";
-#endif
-
-/* __ieee754_gamma(x)
- * Return the logarithm of the Gamma function of x.
- *
- * Method: call __ieee754_gamma_r
- */
-
-#include "math.h"
-#include "math_private.h"
-
-extern int signgam;
-
-double
-__ieee754_gamma(double x)
-{
-	return __ieee754_gamma_r(x,&signgam);
-}
diff --git a/libm/src/e_gamma_r.c b/libm/src/e_gamma_r.c
deleted file mode 100644
index be8339d..0000000
--- a/libm/src/e_gamma_r.c
+++ /dev/null
@@ -1,33 +0,0 @@
-
-/* @(#)e_gamma_r.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- *
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_gamma_r.c,v 1.7 2005/02/04 18:26:05 das Exp $";
-#endif
-
-/* __ieee754_gamma_r(x, signgamp)
- * Reentrant version of the logarithm of the Gamma function 
- * with user provide pointer for the sign of Gamma(x). 
- *
- * Method: See __ieee754_lgamma_r
- */
-
-#include "math.h"
-#include "math_private.h"
-
-double
-__ieee754_gamma_r(double x, int *signgamp)
-{
-	return __ieee754_lgamma_r(x,signgamp);
-}
diff --git a/libm/src/e_gammaf.c b/libm/src/e_gammaf.c
deleted file mode 100644
index b5c2ec1..0000000
--- a/libm/src/e_gammaf.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* e_gammaf.c -- float version of e_gamma.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_gammaf.c,v 1.6 2002/05/28 17:03:12 alfred Exp $";
-#endif
-
-/* __ieee754_gammaf(x)
- * Return the logarithm of the Gamma function of x.
- *
- * Method: call __ieee754_gammaf_r
- */
-
-#include "math.h"
-#include "math_private.h"
-
-extern int signgam;
-
-float
-__ieee754_gammaf(float x)
-{
-	return __ieee754_gammaf_r(x,&signgam);
-}
diff --git a/libm/src/e_gammaf_r.c b/libm/src/e_gammaf_r.c
deleted file mode 100644
index d4300c3..0000000
--- a/libm/src/e_gammaf_r.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* e_gammaf_r.c -- float version of e_gamma_r.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_gammaf_r.c,v 1.7 2002/05/28 18:15:03 alfred Exp $";
-#endif
-
-/* __ieee754_gammaf_r(x, signgamp)
- * Reentrant version of the logarithm of the Gamma function
- * with user provide pointer for the sign of Gamma(x).
- *
- * Method: See __ieee754_lgammaf_r
- */
-
-#include "math.h"
-#include "math_private.h"
-
-float
-__ieee754_gammaf_r(float x, int *signgamp)
-{
-	return __ieee754_lgammaf_r(x,signgamp);
-}
diff --git a/libm/src/e_hypot.c b/libm/src/e_hypot.c
deleted file mode 100644
index 11385f5..0000000
--- a/libm/src/e_hypot.c
+++ /dev/null
@@ -1,125 +0,0 @@
-
-/* @(#)e_hypot.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_hypot.c,v 1.9 2005/02/04 18:26:05 das Exp $";
-#endif
-
-/* __ieee754_hypot(x,y)
- *
- * Method :                  
- *	If (assume round-to-nearest) z=x*x+y*y 
- *	has error less than sqrt(2)/2 ulp, than 
- *	sqrt(z) has error less than 1 ulp (exercise).
- *
- *	So, compute sqrt(x*x+y*y) with some care as 
- *	follows to get the error below 1 ulp:
- *
- *	Assume x>y>0;
- *	(if possible, set rounding to round-to-nearest)
- *	1. if x > 2y  use
- *		x1*x1+(y*y+(x2*(x+x1))) for x*x+y*y
- *	where x1 = x with lower 32 bits cleared, x2 = x-x1; else
- *	2. if x <= 2y use
- *		t1*y1+((x-y)*(x-y)+(t1*y2+t2*y))
- *	where t1 = 2x with lower 32 bits cleared, t2 = 2x-t1, 
- *	y1= y with lower 32 bits chopped, y2 = y-y1.
- *		
- *	NOTE: scaling may be necessary if some argument is too 
- *	      large or too tiny
- *
- * Special cases:
- *	hypot(x,y) is INF if x or y is +INF or -INF; else
- *	hypot(x,y) is NAN if x or y is NAN.
- *
- * Accuracy:
- * 	hypot(x,y) returns sqrt(x^2+y^2) with error less 
- * 	than 1 ulps (units in the last place) 
- */
-
-#include "math.h"
-#include "math_private.h"
-
-double
-__ieee754_hypot(double x, double y)
-{
-	double a=x,b=y,t1,t2,y1,y2,w;
-	int32_t j,k,ha,hb;
-
-	GET_HIGH_WORD(ha,x);
-	ha &= 0x7fffffff;
-	GET_HIGH_WORD(hb,y);
-	hb &= 0x7fffffff;
-	if(hb > ha) {a=y;b=x;j=ha; ha=hb;hb=j;} else {a=x;b=y;}
-	SET_HIGH_WORD(a,ha);	/* a <- |a| */
-	SET_HIGH_WORD(b,hb);	/* b <- |b| */
-	if((ha-hb)>0x3c00000) {return a+b;} /* x/y > 2**60 */
-	k=0;
-	if(ha > 0x5f300000) {	/* a>2**500 */
-	   if(ha >= 0x7ff00000) {	/* Inf or NaN */
-	       u_int32_t low;
-	       w = a+b;			/* for sNaN */
-	       GET_LOW_WORD(low,a);
-	       if(((ha&0xfffff)|low)==0) w = a;
-	       GET_LOW_WORD(low,b);
-	       if(((hb^0x7ff00000)|low)==0) w = b;
-	       return w;
-	   }
-	   /* scale a and b by 2**-600 */
-	   ha -= 0x25800000; hb -= 0x25800000;	k += 600;
-	   SET_HIGH_WORD(a,ha);
-	   SET_HIGH_WORD(b,hb);
-	}
-	if(hb < 0x20b00000) {	/* b < 2**-500 */
-	    if(hb <= 0x000fffff) {	/* subnormal b or 0 */
-	        u_int32_t low;
-		GET_LOW_WORD(low,b);
-		if((hb|low)==0) return a;
-		t1=0;
-		SET_HIGH_WORD(t1,0x7fd00000);	/* t1=2^1022 */
-		b *= t1;
-		a *= t1;
-		k -= 1022;
-	    } else {		/* scale a and b by 2^600 */
-	        ha += 0x25800000; 	/* a *= 2^600 */
-		hb += 0x25800000;	/* b *= 2^600 */
-		k -= 600;
-		SET_HIGH_WORD(a,ha);
-		SET_HIGH_WORD(b,hb);
-	    }
-	}
-    /* medium size a and b */
-	w = a-b;
-	if (w>b) {
-	    t1 = 0;
-	    SET_HIGH_WORD(t1,ha);
-	    t2 = a-t1;
-	    w  = sqrt(t1*t1-(b*(-b)-t2*(a+t1)));
-	} else {
-	    a  = a+a;
-	    y1 = 0;
-	    SET_HIGH_WORD(y1,hb);
-	    y2 = b - y1;
-	    t1 = 0;
-	    SET_HIGH_WORD(t1,ha+0x00100000);
-	    t2 = a - t1;
-	    w  = sqrt(t1*y1-(w*(-w)-(t1*y2+t2*b)));
-	}
-	if(k!=0) {
-	    u_int32_t high;
-	    t1 = 1.0;
-	    GET_HIGH_WORD(high,t1);
-	    SET_HIGH_WORD(t1,high+(k<<20));
-	    return t1*w;
-	} else return w;
-}
diff --git a/libm/src/e_hypotf.c b/libm/src/e_hypotf.c
deleted file mode 100644
index 354075a..0000000
--- a/libm/src/e_hypotf.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* e_hypotf.c -- float version of e_hypot.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_hypotf.c,v 1.9 2002/05/28 18:15:03 alfred Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-float
-__ieee754_hypotf(float x, float y)
-{
-	float a=x,b=y,t1,t2,y1,y2,w;
-	int32_t j,k,ha,hb;
-
-	GET_FLOAT_WORD(ha,x);
-	ha &= 0x7fffffff;
-	GET_FLOAT_WORD(hb,y);
-	hb &= 0x7fffffff;
-	if(hb > ha) {a=y;b=x;j=ha; ha=hb;hb=j;} else {a=x;b=y;}
-	SET_FLOAT_WORD(a,ha);	/* a <- |a| */
-	SET_FLOAT_WORD(b,hb);	/* b <- |b| */
-	if((ha-hb)>0xf000000) {return a+b;} /* x/y > 2**30 */
-	k=0;
-	if(ha > 0x58800000) {	/* a>2**50 */
-	   if(ha >= 0x7f800000) {	/* Inf or NaN */
-	       w = a+b;			/* for sNaN */
-	       if(ha == 0x7f800000) w = a;
-	       if(hb == 0x7f800000) w = b;
-	       return w;
-	   }
-	   /* scale a and b by 2**-68 */
-	   ha -= 0x22000000; hb -= 0x22000000;	k += 68;
-	   SET_FLOAT_WORD(a,ha);
-	   SET_FLOAT_WORD(b,hb);
-	}
-	if(hb < 0x26800000) {	/* b < 2**-50 */
-	    if(hb <= 0x007fffff) {	/* subnormal b or 0 */
-	        if(hb==0) return a;
-		SET_FLOAT_WORD(t1,0x7e800000);	/* t1=2^126 */
-		b *= t1;
-		a *= t1;
-		k -= 126;
-	    } else {		/* scale a and b by 2^68 */
-	        ha += 0x22000000; 	/* a *= 2^68 */
-		hb += 0x22000000;	/* b *= 2^68 */
-		k -= 68;
-		SET_FLOAT_WORD(a,ha);
-		SET_FLOAT_WORD(b,hb);
-	    }
-	}
-    /* medium size a and b */
-	w = a-b;
-	if (w>b) {
-	    SET_FLOAT_WORD(t1,ha&0xfffff000);
-	    t2 = a-t1;
-	    w  = __ieee754_sqrtf(t1*t1-(b*(-b)-t2*(a+t1)));
-	} else {
-	    a  = a+a;
-	    SET_FLOAT_WORD(y1,hb&0xfffff000);
-	    y2 = b - y1;
-	    SET_FLOAT_WORD(t1,ha+0x00800000);
-	    t2 = a - t1;
-	    w  = __ieee754_sqrtf(t1*y1-(w*(-w)-(t1*y2+t2*b)));
-	}
-	if(k!=0) {
-	    SET_FLOAT_WORD(t1,0x3f800000+(k<<23));
-	    return t1*w;
-	} else return w;
-}
diff --git a/libm/src/e_j0.c b/libm/src/e_j0.c
deleted file mode 100644
index d99bf11..0000000
--- a/libm/src/e_j0.c
+++ /dev/null
@@ -1,382 +0,0 @@
-
-/* @(#)e_j0.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_j0.c,v 1.8 2005/02/04 18:26:05 das Exp $";
-#endif
-
-/* __ieee754_j0(x), __ieee754_y0(x)
- * Bessel function of the first and second kinds of order zero.
- * Method -- j0(x):
- *	1. For tiny x, we use j0(x) = 1 - x^2/4 + x^4/64 - ...
- *	2. Reduce x to |x| since j0(x)=j0(-x),  and
- *	   for x in (0,2)
- *		j0(x) = 1-z/4+ z^2*R0/S0,  where z = x*x;
- *	   (precision:  |j0-1+z/4-z^2R0/S0 |<2**-63.67 )
- *	   for x in (2,inf)
- * 		j0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)-q0(x)*sin(x0))
- * 	   where x0 = x-pi/4. It is better to compute sin(x0),cos(x0)
- *	   as follow:
- *		cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4)
- *			= 1/sqrt(2) * (cos(x) + sin(x))
- *		sin(x0) = sin(x)cos(pi/4)-cos(x)sin(pi/4)
- *			= 1/sqrt(2) * (sin(x) - cos(x))
- * 	   (To avoid cancellation, use
- *		sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
- * 	    to compute the worse one.)
- *	   
- *	3 Special cases
- *		j0(nan)= nan
- *		j0(0) = 1
- *		j0(inf) = 0
- *		
- * Method -- y0(x):
- *	1. For x<2.
- *	   Since 
- *		y0(x) = 2/pi*(j0(x)*(ln(x/2)+Euler) + x^2/4 - ...)
- *	   therefore y0(x)-2/pi*j0(x)*ln(x) is an even function.
- *	   We use the following function to approximate y0,
- *		y0(x) = U(z)/V(z) + (2/pi)*(j0(x)*ln(x)), z= x^2
- *	   where 
- *		U(z) = u00 + u01*z + ... + u06*z^6
- *		V(z) = 1  + v01*z + ... + v04*z^4
- *	   with absolute approximation error bounded by 2**-72.
- *	   Note: For tiny x, U/V = u0 and j0(x)~1, hence
- *		y0(tiny) = u0 + (2/pi)*ln(tiny), (choose tiny<2**-27)
- *	2. For x>=2.
- * 		y0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)+q0(x)*sin(x0))
- * 	   where x0 = x-pi/4. It is better to compute sin(x0),cos(x0)
- *	   by the method mentioned above.
- *	3. Special cases: y0(0)=-inf, y0(x<0)=NaN, y0(inf)=0.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static double pzero(double), qzero(double);
-
-static const double
-huge 	= 1e300,
-one	= 1.0,
-invsqrtpi=  5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */
-tpi      =  6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */
- 		/* R0/S0 on [0, 2.00] */
-R02  =  1.56249999999999947958e-02, /* 0x3F8FFFFF, 0xFFFFFFFD */
-R03  = -1.89979294238854721751e-04, /* 0xBF28E6A5, 0xB61AC6E9 */
-R04  =  1.82954049532700665670e-06, /* 0x3EBEB1D1, 0x0C503919 */
-R05  = -4.61832688532103189199e-09, /* 0xBE33D5E7, 0x73D63FCE */
-S01  =  1.56191029464890010492e-02, /* 0x3F8FFCE8, 0x82C8C2A4 */
-S02  =  1.16926784663337450260e-04, /* 0x3F1EA6D2, 0xDD57DBF4 */
-S03  =  5.13546550207318111446e-07, /* 0x3EA13B54, 0xCE84D5A9 */
-S04  =  1.16614003333790000205e-09; /* 0x3E1408BC, 0xF4745D8F */
-
-static const double zero = 0.0;
-
-double
-__ieee754_j0(double x)
-{
-	double z, s,c,ss,cc,r,u,v;
-	int32_t hx,ix;
-
-	GET_HIGH_WORD(hx,x);
-	ix = hx&0x7fffffff;
-	if(ix>=0x7ff00000) return one/(x*x);
-	x = fabs(x);
-	if(ix >= 0x40000000) {	/* |x| >= 2.0 */
-		s = sin(x);
-		c = cos(x);
-		ss = s-c;
-		cc = s+c;
-		if(ix<0x7fe00000) {  /* make sure x+x not overflow */
-		    z = -cos(x+x);
-		    if ((s*c)<zero) cc = z/ss;
-		    else 	    ss = z/cc;
-		}
-	/*
-	 * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
-	 * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
-	 */
-		if(ix>0x48000000) z = (invsqrtpi*cc)/sqrt(x);
-		else {
-		    u = pzero(x); v = qzero(x);
-		    z = invsqrtpi*(u*cc-v*ss)/sqrt(x);
-		}
-		return z;
-	}
-	if(ix<0x3f200000) {	/* |x| < 2**-13 */
-	    if(huge+x>one) {	/* raise inexact if x != 0 */
-	        if(ix<0x3e400000) return one;	/* |x|<2**-27 */
-	        else 	      return one - 0.25*x*x;
-	    }
-	}
-	z = x*x;
-	r =  z*(R02+z*(R03+z*(R04+z*R05)));
-	s =  one+z*(S01+z*(S02+z*(S03+z*S04)));
-	if(ix < 0x3FF00000) {	/* |x| < 1.00 */
-	    return one + z*(-0.25+(r/s));
-	} else {
-	    u = 0.5*x;
-	    return((one+u)*(one-u)+z*(r/s));
-	}
-}
-
-static const double
-u00  = -7.38042951086872317523e-02, /* 0xBFB2E4D6, 0x99CBD01F */
-u01  =  1.76666452509181115538e-01, /* 0x3FC69D01, 0x9DE9E3FC */
-u02  = -1.38185671945596898896e-02, /* 0xBF8C4CE8, 0xB16CFA97 */
-u03  =  3.47453432093683650238e-04, /* 0x3F36C54D, 0x20B29B6B */
-u04  = -3.81407053724364161125e-06, /* 0xBECFFEA7, 0x73D25CAD */
-u05  =  1.95590137035022920206e-08, /* 0x3E550057, 0x3B4EABD4 */
-u06  = -3.98205194132103398453e-11, /* 0xBDC5E43D, 0x693FB3C8 */
-v01  =  1.27304834834123699328e-02, /* 0x3F8A1270, 0x91C9C71A */
-v02  =  7.60068627350353253702e-05, /* 0x3F13ECBB, 0xF578C6C1 */
-v03  =  2.59150851840457805467e-07, /* 0x3E91642D, 0x7FF202FD */
-v04  =  4.41110311332675467403e-10; /* 0x3DFE5018, 0x3BD6D9EF */
-
-double
-__ieee754_y0(double x)
-{
-	double z, s,c,ss,cc,u,v;
-	int32_t hx,ix,lx;
-
-	EXTRACT_WORDS(hx,lx,x);
-        ix = 0x7fffffff&hx;
-    /* Y0(NaN) is NaN, y0(-inf) is Nan, y0(inf) is 0  */
-	if(ix>=0x7ff00000) return  one/(x+x*x); 
-        if((ix|lx)==0) return -one/zero;
-        if(hx<0) return zero/zero;
-        if(ix >= 0x40000000) {  /* |x| >= 2.0 */
-        /* y0(x) = sqrt(2/(pi*x))*(p0(x)*sin(x0)+q0(x)*cos(x0))
-         * where x0 = x-pi/4
-         *      Better formula:
-         *              cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4)
-         *                      =  1/sqrt(2) * (sin(x) + cos(x))
-         *              sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
-         *                      =  1/sqrt(2) * (sin(x) - cos(x))
-         * To avoid cancellation, use
-         *              sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
-         * to compute the worse one.
-         */
-                s = sin(x);
-                c = cos(x);
-                ss = s-c;
-                cc = s+c;
-	/*
-	 * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
-	 * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
-	 */
-                if(ix<0x7fe00000) {  /* make sure x+x not overflow */
-                    z = -cos(x+x);
-                    if ((s*c)<zero) cc = z/ss;
-                    else            ss = z/cc;
-                }
-                if(ix>0x48000000) z = (invsqrtpi*ss)/sqrt(x);
-                else {
-                    u = pzero(x); v = qzero(x);
-                    z = invsqrtpi*(u*ss+v*cc)/sqrt(x);
-                }
-                return z;
-	}
-	if(ix<=0x3e400000) {	/* x < 2**-27 */
-	    return(u00 + tpi*__ieee754_log(x));
-	}
-	z = x*x;
-	u = u00+z*(u01+z*(u02+z*(u03+z*(u04+z*(u05+z*u06)))));
-	v = one+z*(v01+z*(v02+z*(v03+z*v04)));
-	return(u/v + tpi*(__ieee754_j0(x)*__ieee754_log(x)));
-}
-
-/* The asymptotic expansions of pzero is
- *	1 - 9/128 s^2 + 11025/98304 s^4 - ...,	where s = 1/x.
- * For x >= 2, We approximate pzero by
- * 	pzero(x) = 1 + (R/S)
- * where  R = pR0 + pR1*s^2 + pR2*s^4 + ... + pR5*s^10
- * 	  S = 1 + pS0*s^2 + ... + pS4*s^10
- * and
- *	| pzero(x)-1-R/S | <= 2  ** ( -60.26)
- */
-static const double pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
-  0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
- -7.03124999999900357484e-02, /* 0xBFB1FFFF, 0xFFFFFD32 */
- -8.08167041275349795626e+00, /* 0xC02029D0, 0xB44FA779 */
- -2.57063105679704847262e+02, /* 0xC0701102, 0x7B19E863 */
- -2.48521641009428822144e+03, /* 0xC0A36A6E, 0xCD4DCAFC */
- -5.25304380490729545272e+03, /* 0xC0B4850B, 0x36CC643D */
-};
-static const double pS8[5] = {
-  1.16534364619668181717e+02, /* 0x405D2233, 0x07A96751 */
-  3.83374475364121826715e+03, /* 0x40ADF37D, 0x50596938 */
-  4.05978572648472545552e+04, /* 0x40E3D2BB, 0x6EB6B05F */
-  1.16752972564375915681e+05, /* 0x40FC810F, 0x8F9FA9BD */
-  4.76277284146730962675e+04, /* 0x40E74177, 0x4F2C49DC */
-};
-
-static const double pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
- -1.14125464691894502584e-11, /* 0xBDA918B1, 0x47E495CC */
- -7.03124940873599280078e-02, /* 0xBFB1FFFF, 0xE69AFBC6 */
- -4.15961064470587782438e+00, /* 0xC010A370, 0xF90C6BBF */
- -6.76747652265167261021e+01, /* 0xC050EB2F, 0x5A7D1783 */
- -3.31231299649172967747e+02, /* 0xC074B3B3, 0x6742CC63 */
- -3.46433388365604912451e+02, /* 0xC075A6EF, 0x28A38BD7 */
-};
-static const double pS5[5] = {
-  6.07539382692300335975e+01, /* 0x404E6081, 0x0C98C5DE */
-  1.05125230595704579173e+03, /* 0x40906D02, 0x5C7E2864 */
-  5.97897094333855784498e+03, /* 0x40B75AF8, 0x8FBE1D60 */
-  9.62544514357774460223e+03, /* 0x40C2CCB8, 0xFA76FA38 */
-  2.40605815922939109441e+03, /* 0x40A2CC1D, 0xC70BE864 */
-};
-
-static const double pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
- -2.54704601771951915620e-09, /* 0xBE25E103, 0x6FE1AA86 */
- -7.03119616381481654654e-02, /* 0xBFB1FFF6, 0xF7C0E24B */
- -2.40903221549529611423e+00, /* 0xC00345B2, 0xAEA48074 */
- -2.19659774734883086467e+01, /* 0xC035F74A, 0x4CB94E14 */
- -5.80791704701737572236e+01, /* 0xC04D0A22, 0x420A1A45 */
- -3.14479470594888503854e+01, /* 0xC03F72AC, 0xA892D80F */
-};
-static const double pS3[5] = {
-  3.58560338055209726349e+01, /* 0x4041ED92, 0x84077DD3 */
-  3.61513983050303863820e+02, /* 0x40769839, 0x464A7C0E */
-  1.19360783792111533330e+03, /* 0x4092A66E, 0x6D1061D6 */
-  1.12799679856907414432e+03, /* 0x40919FFC, 0xB8C39B7E */
-  1.73580930813335754692e+02, /* 0x4065B296, 0xFC379081 */
-};
-
-static const double pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
- -8.87534333032526411254e-08, /* 0xBE77D316, 0xE927026D */
- -7.03030995483624743247e-02, /* 0xBFB1FF62, 0x495E1E42 */
- -1.45073846780952986357e+00, /* 0xBFF73639, 0x8A24A843 */
- -7.63569613823527770791e+00, /* 0xC01E8AF3, 0xEDAFA7F3 */
- -1.11931668860356747786e+01, /* 0xC02662E6, 0xC5246303 */
- -3.23364579351335335033e+00, /* 0xC009DE81, 0xAF8FE70F */
-};
-static const double pS2[5] = {
-  2.22202997532088808441e+01, /* 0x40363865, 0x908B5959 */
-  1.36206794218215208048e+02, /* 0x4061069E, 0x0EE8878F */
-  2.70470278658083486789e+02, /* 0x4070E786, 0x42EA079B */
-  1.53875394208320329881e+02, /* 0x40633C03, 0x3AB6FAFF */
-  1.46576176948256193810e+01, /* 0x402D50B3, 0x44391809 */
-};
-
-	static double pzero(double x)
-{
-	const double *p,*q;
-	double z,r,s;
-	int32_t ix;
-	GET_HIGH_WORD(ix,x);
-	ix &= 0x7fffffff;
-	if(ix>=0x40200000)     {p = pR8; q= pS8;}
-	else if(ix>=0x40122E8B){p = pR5; q= pS5;}
-	else if(ix>=0x4006DB6D){p = pR3; q= pS3;}
-	else if(ix>=0x40000000){p = pR2; q= pS2;}
-	z = one/(x*x);
-	r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
-	s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
-	return one+ r/s;
-}
-		
-
-/* For x >= 8, the asymptotic expansions of qzero is
- *	-1/8 s + 75/1024 s^3 - ..., where s = 1/x.
- * We approximate pzero by
- * 	qzero(x) = s*(-1.25 + (R/S))
- * where  R = qR0 + qR1*s^2 + qR2*s^4 + ... + qR5*s^10
- * 	  S = 1 + qS0*s^2 + ... + qS5*s^12
- * and
- *	| qzero(x)/s +1.25-R/S | <= 2  ** ( -61.22)
- */
-static const double qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
-  0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
-  7.32421874999935051953e-02, /* 0x3FB2BFFF, 0xFFFFFE2C */
-  1.17682064682252693899e+01, /* 0x40278952, 0x5BB334D6 */
-  5.57673380256401856059e+02, /* 0x40816D63, 0x15301825 */
-  8.85919720756468632317e+03, /* 0x40C14D99, 0x3E18F46D */
-  3.70146267776887834771e+04, /* 0x40E212D4, 0x0E901566 */
-};
-static const double qS8[6] = {
-  1.63776026895689824414e+02, /* 0x406478D5, 0x365B39BC */
-  8.09834494656449805916e+03, /* 0x40BFA258, 0x4E6B0563 */
-  1.42538291419120476348e+05, /* 0x41016652, 0x54D38C3F */
-  8.03309257119514397345e+05, /* 0x412883DA, 0x83A52B43 */
-  8.40501579819060512818e+05, /* 0x4129A66B, 0x28DE0B3D */
- -3.43899293537866615225e+05, /* 0xC114FD6D, 0x2C9530C5 */
-};
-
-static const double qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
-  1.84085963594515531381e-11, /* 0x3DB43D8F, 0x29CC8CD9 */
-  7.32421766612684765896e-02, /* 0x3FB2BFFF, 0xD172B04C */
-  5.83563508962056953777e+00, /* 0x401757B0, 0xB9953DD3 */
-  1.35111577286449829671e+02, /* 0x4060E392, 0x0A8788E9 */
-  1.02724376596164097464e+03, /* 0x40900CF9, 0x9DC8C481 */
-  1.98997785864605384631e+03, /* 0x409F17E9, 0x53C6E3A6 */
-};
-static const double qS5[6] = {
-  8.27766102236537761883e+01, /* 0x4054B1B3, 0xFB5E1543 */
-  2.07781416421392987104e+03, /* 0x40A03BA0, 0xDA21C0CE */
-  1.88472887785718085070e+04, /* 0x40D267D2, 0x7B591E6D */
-  5.67511122894947329769e+04, /* 0x40EBB5E3, 0x97E02372 */
-  3.59767538425114471465e+04, /* 0x40E19118, 0x1F7A54A0 */
- -5.35434275601944773371e+03, /* 0xC0B4EA57, 0xBEDBC609 */
-};
-
-static const double qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
-  4.37741014089738620906e-09, /* 0x3E32CD03, 0x6ADECB82 */
-  7.32411180042911447163e-02, /* 0x3FB2BFEE, 0x0E8D0842 */
-  3.34423137516170720929e+00, /* 0x400AC0FC, 0x61149CF5 */
-  4.26218440745412650017e+01, /* 0x40454F98, 0x962DAEDD */
-  1.70808091340565596283e+02, /* 0x406559DB, 0xE25EFD1F */
-  1.66733948696651168575e+02, /* 0x4064D77C, 0x81FA21E0 */
-};
-static const double qS3[6] = {
-  4.87588729724587182091e+01, /* 0x40486122, 0xBFE343A6 */
-  7.09689221056606015736e+02, /* 0x40862D83, 0x86544EB3 */
-  3.70414822620111362994e+03, /* 0x40ACF04B, 0xE44DFC63 */
-  6.46042516752568917582e+03, /* 0x40B93C6C, 0xD7C76A28 */
-  2.51633368920368957333e+03, /* 0x40A3A8AA, 0xD94FB1C0 */
- -1.49247451836156386662e+02, /* 0xC062A7EB, 0x201CF40F */
-};
-
-static const double qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
-  1.50444444886983272379e-07, /* 0x3E84313B, 0x54F76BDB */
-  7.32234265963079278272e-02, /* 0x3FB2BEC5, 0x3E883E34 */
-  1.99819174093815998816e+00, /* 0x3FFFF897, 0xE727779C */
-  1.44956029347885735348e+01, /* 0x402CFDBF, 0xAAF96FE5 */
-  3.16662317504781540833e+01, /* 0x403FAA8E, 0x29FBDC4A */
-  1.62527075710929267416e+01, /* 0x403040B1, 0x71814BB4 */
-};
-static const double qS2[6] = {
-  3.03655848355219184498e+01, /* 0x403E5D96, 0xF7C07AED */
-  2.69348118608049844624e+02, /* 0x4070D591, 0xE4D14B40 */
-  8.44783757595320139444e+02, /* 0x408A6645, 0x22B3BF22 */
-  8.82935845112488550512e+02, /* 0x408B977C, 0x9C5CC214 */
-  2.12666388511798828631e+02, /* 0x406A9553, 0x0E001365 */
- -5.31095493882666946917e+00, /* 0xC0153E6A, 0xF8B32931 */
-};
-
-	static double qzero(double x)
-{
-	const double *p,*q;
-	double s,r,z;
-	int32_t ix;
-	GET_HIGH_WORD(ix,x);
-	ix &= 0x7fffffff;
-	if(ix>=0x40200000)     {p = qR8; q= qS8;}
-	else if(ix>=0x40122E8B){p = qR5; q= qS5;}
-	else if(ix>=0x4006DB6D){p = qR3; q= qS3;}
-	else if(ix>=0x40000000){p = qR2; q= qS2;}
-	z = one/(x*x);
-	r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
-	s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
-	return (-.125 + r/s)/x;
-}
diff --git a/libm/src/e_j0f.c b/libm/src/e_j0f.c
deleted file mode 100644
index 6b566bf..0000000
--- a/libm/src/e_j0f.c
+++ /dev/null
@@ -1,339 +0,0 @@
-/* e_j0f.c -- float version of e_j0.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Bugs in __ieee754_j0f and __ieee754_y0f fixed by Scott Turner 01/16/2010
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_j0f.c,v 1.7 2002/05/28 18:15:03 alfred Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static float pzerof(float), qzerof(float);
-
-static const float
-huge 	= 1e30,
-one	= 1.0,
-invsqrtpi=  5.6418961287e-01, /* 0x3f106ebb */
-tpi      =  6.3661974669e-01, /* 0x3f22f983 */
- 		/* R0/S0 on [0, 2.00] */
-R02  =  1.5625000000e-02, /* 0x3c800000 */
-R03  = -1.8997929874e-04, /* 0xb947352e */
-R04  =  1.8295404516e-06, /* 0x35f58e88 */
-R05  = -4.6183270541e-09, /* 0xb19eaf3c */
-S01  =  1.5619102865e-02, /* 0x3c7fe744 */
-S02  =  1.1692678527e-04, /* 0x38f53697 */
-S03  =  5.1354652442e-07, /* 0x3509daa6 */
-S04  =  1.1661400734e-09; /* 0x30a045e8 */
-
-static const float zero = 0.0;
-
-float
-__ieee754_j0f(float x)
-{
-	float z, s,c,ss,cc,r,u,v;
-	int32_t hx,ix;
-
-	GET_FLOAT_WORD(hx,x);
-	ix = hx&0x7fffffff;
-	if(ix>=0x7f800000) return one/(x*x);
-	x = fabsf(x);
-	if(ix >= 0x40000000) {	/* |x| >= 2.0 */
-		s = sinf(x);
-		c = cosf(x);
-		ss = s-c;
-		cc = s+c;
-		if(ix<0x7f000000) {  /* make sure x+x not overflow */
-		    z = -cosf(x+x);
-		    if ((s*c)<zero) cc = z/ss;
-		    else 	    ss = z/cc;
-		}
-	/*
-	 * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
-	 * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
-	 */
-		if(((uint32_t)hx)>0x80000000) z = (invsqrtpi*cc)/sqrtf(x);
-		else {
-		    u = pzerof(x); v = qzerof(x);
-		    z = invsqrtpi*(u*cc-v*ss)/sqrtf(x);
-		}
-		return z;
-	}
-	if(ix<0x39000000) {	/* |x| < 2**-13 */
-	    if(huge+x>one) {	/* raise inexact if x != 0 */
-	        if(ix<0x32000000) return one;	/* |x|<2**-27 */
-	        else 	      return one - (float)0.25*x*x;
-	    }
-	}
-	z = x*x;
-	r =  z*(R02+z*(R03+z*(R04+z*R05)));
-	s =  one+z*(S01+z*(S02+z*(S03+z*S04)));
-	if(ix < 0x3F800000) {	/* |x| < 1.00 */
-	    return one + z*((float)-0.25+(r/s));
-	} else {
-	    u = (float)0.5*x;
-	    return((one+u)*(one-u)+z*(r/s));
-	}
-}
-
-static const float
-u00  = -7.3804296553e-02, /* 0xbd9726b5 */
-u01  =  1.7666645348e-01, /* 0x3e34e80d */
-u02  = -1.3818567619e-02, /* 0xbc626746 */
-u03  =  3.4745343146e-04, /* 0x39b62a69 */
-u04  = -3.8140706238e-06, /* 0xb67ff53c */
-u05  =  1.9559013964e-08, /* 0x32a802ba */
-u06  = -3.9820518410e-11, /* 0xae2f21eb */
-v01  =  1.2730483897e-02, /* 0x3c509385 */
-v02  =  7.6006865129e-05, /* 0x389f65e0 */
-v03  =  2.5915085189e-07, /* 0x348b216c */
-v04  =  4.4111031494e-10; /* 0x2ff280c2 */
-
-float
-__ieee754_y0f(float x)
-{
-	float z, s,c,ss,cc,u,v;
-	int32_t hx,ix;
-
-	GET_FLOAT_WORD(hx,x);
-        ix = hx&0x7fffffff;
-    /* Y0(NaN) is NaN, y0(-inf) is Nan, y0(inf) is 0  */
-	if(ix>=0x7f800000) return  one/(x+x*x);
-        if(ix==0) return -one/zero;
-        if(hx<0) return zero/zero;
-        if(ix >= 0x40000000) {  /* |x| >= 2.0 */
-        /* y0(x) = sqrt(2/(pi*x))*(p0(x)*sin(x0)+q0(x)*cos(x0))
-         * where x0 = x-pi/4
-         *      Better formula:
-         *              cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4)
-         *                      =  1/sqrt(2) * (sin(x) + cos(x))
-         *              sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
-         *                      =  1/sqrt(2) * (sin(x) - cos(x))
-         * To avoid cancellation, use
-         *              sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
-         * to compute the worse one.
-         */
-                s = sinf(x);
-                c = cosf(x);
-                ss = s-c;
-                cc = s+c;
-	/*
-	 * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
-	 * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
-	 */
-                if(ix<0x7f000000) {  /* make sure x+x not overflow */
-                    z = -cosf(x+x);
-                    if ((s*c)<zero) cc = z/ss;
-                    else            ss = z/cc;
-                }
-                if(((uint32_t)hx)>0x80000000) z = (invsqrtpi*ss)/sqrtf(x);
-                else {
-                    u = pzerof(x); v = qzerof(x);
-                    z = invsqrtpi*(u*ss+v*cc)/sqrtf(x);
-                }
-                return z;
-	}
-	if(ix<=0x32000000) {	/* x < 2**-27 */
-	    return(u00 + tpi*__ieee754_logf(x));
-	}
-	z = x*x;
-	u = u00+z*(u01+z*(u02+z*(u03+z*(u04+z*(u05+z*u06)))));
-	v = one+z*(v01+z*(v02+z*(v03+z*v04)));
-	return(u/v + tpi*(__ieee754_j0f(x)*__ieee754_logf(x)));
-}
-
-/* The asymptotic expansions of pzero is
- *	1 - 9/128 s^2 + 11025/98304 s^4 - ...,	where s = 1/x.
- * For x >= 2, We approximate pzero by
- * 	pzero(x) = 1 + (R/S)
- * where  R = pR0 + pR1*s^2 + pR2*s^4 + ... + pR5*s^10
- * 	  S = 1 + pS0*s^2 + ... + pS4*s^10
- * and
- *	| pzero(x)-1-R/S | <= 2  ** ( -60.26)
- */
-static const float pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
-  0.0000000000e+00, /* 0x00000000 */
- -7.0312500000e-02, /* 0xbd900000 */
- -8.0816707611e+00, /* 0xc1014e86 */
- -2.5706311035e+02, /* 0xc3808814 */
- -2.4852163086e+03, /* 0xc51b5376 */
- -5.2530439453e+03, /* 0xc5a4285a */
-};
-static const float pS8[5] = {
-  1.1653436279e+02, /* 0x42e91198 */
-  3.8337448730e+03, /* 0x456f9beb */
-  4.0597855469e+04, /* 0x471e95db */
-  1.1675296875e+05, /* 0x47e4087c */
-  4.7627726562e+04, /* 0x473a0bba */
-};
-static const float pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
- -1.1412546255e-11, /* 0xad48c58a */
- -7.0312492549e-02, /* 0xbd8fffff */
- -4.1596107483e+00, /* 0xc0851b88 */
- -6.7674766541e+01, /* 0xc287597b */
- -3.3123129272e+02, /* 0xc3a59d9b */
- -3.4643338013e+02, /* 0xc3ad3779 */
-};
-static const float pS5[5] = {
-  6.0753936768e+01, /* 0x42730408 */
-  1.0512523193e+03, /* 0x44836813 */
-  5.9789707031e+03, /* 0x45bad7c4 */
-  9.6254453125e+03, /* 0x461665c8 */
-  2.4060581055e+03, /* 0x451660ee */
-};
-
-static const float pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
- -2.5470459075e-09, /* 0xb12f081b */
- -7.0311963558e-02, /* 0xbd8fffb8 */
- -2.4090321064e+00, /* 0xc01a2d95 */
- -2.1965976715e+01, /* 0xc1afba52 */
- -5.8079170227e+01, /* 0xc2685112 */
- -3.1447946548e+01, /* 0xc1fb9565 */
-};
-static const float pS3[5] = {
-  3.5856033325e+01, /* 0x420f6c94 */
-  3.6151397705e+02, /* 0x43b4c1ca */
-  1.1936077881e+03, /* 0x44953373 */
-  1.1279968262e+03, /* 0x448cffe6 */
-  1.7358093262e+02, /* 0x432d94b8 */
-};
-
-static const float pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
- -8.8753431271e-08, /* 0xb3be98b7 */
- -7.0303097367e-02, /* 0xbd8ffb12 */
- -1.4507384300e+00, /* 0xbfb9b1cc */
- -7.6356959343e+00, /* 0xc0f4579f */
- -1.1193166733e+01, /* 0xc1331736 */
- -3.2336456776e+00, /* 0xc04ef40d */
-};
-static const float pS2[5] = {
-  2.2220300674e+01, /* 0x41b1c32d */
-  1.3620678711e+02, /* 0x430834f0 */
-  2.7047027588e+02, /* 0x43873c32 */
-  1.5387539673e+02, /* 0x4319e01a */
-  1.4657617569e+01, /* 0x416a859a */
-};
-
-	static float pzerof(float x)
-{
-	const float *p,*q;
-	float z,r,s;
-	int32_t ix;
-	GET_FLOAT_WORD(ix,x);
-	ix &= 0x7fffffff;
-	if(ix>=0x41000000)     {p = pR8; q= pS8;}
-	else if(ix>=0x40f71c58){p = pR5; q= pS5;}
-	else if(ix>=0x4036db68){p = pR3; q= pS3;}
-	else if(ix>=0x40000000){p = pR2; q= pS2;}
-	z = one/(x*x);
-	r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
-	s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
-	return one+ r/s;
-}
-
-
-/* For x >= 8, the asymptotic expansions of qzero is
- *	-1/8 s + 75/1024 s^3 - ..., where s = 1/x.
- * We approximate pzero by
- * 	qzero(x) = s*(-1.25 + (R/S))
- * where  R = qR0 + qR1*s^2 + qR2*s^4 + ... + qR5*s^10
- * 	  S = 1 + qS0*s^2 + ... + qS5*s^12
- * and
- *	| qzero(x)/s +1.25-R/S | <= 2  ** ( -61.22)
- */
-static const float qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
-  0.0000000000e+00, /* 0x00000000 */
-  7.3242187500e-02, /* 0x3d960000 */
-  1.1768206596e+01, /* 0x413c4a93 */
-  5.5767340088e+02, /* 0x440b6b19 */
-  8.8591972656e+03, /* 0x460a6cca */
-  3.7014625000e+04, /* 0x471096a0 */
-};
-static const float qS8[6] = {
-  1.6377603149e+02, /* 0x4323c6aa */
-  8.0983447266e+03, /* 0x45fd12c2 */
-  1.4253829688e+05, /* 0x480b3293 */
-  8.0330925000e+05, /* 0x49441ed4 */
-  8.4050156250e+05, /* 0x494d3359 */
- -3.4389928125e+05, /* 0xc8a7eb69 */
-};
-
-static const float qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
-  1.8408595828e-11, /* 0x2da1ec79 */
-  7.3242180049e-02, /* 0x3d95ffff */
-  5.8356351852e+00, /* 0x40babd86 */
-  1.3511157227e+02, /* 0x43071c90 */
-  1.0272437744e+03, /* 0x448067cd */
-  1.9899779053e+03, /* 0x44f8bf4b */
-};
-static const float qS5[6] = {
-  8.2776611328e+01, /* 0x42a58da0 */
-  2.0778142090e+03, /* 0x4501dd07 */
-  1.8847289062e+04, /* 0x46933e94 */
-  5.6751113281e+04, /* 0x475daf1d */
-  3.5976753906e+04, /* 0x470c88c1 */
- -5.3543427734e+03, /* 0xc5a752be */
-};
-
-static const float qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
-  4.3774099900e-09, /* 0x3196681b */
-  7.3241114616e-02, /* 0x3d95ff70 */
-  3.3442313671e+00, /* 0x405607e3 */
-  4.2621845245e+01, /* 0x422a7cc5 */
-  1.7080809021e+02, /* 0x432acedf */
-  1.6673394775e+02, /* 0x4326bbe4 */
-};
-static const float qS3[6] = {
-  4.8758872986e+01, /* 0x42430916 */
-  7.0968920898e+02, /* 0x44316c1c */
-  3.7041481934e+03, /* 0x4567825f */
-  6.4604252930e+03, /* 0x45c9e367 */
-  2.5163337402e+03, /* 0x451d4557 */
- -1.4924745178e+02, /* 0xc3153f59 */
-};
-
-static const float qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
-  1.5044444979e-07, /* 0x342189db */
-  7.3223426938e-02, /* 0x3d95f62a */
-  1.9981917143e+00, /* 0x3fffc4bf */
-  1.4495602608e+01, /* 0x4167edfd */
-  3.1666231155e+01, /* 0x41fd5471 */
-  1.6252708435e+01, /* 0x4182058c */
-};
-static const float qS2[6] = {
-  3.0365585327e+01, /* 0x41f2ecb8 */
-  2.6934811401e+02, /* 0x4386ac8f */
-  8.4478375244e+02, /* 0x44533229 */
-  8.8293585205e+02, /* 0x445cbbe5 */
-  2.1266638184e+02, /* 0x4354aa98 */
- -5.3109550476e+00, /* 0xc0a9f358 */
-};
-
-	static float qzerof(float x)
-{
-	const float *p,*q;
-	float s,r,z;
-	int32_t ix;
-	GET_FLOAT_WORD(ix,x);
-	ix &= 0x7fffffff;
-	if(ix>=0x41000000)     {p = qR8; q= qS8;}
-	else if(ix>=0x40f71c58){p = qR5; q= qS5;}
-	else if(ix>=0x4036db68){p = qR3; q= qS3;}
-	else if(ix>=0x40000000){p = qR2; q= qS2;}
-	z = one/(x*x);
-	r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
-	s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
-	return (-(float).125 + r/s)/x;
-}
diff --git a/libm/src/e_j1.c b/libm/src/e_j1.c
deleted file mode 100644
index 4dbf222..0000000
--- a/libm/src/e_j1.c
+++ /dev/null
@@ -1,377 +0,0 @@
-
-/* @(#)e_j1.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_j1.c,v 1.8 2005/02/04 18:26:06 das Exp $";
-#endif
-
-/* __ieee754_j1(x), __ieee754_y1(x)
- * Bessel function of the first and second kinds of order zero.
- * Method -- j1(x):
- *	1. For tiny x, we use j1(x) = x/2 - x^3/16 + x^5/384 - ...
- *	2. Reduce x to |x| since j1(x)=-j1(-x),  and
- *	   for x in (0,2)
- *		j1(x) = x/2 + x*z*R0/S0,  where z = x*x;
- *	   (precision:  |j1/x - 1/2 - R0/S0 |<2**-61.51 )
- *	   for x in (2,inf)
- * 		j1(x) = sqrt(2/(pi*x))*(p1(x)*cos(x1)-q1(x)*sin(x1))
- * 		y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1))
- * 	   where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1)
- *	   as follow:
- *		cos(x1) =  cos(x)cos(3pi/4)+sin(x)sin(3pi/4)
- *			=  1/sqrt(2) * (sin(x) - cos(x))
- *		sin(x1) =  sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
- *			= -1/sqrt(2) * (sin(x) + cos(x))
- * 	   (To avoid cancellation, use
- *		sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
- * 	    to compute the worse one.)
- *	   
- *	3 Special cases
- *		j1(nan)= nan
- *		j1(0) = 0
- *		j1(inf) = 0
- *		
- * Method -- y1(x):
- *	1. screen out x<=0 cases: y1(0)=-inf, y1(x<0)=NaN 
- *	2. For x<2.
- *	   Since 
- *		y1(x) = 2/pi*(j1(x)*(ln(x/2)+Euler)-1/x-x/2+5/64*x^3-...)
- *	   therefore y1(x)-2/pi*j1(x)*ln(x)-1/x is an odd function.
- *	   We use the following function to approximate y1,
- *		y1(x) = x*U(z)/V(z) + (2/pi)*(j1(x)*ln(x)-1/x), z= x^2
- *	   where for x in [0,2] (abs err less than 2**-65.89)
- *		U(z) = U0[0] + U0[1]*z + ... + U0[4]*z^4
- *		V(z) = 1  + v0[0]*z + ... + v0[4]*z^5
- *	   Note: For tiny x, 1/x dominate y1 and hence
- *		y1(tiny) = -2/pi/tiny, (choose tiny<2**-54)
- *	3. For x>=2.
- * 		y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1))
- * 	   where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1)
- *	   by method mentioned above.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static double pone(double), qone(double);
-
-static const double
-huge    = 1e300,
-one	= 1.0,
-invsqrtpi=  5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */
-tpi      =  6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */
-	/* R0/S0 on [0,2] */
-r00  = -6.25000000000000000000e-02, /* 0xBFB00000, 0x00000000 */
-r01  =  1.40705666955189706048e-03, /* 0x3F570D9F, 0x98472C61 */
-r02  = -1.59955631084035597520e-05, /* 0xBEF0C5C6, 0xBA169668 */
-r03  =  4.96727999609584448412e-08, /* 0x3E6AAAFA, 0x46CA0BD9 */
-s01  =  1.91537599538363460805e-02, /* 0x3F939D0B, 0x12637E53 */
-s02  =  1.85946785588630915560e-04, /* 0x3F285F56, 0xB9CDF664 */
-s03  =  1.17718464042623683263e-06, /* 0x3EB3BFF8, 0x333F8498 */
-s04  =  5.04636257076217042715e-09, /* 0x3E35AC88, 0xC97DFF2C */
-s05  =  1.23542274426137913908e-11; /* 0x3DAB2ACF, 0xCFB97ED8 */
-
-static const double zero    = 0.0;
-
-double
-__ieee754_j1(double x)
-{
-	double z, s,c,ss,cc,r,u,v,y;
-	int32_t hx,ix;
-
-	GET_HIGH_WORD(hx,x);
-	ix = hx&0x7fffffff;
-	if(ix>=0x7ff00000) return one/x;
-	y = fabs(x);
-	if(ix >= 0x40000000) {	/* |x| >= 2.0 */
-		s = sin(y);
-		c = cos(y);
-		ss = -s-c;
-		cc = s-c;
-		if(ix<0x7fe00000) {  /* make sure y+y not overflow */
-		    z = cos(y+y);
-		    if ((s*c)>zero) cc = z/ss;
-		    else 	    ss = z/cc;
-		}
-	/*
-	 * j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x)
-	 * y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x)
-	 */
-		if(ix>0x48000000) z = (invsqrtpi*cc)/sqrt(y);
-		else {
-		    u = pone(y); v = qone(y);
-		    z = invsqrtpi*(u*cc-v*ss)/sqrt(y);
-		}
-		if(hx<0) return -z;
-		else  	 return  z;
-	}
-	if(ix<0x3e400000) {	/* |x|<2**-27 */
-	    if(huge+x>one) return 0.5*x;/* inexact if x!=0 necessary */
-	}
-	z = x*x;
-	r =  z*(r00+z*(r01+z*(r02+z*r03)));
-	s =  one+z*(s01+z*(s02+z*(s03+z*(s04+z*s05))));
-	r *= x;
-	return(x*0.5+r/s);
-}
-
-static const double U0[5] = {
- -1.96057090646238940668e-01, /* 0xBFC91866, 0x143CBC8A */
-  5.04438716639811282616e-02, /* 0x3FA9D3C7, 0x76292CD1 */
- -1.91256895875763547298e-03, /* 0xBF5F55E5, 0x4844F50F */
-  2.35252600561610495928e-05, /* 0x3EF8AB03, 0x8FA6B88E */
- -9.19099158039878874504e-08, /* 0xBE78AC00, 0x569105B8 */
-};
-static const double V0[5] = {
-  1.99167318236649903973e-02, /* 0x3F94650D, 0x3F4DA9F0 */
-  2.02552581025135171496e-04, /* 0x3F2A8C89, 0x6C257764 */
-  1.35608801097516229404e-06, /* 0x3EB6C05A, 0x894E8CA6 */
-  6.22741452364621501295e-09, /* 0x3E3ABF1D, 0x5BA69A86 */
-  1.66559246207992079114e-11, /* 0x3DB25039, 0xDACA772A */
-};
-
-double
-__ieee754_y1(double x)
-{
-	double z, s,c,ss,cc,u,v;
-	int32_t hx,ix,lx;
-
-	EXTRACT_WORDS(hx,lx,x);
-        ix = 0x7fffffff&hx;
-    /* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */
-	if(ix>=0x7ff00000) return  one/(x+x*x); 
-        if((ix|lx)==0) return -one/zero;
-        if(hx<0) return zero/zero;
-        if(ix >= 0x40000000) {  /* |x| >= 2.0 */
-                s = sin(x);
-                c = cos(x);
-                ss = -s-c;
-                cc = s-c;
-                if(ix<0x7fe00000) {  /* make sure x+x not overflow */
-                    z = cos(x+x);
-                    if ((s*c)>zero) cc = z/ss;
-                    else            ss = z/cc;
-                }
-        /* y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x0)+q1(x)*cos(x0))
-         * where x0 = x-3pi/4
-         *      Better formula:
-         *              cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4)
-         *                      =  1/sqrt(2) * (sin(x) - cos(x))
-         *              sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
-         *                      = -1/sqrt(2) * (cos(x) + sin(x))
-         * To avoid cancellation, use
-         *              sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
-         * to compute the worse one.
-         */
-                if(ix>0x48000000) z = (invsqrtpi*ss)/sqrt(x);
-                else {
-                    u = pone(x); v = qone(x);
-                    z = invsqrtpi*(u*ss+v*cc)/sqrt(x);
-                }
-                return z;
-        } 
-        if(ix<=0x3c900000) {    /* x < 2**-54 */
-            return(-tpi/x);
-        } 
-        z = x*x;
-        u = U0[0]+z*(U0[1]+z*(U0[2]+z*(U0[3]+z*U0[4])));
-        v = one+z*(V0[0]+z*(V0[1]+z*(V0[2]+z*(V0[3]+z*V0[4]))));
-        return(x*(u/v) + tpi*(__ieee754_j1(x)*__ieee754_log(x)-one/x));
-}
-
-/* For x >= 8, the asymptotic expansions of pone is
- *	1 + 15/128 s^2 - 4725/2^15 s^4 - ...,	where s = 1/x.
- * We approximate pone by
- * 	pone(x) = 1 + (R/S)
- * where  R = pr0 + pr1*s^2 + pr2*s^4 + ... + pr5*s^10
- * 	  S = 1 + ps0*s^2 + ... + ps4*s^10
- * and
- *	| pone(x)-1-R/S | <= 2  ** ( -60.06)
- */
-
-static const double pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
-  0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
-  1.17187499999988647970e-01, /* 0x3FBDFFFF, 0xFFFFFCCE */
-  1.32394806593073575129e+01, /* 0x402A7A9D, 0x357F7FCE */
-  4.12051854307378562225e+02, /* 0x4079C0D4, 0x652EA590 */
-  3.87474538913960532227e+03, /* 0x40AE457D, 0xA3A532CC */
-  7.91447954031891731574e+03, /* 0x40BEEA7A, 0xC32782DD */
-};
-static const double ps8[5] = {
-  1.14207370375678408436e+02, /* 0x405C8D45, 0x8E656CAC */
-  3.65093083420853463394e+03, /* 0x40AC85DC, 0x964D274F */
-  3.69562060269033463555e+04, /* 0x40E20B86, 0x97C5BB7F */
-  9.76027935934950801311e+04, /* 0x40F7D42C, 0xB28F17BB */
-  3.08042720627888811578e+04, /* 0x40DE1511, 0x697A0B2D */
-};
-
-static const double pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
-  1.31990519556243522749e-11, /* 0x3DAD0667, 0xDAE1CA7D */
-  1.17187493190614097638e-01, /* 0x3FBDFFFF, 0xE2C10043 */
-  6.80275127868432871736e+00, /* 0x401B3604, 0x6E6315E3 */
-  1.08308182990189109773e+02, /* 0x405B13B9, 0x452602ED */
-  5.17636139533199752805e+02, /* 0x40802D16, 0xD052D649 */
-  5.28715201363337541807e+02, /* 0x408085B8, 0xBB7E0CB7 */
-};
-static const double ps5[5] = {
-  5.92805987221131331921e+01, /* 0x404DA3EA, 0xA8AF633D */
-  9.91401418733614377743e+02, /* 0x408EFB36, 0x1B066701 */
-  5.35326695291487976647e+03, /* 0x40B4E944, 0x5706B6FB */
-  7.84469031749551231769e+03, /* 0x40BEA4B0, 0xB8A5BB15 */
-  1.50404688810361062679e+03, /* 0x40978030, 0x036F5E51 */
-};
-
-static const double pr3[6] = {
-  3.02503916137373618024e-09, /* 0x3E29FC21, 0xA7AD9EDD */
-  1.17186865567253592491e-01, /* 0x3FBDFFF5, 0x5B21D17B */
-  3.93297750033315640650e+00, /* 0x400F76BC, 0xE85EAD8A */
-  3.51194035591636932736e+01, /* 0x40418F48, 0x9DA6D129 */
-  9.10550110750781271918e+01, /* 0x4056C385, 0x4D2C1837 */
-  4.85590685197364919645e+01, /* 0x4048478F, 0x8EA83EE5 */
-};
-static const double ps3[5] = {
-  3.47913095001251519989e+01, /* 0x40416549, 0xA134069C */
-  3.36762458747825746741e+02, /* 0x40750C33, 0x07F1A75F */
-  1.04687139975775130551e+03, /* 0x40905B7C, 0x5037D523 */
-  8.90811346398256432622e+02, /* 0x408BD67D, 0xA32E31E9 */
-  1.03787932439639277504e+02, /* 0x4059F26D, 0x7C2EED53 */
-};
-
-static const double pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
-  1.07710830106873743082e-07, /* 0x3E7CE9D4, 0xF65544F4 */
-  1.17176219462683348094e-01, /* 0x3FBDFF42, 0xBE760D83 */
-  2.36851496667608785174e+00, /* 0x4002F2B7, 0xF98FAEC0 */
-  1.22426109148261232917e+01, /* 0x40287C37, 0x7F71A964 */
-  1.76939711271687727390e+01, /* 0x4031B1A8, 0x177F8EE2 */
-  5.07352312588818499250e+00, /* 0x40144B49, 0xA574C1FE */
-};
-static const double ps2[5] = {
-  2.14364859363821409488e+01, /* 0x40356FBD, 0x8AD5ECDC */
-  1.25290227168402751090e+02, /* 0x405F5293, 0x14F92CD5 */
-  2.32276469057162813669e+02, /* 0x406D08D8, 0xD5A2DBD9 */
-  1.17679373287147100768e+02, /* 0x405D6B7A, 0xDA1884A9 */
-  8.36463893371618283368e+00, /* 0x4020BAB1, 0xF44E5192 */
-};
-
-	static double pone(double x)
-{
-	const double *p,*q;
-	double z,r,s;
-        int32_t ix;
-	GET_HIGH_WORD(ix,x);
-	ix &= 0x7fffffff;
-        if(ix>=0x40200000)     {p = pr8; q= ps8;}
-        else if(ix>=0x40122E8B){p = pr5; q= ps5;}
-        else if(ix>=0x4006DB6D){p = pr3; q= ps3;}
-        else if(ix>=0x40000000){p = pr2; q= ps2;}
-        z = one/(x*x);
-        r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
-        s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
-        return one+ r/s;
-}
-		
-
-/* For x >= 8, the asymptotic expansions of qone is
- *	3/8 s - 105/1024 s^3 - ..., where s = 1/x.
- * We approximate pone by
- * 	qone(x) = s*(0.375 + (R/S))
- * where  R = qr1*s^2 + qr2*s^4 + ... + qr5*s^10
- * 	  S = 1 + qs1*s^2 + ... + qs6*s^12
- * and
- *	| qone(x)/s -0.375-R/S | <= 2  ** ( -61.13)
- */
-
-static const double qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
-  0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
- -1.02539062499992714161e-01, /* 0xBFBA3FFF, 0xFFFFFDF3 */
- -1.62717534544589987888e+01, /* 0xC0304591, 0xA26779F7 */
- -7.59601722513950107896e+02, /* 0xC087BCD0, 0x53E4B576 */
- -1.18498066702429587167e+04, /* 0xC0C724E7, 0x40F87415 */
- -4.84385124285750353010e+04, /* 0xC0E7A6D0, 0x65D09C6A */
-};
-static const double qs8[6] = {
-  1.61395369700722909556e+02, /* 0x40642CA6, 0xDE5BCDE5 */
-  7.82538599923348465381e+03, /* 0x40BE9162, 0xD0D88419 */
-  1.33875336287249578163e+05, /* 0x4100579A, 0xB0B75E98 */
-  7.19657723683240939863e+05, /* 0x4125F653, 0x72869C19 */
-  6.66601232617776375264e+05, /* 0x412457D2, 0x7719AD5C */
- -2.94490264303834643215e+05, /* 0xC111F969, 0x0EA5AA18 */
-};
-
-static const double qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
- -2.08979931141764104297e-11, /* 0xBDB6FA43, 0x1AA1A098 */
- -1.02539050241375426231e-01, /* 0xBFBA3FFF, 0xCB597FEF */
- -8.05644828123936029840e+00, /* 0xC0201CE6, 0xCA03AD4B */
- -1.83669607474888380239e+02, /* 0xC066F56D, 0x6CA7B9B0 */
- -1.37319376065508163265e+03, /* 0xC09574C6, 0x6931734F */
- -2.61244440453215656817e+03, /* 0xC0A468E3, 0x88FDA79D */
-};
-static const double qs5[6] = {
-  8.12765501384335777857e+01, /* 0x405451B2, 0xFF5A11B2 */
-  1.99179873460485964642e+03, /* 0x409F1F31, 0xE77BF839 */
-  1.74684851924908907677e+04, /* 0x40D10F1F, 0x0D64CE29 */
-  4.98514270910352279316e+04, /* 0x40E8576D, 0xAABAD197 */
-  2.79480751638918118260e+04, /* 0x40DB4B04, 0xCF7C364B */
- -4.71918354795128470869e+03, /* 0xC0B26F2E, 0xFCFFA004 */
-};
-
-static const double qr3[6] = {
- -5.07831226461766561369e-09, /* 0xBE35CFA9, 0xD38FC84F */
- -1.02537829820837089745e-01, /* 0xBFBA3FEB, 0x51AEED54 */
- -4.61011581139473403113e+00, /* 0xC01270C2, 0x3302D9FF */
- -5.78472216562783643212e+01, /* 0xC04CEC71, 0xC25D16DA */
- -2.28244540737631695038e+02, /* 0xC06C87D3, 0x4718D55F */
- -2.19210128478909325622e+02, /* 0xC06B66B9, 0x5F5C1BF6 */
-};
-static const double qs3[6] = {
-  4.76651550323729509273e+01, /* 0x4047D523, 0xCCD367E4 */
-  6.73865112676699709482e+02, /* 0x40850EEB, 0xC031EE3E */
-  3.38015286679526343505e+03, /* 0x40AA684E, 0x448E7C9A */
-  5.54772909720722782367e+03, /* 0x40B5ABBA, 0xA61D54A6 */
-  1.90311919338810798763e+03, /* 0x409DBC7A, 0x0DD4DF4B */
- -1.35201191444307340817e+02, /* 0xC060E670, 0x290A311F */
-};
-
-static const double qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
- -1.78381727510958865572e-07, /* 0xBE87F126, 0x44C626D2 */
- -1.02517042607985553460e-01, /* 0xBFBA3E8E, 0x9148B010 */
- -2.75220568278187460720e+00, /* 0xC0060484, 0x69BB4EDA */
- -1.96636162643703720221e+01, /* 0xC033A9E2, 0xC168907F */
- -4.23253133372830490089e+01, /* 0xC04529A3, 0xDE104AAA */
- -2.13719211703704061733e+01, /* 0xC0355F36, 0x39CF6E52 */
-};
-static const double qs2[6] = {
-  2.95333629060523854548e+01, /* 0x403D888A, 0x78AE64FF */
-  2.52981549982190529136e+02, /* 0x406F9F68, 0xDB821CBA */
-  7.57502834868645436472e+02, /* 0x4087AC05, 0xCE49A0F7 */
-  7.39393205320467245656e+02, /* 0x40871B25, 0x48D4C029 */
-  1.55949003336666123687e+02, /* 0x40637E5E, 0x3C3ED8D4 */
- -4.95949898822628210127e+00, /* 0xC013D686, 0xE71BE86B */
-};
-
-	static double qone(double x)
-{
-	const double *p,*q;
-	double  s,r,z;
-	int32_t ix;
-	GET_HIGH_WORD(ix,x);
-	ix &= 0x7fffffff;
-	if(ix>=0x40200000)     {p = qr8; q= qs8;}
-	else if(ix>=0x40122E8B){p = qr5; q= qs5;}
-	else if(ix>=0x4006DB6D){p = qr3; q= qs3;}
-	else if(ix>=0x40000000){p = qr2; q= qs2;}
-	z = one/(x*x);
-	r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
-	s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
-	return (.375 + r/s)/x;
-}
diff --git a/libm/src/e_j1f.c b/libm/src/e_j1f.c
deleted file mode 100644
index ea05774..0000000
--- a/libm/src/e_j1f.c
+++ /dev/null
@@ -1,335 +0,0 @@
-/* e_j1f.c -- float version of e_j1.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Bug in __ieee754_j1f fixed by Scott Turner 1/16/2010
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_j1f.c,v 1.7 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static float ponef(float), qonef(float);
-
-static const float
-huge    = 1e30,
-one	= 1.0,
-invsqrtpi=  5.6418961287e-01, /* 0x3f106ebb */
-tpi      =  6.3661974669e-01, /* 0x3f22f983 */
-	/* R0/S0 on [0,2] */
-r00  = -6.2500000000e-02, /* 0xbd800000 */
-r01  =  1.4070566976e-03, /* 0x3ab86cfd */
-r02  = -1.5995563444e-05, /* 0xb7862e36 */
-r03  =  4.9672799207e-08, /* 0x335557d2 */
-s01  =  1.9153760746e-02, /* 0x3c9ce859 */
-s02  =  1.8594678841e-04, /* 0x3942fab6 */
-s03  =  1.1771846857e-06, /* 0x359dffc2 */
-s04  =  5.0463624390e-09, /* 0x31ad6446 */
-s05  =  1.2354227016e-11; /* 0x2d59567e */
-
-static const float zero    = 0.0;
-
-float
-__ieee754_j1f(float x)
-{
-	float z, s,c,ss,cc,r,u,v,y;
-	int32_t hx,ix;
-
-	GET_FLOAT_WORD(hx,x);
-	ix = hx&0x7fffffff;
-	if(ix>=0x7f800000) return one/x;
-	y = fabsf(x);
-	if(ix >= 0x40000000) {	/* |x| >= 2.0 */
-		s = sinf(y);
-		c = cosf(y);
-		ss = -s-c;
-		cc = s-c;
-		if(ix<0x7f000000) {  /* make sure y+y not overflow */
-		    z = cosf(y+y);
-		    if ((s*c)>zero) cc = z/ss;
-		    else 	    ss = z/cc;
-		}
-	/*
-	 * j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x)
-	 * y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x)
-	 */
-		if(((uint32_t)hx)>0x80000000) z = (invsqrtpi*cc)/sqrtf(y);
-		else {
-		    u = ponef(y); v = qonef(y);
-		    z = invsqrtpi*(u*cc-v*ss)/sqrtf(y);
-		}
-		if(hx<0) return -z;
-		else  	 return  z;
-	}
-	if(ix<0x32000000) {	/* |x|<2**-27 */
-	    if(huge+x>one) return (float)0.5*x;/* inexact if x!=0 necessary */
-	}
-	z = x*x;
-	r =  z*(r00+z*(r01+z*(r02+z*r03)));
-	s =  one+z*(s01+z*(s02+z*(s03+z*(s04+z*s05))));
-	r *= x;
-	return(x*(float)0.5+r/s);
-}
-
-static const float U0[5] = {
- -1.9605709612e-01, /* 0xbe48c331 */
-  5.0443872809e-02, /* 0x3d4e9e3c */
- -1.9125689287e-03, /* 0xbafaaf2a */
-  2.3525259166e-05, /* 0x37c5581c */
- -9.1909917899e-08, /* 0xb3c56003 */
-};
-static const float V0[5] = {
-  1.9916731864e-02, /* 0x3ca3286a */
-  2.0255257550e-04, /* 0x3954644b */
-  1.3560879779e-06, /* 0x35b602d4 */
-  6.2274145840e-09, /* 0x31d5f8eb */
-  1.6655924903e-11, /* 0x2d9281cf */
-};
-
-float
-__ieee754_y1f(float x)
-{
-	float z, s,c,ss,cc,u,v;
-	int32_t hx,ix;
-
-	GET_FLOAT_WORD(hx,x);
-        ix = 0x7fffffff&hx;
-    /* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */
-	if(ix>=0x7f800000) return  one/(x+x*x);
-        if(ix==0) return -one/zero;
-        if(hx<0) return zero/zero;
-        if(ix >= 0x40000000) {  /* |x| >= 2.0 */
-                s = sinf(x);
-                c = cosf(x);
-                ss = -s-c;
-                cc = s-c;
-                if(ix<0x7f000000) {  /* make sure x+x not overflow */
-                    z = cosf(x+x);
-                    if ((s*c)>zero) cc = z/ss;
-                    else            ss = z/cc;
-                }
-        /* y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x0)+q1(x)*cos(x0))
-         * where x0 = x-3pi/4
-         *      Better formula:
-         *              cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4)
-         *                      =  1/sqrt(2) * (sin(x) - cos(x))
-         *              sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
-         *                      = -1/sqrt(2) * (cos(x) + sin(x))
-         * To avoid cancellation, use
-         *              sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
-         * to compute the worse one.
-         */
-                if(ix>0x48000000) z = (invsqrtpi*ss)/sqrtf(x);
-                else {
-                    u = ponef(x); v = qonef(x);
-                    z = invsqrtpi*(u*ss+v*cc)/sqrtf(x);
-                }
-                return z;
-        }
-        if(ix<=0x24800000) {    /* x < 2**-54 */
-            return(-tpi/x);
-        }
-        z = x*x;
-        u = U0[0]+z*(U0[1]+z*(U0[2]+z*(U0[3]+z*U0[4])));
-        v = one+z*(V0[0]+z*(V0[1]+z*(V0[2]+z*(V0[3]+z*V0[4]))));
-        return(x*(u/v) + tpi*(__ieee754_j1f(x)*__ieee754_logf(x)-one/x));
-}
-
-/* For x >= 8, the asymptotic expansions of pone is
- *	1 + 15/128 s^2 - 4725/2^15 s^4 - ...,	where s = 1/x.
- * We approximate pone by
- * 	pone(x) = 1 + (R/S)
- * where  R = pr0 + pr1*s^2 + pr2*s^4 + ... + pr5*s^10
- * 	  S = 1 + ps0*s^2 + ... + ps4*s^10
- * and
- *	| pone(x)-1-R/S | <= 2  ** ( -60.06)
- */
-
-static const float pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
-  0.0000000000e+00, /* 0x00000000 */
-  1.1718750000e-01, /* 0x3df00000 */
-  1.3239480972e+01, /* 0x4153d4ea */
-  4.1205184937e+02, /* 0x43ce06a3 */
-  3.8747453613e+03, /* 0x45722bed */
-  7.9144794922e+03, /* 0x45f753d6 */
-};
-static const float ps8[5] = {
-  1.1420736694e+02, /* 0x42e46a2c */
-  3.6509309082e+03, /* 0x45642ee5 */
-  3.6956207031e+04, /* 0x47105c35 */
-  9.7602796875e+04, /* 0x47bea166 */
-  3.0804271484e+04, /* 0x46f0a88b */
-};
-
-static const float pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
-  1.3199052094e-11, /* 0x2d68333f */
-  1.1718749255e-01, /* 0x3defffff */
-  6.8027510643e+00, /* 0x40d9b023 */
-  1.0830818176e+02, /* 0x42d89dca */
-  5.1763616943e+02, /* 0x440168b7 */
-  5.2871520996e+02, /* 0x44042dc6 */
-};
-static const float ps5[5] = {
-  5.9280597687e+01, /* 0x426d1f55 */
-  9.9140142822e+02, /* 0x4477d9b1 */
-  5.3532670898e+03, /* 0x45a74a23 */
-  7.8446904297e+03, /* 0x45f52586 */
-  1.5040468750e+03, /* 0x44bc0180 */
-};
-
-static const float pr3[6] = {
-  3.0250391081e-09, /* 0x314fe10d */
-  1.1718686670e-01, /* 0x3defffab */
-  3.9329774380e+00, /* 0x407bb5e7 */
-  3.5119403839e+01, /* 0x420c7a45 */
-  9.1055007935e+01, /* 0x42b61c2a */
-  4.8559066772e+01, /* 0x42423c7c */
-};
-static const float ps3[5] = {
-  3.4791309357e+01, /* 0x420b2a4d */
-  3.3676245117e+02, /* 0x43a86198 */
-  1.0468714600e+03, /* 0x4482dbe3 */
-  8.9081134033e+02, /* 0x445eb3ed */
-  1.0378793335e+02, /* 0x42cf936c */
-};
-
-static const float pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
-  1.0771083225e-07, /* 0x33e74ea8 */
-  1.1717621982e-01, /* 0x3deffa16 */
-  2.3685150146e+00, /* 0x401795c0 */
-  1.2242610931e+01, /* 0x4143e1bc */
-  1.7693971634e+01, /* 0x418d8d41 */
-  5.0735230446e+00, /* 0x40a25a4d */
-};
-static const float ps2[5] = {
-  2.1436485291e+01, /* 0x41ab7dec */
-  1.2529022980e+02, /* 0x42fa9499 */
-  2.3227647400e+02, /* 0x436846c7 */
-  1.1767937469e+02, /* 0x42eb5bd7 */
-  8.3646392822e+00, /* 0x4105d590 */
-};
-
-	static float ponef(float x)
-{
-	const float *p,*q;
-	float z,r,s;
-        int32_t ix;
-	GET_FLOAT_WORD(ix,x);
-	ix &= 0x7fffffff;
-        if(ix>=0x41000000)     {p = pr8; q= ps8;}
-        else if(ix>=0x40f71c58){p = pr5; q= ps5;}
-        else if(ix>=0x4036db68){p = pr3; q= ps3;}
-        else if(ix>=0x40000000){p = pr2; q= ps2;}
-        z = one/(x*x);
-        r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
-        s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
-        return one+ r/s;
-}
-
-
-/* For x >= 8, the asymptotic expansions of qone is
- *	3/8 s - 105/1024 s^3 - ..., where s = 1/x.
- * We approximate pone by
- * 	qone(x) = s*(0.375 + (R/S))
- * where  R = qr1*s^2 + qr2*s^4 + ... + qr5*s^10
- * 	  S = 1 + qs1*s^2 + ... + qs6*s^12
- * and
- *	| qone(x)/s -0.375-R/S | <= 2  ** ( -61.13)
- */
-
-static const float qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
-  0.0000000000e+00, /* 0x00000000 */
- -1.0253906250e-01, /* 0xbdd20000 */
- -1.6271753311e+01, /* 0xc1822c8d */
- -7.5960174561e+02, /* 0xc43de683 */
- -1.1849806641e+04, /* 0xc639273a */
- -4.8438511719e+04, /* 0xc73d3683 */
-};
-static const float qs8[6] = {
-  1.6139537048e+02, /* 0x43216537 */
-  7.8253862305e+03, /* 0x45f48b17 */
-  1.3387534375e+05, /* 0x4802bcd6 */
-  7.1965775000e+05, /* 0x492fb29c */
-  6.6660125000e+05, /* 0x4922be94 */
- -2.9449025000e+05, /* 0xc88fcb48 */
-};
-
-static const float qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
- -2.0897993405e-11, /* 0xadb7d219 */
- -1.0253904760e-01, /* 0xbdd1fffe */
- -8.0564479828e+00, /* 0xc100e736 */
- -1.8366960144e+02, /* 0xc337ab6b */
- -1.3731937256e+03, /* 0xc4aba633 */
- -2.6124443359e+03, /* 0xc523471c */
-};
-static const float qs5[6] = {
-  8.1276550293e+01, /* 0x42a28d98 */
-  1.9917987061e+03, /* 0x44f8f98f */
-  1.7468484375e+04, /* 0x468878f8 */
-  4.9851425781e+04, /* 0x4742bb6d */
-  2.7948074219e+04, /* 0x46da5826 */
- -4.7191835938e+03, /* 0xc5937978 */
-};
-
-static const float qr3[6] = {
- -5.0783124372e-09, /* 0xb1ae7d4f */
- -1.0253783315e-01, /* 0xbdd1ff5b */
- -4.6101160049e+00, /* 0xc0938612 */
- -5.7847221375e+01, /* 0xc267638e */
- -2.2824453735e+02, /* 0xc3643e9a */
- -2.1921012878e+02, /* 0xc35b35cb */
-};
-static const float qs3[6] = {
-  4.7665153503e+01, /* 0x423ea91e */
-  6.7386511230e+02, /* 0x4428775e */
-  3.3801528320e+03, /* 0x45534272 */
-  5.5477290039e+03, /* 0x45ad5dd5 */
-  1.9031191406e+03, /* 0x44ede3d0 */
- -1.3520118713e+02, /* 0xc3073381 */
-};
-
-static const float qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
- -1.7838172539e-07, /* 0xb43f8932 */
- -1.0251704603e-01, /* 0xbdd1f475 */
- -2.7522056103e+00, /* 0xc0302423 */
- -1.9663616180e+01, /* 0xc19d4f16 */
- -4.2325313568e+01, /* 0xc2294d1f */
- -2.1371921539e+01, /* 0xc1aaf9b2 */
-};
-static const float qs2[6] = {
-  2.9533363342e+01, /* 0x41ec4454 */
-  2.5298155212e+02, /* 0x437cfb47 */
-  7.5750280762e+02, /* 0x443d602e */
-  7.3939318848e+02, /* 0x4438d92a */
-  1.5594900513e+02, /* 0x431bf2f2 */
- -4.9594988823e+00, /* 0xc09eb437 */
-};
-
-	static float qonef(float x)
-{
-	const float *p,*q;
-	float  s,r,z;
-	int32_t ix;
-	GET_FLOAT_WORD(ix,x);
-	ix &= 0x7fffffff;
-	if(ix>=0x40200000)     {p = qr8; q= qs8;}
-	else if(ix>=0x40f71c58){p = qr5; q= qs5;}
-	else if(ix>=0x4036db68){p = qr3; q= qs3;}
-	else if(ix>=0x40000000){p = qr2; q= qs2;}
-	z = one/(x*x);
-	r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
-	s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
-	return ((float).375 + r/s)/x;
-}
diff --git a/libm/src/e_jn.c b/libm/src/e_jn.c
deleted file mode 100644
index 413b22d..0000000
--- a/libm/src/e_jn.c
+++ /dev/null
@@ -1,266 +0,0 @@
-
-/* @(#)e_jn.c 1.4 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_jn.c,v 1.9 2005/02/04 18:26:06 das Exp $";
-#endif
-
-/*
- * __ieee754_jn(n, x), __ieee754_yn(n, x)
- * floating point Bessel's function of the 1st and 2nd kind
- * of order n
- *          
- * Special cases:
- *	y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal;
- *	y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal.
- * Note 2. About jn(n,x), yn(n,x)
- *	For n=0, j0(x) is called,
- *	for n=1, j1(x) is called,
- *	for n<x, forward recursion us used starting
- *	from values of j0(x) and j1(x).
- *	for n>x, a continued fraction approximation to
- *	j(n,x)/j(n-1,x) is evaluated and then backward
- *	recursion is used starting from a supposed value
- *	for j(n,x). The resulting value of j(0,x) is
- *	compared with the actual value to correct the
- *	supposed value of j(n,x).
- *
- *	yn(n,x) is similar in all respects, except
- *	that forward recursion is used for all
- *	values of n>1.
- *	
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-invsqrtpi=  5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */
-two   =  2.00000000000000000000e+00, /* 0x40000000, 0x00000000 */
-one   =  1.00000000000000000000e+00; /* 0x3FF00000, 0x00000000 */
-
-static const double zero  =  0.00000000000000000000e+00;
-
-double
-__ieee754_jn(int n, double x)
-{
-	int32_t i,hx,ix,lx, sgn;
-	double a, b, temp, di;
-	double z, w;
-
-    /* J(-n,x) = (-1)^n * J(n, x), J(n, -x) = (-1)^n * J(n, x)
-     * Thus, J(-n,x) = J(n,-x)
-     */
-	EXTRACT_WORDS(hx,lx,x);
-	ix = 0x7fffffff&hx;
-    /* if J(n,NaN) is NaN */
-	if((ix|((u_int32_t)(lx|-lx))>>31)>0x7ff00000) return x+x;
-	if(n<0){		
-		n = -n;
-		x = -x;
-		hx ^= 0x80000000;
-	}
-	if(n==0) return(__ieee754_j0(x));
-	if(n==1) return(__ieee754_j1(x));
-	sgn = (n&1)&(hx>>31);	/* even n -- 0, odd n -- sign(x) */
-	x = fabs(x);
-	if((ix|lx)==0||ix>=0x7ff00000) 	/* if x is 0 or inf */
-	    b = zero;
-	else if((double)n<=x) {   
-		/* Safe to use J(n+1,x)=2n/x *J(n,x)-J(n-1,x) */
-	    if(ix>=0x52D00000) { /* x > 2**302 */
-    /* (x >> n**2) 
-     *	    Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi)
-     *	    Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi)
-     *	    Let s=sin(x), c=cos(x), 
-     *		xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then
-     *
-     *		   n	sin(xn)*sqt2	cos(xn)*sqt2
-     *		----------------------------------
-     *		   0	 s-c		 c+s
-     *		   1	-s-c 		-c+s
-     *		   2	-s+c		-c-s
-     *		   3	 s+c		 c-s
-     */
-		switch(n&3) {
-		    case 0: temp =  cos(x)+sin(x); break;
-		    case 1: temp = -cos(x)+sin(x); break;
-		    case 2: temp = -cos(x)-sin(x); break;
-		    case 3: temp =  cos(x)-sin(x); break;
-		}
-		b = invsqrtpi*temp/sqrt(x);
-	    } else {	
-	        a = __ieee754_j0(x);
-	        b = __ieee754_j1(x);
-	        for(i=1;i<n;i++){
-		    temp = b;
-		    b = b*((double)(i+i)/x) - a; /* avoid underflow */
-		    a = temp;
-	        }
-	    }
-	} else {
-	    if(ix<0x3e100000) {	/* x < 2**-29 */
-    /* x is tiny, return the first Taylor expansion of J(n,x) 
-     * J(n,x) = 1/n!*(x/2)^n  - ...
-     */
-		if(n>33)	/* underflow */
-		    b = zero;
-		else {
-		    temp = x*0.5; b = temp;
-		    for (a=one,i=2;i<=n;i++) {
-			a *= (double)i;		/* a = n! */
-			b *= temp;		/* b = (x/2)^n */
-		    }
-		    b = b/a;
-		}
-	    } else {
-		/* use backward recurrence */
-		/* 			x      x^2      x^2       
-		 *  J(n,x)/J(n-1,x) =  ----   ------   ------   .....
-		 *			2n  - 2(n+1) - 2(n+2)
-		 *
-		 * 			1      1        1       
-		 *  (for large x)   =  ----  ------   ------   .....
-		 *			2n   2(n+1)   2(n+2)
-		 *			-- - ------ - ------ - 
-		 *			 x     x         x
-		 *
-		 * Let w = 2n/x and h=2/x, then the above quotient
-		 * is equal to the continued fraction:
-		 *		    1
-		 *	= -----------------------
-		 *		       1
-		 *	   w - -----------------
-		 *			  1
-		 * 	        w+h - ---------
-		 *		       w+2h - ...
-		 *
-		 * To determine how many terms needed, let
-		 * Q(0) = w, Q(1) = w(w+h) - 1,
-		 * Q(k) = (w+k*h)*Q(k-1) - Q(k-2),
-		 * When Q(k) > 1e4	good for single 
-		 * When Q(k) > 1e9	good for double 
-		 * When Q(k) > 1e17	good for quadruple 
-		 */
-	    /* determine k */
-		double t,v;
-		double q0,q1,h,tmp; int32_t k,m;
-		w  = (n+n)/(double)x; h = 2.0/(double)x;
-		q0 = w;  z = w+h; q1 = w*z - 1.0; k=1;
-		while(q1<1.0e9) {
-			k += 1; z += h;
-			tmp = z*q1 - q0;
-			q0 = q1;
-			q1 = tmp;
-		}
-		m = n+n;
-		for(t=zero, i = 2*(n+k); i>=m; i -= 2) t = one/(i/x-t);
-		a = t;
-		b = one;
-		/*  estimate log((2/x)^n*n!) = n*log(2/x)+n*ln(n)
-		 *  Hence, if n*(log(2n/x)) > ...
-		 *  single 8.8722839355e+01
-		 *  double 7.09782712893383973096e+02
-		 *  long double 1.1356523406294143949491931077970765006170e+04
-		 *  then recurrent value may overflow and the result is
-		 *  likely underflow to zero
-		 */
-		tmp = n;
-		v = two/x;
-		tmp = tmp*__ieee754_log(fabs(v*tmp));
-		if(tmp<7.09782712893383973096e+02) {
-	    	    for(i=n-1,di=(double)(i+i);i>0;i--){
-		        temp = b;
-			b *= di;
-			b  = b/x - a;
-		        a = temp;
-			di -= two;
-	     	    }
-		} else {
-	    	    for(i=n-1,di=(double)(i+i);i>0;i--){
-		        temp = b;
-			b *= di;
-			b  = b/x - a;
-		        a = temp;
-			di -= two;
-		    /* scale b to avoid spurious overflow */
-			if(b>1e100) {
-			    a /= b;
-			    t /= b;
-			    b  = one;
-			}
-	     	    }
-		}
-	    	b = (t*__ieee754_j0(x)/b);
-	    }
-	}
-	if(sgn==1) return -b; else return b;
-}
-
-double
-__ieee754_yn(int n, double x)
-{
-	int32_t i,hx,ix,lx;
-	int32_t sign;
-	double a, b, temp;
-
-	EXTRACT_WORDS(hx,lx,x);
-	ix = 0x7fffffff&hx;
-    /* if Y(n,NaN) is NaN */
-	if((ix|((u_int32_t)(lx|-lx))>>31)>0x7ff00000) return x+x;
-	if((ix|lx)==0) return -one/zero;
-	if(hx<0) return zero/zero;
-	sign = 1;
-	if(n<0){
-		n = -n;
-		sign = 1 - ((n&1)<<1);
-	}
-	if(n==0) return(__ieee754_y0(x));
-	if(n==1) return(sign*__ieee754_y1(x));
-	if(ix==0x7ff00000) return zero;
-	if(ix>=0x52D00000) { /* x > 2**302 */
-    /* (x >> n**2) 
-     *	    Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi)
-     *	    Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi)
-     *	    Let s=sin(x), c=cos(x), 
-     *		xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then
-     *
-     *		   n	sin(xn)*sqt2	cos(xn)*sqt2
-     *		----------------------------------
-     *		   0	 s-c		 c+s
-     *		   1	-s-c 		-c+s
-     *		   2	-s+c		-c-s
-     *		   3	 s+c		 c-s
-     */
-		switch(n&3) {
-		    case 0: temp =  sin(x)-cos(x); break;
-		    case 1: temp = -sin(x)-cos(x); break;
-		    case 2: temp = -sin(x)+cos(x); break;
-		    case 3: temp =  sin(x)+cos(x); break;
-		}
-		b = invsqrtpi*temp/sqrt(x);
-	} else {
-	    u_int32_t high;
-	    a = __ieee754_y0(x);
-	    b = __ieee754_y1(x);
-	/* quit if b is -inf */
-	    GET_HIGH_WORD(high,b);
-	    for(i=1;i<n&&high!=0xfff00000;i++){
-		temp = b;
-		b = ((double)(i+i)/x)*b - a;
-		GET_HIGH_WORD(high,b);
-		a = temp;
-	    }
-	}
-	if(sign>0) return b; else return -b;
-}
diff --git a/libm/src/e_jnf.c b/libm/src/e_jnf.c
deleted file mode 100644
index a61fb68..0000000
--- a/libm/src/e_jnf.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/* e_jnf.c -- float version of e_jn.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_jnf.c,v 1.8 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float
-invsqrtpi=  5.6418961287e-01, /* 0x3f106ebb */
-two   =  2.0000000000e+00, /* 0x40000000 */
-one   =  1.0000000000e+00; /* 0x3F800000 */
-
-static const float zero  =  0.0000000000e+00;
-
-float
-__ieee754_jnf(int n, float x)
-{
-	int32_t i,hx,ix, sgn;
-	float a, b, temp, di;
-	float z, w;
-
-    /* J(-n,x) = (-1)^n * J(n, x), J(n, -x) = (-1)^n * J(n, x)
-     * Thus, J(-n,x) = J(n,-x)
-     */
-	GET_FLOAT_WORD(hx,x);
-	ix = 0x7fffffff&hx;
-    /* if J(n,NaN) is NaN */
-	if(ix>0x7f800000) return x+x;
-	if(n<0){
-		n = -n;
-		x = -x;
-		hx ^= 0x80000000;
-	}
-	if(n==0) return(__ieee754_j0f(x));
-	if(n==1) return(__ieee754_j1f(x));
-	sgn = (n&1)&(hx>>31);	/* even n -- 0, odd n -- sign(x) */
-	x = fabsf(x);
-	if(ix==0||ix>=0x7f800000) 	/* if x is 0 or inf */
-	    b = zero;
-	else if((float)n<=x) {
-		/* Safe to use J(n+1,x)=2n/x *J(n,x)-J(n-1,x) */
-	    a = __ieee754_j0f(x);
-	    b = __ieee754_j1f(x);
-	    for(i=1;i<n;i++){
-		temp = b;
-		b = b*((float)(i+i)/x) - a; /* avoid underflow */
-		a = temp;
-	    }
-	} else {
-	    if(ix<0x30800000) {	/* x < 2**-29 */
-    /* x is tiny, return the first Taylor expansion of J(n,x)
-     * J(n,x) = 1/n!*(x/2)^n  - ...
-     */
-		if(n>33)	/* underflow */
-		    b = zero;
-		else {
-		    temp = x*(float)0.5; b = temp;
-		    for (a=one,i=2;i<=n;i++) {
-			a *= (float)i;		/* a = n! */
-			b *= temp;		/* b = (x/2)^n */
-		    }
-		    b = b/a;
-		}
-	    } else {
-		/* use backward recurrence */
-		/* 			x      x^2      x^2
-		 *  J(n,x)/J(n-1,x) =  ----   ------   ------   .....
-		 *			2n  - 2(n+1) - 2(n+2)
-		 *
-		 * 			1      1        1
-		 *  (for large x)   =  ----  ------   ------   .....
-		 *			2n   2(n+1)   2(n+2)
-		 *			-- - ------ - ------ -
-		 *			 x     x         x
-		 *
-		 * Let w = 2n/x and h=2/x, then the above quotient
-		 * is equal to the continued fraction:
-		 *		    1
-		 *	= -----------------------
-		 *		       1
-		 *	   w - -----------------
-		 *			  1
-		 * 	        w+h - ---------
-		 *		       w+2h - ...
-		 *
-		 * To determine how many terms needed, let
-		 * Q(0) = w, Q(1) = w(w+h) - 1,
-		 * Q(k) = (w+k*h)*Q(k-1) - Q(k-2),
-		 * When Q(k) > 1e4	good for single
-		 * When Q(k) > 1e9	good for double
-		 * When Q(k) > 1e17	good for quadruple
-		 */
-	    /* determine k */
-		float t,v;
-		float q0,q1,h,tmp; int32_t k,m;
-		w  = (n+n)/(float)x; h = (float)2.0/(float)x;
-		q0 = w;  z = w+h; q1 = w*z - (float)1.0; k=1;
-		while(q1<(float)1.0e9) {
-			k += 1; z += h;
-			tmp = z*q1 - q0;
-			q0 = q1;
-			q1 = tmp;
-		}
-		m = n+n;
-		for(t=zero, i = 2*(n+k); i>=m; i -= 2) t = one/(i/x-t);
-		a = t;
-		b = one;
-		/*  estimate log((2/x)^n*n!) = n*log(2/x)+n*ln(n)
-		 *  Hence, if n*(log(2n/x)) > ...
-		 *  single 8.8722839355e+01
-		 *  double 7.09782712893383973096e+02
-		 *  long double 1.1356523406294143949491931077970765006170e+04
-		 *  then recurrent value may overflow and the result is
-		 *  likely underflow to zero
-		 */
-		tmp = n;
-		v = two/x;
-		tmp = tmp*__ieee754_logf(fabsf(v*tmp));
-		if(tmp<(float)8.8721679688e+01) {
-	    	    for(i=n-1,di=(float)(i+i);i>0;i--){
-		        temp = b;
-			b *= di;
-			b  = b/x - a;
-		        a = temp;
-			di -= two;
-	     	    }
-		} else {
-	    	    for(i=n-1,di=(float)(i+i);i>0;i--){
-		        temp = b;
-			b *= di;
-			b  = b/x - a;
-		        a = temp;
-			di -= two;
-		    /* scale b to avoid spurious overflow */
-			if(b>(float)1e10) {
-			    a /= b;
-			    t /= b;
-			    b  = one;
-			}
-	     	    }
-		}
-	    	b = (t*__ieee754_j0f(x)/b);
-	    }
-	}
-	if(sgn==1) return -b; else return b;
-}
-
-float
-__ieee754_ynf(int n, float x)
-{
-	int32_t i,hx,ix,ib;
-	int32_t sign;
-	float a, b, temp;
-
-	GET_FLOAT_WORD(hx,x);
-	ix = 0x7fffffff&hx;
-    /* if Y(n,NaN) is NaN */
-	if(ix>0x7f800000) return x+x;
-	if(ix==0) return -one/zero;
-	if(hx<0) return zero/zero;
-	sign = 1;
-	if(n<0){
-		n = -n;
-		sign = 1 - ((n&1)<<1);
-	}
-	if(n==0) return(__ieee754_y0f(x));
-	if(n==1) return(sign*__ieee754_y1f(x));
-	if(ix==0x7f800000) return zero;
-
-	a = __ieee754_y0f(x);
-	b = __ieee754_y1f(x);
-	/* quit if b is -inf */
-	GET_FLOAT_WORD(ib,b);
-	for(i=1; i<n && (((uint32_t)ib) != 0xff800000); i++){
-	    temp = b;
-	    b = ((float)(i+i)/x)*b - a;
-	    GET_FLOAT_WORD(ib,b);
-	    a = temp;
-	}
-	if(sign>0) return b; else return -b;
-}
diff --git a/libm/src/e_ldexpf.c b/libm/src/e_ldexpf.c
deleted file mode 100644
index 86297fc..0000000
--- a/libm/src/e_ldexpf.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/* e_scalbf.c -- float version of e_scalb.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-#include "math.h"
-#include "math_private.h"
-
-float
-__ieee754_ldexpf(float x, int fn)
-{
-    return __ieee754_scalbf(x,fn);
-}
diff --git a/libm/src/e_lgamma.c b/libm/src/e_lgamma.c
deleted file mode 100644
index 87ad41a..0000000
--- a/libm/src/e_lgamma.c
+++ /dev/null
@@ -1,34 +0,0 @@
-
-/* @(#)e_lgamma.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- *
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_lgamma.c,v 1.8 2005/02/04 18:26:06 das Exp $";
-#endif
-
-/* __ieee754_lgamma(x)
- * Return the logarithm of the Gamma function of x.
- *
- * Method: call __ieee754_lgamma_r
- */
-
-#include "math.h"
-#include "math_private.h"
-
-extern int signgam;
-
-double
-__ieee754_lgamma(double x)
-{
-	return __ieee754_lgamma_r(x,&signgam);
-}
diff --git a/libm/src/e_lgamma_r.c b/libm/src/e_lgamma_r.c
deleted file mode 100644
index 68dbfd0..0000000
--- a/libm/src/e_lgamma_r.c
+++ /dev/null
@@ -1,297 +0,0 @@
-
-/* @(#)e_lgamma_r.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- *
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_lgamma_r.c,v 1.8 2005/02/04 18:26:06 das Exp $";
-#endif
-
-/* __ieee754_lgamma_r(x, signgamp)
- * Reentrant version of the logarithm of the Gamma function 
- * with user provide pointer for the sign of Gamma(x). 
- *
- * Method:
- *   1. Argument Reduction for 0 < x <= 8
- * 	Since gamma(1+s)=s*gamma(s), for x in [0,8], we may 
- * 	reduce x to a number in [1.5,2.5] by
- * 		lgamma(1+s) = log(s) + lgamma(s)
- *	for example,
- *		lgamma(7.3) = log(6.3) + lgamma(6.3)
- *			    = log(6.3*5.3) + lgamma(5.3)
- *			    = log(6.3*5.3*4.3*3.3*2.3) + lgamma(2.3)
- *   2. Polynomial approximation of lgamma around its
- *	minimun ymin=1.461632144968362245 to maintain monotonicity.
- *	On [ymin-0.23, ymin+0.27] (i.e., [1.23164,1.73163]), use
- *		Let z = x-ymin;
- *		lgamma(x) = -1.214862905358496078218 + z^2*poly(z)
- *	where
- *		poly(z) is a 14 degree polynomial.
- *   2. Rational approximation in the primary interval [2,3]
- *	We use the following approximation:
- *		s = x-2.0;
- *		lgamma(x) = 0.5*s + s*P(s)/Q(s)
- *	with accuracy
- *		|P/Q - (lgamma(x)-0.5s)| < 2**-61.71
- *	Our algorithms are based on the following observation
- *
- *                             zeta(2)-1    2    zeta(3)-1    3
- * lgamma(2+s) = s*(1-Euler) + --------- * s  -  --------- * s  + ...
- *                                 2                 3
- *
- *	where Euler = 0.5771... is the Euler constant, which is very
- *	close to 0.5.
- *
- *   3. For x>=8, we have
- *	lgamma(x)~(x-0.5)log(x)-x+0.5*log(2pi)+1/(12x)-1/(360x**3)+....
- *	(better formula:
- *	   lgamma(x)~(x-0.5)*(log(x)-1)-.5*(log(2pi)-1) + ...)
- *	Let z = 1/x, then we approximation
- *		f(z) = lgamma(x) - (x-0.5)(log(x)-1)
- *	by
- *	  			    3       5             11
- *		w = w0 + w1*z + w2*z  + w3*z  + ... + w6*z
- *	where 
- *		|w - f(z)| < 2**-58.74
- *		
- *   4. For negative x, since (G is gamma function)
- *		-x*G(-x)*G(x) = pi/sin(pi*x),
- * 	we have
- * 		G(x) = pi/(sin(pi*x)*(-x)*G(-x))
- *	since G(-x) is positive, sign(G(x)) = sign(sin(pi*x)) for x<0
- *	Hence, for x<0, signgam = sign(sin(pi*x)) and 
- *		lgamma(x) = log(|Gamma(x)|)
- *			  = log(pi/(|x*sin(pi*x)|)) - lgamma(-x);
- *	Note: one should avoid compute pi*(-x) directly in the 
- *	      computation of sin(pi*(-x)).
- *		
- *   5. Special Cases
- *		lgamma(2+s) ~ s*(1-Euler) for tiny s
- *		lgamma(1)=lgamma(2)=0
- *		lgamma(x) ~ -log(x) for tiny x
- *		lgamma(0) = lgamma(inf) = inf
- *	 	lgamma(-integer) = +-inf
- *	
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-two52=  4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
-half=  5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
-one =  1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
-pi  =  3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */
-a0  =  7.72156649015328655494e-02, /* 0x3FB3C467, 0xE37DB0C8 */
-a1  =  3.22467033424113591611e-01, /* 0x3FD4A34C, 0xC4A60FAD */
-a2  =  6.73523010531292681824e-02, /* 0x3FB13E00, 0x1A5562A7 */
-a3  =  2.05808084325167332806e-02, /* 0x3F951322, 0xAC92547B */
-a4  =  7.38555086081402883957e-03, /* 0x3F7E404F, 0xB68FEFE8 */
-a5  =  2.89051383673415629091e-03, /* 0x3F67ADD8, 0xCCB7926B */
-a6  =  1.19270763183362067845e-03, /* 0x3F538A94, 0x116F3F5D */
-a7  =  5.10069792153511336608e-04, /* 0x3F40B6C6, 0x89B99C00 */
-a8  =  2.20862790713908385557e-04, /* 0x3F2CF2EC, 0xED10E54D */
-a9  =  1.08011567247583939954e-04, /* 0x3F1C5088, 0x987DFB07 */
-a10 =  2.52144565451257326939e-05, /* 0x3EFA7074, 0x428CFA52 */
-a11 =  4.48640949618915160150e-05, /* 0x3F07858E, 0x90A45837 */
-tc  =  1.46163214496836224576e+00, /* 0x3FF762D8, 0x6356BE3F */
-tf  = -1.21486290535849611461e-01, /* 0xBFBF19B9, 0xBCC38A42 */
-/* tt = -(tail of tf) */
-tt  = -3.63867699703950536541e-18, /* 0xBC50C7CA, 0xA48A971F */
-t0  =  4.83836122723810047042e-01, /* 0x3FDEF72B, 0xC8EE38A2 */
-t1  = -1.47587722994593911752e-01, /* 0xBFC2E427, 0x8DC6C509 */
-t2  =  6.46249402391333854778e-02, /* 0x3FB08B42, 0x94D5419B */
-t3  = -3.27885410759859649565e-02, /* 0xBFA0C9A8, 0xDF35B713 */
-t4  =  1.79706750811820387126e-02, /* 0x3F9266E7, 0x970AF9EC */
-t5  = -1.03142241298341437450e-02, /* 0xBF851F9F, 0xBA91EC6A */
-t6  =  6.10053870246291332635e-03, /* 0x3F78FCE0, 0xE370E344 */
-t7  = -3.68452016781138256760e-03, /* 0xBF6E2EFF, 0xB3E914D7 */
-t8  =  2.25964780900612472250e-03, /* 0x3F6282D3, 0x2E15C915 */
-t9  = -1.40346469989232843813e-03, /* 0xBF56FE8E, 0xBF2D1AF1 */
-t10 =  8.81081882437654011382e-04, /* 0x3F4CDF0C, 0xEF61A8E9 */
-t11 = -5.38595305356740546715e-04, /* 0xBF41A610, 0x9C73E0EC */
-t12 =  3.15632070903625950361e-04, /* 0x3F34AF6D, 0x6C0EBBF7 */
-t13 = -3.12754168375120860518e-04, /* 0xBF347F24, 0xECC38C38 */
-t14 =  3.35529192635519073543e-04, /* 0x3F35FD3E, 0xE8C2D3F4 */
-u0  = -7.72156649015328655494e-02, /* 0xBFB3C467, 0xE37DB0C8 */
-u1  =  6.32827064025093366517e-01, /* 0x3FE4401E, 0x8B005DFF */
-u2  =  1.45492250137234768737e+00, /* 0x3FF7475C, 0xD119BD6F */
-u3  =  9.77717527963372745603e-01, /* 0x3FEF4976, 0x44EA8450 */
-u4  =  2.28963728064692451092e-01, /* 0x3FCD4EAE, 0xF6010924 */
-u5  =  1.33810918536787660377e-02, /* 0x3F8B678B, 0xBF2BAB09 */
-v1  =  2.45597793713041134822e+00, /* 0x4003A5D7, 0xC2BD619C */
-v2  =  2.12848976379893395361e+00, /* 0x40010725, 0xA42B18F5 */
-v3  =  7.69285150456672783825e-01, /* 0x3FE89DFB, 0xE45050AF */
-v4  =  1.04222645593369134254e-01, /* 0x3FBAAE55, 0xD6537C88 */
-v5  =  3.21709242282423911810e-03, /* 0x3F6A5ABB, 0x57D0CF61 */
-s0  = -7.72156649015328655494e-02, /* 0xBFB3C467, 0xE37DB0C8 */
-s1  =  2.14982415960608852501e-01, /* 0x3FCB848B, 0x36E20878 */
-s2  =  3.25778796408930981787e-01, /* 0x3FD4D98F, 0x4F139F59 */
-s3  =  1.46350472652464452805e-01, /* 0x3FC2BB9C, 0xBEE5F2F7 */
-s4  =  2.66422703033638609560e-02, /* 0x3F9B481C, 0x7E939961 */
-s5  =  1.84028451407337715652e-03, /* 0x3F5E26B6, 0x7368F239 */
-s6  =  3.19475326584100867617e-05, /* 0x3F00BFEC, 0xDD17E945 */
-r1  =  1.39200533467621045958e+00, /* 0x3FF645A7, 0x62C4AB74 */
-r2  =  7.21935547567138069525e-01, /* 0x3FE71A18, 0x93D3DCDC */
-r3  =  1.71933865632803078993e-01, /* 0x3FC601ED, 0xCCFBDF27 */
-r4  =  1.86459191715652901344e-02, /* 0x3F9317EA, 0x742ED475 */
-r5  =  7.77942496381893596434e-04, /* 0x3F497DDA, 0xCA41A95B */
-r6  =  7.32668430744625636189e-06, /* 0x3EDEBAF7, 0xA5B38140 */
-w0  =  4.18938533204672725052e-01, /* 0x3FDACFE3, 0x90C97D69 */
-w1  =  8.33333333333329678849e-02, /* 0x3FB55555, 0x5555553B */
-w2  = -2.77777777728775536470e-03, /* 0xBF66C16C, 0x16B02E5C */
-w3  =  7.93650558643019558500e-04, /* 0x3F4A019F, 0x98CF38B6 */
-w4  = -5.95187557450339963135e-04, /* 0xBF4380CB, 0x8C0FE741 */
-w5  =  8.36339918996282139126e-04, /* 0x3F4B67BA, 0x4CDAD5D1 */
-w6  = -1.63092934096575273989e-03; /* 0xBF5AB89D, 0x0B9E43E4 */
-
-static const double zero=  0.00000000000000000000e+00;
-
-	static double sin_pi(double x)
-{
-	double y,z;
-	int n,ix;
-
-	GET_HIGH_WORD(ix,x);
-	ix &= 0x7fffffff;
-
-	if(ix<0x3fd00000) return __kernel_sin(pi*x,zero,0);
-	y = -x;		/* x is assume negative */
-
-    /*
-     * argument reduction, make sure inexact flag not raised if input
-     * is an integer
-     */
-	z = floor(y);
-	if(z!=y) {				/* inexact anyway */
-	    y  *= 0.5;
-	    y   = 2.0*(y - floor(y));		/* y = |x| mod 2.0 */
-	    n   = (int) (y*4.0);
-	} else {
-            if(ix>=0x43400000) {
-                y = zero; n = 0;                 /* y must be even */
-            } else {
-                if(ix<0x43300000) z = y+two52;	/* exact */
-		GET_LOW_WORD(n,z);
-		n &= 1;
-                y  = n;
-                n<<= 2;
-            }
-        }
-	switch (n) {
-	    case 0:   y =  __kernel_sin(pi*y,zero,0); break;
-	    case 1:   
-	    case 2:   y =  __kernel_cos(pi*(0.5-y),zero); break;
-	    case 3:  
-	    case 4:   y =  __kernel_sin(pi*(one-y),zero,0); break;
-	    case 5:
-	    case 6:   y = -__kernel_cos(pi*(y-1.5),zero); break;
-	    default:  y =  __kernel_sin(pi*(y-2.0),zero,0); break;
-	    }
-	return -y;
-}
-
-
-double
-__ieee754_lgamma_r(double x, int *signgamp)
-{
-	double t,y,z,nadj,p,p1,p2,p3,q,r,w;
-	int i,hx,lx,ix;
-
-	EXTRACT_WORDS(hx,lx,x);
-
-    /* purge off +-inf, NaN, +-0, and negative arguments */
-	*signgamp = 1;
-	ix = hx&0x7fffffff;
-	if(ix>=0x7ff00000) return x*x;
-	if((ix|lx)==0) return one/zero;
-	if(ix<0x3b900000) {	/* |x|<2**-70, return -log(|x|) */
-	    if(hx<0) {
-	        *signgamp = -1;
-	        return -__ieee754_log(-x);
-	    } else return -__ieee754_log(x);
-	}
-	if(hx<0) {
-	    if(ix>=0x43300000) 	/* |x|>=2**52, must be -integer */
-		return one/zero;
-	    t = sin_pi(x);
-	    if(t==zero) return one/zero; /* -integer */
-	    nadj = __ieee754_log(pi/fabs(t*x));
-	    if(t<zero) *signgamp = -1;
-	    x = -x;
-	}
-
-    /* purge off 1 and 2 */
-	if((((ix-0x3ff00000)|lx)==0)||(((ix-0x40000000)|lx)==0)) r = 0;
-    /* for x < 2.0 */
-	else if(ix<0x40000000) {
-	    if(ix<=0x3feccccc) { 	/* lgamma(x) = lgamma(x+1)-log(x) */
-		r = -__ieee754_log(x);
-		if(ix>=0x3FE76944) {y = one-x; i= 0;}
-		else if(ix>=0x3FCDA661) {y= x-(tc-one); i=1;}
-	  	else {y = x; i=2;}
-	    } else {
-	  	r = zero;
-	        if(ix>=0x3FFBB4C3) {y=2.0-x;i=0;} /* [1.7316,2] */
-	        else if(ix>=0x3FF3B4C4) {y=x-tc;i=1;} /* [1.23,1.73] */
-		else {y=x-one;i=2;}
-	    }
-	    switch(i) {
-	      case 0:
-		z = y*y;
-		p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10))));
-		p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11)))));
-		p  = y*p1+p2;
-		r  += (p-0.5*y); break;
-	      case 1:
-		z = y*y;
-		w = z*y;
-		p1 = t0+w*(t3+w*(t6+w*(t9 +w*t12)));	/* parallel comp */
-		p2 = t1+w*(t4+w*(t7+w*(t10+w*t13)));
-		p3 = t2+w*(t5+w*(t8+w*(t11+w*t14)));
-		p  = z*p1-(tt-w*(p2+y*p3));
-		r += (tf + p); break;
-	      case 2:	
-		p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5)))));
-		p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*v5))));
-		r += (-0.5*y + p1/p2);
-	    }
-	}
-	else if(ix<0x40200000) { 			/* x < 8.0 */
-	    i = (int)x;
-	    t = zero;
-	    y = x-(double)i;
-	    p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6))))));
-	    q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6)))));
-	    r = half*y+p/q;
-	    z = one;	/* lgamma(1+s) = log(s) + lgamma(s) */
-	    switch(i) {
-	    case 7: z *= (y+6.0);	/* FALLTHRU */
-	    case 6: z *= (y+5.0);	/* FALLTHRU */
-	    case 5: z *= (y+4.0);	/* FALLTHRU */
-	    case 4: z *= (y+3.0);	/* FALLTHRU */
-	    case 3: z *= (y+2.0);	/* FALLTHRU */
-		    r += __ieee754_log(z); break;
-	    }
-    /* 8.0 <= x < 2**58 */
-	} else if (ix < 0x43900000) {
-	    t = __ieee754_log(x);
-	    z = one/x;
-	    y = z*z;
-	    w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6)))));
-	    r = (x-half)*(t-one)+w;
-	} else 
-    /* 2**58 <= x <= inf */
-	    r =  x*(__ieee754_log(x)-one);
-	if(hx<0) r = nadj - r;
-	return r;
-}
diff --git a/libm/src/e_lgammaf.c b/libm/src/e_lgammaf.c
deleted file mode 100644
index b1f48d5..0000000
--- a/libm/src/e_lgammaf.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* e_lgammaf.c -- float version of e_lgamma.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_lgammaf.c,v 1.7 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-/* __ieee754_lgammaf(x)
- * Return the logarithm of the Gamma function of x.
- *
- * Method: call __ieee754_lgammaf_r
- */
-
-#include "math.h"
-#include "math_private.h"
-
-extern int signgam;
-
-float
-__ieee754_lgammaf(float x)
-{
-	return __ieee754_lgammaf_r(x,&signgam);
-}
diff --git a/libm/src/e_lgammaf_r.c b/libm/src/e_lgammaf_r.c
deleted file mode 100644
index 3b55208..0000000
--- a/libm/src/e_lgammaf_r.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/* e_lgammaf_r.c -- float version of e_lgamma_r.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_lgammaf_r.c,v 1.9 2005/11/28 08:32:15 bde Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float
-two23=  8.3886080000e+06, /* 0x4b000000 */
-half=  5.0000000000e-01, /* 0x3f000000 */
-one =  1.0000000000e+00, /* 0x3f800000 */
-pi  =  3.1415927410e+00, /* 0x40490fdb */
-a0  =  7.7215664089e-02, /* 0x3d9e233f */
-a1  =  3.2246702909e-01, /* 0x3ea51a66 */
-a2  =  6.7352302372e-02, /* 0x3d89f001 */
-a3  =  2.0580807701e-02, /* 0x3ca89915 */
-a4  =  7.3855509982e-03, /* 0x3bf2027e */
-a5  =  2.8905137442e-03, /* 0x3b3d6ec6 */
-a6  =  1.1927076848e-03, /* 0x3a9c54a1 */
-a7  =  5.1006977446e-04, /* 0x3a05b634 */
-a8  =  2.2086278477e-04, /* 0x39679767 */
-a9  =  1.0801156895e-04, /* 0x38e28445 */
-a10 =  2.5214456400e-05, /* 0x37d383a2 */
-a11 =  4.4864096708e-05, /* 0x383c2c75 */
-tc  =  1.4616321325e+00, /* 0x3fbb16c3 */
-tf  = -1.2148628384e-01, /* 0xbdf8cdcd */
-/* tt = -(tail of tf) */
-tt  =  6.6971006518e-09, /* 0x31e61c52 */
-t0  =  4.8383611441e-01, /* 0x3ef7b95e */
-t1  = -1.4758771658e-01, /* 0xbe17213c */
-t2  =  6.4624942839e-02, /* 0x3d845a15 */
-t3  = -3.2788541168e-02, /* 0xbd064d47 */
-t4  =  1.7970675603e-02, /* 0x3c93373d */
-t5  = -1.0314224288e-02, /* 0xbc28fcfe */
-t6  =  6.1005386524e-03, /* 0x3bc7e707 */
-t7  = -3.6845202558e-03, /* 0xbb7177fe */
-t8  =  2.2596477065e-03, /* 0x3b141699 */
-t9  = -1.4034647029e-03, /* 0xbab7f476 */
-t10 =  8.8108185446e-04, /* 0x3a66f867 */
-t11 = -5.3859531181e-04, /* 0xba0d3085 */
-t12 =  3.1563205994e-04, /* 0x39a57b6b */
-t13 = -3.1275415677e-04, /* 0xb9a3f927 */
-t14 =  3.3552918467e-04, /* 0x39afe9f7 */
-u0  = -7.7215664089e-02, /* 0xbd9e233f */
-u1  =  6.3282704353e-01, /* 0x3f2200f4 */
-u2  =  1.4549225569e+00, /* 0x3fba3ae7 */
-u3  =  9.7771751881e-01, /* 0x3f7a4bb2 */
-u4  =  2.2896373272e-01, /* 0x3e6a7578 */
-u5  =  1.3381091878e-02, /* 0x3c5b3c5e */
-v1  =  2.4559779167e+00, /* 0x401d2ebe */
-v2  =  2.1284897327e+00, /* 0x4008392d */
-v3  =  7.6928514242e-01, /* 0x3f44efdf */
-v4  =  1.0422264785e-01, /* 0x3dd572af */
-v5  =  3.2170924824e-03, /* 0x3b52d5db */
-s0  = -7.7215664089e-02, /* 0xbd9e233f */
-s1  =  2.1498242021e-01, /* 0x3e5c245a */
-s2  =  3.2577878237e-01, /* 0x3ea6cc7a */
-s3  =  1.4635047317e-01, /* 0x3e15dce6 */
-s4  =  2.6642270386e-02, /* 0x3cda40e4 */
-s5  =  1.8402845599e-03, /* 0x3af135b4 */
-s6  =  3.1947532989e-05, /* 0x3805ff67 */
-r1  =  1.3920053244e+00, /* 0x3fb22d3b */
-r2  =  7.2193557024e-01, /* 0x3f38d0c5 */
-r3  =  1.7193385959e-01, /* 0x3e300f6e */
-r4  =  1.8645919859e-02, /* 0x3c98bf54 */
-r5  =  7.7794247773e-04, /* 0x3a4beed6 */
-r6  =  7.3266842264e-06, /* 0x36f5d7bd */
-w0  =  4.1893854737e-01, /* 0x3ed67f1d */
-w1  =  8.3333335817e-02, /* 0x3daaaaab */
-w2  = -2.7777778450e-03, /* 0xbb360b61 */
-w3  =  7.9365057172e-04, /* 0x3a500cfd */
-w4  = -5.9518753551e-04, /* 0xba1c065c */
-w5  =  8.3633989561e-04, /* 0x3a5b3dd2 */
-w6  = -1.6309292987e-03; /* 0xbad5c4e8 */
-
-static const float zero=  0.0000000000e+00;
-
-	static float sin_pif(float x)
-{
-	float y,z;
-	int n,ix;
-
-	GET_FLOAT_WORD(ix,x);
-	ix &= 0x7fffffff;
-
-	if(ix<0x3e800000) return __kernel_sindf(pi*x);
-	y = -x;		/* x is assume negative */
-
-    /*
-     * argument reduction, make sure inexact flag not raised if input
-     * is an integer
-     */
-	z = floorf(y);
-	if(z!=y) {				/* inexact anyway */
-	    y  *= (float)0.5;
-	    y   = (float)2.0*(y - floorf(y));	/* y = |x| mod 2.0 */
-	    n   = (int) (y*(float)4.0);
-	} else {
-            if(ix>=0x4b800000) {
-                y = zero; n = 0;                 /* y must be even */
-            } else {
-                if(ix<0x4b000000) z = y+two23;	/* exact */
-		GET_FLOAT_WORD(n,z);
-		n &= 1;
-                y  = n;
-                n<<= 2;
-            }
-        }
-	switch (n) {
-	    case 0:   y =  __kernel_sindf(pi*y); break;
-	    case 1:
-	    case 2:   y =  __kernel_cosdf(pi*((float)0.5-y)); break;
-	    case 3:
-	    case 4:   y =  __kernel_sindf(pi*(one-y)); break;
-	    case 5:
-	    case 6:   y = -__kernel_cosdf(pi*(y-(float)1.5)); break;
-	    default:  y =  __kernel_sindf(pi*(y-(float)2.0)); break;
-	    }
-	return -y;
-}
-
-
-float
-__ieee754_lgammaf_r(float x, int *signgamp)
-{
-	float t,y,z,nadj,p,p1,p2,p3,q,r,w;
-	int i,hx,ix;
-
-	GET_FLOAT_WORD(hx,x);
-
-    /* purge off +-inf, NaN, +-0, and negative arguments */
-	*signgamp = 1;
-	ix = hx&0x7fffffff;
-	if(ix>=0x7f800000) return x*x;
-	if(ix==0) return one/zero;
-	if(ix<0x35000000) {	/* |x|<2**-21, return -log(|x|) */
-	    if(hx<0) {
-	        *signgamp = -1;
-	        return -__ieee754_logf(-x);
-	    } else return -__ieee754_logf(x);
-	}
-	if(hx<0) {
-	    if(ix>=0x4b000000) 	/* |x|>=2**23, must be -integer */
-		return one/zero;
-	    t = sin_pif(x);
-	    if(t==zero) return one/zero; /* -integer */
-	    nadj = __ieee754_logf(pi/fabsf(t*x));
-	    if(t<zero) *signgamp = -1;
-	    x = -x;
-	}
-
-    /* purge off 1 and 2 */
-	if (ix==0x3f800000||ix==0x40000000) r = 0;
-    /* for x < 2.0 */
-	else if(ix<0x40000000) {
-	    if(ix<=0x3f666666) { 	/* lgamma(x) = lgamma(x+1)-log(x) */
-		r = -__ieee754_logf(x);
-		if(ix>=0x3f3b4a20) {y = one-x; i= 0;}
-		else if(ix>=0x3e6d3308) {y= x-(tc-one); i=1;}
-	  	else {y = x; i=2;}
-	    } else {
-	  	r = zero;
-	        if(ix>=0x3fdda618) {y=(float)2.0-x;i=0;} /* [1.7316,2] */
-	        else if(ix>=0x3F9da620) {y=x-tc;i=1;} /* [1.23,1.73] */
-		else {y=x-one;i=2;}
-	    }
-	    switch(i) {
-	      case 0:
-		z = y*y;
-		p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10))));
-		p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11)))));
-		p  = y*p1+p2;
-		r  += (p-(float)0.5*y); break;
-	      case 1:
-		z = y*y;
-		w = z*y;
-		p1 = t0+w*(t3+w*(t6+w*(t9 +w*t12)));	/* parallel comp */
-		p2 = t1+w*(t4+w*(t7+w*(t10+w*t13)));
-		p3 = t2+w*(t5+w*(t8+w*(t11+w*t14)));
-		p  = z*p1-(tt-w*(p2+y*p3));
-		r += (tf + p); break;
-	      case 2:
-		p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5)))));
-		p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*v5))));
-		r += (-(float)0.5*y + p1/p2);
-	    }
-	}
-	else if(ix<0x41000000) { 			/* x < 8.0 */
-	    i = (int)x;
-	    t = zero;
-	    y = x-(float)i;
-	    p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6))))));
-	    q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6)))));
-	    r = half*y+p/q;
-	    z = one;	/* lgamma(1+s) = log(s) + lgamma(s) */
-	    switch(i) {
-	    case 7: z *= (y+(float)6.0);	/* FALLTHRU */
-	    case 6: z *= (y+(float)5.0);	/* FALLTHRU */
-	    case 5: z *= (y+(float)4.0);	/* FALLTHRU */
-	    case 4: z *= (y+(float)3.0);	/* FALLTHRU */
-	    case 3: z *= (y+(float)2.0);	/* FALLTHRU */
-		    r += __ieee754_logf(z); break;
-	    }
-    /* 8.0 <= x < 2**58 */
-	} else if (ix < 0x5c800000) {
-	    t = __ieee754_logf(x);
-	    z = one/x;
-	    y = z*z;
-	    w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6)))));
-	    r = (x-half)*(t-one)+w;
-	} else
-    /* 2**58 <= x <= inf */
-	    r =  x*(__ieee754_logf(x)-one);
-	if(hx<0) r = nadj - r;
-	return r;
-}
diff --git a/libm/src/e_log.c b/libm/src/e_log.c
deleted file mode 100644
index 2dbf057..0000000
--- a/libm/src/e_log.c
+++ /dev/null
@@ -1,135 +0,0 @@
-
-/* @(#)e_log.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_log.c,v 1.10 2005/02/04 18:26:06 das Exp $";
-#endif
-
-/* __ieee754_log(x)
- * Return the logrithm of x
- *
- * Method :                  
- *   1. Argument Reduction: find k and f such that 
- *			x = 2^k * (1+f), 
- *	   where  sqrt(2)/2 < 1+f < sqrt(2) .
- *
- *   2. Approximation of log(1+f).
- *	Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
- *		 = 2s + 2/3 s**3 + 2/5 s**5 + .....,
- *	     	 = 2s + s*R
- *      We use a special Reme algorithm on [0,0.1716] to generate 
- * 	a polynomial of degree 14 to approximate R The maximum error 
- *	of this polynomial approximation is bounded by 2**-58.45. In
- *	other words,
- *		        2      4      6      8      10      12      14
- *	    R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s  +Lg6*s  +Lg7*s
- *  	(the values of Lg1 to Lg7 are listed in the program)
- *	and
- *	    |      2          14          |     -58.45
- *	    | Lg1*s +...+Lg7*s    -  R(z) | <= 2 
- *	    |                             |
- *	Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
- *	In order to guarantee error in log below 1ulp, we compute log
- *	by
- *		log(1+f) = f - s*(f - R)	(if f is not too large)
- *		log(1+f) = f - (hfsq - s*(hfsq+R)).	(better accuracy)
- *	
- *	3. Finally,  log(x) = k*ln2 + log(1+f).  
- *			    = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo)))
- *	   Here ln2 is split into two floating point number: 
- *			ln2_hi + ln2_lo,
- *	   where n*ln2_hi is always exact for |n| < 2000.
- *
- * Special cases:
- *	log(x) is NaN with signal if x < 0 (including -INF) ; 
- *	log(+INF) is +INF; log(0) is -INF with signal;
- *	log(NaN) is that NaN with no signal.
- *
- * Accuracy:
- *	according to an error analysis, the error is always less than
- *	1 ulp (unit in the last place).
- *
- * Constants:
- * The hexadecimal values are the intended ones for the following 
- * constants. The decimal values may be used, provided that the 
- * compiler will convert from decimal to binary accurately enough 
- * to produce the hexadecimal values shown.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-ln2_hi  =  6.93147180369123816490e-01,	/* 3fe62e42 fee00000 */
-ln2_lo  =  1.90821492927058770002e-10,	/* 3dea39ef 35793c76 */
-two54   =  1.80143985094819840000e+16,  /* 43500000 00000000 */
-Lg1 = 6.666666666666735130e-01,  /* 3FE55555 55555593 */
-Lg2 = 3.999999999940941908e-01,  /* 3FD99999 9997FA04 */
-Lg3 = 2.857142874366239149e-01,  /* 3FD24924 94229359 */
-Lg4 = 2.222219843214978396e-01,  /* 3FCC71C5 1D8E78AF */
-Lg5 = 1.818357216161805012e-01,  /* 3FC74664 96CB03DE */
-Lg6 = 1.531383769920937332e-01,  /* 3FC39A09 D078C69F */
-Lg7 = 1.479819860511658591e-01;  /* 3FC2F112 DF3E5244 */
-
-static const double zero   =  0.0;
-
-double
-__ieee754_log(double x)
-{
-	double hfsq,f,s,z,R,w,t1,t2,dk;
-	int32_t k,hx,i,j;
-	u_int32_t lx;
-
-	EXTRACT_WORDS(hx,lx,x);
-
-	k=0;
-	if (hx < 0x00100000) {			/* x < 2**-1022  */
-	    if (((hx&0x7fffffff)|lx)==0) 
-		return -two54/zero;		/* log(+-0)=-inf */
-	    if (hx<0) return (x-x)/zero;	/* log(-#) = NaN */
-	    k -= 54; x *= two54; /* subnormal number, scale up x */
-	    GET_HIGH_WORD(hx,x);
-	} 
-	if (hx >= 0x7ff00000) return x+x;
-	k += (hx>>20)-1023;
-	hx &= 0x000fffff;
-	i = (hx+0x95f64)&0x100000;
-	SET_HIGH_WORD(x,hx|(i^0x3ff00000));	/* normalize x or x/2 */
-	k += (i>>20);
-	f = x-1.0;
-	if((0x000fffff&(2+hx))<3) {	/* |f| < 2**-20 */
-	    if(f==zero) if(k==0) return zero;  else {dk=(double)k;
-				 return dk*ln2_hi+dk*ln2_lo;}
-	    R = f*f*(0.5-0.33333333333333333*f);
-	    if(k==0) return f-R; else {dk=(double)k;
-	    	     return dk*ln2_hi-((R-dk*ln2_lo)-f);}
-	}
- 	s = f/(2.0+f); 
-	dk = (double)k;
-	z = s*s;
-	i = hx-0x6147a;
-	w = z*z;
-	j = 0x6b851-hx;
-	t1= w*(Lg2+w*(Lg4+w*Lg6)); 
-	t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7))); 
-	i |= j;
-	R = t2+t1;
-	if(i>0) {
-	    hfsq=0.5*f*f;
-	    if(k==0) return f-(hfsq-s*(hfsq+R)); else
-		     return dk*ln2_hi-((hfsq-(s*(hfsq+R)+dk*ln2_lo))-f);
-	} else {
-	    if(k==0) return f-s*(f-R); else
-		     return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f);
-	}
-}
diff --git a/libm/src/e_log10.c b/libm/src/e_log10.c
deleted file mode 100644
index e84c0c7..0000000
--- a/libm/src/e_log10.c
+++ /dev/null
@@ -1,87 +0,0 @@
-
-/* @(#)e_log10.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_log10.c,v 1.11 2005/02/04 18:26:06 das Exp $";
-#endif
-
-/* __ieee754_log10(x)
- * Return the base 10 logarithm of x
- * 
- * Method :
- *	Let log10_2hi = leading 40 bits of log10(2) and
- *	    log10_2lo = log10(2) - log10_2hi,
- *	    ivln10   = 1/log(10) rounded.
- *	Then
- *		n = ilogb(x), 
- *		if(n<0)  n = n+1;
- *		x = scalbn(x,-n);
- *		log10(x) := n*log10_2hi + (n*log10_2lo + ivln10*log(x))
- *
- * Note 1:
- *	To guarantee log10(10**n)=n, where 10**n is normal, the rounding 
- *	mode must set to Round-to-Nearest.
- * Note 2:
- *	[1/log(10)] rounded to 53 bits has error  .198   ulps;
- *	log10 is monotonic at all binary break points.
- *
- * Special cases:
- *	log10(x) is NaN with signal if x < 0; 
- *	log10(+INF) is +INF with no signal; log10(0) is -INF with signal;
- *	log10(NaN) is that NaN with no signal;
- *	log10(10**N) = N  for N=0,1,...,22.
- *
- * Constants:
- * The hexadecimal values are the intended ones for the following constants.
- * The decimal values may be used, provided that the compiler will convert
- * from decimal to binary accurately enough to produce the hexadecimal values
- * shown.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-two54      =  1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
-ivln10     =  4.34294481903251816668e-01, /* 0x3FDBCB7B, 0x1526E50E */
-log10_2hi  =  3.01029995663611771306e-01, /* 0x3FD34413, 0x509F6000 */
-log10_2lo  =  3.69423907715893078616e-13; /* 0x3D59FEF3, 0x11F12B36 */
-
-static const double zero   =  0.0;
-
-double
-__ieee754_log10(double x)
-{
-	double y,z;
-	int32_t i,k,hx;
-	u_int32_t lx;
-
-	EXTRACT_WORDS(hx,lx,x);
-
-        k=0;
-        if (hx < 0x00100000) {                  /* x < 2**-1022  */
-            if (((hx&0x7fffffff)|lx)==0)
-                return -two54/zero;             /* log(+-0)=-inf */
-            if (hx<0) return (x-x)/zero;        /* log(-#) = NaN */
-            k -= 54; x *= two54; /* subnormal number, scale up x */
-	    GET_HIGH_WORD(hx,x);
-        }
-	if (hx >= 0x7ff00000) return x+x;
-	k += (hx>>20)-1023;
-	i  = ((u_int32_t)k&0x80000000)>>31;
-        hx = (hx&0x000fffff)|((0x3ff-i)<<20);
-        y  = (double)(k+i);
-	SET_HIGH_WORD(x,hx);
-	z  = y*log10_2lo + ivln10*__ieee754_log(x);
-	return  z+y*log10_2hi;
-}
diff --git a/libm/src/e_log10f.c b/libm/src/e_log10f.c
deleted file mode 100644
index 3473088..0000000
--- a/libm/src/e_log10f.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/* e_log10f.c -- float version of e_log10.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_log10f.c,v 1.8 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float
-two25      =  3.3554432000e+07, /* 0x4c000000 */
-ivln10     =  4.3429449201e-01, /* 0x3ede5bd9 */
-log10_2hi  =  3.0102920532e-01, /* 0x3e9a2080 */
-log10_2lo  =  7.9034151668e-07; /* 0x355427db */
-
-static const float zero   =  0.0;
-
-float
-__ieee754_log10f(float x)
-{
-	float y,z;
-	int32_t i,k,hx;
-
-	GET_FLOAT_WORD(hx,x);
-
-        k=0;
-        if (hx < 0x00800000) {                  /* x < 2**-126  */
-            if ((hx&0x7fffffff)==0)
-                return -two25/zero;             /* log(+-0)=-inf */
-            if (hx<0) return (x-x)/zero;        /* log(-#) = NaN */
-            k -= 25; x *= two25; /* subnormal number, scale up x */
-	    GET_FLOAT_WORD(hx,x);
-        }
-	if (hx >= 0x7f800000) return x+x;
-	k += (hx>>23)-127;
-	i  = ((u_int32_t)k&0x80000000)>>31;
-        hx = (hx&0x007fffff)|((0x7f-i)<<23);
-        y  = (float)(k+i);
-	SET_FLOAT_WORD(x,hx);
-	z  = y*log10_2lo + ivln10*__ieee754_logf(x);
-	return  z+y*log10_2hi;
-}
diff --git a/libm/src/e_logf.c b/libm/src/e_logf.c
deleted file mode 100644
index 7cee2ab..0000000
--- a/libm/src/e_logf.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* e_logf.c -- float version of e_log.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_logf.c,v 1.8 2005/11/12 18:20:09 bde Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float
-ln2_hi =   6.9313812256e-01,	/* 0x3f317180 */
-ln2_lo =   9.0580006145e-06,	/* 0x3717f7d1 */
-two25 =    3.355443200e+07,	/* 0x4c000000 */
-/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */
-Lg1 =      0xaaaaaa.0p-24,	/* 0.66666662693 */
-Lg2 =      0xccce13.0p-25,	/* 0.40000972152 */
-Lg3 =      0x91e9ee.0p-25,	/* 0.28498786688 */
-Lg4 =      0xf89e26.0p-26;	/* 0.24279078841 */
-
-static const float zero   =  0.0;
-
-float
-__ieee754_logf(float x)
-{
-	float hfsq,f,s,z,R,w,t1,t2,dk;
-	int32_t k,ix,i,j;
-
-	GET_FLOAT_WORD(ix,x);
-
-	k=0;
-	if (ix < 0x00800000) {			/* x < 2**-126  */
-	    if ((ix&0x7fffffff)==0)
-		return -two25/zero;		/* log(+-0)=-inf */
-	    if (ix<0) return (x-x)/zero;	/* log(-#) = NaN */
-	    k -= 25; x *= two25; /* subnormal number, scale up x */
-	    GET_FLOAT_WORD(ix,x);
-	}
-	if (ix >= 0x7f800000) return x+x;
-	k += (ix>>23)-127;
-	ix &= 0x007fffff;
-	i = (ix+(0x95f64<<3))&0x800000;
-	SET_FLOAT_WORD(x,ix|(i^0x3f800000));	/* normalize x or x/2 */
-	k += (i>>23);
-	f = x-(float)1.0;
-	if((0x007fffff&(15+ix))<16) {	/* |f| < 2**-20 */
-	    if(f==zero) if(k==0) return zero;  else {dk=(float)k;
-				 return dk*ln2_hi+dk*ln2_lo;}
-	    R = f*f*((float)0.5-(float)0.33333333333333333*f);
-	    if(k==0) return f-R; else {dk=(float)k;
-	    	     return dk*ln2_hi-((R-dk*ln2_lo)-f);}
-	}
- 	s = f/((float)2.0+f);
-	dk = (float)k;
-	z = s*s;
-	i = ix-(0x6147a<<3);
-	w = z*z;
-	j = (0x6b851<<3)-ix;
-	t1= w*(Lg2+w*Lg4);
-	t2= z*(Lg1+w*Lg3);
-	i |= j;
-	R = t2+t1;
-	if(i>0) {
-	    hfsq=(float)0.5*f*f;
-	    if(k==0) return f-(hfsq-s*(hfsq+R)); else
-		     return dk*ln2_hi-((hfsq-(s*(hfsq+R)+dk*ln2_lo))-f);
-	} else {
-	    if(k==0) return f-s*(f-R); else
-		     return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f);
-	}
-}
diff --git a/libm/src/e_pow.c b/libm/src/e_pow.c
deleted file mode 100644
index d213132..0000000
--- a/libm/src/e_pow.c
+++ /dev/null
@@ -1,304 +0,0 @@
-/* @(#)e_pow.c 1.5 04/04/22 SMI */
-/*
- * ====================================================
- * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_pow.c,v 1.11 2005/02/04 18:26:06 das Exp $";
-#endif
-
-/* __ieee754_pow(x,y) return x**y
- *
- *		      n
- * Method:  Let x =  2   * (1+f)
- *	1. Compute and return log2(x) in two pieces:
- *		log2(x) = w1 + w2,
- *	   where w1 has 53-24 = 29 bit trailing zeros.
- *	2. Perform y*log2(x) = n+y' by simulating muti-precision 
- *	   arithmetic, where |y'|<=0.5.
- *	3. Return x**y = 2**n*exp(y'*log2)
- *
- * Special cases:
- *	1.  (anything) ** 0  is 1
- *	2.  (anything) ** 1  is itself
- *	3.  (anything) ** NAN is NAN
- *	4.  NAN ** (anything except 0) is NAN
- *	5.  +-(|x| > 1) **  +INF is +INF
- *	6.  +-(|x| > 1) **  -INF is +0
- *	7.  +-(|x| < 1) **  +INF is +0
- *	8.  +-(|x| < 1) **  -INF is +INF
- *	9.  +-1         ** +-INF is NAN
- *	10. +0 ** (+anything except 0, NAN)               is +0
- *	11. -0 ** (+anything except 0, NAN, odd integer)  is +0
- *	12. +0 ** (-anything except 0, NAN)               is +INF
- *	13. -0 ** (-anything except 0, NAN, odd integer)  is +INF
- *	14. -0 ** (odd integer) = -( +0 ** (odd integer) )
- *	15. +INF ** (+anything except 0,NAN) is +INF
- *	16. +INF ** (-anything except 0,NAN) is +0
- *	17. -INF ** (anything)  = -0 ** (-anything)
- *	18. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer)
- *	19. (-anything except 0 and inf) ** (non-integer) is NAN
- *
- * Accuracy:
- *	pow(x,y) returns x**y nearly rounded. In particular
- *			pow(integer,integer)
- *	always returns the correct integer provided it is 
- *	representable.
- *
- * Constants :
- * The hexadecimal values are the intended ones for the following 
- * constants. The decimal values may be used, provided that the 
- * compiler will convert from decimal to binary accurately enough 
- * to produce the hexadecimal values shown.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-bp[] = {1.0, 1.5,},
-dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */
-dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */
-zero    =  0.0,
-one	=  1.0,
-two	=  2.0,
-two53	=  9007199254740992.0,	/* 0x43400000, 0x00000000 */
-huge	=  1.0e300,
-tiny    =  1.0e-300,
-	/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
-L1  =  5.99999999999994648725e-01, /* 0x3FE33333, 0x33333303 */
-L2  =  4.28571428578550184252e-01, /* 0x3FDB6DB6, 0xDB6FABFF */
-L3  =  3.33333329818377432918e-01, /* 0x3FD55555, 0x518F264D */
-L4  =  2.72728123808534006489e-01, /* 0x3FD17460, 0xA91D4101 */
-L5  =  2.30660745775561754067e-01, /* 0x3FCD864A, 0x93C9DB65 */
-L6  =  2.06975017800338417784e-01, /* 0x3FCA7E28, 0x4A454EEF */
-P1   =  1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */
-P2   = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */
-P3   =  6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
-P4   = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
-P5   =  4.13813679705723846039e-08, /* 0x3E663769, 0x72BEA4D0 */
-lg2  =  6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */
-lg2_h  =  6.93147182464599609375e-01, /* 0x3FE62E43, 0x00000000 */
-lg2_l  = -1.90465429995776804525e-09, /* 0xBE205C61, 0x0CA86C39 */
-ovt =  8.0085662595372944372e-0017, /* -(1024-log2(ovfl+.5ulp)) */
-cp    =  9.61796693925975554329e-01, /* 0x3FEEC709, 0xDC3A03FD =2/(3ln2) */
-cp_h  =  9.61796700954437255859e-01, /* 0x3FEEC709, 0xE0000000 =(float)cp */
-cp_l  = -7.02846165095275826516e-09, /* 0xBE3E2FE0, 0x145B01F5 =tail of cp_h*/
-ivln2    =  1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */
-ivln2_h  =  1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/
-ivln2_l  =  1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
-
-double
-__ieee754_pow(double x, double y)
-{
-	double z,ax,z_h,z_l,p_h,p_l;
-	double y1,t1,t2,r,s,t,u,v,w;
-	int32_t i,j,k,yisint,n;
-	int32_t hx,hy,ix,iy;
-	u_int32_t lx,ly;
-
-	EXTRACT_WORDS(hx,lx,x);
-	EXTRACT_WORDS(hy,ly,y);
-	ix = hx&0x7fffffff;  iy = hy&0x7fffffff;
-
-    /* y==zero: x**0 = 1 */
-	if((iy|ly)==0) return one; 	
-
-    /* +-NaN return x+y */
-	if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) ||
-	   iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0))) 
-		return x+y;	
-
-    /* determine if y is an odd int when x < 0
-     * yisint = 0	... y is not an integer
-     * yisint = 1	... y is an odd int
-     * yisint = 2	... y is an even int
-     */
-	yisint  = 0;
-	if(hx<0) {	
-	    if(iy>=0x43400000) yisint = 2; /* even integer y */
-	    else if(iy>=0x3ff00000) {
-		k = (iy>>20)-0x3ff;	   /* exponent */
-		if(k>20) {
-		    j = ly>>(52-k);
-		    if((j<<(52-k))==ly) yisint = 2-(j&1);
-		} else if(ly==0) {
-		    j = iy>>(20-k);
-		    if((j<<(20-k))==iy) yisint = 2-(j&1);
-		}
-	    }		
-	} 
-
-    /* special value of y */
-	if(ly==0) { 	
-	    if (iy==0x7ff00000) {	/* y is +-inf */
-	        if(((ix-0x3ff00000)|lx)==0)
-		    return  y - y;	/* inf**+-1 is NaN */
-	        else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */
-		    return (hy>=0)? y: zero;
-	        else			/* (|x|<1)**-,+inf = inf,0 */
-		    return (hy<0)?-y: zero;
-	    } 
-	    if(iy==0x3ff00000) {	/* y is  +-1 */
-		if(hy<0) return one/x; else return x;
-	    }
-	    if(hy==0x40000000) return x*x; /* y is  2 */
-	    if(hy==0x3fe00000) {	/* y is  0.5 */
-		if(hx>=0)	/* x >= +0 */
-		return sqrt(x);	
-	    }
-	}
-
-	ax   = fabs(x);
-    /* special value of x */
-	if(lx==0) {
-	    if(ix==0x7ff00000||ix==0||ix==0x3ff00000){
-		z = ax;			/*x is +-0,+-inf,+-1*/
-		if(hy<0) z = one/z;	/* z = (1/|x|) */
-		if(hx<0) {
-		    if(((ix-0x3ff00000)|yisint)==0) {
-			z = (z-z)/(z-z); /* (-1)**non-int is NaN */
-		    } else if(yisint==1) 
-			z = -z;		/* (x<0)**odd = -(|x|**odd) */
-		}
-		return z;
-	    }
-	}
-    
-    /* CYGNUS LOCAL + fdlibm-5.3 fix: This used to be
-	n = (hx>>31)+1;
-       but ANSI C says a right shift of a signed negative quantity is
-       implementation defined.  */
-	n = ((u_int32_t)hx>>31)-1;
-
-    /* (x<0)**(non-int) is NaN */
-	if((n|yisint)==0) return (x-x)/(x-x);
-
-	s = one; /* s (sign of result -ve**odd) = -1 else = 1 */
-	if((n|(yisint-1))==0) s = -one;/* (-ve)**(odd int) */
-
-    /* |y| is huge */
-	if(iy>0x41e00000) { /* if |y| > 2**31 */
-	    if(iy>0x43f00000){	/* if |y| > 2**64, must o/uflow */
-		if(ix<=0x3fefffff) return (hy<0)? huge*huge:tiny*tiny;
-		if(ix>=0x3ff00000) return (hy>0)? huge*huge:tiny*tiny;
-	    }
-	/* over/underflow if x is not close to one */
-	    if(ix<0x3fefffff) return (hy<0)? s*huge*huge:s*tiny*tiny;
-	    if(ix>0x3ff00000) return (hy>0)? s*huge*huge:s*tiny*tiny;
-	/* now |1-x| is tiny <= 2**-20, suffice to compute 
-	   log(x) by x-x^2/2+x^3/3-x^4/4 */
-	    t = ax-one;		/* t has 20 trailing zeros */
-	    w = (t*t)*(0.5-t*(0.3333333333333333333333-t*0.25));
-	    u = ivln2_h*t;	/* ivln2_h has 21 sig. bits */
-	    v = t*ivln2_l-w*ivln2;
-	    t1 = u+v;
-	    SET_LOW_WORD(t1,0);
-	    t2 = v-(t1-u);
-	} else {
-	    double ss,s2,s_h,s_l,t_h,t_l;
-	    n = 0;
-	/* take care subnormal number */
-	    if(ix<0x00100000)
-		{ax *= two53; n -= 53; GET_HIGH_WORD(ix,ax); }
-	    n  += ((ix)>>20)-0x3ff;
-	    j  = ix&0x000fffff;
-	/* determine interval */
-	    ix = j|0x3ff00000;		/* normalize ix */
-	    if(j<=0x3988E) k=0;		/* |x|<sqrt(3/2) */
-	    else if(j<0xBB67A) k=1;	/* |x|<sqrt(3)   */
-	    else {k=0;n+=1;ix -= 0x00100000;}
-	    SET_HIGH_WORD(ax,ix);
-
-	/* compute ss = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
-	    u = ax-bp[k];		/* bp[0]=1.0, bp[1]=1.5 */
-	    v = one/(ax+bp[k]);
-	    ss = u*v;
-	    s_h = ss;
-	    SET_LOW_WORD(s_h,0);
-	/* t_h=ax+bp[k] High */
-	    t_h = zero;
-	    SET_HIGH_WORD(t_h,((ix>>1)|0x20000000)+0x00080000+(k<<18));
-	    t_l = ax - (t_h-bp[k]);
-	    s_l = v*((u-s_h*t_h)-s_h*t_l);
-	/* compute log(ax) */
-	    s2 = ss*ss;
-	    r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6)))));
-	    r += s_l*(s_h+ss);
-	    s2  = s_h*s_h;
-	    t_h = 3.0+s2+r;
-	    SET_LOW_WORD(t_h,0);
-	    t_l = r-((t_h-3.0)-s2);
-	/* u+v = ss*(1+...) */
-	    u = s_h*t_h;
-	    v = s_l*t_h+t_l*ss;
-	/* 2/(3log2)*(ss+...) */
-	    p_h = u+v;
-	    SET_LOW_WORD(p_h,0);
-	    p_l = v-(p_h-u);
-	    z_h = cp_h*p_h;		/* cp_h+cp_l = 2/(3*log2) */
-	    z_l = cp_l*p_h+p_l*cp+dp_l[k];
-	/* log2(ax) = (ss+..)*2/(3*log2) = n + dp_h + z_h + z_l */
-	    t = (double)n;
-	    t1 = (((z_h+z_l)+dp_h[k])+t);
-	    SET_LOW_WORD(t1,0);
-	    t2 = z_l-(((t1-t)-dp_h[k])-z_h);
-	}
-
-    /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
-	y1  = y;
-	SET_LOW_WORD(y1,0);
-	p_l = (y-y1)*t1+y*t2;
-	p_h = y1*t1;
-	z = p_l+p_h;
-	EXTRACT_WORDS(j,i,z);
-	if (j>=0x40900000) {				/* z >= 1024 */
-	    if(((j-0x40900000)|i)!=0)			/* if z > 1024 */
-		return s*huge*huge;			/* overflow */
-	    else {
-		if(p_l+ovt>z-p_h) return s*huge*huge;	/* overflow */
-	    }
-	} else if((j&0x7fffffff)>=0x4090cc00 ) {	/* z <= -1075 */
-	    if(((j-0xc090cc00)|i)!=0) 		/* z < -1075 */
-		return s*tiny*tiny;		/* underflow */
-	    else {
-		if(p_l<=z-p_h) return s*tiny*tiny;	/* underflow */
-	    }
-	}
-    /*
-     * compute 2**(p_h+p_l)
-     */
-	i = j&0x7fffffff;
-	k = (i>>20)-0x3ff;
-	n = 0;
-	if(i>0x3fe00000) {		/* if |z| > 0.5, set n = [z+0.5] */
-	    n = j+(0x00100000>>(k+1));
-	    k = ((n&0x7fffffff)>>20)-0x3ff;	/* new k for n */
-	    t = zero;
-	    SET_HIGH_WORD(t,n&~(0x000fffff>>k));
-	    n = ((n&0x000fffff)|0x00100000)>>(20-k);
-	    if(j<0) n = -n;
-	    p_h -= t;
-	} 
-	t = p_l+p_h;
-	SET_LOW_WORD(t,0);
-	u = t*lg2_h;
-	v = (p_l-(t-p_h))*lg2+t*lg2_l;
-	z = u+v;
-	w = v-(z-u);
-	t  = z*z;
-	t1  = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
-	r  = (z*t1)/(t1-two)-(w+z*w);
-	z  = one-(r-z);
-	GET_HIGH_WORD(j,z);
-	j += (n<<20);
-	if((j>>20)<=0) z = scalbn(z,n);	/* subnormal output */
-	else SET_HIGH_WORD(z,j);
-	return s*z;
-}
diff --git a/libm/src/e_powf.c b/libm/src/e_powf.c
deleted file mode 100644
index 41f08dd..0000000
--- a/libm/src/e_powf.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/* e_powf.c -- float version of e_pow.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_powf.c,v 1.12 2004/06/01 19:33:30 bde Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float
-bp[] = {1.0, 1.5,},
-dp_h[] = { 0.0, 5.84960938e-01,}, /* 0x3f15c000 */
-dp_l[] = { 0.0, 1.56322085e-06,}, /* 0x35d1cfdc */
-zero    =  0.0,
-one	=  1.0,
-two	=  2.0,
-two24	=  16777216.0,	/* 0x4b800000 */
-huge	=  1.0e30,
-tiny    =  1.0e-30,
-	/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
-L1  =  6.0000002384e-01, /* 0x3f19999a */
-L2  =  4.2857143283e-01, /* 0x3edb6db7 */
-L3  =  3.3333334327e-01, /* 0x3eaaaaab */
-L4  =  2.7272811532e-01, /* 0x3e8ba305 */
-L5  =  2.3066075146e-01, /* 0x3e6c3255 */
-L6  =  2.0697501302e-01, /* 0x3e53f142 */
-P1   =  1.6666667163e-01, /* 0x3e2aaaab */
-P2   = -2.7777778450e-03, /* 0xbb360b61 */
-P3   =  6.6137559770e-05, /* 0x388ab355 */
-P4   = -1.6533901999e-06, /* 0xb5ddea0e */
-P5   =  4.1381369442e-08, /* 0x3331bb4c */
-lg2  =  6.9314718246e-01, /* 0x3f317218 */
-lg2_h  =  6.93145752e-01, /* 0x3f317200 */
-lg2_l  =  1.42860654e-06, /* 0x35bfbe8c */
-ovt =  4.2995665694e-08, /* -(128-log2(ovfl+.5ulp)) */
-cp    =  9.6179670095e-01, /* 0x3f76384f =2/(3ln2) */
-cp_h  =  9.6179199219e-01, /* 0x3f763800 =head of cp */
-cp_l  =  4.7017383622e-06, /* 0x369dc3a0 =tail of cp_h */
-ivln2    =  1.4426950216e+00, /* 0x3fb8aa3b =1/ln2 */
-ivln2_h  =  1.4426879883e+00, /* 0x3fb8aa00 =16b 1/ln2*/
-ivln2_l  =  7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/
-
-float
-__ieee754_powf(float x, float y)
-{
-	float z,ax,z_h,z_l,p_h,p_l;
-	float y1,t1,t2,r,s,sn,t,u,v,w;
-	int32_t i,j,k,yisint,n;
-	int32_t hx,hy,ix,iy,is;
-
-	GET_FLOAT_WORD(hx,x);
-	GET_FLOAT_WORD(hy,y);
-	ix = hx&0x7fffffff;  iy = hy&0x7fffffff;
-
-    /* y==zero: x**0 = 1 */
-	if(iy==0) return one;
-
-    /* +-NaN return x+y */
-	if(ix > 0x7f800000 ||
-	   iy > 0x7f800000)
-		return x+y;
-
-    /* determine if y is an odd int when x < 0
-     * yisint = 0	... y is not an integer
-     * yisint = 1	... y is an odd int
-     * yisint = 2	... y is an even int
-     */
-	yisint  = 0;
-	if(hx<0) {
-	    if(iy>=0x4b800000) yisint = 2; /* even integer y */
-	    else if(iy>=0x3f800000) {
-		k = (iy>>23)-0x7f;	   /* exponent */
-		j = iy>>(23-k);
-		if((j<<(23-k))==iy) yisint = 2-(j&1);
-	    }
-	}
-
-    /* special value of y */
-	if (iy==0x7f800000) {	/* y is +-inf */
-	    if (ix==0x3f800000)
-	        return  y - y;	/* inf**+-1 is NaN */
-	    else if (ix > 0x3f800000)/* (|x|>1)**+-inf = inf,0 */
-	        return (hy>=0)? y: zero;
-	    else			/* (|x|<1)**-,+inf = inf,0 */
-	        return (hy<0)?-y: zero;
-	}
-	if(iy==0x3f800000) {	/* y is  +-1 */
-	    if(hy<0) return one/x; else return x;
-	}
-	if(hy==0x40000000) return x*x; /* y is  2 */
-	if(hy==0x3f000000) {	/* y is  0.5 */
-	    if(hx>=0)	/* x >= +0 */
-	    return __ieee754_sqrtf(x);
-	}
-
-	ax   = fabsf(x);
-    /* special value of x */
-	if(ix==0x7f800000||ix==0||ix==0x3f800000){
-	    z = ax;			/*x is +-0,+-inf,+-1*/
-	    if(hy<0) z = one/z;	/* z = (1/|x|) */
-	    if(hx<0) {
-		if(((ix-0x3f800000)|yisint)==0) {
-		    z = (z-z)/(z-z); /* (-1)**non-int is NaN */
-		} else if(yisint==1)
-		    z = -z;		/* (x<0)**odd = -(|x|**odd) */
-	    }
-	    return z;
-	}
-
-	n = ((u_int32_t)hx>>31)-1;
-
-    /* (x<0)**(non-int) is NaN */
-	if((n|yisint)==0) return (x-x)/(x-x);
-
-	sn = one; /* s (sign of result -ve**odd) = -1 else = 1 */
-	if((n|(yisint-1))==0) sn = -one;/* (-ve)**(odd int) */
-
-    /* |y| is huge */
-	if(iy>0x4d000000) { /* if |y| > 2**27 */
-	/* over/underflow if x is not close to one */
-	    if(ix<0x3f7ffff8) return (hy<0)? sn*huge*huge:sn*tiny*tiny;
-	    if(ix>0x3f800007) return (hy>0)? sn*huge*huge:sn*tiny*tiny;
-	/* now |1-x| is tiny <= 2**-20, suffice to compute
-	   log(x) by x-x^2/2+x^3/3-x^4/4 */
-	    t = ax-1;		/* t has 20 trailing zeros */
-	    w = (t*t)*((float)0.5-t*((float)0.333333333333-t*(float)0.25));
-	    u = ivln2_h*t;	/* ivln2_h has 16 sig. bits */
-	    v = t*ivln2_l-w*ivln2;
-	    t1 = u+v;
-	    GET_FLOAT_WORD(is,t1);
-	    SET_FLOAT_WORD(t1,is&0xfffff000);
-	    t2 = v-(t1-u);
-	} else {
-	    float s2,s_h,s_l,t_h,t_l;
-	    n = 0;
-	/* take care subnormal number */
-	    if(ix<0x00800000)
-		{ax *= two24; n -= 24; GET_FLOAT_WORD(ix,ax); }
-	    n  += ((ix)>>23)-0x7f;
-	    j  = ix&0x007fffff;
-	/* determine interval */
-	    ix = j|0x3f800000;		/* normalize ix */
-	    if(j<=0x1cc471) k=0;	/* |x|<sqrt(3/2) */
-	    else if(j<0x5db3d7) k=1;	/* |x|<sqrt(3)   */
-	    else {k=0;n+=1;ix -= 0x00800000;}
-	    SET_FLOAT_WORD(ax,ix);
-
-	/* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
-	    u = ax-bp[k];		/* bp[0]=1.0, bp[1]=1.5 */
-	    v = one/(ax+bp[k]);
-	    s = u*v;
-	    s_h = s;
-	    GET_FLOAT_WORD(is,s_h);
-	    SET_FLOAT_WORD(s_h,is&0xfffff000);
-	/* t_h=ax+bp[k] High */
-	    is = ((ix>>1)&0xfffff000)|0x20000000;
-	    SET_FLOAT_WORD(t_h,is+0x00400000+(k<<21));
-	    t_l = ax - (t_h-bp[k]);
-	    s_l = v*((u-s_h*t_h)-s_h*t_l);
-	/* compute log(ax) */
-	    s2 = s*s;
-	    r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6)))));
-	    r += s_l*(s_h+s);
-	    s2  = s_h*s_h;
-	    t_h = (float)3.0+s2+r;
-	    GET_FLOAT_WORD(is,t_h);
-	    SET_FLOAT_WORD(t_h,is&0xfffff000);
-	    t_l = r-((t_h-(float)3.0)-s2);
-	/* u+v = s*(1+...) */
-	    u = s_h*t_h;
-	    v = s_l*t_h+t_l*s;
-	/* 2/(3log2)*(s+...) */
-	    p_h = u+v;
-	    GET_FLOAT_WORD(is,p_h);
-	    SET_FLOAT_WORD(p_h,is&0xfffff000);
-	    p_l = v-(p_h-u);
-	    z_h = cp_h*p_h;		/* cp_h+cp_l = 2/(3*log2) */
-	    z_l = cp_l*p_h+p_l*cp+dp_l[k];
-	/* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */
-	    t = (float)n;
-	    t1 = (((z_h+z_l)+dp_h[k])+t);
-	    GET_FLOAT_WORD(is,t1);
-	    SET_FLOAT_WORD(t1,is&0xfffff000);
-	    t2 = z_l-(((t1-t)-dp_h[k])-z_h);
-	}
-
-    /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
-	GET_FLOAT_WORD(is,y);
-	SET_FLOAT_WORD(y1,is&0xfffff000);
-	p_l = (y-y1)*t1+y*t2;
-	p_h = y1*t1;
-	z = p_l+p_h;
-	GET_FLOAT_WORD(j,z);
-	if (j>0x43000000)				/* if z > 128 */
-	    return sn*huge*huge;			/* overflow */
-	else if (j==0x43000000) {			/* if z == 128 */
-	    if(p_l+ovt>z-p_h) return sn*huge*huge;	/* overflow */
-	}
-	else if ((j&0x7fffffff)>0x43160000)		/* z <= -150 */
-	    return sn*tiny*tiny;			/* underflow */
-	else if (j==0xc3160000){			/* z == -150 */
-	    if(p_l<=z-p_h) return sn*tiny*tiny;		/* underflow */
-	}
-    /*
-     * compute 2**(p_h+p_l)
-     */
-	i = j&0x7fffffff;
-	k = (i>>23)-0x7f;
-	n = 0;
-	if(i>0x3f000000) {		/* if |z| > 0.5, set n = [z+0.5] */
-	    n = j+(0x00800000>>(k+1));
-	    k = ((n&0x7fffffff)>>23)-0x7f;	/* new k for n */
-	    SET_FLOAT_WORD(t,n&~(0x007fffff>>k));
-	    n = ((n&0x007fffff)|0x00800000)>>(23-k);
-	    if(j<0) n = -n;
-	    p_h -= t;
-	}
-	t = p_l+p_h;
-	GET_FLOAT_WORD(is,t);
-	SET_FLOAT_WORD(t,is&0xffff8000);
-	u = t*lg2_h;
-	v = (p_l-(t-p_h))*lg2+t*lg2_l;
-	z = u+v;
-	w = v-(z-u);
-	t  = z*z;
-	t1  = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
-	r  = (z*t1)/(t1-two)-(w+z*w);
-	z  = one-(r-z);
-	GET_FLOAT_WORD(j,z);
-	j += (n<<23);
-	if((j>>23)<=0) z = scalbnf(z,n);	/* subnormal output */
-	else SET_FLOAT_WORD(z,j);
-	return sn*z;
-}
diff --git a/libm/src/e_rem_pio2.c b/libm/src/e_rem_pio2.c
deleted file mode 100644
index 121ba29..0000000
--- a/libm/src/e_rem_pio2.c
+++ /dev/null
@@ -1,168 +0,0 @@
-
-/* @(#)e_rem_pio2.c 1.4 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- *
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_rem_pio2.c,v 1.8 2005/02/04 18:26:06 das Exp $";
-#endif
-
-/* __ieee754_rem_pio2(x,y)
- * 
- * return the remainder of x rem pi/2 in y[0]+y[1] 
- * use __kernel_rem_pio2()
- */
-
-#include "math.h"
-#include "math_private.h"
-
-/*
- * Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi 
- */
-static const int32_t two_over_pi[] = {
-0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, 
-0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, 
-0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, 
-0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41, 
-0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8, 
-0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF, 
-0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5, 
-0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08, 
-0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3, 
-0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880, 
-0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B, 
-};
-
-static const int32_t npio2_hw[] = {
-0x3FF921FB, 0x400921FB, 0x4012D97C, 0x401921FB, 0x401F6A7A, 0x4022D97C,
-0x4025FDBB, 0x402921FB, 0x402C463A, 0x402F6A7A, 0x4031475C, 0x4032D97C,
-0x40346B9C, 0x4035FDBB, 0x40378FDB, 0x403921FB, 0x403AB41B, 0x403C463A,
-0x403DD85A, 0x403F6A7A, 0x40407E4C, 0x4041475C, 0x4042106C, 0x4042D97C,
-0x4043A28C, 0x40446B9C, 0x404534AC, 0x4045FDBB, 0x4046C6CB, 0x40478FDB,
-0x404858EB, 0x404921FB,
-};
-
-/*
- * invpio2:  53 bits of 2/pi
- * pio2_1:   first  33 bit of pi/2
- * pio2_1t:  pi/2 - pio2_1
- * pio2_2:   second 33 bit of pi/2
- * pio2_2t:  pi/2 - (pio2_1+pio2_2)
- * pio2_3:   third  33 bit of pi/2
- * pio2_3t:  pi/2 - (pio2_1+pio2_2+pio2_3)
- */
-
-static const double
-zero =  0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
-half =  5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
-two24 =  1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */
-invpio2 =  6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */
-pio2_1  =  1.57079632673412561417e+00, /* 0x3FF921FB, 0x54400000 */
-pio2_1t =  6.07710050650619224932e-11, /* 0x3DD0B461, 0x1A626331 */
-pio2_2  =  6.07710050630396597660e-11, /* 0x3DD0B461, 0x1A600000 */
-pio2_2t =  2.02226624879595063154e-21, /* 0x3BA3198A, 0x2E037073 */
-pio2_3  =  2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */
-pio2_3t =  8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */
-
-	int32_t __ieee754_rem_pio2(double x, double *y)
-{
-	double z,w,t,r,fn;
-	double tx[3];
-	int32_t e0,i,j,nx,n,ix,hx;
-	u_int32_t low;
-
-	GET_HIGH_WORD(hx,x);		/* high word of x */
-	ix = hx&0x7fffffff;
-	if(ix<=0x3fe921fb)   /* |x| ~<= pi/4 , no need for reduction */
-	    {y[0] = x; y[1] = 0; return 0;}
-	if(ix<0x4002d97c) {  /* |x| < 3pi/4, special case with n=+-1 */
-	    if(hx>0) { 
-		z = x - pio2_1;
-		if(ix!=0x3ff921fb) { 	/* 33+53 bit pi is good enough */
-		    y[0] = z - pio2_1t;
-		    y[1] = (z-y[0])-pio2_1t;
-		} else {		/* near pi/2, use 33+33+53 bit pi */
-		    z -= pio2_2;
-		    y[0] = z - pio2_2t;
-		    y[1] = (z-y[0])-pio2_2t;
-		}
-		return 1;
-	    } else {	/* negative x */
-		z = x + pio2_1;
-		if(ix!=0x3ff921fb) { 	/* 33+53 bit pi is good enough */
-		    y[0] = z + pio2_1t;
-		    y[1] = (z-y[0])+pio2_1t;
-		} else {		/* near pi/2, use 33+33+53 bit pi */
-		    z += pio2_2;
-		    y[0] = z + pio2_2t;
-		    y[1] = (z-y[0])+pio2_2t;
-		}
-		return -1;
-	    }
-	}
-	if(ix<=0x413921fb) { /* |x| ~<= 2^19*(pi/2), medium size */
-	    t  = fabs(x);
-	    n  = (int32_t) (t*invpio2+half);
-	    fn = (double)n;
-	    r  = t-fn*pio2_1;
-	    w  = fn*pio2_1t;	/* 1st round good to 85 bit */
-	    if(n<32&&ix!=npio2_hw[n-1]) {	
-		y[0] = r-w;	/* quick check no cancellation */
-	    } else {
-	        u_int32_t high;
-	        j  = ix>>20;
-	        y[0] = r-w; 
-		GET_HIGH_WORD(high,y[0]);
-	        i = j-((high>>20)&0x7ff);
-	        if(i>16) {  /* 2nd iteration needed, good to 118 */
-		    t  = r;
-		    w  = fn*pio2_2;	
-		    r  = t-w;
-		    w  = fn*pio2_2t-((t-r)-w);	
-		    y[0] = r-w;
-		    GET_HIGH_WORD(high,y[0]);
-		    i = j-((high>>20)&0x7ff);
-		    if(i>49)  {	/* 3rd iteration need, 151 bits acc */
-		    	t  = r;	/* will cover all possible cases */
-		    	w  = fn*pio2_3;	
-		    	r  = t-w;
-		    	w  = fn*pio2_3t-((t-r)-w);	
-		    	y[0] = r-w;
-		    }
-		}
-	    }
-	    y[1] = (r-y[0])-w;
-	    if(hx<0) 	{y[0] = -y[0]; y[1] = -y[1]; return -n;}
-	    else	 return n;
-	}
-    /* 
-     * all other (large) arguments
-     */
-	if(ix>=0x7ff00000) {		/* x is inf or NaN */
-	    y[0]=y[1]=x-x; return 0;
-	}
-    /* set z = scalbn(|x|,ilogb(x)-23) */
-	GET_LOW_WORD(low,x);
-	SET_LOW_WORD(z,low);
-	e0 	= (ix>>20)-1046;	/* e0 = ilogb(z)-23; */
-	SET_HIGH_WORD(z, ix - ((int32_t)(e0<<20)));
-	for(i=0;i<2;i++) {
-		tx[i] = (double)((int32_t)(z));
-		z     = (z-tx[i])*two24;
-	}
-	tx[2] = z;
-	nx = 3;
-	while(tx[nx-1]==zero) nx--;	/* skip zero term */
-	n  =  __kernel_rem_pio2(tx,y,e0,nx,2,two_over_pi);
-	if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;}
-	return n;
-}
diff --git a/libm/src/e_rem_pio2f.c b/libm/src/e_rem_pio2f.c
deleted file mode 100644
index 5231cd4..0000000
--- a/libm/src/e_rem_pio2f.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/* e_rem_pio2f.c -- float version of e_rem_pio2.c
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Debugged and optimized by Bruce D. Evans.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_rem_pio2f.c,v 1.19 2005/11/23 03:03:09 bde Exp $";
-#endif
-
-/* __ieee754_rem_pio2f(x,y)
- *
- * return the remainder of x rem pi/2 in y[0]+y[1]
- * use double precision internally
- * use __kernel_rem_pio2() for large x
- */
-
-#include "math.h"
-#include "math_private.h"
-
-/*
- * Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi
- */
-static const int32_t two_over_pi[] = {
-0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, 
-0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, 
-0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, 
-0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41, 
-0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8, 
-0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF, 
-0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5, 
-0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08, 
-0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3, 
-0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880, 
-0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B, 
-};
-
-/*
- * invpio2:  53 bits of 2/pi
- * pio2_1:   first  33 bit of pi/2
- * pio2_1t:  pi/2 - pio2_1
- */
-
-static const double
-zero =  0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
-half =  5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
-two24 =  1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */
-invpio2 =  6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */
-pio2_1  =  1.57079632673412561417e+00, /* 0x3FF921FB, 0x54400000 */
-pio2_1t =  6.07710050650619224932e-11; /* 0x3DD0B461, 0x1A626331 */
-
-	int32_t __ieee754_rem_pio2f(float x, float *y)
-{
-	double w,t,r,fn;
-	double tx[1],ty[2];
-	float z;
-	int32_t e0,n,ix,hx;
-
-	GET_FLOAT_WORD(hx,x);
-	ix = hx&0x7fffffff;
-    /* 33+53 bit pi is good enough for medium size */
-	if(ix<=0x49490f80) {		/* |x| ~<= 2^19*(pi/2), medium size */
-	    t  = fabsf(x);
-	    n  = (int32_t) (t*invpio2+half);
-	    fn = (double)n;
-	    r  = t-fn*pio2_1;
-	    w  = fn*pio2_1t;
-	    y[0] = r-w;
-	    y[1] = (r-y[0])-w;
-	    if(hx<0) 	{y[0] = -y[0]; y[1] = -y[1]; return -n;}
-	    else	 return n;
-	}
-    /*
-     * all other (large) arguments
-     */
-	if(ix>=0x7f800000) {		/* x is inf or NaN */
-	    y[0]=y[1]=x-x; return 0;
-	}
-    /* set z = scalbn(|x|,ilogb(|x|)-23) */
-	e0 = (ix>>23)-150;		/* e0 = ilogb(|x|)-23; */
-	SET_FLOAT_WORD(z, ix - ((int32_t)(e0<<23)));
-	tx[0] = z;
-	n  =  __kernel_rem_pio2(tx,ty,e0,1,1,two_over_pi);
-	y[0] = ty[0];
-	y[1] = ty[0] - y[0];
-	if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;}
-	return n;
-}
diff --git a/libm/src/e_remainder.c b/libm/src/e_remainder.c
deleted file mode 100644
index 46932a2..0000000
--- a/libm/src/e_remainder.c
+++ /dev/null
@@ -1,73 +0,0 @@
-
-/* @(#)e_remainder.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_remainder.c,v 1.10 2005/02/04 18:26:06 das Exp $";
-#endif
-
-/* __ieee754_remainder(x,p)
- * Return :                  
- * 	returns  x REM p  =  x - [x/p]*p as if in infinite 
- * 	precise arithmetic, where [x/p] is the (infinite bit) 
- *	integer nearest x/p (in half way case choose the even one).
- * Method : 
- *	Based on fmod() return x-[x/p]chopped*p exactlp.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double zero = 0.0;
-
-
-double
-__ieee754_remainder(double x, double p)
-{
-	int32_t hx,hp;
-	u_int32_t sx,lx,lp;
-	double p_half;
-
-	EXTRACT_WORDS(hx,lx,x);
-	EXTRACT_WORDS(hp,lp,p);
-	sx = hx&0x80000000;
-	hp &= 0x7fffffff;
-	hx &= 0x7fffffff;
-
-    /* purge off exception values */
-	if((hp|lp)==0) return (x*p)/(x*p); 	/* p = 0 */
-	if((hx>=0x7ff00000)||			/* x not finite */
-	  ((hp>=0x7ff00000)&&			/* p is NaN */
-	  (((hp-0x7ff00000)|lp)!=0)))
-	    return (x*p)/(x*p);
-
-
-	if (hp<=0x7fdfffff) x = __ieee754_fmod(x,p+p);	/* now x < 2p */
-	if (((hx-hp)|(lx-lp))==0) return zero*x;
-	x  = fabs(x);
-	p  = fabs(p);
-	if (hp<0x00200000) {
-	    if(x+x>p) {
-		x-=p;
-		if(x+x>=p) x -= p;
-	    }
-	} else {
-	    p_half = 0.5*p;
-	    if(x>p_half) {
-		x-=p;
-		if(x>=p_half) x -= p;
-	    }
-	}
-	GET_HIGH_WORD(hx,x);
-	SET_HIGH_WORD(x,hx^sx);
-	return x;
-}
diff --git a/libm/src/e_remainderf.c b/libm/src/e_remainderf.c
deleted file mode 100644
index 4045088..0000000
--- a/libm/src/e_remainderf.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/* e_remainderf.c -- float version of e_remainder.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_remainderf.c,v 1.7 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float zero = 0.0;
-
-
-float
-__ieee754_remainderf(float x, float p)
-{
-	int32_t hx,hp;
-	u_int32_t sx;
-	float p_half;
-
-	GET_FLOAT_WORD(hx,x);
-	GET_FLOAT_WORD(hp,p);
-	sx = hx&0x80000000;
-	hp &= 0x7fffffff;
-	hx &= 0x7fffffff;
-
-    /* purge off exception values */
-	if(hp==0) return (x*p)/(x*p);	 	/* p = 0 */
-	if((hx>=0x7f800000)||			/* x not finite */
-	  ((hp>0x7f800000)))			/* p is NaN */
-	    return (x*p)/(x*p);
-
-
-	if (hp<=0x7effffff) x = __ieee754_fmodf(x,p+p);	/* now x < 2p */
-	if ((hx-hp)==0) return zero*x;
-	x  = fabsf(x);
-	p  = fabsf(p);
-	if (hp<0x01000000) {
-	    if(x+x>p) {
-		x-=p;
-		if(x+x>=p) x -= p;
-	    }
-	} else {
-	    p_half = (float)0.5*p;
-	    if(x>p_half) {
-		x-=p;
-		if(x>=p_half) x -= p;
-	    }
-	}
-	GET_FLOAT_WORD(hx,x);
-	SET_FLOAT_WORD(x,hx^sx);
-	return x;
-}
diff --git a/libm/src/e_scalb.c b/libm/src/e_scalb.c
deleted file mode 100644
index b81666e..0000000
--- a/libm/src/e_scalb.c
+++ /dev/null
@@ -1,48 +0,0 @@
-
-/* @(#)e_scalb.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_scalb.c,v 1.12 2005/02/04 18:26:06 das Exp $";
-#endif
-
-/*
- * __ieee754_scalb(x, fn) is provide for
- * passing various standard test suite. One 
- * should use scalbn() instead.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-#ifdef _SCALB_INT
-double
-__ieee754_scalb(double x, int fn)
-#else
-double
-__ieee754_scalb(double x, double fn)
-#endif
-{
-#ifdef _SCALB_INT
-	return scalbn(x,fn);
-#else
-	if (isnan(x)||isnan(fn)) return x*fn;
-	if (!finite(fn)) {
-	    if(fn>0.0) return x*fn;
-	    else       return x/(-fn);
-	}
-	if (rint(fn)!=fn) return (fn-fn)/(fn-fn);
-	if ( fn > 65000.0) return scalbn(x, 65000);
-	if (-fn > 65000.0) return scalbn(x,-65000);
-	return scalbn(x,(int)fn);
-#endif
-}
diff --git a/libm/src/e_scalbf.c b/libm/src/e_scalbf.c
deleted file mode 100644
index 07ac1f4..0000000
--- a/libm/src/e_scalbf.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* e_scalbf.c -- float version of e_scalb.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_scalbf.c,v 1.10 2005/12/06 20:12:38 obrien Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-#ifdef _SCALB_INT
-float
-__ieee754_scalbf(float x, int fn)
-#else
-float
-__ieee754_scalbf(float x, float fn)
-#endif
-{
-#ifdef _SCALB_INT
-	return scalbnf(x,fn);
-#else
-	if ((isnanf)(x)||(isnanf)(fn)) return x*fn;
-	if (!finitef(fn)) {
-	    if(fn>(float)0.0) return x*fn;
-	    else       return x/(-fn);
-	}
-	if (rintf(fn)!=fn) return (fn-fn)/(fn-fn);
-	if ( fn > (float)65000.0) return scalbnf(x, 65000);
-	if (-fn > (float)65000.0) return scalbnf(x,-65000);
-	return scalbnf(x,(int)fn);
-#endif
-}
-
-__weak_reference(scalbf, ldexpf);
diff --git a/libm/src/e_sinh.c b/libm/src/e_sinh.c
deleted file mode 100644
index 7584b27..0000000
--- a/libm/src/e_sinh.c
+++ /dev/null
@@ -1,79 +0,0 @@
-
-/* @(#)e_sinh.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_sinh.c,v 1.9 2005/02/04 18:26:06 das Exp $";
-#endif
-
-/* __ieee754_sinh(x)
- * Method : 
- * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
- *	1. Replace x by |x| (sinh(-x) = -sinh(x)). 
- *	2. 
- *		                                    E + E/(E+1)
- *	    0        <= x <= 22     :  sinh(x) := --------------, E=expm1(x)
- *			       			        2
- *
- *	    22       <= x <= lnovft :  sinh(x) := exp(x)/2 
- *	    lnovft   <= x <= ln2ovft:  sinh(x) := exp(x/2)/2 * exp(x/2)
- *	    ln2ovft  <  x	    :  sinh(x) := x*shuge (overflow)
- *
- * Special cases:
- *	sinh(x) is |x| if x is +INF, -INF, or NaN.
- *	only sinh(0)=0 is exact for finite x.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double one = 1.0, shuge = 1.0e307;
-
-double
-__ieee754_sinh(double x)
-{
-	double t,w,h;
-	int32_t ix,jx;
-	u_int32_t lx;
-
-    /* High word of |x|. */
-	GET_HIGH_WORD(jx,x);
-	ix = jx&0x7fffffff;
-
-    /* x is INF or NaN */
-	if(ix>=0x7ff00000) return x+x;	
-
-	h = 0.5;
-	if (jx<0) h = -h;
-    /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
-	if (ix < 0x40360000) {		/* |x|<22 */
-	    if (ix<0x3e300000) 		/* |x|<2**-28 */
-		if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
-	    t = expm1(fabs(x));
-	    if(ix<0x3ff00000) return h*(2.0*t-t*t/(t+one));
-	    return h*(t+t/(t+one));
-	}
-
-    /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */
-	if (ix < 0x40862E42)  return h*__ieee754_exp(fabs(x));
-
-    /* |x| in [log(maxdouble), overflowthresold] */
-	GET_LOW_WORD(lx,x);
-	if (ix<0x408633CE || ((ix==0x408633ce)&&(lx<=(u_int32_t)0x8fb9f87d))) {
-	    w = __ieee754_exp(0.5*fabs(x));
-	    t = h*w;
-	    return t*w;
-	}
-
-    /* |x| > overflowthresold, sinh(x) overflow */
-	return x*shuge;
-}
diff --git a/libm/src/e_sinhf.c b/libm/src/e_sinhf.c
deleted file mode 100644
index 02e753f..0000000
--- a/libm/src/e_sinhf.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/* e_sinhf.c -- float version of e_sinh.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_sinhf.c,v 1.8 2005/11/13 00:41:46 bde Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float one = 1.0, shuge = 1.0e37;
-
-float
-__ieee754_sinhf(float x)
-{
-	float t,w,h;
-	int32_t ix,jx;
-
-	GET_FLOAT_WORD(jx,x);
-	ix = jx&0x7fffffff;
-
-    /* x is INF or NaN */
-	if(ix>=0x7f800000) return x+x;
-
-	h = 0.5;
-	if (jx<0) h = -h;
-    /* |x| in [0,9], return sign(x)*0.5*(E+E/(E+1))) */
-	if (ix < 0x41100000) {		/* |x|<9 */
-	    if (ix<0x39800000) 		/* |x|<2**-12 */
-		if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
-	    t = expm1f(fabsf(x));
-	    if(ix<0x3f800000) return h*((float)2.0*t-t*t/(t+one));
-	    return h*(t+t/(t+one));
-	}
-
-    /* |x| in [9, logf(maxfloat)] return 0.5*exp(|x|) */
-	if (ix < 0x42b17217)  return h*__ieee754_expf(fabsf(x));
-
-    /* |x| in [logf(maxfloat), overflowthresold] */
-	if (ix<=0x42b2d4fc) {
-	    w = __ieee754_expf((float)0.5*fabsf(x));
-	    t = h*w;
-	    return t*w;
-	}
-
-    /* |x| > overflowthresold, sinh(x) overflow */
-	return x*shuge;
-}
diff --git a/libm/src/e_sqrt.c b/libm/src/e_sqrt.c
deleted file mode 100644
index d75cb10..0000000
--- a/libm/src/e_sqrt.c
+++ /dev/null
@@ -1,446 +0,0 @@
-
-/* @(#)e_sqrt.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_sqrt.c,v 1.10 2005/02/04 18:26:06 das Exp $";
-#endif
-
-/* __ieee754_sqrt(x)
- * Return correctly rounded sqrt.
- *           ------------------------------------------
- *	     |  Use the hardware sqrt if you have one |
- *           ------------------------------------------
- * Method: 
- *   Bit by bit method using integer arithmetic. (Slow, but portable) 
- *   1. Normalization
- *	Scale x to y in [1,4) with even powers of 2: 
- *	find an integer k such that  1 <= (y=x*2^(2k)) < 4, then
- *		sqrt(x) = 2^k * sqrt(y)
- *   2. Bit by bit computation
- *	Let q  = sqrt(y) truncated to i bit after binary point (q = 1),
- *	     i							 0
- *                                     i+1         2
- *	    s  = 2*q , and	y  =  2   * ( y - q  ).		(1)
- *	     i      i            i                 i
- *                                                        
- *	To compute q    from q , one checks whether 
- *		    i+1       i                       
- *
- *			      -(i+1) 2
- *			(q + 2      ) <= y.			(2)
- *     			  i
- *							      -(i+1)
- *	If (2) is false, then q   = q ; otherwise q   = q  + 2      .
- *		 	       i+1   i             i+1   i
- *
- *	With some algebric manipulation, it is not difficult to see
- *	that (2) is equivalent to 
- *                             -(i+1)
- *			s  +  2       <= y			(3)
- *			 i                i
- *
- *	The advantage of (3) is that s  and y  can be computed by 
- *				      i      i
- *	the following recurrence formula:
- *	    if (3) is false
- *
- *	    s     =  s  ,	y    = y   ;			(4)
- *	     i+1      i		 i+1    i
- *
- *	    otherwise,
- *                         -i                     -(i+1)
- *	    s	  =  s  + 2  ,  y    = y  -  s  - 2  		(5)
- *           i+1      i          i+1    i     i
- *				
- *	One may easily use induction to prove (4) and (5). 
- *	Note. Since the left hand side of (3) contain only i+2 bits,
- *	      it does not necessary to do a full (53-bit) comparison 
- *	      in (3).
- *   3. Final rounding
- *	After generating the 53 bits result, we compute one more bit.
- *	Together with the remainder, we can decide whether the
- *	result is exact, bigger than 1/2ulp, or less than 1/2ulp
- *	(it will never equal to 1/2ulp).
- *	The rounding mode can be detected by checking whether
- *	huge + tiny is equal to huge, and whether huge - tiny is
- *	equal to huge for some floating point number "huge" and "tiny".
- *		
- * Special cases:
- *	sqrt(+-0) = +-0 	... exact
- *	sqrt(inf) = inf
- *	sqrt(-ve) = NaN		... with invalid signal
- *	sqrt(NaN) = NaN		... with invalid signal for signaling NaN
- *
- * Other methods : see the appended file at the end of the program below.
- *---------------
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static	const double	one	= 1.0, tiny=1.0e-300;
-
-double
-__ieee754_sqrt(double x)
-{
-	double z;
-	int32_t sign = (int)0x80000000;
-	int32_t ix0,s0,q,m,t,i;
-	u_int32_t r,t1,s1,ix1,q1;
-
-	EXTRACT_WORDS(ix0,ix1,x);
-
-    /* take care of Inf and NaN */
-	if((ix0&0x7ff00000)==0x7ff00000) {			
-	    return x*x+x;		/* sqrt(NaN)=NaN, sqrt(+inf)=+inf
-					   sqrt(-inf)=sNaN */
-	} 
-    /* take care of zero */
-	if(ix0<=0) {
-	    if(((ix0&(~sign))|ix1)==0) return x;/* sqrt(+-0) = +-0 */
-	    else if(ix0<0)
-		return (x-x)/(x-x);		/* sqrt(-ve) = sNaN */
-	}
-    /* normalize x */
-	m = (ix0>>20);
-	if(m==0) {				/* subnormal x */
-	    while(ix0==0) {
-		m -= 21;
-		ix0 |= (ix1>>11); ix1 <<= 21;
-	    }
-	    for(i=0;(ix0&0x00100000)==0;i++) ix0<<=1;
-	    m -= i-1;
-	    ix0 |= (ix1>>(32-i));
-	    ix1 <<= i;
-	}
-	m -= 1023;	/* unbias exponent */
-	ix0 = (ix0&0x000fffff)|0x00100000;
-	if(m&1){	/* odd m, double x to make it even */
-	    ix0 += ix0 + ((ix1&sign)>>31);
-	    ix1 += ix1;
-	}
-	m >>= 1;	/* m = [m/2] */
-
-    /* generate sqrt(x) bit by bit */
-	ix0 += ix0 + ((ix1&sign)>>31);
-	ix1 += ix1;
-	q = q1 = s0 = s1 = 0;	/* [q,q1] = sqrt(x) */
-	r = 0x00200000;		/* r = moving bit from right to left */
-
-	while(r!=0) {
-	    t = s0+r; 
-	    if(t<=ix0) { 
-		s0   = t+r; 
-		ix0 -= t; 
-		q   += r; 
-	    } 
-	    ix0 += ix0 + ((ix1&sign)>>31);
-	    ix1 += ix1;
-	    r>>=1;
-	}
-
-	r = sign;
-	while(r!=0) {
-	    t1 = s1+r; 
-	    t  = s0;
-	    if((t<ix0)||((t==ix0)&&(t1<=ix1))) { 
-		s1  = t1+r;
-		if(((t1&sign)==sign)&&(s1&sign)==0) s0 += 1;
-		ix0 -= t;
-		if (ix1 < t1) ix0 -= 1;
-		ix1 -= t1;
-		q1  += r;
-	    }
-	    ix0 += ix0 + ((ix1&sign)>>31);
-	    ix1 += ix1;
-	    r>>=1;
-	}
-
-    /* use floating add to find out rounding direction */
-	if((ix0|ix1)!=0) {
-	    z = one-tiny; /* trigger inexact flag */
-	    if (z>=one) {
-	        z = one+tiny;
-	        if (q1==(u_int32_t)0xffffffff) { q1=0; q += 1;}
-		else if (z>one) {
-		    if (q1==(u_int32_t)0xfffffffe) q+=1;
-		    q1+=2; 
-		} else
-	            q1 += (q1&1);
-	    }
-	}
-	ix0 = (q>>1)+0x3fe00000;
-	ix1 =  q1>>1;
-	if ((q&1)==1) ix1 |= sign;
-	ix0 += (m <<20);
-	INSERT_WORDS(z,ix0,ix1);
-	return z;
-}
-
-/*
-Other methods  (use floating-point arithmetic)
--------------
-(This is a copy of a drafted paper by Prof W. Kahan 
-and K.C. Ng, written in May, 1986)
-
-	Two algorithms are given here to implement sqrt(x) 
-	(IEEE double precision arithmetic) in software.
-	Both supply sqrt(x) correctly rounded. The first algorithm (in
-	Section A) uses newton iterations and involves four divisions.
-	The second one uses reciproot iterations to avoid division, but
-	requires more multiplications. Both algorithms need the ability
-	to chop results of arithmetic operations instead of round them, 
-	and the INEXACT flag to indicate when an arithmetic operation
-	is executed exactly with no roundoff error, all part of the 
-	standard (IEEE 754-1985). The ability to perform shift, add,
-	subtract and logical AND operations upon 32-bit words is needed
-	too, though not part of the standard.
-
-A.  sqrt(x) by Newton Iteration
-
-   (1)	Initial approximation
-
-	Let x0 and x1 be the leading and the trailing 32-bit words of
-	a floating point number x (in IEEE double format) respectively 
-
-	    1    11		     52				  ...widths
-	   ------------------------------------------------------
-	x: |s|	  e     |	      f				|
-	   ------------------------------------------------------
-	      msb    lsb  msb				      lsb ...order
-
- 
-	     ------------------------  	     ------------------------
-	x0:  |s|   e    |    f1     |	 x1: |          f2           |
-	     ------------------------  	     ------------------------
-
-	By performing shifts and subtracts on x0 and x1 (both regarded
-	as integers), we obtain an 8-bit approximation of sqrt(x) as
-	follows.
-
-		k  := (x0>>1) + 0x1ff80000;
-		y0 := k - T1[31&(k>>15)].	... y ~ sqrt(x) to 8 bits
-	Here k is a 32-bit integer and T1[] is an integer array containing
-	correction terms. Now magically the floating value of y (y's
-	leading 32-bit word is y0, the value of its trailing word is 0)
-	approximates sqrt(x) to almost 8-bit.
-
-	Value of T1:
-	static int T1[32]= {
-	0,	1024,	3062,	5746,	9193,	13348,	18162,	23592,
-	29598,	36145,	43202,	50740,	58733,	67158,	75992,	85215,
-	83599,	71378,	60428,	50647,	41945,	34246,	27478,	21581,
-	16499,	12183,	8588,	5674,	3403,	1742,	661,	130,};
-
-    (2)	Iterative refinement
-
-	Apply Heron's rule three times to y, we have y approximates 
-	sqrt(x) to within 1 ulp (Unit in the Last Place):
-
-		y := (y+x/y)/2		... almost 17 sig. bits
-		y := (y+x/y)/2		... almost 35 sig. bits
-		y := y-(y-x/y)/2	... within 1 ulp
-
-
-	Remark 1.
-	    Another way to improve y to within 1 ulp is:
-
-		y := (y+x/y)		... almost 17 sig. bits to 2*sqrt(x)
-		y := y - 0x00100006	... almost 18 sig. bits to sqrt(x)
-
-				2
-			    (x-y )*y
-		y := y + 2* ----------	...within 1 ulp
-			       2
-			     3y  + x
-
-
-	This formula has one division fewer than the one above; however,
-	it requires more multiplications and additions. Also x must be
-	scaled in advance to avoid spurious overflow in evaluating the
-	expression 3y*y+x. Hence it is not recommended uless division
-	is slow. If division is very slow, then one should use the 
-	reciproot algorithm given in section B.
-
-    (3) Final adjustment
-
-	By twiddling y's last bit it is possible to force y to be 
-	correctly rounded according to the prevailing rounding mode
-	as follows. Let r and i be copies of the rounding mode and
-	inexact flag before entering the square root program. Also we
-	use the expression y+-ulp for the next representable floating
-	numbers (up and down) of y. Note that y+-ulp = either fixed
-	point y+-1, or multiply y by nextafter(1,+-inf) in chopped
-	mode.
-
-		I := FALSE;	... reset INEXACT flag I
-		R := RZ;	... set rounding mode to round-toward-zero
-		z := x/y;	... chopped quotient, possibly inexact
-		If(not I) then {	... if the quotient is exact
-		    if(z=y) {
-		        I := i;	 ... restore inexact flag
-		        R := r;  ... restore rounded mode
-		        return sqrt(x):=y.
-		    } else {
-			z := z - ulp;	... special rounding
-		    }
-		}
-		i := TRUE;		... sqrt(x) is inexact
-		If (r=RN) then z=z+ulp	... rounded-to-nearest
-		If (r=RP) then {	... round-toward-+inf
-		    y = y+ulp; z=z+ulp;
-		}
-		y := y+z;		... chopped sum
-		y0:=y0-0x00100000;	... y := y/2 is correctly rounded.
-	        I := i;	 		... restore inexact flag
-	        R := r;  		... restore rounded mode
-	        return sqrt(x):=y.
-		    
-    (4)	Special cases
-
-	Square root of +inf, +-0, or NaN is itself;
-	Square root of a negative number is NaN with invalid signal.
-
-
-B.  sqrt(x) by Reciproot Iteration
-
-   (1)	Initial approximation
-
-	Let x0 and x1 be the leading and the trailing 32-bit words of
-	a floating point number x (in IEEE double format) respectively
-	(see section A). By performing shifs and subtracts on x0 and y0,
-	we obtain a 7.8-bit approximation of 1/sqrt(x) as follows.
-
-	    k := 0x5fe80000 - (x0>>1);
-	    y0:= k - T2[63&(k>>14)].	... y ~ 1/sqrt(x) to 7.8 bits
-
-	Here k is a 32-bit integer and T2[] is an integer array 
-	containing correction terms. Now magically the floating
-	value of y (y's leading 32-bit word is y0, the value of
-	its trailing word y1 is set to zero) approximates 1/sqrt(x)
-	to almost 7.8-bit.
-
-	Value of T2:
-	static int T2[64]= {
-	0x1500,	0x2ef8,	0x4d67,	0x6b02,	0x87be,	0xa395,	0xbe7a,	0xd866,
-	0xf14a,	0x1091b,0x11fcd,0x13552,0x14999,0x15c98,0x16e34,0x17e5f,
-	0x18d03,0x19a01,0x1a545,0x1ae8a,0x1b5c4,0x1bb01,0x1bfde,0x1c28d,
-	0x1c2de,0x1c0db,0x1ba73,0x1b11c,0x1a4b5,0x1953d,0x18266,0x16be0,
-	0x1683e,0x179d8,0x18a4d,0x19992,0x1a789,0x1b445,0x1bf61,0x1c989,
-	0x1d16d,0x1d77b,0x1dddf,0x1e2ad,0x1e5bf,0x1e6e8,0x1e654,0x1e3cd,
-	0x1df2a,0x1d635,0x1cb16,0x1be2c,0x1ae4e,0x19bde,0x1868e,0x16e2e,
-	0x1527f,0x1334a,0x11051,0xe951,	0xbe01,	0x8e0d,	0x5924,	0x1edd,};
-
-    (2)	Iterative refinement
-
-	Apply Reciproot iteration three times to y and multiply the
-	result by x to get an approximation z that matches sqrt(x)
-	to about 1 ulp. To be exact, we will have 
-		-1ulp < sqrt(x)-z<1.0625ulp.
-	
-	... set rounding mode to Round-to-nearest
-	   y := y*(1.5-0.5*x*y*y)	... almost 15 sig. bits to 1/sqrt(x)
-	   y := y*((1.5-2^-30)+0.5*x*y*y)... about 29 sig. bits to 1/sqrt(x)
-	... special arrangement for better accuracy
-	   z := x*y			... 29 bits to sqrt(x), with z*y<1
-	   z := z + 0.5*z*(1-z*y)	... about 1 ulp to sqrt(x)
-
-	Remark 2. The constant 1.5-2^-30 is chosen to bias the error so that
-	(a) the term z*y in the final iteration is always less than 1; 
-	(b) the error in the final result is biased upward so that
-		-1 ulp < sqrt(x) - z < 1.0625 ulp
-	    instead of |sqrt(x)-z|<1.03125ulp.
-
-    (3)	Final adjustment
-
-	By twiddling y's last bit it is possible to force y to be 
-	correctly rounded according to the prevailing rounding mode
-	as follows. Let r and i be copies of the rounding mode and
-	inexact flag before entering the square root program. Also we
-	use the expression y+-ulp for the next representable floating
-	numbers (up and down) of y. Note that y+-ulp = either fixed
-	point y+-1, or multiply y by nextafter(1,+-inf) in chopped
-	mode.
-
-	R := RZ;		... set rounding mode to round-toward-zero
-	switch(r) {
-	    case RN:		... round-to-nearest
-	       if(x<= z*(z-ulp)...chopped) z = z - ulp; else
-	       if(x<= z*(z+ulp)...chopped) z = z; else z = z+ulp;
-	       break;
-	    case RZ:case RM:	... round-to-zero or round-to--inf
-	       R:=RP;		... reset rounding mod to round-to-+inf
-	       if(x<z*z ... rounded up) z = z - ulp; else
-	       if(x>=(z+ulp)*(z+ulp) ...rounded up) z = z+ulp;
-	       break;
-	    case RP:		... round-to-+inf
-	       if(x>(z+ulp)*(z+ulp)...chopped) z = z+2*ulp; else
-	       if(x>z*z ...chopped) z = z+ulp;
-	       break;
-	}
-
-	Remark 3. The above comparisons can be done in fixed point. For
-	example, to compare x and w=z*z chopped, it suffices to compare
-	x1 and w1 (the trailing parts of x and w), regarding them as
-	two's complement integers.
-
-	...Is z an exact square root?
-	To determine whether z is an exact square root of x, let z1 be the
-	trailing part of z, and also let x0 and x1 be the leading and
-	trailing parts of x.
-
-	If ((z1&0x03ffffff)!=0)	... not exact if trailing 26 bits of z!=0
-	    I := 1;		... Raise Inexact flag: z is not exact
-	else {
-	    j := 1 - [(x0>>20)&1]	... j = logb(x) mod 2
-	    k := z1 >> 26;		... get z's 25-th and 26-th 
-					    fraction bits
-	    I := i or (k&j) or ((k&(j+j+1))!=(x1&3));
-	}
-	R:= r		... restore rounded mode
-	return sqrt(x):=z.
-
-	If multiplication is cheaper then the foregoing red tape, the 
-	Inexact flag can be evaluated by
-
-	    I := i;
-	    I := (z*z!=x) or I.
-
-	Note that z*z can overwrite I; this value must be sensed if it is 
-	True.
-
-	Remark 4. If z*z = x exactly, then bit 25 to bit 0 of z1 must be
-	zero.
-
-		    --------------------
-		z1: |        f2        | 
-		    --------------------
-		bit 31		   bit 0
-
-	Further more, bit 27 and 26 of z1, bit 0 and 1 of x1, and the odd
-	or even of logb(x) have the following relations:
-
-	-------------------------------------------------
-	bit 27,26 of z1		bit 1,0 of x1	logb(x)
-	-------------------------------------------------
-	00			00		odd and even
-	01			01		even
-	10			10		odd
-	10			00		even
-	11			01		even
-	-------------------------------------------------
-
-    (4)	Special cases (see (4) of Section A).	
- 
- */
- 
diff --git a/libm/src/e_sqrtf.c b/libm/src/e_sqrtf.c
deleted file mode 100644
index edc9ef2..0000000
--- a/libm/src/e_sqrtf.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/* e_sqrtf.c -- float version of e_sqrt.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_sqrtf.c,v 1.7 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static	const float	one	= 1.0, tiny=1.0e-30;
-
-float
-__ieee754_sqrtf(float x)
-{
-	float z;
-	int32_t sign = (int)0x80000000;
-	int32_t ix,s,q,m,t,i;
-	u_int32_t r;
-
-	GET_FLOAT_WORD(ix,x);
-
-    /* take care of Inf and NaN */
-	if((ix&0x7f800000)==0x7f800000) {
-	    return x*x+x;		/* sqrt(NaN)=NaN, sqrt(+inf)=+inf
-					   sqrt(-inf)=sNaN */
-	}
-    /* take care of zero */
-	if(ix<=0) {
-	    if((ix&(~sign))==0) return x;/* sqrt(+-0) = +-0 */
-	    else if(ix<0)
-		return (x-x)/(x-x);		/* sqrt(-ve) = sNaN */
-	}
-    /* normalize x */
-	m = (ix>>23);
-	if(m==0) {				/* subnormal x */
-	    for(i=0;(ix&0x00800000)==0;i++) ix<<=1;
-	    m -= i-1;
-	}
-	m -= 127;	/* unbias exponent */
-	ix = (ix&0x007fffff)|0x00800000;
-	if(m&1)	/* odd m, double x to make it even */
-	    ix += ix;
-	m >>= 1;	/* m = [m/2] */
-
-    /* generate sqrt(x) bit by bit */
-	ix += ix;
-	q = s = 0;		/* q = sqrt(x) */
-	r = 0x01000000;		/* r = moving bit from right to left */
-
-	while(r!=0) {
-	    t = s+r;
-	    if(t<=ix) {
-		s    = t+r;
-		ix  -= t;
-		q   += r;
-	    }
-	    ix += ix;
-	    r>>=1;
-	}
-
-    /* use floating add to find out rounding direction */
-	if(ix!=0) {
-	    z = one-tiny; /* trigger inexact flag */
-	    if (z>=one) {
-	        z = one+tiny;
-		if (z>one)
-		    q += 2;
-		else
-		    q += (q&1);
-	    }
-	}
-	ix = (q>>1)+0x3f000000;
-	ix += (m <<23);
-	SET_FLOAT_WORD(z,ix);
-	return z;
-}
diff --git a/libm/src/fpmath.h b/libm/src/fpmath.h
deleted file mode 100644
index 879bd7b..0000000
--- a/libm/src/fpmath.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
- * Copyright (c) 2002 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/libc/include/fpmath.h,v 1.3 2005/02/06 03:23:31 das Exp $
- */
-
-#include <endian.h>
-#include "_fpmath.h"
-
-union IEEEf2bits {
-	float	f;
-	struct {
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-		unsigned int	man	:23;
-		unsigned int	exp	:8;
-		unsigned int	sign	:1;
-#else /* _BIG_ENDIAN */
-		unsigned int	sign	:1;
-		unsigned int	exp	:8;
-		unsigned int	man	:23;
-#endif
-	} bits;
-};
-
-#define	DBL_MANH_SIZE	20
-#define	DBL_MANL_SIZE	32
-
-union IEEEd2bits {
-	double	d;
-	struct {
-/* #ifdef __ARMEB__ */
-#if (__BYTE_ORDER == __BIG_ENDIAN) || (defined(__arm__) && !defined(__VFP_FP__))
-		unsigned int	manh	:20;
-		unsigned int	exp	:11;
-		unsigned int	sign	:1;
-		unsigned int	manl	:32;
-#elif  __BYTE_ORDER == __LITTLE_ENDIAN 
-		unsigned int	manl	:32;
-		unsigned int	manh	:20;
-		unsigned int	exp	:11;
-		unsigned int	sign	:1;
-#elif __BYTE_ORDER == __BIG_ENDIAN
-		unsigned int	sign	:1;
-		unsigned int	exp	:11;
-		unsigned int	manh	:20;
-		unsigned int	manl	:32;
-#endif
-	} bits;
-};
diff --git a/libm/src/k_cos.c b/libm/src/k_cos.c
deleted file mode 100644
index 00916d7..0000000
--- a/libm/src/k_cos.c
+++ /dev/null
@@ -1,79 +0,0 @@
-
-/* @(#)k_cos.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/k_cos.c,v 1.10 2005/10/26 12:36:18 bde Exp $";
-#endif
-
-/*
- * __kernel_cos( x,  y )
- * kernel cos function on [-pi/4, pi/4], pi/4 ~ 0.785398164
- * Input x is assumed to be bounded by ~pi/4 in magnitude.
- * Input y is the tail of x. 
- *
- * Algorithm
- *	1. Since cos(-x) = cos(x), we need only to consider positive x.
- *	2. if x < 2^-27 (hx<0x3e400000 0), return 1 with inexact if x!=0.
- *	3. cos(x) is approximated by a polynomial of degree 14 on
- *	   [0,pi/4]
- *		  	                 4            14
- *	   	cos(x) ~ 1 - x*x/2 + C1*x + ... + C6*x
- *	   where the remez error is
- *	
- * 	|              2     4     6     8     10    12     14 |     -58
- * 	|cos(x)-(1-.5*x +C1*x +C2*x +C3*x +C4*x +C5*x  +C6*x  )| <= 2
- * 	|    					               | 
- * 
- * 	               4     6     8     10    12     14 
- *	4. let r = C1*x +C2*x +C3*x +C4*x +C5*x  +C6*x  , then
- *	       cos(x) ~ 1 - x*x/2 + r
- *	   since cos(x+y) ~ cos(x) - sin(x)*y 
- *			  ~ cos(x) - x*y,
- *	   a correction term is necessary in cos(x) and hence
- *		cos(x+y) = 1 - (x*x/2 - (r - x*y))
- *	   For better accuracy, rearrange to
- *		cos(x+y) ~ w + (tmp + (r-x*y))
- *	   where w = 1 - x*x/2 and tmp is a tiny correction term
- *	   (1 - x*x/2 == w + tmp exactly in infinite precision).
- *	   The exactness of w + tmp in infinite precision depends on w
- *	   and tmp having the same precision as x.  If they have extra
- *	   precision due to compiler bugs, then the extra precision is
- *	   only good provided it is retained in all terms of the final
- *	   expression for cos().  Retention happens in all cases tested
- *	   under FreeBSD, so don't pessimize things by forcibly clipping
- *	   any extra precision in w.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-one =  1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
-C1  =  4.16666666666666019037e-02, /* 0x3FA55555, 0x5555554C */
-C2  = -1.38888888888741095749e-03, /* 0xBF56C16C, 0x16C15177 */
-C3  =  2.48015872894767294178e-05, /* 0x3EFA01A0, 0x19CB1590 */
-C4  = -2.75573143513906633035e-07, /* 0xBE927E4F, 0x809C52AD */
-C5  =  2.08757232129817482790e-09, /* 0x3E21EE9E, 0xBDB4B1C4 */
-C6  = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */
-
-double
-__kernel_cos(double x, double y)
-{
-	double hz,z,r,w;
-
-	z  = x*x;
-	r  = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*C6)))));
-	hz = (float)0.5*z;
-	w  = one-hz;
-	return w + (((one-w)-hz) + (z*r-x*y));
-}
diff --git a/libm/src/k_cosf.c b/libm/src/k_cosf.c
deleted file mode 100644
index ff08d5f..0000000
--- a/libm/src/k_cosf.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/* k_cosf.c -- float version of k_cos.c
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Debugged and optimized by Bruce D. Evans.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef INLINE_KERNEL_COSDF
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/k_cosf.c,v 1.15 2005/11/30 11:51:17 bde Exp $";
-#endif
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-/* |cos(x) - c(x)| < 2**-34.1 (~[-5.37e-11, 5.295e-11]). */
-static const double
-one =  1.0,
-C0  = -0x1ffffffd0c5e81.0p-54,	/* -0.499999997251031003120 */
-C1  =  0x155553e1053a42.0p-57,	/*  0.0416666233237390631894 */
-C2  = -0x16c087e80f1e27.0p-62,	/* -0.00138867637746099294692 */
-C3  =  0x199342e0ee5069.0p-68;	/*  0.0000243904487962774090654 */
-
-#ifdef INLINE_KERNEL_COSDF
-extern inline
-#endif
-float
-__kernel_cosdf(double x)
-{
-	double r, w, z;
-
-	/* Try to optimize for parallel evaluation as in k_tanf.c. */
-	z = x*x;
-	w = z*z;
-	r = C2+z*C3;
-	return ((one+z*C0) + w*C1) + (w*z)*r;
-}
diff --git a/libm/src/k_rem_pio2.c b/libm/src/k_rem_pio2.c
deleted file mode 100644
index 7116f31..0000000
--- a/libm/src/k_rem_pio2.c
+++ /dev/null
@@ -1,304 +0,0 @@
-
-/* @(#)k_rem_pio2.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/k_rem_pio2.c,v 1.7 2005/02/04 18:26:06 das Exp $";
-#endif
-
-/*
- * __kernel_rem_pio2(x,y,e0,nx,prec,ipio2)
- * double x[],y[]; int e0,nx,prec; int ipio2[];
- * 
- * __kernel_rem_pio2 return the last three digits of N with 
- *		y = x - N*pi/2
- * so that |y| < pi/2.
- *
- * The method is to compute the integer (mod 8) and fraction parts of 
- * (2/pi)*x without doing the full multiplication. In general we
- * skip the part of the product that are known to be a huge integer (
- * more accurately, = 0 mod 8 ). Thus the number of operations are
- * independent of the exponent of the input.
- *
- * (2/pi) is represented by an array of 24-bit integers in ipio2[].
- *
- * Input parameters:
- * 	x[]	The input value (must be positive) is broken into nx 
- *		pieces of 24-bit integers in double precision format.
- *		x[i] will be the i-th 24 bit of x. The scaled exponent 
- *		of x[0] is given in input parameter e0 (i.e., x[0]*2^e0 
- *		match x's up to 24 bits.
- *
- *		Example of breaking a double positive z into x[0]+x[1]+x[2]:
- *			e0 = ilogb(z)-23
- *			z  = scalbn(z,-e0)
- *		for i = 0,1,2
- *			x[i] = floor(z)
- *			z    = (z-x[i])*2**24
- *
- *
- *	y[]	ouput result in an array of double precision numbers.
- *		The dimension of y[] is:
- *			24-bit  precision	1
- *			53-bit  precision	2
- *			64-bit  precision	2
- *			113-bit precision	3
- *		The actual value is the sum of them. Thus for 113-bit
- *		precison, one may have to do something like:
- *
- *		long double t,w,r_head, r_tail;
- *		t = (long double)y[2] + (long double)y[1];
- *		w = (long double)y[0];
- *		r_head = t+w;
- *		r_tail = w - (r_head - t);
- *
- *	e0	The exponent of x[0]
- *
- *	nx	dimension of x[]
- *
- *  	prec	an integer indicating the precision:
- *			0	24  bits (single)
- *			1	53  bits (double)
- *			2	64  bits (extended)
- *			3	113 bits (quad)
- *
- *	ipio2[]
- *		integer array, contains the (24*i)-th to (24*i+23)-th 
- *		bit of 2/pi after binary point. The corresponding 
- *		floating value is
- *
- *			ipio2[i] * 2^(-24(i+1)).
- *
- * External function:
- *	double scalbn(), floor();
- *
- *
- * Here is the description of some local variables:
- *
- * 	jk	jk+1 is the initial number of terms of ipio2[] needed
- *		in the computation. The recommended value is 2,3,4,
- *		6 for single, double, extended,and quad.
- *
- * 	jz	local integer variable indicating the number of 
- *		terms of ipio2[] used. 
- *
- *	jx	nx - 1
- *
- *	jv	index for pointing to the suitable ipio2[] for the
- *		computation. In general, we want
- *			( 2^e0*x[0] * ipio2[jv-1]*2^(-24jv) )/8
- *		is an integer. Thus
- *			e0-3-24*jv >= 0 or (e0-3)/24 >= jv
- *		Hence jv = max(0,(e0-3)/24).
- *
- *	jp	jp+1 is the number of terms in PIo2[] needed, jp = jk.
- *
- * 	q[]	double array with integral value, representing the
- *		24-bits chunk of the product of x and 2/pi.
- *
- *	q0	the corresponding exponent of q[0]. Note that the
- *		exponent for q[i] would be q0-24*i.
- *
- *	PIo2[]	double precision array, obtained by cutting pi/2
- *		into 24 bits chunks. 
- *
- *	f[]	ipio2[] in floating point 
- *
- *	iq[]	integer array by breaking up q[] in 24-bits chunk.
- *
- *	fq[]	final product of x*(2/pi) in fq[0],..,fq[jk]
- *
- *	ih	integer. If >0 it indicates q[] is >= 0.5, hence
- *		it also indicates the *sign* of the result.
- *
- */
-
-
-/*
- * Constants:
- * The hexadecimal values are the intended ones for the following 
- * constants. The decimal values may be used, provided that the 
- * compiler will convert from decimal to binary accurately enough 
- * to produce the hexadecimal values shown.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const int init_jk[] = {2,3,4,6}; /* initial value for jk */
-
-static const double PIo2[] = {
-  1.57079625129699707031e+00, /* 0x3FF921FB, 0x40000000 */
-  7.54978941586159635335e-08, /* 0x3E74442D, 0x00000000 */
-  5.39030252995776476554e-15, /* 0x3CF84698, 0x80000000 */
-  3.28200341580791294123e-22, /* 0x3B78CC51, 0x60000000 */
-  1.27065575308067607349e-29, /* 0x39F01B83, 0x80000000 */
-  1.22933308981111328932e-36, /* 0x387A2520, 0x40000000 */
-  2.73370053816464559624e-44, /* 0x36E38222, 0x80000000 */
-  2.16741683877804819444e-51, /* 0x3569F31D, 0x00000000 */
-};
-
-static const double			
-zero   = 0.0,
-one    = 1.0,
-two24   =  1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */
-twon24  =  5.96046447753906250000e-08; /* 0x3E700000, 0x00000000 */
-
-	int __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int32_t *ipio2)
-{
-	int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih;
-	double z,fw,f[20],fq[20],q[20];
-
-    /* initialize jk*/
-	jk = init_jk[prec];
-	jp = jk;
-
-    /* determine jx,jv,q0, note that 3>q0 */
-	jx =  nx-1;
-	jv = (e0-3)/24; if(jv<0) jv=0;
-	q0 =  e0-24*(jv+1);
-
-    /* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */
-	j = jv-jx; m = jx+jk;
-	for(i=0;i<=m;i++,j++) f[i] = (j<0)? zero : (double) ipio2[j];
-
-    /* compute q[0],q[1],...q[jk] */
-	for (i=0;i<=jk;i++) {
-	    for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
-	}
-
-	jz = jk;
-recompute:
-    /* distill q[] into iq[] reversingly */
-	for(i=0,j=jz,z=q[jz];j>0;i++,j--) {
-	    fw    =  (double)((int32_t)(twon24* z));
-	    iq[i] =  (int32_t)(z-two24*fw);
-	    z     =  q[j-1]+fw;
-	}
-
-    /* compute n */
-	z  = scalbn(z,q0);		/* actual value of z */
-	z -= 8.0*floor(z*0.125);		/* trim off integer >= 8 */
-	n  = (int32_t) z;
-	z -= (double)n;
-	ih = 0;
-	if(q0>0) {	/* need iq[jz-1] to determine n */
-	    i  = (iq[jz-1]>>(24-q0)); n += i;
-	    iq[jz-1] -= i<<(24-q0);
-	    ih = iq[jz-1]>>(23-q0);
-	} 
-	else if(q0==0) ih = iq[jz-1]>>23;
-	else if(z>=0.5) ih=2;
-
-	if(ih>0) {	/* q > 0.5 */
-	    n += 1; carry = 0;
-	    for(i=0;i<jz ;i++) {	/* compute 1-q */
-		j = iq[i];
-		if(carry==0) {
-		    if(j!=0) {
-			carry = 1; iq[i] = 0x1000000- j;
-		    }
-		} else  iq[i] = 0xffffff - j;
-	    }
-	    if(q0>0) {		/* rare case: chance is 1 in 12 */
-	        switch(q0) {
-	        case 1:
-	    	   iq[jz-1] &= 0x7fffff; break;
-	    	case 2:
-	    	   iq[jz-1] &= 0x3fffff; break;
-	        }
-	    }
-	    if(ih==2) {
-		z = one - z;
-		if(carry!=0) z -= scalbn(one,q0);
-	    }
-	}
-
-    /* check if recomputation is needed */
-	if(z==zero) {
-	    j = 0;
-	    for (i=jz-1;i>=jk;i--) j |= iq[i];
-	    if(j==0) { /* need recomputation */
-		for(k=1;iq[jk-k]==0;k++);   /* k = no. of terms needed */
-
-		for(i=jz+1;i<=jz+k;i++) {   /* add q[jz+1] to q[jz+k] */
-		    f[jx+i] = (double) ipio2[jv+i];
-		    for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j];
-		    q[i] = fw;
-		}
-		jz += k;
-		goto recompute;
-	    }
-	}
-
-    /* chop off zero terms */
-	if(z==0.0) {
-	    jz -= 1; q0 -= 24;
-	    while(iq[jz]==0) { jz--; q0-=24;}
-	} else { /* break z into 24-bit if necessary */
-	    z = scalbn(z,-q0);
-	    if(z>=two24) { 
-		fw = (double)((int32_t)(twon24*z));
-		iq[jz] = (int32_t)(z-two24*fw);
-		jz += 1; q0 += 24;
-		iq[jz] = (int32_t) fw;
-	    } else iq[jz] = (int32_t) z ;
-	}
-
-    /* convert integer "bit" chunk to floating-point value */
-	fw = scalbn(one,q0);
-	for(i=jz;i>=0;i--) {
-	    q[i] = fw*(double)iq[i]; fw*=twon24;
-	}
-
-    /* compute PIo2[0,...,jp]*q[jz,...,0] */
-	for(i=jz;i>=0;i--) {
-	    for(fw=0.0,k=0;k<=jp&&k<=jz-i;k++) fw += PIo2[k]*q[i+k];
-	    fq[jz-i] = fw;
-	}
-
-    /* compress fq[] into y[] */
-	switch(prec) {
-	    case 0:
-		fw = 0.0;
-		for (i=jz;i>=0;i--) fw += fq[i];
-		y[0] = (ih==0)? fw: -fw; 
-		break;
-	    case 1:
-	    case 2:
-		fw = 0.0;
-		for (i=jz;i>=0;i--) fw += fq[i]; 
-		y[0] = (ih==0)? fw: -fw; 
-		fw = fq[0]-fw;
-		for (i=1;i<=jz;i++) fw += fq[i];
-		y[1] = (ih==0)? fw: -fw; 
-		break;
-	    case 3:	/* painful */
-		for (i=jz;i>0;i--) {
-		    fw      = fq[i-1]+fq[i]; 
-		    fq[i]  += fq[i-1]-fw;
-		    fq[i-1] = fw;
-		}
-		for (i=jz;i>1;i--) {
-		    fw      = fq[i-1]+fq[i]; 
-		    fq[i]  += fq[i-1]-fw;
-		    fq[i-1] = fw;
-		}
-		for (fw=0.0,i=jz;i>=2;i--) fw += fq[i]; 
-		if(ih==0) {
-		    y[0] =  fq[0]; y[1] =  fq[1]; y[2] =  fw;
-		} else {
-		    y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw;
-		}
-	}
-	return n&7;
-}
diff --git a/libm/src/k_rem_pio2f.c b/libm/src/k_rem_pio2f.c
deleted file mode 100644
index 35c28f5..0000000
--- a/libm/src/k_rem_pio2f.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/* k_rem_pio2f.c -- float version of k_rem_pio2.c
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/k_rem_pio2f.c,v 1.8 2005/10/11 07:56:05 bde Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-/* In the float version, the input parameter x contains 8 bit
-   integers, not 24 bit integers.  113 bit precision is not supported.  */
-
-static const int init_jk[] = {4,7,9}; /* initial value for jk */
-
-static const float PIo2[] = {
-  1.5703125000e+00, /* 0x3fc90000 */
-  4.5776367188e-04, /* 0x39f00000 */
-  2.5987625122e-05, /* 0x37da0000 */
-  7.5437128544e-08, /* 0x33a20000 */
-  6.0026650317e-11, /* 0x2e840000 */
-  7.3896444519e-13, /* 0x2b500000 */
-  5.3845816694e-15, /* 0x27c20000 */
-  5.6378512969e-18, /* 0x22d00000 */
-  8.3009228831e-20, /* 0x1fc40000 */
-  3.2756352257e-22, /* 0x1bc60000 */
-  6.3331015649e-25, /* 0x17440000 */
-};
-
-static const float
-zero   = 0.0,
-one    = 1.0,
-two8   =  2.5600000000e+02, /* 0x43800000 */
-twon8  =  3.9062500000e-03; /* 0x3b800000 */
-
-	int __kernel_rem_pio2f(float *x, float *y, int e0, int nx, int prec, const int32_t *ipio2)
-{
-	int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih;
-	float z,fw,f[20],fq[20],q[20];
-
-    /* initialize jk*/
-	jk = init_jk[prec];
-	jp = jk;
-
-    /* determine jx,jv,q0, note that 3>q0 */
-	jx =  nx-1;
-	jv = (e0-3)/8; if(jv<0) jv=0;
-	q0 =  e0-8*(jv+1);
-
-    /* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */
-	j = jv-jx; m = jx+jk;
-	for(i=0;i<=m;i++,j++) f[i] = (j<0)? zero : (float) ipio2[j];
-
-    /* compute q[0],q[1],...q[jk] */
-	for (i=0;i<=jk;i++) {
-	    for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
-	}
-
-	jz = jk;
-recompute:
-    /* distill q[] into iq[] reversingly */
-	for(i=0,j=jz,z=q[jz];j>0;i++,j--) {
-	    fw    =  (float)((int32_t)(twon8* z));
-	    iq[i] =  (int32_t)(z-two8*fw);
-	    z     =  q[j-1]+fw;
-	}
-
-    /* compute n */
-	z  = scalbnf(z,q0);		/* actual value of z */
-	z -= (float)8.0*floorf(z*(float)0.125);	/* trim off integer >= 8 */
-	n  = (int32_t) z;
-	z -= (float)n;
-	ih = 0;
-	if(q0>0) {	/* need iq[jz-1] to determine n */
-	    i  = (iq[jz-1]>>(8-q0)); n += i;
-	    iq[jz-1] -= i<<(8-q0);
-	    ih = iq[jz-1]>>(7-q0);
-	}
-	else if(q0==0) ih = iq[jz-1]>>7;
-	else if(z>=(float)0.5) ih=2;
-
-	if(ih>0) {	/* q > 0.5 */
-	    n += 1; carry = 0;
-	    for(i=0;i<jz ;i++) {	/* compute 1-q */
-		j = iq[i];
-		if(carry==0) {
-		    if(j!=0) {
-			carry = 1; iq[i] = 0x100- j;
-		    }
-		} else  iq[i] = 0xff - j;
-	    }
-	    if(q0>0) {		/* rare case: chance is 1 in 12 */
-	        switch(q0) {
-	        case 1:
-	    	   iq[jz-1] &= 0x7f; break;
-	    	case 2:
-	    	   iq[jz-1] &= 0x3f; break;
-	        }
-	    }
-	    if(ih==2) {
-		z = one - z;
-		if(carry!=0) z -= scalbnf(one,q0);
-	    }
-	}
-
-    /* check if recomputation is needed */
-	if(z==zero) {
-	    j = 0;
-	    for (i=jz-1;i>=jk;i--) j |= iq[i];
-	    if(j==0) { /* need recomputation */
-		for(k=1;iq[jk-k]==0;k++);   /* k = no. of terms needed */
-
-		for(i=jz+1;i<=jz+k;i++) {   /* add q[jz+1] to q[jz+k] */
-		    f[jx+i] = (float) ipio2[jv+i];
-		    for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j];
-		    q[i] = fw;
-		}
-		jz += k;
-		goto recompute;
-	    }
-	}
-
-    /* chop off zero terms */
-	if(z==(float)0.0) {
-	    jz -= 1; q0 -= 8;
-	    while(iq[jz]==0) { jz--; q0-=8;}
-	} else { /* break z into 8-bit if necessary */
-	    z = scalbnf(z,-q0);
-	    if(z>=two8) {
-		fw = (float)((int32_t)(twon8*z));
-		iq[jz] = (int32_t)(z-two8*fw);
-		jz += 1; q0 += 8;
-		iq[jz] = (int32_t) fw;
-	    } else iq[jz] = (int32_t) z ;
-	}
-
-    /* convert integer "bit" chunk to floating-point value */
-	fw = scalbnf(one,q0);
-	for(i=jz;i>=0;i--) {
-	    q[i] = fw*(float)iq[i]; fw*=twon8;
-	}
-
-    /* compute PIo2[0,...,jp]*q[jz,...,0] */
-	for(i=jz;i>=0;i--) {
-	    for(fw=0.0,k=0;k<=jp&&k<=jz-i;k++) fw += PIo2[k]*q[i+k];
-	    fq[jz-i] = fw;
-	}
-
-    /* compress fq[] into y[] */
-	switch(prec) {
-	    case 0:
-		fw = 0.0;
-		for (i=jz;i>=0;i--) fw += fq[i];
-		y[0] = (ih==0)? fw: -fw;
-		break;
-	    case 1:
-	    case 2:
-		fw = 0.0;
-		for (i=jz;i>=0;i--) fw += fq[i];
-		fw = *(volatile float *)&fw;	/* clip any extra precision */
-		y[0] = (ih==0)? fw: -fw;
-		fw = fq[0]-fw;
-		for (i=1;i<=jz;i++) fw += fq[i];
-		y[1] = (ih==0)? fw: -fw;
-		break;
-	    case 3:	/* painful */
-		for (i=jz;i>0;i--) {
-		    fw      = fq[i-1]+fq[i];
-		    fq[i]  += fq[i-1]-fw;
-		    fq[i-1] = fw;
-		}
-		for (i=jz;i>1;i--) {
-		    fw      = fq[i-1]+fq[i];
-		    fq[i]  += fq[i-1]-fw;
-		    fq[i-1] = fw;
-		}
-		for (fw=0.0,i=jz;i>=2;i--) fw += fq[i];
-		if(ih==0) {
-		    y[0] =  fq[0]; y[1] =  fq[1]; y[2] =  fw;
-		} else {
-		    y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw;
-		}
-	}
-	return n&7;
-}
diff --git a/libm/src/k_sin.c b/libm/src/k_sin.c
deleted file mode 100644
index ae06a9d..0000000
--- a/libm/src/k_sin.c
+++ /dev/null
@@ -1,70 +0,0 @@
-
-/* @(#)k_sin.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/k_sin.c,v 1.10 2005/11/02 13:06:49 bde Exp $";
-#endif
-
-/* __kernel_sin( x, y, iy)
- * kernel sin function on ~[-pi/4, pi/4] (except on -0), pi/4 ~ 0.7854
- * Input x is assumed to be bounded by ~pi/4 in magnitude.
- * Input y is the tail of x.
- * Input iy indicates whether y is 0. (if iy=0, y assume to be 0). 
- *
- * Algorithm
- *	1. Since sin(-x) = -sin(x), we need only to consider positive x. 
- *	2. Callers must return sin(-0) = -0 without calling here since our
- *	   odd polynomial is not evaluated in a way that preserves -0.
- *	   Callers may do the optimization sin(x) ~ x for tiny x.
- *	3. sin(x) is approximated by a polynomial of degree 13 on
- *	   [0,pi/4]
- *		  	         3            13
- *	   	sin(x) ~ x + S1*x + ... + S6*x
- *	   where
- *	
- * 	|sin(x)         2     4     6     8     10     12  |     -58
- * 	|----- - (1+S1*x +S2*x +S3*x +S4*x +S5*x  +S6*x   )| <= 2
- * 	|  x 					           | 
- * 
- *	4. sin(x+y) = sin(x) + sin'(x')*y
- *		    ~ sin(x) + (1-x*x/2)*y
- *	   For better accuracy, let 
- *		     3      2      2      2      2
- *		r = x *(S2+x *(S3+x *(S4+x *(S5+x *S6))))
- *	   then                   3    2
- *		sin(x) = x + (S1*x + (x *(r-y/2)+y))
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-half =  5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
-S1  = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549 */
-S2  =  8.33333333332248946124e-03, /* 0x3F811111, 0x1110F8A6 */
-S3  = -1.98412698298579493134e-04, /* 0xBF2A01A0, 0x19C161D5 */
-S4  =  2.75573137070700676789e-06, /* 0x3EC71DE3, 0x57B1FE7D */
-S5  = -2.50507602534068634195e-08, /* 0xBE5AE5E6, 0x8A2B9CEB */
-S6  =  1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */
-
-double
-__kernel_sin(double x, double y, int iy)
-{
-	double z,r,v;
-
-	z	=  x*x;
-	v	=  z*x;
-	r	=  S2+z*(S3+z*(S4+z*(S5+z*S6)));
-	if(iy==0) return x+v*(S1+z*r);
-	else      return x-((z*(half*y-v*r)-y)-v*S1);
-}
diff --git a/libm/src/k_sinf.c b/libm/src/k_sinf.c
deleted file mode 100644
index e45dc42..0000000
--- a/libm/src/k_sinf.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/* k_sinf.c -- float version of k_sin.c
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Optimized by Bruce D. Evans.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef INLINE_KERNEL_SINDF
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/k_sinf.c,v 1.13 2005/11/30 11:51:17 bde Exp $";
-#endif
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-/* |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]). */
-static const double
-S1 = -0x15555554cbac77.0p-55,	/* -0.166666666416265235595 */
-S2 =  0x111110896efbb2.0p-59,	/*  0.0083333293858894631756 */
-S3 = -0x1a00f9e2cae774.0p-65,	/* -0.000198393348360966317347 */
-S4 =  0x16cd878c3b46a7.0p-71;	/*  0.0000027183114939898219064 */
-
-#ifdef INLINE_KERNEL_SINDF
-extern inline
-#endif
-float
-__kernel_sindf(double x)
-{
-	double r, s, w, z;
-
-	/* Try to optimize for parallel evaluation as in k_tanf.c. */
-	z = x*x;
-	w = z*z;
-	r = S3+z*S4;
-	s = z*x;
-	return (x + s*(S1+z*S2)) + s*w*r;
-}
diff --git a/libm/src/k_tan.c b/libm/src/k_tan.c
deleted file mode 100644
index 82fe155..0000000
--- a/libm/src/k_tan.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/* @(#)k_tan.c 1.5 04/04/22 SMI */
-
-/*
- * ====================================================
- * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
- *
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/* INDENT OFF */
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/k_tan.c,v 1.12 2005/11/02 14:01:45 bde Exp $";
-#endif
-
-/* __kernel_tan( x, y, k )
- * kernel tan function on ~[-pi/4, pi/4] (except on -0), pi/4 ~ 0.7854
- * Input x is assumed to be bounded by ~pi/4 in magnitude.
- * Input y is the tail of x.
- * Input k indicates whether tan (if k = 1) or -1/tan (if k = -1) is returned.
- *
- * Algorithm
- *	1. Since tan(-x) = -tan(x), we need only to consider positive x.
- *	2. Callers must return tan(-0) = -0 without calling here since our
- *	   odd polynomial is not evaluated in a way that preserves -0.
- *	   Callers may do the optimization tan(x) ~ x for tiny x.
- *	3. tan(x) is approximated by a odd polynomial of degree 27 on
- *	   [0,0.67434]
- *		  	         3             27
- *	   	tan(x) ~ x + T1*x + ... + T13*x
- *	   where
- *
- * 	        |tan(x)         2     4            26   |     -59.2
- * 	        |----- - (1+T1*x +T2*x +.... +T13*x    )| <= 2
- * 	        |  x 					|
- *
- *	   Note: tan(x+y) = tan(x) + tan'(x)*y
- *		          ~ tan(x) + (1+x*x)*y
- *	   Therefore, for better accuracy in computing tan(x+y), let
- *		     3      2      2       2       2
- *		r = x *(T2+x *(T3+x *(...+x *(T12+x *T13))))
- *	   then
- *		 		    3    2
- *		tan(x+y) = x + (T1*x + (x *(r+y)+y))
- *
- *      4. For x in [0.67434,pi/4],  let y = pi/4 - x, then
- *		tan(x) = tan(pi/4-y) = (1-tan(y))/(1+tan(y))
- *		       = 1 - 2*(tan(y) - (tan(y)^2)/(1+tan(y)))
- */
-
-#include "math.h"
-#include "math_private.h"
-static const double xxx[] = {
-		 3.33333333333334091986e-01,	/* 3FD55555, 55555563 */
-		 1.33333333333201242699e-01,	/* 3FC11111, 1110FE7A */
-		 5.39682539762260521377e-02,	/* 3FABA1BA, 1BB341FE */
-		 2.18694882948595424599e-02,	/* 3F9664F4, 8406D637 */
-		 8.86323982359930005737e-03,	/* 3F8226E3, E96E8493 */
-		 3.59207910759131235356e-03,	/* 3F6D6D22, C9560328 */
-		 1.45620945432529025516e-03,	/* 3F57DBC8, FEE08315 */
-		 5.88041240820264096874e-04,	/* 3F4344D8, F2F26501 */
-		 2.46463134818469906812e-04,	/* 3F3026F7, 1A8D1068 */
-		 7.81794442939557092300e-05,	/* 3F147E88, A03792A6 */
-		 7.14072491382608190305e-05,	/* 3F12B80F, 32F0A7E9 */
-		-1.85586374855275456654e-05,	/* BEF375CB, DB605373 */
-		 2.59073051863633712884e-05,	/* 3EFB2A70, 74BF7AD4 */
-/* one */	 1.00000000000000000000e+00,	/* 3FF00000, 00000000 */
-/* pio4 */	 7.85398163397448278999e-01,	/* 3FE921FB, 54442D18 */
-/* pio4lo */	 3.06161699786838301793e-17	/* 3C81A626, 33145C07 */
-};
-#define	one	xxx[13]
-#define	pio4	xxx[14]
-#define	pio4lo	xxx[15]
-#define	T	xxx
-/* INDENT ON */
-
-double
-__kernel_tan(double x, double y, int iy) {
-	double z, r, v, w, s;
-	int32_t ix, hx;
-
-	GET_HIGH_WORD(hx,x);
-	ix = hx & 0x7fffffff;			/* high word of |x| */
-	if (ix >= 0x3FE59428) {	/* |x| >= 0.6744 */
-		if (hx < 0) {
-			x = -x;
-			y = -y;
-		}
-		z = pio4 - x;
-		w = pio4lo - y;
-		x = z + w;
-		y = 0.0;
-	}
-	z = x * x;
-	w = z * z;
-	/*
-	 * Break x^5*(T[1]+x^2*T[2]+...) into
-	 * x^5(T[1]+x^4*T[3]+...+x^20*T[11]) +
-	 * x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12]))
-	 */
-	r = T[1] + w * (T[3] + w * (T[5] + w * (T[7] + w * (T[9] +
-		w * T[11]))));
-	v = z * (T[2] + w * (T[4] + w * (T[6] + w * (T[8] + w * (T[10] +
-		w * T[12])))));
-	s = z * x;
-	r = y + z * (s * (r + v) + y);
-	r += T[0] * s;
-	w = x + r;
-	if (ix >= 0x3FE59428) {
-		v = (double) iy;
-		return (double) (1 - ((hx >> 30) & 2)) *
-			(v - 2.0 * (x - (w * w / (w + v) - r)));
-	}
-	if (iy == 1)
-		return w;
-	else {
-		/*
-		 * if allow error up to 2 ulp, simply return
-		 * -1.0 / (x+r) here
-		 */
-		/* compute -1.0 / (x+r) accurately */
-		double a, t;
-		z = w;
-		SET_LOW_WORD(z,0);
-		v = r - (z - x);	/* z+v = r+x */
-		t = a = -1.0 / w;	/* a = -1.0/w */
-		SET_LOW_WORD(t,0);
-		s = 1.0 + t * z;
-		return t + a * (s + t * v);
-	}
-}
diff --git a/libm/src/k_tanf.c b/libm/src/k_tanf.c
deleted file mode 100644
index 6574030..0000000
--- a/libm/src/k_tanf.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/* k_tanf.c -- float version of k_tan.c
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Optimized by Bruce D. Evans.
- */
-
-/*
- * ====================================================
- * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
- *
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef INLINE_KERNEL_TANDF
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/k_tanf.c,v 1.20 2005/11/28 11:46:20 bde Exp $";
-#endif
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-/* |tan(x)/x - t(x)| < 2**-25.5 (~[-2e-08, 2e-08]). */
-static const double
-T[] =  {
-  0x15554d3418c99f.0p-54,	/* 0.333331395030791399758 */
-  0x1112fd38999f72.0p-55,	/* 0.133392002712976742718 */
-  0x1b54c91d865afe.0p-57,	/* 0.0533812378445670393523 */
-  0x191df3908c33ce.0p-58,	/* 0.0245283181166547278873 */
-  0x185dadfcecf44e.0p-61,	/* 0.00297435743359967304927 */
-  0x1362b9bf971bcd.0p-59,	/* 0.00946564784943673166728 */
-};
-
-#ifdef INLINE_KERNEL_TANDF
-extern inline
-#endif
-float
-__kernel_tandf(double x, int iy)
-{
-	double z,r,w,s,t,u;
-
-	z	=  x*x;
-	/*
-	 * Split up the polynomial into small independent terms to give
-	 * opportunities for parallel evaluation.  The chosen splitting is
-	 * micro-optimized for Athlons (XP, X64).  It costs 2 multiplications
-	 * relative to Horner's method on sequential machines.
-	 *
-	 * We add the small terms from lowest degree up for efficiency on
-	 * non-sequential machines (the lowest degree terms tend to be ready
-	 * earlier).  Apart from this, we don't care about order of
-	 * operations, and don't need to to care since we have precision to
-	 * spare.  However, the chosen splitting is good for accuracy too,
-	 * and would give results as accurate as Horner's method if the
-	 * small terms were added from highest degree down.
-	 */
-	r = T[4]+z*T[5];
-	t = T[2]+z*T[3];
-	w = z*z;
-	s = z*x;
-	u = T[0]+z*T[1];
-	r = (x+s*u)+(s*w)*(t+w*r);
-	if(iy==1) return r;
-	else return -1.0/r;
-}
diff --git a/libm/src/math_private.h b/libm/src/math_private.h
deleted file mode 100644
index 5f6e088..0000000
--- a/libm/src/math_private.h
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
- * from: @(#)fdlibm.h 5.1 93/09/24
- * $FreeBSD: src/lib/msun/src/math_private.h,v 1.20 2005/11/28 04:58:57 bde Exp $
- */
-
-#ifndef _MATH_PRIVATE_H_
-#define	_MATH_PRIVATE_H_
-
-#include <sys/types.h>
-#include <endian.h>
-
-/*
- * The original fdlibm code used statements like:
- *	n0 = ((*(int*)&one)>>29)^1;		* index of high word *
- *	ix0 = *(n0+(int*)&x);			* high word of x *
- *	ix1 = *((1-n0)+(int*)&x);		* low word of x *
- * to dig two 32 bit words out of the 64 bit IEEE floating point
- * value.  That is non-ANSI, and, moreover, the gcc instruction
- * scheduler gets it wrong.  We instead use the following macros.
- * Unlike the original code, we determine the endianness at compile
- * time, not at run time; I don't see much benefit to selecting
- * endianness at run time.
- */
-
-/*
- * A union which permits us to convert between a double and two 32 bit
- * ints.
- */
-
-#if (__BYTE_ORDER == __BIG_ENDIAN) || (defined(__arm__) && !defined(__VFP_FP__))
-
-typedef union
-{
-  double value;
-  struct
-  {
-    u_int32_t msw;
-    u_int32_t lsw;
-  } parts;
-} ieee_double_shape_type;
-
-#endif
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN  && !(defined(__arm__) && !defined(__VFP_FP__))
-
-typedef union
-{
-  double value;
-  struct
-  {
-    u_int32_t lsw;
-    u_int32_t msw;
-  } parts;
-} ieee_double_shape_type;
-
-#endif
-
-/* Get two 32 bit ints from a double.  */
-
-#define EXTRACT_WORDS(ix0,ix1,d)				\
-do {								\
-  ieee_double_shape_type ew_u;					\
-  ew_u.value = (d);						\
-  (ix0) = ew_u.parts.msw;					\
-  (ix1) = ew_u.parts.lsw;					\
-} while (0)
-
-/* Get the more significant 32 bit int from a double.  */
-
-#define GET_HIGH_WORD(i,d)					\
-do {								\
-  ieee_double_shape_type gh_u;					\
-  gh_u.value = (d);						\
-  (i) = gh_u.parts.msw;						\
-} while (0)
-
-/* Get the less significant 32 bit int from a double.  */
-
-#define GET_LOW_WORD(i,d)					\
-do {								\
-  ieee_double_shape_type gl_u;					\
-  gl_u.value = (d);						\
-  (i) = gl_u.parts.lsw;						\
-} while (0)
-
-/* Set a double from two 32 bit ints.  */
-
-#define INSERT_WORDS(d,ix0,ix1)					\
-do {								\
-  ieee_double_shape_type iw_u;					\
-  iw_u.parts.msw = (ix0);					\
-  iw_u.parts.lsw = (ix1);					\
-  (d) = iw_u.value;						\
-} while (0)
-
-/* Set the more significant 32 bits of a double from an int.  */
-
-#define SET_HIGH_WORD(d,v)					\
-do {								\
-  ieee_double_shape_type sh_u;					\
-  sh_u.value = (d);						\
-  sh_u.parts.msw = (v);						\
-  (d) = sh_u.value;						\
-} while (0)
-
-/* Set the less significant 32 bits of a double from an int.  */
-
-#define SET_LOW_WORD(d,v)					\
-do {								\
-  ieee_double_shape_type sl_u;					\
-  sl_u.value = (d);						\
-  sl_u.parts.lsw = (v);						\
-  (d) = sl_u.value;						\
-} while (0)
-
-/*
- * A union which permits us to convert between a float and a 32 bit
- * int.
- */
-
-typedef union
-{
-  float value;
-  /* FIXME: Assumes 32 bit int.  */
-  unsigned int word;
-} ieee_float_shape_type;
-
-/* Get a 32 bit int from a float.  */
-
-#define GET_FLOAT_WORD(i,d)					\
-do {								\
-  ieee_float_shape_type gf_u;					\
-  gf_u.value = (d);						\
-  (i) = gf_u.word;						\
-} while (0)
-
-/* Set a float from a 32 bit int.  */
-
-#define SET_FLOAT_WORD(d,i)					\
-do {								\
-  ieee_float_shape_type sf_u;					\
-  sf_u.word = (i);						\
-  (d) = sf_u.value;						\
-} while (0)
-
-#ifdef _COMPLEX_H
-/*
- * Inline functions that can be used to construct complex values.
- *
- * The C99 standard intends x+I*y to be used for this, but x+I*y is
- * currently unusable in general since gcc introduces many overflow,
- * underflow, sign and efficiency bugs by rewriting I*y as
- * (0.0+I)*(y+0.0*I) and laboriously computing the full complex product.
- * In particular, I*Inf is corrupted to NaN+I*Inf, and I*-0 is corrupted
- * to -0.0+I*0.0.
- */
-static __inline float complex
-cpackf(float x, float y)
-{
-	float complex z;
-
-	__real__ z = x;
-	__imag__ z = y;
-	return (z);
-}
-
-static __inline double complex
-cpack(double x, double y)
-{
-	double complex z;
-
-	__real__ z = x;
-	__imag__ z = y;
-	return (z);
-}
-
-static __inline long double complex
-cpackl(long double x, long double y)
-{
-	long double complex z;
-
-	__real__ z = x;
-	__imag__ z = y;
-	return (z);
-}
-#endif /* _COMPLEX_H */
- 
-/*
- * ieee style elementary functions
- *
- * We rename functions here to improve other sources' diffability
- * against fdlibm.
- */
-#define	__ieee754_sqrt	sqrt
-#define	__ieee754_acos	acos
-#define	__ieee754_acosh	acosh
-#define	__ieee754_log	log
-#define	__ieee754_atanh	atanh
-#define	__ieee754_asin	asin
-#define	__ieee754_atan2	atan2
-#define	__ieee754_exp	exp
-#define	__ieee754_cosh	cosh
-#define	__ieee754_fmod	fmod
-#define	__ieee754_pow	pow
-#define	__ieee754_lgamma lgamma
-#define	__ieee754_gamma	gamma
-#define	__ieee754_lgamma_r lgamma_r
-#define	__ieee754_gamma_r gamma_r
-#define	__ieee754_log10	log10
-#define	__ieee754_sinh	sinh
-#define	__ieee754_hypot	hypot
-#define	__ieee754_j0	j0
-#define	__ieee754_j1	j1
-#define	__ieee754_y0	y0
-#define	__ieee754_y1	y1
-#define	__ieee754_jn	jn
-#define	__ieee754_yn	yn
-#define	__ieee754_remainder remainder
-#define	__ieee754_scalb	scalb
-#define	__ieee754_sqrtf	sqrtf
-#define	__ieee754_acosf	acosf
-#define	__ieee754_acoshf acoshf
-#define	__ieee754_logf	logf
-#define	__ieee754_atanhf atanhf
-#define	__ieee754_asinf	asinf
-#define	__ieee754_atan2f atan2f
-#define	__ieee754_expf	expf
-#define	__ieee754_coshf	coshf
-#define	__ieee754_fmodf	fmodf
-#define	__ieee754_powf	powf
-#define	__ieee754_lgammaf lgammaf
-#define	__ieee754_gammaf gammaf
-#define	__ieee754_lgammaf_r lgammaf_r
-#define	__ieee754_gammaf_r gammaf_r
-#define	__ieee754_log10f log10f
-#define	__ieee754_sinhf	sinhf
-#define	__ieee754_hypotf hypotf
-#define	__ieee754_j0f	j0f
-#define	__ieee754_j1f	j1f
-#define	__ieee754_y0f	y0f
-#define	__ieee754_y1f	y1f
-#define	__ieee754_jnf	jnf
-#define	__ieee754_ynf	ynf
-#define	__ieee754_remainderf remainderf
-#define	__ieee754_scalbf scalbf
-#define __ieee754_ldexpf ldexpf
-
-/* fdlibm kernel function */
-int	__ieee754_rem_pio2(double,double*);
-double	__kernel_sin(double,double,int);
-double	__kernel_cos(double,double);
-double	__kernel_tan(double,double,int);
-int	__kernel_rem_pio2(double*,double*,int,int,int,const int*);
-
-/* float versions of fdlibm kernel functions */
-int	__ieee754_rem_pio2f(float,float*);
-float	__kernel_sindf(double);
-float	__kernel_cosdf(double);
-float	__kernel_tandf(double,int);
-int	__kernel_rem_pio2f(float*,float*,int,int,int,const int*);
-
-#endif /* !_MATH_PRIVATE_H_ */
diff --git a/libm/src/s_asinh.c b/libm/src/s_asinh.c
deleted file mode 100644
index 079007f..0000000
--- a/libm/src/s_asinh.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/* @(#)s_asinh.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_asinh.c,v 1.8 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-/* asinh(x)
- * Method :
- *	Based on
- *		asinh(x) = sign(x) * log [ |x| + sqrt(x*x+1) ]
- *	we have
- *	asinh(x) := x  if  1+x*x=1,
- *		 := sign(x)*(log(x)+ln2)) for large |x|, else
- *		 := sign(x)*log(2|x|+1/(|x|+sqrt(x*x+1))) if|x|>2, else
- *		 := sign(x)*log1p(|x| + x^2/(1 + sqrt(1+x^2)))
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-one =  1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
-ln2 =  6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */
-huge=  1.00000000000000000000e+300;
-
-double
-asinh(double x)
-{
-	double t,w;
-	int32_t hx,ix;
-	GET_HIGH_WORD(hx,x);
-	ix = hx&0x7fffffff;
-	if(ix>=0x7ff00000) return x+x;	/* x is inf or NaN */
-	if(ix< 0x3e300000) {	/* |x|<2**-28 */
-	    if(huge+x>one) return x;	/* return x inexact except 0 */
-	}
-	if(ix>0x41b00000) {	/* |x| > 2**28 */
-	    w = __ieee754_log(fabs(x))+ln2;
-	} else if (ix>0x40000000) {	/* 2**28 > |x| > 2.0 */
-	    t = fabs(x);
-	    w = __ieee754_log(2.0*t+one/(__ieee754_sqrt(x*x+one)+t));
-	} else {		/* 2.0 > |x| > 2**-28 */
-	    t = x*x;
-	    w =log1p(fabs(x)+t/(one+__ieee754_sqrt(one+t)));
-	}
-	if(hx>0) return w; else return -w;
-}
diff --git a/libm/src/s_asinhf.c b/libm/src/s_asinhf.c
deleted file mode 100644
index 73dc798..0000000
--- a/libm/src/s_asinhf.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* s_asinhf.c -- float version of s_asinh.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_asinhf.c,v 1.8 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float
-one =  1.0000000000e+00, /* 0x3F800000 */
-ln2 =  6.9314718246e-01, /* 0x3f317218 */
-huge=  1.0000000000e+30;
-
-float
-asinhf(float x)
-{
-	float t,w;
-	int32_t hx,ix;
-	GET_FLOAT_WORD(hx,x);
-	ix = hx&0x7fffffff;
-	if(ix>=0x7f800000) return x+x;	/* x is inf or NaN */
-	if(ix< 0x31800000) {	/* |x|<2**-28 */
-	    if(huge+x>one) return x;	/* return x inexact except 0 */
-	}
-	if(ix>0x4d800000) {	/* |x| > 2**28 */
-	    w = __ieee754_logf(fabsf(x))+ln2;
-	} else if (ix>0x40000000) {	/* 2**28 > |x| > 2.0 */
-	    t = fabsf(x);
-	    w = __ieee754_logf((float)2.0*t+one/(__ieee754_sqrtf(x*x+one)+t));
-	} else {		/* 2.0 > |x| > 2**-28 */
-	    t = x*x;
-	    w =log1pf(fabsf(x)+t/(one+__ieee754_sqrtf(one+t)));
-	}
-	if(hx>0) return w; else return -w;
-}
diff --git a/libm/src/s_atan.c b/libm/src/s_atan.c
deleted file mode 100644
index 23d7aa8..0000000
--- a/libm/src/s_atan.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/* @(#)s_atan.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_atan.c,v 1.9 2003/07/23 04:53:46 peter Exp $";
-#endif
-
-/* atan(x)
- * Method
- *   1. Reduce x to positive by atan(x) = -atan(-x).
- *   2. According to the integer k=4t+0.25 chopped, t=x, the argument
- *      is further reduced to one of the following intervals and the
- *      arctangent of t is evaluated by the corresponding formula:
- *
- *      [0,7/16]      atan(x) = t-t^3*(a1+t^2*(a2+...(a10+t^2*a11)...)
- *      [7/16,11/16]  atan(x) = atan(1/2) + atan( (t-0.5)/(1+t/2) )
- *      [11/16.19/16] atan(x) = atan( 1 ) + atan( (t-1)/(1+t) )
- *      [19/16,39/16] atan(x) = atan(3/2) + atan( (t-1.5)/(1+1.5t) )
- *      [39/16,INF]   atan(x) = atan(INF) + atan( -1/t )
- *
- * Constants:
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
- * to produce the hexadecimal values shown.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double atanhi[] = {
-  4.63647609000806093515e-01, /* atan(0.5)hi 0x3FDDAC67, 0x0561BB4F */
-  7.85398163397448278999e-01, /* atan(1.0)hi 0x3FE921FB, 0x54442D18 */
-  9.82793723247329054082e-01, /* atan(1.5)hi 0x3FEF730B, 0xD281F69B */
-  1.57079632679489655800e+00, /* atan(inf)hi 0x3FF921FB, 0x54442D18 */
-};
-
-static const double atanlo[] = {
-  2.26987774529616870924e-17, /* atan(0.5)lo 0x3C7A2B7F, 0x222F65E2 */
-  3.06161699786838301793e-17, /* atan(1.0)lo 0x3C81A626, 0x33145C07 */
-  1.39033110312309984516e-17, /* atan(1.5)lo 0x3C700788, 0x7AF0CBBD */
-  6.12323399573676603587e-17, /* atan(inf)lo 0x3C91A626, 0x33145C07 */
-};
-
-static const double aT[] = {
-  3.33333333333329318027e-01, /* 0x3FD55555, 0x5555550D */
- -1.99999999998764832476e-01, /* 0xBFC99999, 0x9998EBC4 */
-  1.42857142725034663711e-01, /* 0x3FC24924, 0x920083FF */
- -1.11111104054623557880e-01, /* 0xBFBC71C6, 0xFE231671 */
-  9.09088713343650656196e-02, /* 0x3FB745CD, 0xC54C206E */
- -7.69187620504482999495e-02, /* 0xBFB3B0F2, 0xAF749A6D */
-  6.66107313738753120669e-02, /* 0x3FB10D66, 0xA0D03D51 */
- -5.83357013379057348645e-02, /* 0xBFADDE2D, 0x52DEFD9A */
-  4.97687799461593236017e-02, /* 0x3FA97B4B, 0x24760DEB */
- -3.65315727442169155270e-02, /* 0xBFA2B444, 0x2C6A6C2F */
-  1.62858201153657823623e-02, /* 0x3F90AD3A, 0xE322DA11 */
-};
-
-	static const double
-one   = 1.0,
-huge   = 1.0e300;
-
-double
-atan(double x)
-{
-	double w,s1,s2,z;
-	int32_t ix,hx,id;
-
-	GET_HIGH_WORD(hx,x);
-	ix = hx&0x7fffffff;
-	if(ix>=0x44100000) {	/* if |x| >= 2^66 */
-	    u_int32_t low;
-	    GET_LOW_WORD(low,x);
-	    if(ix>0x7ff00000||
-		(ix==0x7ff00000&&(low!=0)))
-		return x+x;		/* NaN */
-	    if(hx>0) return  atanhi[3]+atanlo[3];
-	    else     return -atanhi[3]-atanlo[3];
-	} if (ix < 0x3fdc0000) {	/* |x| < 0.4375 */
-	    if (ix < 0x3e200000) {	/* |x| < 2^-29 */
-		if(huge+x>one) return x;	/* raise inexact */
-	    }
-	    id = -1;
-	} else {
-	x = fabs(x);
-	if (ix < 0x3ff30000) {		/* |x| < 1.1875 */
-	    if (ix < 0x3fe60000) {	/* 7/16 <=|x|<11/16 */
-		id = 0; x = (2.0*x-one)/(2.0+x);
-	    } else {			/* 11/16<=|x|< 19/16 */
-		id = 1; x  = (x-one)/(x+one);
-	    }
-	} else {
-	    if (ix < 0x40038000) {	/* |x| < 2.4375 */
-		id = 2; x  = (x-1.5)/(one+1.5*x);
-	    } else {			/* 2.4375 <= |x| < 2^66 */
-		id = 3; x  = -1.0/x;
-	    }
-	}}
-    /* end of argument reduction */
-	z = x*x;
-	w = z*z;
-    /* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */
-	s1 = z*(aT[0]+w*(aT[2]+w*(aT[4]+w*(aT[6]+w*(aT[8]+w*aT[10])))));
-	s2 = w*(aT[1]+w*(aT[3]+w*(aT[5]+w*(aT[7]+w*aT[9]))));
-	if (id<0) return x - x*(s1+s2);
-	else {
-	    z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x);
-	    return (hx<0)? -z:z;
-	}
-}
diff --git a/libm/src/s_atanf.c b/libm/src/s_atanf.c
deleted file mode 100644
index f90b35d..0000000
--- a/libm/src/s_atanf.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/* s_atanf.c -- float version of s_atan.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_atanf.c,v 1.7 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float atanhi[] = {
-  4.6364760399e-01, /* atan(0.5)hi 0x3eed6338 */
-  7.8539812565e-01, /* atan(1.0)hi 0x3f490fda */
-  9.8279368877e-01, /* atan(1.5)hi 0x3f7b985e */
-  1.5707962513e+00, /* atan(inf)hi 0x3fc90fda */
-};
-
-static const float atanlo[] = {
-  5.0121582440e-09, /* atan(0.5)lo 0x31ac3769 */
-  3.7748947079e-08, /* atan(1.0)lo 0x33222168 */
-  3.4473217170e-08, /* atan(1.5)lo 0x33140fb4 */
-  7.5497894159e-08, /* atan(inf)lo 0x33a22168 */
-};
-
-static const float aT[] = {
-  3.3333334327e-01, /* 0x3eaaaaaa */
- -2.0000000298e-01, /* 0xbe4ccccd */
-  1.4285714924e-01, /* 0x3e124925 */
- -1.1111110449e-01, /* 0xbde38e38 */
-  9.0908870101e-02, /* 0x3dba2e6e */
- -7.6918758452e-02, /* 0xbd9d8795 */
-  6.6610731184e-02, /* 0x3d886b35 */
- -5.8335702866e-02, /* 0xbd6ef16b */
-  4.9768779427e-02, /* 0x3d4bda59 */
- -3.6531571299e-02, /* 0xbd15a221 */
-  1.6285819933e-02, /* 0x3c8569d7 */
-};
-
-	static const float
-one   = 1.0,
-huge   = 1.0e30;
-
-float
-atanf(float x)
-{
-	float w,s1,s2,z;
-	int32_t ix,hx,id;
-
-	GET_FLOAT_WORD(hx,x);
-	ix = hx&0x7fffffff;
-	if(ix>=0x50800000) {	/* if |x| >= 2^34 */
-	    if(ix>0x7f800000)
-		return x+x;		/* NaN */
-	    if(hx>0) return  atanhi[3]+atanlo[3];
-	    else     return -atanhi[3]-atanlo[3];
-	} if (ix < 0x3ee00000) {	/* |x| < 0.4375 */
-	    if (ix < 0x31000000) {	/* |x| < 2^-29 */
-		if(huge+x>one) return x;	/* raise inexact */
-	    }
-	    id = -1;
-	} else {
-	x = fabsf(x);
-	if (ix < 0x3f980000) {		/* |x| < 1.1875 */
-	    if (ix < 0x3f300000) {	/* 7/16 <=|x|<11/16 */
-		id = 0; x = ((float)2.0*x-one)/((float)2.0+x);
-	    } else {			/* 11/16<=|x|< 19/16 */
-		id = 1; x  = (x-one)/(x+one);
-	    }
-	} else {
-	    if (ix < 0x401c0000) {	/* |x| < 2.4375 */
-		id = 2; x  = (x-(float)1.5)/(one+(float)1.5*x);
-	    } else {			/* 2.4375 <= |x| < 2^66 */
-		id = 3; x  = -(float)1.0/x;
-	    }
-	}}
-    /* end of argument reduction */
-	z = x*x;
-	w = z*z;
-    /* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */
-	s1 = z*(aT[0]+w*(aT[2]+w*(aT[4]+w*(aT[6]+w*(aT[8]+w*aT[10])))));
-	s2 = w*(aT[1]+w*(aT[3]+w*(aT[5]+w*(aT[7]+w*aT[9]))));
-	if (id<0) return x - x*(s1+s2);
-	else {
-	    z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x);
-	    return (hx<0)? -z:z;
-	}
-}
diff --git a/libm/src/s_cbrt.c b/libm/src/s_cbrt.c
deleted file mode 100644
index b600677..0000000
--- a/libm/src/s_cbrt.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/* @(#)s_cbrt.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- *
- * Optimized by Bruce D. Evans.
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_cbrt.c,v 1.10 2005/12/13 20:17:23 bde Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-/* cbrt(x)
- * Return cube root of x
- */
-static const u_int32_t
-	B1 = 715094163, /* B1 = (1023-1023/3-0.03306235651)*2**20 */
-	B2 = 696219795; /* B2 = (1023-1023/3-54/3-0.03306235651)*2**20 */
-
-static const double
-C =  5.42857142857142815906e-01, /* 19/35     = 0x3FE15F15, 0xF15F15F1 */
-D = -7.05306122448979611050e-01, /* -864/1225 = 0xBFE691DE, 0x2532C834 */
-E =  1.41428571428571436819e+00, /* 99/70     = 0x3FF6A0EA, 0x0EA0EA0F */
-F =  1.60714285714285720630e+00, /* 45/28     = 0x3FF9B6DB, 0x6DB6DB6E */
-G =  3.57142857142857150787e-01; /* 5/14      = 0x3FD6DB6D, 0xB6DB6DB7 */
-
-double
-cbrt(double x)
-{
-	int32_t	hx;
-	double r,s,t=0.0,w;
-	u_int32_t sign;
-	u_int32_t high,low;
-
-	GET_HIGH_WORD(hx,x);
-	sign=hx&0x80000000; 		/* sign= sign(x) */
-	hx  ^=sign;
-	if(hx>=0x7ff00000) return(x+x); /* cbrt(NaN,INF) is itself */
-	GET_LOW_WORD(low,x);
-	if((hx|low)==0)
-	    return(x);		/* cbrt(0) is itself */
-
-    /*
-     * Rough cbrt to 5 bits:
-     *    cbrt(2**e*(1+m) ~= 2**(e/3)*(1+(e%3+m)/3)
-     * where e is integral and >= 0, m is real and in [0, 1), and "/" and
-     * "%" are integer division and modulus with rounding towards minus
-     * infinity.  The RHS is always >= the LHS and has a maximum relative
-     * error of about 1 in 16.  Adding a bias of -0.03306235651 to the
-     * (e%3+m)/3 term reduces the error to about 1 in 32. With the IEEE
-     * floating point representation, for finite positive normal values,
-     * ordinary integer divison of the value in bits magically gives
-     * almost exactly the RHS of the above provided we first subtract the
-     * exponent bias (1023 for doubles) and later add it back.  We do the
-     * subtraction virtually to keep e >= 0 so that ordinary integer
-     * division rounds towards minus infinity; this is also efficient.
-     */
-	if(hx<0x00100000) { 		/* subnormal number */
-	    SET_HIGH_WORD(t,0x43500000); /* set t= 2**54 */
-	    t*=x;
-	    GET_HIGH_WORD(high,t);
-	    SET_HIGH_WORD(t,sign|((high&0x7fffffff)/3+B2));
-	} else
-	    SET_HIGH_WORD(t,sign|(hx/3+B1));
-
-    /* new cbrt to 23 bits; may be implemented in single precision */
-	r=t*t/x;
-	s=C+r*t;
-	t*=G+F/(s+E+D/s);
-
-    /* chop t to 20 bits and make it larger in magnitude than cbrt(x) */
-	GET_HIGH_WORD(high,t);
-	INSERT_WORDS(t,high+0x00000001,0);
-
-    /* one step Newton iteration to 53 bits with error less than 0.667 ulps */
-	s=t*t;		/* t*t is exact */
-	r=x/s;
-	w=t+t;
-	r=(r-t)/(w+r);	/* r-t is exact */
-	t=t+t*r;
-
-	return(t);
-}
diff --git a/libm/src/s_cbrtf.c b/libm/src/s_cbrtf.c
deleted file mode 100644
index 75569a2..0000000
--- a/libm/src/s_cbrtf.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/* s_cbrtf.c -- float version of s_cbrt.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Debugged and optimized by Bruce D. Evans.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_cbrtf.c,v 1.12 2005/12/13 20:17:23 bde Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-/* cbrtf(x)
- * Return cube root of x
- */
-static const unsigned
-	B1 = 709958130, /* B1 = (127-127.0/3-0.03306235651)*2**23 */
-	B2 = 642849266; /* B2 = (127-127.0/3-24/3-0.03306235651)*2**23 */
-
-static const float
-C =  5.4285717010e-01, /* 19/35     = 0x3f0af8b0 */
-D = -7.0530611277e-01, /* -864/1225 = 0xbf348ef1 */
-E =  1.4142856598e+00, /* 99/70     = 0x3fb50750 */
-F =  1.6071428061e+00, /* 45/28     = 0x3fcdb6db */
-G =  3.5714286566e-01; /* 5/14      = 0x3eb6db6e */
-
-float
-cbrtf(float x)
-{
-	float r,s,t,w;
-	int32_t hx;
-	u_int32_t sign;
-	u_int32_t high;
-
-	GET_FLOAT_WORD(hx,x);
-	sign=hx&0x80000000; 		/* sign= sign(x) */
-	hx  ^=sign;
-	if(hx>=0x7f800000) return(x+x); /* cbrt(NaN,INF) is itself */
-	if(hx==0)
-	    return(x);		/* cbrt(0) is itself */
-
-    /* rough cbrt to 5 bits */
-	if(hx<0x00800000) { 		/* subnormal number */
-	    SET_FLOAT_WORD(t,0x4b800000); /* set t= 2**24 */
-	    t*=x;
-	    GET_FLOAT_WORD(high,t);
-	    SET_FLOAT_WORD(t,sign|((high&0x7fffffff)/3+B2));
-	} else
-	    SET_FLOAT_WORD(t,sign|(hx/3+B1));
-
-    /* new cbrt to 23 bits */
-	r=t*t/x;
-	s=C+r*t;
-	t*=G+F/(s+E+D/s);
-
-    /* chop t to 12 bits and make it larger in magnitude than cbrt(x) */
-	GET_FLOAT_WORD(high,t);
-	SET_FLOAT_WORD(t,(high&0xfffff000)+0x00001000);
-
-    /* one step Newton iteration to 24 bits with error less than 0.667 ulps */
-	s=t*t;		/* t*t is exact */
-	r=x/s;
-	w=t+t;
-	r=(r-t)/(w+r);	/* r-t is exact */
-	t=t+t*r;
-
-	return(t);
-}
diff --git a/libm/src/s_ceil.c b/libm/src/s_ceil.c
deleted file mode 100644
index e5440e2..0000000
--- a/libm/src/s_ceil.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/* @(#)s_ceil.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_ceil.c,v 1.9 2003/07/23 04:53:46 peter Exp $";
-#endif
-
-/*
- * ceil(x)
- * Return x rounded toward -inf to integral value
- * Method:
- *	Bit twiddling.
- * Exception:
- *	Inexact flag raised if x not equal to ceil(x).
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double huge = 1.0e300;
-
-double
-ceil(double x)
-{
-	int32_t i0,i1,j0;
-	u_int32_t i,j;
-	EXTRACT_WORDS(i0,i1,x);
-	j0 = ((i0>>20)&0x7ff)-0x3ff;
-	if(j0<20) {
-	    if(j0<0) { 	/* raise inexact if x != 0 */
-		if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */
-		    if(i0<0) {i0=0x80000000;i1=0;}
-		    else if((i0|i1)!=0) { i0=0x3ff00000;i1=0;}
-		}
-	    } else {
-		i = (0x000fffff)>>j0;
-		if(((i0&i)|i1)==0) return x; /* x is integral */
-		if(huge+x>0.0) {	/* raise inexact flag */
-		    if(i0>0) i0 += (0x00100000)>>j0;
-		    i0 &= (~i); i1=0;
-		}
-	    }
-	} else if (j0>51) {
-	    if(j0==0x400) return x+x;	/* inf or NaN */
-	    else return x;		/* x is integral */
-	} else {
-	    i = ((u_int32_t)(0xffffffff))>>(j0-20);
-	    if((i1&i)==0) return x;	/* x is integral */
-	    if(huge+x>0.0) { 		/* raise inexact flag */
-		if(i0>0) {
-		    if(j0==20) i0+=1;
-		    else {
-			j = i1 + (1<<(52-j0));
-			if(j<i1) i0+=1;	/* got a carry */
-			i1 = j;
-		    }
-		}
-		i1 &= (~i);
-	    }
-	}
-	INSERT_WORDS(x,i0,i1);
-	return x;
-}
diff --git a/libm/src/s_ceilf.c b/libm/src/s_ceilf.c
deleted file mode 100644
index 5c465b3..0000000
--- a/libm/src/s_ceilf.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/* s_ceilf.c -- float version of s_ceil.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_ceilf.c,v 1.7 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float huge = 1.0e30;
-
-float
-ceilf(float x)
-{
-	int32_t i0,j0;
-	u_int32_t i;
-
-	GET_FLOAT_WORD(i0,x);
-	j0 = ((i0>>23)&0xff)-0x7f;
-	if(j0<23) {
-	    if(j0<0) { 	/* raise inexact if x != 0 */
-		if(huge+x>(float)0.0) {/* return 0*sign(x) if |x|<1 */
-		    if(i0<0) {i0=0x80000000;}
-		    else if(i0!=0) { i0=0x3f800000;}
-		}
-	    } else {
-		i = (0x007fffff)>>j0;
-		if((i0&i)==0) return x; /* x is integral */
-		if(huge+x>(float)0.0) {	/* raise inexact flag */
-		    if(i0>0) i0 += (0x00800000)>>j0;
-		    i0 &= (~i);
-		}
-	    }
-	} else {
-	    if(j0==0x80) return x+x;	/* inf or NaN */
-	    else return x;		/* x is integral */
-	}
-	SET_FLOAT_WORD(x,i0);
-	return x;
-}
diff --git a/libm/src/s_ceill.c b/libm/src/s_ceill.c
deleted file mode 100644
index 7e8817c..0000000
--- a/libm/src/s_ceill.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- *
- * From: @(#)s_ceil.c 5.1 93/09/24
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_ceill.c,v 1.4 2005/04/28 19:45:55 stefanf Exp $";
-#endif
-
-/*
- * ceill(x)
- * Return x rounded toward -inf to integral value
- * Method:
- *	Bit twiddling.
- * Exception:
- *	Inexact flag raised if x not equal to ceill(x).
- */
-
-#include <float.h>
-#include <math.h>
-#include <stdint.h>
-
-#include "fpmath.h"
-
-#ifdef LDBL_IMPLICIT_NBIT
-#define	MANH_SIZE	(LDBL_MANH_SIZE + 1)
-#define	INC_MANH(u, c)	do {					\
-	uint64_t o = u.bits.manh;				\
-	u.bits.manh += (c);					\
-	if (u.bits.manh < o)					\
-		u.bits.exp++;					\
-} while (0)
-#else
-#define	MANH_SIZE	LDBL_MANH_SIZE
-#define	INC_MANH(u, c)	do {					\
-	uint64_t o = u.bits.manh;				\
-	u.bits.manh += (c);					\
-	if (u.bits.manh < o) {					\
-		u.bits.exp++;					\
-		u.bits.manh |= 1llu << (LDBL_MANH_SIZE - 1);	\
-	}							\
-} while (0)
-#endif
-
-static const long double huge = 1.0e300;
-
-long double
-ceill(long double x)
-{
-	union IEEEl2bits u = { .e = x };
-	int e = u.bits.exp - LDBL_MAX_EXP + 1;
-
-	if (e < MANH_SIZE - 1) {
-		if (e < 0) {			/* raise inexact if x != 0 */
-			if (huge + x > 0.0)
-				if (u.bits.exp > 0 ||
-				    (u.bits.manh | u.bits.manl) != 0)
-					u.e = u.bits.sign ? 0.0 : 1.0;
-		} else {
-			uint64_t m = ((1llu << MANH_SIZE) - 1) >> (e + 1);
-			if (((u.bits.manh & m) | u.bits.manl) == 0)
-				return (x);	/* x is integral */
-			if (!u.bits.sign) {
-#ifdef LDBL_IMPLICIT_NBIT
-				if (e == 0)
-					u.bits.exp++;
-				else
-#endif
-				INC_MANH(u, 1llu << (MANH_SIZE - e - 1));
-			}
-			if (huge + x > 0.0) {	/* raise inexact flag */
-				u.bits.manh &= ~m;
-				u.bits.manl = 0;
-			}
-		}
-	} else if (e < LDBL_MANT_DIG - 1) {
-		uint64_t m = (uint64_t)-1 >> (64 - LDBL_MANT_DIG + e + 1);
-		if ((u.bits.manl & m) == 0)
-			return (x);	/* x is integral */
-		if (!u.bits.sign) {
-			if (e == MANH_SIZE - 1)
-				INC_MANH(u, 1);
-			else {
-				uint64_t o = u.bits.manl;
-				u.bits.manl += 1llu << (LDBL_MANT_DIG - e - 1);
-				if (u.bits.manl < o)	/* got a carry */
-					INC_MANH(u, 1);
-			}
-		}
-		if (huge + x > 0.0)		/* raise inexact flag */
-			u.bits.manl &= ~m;
-	}
-	return (u.e);
-}
diff --git a/libm/src/s_cimag.c b/libm/src/s_cimag.c
deleted file mode 100644
index e4be0b3..0000000
--- a/libm/src/s_cimag.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * Copyright (c) 2004 Stefan Farfeleder
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/src/s_cimag.c,v 1.1 2004/05/30 09:21:56 stefanf Exp $
- */
-
-#include <complex.h>
-
-double
-cimag(double complex z)
-{
-	return -z * I;
-}
diff --git a/libm/src/s_cimagf.c b/libm/src/s_cimagf.c
deleted file mode 100644
index 1e0f53f..0000000
--- a/libm/src/s_cimagf.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * Copyright (c) 2004 Stefan Farfeleder
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/src/s_cimagf.c,v 1.1 2004/05/30 09:21:56 stefanf Exp $
- */
-
-#include <complex.h>
-
-float
-cimagf(float complex z)
-{
-	return -z * I;
-}
diff --git a/libm/src/s_cimagl.c b/libm/src/s_cimagl.c
deleted file mode 100644
index a87677e..0000000
--- a/libm/src/s_cimagl.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * Copyright (c) 2004 Stefan Farfeleder
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/src/s_cimagl.c,v 1.1 2004/05/30 09:21:56 stefanf Exp $
- */
-
-#include <complex.h>
-
-long double
-cimagl(long double complex z)
-{
-	return -z * I;
-}
diff --git a/libm/src/s_conj.c b/libm/src/s_conj.c
deleted file mode 100644
index d47a15d..0000000
--- a/libm/src/s_conj.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * Copyright (c) 2004 Stefan Farfeleder
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/src/s_conj.c,v 1.1 2004/05/30 09:21:56 stefanf Exp $
- */
-
-#include <complex.h>
-
-double complex
-conj(double complex z)
-{
-	return creal(z) - I * cimag(z);
-}
diff --git a/libm/src/s_conjf.c b/libm/src/s_conjf.c
deleted file mode 100644
index 24e0398..0000000
--- a/libm/src/s_conjf.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * Copyright (c) 2004 Stefan Farfeleder
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/src/s_conjf.c,v 1.1 2004/05/30 09:21:56 stefanf Exp $
- */
-
-#include <complex.h>
-
-float complex
-conjf(float complex z)
-{
-	return crealf(z) - I * cimagf(z);
-}
diff --git a/libm/src/s_conjl.c b/libm/src/s_conjl.c
deleted file mode 100644
index 13d80c2..0000000
--- a/libm/src/s_conjl.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * Copyright (c) 2004 Stefan Farfeleder
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/src/s_conjl.c,v 1.1 2004/05/30 09:21:56 stefanf Exp $
- */
-
-#include <complex.h>
-
-long double complex
-conjl(long double complex z)
-{
-	return creall(z) - I * cimagl(z);
-}
diff --git a/libm/src/s_copysign.c b/libm/src/s_copysign.c
deleted file mode 100644
index f37be0d..0000000
--- a/libm/src/s_copysign.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* @(#)s_copysign.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_copysign.c,v 1.9 2003/07/23 04:53:46 peter Exp $";
-#endif
-
-/*
- * copysign(double x, double y)
- * copysign(x,y) returns a value with the magnitude of x and
- * with the sign bit of y.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-double
-copysign(double x, double y)
-{
-	u_int32_t hx,hy;
-	GET_HIGH_WORD(hx,x);
-	GET_HIGH_WORD(hy,y);
-	SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000));
-        return x;
-}
diff --git a/libm/src/s_copysignf.c b/libm/src/s_copysignf.c
deleted file mode 100644
index 79c4480..0000000
--- a/libm/src/s_copysignf.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* s_copysignf.c -- float version of s_copysign.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_copysignf.c,v 1.9 2003/07/23 04:53:46 peter Exp $";
-#endif
-
-/*
- * copysignf(float x, float y)
- * copysignf(x,y) returns a value with the magnitude of x and
- * with the sign bit of y.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-float
-copysignf(float x, float y)
-{
-	u_int32_t ix,iy;
-	GET_FLOAT_WORD(ix,x);
-	GET_FLOAT_WORD(iy,y);
-	SET_FLOAT_WORD(x,(ix&0x7fffffff)|(iy&0x80000000));
-        return x;
-}
diff --git a/libm/src/s_copysignl.c b/libm/src/s_copysignl.c
deleted file mode 100644
index 5c5bd39..0000000
--- a/libm/src/s_copysignl.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * Copyright (c) 2004 Stefan Farfeleder
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/src/s_copysignl.c,v 1.1 2004/05/07 18:56:31 stefanf Exp $
- */
-
-#include <math.h>
-
-#include "fpmath.h"
-
-long double
-copysignl(long double x, long double y)
-{
-	union IEEEl2bits ux, uy;
-
-	ux.e = x;
-	uy.e = y;
-	ux.bits.sign = uy.bits.sign;
-	return (ux.e);
-}
diff --git a/libm/src/s_cos.c b/libm/src/s_cos.c
deleted file mode 100644
index 0faf91e..0000000
--- a/libm/src/s_cos.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* @(#)s_cos.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_cos.c,v 1.10 2005/10/24 14:08:36 bde Exp $";
-#endif
-
-/* cos(x)
- * Return cosine function of x.
- *
- * kernel function:
- *	__kernel_sin		... sine function on [-pi/4,pi/4]
- *	__kernel_cos		... cosine function on [-pi/4,pi/4]
- *	__ieee754_rem_pio2	... argument reduction routine
- *
- * Method.
- *      Let S,C and T denote the sin, cos and tan respectively on
- *	[-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
- *	in [-pi/4 , +pi/4], and let n = k mod 4.
- *	We have
- *
- *          n        sin(x)      cos(x)        tan(x)
- *     ----------------------------------------------------------
- *	    0	       S	   C		 T
- *	    1	       C	  -S		-1/T
- *	    2	      -S	  -C		 T
- *	    3	      -C	   S		-1/T
- *     ----------------------------------------------------------
- *
- * Special cases:
- *      Let trig be any of sin, cos, or tan.
- *      trig(+-INF)  is NaN, with signals;
- *      trig(NaN)    is that NaN;
- *
- * Accuracy:
- *	TRIG(x) returns trig(x) nearly rounded
- */
-
-#include "math.h"
-#include "math_private.h"
-
-double
-cos(double x)
-{
-	double y[2],z=0.0;
-	int32_t n, ix;
-
-    /* High word of x. */
-	GET_HIGH_WORD(ix,x);
-
-    /* |x| ~< pi/4 */
-	ix &= 0x7fffffff;
-	if(ix <= 0x3fe921fb) {
-	    if(ix<0x3e400000)			/* if x < 2**-27 */
-		if(((int)x)==0) return 1.0;	/* generate inexact */
-	    return __kernel_cos(x,z);
-	}
-
-    /* cos(Inf or NaN) is NaN */
-	else if (ix>=0x7ff00000) return x-x;
-
-    /* argument reduction needed */
-	else {
-	    n = __ieee754_rem_pio2(x,y);
-	    switch(n&3) {
-		case 0: return  __kernel_cos(y[0],y[1]);
-		case 1: return -__kernel_sin(y[0],y[1],1);
-		case 2: return -__kernel_cos(y[0],y[1]);
-		default:
-		        return  __kernel_sin(y[0],y[1],1);
-	    }
-	}
-}
diff --git a/libm/src/s_cosf.c b/libm/src/s_cosf.c
deleted file mode 100644
index 31adade..0000000
--- a/libm/src/s_cosf.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* s_cosf.c -- float version of s_cos.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Optimized by Bruce D. Evans.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_cosf.c,v 1.15 2005/11/30 06:47:18 bde Exp $";
-#endif
-
-#include "math.h"
-#define	INLINE_KERNEL_COSDF
-#define	INLINE_KERNEL_SINDF
-#include "math_private.h"
-#include "k_cosf.c"
-#include "k_sinf.c"
-
-/* Small multiples of pi/2 rounded to double precision. */
-static const double
-c1pio2 = 1*M_PI_2,			/* 0x3FF921FB, 0x54442D18 */
-c2pio2 = 2*M_PI_2,			/* 0x400921FB, 0x54442D18 */
-c3pio2 = 3*M_PI_2,			/* 0x4012D97C, 0x7F3321D2 */
-c4pio2 = 4*M_PI_2;			/* 0x401921FB, 0x54442D18 */
-
-float
-cosf(float x)
-{
-	float y[2];
-	int32_t n, hx, ix;
-
-	GET_FLOAT_WORD(hx,x);
-	ix = hx & 0x7fffffff;
-
-	if(ix <= 0x3f490fda) {		/* |x| ~<= pi/4 */
-	    if(ix<0x39800000)		/* |x| < 2**-12 */
-		if(((int)x)==0) return 1.0;	/* 1 with inexact if x != 0 */
-	    return __kernel_cosdf(x);
-	}
-	if(ix<=0x407b53d1) {		/* |x| ~<= 5*pi/4 */
-	    if(ix>0x4016cbe3)		/* |x|  ~> 3*pi/4 */
-		return -__kernel_cosdf(x + (hx > 0 ? -c2pio2 : c2pio2));
-	    else {
-		if(hx>0)
-		    return __kernel_sindf(c1pio2 - x);
-		else
-		    return __kernel_sindf(x + c1pio2);
-	    }
-	}
-	if(ix<=0x40e231d5) {		/* |x| ~<= 9*pi/4 */
-	    if(ix>0x40afeddf)		/* |x|  ~> 7*pi/4 */
-		return __kernel_cosdf(x + (hx > 0 ? -c4pio2 : c4pio2));
-	    else {
-		if(hx>0)
-		    return __kernel_sindf(x - c3pio2);
-		else
-		    return __kernel_sindf(-c3pio2 - x);
-	    }
-	}
-
-    /* cos(Inf or NaN) is NaN */
-	else if (ix>=0x7f800000) return x-x;
-
-    /* general argument reduction needed */
-	else {
-	    n = __ieee754_rem_pio2f(x,y);
-	    switch(n&3) {
-		case 0: return  __kernel_cosdf((double)y[0]+y[1]);
-		case 1: return  __kernel_sindf(-(double)y[0]-y[1]);
-		case 2: return -__kernel_cosdf((double)y[0]+y[1]);
-		default:
-		        return  __kernel_sindf((double)y[0]+y[1]);
-	    }
-	}
-}
diff --git a/libm/src/s_creal.c b/libm/src/s_creal.c
deleted file mode 100644
index ad14cdf..0000000
--- a/libm/src/s_creal.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * Copyright (c) 2004 Stefan Farfeleder
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/src/s_creal.c,v 1.1 2004/05/30 09:21:56 stefanf Exp $
- */
-
-#include <complex.h>
-
-double
-creal(double complex z)
-{
-	return z;
-}
diff --git a/libm/src/s_crealf.c b/libm/src/s_crealf.c
deleted file mode 100644
index a5c1562..0000000
--- a/libm/src/s_crealf.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * Copyright (c) 2004 Stefan Farfeleder
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/src/s_crealf.c,v 1.1 2004/05/30 09:21:56 stefanf Exp $
- */
-
-#include <complex.h>
-
-float
-crealf(float complex z)
-{
-	return z;
-}
diff --git a/libm/src/s_creall.c b/libm/src/s_creall.c
deleted file mode 100644
index 1531d16..0000000
--- a/libm/src/s_creall.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * Copyright (c) 2004 Stefan Farfeleder
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/src/s_creall.c,v 1.1 2004/05/30 09:21:56 stefanf Exp $
- */
-
-#include <complex.h>
-
-long double
-creall(long double complex z)
-{
-	return z;
-}
diff --git a/libm/src/s_erf.c b/libm/src/s_erf.c
deleted file mode 100644
index f33a2a5..0000000
--- a/libm/src/s_erf.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/* @(#)s_erf.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_erf.c,v 1.7 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-/* double erf(double x)
- * double erfc(double x)
- *			     x
- *		      2      |\
- *     erf(x)  =  ---------  | exp(-t*t)dt
- *	 	   sqrt(pi) \|
- *			     0
- *
- *     erfc(x) =  1-erf(x)
- *  Note that
- *		erf(-x) = -erf(x)
- *		erfc(-x) = 2 - erfc(x)
- *
- * Method:
- *	1. For |x| in [0, 0.84375]
- *	    erf(x)  = x + x*R(x^2)
- *          erfc(x) = 1 - erf(x)           if x in [-.84375,0.25]
- *                  = 0.5 + ((0.5-x)-x*R)  if x in [0.25,0.84375]
- *	   where R = P/Q where P is an odd poly of degree 8 and
- *	   Q is an odd poly of degree 10.
- *						 -57.90
- *			| R - (erf(x)-x)/x | <= 2
- *
- *
- *	   Remark. The formula is derived by noting
- *          erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....)
- *	   and that
- *          2/sqrt(pi) = 1.128379167095512573896158903121545171688
- *	   is close to one. The interval is chosen because the fix
- *	   point of erf(x) is near 0.6174 (i.e., erf(x)=x when x is
- *	   near 0.6174), and by some experiment, 0.84375 is chosen to
- * 	   guarantee the error is less than one ulp for erf.
- *
- *      2. For |x| in [0.84375,1.25], let s = |x| - 1, and
- *         c = 0.84506291151 rounded to single (24 bits)
- *         	erf(x)  = sign(x) * (c  + P1(s)/Q1(s))
- *         	erfc(x) = (1-c)  - P1(s)/Q1(s) if x > 0
- *			  1+(c+P1(s)/Q1(s))    if x < 0
- *         	|P1/Q1 - (erf(|x|)-c)| <= 2**-59.06
- *	   Remark: here we use the taylor series expansion at x=1.
- *		erf(1+s) = erf(1) + s*Poly(s)
- *			 = 0.845.. + P1(s)/Q1(s)
- *	   That is, we use rational approximation to approximate
- *			erf(1+s) - (c = (single)0.84506291151)
- *	   Note that |P1/Q1|< 0.078 for x in [0.84375,1.25]
- *	   where
- *		P1(s) = degree 6 poly in s
- *		Q1(s) = degree 6 poly in s
- *
- *      3. For x in [1.25,1/0.35(~2.857143)],
- *         	erfc(x) = (1/x)*exp(-x*x-0.5625+R1/S1)
- *         	erf(x)  = 1 - erfc(x)
- *	   where
- *		R1(z) = degree 7 poly in z, (z=1/x^2)
- *		S1(z) = degree 8 poly in z
- *
- *      4. For x in [1/0.35,28]
- *         	erfc(x) = (1/x)*exp(-x*x-0.5625+R2/S2) if x > 0
- *			= 2.0 - (1/x)*exp(-x*x-0.5625+R2/S2) if -6<x<0
- *			= 2.0 - tiny		(if x <= -6)
- *         	erf(x)  = sign(x)*(1.0 - erfc(x)) if x < 6, else
- *         	erf(x)  = sign(x)*(1.0 - tiny)
- *	   where
- *		R2(z) = degree 6 poly in z, (z=1/x^2)
- *		S2(z) = degree 7 poly in z
- *
- *      Note1:
- *	   To compute exp(-x*x-0.5625+R/S), let s be a single
- *	   precision number and s := x; then
- *		-x*x = -s*s + (s-x)*(s+x)
- *	        exp(-x*x-0.5626+R/S) =
- *			exp(-s*s-0.5625)*exp((s-x)*(s+x)+R/S);
- *      Note2:
- *	   Here 4 and 5 make use of the asymptotic series
- *			  exp(-x*x)
- *		erfc(x) ~ ---------- * ( 1 + Poly(1/x^2) )
- *			  x*sqrt(pi)
- *	   We use rational approximation to approximate
- *      	g(s)=f(1/x^2) = log(erfc(x)*x) - x*x + 0.5625
- *	   Here is the error bound for R1/S1 and R2/S2
- *      	|R1/S1 - f(x)|  < 2**(-62.57)
- *      	|R2/S2 - f(x)|  < 2**(-61.52)
- *
- *      5. For inf > x >= 28
- *         	erf(x)  = sign(x) *(1 - tiny)  (raise inexact)
- *         	erfc(x) = tiny*tiny (raise underflow) if x > 0
- *			= 2 - tiny if x<0
- *
- *      7. Special case:
- *         	erf(0)  = 0, erf(inf)  = 1, erf(-inf) = -1,
- *         	erfc(0) = 1, erfc(inf) = 0, erfc(-inf) = 2,
- *	   	erfc/erf(NaN) is NaN
- */
-
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-tiny	    = 1e-300,
-half=  5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
-one =  1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
-two =  2.00000000000000000000e+00, /* 0x40000000, 0x00000000 */
-	/* c = (float)0.84506291151 */
-erx =  8.45062911510467529297e-01, /* 0x3FEB0AC1, 0x60000000 */
-/*
- * Coefficients for approximation to  erf on [0,0.84375]
- */
-efx =  1.28379167095512586316e-01, /* 0x3FC06EBA, 0x8214DB69 */
-efx8=  1.02703333676410069053e+00, /* 0x3FF06EBA, 0x8214DB69 */
-pp0  =  1.28379167095512558561e-01, /* 0x3FC06EBA, 0x8214DB68 */
-pp1  = -3.25042107247001499370e-01, /* 0xBFD4CD7D, 0x691CB913 */
-pp2  = -2.84817495755985104766e-02, /* 0xBF9D2A51, 0xDBD7194F */
-pp3  = -5.77027029648944159157e-03, /* 0xBF77A291, 0x236668E4 */
-pp4  = -2.37630166566501626084e-05, /* 0xBEF8EAD6, 0x120016AC */
-qq1  =  3.97917223959155352819e-01, /* 0x3FD97779, 0xCDDADC09 */
-qq2  =  6.50222499887672944485e-02, /* 0x3FB0A54C, 0x5536CEBA */
-qq3  =  5.08130628187576562776e-03, /* 0x3F74D022, 0xC4D36B0F */
-qq4  =  1.32494738004321644526e-04, /* 0x3F215DC9, 0x221C1A10 */
-qq5  = -3.96022827877536812320e-06, /* 0xBED09C43, 0x42A26120 */
-/*
- * Coefficients for approximation to  erf  in [0.84375,1.25]
- */
-pa0  = -2.36211856075265944077e-03, /* 0xBF6359B8, 0xBEF77538 */
-pa1  =  4.14856118683748331666e-01, /* 0x3FDA8D00, 0xAD92B34D */
-pa2  = -3.72207876035701323847e-01, /* 0xBFD7D240, 0xFBB8C3F1 */
-pa3  =  3.18346619901161753674e-01, /* 0x3FD45FCA, 0x805120E4 */
-pa4  = -1.10894694282396677476e-01, /* 0xBFBC6398, 0x3D3E28EC */
-pa5  =  3.54783043256182359371e-02, /* 0x3FA22A36, 0x599795EB */
-pa6  = -2.16637559486879084300e-03, /* 0xBF61BF38, 0x0A96073F */
-qa1  =  1.06420880400844228286e-01, /* 0x3FBB3E66, 0x18EEE323 */
-qa2  =  5.40397917702171048937e-01, /* 0x3FE14AF0, 0x92EB6F33 */
-qa3  =  7.18286544141962662868e-02, /* 0x3FB2635C, 0xD99FE9A7 */
-qa4  =  1.26171219808761642112e-01, /* 0x3FC02660, 0xE763351F */
-qa5  =  1.36370839120290507362e-02, /* 0x3F8BEDC2, 0x6B51DD1C */
-qa6  =  1.19844998467991074170e-02, /* 0x3F888B54, 0x5735151D */
-/*
- * Coefficients for approximation to  erfc in [1.25,1/0.35]
- */
-ra0  = -9.86494403484714822705e-03, /* 0xBF843412, 0x600D6435 */
-ra1  = -6.93858572707181764372e-01, /* 0xBFE63416, 0xE4BA7360 */
-ra2  = -1.05586262253232909814e+01, /* 0xC0251E04, 0x41B0E726 */
-ra3  = -6.23753324503260060396e+01, /* 0xC04F300A, 0xE4CBA38D */
-ra4  = -1.62396669462573470355e+02, /* 0xC0644CB1, 0x84282266 */
-ra5  = -1.84605092906711035994e+02, /* 0xC067135C, 0xEBCCABB2 */
-ra6  = -8.12874355063065934246e+01, /* 0xC0545265, 0x57E4D2F2 */
-ra7  = -9.81432934416914548592e+00, /* 0xC023A0EF, 0xC69AC25C */
-sa1  =  1.96512716674392571292e+01, /* 0x4033A6B9, 0xBD707687 */
-sa2  =  1.37657754143519042600e+02, /* 0x4061350C, 0x526AE721 */
-sa3  =  4.34565877475229228821e+02, /* 0x407B290D, 0xD58A1A71 */
-sa4  =  6.45387271733267880336e+02, /* 0x40842B19, 0x21EC2868 */
-sa5  =  4.29008140027567833386e+02, /* 0x407AD021, 0x57700314 */
-sa6  =  1.08635005541779435134e+02, /* 0x405B28A3, 0xEE48AE2C */
-sa7  =  6.57024977031928170135e+00, /* 0x401A47EF, 0x8E484A93 */
-sa8  = -6.04244152148580987438e-02, /* 0xBFAEEFF2, 0xEE749A62 */
-/*
- * Coefficients for approximation to  erfc in [1/.35,28]
- */
-rb0  = -9.86494292470009928597e-03, /* 0xBF843412, 0x39E86F4A */
-rb1  = -7.99283237680523006574e-01, /* 0xBFE993BA, 0x70C285DE */
-rb2  = -1.77579549177547519889e+01, /* 0xC031C209, 0x555F995A */
-rb3  = -1.60636384855821916062e+02, /* 0xC064145D, 0x43C5ED98 */
-rb4  = -6.37566443368389627722e+02, /* 0xC083EC88, 0x1375F228 */
-rb5  = -1.02509513161107724954e+03, /* 0xC0900461, 0x6A2E5992 */
-rb6  = -4.83519191608651397019e+02, /* 0xC07E384E, 0x9BDC383F */
-sb1  =  3.03380607434824582924e+01, /* 0x403E568B, 0x261D5190 */
-sb2  =  3.25792512996573918826e+02, /* 0x40745CAE, 0x221B9F0A */
-sb3  =  1.53672958608443695994e+03, /* 0x409802EB, 0x189D5118 */
-sb4  =  3.19985821950859553908e+03, /* 0x40A8FFB7, 0x688C246A */
-sb5  =  2.55305040643316442583e+03, /* 0x40A3F219, 0xCEDF3BE6 */
-sb6  =  4.74528541206955367215e+02, /* 0x407DA874, 0xE79FE763 */
-sb7  = -2.24409524465858183362e+01; /* 0xC03670E2, 0x42712D62 */
-
-double
-erf(double x)
-{
-	int32_t hx,ix,i;
-	double R,S,P,Q,s,y,z,r;
-	GET_HIGH_WORD(hx,x);
-	ix = hx&0x7fffffff;
-	if(ix>=0x7ff00000) {		/* erf(nan)=nan */
-	    i = ((u_int32_t)hx>>31)<<1;
-	    return (double)(1-i)+one/x;	/* erf(+-inf)=+-1 */
-	}
-
-	if(ix < 0x3feb0000) {		/* |x|<0.84375 */
-	    if(ix < 0x3e300000) { 	/* |x|<2**-28 */
-	        if (ix < 0x00800000)
-		    return 0.125*(8.0*x+efx8*x);  /*avoid underflow */
-		return x + efx*x;
-	    }
-	    z = x*x;
-	    r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
-	    s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
-	    y = r/s;
-	    return x + x*y;
-	}
-	if(ix < 0x3ff40000) {		/* 0.84375 <= |x| < 1.25 */
-	    s = fabs(x)-one;
-	    P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
-	    Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
-	    if(hx>=0) return erx + P/Q; else return -erx - P/Q;
-	}
-	if (ix >= 0x40180000) {		/* inf>|x|>=6 */
-	    if(hx>=0) return one-tiny; else return tiny-one;
-	}
-	x = fabs(x);
- 	s = one/(x*x);
-	if(ix< 0x4006DB6E) {	/* |x| < 1/0.35 */
-	    R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
-				ra5+s*(ra6+s*ra7))))));
-	    S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
-				sa5+s*(sa6+s*(sa7+s*sa8)))))));
-	} else {	/* |x| >= 1/0.35 */
-	    R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
-				rb5+s*rb6)))));
-	    S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
-				sb5+s*(sb6+s*sb7))))));
-	}
-	z  = x;
-	SET_LOW_WORD(z,0);
-	r  =  __ieee754_exp(-z*z-0.5625)*__ieee754_exp((z-x)*(z+x)+R/S);
-	if(hx>=0) return one-r/x; else return  r/x-one;
-}
-
-double
-erfc(double x)
-{
-	int32_t hx,ix;
-	double R,S,P,Q,s,y,z,r;
-	GET_HIGH_WORD(hx,x);
-	ix = hx&0x7fffffff;
-	if(ix>=0x7ff00000) {			/* erfc(nan)=nan */
-						/* erfc(+-inf)=0,2 */
-	    return (double)(((u_int32_t)hx>>31)<<1)+one/x;
-	}
-
-	if(ix < 0x3feb0000) {		/* |x|<0.84375 */
-	    if(ix < 0x3c700000)  	/* |x|<2**-56 */
-		return one-x;
-	    z = x*x;
-	    r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
-	    s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
-	    y = r/s;
-	    if(hx < 0x3fd00000) {  	/* x<1/4 */
-		return one-(x+x*y);
-	    } else {
-		r = x*y;
-		r += (x-half);
-	        return half - r ;
-	    }
-	}
-	if(ix < 0x3ff40000) {		/* 0.84375 <= |x| < 1.25 */
-	    s = fabs(x)-one;
-	    P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
-	    Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
-	    if(hx>=0) {
-	        z  = one-erx; return z - P/Q;
-	    } else {
-		z = erx+P/Q; return one+z;
-	    }
-	}
-	if (ix < 0x403c0000) {		/* |x|<28 */
-	    x = fabs(x);
- 	    s = one/(x*x);
-	    if(ix< 0x4006DB6D) {	/* |x| < 1/.35 ~ 2.857143*/
-	        R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
-				ra5+s*(ra6+s*ra7))))));
-	        S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
-				sa5+s*(sa6+s*(sa7+s*sa8)))))));
-	    } else {			/* |x| >= 1/.35 ~ 2.857143 */
-		if(hx<0&&ix>=0x40180000) return two-tiny;/* x < -6 */
-	        R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
-				rb5+s*rb6)))));
-	        S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
-				sb5+s*(sb6+s*sb7))))));
-	    }
-	    z  = x;
-	    SET_LOW_WORD(z,0);
-	    r  =  __ieee754_exp(-z*z-0.5625)*
-			__ieee754_exp((z-x)*(z+x)+R/S);
-	    if(hx>0) return r/x; else return two-r/x;
-	} else {
-	    if(hx>0) return tiny*tiny; else return two-tiny;
-	}
-}
diff --git a/libm/src/s_erff.c b/libm/src/s_erff.c
deleted file mode 100644
index 24e053c..0000000
--- a/libm/src/s_erff.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/* s_erff.c -- float version of s_erf.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_erff.c,v 1.7 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float
-tiny	    = 1e-30,
-half=  5.0000000000e-01, /* 0x3F000000 */
-one =  1.0000000000e+00, /* 0x3F800000 */
-two =  2.0000000000e+00, /* 0x40000000 */
-	/* c = (subfloat)0.84506291151 */
-erx =  8.4506291151e-01, /* 0x3f58560b */
-/*
- * Coefficients for approximation to  erf on [0,0.84375]
- */
-efx =  1.2837916613e-01, /* 0x3e0375d4 */
-efx8=  1.0270333290e+00, /* 0x3f8375d4 */
-pp0  =  1.2837916613e-01, /* 0x3e0375d4 */
-pp1  = -3.2504209876e-01, /* 0xbea66beb */
-pp2  = -2.8481749818e-02, /* 0xbce9528f */
-pp3  = -5.7702702470e-03, /* 0xbbbd1489 */
-pp4  = -2.3763017452e-05, /* 0xb7c756b1 */
-qq1  =  3.9791721106e-01, /* 0x3ecbbbce */
-qq2  =  6.5022252500e-02, /* 0x3d852a63 */
-qq3  =  5.0813062117e-03, /* 0x3ba68116 */
-qq4  =  1.3249473704e-04, /* 0x390aee49 */
-qq5  = -3.9602282413e-06, /* 0xb684e21a */
-/*
- * Coefficients for approximation to  erf  in [0.84375,1.25]
- */
-pa0  = -2.3621185683e-03, /* 0xbb1acdc6 */
-pa1  =  4.1485610604e-01, /* 0x3ed46805 */
-pa2  = -3.7220788002e-01, /* 0xbebe9208 */
-pa3  =  3.1834661961e-01, /* 0x3ea2fe54 */
-pa4  = -1.1089469492e-01, /* 0xbde31cc2 */
-pa5  =  3.5478305072e-02, /* 0x3d1151b3 */
-pa6  = -2.1663755178e-03, /* 0xbb0df9c0 */
-qa1  =  1.0642088205e-01, /* 0x3dd9f331 */
-qa2  =  5.4039794207e-01, /* 0x3f0a5785 */
-qa3  =  7.1828655899e-02, /* 0x3d931ae7 */
-qa4  =  1.2617121637e-01, /* 0x3e013307 */
-qa5  =  1.3637083583e-02, /* 0x3c5f6e13 */
-qa6  =  1.1984500103e-02, /* 0x3c445aa3 */
-/*
- * Coefficients for approximation to  erfc in [1.25,1/0.35]
- */
-ra0  = -9.8649440333e-03, /* 0xbc21a093 */
-ra1  = -6.9385856390e-01, /* 0xbf31a0b7 */
-ra2  = -1.0558626175e+01, /* 0xc128f022 */
-ra3  = -6.2375331879e+01, /* 0xc2798057 */
-ra4  = -1.6239666748e+02, /* 0xc322658c */
-ra5  = -1.8460508728e+02, /* 0xc3389ae7 */
-ra6  = -8.1287437439e+01, /* 0xc2a2932b */
-ra7  = -9.8143291473e+00, /* 0xc11d077e */
-sa1  =  1.9651271820e+01, /* 0x419d35ce */
-sa2  =  1.3765776062e+02, /* 0x4309a863 */
-sa3  =  4.3456588745e+02, /* 0x43d9486f */
-sa4  =  6.4538726807e+02, /* 0x442158c9 */
-sa5  =  4.2900814819e+02, /* 0x43d6810b */
-sa6  =  1.0863500214e+02, /* 0x42d9451f */
-sa7  =  6.5702495575e+00, /* 0x40d23f7c */
-sa8  = -6.0424413532e-02, /* 0xbd777f97 */
-/*
- * Coefficients for approximation to  erfc in [1/.35,28]
- */
-rb0  = -9.8649431020e-03, /* 0xbc21a092 */
-rb1  = -7.9928326607e-01, /* 0xbf4c9dd4 */
-rb2  = -1.7757955551e+01, /* 0xc18e104b */
-rb3  = -1.6063638306e+02, /* 0xc320a2ea */
-rb4  = -6.3756646729e+02, /* 0xc41f6441 */
-rb5  = -1.0250950928e+03, /* 0xc480230b */
-rb6  = -4.8351919556e+02, /* 0xc3f1c275 */
-sb1  =  3.0338060379e+01, /* 0x41f2b459 */
-sb2  =  3.2579251099e+02, /* 0x43a2e571 */
-sb3  =  1.5367296143e+03, /* 0x44c01759 */
-sb4  =  3.1998581543e+03, /* 0x4547fdbb */
-sb5  =  2.5530502930e+03, /* 0x451f90ce */
-sb6  =  4.7452853394e+02, /* 0x43ed43a7 */
-sb7  = -2.2440952301e+01; /* 0xc1b38712 */
-
-float
-erff(float x)
-{
-	int32_t hx,ix,i;
-	float R,S,P,Q,s,y,z,r;
-	GET_FLOAT_WORD(hx,x);
-	ix = hx&0x7fffffff;
-	if(ix>=0x7f800000) {		/* erf(nan)=nan */
-	    i = ((u_int32_t)hx>>31)<<1;
-	    return (float)(1-i)+one/x;	/* erf(+-inf)=+-1 */
-	}
-
-	if(ix < 0x3f580000) {		/* |x|<0.84375 */
-	    if(ix < 0x31800000) { 	/* |x|<2**-28 */
-	        if (ix < 0x04000000)
-		    /*avoid underflow */
-		    return (float)0.125*((float)8.0*x+efx8*x);
-		return x + efx*x;
-	    }
-	    z = x*x;
-	    r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
-	    s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
-	    y = r/s;
-	    return x + x*y;
-	}
-	if(ix < 0x3fa00000) {		/* 0.84375 <= |x| < 1.25 */
-	    s = fabsf(x)-one;
-	    P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
-	    Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
-	    if(hx>=0) return erx + P/Q; else return -erx - P/Q;
-	}
-	if (ix >= 0x40c00000) {		/* inf>|x|>=6 */
-	    if(hx>=0) return one-tiny; else return tiny-one;
-	}
-	x = fabsf(x);
- 	s = one/(x*x);
-	if(ix< 0x4036DB6E) {	/* |x| < 1/0.35 */
-	    R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
-				ra5+s*(ra6+s*ra7))))));
-	    S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
-				sa5+s*(sa6+s*(sa7+s*sa8)))))));
-	} else {	/* |x| >= 1/0.35 */
-	    R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
-				rb5+s*rb6)))));
-	    S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
-				sb5+s*(sb6+s*sb7))))));
-	}
-	GET_FLOAT_WORD(ix,x);
-	SET_FLOAT_WORD(z,ix&0xfffff000);
-	r  =  __ieee754_expf(-z*z-(float)0.5625)*__ieee754_expf((z-x)*(z+x)+R/S);
-	if(hx>=0) return one-r/x; else return  r/x-one;
-}
-
-float
-erfcf(float x)
-{
-	int32_t hx,ix;
-	float R,S,P,Q,s,y,z,r;
-	GET_FLOAT_WORD(hx,x);
-	ix = hx&0x7fffffff;
-	if(ix>=0x7f800000) {			/* erfc(nan)=nan */
-						/* erfc(+-inf)=0,2 */
-	    return (float)(((u_int32_t)hx>>31)<<1)+one/x;
-	}
-
-	if(ix < 0x3f580000) {		/* |x|<0.84375 */
-	    if(ix < 0x23800000)  	/* |x|<2**-56 */
-		return one-x;
-	    z = x*x;
-	    r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
-	    s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
-	    y = r/s;
-	    if(hx < 0x3e800000) {  	/* x<1/4 */
-		return one-(x+x*y);
-	    } else {
-		r = x*y;
-		r += (x-half);
-	        return half - r ;
-	    }
-	}
-	if(ix < 0x3fa00000) {		/* 0.84375 <= |x| < 1.25 */
-	    s = fabsf(x)-one;
-	    P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
-	    Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
-	    if(hx>=0) {
-	        z  = one-erx; return z - P/Q;
-	    } else {
-		z = erx+P/Q; return one+z;
-	    }
-	}
-	if (ix < 0x41e00000) {		/* |x|<28 */
-	    x = fabsf(x);
- 	    s = one/(x*x);
-	    if(ix< 0x4036DB6D) {	/* |x| < 1/.35 ~ 2.857143*/
-	        R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
-				ra5+s*(ra6+s*ra7))))));
-	        S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
-				sa5+s*(sa6+s*(sa7+s*sa8)))))));
-	    } else {			/* |x| >= 1/.35 ~ 2.857143 */
-		if(hx<0&&ix>=0x40c00000) return two-tiny;/* x < -6 */
-	        R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
-				rb5+s*rb6)))));
-	        S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
-				sb5+s*(sb6+s*sb7))))));
-	    }
-	    GET_FLOAT_WORD(ix,x);
-	    SET_FLOAT_WORD(z,ix&0xfffff000);
-	    r  =  __ieee754_expf(-z*z-(float)0.5625)*
-			__ieee754_expf((z-x)*(z+x)+R/S);
-	    if(hx>0) return r/x; else return two-r/x;
-	} else {
-	    if(hx>0) return tiny*tiny; else return two-tiny;
-	}
-}
diff --git a/libm/src/s_exp2.c b/libm/src/s_exp2.c
deleted file mode 100644
index addef04..0000000
--- a/libm/src/s_exp2.c
+++ /dev/null
@@ -1,389 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_exp2.c,v 1.1 2005/04/05 02:57:15 das Exp $"); */
-
-#include "math.h"
-#include "math_private.h"
-
-#define	TBLBITS	8
-#define	TBLSIZE	(1 << TBLBITS)
-
-static const double
-    huge     = 0x1p1000,
-    twom1000 = 0x1p-1000,
-    redux    = 0x1.8p52 / TBLSIZE,
-    P1	     = 0x1.62e42fefa39efp-1,
-    P2	     = 0x1.ebfbdff82c575p-3,
-    P3	     = 0x1.c6b08d704a0a6p-5,
-    P4	     = 0x1.3b2ab88f70400p-7,
-    P5	     = 0x1.5d88003875c74p-10;
-
-static const double tbl[TBLSIZE * 2] = {
-/*	exp2(z + eps)		eps	*/
-	0x1.6a09e667f3d5dp-1,	 0x1.9880p-44,
-	0x1.6b052fa751744p-1,	 0x1.8000p-50,
-	0x1.6c012750bd9fep-1,	-0x1.8780p-45,
-	0x1.6cfdcddd476bfp-1,	 0x1.ec00p-46,
-	0x1.6dfb23c651a29p-1,	-0x1.8000p-50,
-	0x1.6ef9298593ae3p-1,	-0x1.c000p-52,
-	0x1.6ff7df9519386p-1,	-0x1.fd80p-45,
-	0x1.70f7466f42da3p-1,	-0x1.c880p-45,
-	0x1.71f75e8ec5fc3p-1,	 0x1.3c00p-46,
-	0x1.72f8286eacf05p-1,	-0x1.8300p-44,
-	0x1.73f9a48a58152p-1,	-0x1.0c00p-47,
-	0x1.74fbd35d7ccfcp-1,	 0x1.f880p-45,
-	0x1.75feb564267f1p-1,	 0x1.3e00p-47,
-	0x1.77024b1ab6d48p-1,	-0x1.7d00p-45,
-	0x1.780694fde5d38p-1,	-0x1.d000p-50,
-	0x1.790b938ac1d00p-1,	 0x1.3000p-49,
-	0x1.7a11473eb0178p-1,	-0x1.d000p-49,
-	0x1.7b17b0976d060p-1,	 0x1.0400p-45,
-	0x1.7c1ed0130c133p-1,	 0x1.0000p-53,
-	0x1.7d26a62ff8636p-1,	-0x1.6900p-45,
-	0x1.7e2f336cf4e3bp-1,	-0x1.2e00p-47,
-	0x1.7f3878491c3e8p-1,	-0x1.4580p-45,
-	0x1.80427543e1b4ep-1,	 0x1.3000p-44,
-	0x1.814d2add1071ap-1,	 0x1.f000p-47,
-	0x1.82589994ccd7ep-1,	-0x1.1c00p-45,
-	0x1.8364c1eb942d0p-1,	 0x1.9d00p-45,
-	0x1.8471a4623cab5p-1,	 0x1.7100p-43,
-	0x1.857f4179f5bbcp-1,	 0x1.2600p-45,
-	0x1.868d99b4491afp-1,	-0x1.2c40p-44,
-	0x1.879cad931a395p-1,	-0x1.3000p-45,
-	0x1.88ac7d98a65b8p-1,	-0x1.a800p-45,
-	0x1.89bd0a4785800p-1,	-0x1.d000p-49,
-	0x1.8ace5422aa223p-1,	 0x1.3280p-44,
-	0x1.8be05bad619fap-1,	 0x1.2b40p-43,
-	0x1.8cf3216b54383p-1,	-0x1.ed00p-45,
-	0x1.8e06a5e08664cp-1,	-0x1.0500p-45,
-	0x1.8f1ae99157807p-1,	 0x1.8280p-45,
-	0x1.902fed0282c0ep-1,	-0x1.cb00p-46,
-	0x1.9145b0b91ff96p-1,	-0x1.5e00p-47,
-	0x1.925c353aa2ff9p-1,	 0x1.5400p-48,
-	0x1.93737b0cdc64ap-1,	 0x1.7200p-46,
-	0x1.948b82b5f98aep-1,	-0x1.9000p-47,
-	0x1.95a44cbc852cbp-1,	 0x1.5680p-45,
-	0x1.96bdd9a766f21p-1,	-0x1.6d00p-44,
-	0x1.97d829fde4e2ap-1,	-0x1.1000p-47,
-	0x1.98f33e47a23a3p-1,	 0x1.d000p-45,
-	0x1.9a0f170ca0604p-1,	-0x1.8a40p-44,
-	0x1.9b2bb4d53ff89p-1,	 0x1.55c0p-44,
-	0x1.9c49182a3f15bp-1,	 0x1.6b80p-45,
-	0x1.9d674194bb8c5p-1,	-0x1.c000p-49,
-	0x1.9e86319e3238ep-1,	 0x1.7d00p-46,
-	0x1.9fa5e8d07f302p-1,	 0x1.6400p-46,
-	0x1.a0c667b5de54dp-1,	-0x1.5000p-48,
-	0x1.a1e7aed8eb8f6p-1,	 0x1.9e00p-47,
-	0x1.a309bec4a2e27p-1,	 0x1.ad80p-45,
-	0x1.a42c980460a5dp-1,	-0x1.af00p-46,
-	0x1.a5503b23e259bp-1,	 0x1.b600p-47,
-	0x1.a674a8af46213p-1,	 0x1.8880p-44,
-	0x1.a799e1330b3a7p-1,	 0x1.1200p-46,
-	0x1.a8bfe53c12e8dp-1,	 0x1.6c00p-47,
-	0x1.a9e6b5579fcd2p-1,	-0x1.9b80p-45,
-	0x1.ab0e521356fb8p-1,	 0x1.b700p-45,
-	0x1.ac36bbfd3f381p-1,	 0x1.9000p-50,
-	0x1.ad5ff3a3c2780p-1,	 0x1.4000p-49,
-	0x1.ae89f995ad2a3p-1,	-0x1.c900p-45,
-	0x1.afb4ce622f367p-1,	 0x1.6500p-46,
-	0x1.b0e07298db790p-1,	 0x1.fd40p-45,
-	0x1.b20ce6c9a89a9p-1,	 0x1.2700p-46,
-	0x1.b33a2b84f1a4bp-1,	 0x1.d470p-43,
-	0x1.b468415b747e7p-1,	-0x1.8380p-44,
-	0x1.b59728de5593ap-1,	 0x1.8000p-54,
-	0x1.b6c6e29f1c56ap-1,	 0x1.ad00p-47,
-	0x1.b7f76f2fb5e50p-1,	 0x1.e800p-50,
-	0x1.b928cf22749b2p-1,	-0x1.4c00p-47,
-	0x1.ba5b030a10603p-1,	-0x1.d700p-47,
-	0x1.bb8e0b79a6f66p-1,	 0x1.d900p-47,
-	0x1.bcc1e904bc1ffp-1,	 0x1.2a00p-47,
-	0x1.bdf69c3f3a16fp-1,	-0x1.f780p-46,
-	0x1.bf2c25bd71db8p-1,	-0x1.0a00p-46,
-	0x1.c06286141b2e9p-1,	-0x1.1400p-46,
-	0x1.c199bdd8552e0p-1,	 0x1.be00p-47,
-	0x1.c2d1cd9fa64eep-1,	-0x1.9400p-47,
-	0x1.c40ab5fffd02fp-1,	-0x1.ed00p-47,
-	0x1.c544778fafd15p-1,	 0x1.9660p-44,
-	0x1.c67f12e57d0cbp-1,	-0x1.a100p-46,
-	0x1.c7ba88988c1b6p-1,	-0x1.8458p-42,
-	0x1.c8f6d9406e733p-1,	-0x1.a480p-46,
-	0x1.ca3405751c4dfp-1,	 0x1.b000p-51,
-	0x1.cb720dcef9094p-1,	 0x1.1400p-47,
-	0x1.ccb0f2e6d1689p-1,	 0x1.0200p-48,
-	0x1.cdf0b555dc412p-1,	 0x1.3600p-48,
-	0x1.cf3155b5bab3bp-1,	-0x1.6900p-47,
-	0x1.d072d4a0789bcp-1,	 0x1.9a00p-47,
-	0x1.d1b532b08c8fap-1,	-0x1.5e00p-46,
-	0x1.d2f87080d8a85p-1,	 0x1.d280p-46,
-	0x1.d43c8eacaa203p-1,	 0x1.1a00p-47,
-	0x1.d5818dcfba491p-1,	 0x1.f000p-50,
-	0x1.d6c76e862e6a1p-1,	-0x1.3a00p-47,
-	0x1.d80e316c9834ep-1,	-0x1.cd80p-47,
-	0x1.d955d71ff6090p-1,	 0x1.4c00p-48,
-	0x1.da9e603db32aep-1,	 0x1.f900p-48,
-	0x1.dbe7cd63a8325p-1,	 0x1.9800p-49,
-	0x1.dd321f301b445p-1,	-0x1.5200p-48,
-	0x1.de7d5641c05bfp-1,	-0x1.d700p-46,
-	0x1.dfc97337b9aecp-1,	-0x1.6140p-46,
-	0x1.e11676b197d5ep-1,	 0x1.b480p-47,
-	0x1.e264614f5a3e7p-1,	 0x1.0ce0p-43,
-	0x1.e3b333b16ee5cp-1,	 0x1.c680p-47,
-	0x1.e502ee78b3fb4p-1,	-0x1.9300p-47,
-	0x1.e653924676d68p-1,	-0x1.5000p-49,
-	0x1.e7a51fbc74c44p-1,	-0x1.7f80p-47,
-	0x1.e8f7977cdb726p-1,	-0x1.3700p-48,
-	0x1.ea4afa2a490e8p-1,	 0x1.5d00p-49,
-	0x1.eb9f4867ccae4p-1,	 0x1.61a0p-46,
-	0x1.ecf482d8e680dp-1,	 0x1.5500p-48,
-	0x1.ee4aaa2188514p-1,	 0x1.6400p-51,
-	0x1.efa1bee615a13p-1,	-0x1.e800p-49,
-	0x1.f0f9c1cb64106p-1,	-0x1.a880p-48,
-	0x1.f252b376bb963p-1,	-0x1.c900p-45,
-	0x1.f3ac948dd7275p-1,	 0x1.a000p-53,
-	0x1.f50765b6e4524p-1,	-0x1.4f00p-48,
-	0x1.f6632798844fdp-1,	 0x1.a800p-51,
-	0x1.f7bfdad9cbe38p-1,	 0x1.abc0p-48,
-	0x1.f91d802243c82p-1,	-0x1.4600p-50,
-	0x1.fa7c1819e908ep-1,	-0x1.b0c0p-47,
-	0x1.fbdba3692d511p-1,	-0x1.0e00p-51,
-	0x1.fd3c22b8f7194p-1,	-0x1.0de8p-46,
-	0x1.fe9d96b2a23eep-1,	 0x1.e430p-49,
-	0x1.0000000000000p+0,	 0x0.0000p+0,
-	0x1.00b1afa5abcbep+0,	-0x1.3400p-52,
-	0x1.0163da9fb3303p+0,	-0x1.2170p-46,
-	0x1.02168143b0282p+0,	 0x1.a400p-52,
-	0x1.02c9a3e77806cp+0,	 0x1.f980p-49,
-	0x1.037d42e11bbcap+0,	-0x1.7400p-51,
-	0x1.04315e86e7f89p+0,	 0x1.8300p-50,
-	0x1.04e5f72f65467p+0,	-0x1.a3f0p-46,
-	0x1.059b0d315855ap+0,	-0x1.2840p-47,
-	0x1.0650a0e3c1f95p+0,	 0x1.1600p-48,
-	0x1.0706b29ddf71ap+0,	 0x1.5240p-46,
-	0x1.07bd42b72a82dp+0,	-0x1.9a00p-49,
-	0x1.0874518759bd0p+0,	 0x1.6400p-49,
-	0x1.092bdf66607c8p+0,	-0x1.0780p-47,
-	0x1.09e3ecac6f383p+0,	-0x1.8000p-54,
-	0x1.0a9c79b1f3930p+0,	 0x1.fa00p-48,
-	0x1.0b5586cf988fcp+0,	-0x1.ac80p-48,
-	0x1.0c0f145e46c8ap+0,	 0x1.9c00p-50,
-	0x1.0cc922b724816p+0,	 0x1.5200p-47,
-	0x1.0d83b23395dd8p+0,	-0x1.ad00p-48,
-	0x1.0e3ec32d3d1f3p+0,	 0x1.bac0p-46,
-	0x1.0efa55fdfa9a6p+0,	-0x1.4e80p-47,
-	0x1.0fb66affed2f0p+0,	-0x1.d300p-47,
-	0x1.1073028d7234bp+0,	 0x1.1500p-48,
-	0x1.11301d0125b5bp+0,	 0x1.c000p-49,
-	0x1.11edbab5e2af9p+0,	 0x1.6bc0p-46,
-	0x1.12abdc06c31d5p+0,	 0x1.8400p-49,
-	0x1.136a814f2047dp+0,	-0x1.ed00p-47,
-	0x1.1429aaea92de9p+0,	 0x1.8e00p-49,
-	0x1.14e95934f3138p+0,	 0x1.b400p-49,
-	0x1.15a98c8a58e71p+0,	 0x1.5300p-47,
-	0x1.166a45471c3dfp+0,	 0x1.3380p-47,
-	0x1.172b83c7d5211p+0,	 0x1.8d40p-45,
-	0x1.17ed48695bb9fp+0,	-0x1.5d00p-47,
-	0x1.18af9388c8d93p+0,	-0x1.c880p-46,
-	0x1.1972658375d66p+0,	 0x1.1f00p-46,
-	0x1.1a35beb6fcba7p+0,	 0x1.0480p-46,
-	0x1.1af99f81387e3p+0,	-0x1.7390p-43,
-	0x1.1bbe084045d54p+0,	 0x1.4e40p-45,
-	0x1.1c82f95281c43p+0,	-0x1.a200p-47,
-	0x1.1d4873168b9b2p+0,	 0x1.3800p-49,
-	0x1.1e0e75eb44031p+0,	 0x1.ac00p-49,
-	0x1.1ed5022fcd938p+0,	 0x1.1900p-47,
-	0x1.1f9c18438cdf7p+0,	-0x1.b780p-46,
-	0x1.2063b88628d8fp+0,	 0x1.d940p-45,
-	0x1.212be3578a81ep+0,	 0x1.8000p-50,
-	0x1.21f49917ddd41p+0,	 0x1.b340p-45,
-	0x1.22bdda2791323p+0,	 0x1.9f80p-46,
-	0x1.2387a6e7561e7p+0,	-0x1.9c80p-46,
-	0x1.2451ffb821427p+0,	 0x1.2300p-47,
-	0x1.251ce4fb2a602p+0,	-0x1.3480p-46,
-	0x1.25e85711eceb0p+0,	 0x1.2700p-46,
-	0x1.26b4565e27d16p+0,	 0x1.1d00p-46,
-	0x1.2780e341de00fp+0,	 0x1.1ee0p-44,
-	0x1.284dfe1f5633ep+0,	-0x1.4c00p-46,
-	0x1.291ba7591bb30p+0,	-0x1.3d80p-46,
-	0x1.29e9df51fdf09p+0,	 0x1.8b00p-47,
-	0x1.2ab8a66d10e9bp+0,	-0x1.27c0p-45,
-	0x1.2b87fd0dada3ap+0,	 0x1.a340p-45,
-	0x1.2c57e39771af9p+0,	-0x1.0800p-46,
-	0x1.2d285a6e402d9p+0,	-0x1.ed00p-47,
-	0x1.2df961f641579p+0,	-0x1.4200p-48,
-	0x1.2ecafa93e2ecfp+0,	-0x1.4980p-45,
-	0x1.2f9d24abd8822p+0,	-0x1.6300p-46,
-	0x1.306fe0a31b625p+0,	-0x1.2360p-44,
-	0x1.31432edeea50bp+0,	-0x1.0df8p-40,
-	0x1.32170fc4cd7b8p+0,	-0x1.2480p-45,
-	0x1.32eb83ba8e9a2p+0,	-0x1.5980p-45,
-	0x1.33c08b2641766p+0,	 0x1.ed00p-46,
-	0x1.3496266e3fa27p+0,	-0x1.c000p-50,
-	0x1.356c55f929f0fp+0,	-0x1.0d80p-44,
-	0x1.36431a2de88b9p+0,	 0x1.2c80p-45,
-	0x1.371a7373aaa39p+0,	 0x1.0600p-45,
-	0x1.37f26231e74fep+0,	-0x1.6600p-46,
-	0x1.38cae6d05d838p+0,	-0x1.ae00p-47,
-	0x1.39a401b713ec3p+0,	-0x1.4720p-43,
-	0x1.3a7db34e5a020p+0,	 0x1.8200p-47,
-	0x1.3b57fbfec6e95p+0,	 0x1.e800p-44,
-	0x1.3c32dc313a8f2p+0,	 0x1.f800p-49,
-	0x1.3d0e544ede122p+0,	-0x1.7a00p-46,
-	0x1.3dea64c1234bbp+0,	 0x1.6300p-45,
-	0x1.3ec70df1c4eccp+0,	-0x1.8a60p-43,
-	0x1.3fa4504ac7e8cp+0,	-0x1.cdc0p-44,
-	0x1.40822c367a0bbp+0,	 0x1.5b80p-45,
-	0x1.4160a21f72e95p+0,	 0x1.ec00p-46,
-	0x1.423fb27094646p+0,	-0x1.3600p-46,
-	0x1.431f5d950a920p+0,	 0x1.3980p-45,
-	0x1.43ffa3f84b9ebp+0,	 0x1.a000p-48,
-	0x1.44e0860618919p+0,	-0x1.6c00p-48,
-	0x1.45c2042a7d201p+0,	-0x1.bc00p-47,
-	0x1.46a41ed1d0016p+0,	-0x1.2800p-46,
-	0x1.4786d668b3326p+0,	 0x1.0e00p-44,
-	0x1.486a2b5c13c00p+0,	-0x1.d400p-45,
-	0x1.494e1e192af04p+0,	 0x1.c200p-47,
-	0x1.4a32af0d7d372p+0,	-0x1.e500p-46,
-	0x1.4b17dea6db801p+0,	 0x1.7800p-47,
-	0x1.4bfdad53629e1p+0,	-0x1.3800p-46,
-	0x1.4ce41b817c132p+0,	 0x1.0800p-47,
-	0x1.4dcb299fddddbp+0,	 0x1.c700p-45,
-	0x1.4eb2d81d8ab96p+0,	-0x1.ce00p-46,
-	0x1.4f9b2769d2d02p+0,	 0x1.9200p-46,
-	0x1.508417f4531c1p+0,	-0x1.8c00p-47,
-	0x1.516daa2cf662ap+0,	-0x1.a000p-48,
-	0x1.5257de83f51eap+0,	 0x1.a080p-43,
-	0x1.5342b569d4edap+0,	-0x1.6d80p-45,
-	0x1.542e2f4f6ac1ap+0,	-0x1.2440p-44,
-	0x1.551a4ca5d94dbp+0,	 0x1.83c0p-43,
-	0x1.56070dde9116bp+0,	 0x1.4b00p-45,
-	0x1.56f4736b529dep+0,	 0x1.15a0p-43,
-	0x1.57e27dbe2c40ep+0,	-0x1.9e00p-45,
-	0x1.58d12d497c76fp+0,	-0x1.3080p-45,
-	0x1.59c0827ff0b4cp+0,	 0x1.dec0p-43,
-	0x1.5ab07dd485427p+0,	-0x1.4000p-51,
-	0x1.5ba11fba87af4p+0,	 0x1.0080p-44,
-	0x1.5c9268a59460bp+0,	-0x1.6c80p-45,
-	0x1.5d84590998e3fp+0,	 0x1.69a0p-43,
-	0x1.5e76f15ad20e1p+0,	-0x1.b400p-46,
-	0x1.5f6a320dcebcap+0,	 0x1.7700p-46,
-	0x1.605e1b976dcb8p+0,	 0x1.6f80p-45,
-	0x1.6152ae6cdf715p+0,	 0x1.1000p-47,
-	0x1.6247eb03a5531p+0,	-0x1.5d00p-46,
-	0x1.633dd1d1929b5p+0,	-0x1.2d00p-46,
-	0x1.6434634ccc313p+0,	-0x1.a800p-49,
-	0x1.652b9febc8efap+0,	-0x1.8600p-45,
-	0x1.6623882553397p+0,	 0x1.1fe0p-40,
-	0x1.671c1c708328ep+0,	-0x1.7200p-44,
-	0x1.68155d44ca97ep+0,	 0x1.6800p-49,
-	0x1.690f4b19e9471p+0,	-0x1.9780p-45,
-};
-
-/*
- * exp2(x): compute the base 2 exponential of x
- *
- * Accuracy: Peak error < 0.503 ulp for normalized results.
- *
- * Method: (accurate tables)
- *
- *   Reduce x:
- *     x = 2**k + y, for integer k and |y| <= 1/2.
- *     Thus we have exp2(x) = 2**k * exp2(y).
- *
- *   Reduce y:
- *     y = i/TBLSIZE + z - eps[i] for integer i near y * TBLSIZE.
- *     Thus we have exp2(y) = exp2(i/TBLSIZE) * exp2(z - eps[i]),
- *     with |z - eps[i]| <= 2**-9 + 2**-39 for the table used.
- *
- *   We compute exp2(i/TBLSIZE) via table lookup and exp2(z - eps[i]) via
- *   a degree-5 minimax polynomial with maximum error under 1.3 * 2**-61.
- *   The values in exp2t[] and eps[] are chosen such that
- *   exp2t[i] = exp2(i/TBLSIZE + eps[i]), and eps[i] is a small offset such
- *   that exp2t[i] is accurate to 2**-64.
- *
- *   Note that the range of i is +-TBLSIZE/2, so we actually index the tables
- *   by i0 = i + TBLSIZE/2.  For cache efficiency, exp2t[] and eps[] are
- *   virtual tables, interleaved in the real table tbl[].
- *
- *   This method is due to Gal, with many details due to Gal and Bachelis:
- *
- *	Gal, S. and Bachelis, B.  An Accurate Elementary Mathematical Library
- *	for the IEEE Floating Point Standard.  TOMS 17(1), 26-46 (1991).
- */
-double
-exp2(double x)
-{
-	double r, t, z;
-	uint32_t hx, hr, ix, lx, i0;
-	int k;
-
-	/* Filter out exceptional cases. */
-	GET_HIGH_WORD(hx,x);
-	ix = hx & 0x7fffffff;		/* high word of |x| */
-	if(ix >= 0x40900000) {			/* |x| >= 1024 */
-		if(ix >= 0x7ff00000) {
-			GET_LOW_WORD(lx,x);
-			if(((ix & 0xfffff) | lx) != 0 || (hx & 0x80000000) == 0)
-				return (x); 	/* x is NaN or +Inf */
-			else 
-				return (0.0);	/* x is -Inf */
-		}
-		if(x >= 0x1.0p10)
-			return (huge * huge); /* overflow */
-		if(x <= -0x1.0ccp10)
-			return (twom1000 * twom1000); /* underflow */
-	} else if (ix < 0x3c900000) {		/* |x| < 0x1p-54 */
-		return (1.0 + x);
-	}
-
-	/* Reduce x, computing z, i0, and k. */
-	t = x + redux;
-	GET_LOW_WORD(i0, t);
-	i0 += TBLSIZE / 2;
-	k = (i0 >> TBLBITS) << 20;
-	i0 = (i0 & (TBLSIZE - 1)) << 1;
-	t -= redux;
-	z = x - t;
-
-	/* Compute r = exp2(y) = exp2t[i0] * p(z - eps[i]). */
-	t = tbl[i0];		/* exp2t[i0] */
-	z -= tbl[i0 + 1];	/* eps[i0]   */
-	r = t + t * z * (P1 + z * (P2 + z * (P3 + z * (P4 + z * P5))));
-
-	/* Scale by 2**(k>>20). */
-	if(k >= -1021 << 20) {
-		if (k != 0) {
-			GET_HIGH_WORD(hr, r);
-			SET_HIGH_WORD(r, hr + k);
-		}
-		return (r);
-	} else {
-		GET_HIGH_WORD(hr, r);
-		SET_HIGH_WORD(r, hr + (k + (1000 << 20)));
-		return (r * twom1000);
-	}
-}
diff --git a/libm/src/s_exp2f.c b/libm/src/s_exp2f.c
deleted file mode 100644
index 5e98e8a..0000000
--- a/libm/src/s_exp2f.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_exp2f.c,v 1.1 2005/04/05 02:57:15 das Exp $"); */
-
-#include "math.h"
-#include "math_private.h"
-
-#define	TBLBITS	4
-#define	TBLSIZE	(1 << TBLBITS)
-
-static const float
-    huge    = 0x1p100f,
-    twom100 = 0x1p-100f,
-    redux   = 0x1.8p23f / TBLSIZE,
-    P1	    = 0x1.62e430p-1f,
-    P2	    = 0x1.ebfbe0p-3f,
-    P3	    = 0x1.c6b348p-5f,
-    P4	    = 0x1.3b2c9cp-7f;
-
-static const double exp2ft[TBLSIZE] = {
-	0x1.6a09e667f3bcdp-1,
-	0x1.7a11473eb0187p-1,
-	0x1.8ace5422aa0dbp-1,
-	0x1.9c49182a3f090p-1,
-	0x1.ae89f995ad3adp-1,
-	0x1.c199bdd85529cp-1,
-	0x1.d5818dcfba487p-1,
-	0x1.ea4afa2a490dap-1,
-	0x1.0000000000000p+0,
-	0x1.0b5586cf9890fp+0,
-	0x1.172b83c7d517bp+0,
-	0x1.2387a6e756238p+0,
-	0x1.306fe0a31b715p+0,
-	0x1.3dea64c123422p+0,
-	0x1.4bfdad5362a27p+0,
-	0x1.5ab07dd485429p+0,
-};
-	
-/*
- * exp2f(x): compute the base 2 exponential of x
- *
- * Accuracy: Peak error < 0.501 ulp; location of peak: -0.030110927.
- *
- * Method: (equally-spaced tables)
- *
- *   Reduce x:
- *     x = 2**k + y, for integer k and |y| <= 1/2.
- *     Thus we have exp2f(x) = 2**k * exp2(y).
- *
- *   Reduce y:
- *     y = i/TBLSIZE + z for integer i near y * TBLSIZE.
- *     Thus we have exp2(y) = exp2(i/TBLSIZE) * exp2(z),
- *     with |z| <= 2**-(TBLSIZE+1).
- *
- *   We compute exp2(i/TBLSIZE) via table lookup and exp2(z) via a
- *   degree-4 minimax polynomial with maximum error under 1.4 * 2**-33.
- *   Using double precision in the final calculation avoids roundoff error.
- *
- *   This method is due to Tang, but I do not use his suggested parameters:
- *
- *	Tang, P.  Table-driven Implementation of the Exponential Function
- *	in IEEE Floating-Point Arithmetic.  TOMS 15(2), 144-157 (1989).
- */
-float
-exp2f(float x)
-{
-	double tv;
-	float r, z;
-	volatile float t;	/* prevent gcc from using too much precision */
-	uint32_t hx, hr, ix, i0;
-	int32_t k;
-
-	/* Filter out exceptional cases. */
-	GET_FLOAT_WORD(hx,x);
-	ix = hx & 0x7fffffff;		/* high word of |x| */
-	if(ix >= 0x43000000) {			/* |x| >= 128 */
-		if(ix >= 0x7f800000) {
-			if ((ix & 0x7fffff) != 0 || (hx & 0x80000000) == 0)
-				return (x); 	/* x is NaN or +Inf */
-			else 
-				return (0.0);	/* x is -Inf */
-		}
-		if(x >= 0x1.0p7f)
-			return (huge * huge);	/* overflow */
-		if(x <= -0x1.2cp7f)
-			return (twom100 * twom100); /* underflow */
-	} else if (ix <= 0x33000000) {		/* |x| <= 0x1p-25 */
-		return (1.0f + x);
-	}
-
-	/* Reduce x, computing z, i0, and k. */
-	t = x + redux;
-	GET_FLOAT_WORD(i0, t);
-	i0 += TBLSIZE / 2;
-	k = (i0 >> TBLBITS) << 23;
-	i0 &= TBLSIZE - 1;
-	t -= redux;
-	z = x - t;
-
-	/* Compute r = exp2(y) = exp2ft[i0] * p(z). */
-	tv = exp2ft[i0];
-	r = tv + tv * (z * (P1 + z * (P2 + z * (P3 + z * P4))));
-
-	/* Scale by 2**(k>>23). */
-	if(k >= -125 << 23) {
-		if (k != 0) {
-			GET_FLOAT_WORD(hr, r);
-			SET_FLOAT_WORD(r, hr + k);
-		}
-		return (r);
-	} else {
-		GET_FLOAT_WORD(hr, r);
-		SET_FLOAT_WORD(r, hr + (k + (100 << 23)));
-		return (r * twom100);
-	}
-}
diff --git a/libm/src/s_expm1.c b/libm/src/s_expm1.c
deleted file mode 100644
index 57aa3f2..0000000
--- a/libm/src/s_expm1.c
+++ /dev/null
@@ -1,220 +0,0 @@
-/* @(#)s_expm1.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_expm1.c,v 1.7 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-/* expm1(x)
- * Returns exp(x)-1, the exponential of x minus 1.
- *
- * Method
- *   1. Argument reduction:
- *	Given x, find r and integer k such that
- *
- *               x = k*ln2 + r,  |r| <= 0.5*ln2 ~ 0.34658
- *
- *      Here a correction term c will be computed to compensate
- *	the error in r when rounded to a floating-point number.
- *
- *   2. Approximating expm1(r) by a special rational function on
- *	the interval [0,0.34658]:
- *	Since
- *	    r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 - r^4/360 + ...
- *	we define R1(r*r) by
- *	    r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 * R1(r*r)
- *	That is,
- *	    R1(r**2) = 6/r *((exp(r)+1)/(exp(r)-1) - 2/r)
- *		     = 6/r * ( 1 + 2.0*(1/(exp(r)-1) - 1/r))
- *		     = 1 - r^2/60 + r^4/2520 - r^6/100800 + ...
- *      We use a special Reme algorithm on [0,0.347] to generate
- * 	a polynomial of degree 5 in r*r to approximate R1. The
- *	maximum error of this polynomial approximation is bounded
- *	by 2**-61. In other words,
- *	    R1(z) ~ 1.0 + Q1*z + Q2*z**2 + Q3*z**3 + Q4*z**4 + Q5*z**5
- *	where 	Q1  =  -1.6666666666666567384E-2,
- * 		Q2  =   3.9682539681370365873E-4,
- * 		Q3  =  -9.9206344733435987357E-6,
- * 		Q4  =   2.5051361420808517002E-7,
- * 		Q5  =  -6.2843505682382617102E-9;
- *  	(where z=r*r, and the values of Q1 to Q5 are listed below)
- *	with error bounded by
- *	    |                  5           |     -61
- *	    | 1.0+Q1*z+...+Q5*z   -  R1(z) | <= 2
- *	    |                              |
- *
- *	expm1(r) = exp(r)-1 is then computed by the following
- * 	specific way which minimize the accumulation rounding error:
- *			       2     3
- *			      r     r    [ 3 - (R1 + R1*r/2)  ]
- *	      expm1(r) = r + --- + --- * [--------------------]
- *		              2     2    [ 6 - r*(3 - R1*r/2) ]
- *
- *	To compensate the error in the argument reduction, we use
- *		expm1(r+c) = expm1(r) + c + expm1(r)*c
- *			   ~ expm1(r) + c + r*c
- *	Thus c+r*c will be added in as the correction terms for
- *	expm1(r+c). Now rearrange the term to avoid optimization
- * 	screw up:
- *		        (      2                                    2 )
- *		        ({  ( r    [ R1 -  (3 - R1*r/2) ]  )  }    r  )
- *	 expm1(r+c)~r - ({r*(--- * [--------------------]-c)-c} - --- )
- *	                ({  ( 2    [ 6 - r*(3 - R1*r/2) ]  )  }    2  )
- *                      (                                             )
- *
- *		   = r - E
- *   3. Scale back to obtain expm1(x):
- *	From step 1, we have
- *	   expm1(x) = either 2^k*[expm1(r)+1] - 1
- *		    = or     2^k*[expm1(r) + (1-2^-k)]
- *   4. Implementation notes:
- *	(A). To save one multiplication, we scale the coefficient Qi
- *	     to Qi*2^i, and replace z by (x^2)/2.
- *	(B). To achieve maximum accuracy, we compute expm1(x) by
- *	  (i)   if x < -56*ln2, return -1.0, (raise inexact if x!=inf)
- *	  (ii)  if k=0, return r-E
- *	  (iii) if k=-1, return 0.5*(r-E)-0.5
- *        (iv)	if k=1 if r < -0.25, return 2*((r+0.5)- E)
- *	       	       else	     return  1.0+2.0*(r-E);
- *	  (v)   if (k<-2||k>56) return 2^k(1-(E-r)) - 1 (or exp(x)-1)
- *	  (vi)  if k <= 20, return 2^k((1-2^-k)-(E-r)), else
- *	  (vii) return 2^k(1-((E+2^-k)-r))
- *
- * Special cases:
- *	expm1(INF) is INF, expm1(NaN) is NaN;
- *	expm1(-INF) is -1, and
- *	for finite argument, only expm1(0)=0 is exact.
- *
- * Accuracy:
- *	according to an error analysis, the error is always less than
- *	1 ulp (unit in the last place).
- *
- * Misc. info.
- *	For IEEE double
- *	    if x >  7.09782712893383973096e+02 then expm1(x) overflow
- *
- * Constants:
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
- * to produce the hexadecimal values shown.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-one		= 1.0,
-huge		= 1.0e+300,
-tiny		= 1.0e-300,
-o_threshold	= 7.09782712893383973096e+02,/* 0x40862E42, 0xFEFA39EF */
-ln2_hi		= 6.93147180369123816490e-01,/* 0x3fe62e42, 0xfee00000 */
-ln2_lo		= 1.90821492927058770002e-10,/* 0x3dea39ef, 0x35793c76 */
-invln2		= 1.44269504088896338700e+00,/* 0x3ff71547, 0x652b82fe */
-	/* scaled coefficients related to expm1 */
-Q1  =  -3.33333333333331316428e-02, /* BFA11111 111110F4 */
-Q2  =   1.58730158725481460165e-03, /* 3F5A01A0 19FE5585 */
-Q3  =  -7.93650757867487942473e-05, /* BF14CE19 9EAADBB7 */
-Q4  =   4.00821782732936239552e-06, /* 3ED0CFCA 86E65239 */
-Q5  =  -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */
-
-double
-expm1(double x)
-{
-	double y,hi,lo,c,t,e,hxs,hfx,r1;
-	int32_t k,xsb;
-	u_int32_t hx;
-
-	GET_HIGH_WORD(hx,x);
-	xsb = hx&0x80000000;		/* sign bit of x */
-	if(xsb==0) y=x; else y= -x;	/* y = |x| */
-	hx &= 0x7fffffff;		/* high word of |x| */
-
-    /* filter out huge and non-finite argument */
-	if(hx >= 0x4043687A) {			/* if |x|>=56*ln2 */
-	    if(hx >= 0x40862E42) {		/* if |x|>=709.78... */
-                if(hx>=0x7ff00000) {
-		    u_int32_t low;
-		    GET_LOW_WORD(low,x);
-		    if(((hx&0xfffff)|low)!=0)
-		         return x+x; 	 /* NaN */
-		    else return (xsb==0)? x:-1.0;/* exp(+-inf)={inf,-1} */
-	        }
-	        if(x > o_threshold) return huge*huge; /* overflow */
-	    }
-	    if(xsb!=0) { /* x < -56*ln2, return -1.0 with inexact */
-		if(x+tiny<0.0)		/* raise inexact */
-		return tiny-one;	/* return -1 */
-	    }
-	}
-
-    /* argument reduction */
-	if(hx > 0x3fd62e42) {		/* if  |x| > 0.5 ln2 */
-	    if(hx < 0x3FF0A2B2) {	/* and |x| < 1.5 ln2 */
-		if(xsb==0)
-		    {hi = x - ln2_hi; lo =  ln2_lo;  k =  1;}
-		else
-		    {hi = x + ln2_hi; lo = -ln2_lo;  k = -1;}
-	    } else {
-		k  = invln2*x+((xsb==0)?0.5:-0.5);
-		t  = k;
-		hi = x - t*ln2_hi;	/* t*ln2_hi is exact here */
-		lo = t*ln2_lo;
-	    }
-	    x  = hi - lo;
-	    c  = (hi-x)-lo;
-	}
-	else if(hx < 0x3c900000) {  	/* when |x|<2**-54, return x */
-	    t = huge+x;	/* return x with inexact flags when x!=0 */
-	    return x - (t-(huge+x));
-	}
-	else k = 0;
-
-    /* x is now in primary range */
-	hfx = 0.5*x;
-	hxs = x*hfx;
-	r1 = one+hxs*(Q1+hxs*(Q2+hxs*(Q3+hxs*(Q4+hxs*Q5))));
-	t  = 3.0-r1*hfx;
-	e  = hxs*((r1-t)/(6.0 - x*t));
-	if(k==0) return x - (x*e-hxs);		/* c is 0 */
-	else {
-	    e  = (x*(e-c)-c);
-	    e -= hxs;
-	    if(k== -1) return 0.5*(x-e)-0.5;
-	    if(k==1)
-	       	if(x < -0.25) return -2.0*(e-(x+0.5));
-	       	else 	      return  one+2.0*(x-e);
-	    if (k <= -2 || k>56) {   /* suffice to return exp(x)-1 */
-	        u_int32_t high;
-	        y = one-(e-x);
-		GET_HIGH_WORD(high,y);
-		SET_HIGH_WORD(y,high+(k<<20));	/* add k to y's exponent */
-	        return y-one;
-	    }
-	    t = one;
-	    if(k<20) {
-	        u_int32_t high;
-	        SET_HIGH_WORD(t,0x3ff00000 - (0x200000>>k));  /* t=1-2^-k */
-	       	y = t-(e-x);
-		GET_HIGH_WORD(high,y);
-		SET_HIGH_WORD(y,high+(k<<20));	/* add k to y's exponent */
-	   } else {
-	        u_int32_t high;
-		SET_HIGH_WORD(t,((0x3ff-k)<<20));	/* 2^-k */
-	       	y = x-(e+t);
-	       	y += one;
-		GET_HIGH_WORD(high,y);
-		SET_HIGH_WORD(y,high+(k<<20));	/* add k to y's exponent */
-	    }
-	}
-	return y;
-}
diff --git a/libm/src/s_expm1f.c b/libm/src/s_expm1f.c
deleted file mode 100644
index a670a72..0000000
--- a/libm/src/s_expm1f.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/* s_expm1f.c -- float version of s_expm1.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_expm1f.c,v 1.7 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float
-one		= 1.0,
-huge		= 1.0e+30,
-tiny		= 1.0e-30,
-o_threshold	= 8.8721679688e+01,/* 0x42b17180 */
-ln2_hi		= 6.9313812256e-01,/* 0x3f317180 */
-ln2_lo		= 9.0580006145e-06,/* 0x3717f7d1 */
-invln2		= 1.4426950216e+00,/* 0x3fb8aa3b */
-	/* scaled coefficients related to expm1 */
-Q1  =  -3.3333335072e-02, /* 0xbd088889 */
-Q2  =   1.5873016091e-03, /* 0x3ad00d01 */
-Q3  =  -7.9365076090e-05, /* 0xb8a670cd */
-Q4  =   4.0082177293e-06, /* 0x36867e54 */
-Q5  =  -2.0109921195e-07; /* 0xb457edbb */
-
-float
-expm1f(float x)
-{
-	float y,hi,lo,c,t,e,hxs,hfx,r1;
-	int32_t k,xsb;
-	u_int32_t hx;
-
-	GET_FLOAT_WORD(hx,x);
-	xsb = hx&0x80000000;		/* sign bit of x */
-	if(xsb==0) y=x; else y= -x;	/* y = |x| */
-	hx &= 0x7fffffff;		/* high word of |x| */
-
-    /* filter out huge and non-finite argument */
-	if(hx >= 0x4195b844) {			/* if |x|>=27*ln2 */
-	    if(hx >= 0x42b17218) {		/* if |x|>=88.721... */
-                if(hx>0x7f800000)
-		    return x+x; 	 /* NaN */
-		if(hx==0x7f800000)
-		    return (xsb==0)? x:-1.0;/* exp(+-inf)={inf,-1} */
-	        if(x > o_threshold) return huge*huge; /* overflow */
-	    }
-	    if(xsb!=0) { /* x < -27*ln2, return -1.0 with inexact */
-		if(x+tiny<(float)0.0)	/* raise inexact */
-		return tiny-one;	/* return -1 */
-	    }
-	}
-
-    /* argument reduction */
-	if(hx > 0x3eb17218) {		/* if  |x| > 0.5 ln2 */
-	    if(hx < 0x3F851592) {	/* and |x| < 1.5 ln2 */
-		if(xsb==0)
-		    {hi = x - ln2_hi; lo =  ln2_lo;  k =  1;}
-		else
-		    {hi = x + ln2_hi; lo = -ln2_lo;  k = -1;}
-	    } else {
-		k  = invln2*x+((xsb==0)?(float)0.5:(float)-0.5);
-		t  = k;
-		hi = x - t*ln2_hi;	/* t*ln2_hi is exact here */
-		lo = t*ln2_lo;
-	    }
-	    x  = hi - lo;
-	    c  = (hi-x)-lo;
-	}
-	else if(hx < 0x33000000) {  	/* when |x|<2**-25, return x */
-	    t = huge+x;	/* return x with inexact flags when x!=0 */
-	    return x - (t-(huge+x));
-	}
-	else k = 0;
-
-    /* x is now in primary range */
-	hfx = (float)0.5*x;
-	hxs = x*hfx;
-	r1 = one+hxs*(Q1+hxs*(Q2+hxs*(Q3+hxs*(Q4+hxs*Q5))));
-	t  = (float)3.0-r1*hfx;
-	e  = hxs*((r1-t)/((float)6.0 - x*t));
-	if(k==0) return x - (x*e-hxs);		/* c is 0 */
-	else {
-	    e  = (x*(e-c)-c);
-	    e -= hxs;
-	    if(k== -1) return (float)0.5*(x-e)-(float)0.5;
-	    if(k==1)
-	       	if(x < (float)-0.25) return -(float)2.0*(e-(x+(float)0.5));
-	       	else 	      return  one+(float)2.0*(x-e);
-	    if (k <= -2 || k>56) {   /* suffice to return exp(x)-1 */
-	        int32_t i;
-	        y = one-(e-x);
-		GET_FLOAT_WORD(i,y);
-		SET_FLOAT_WORD(y,i+(k<<23));	/* add k to y's exponent */
-	        return y-one;
-	    }
-	    t = one;
-	    if(k<23) {
-	        int32_t i;
-	        SET_FLOAT_WORD(t,0x3f800000 - (0x1000000>>k)); /* t=1-2^-k */
-	       	y = t-(e-x);
-		GET_FLOAT_WORD(i,y);
-		SET_FLOAT_WORD(y,i+(k<<23));	/* add k to y's exponent */
-	   } else {
-	        int32_t i;
-		SET_FLOAT_WORD(t,((0x7f-k)<<23));	/* 2^-k */
-	       	y = x-(e+t);
-	       	y += one;
-		GET_FLOAT_WORD(i,y);
-		SET_FLOAT_WORD(y,i+(k<<23));	/* add k to y's exponent */
-	    }
-	}
-	return y;
-}
diff --git a/libm/src/s_fabs.c b/libm/src/s_fabs.c
deleted file mode 100644
index 0dfa940..0000000
--- a/libm/src/s_fabs.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* @(#)s_fabs.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_fabs.c,v 1.7 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-/*
- * fabs(x) returns the absolute value of x.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-double
-fabs(double x)
-{
-	u_int32_t high;
-	GET_HIGH_WORD(high,x);
-	SET_HIGH_WORD(x,high&0x7fffffff);
-        return x;
-}
diff --git a/libm/src/s_fabsf.c b/libm/src/s_fabsf.c
deleted file mode 100644
index 2200705..0000000
--- a/libm/src/s_fabsf.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* s_fabsf.c -- float version of s_fabs.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_fabsf.c,v 1.7 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-/*
- * fabsf(x) returns the absolute value of x.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-float
-fabsf(float x)
-{
-	u_int32_t ix;
-	GET_FLOAT_WORD(ix,x);
-	SET_FLOAT_WORD(x,ix&0x7fffffff);
-        return x;
-}
diff --git a/libm/src/s_fdim.c b/libm/src/s_fdim.c
deleted file mode 100644
index 6a347c1..0000000
--- a/libm/src/s_fdim.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_fdim.c,v 1.1 2004/06/30 07:04:01 das Exp $"); */
-
-#include <math.h>
-
-#define	DECL(type, fn)			\
-type					\
-fn(type x, type y)			\
-{					\
-					\
-	if (isnan(x))			\
-		return (x);		\
-	if (isnan(y))			\
-		return (y);		\
-	return (x > y ? x - y : 0.0);	\
-}
-
-DECL(double, fdim)
-DECL(float, fdimf)
-DECL(long double, fdiml)
diff --git a/libm/src/s_finite.c b/libm/src/s_finite.c
deleted file mode 100644
index 704d1d8..0000000
--- a/libm/src/s_finite.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/* @(#)s_finite.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_finite.c,v 1.8 2003/07/23 04:53:46 peter Exp $";
-#endif
-
-/*
- * finite(x) returns 1 is x is finite, else 0;
- * no branching!
- */
-
-#include "math.h"
-#include "math_private.h"
-
-	int finite(double x)
-{
-	int32_t hx;
-	GET_HIGH_WORD(hx,x);
-	return (int)((u_int32_t)((hx&0x7fffffff)-0x7ff00000)>>31);
-}
diff --git a/libm/src/s_finitef.c b/libm/src/s_finitef.c
deleted file mode 100644
index b430639..0000000
--- a/libm/src/s_finitef.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* s_finitef.c -- float version of s_finite.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_finitef.c,v 1.6 2002/05/28 17:51:46 alfred Exp $";
-#endif
-
-/*
- * finitef(x) returns 1 is x is finite, else 0;
- * no branching!
- */
-
-#include "math.h"
-#include "math_private.h"
-
-	int finitef(float x)
-{
-	int32_t ix;
-	GET_FLOAT_WORD(ix,x);
-	return (int)((u_int32_t)((ix&0x7fffffff)-0x7f800000)>>31);
-}
diff --git a/libm/src/s_floor.c b/libm/src/s_floor.c
deleted file mode 100644
index acc3214..0000000
--- a/libm/src/s_floor.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* @(#)s_floor.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_floor.c,v 1.9 2003/07/23 04:53:46 peter Exp $";
-#endif
-
-/*
- * floor(x)
- * Return x rounded toward -inf to integral value
- * Method:
- *	Bit twiddling.
- * Exception:
- *	Inexact flag raised if x not equal to floor(x).
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double huge = 1.0e300;
-
-double
-floor(double x)
-{
-	int32_t i0,i1,j0;
-	u_int32_t i,j;
-	EXTRACT_WORDS(i0,i1,x);
-	j0 = ((i0>>20)&0x7ff)-0x3ff;
-	if(j0<20) {
-	    if(j0<0) { 	/* raise inexact if x != 0 */
-		if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */
-		    if(i0>=0) {i0=i1=0;}
-		    else if(((i0&0x7fffffff)|i1)!=0)
-			{ i0=0xbff00000;i1=0;}
-		}
-	    } else {
-		i = (0x000fffff)>>j0;
-		if(((i0&i)|i1)==0) return x; /* x is integral */
-		if(huge+x>0.0) {	/* raise inexact flag */
-		    if(i0<0) i0 += (0x00100000)>>j0;
-		    i0 &= (~i); i1=0;
-		}
-	    }
-	} else if (j0>51) {
-	    if(j0==0x400) return x+x;	/* inf or NaN */
-	    else return x;		/* x is integral */
-	} else {
-	    i = ((u_int32_t)(0xffffffff))>>(j0-20);
-	    if((i1&i)==0) return x;	/* x is integral */
-	    if(huge+x>0.0) { 		/* raise inexact flag */
-		if(i0<0) {
-		    if(j0==20) i0+=1;
-		    else {
-			j = i1+(1<<(52-j0));
-			if(j<i1) i0 +=1 ; 	/* got a carry */
-			i1=j;
-		    }
-		}
-		i1 &= (~i);
-	    }
-	}
-	INSERT_WORDS(x,i0,i1);
-	return x;
-}
diff --git a/libm/src/s_floorf.c b/libm/src/s_floorf.c
deleted file mode 100644
index 70a71f3..0000000
--- a/libm/src/s_floorf.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/* s_floorf.c -- float version of s_floor.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_floorf.c,v 1.7 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-/*
- * floorf(x)
- * Return x rounded toward -inf to integral value
- * Method:
- *	Bit twiddling.
- * Exception:
- *	Inexact flag raised if x not equal to floorf(x).
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const float huge = 1.0e30;
-
-float
-floorf(float x)
-{
-	int32_t i0,j0;
-	u_int32_t i;
-	GET_FLOAT_WORD(i0,x);
-	j0 = ((i0>>23)&0xff)-0x7f;
-	if(j0<23) {
-	    if(j0<0) { 	/* raise inexact if x != 0 */
-		if(huge+x>(float)0.0) {/* return 0*sign(x) if |x|<1 */
-		    if(i0>=0) {i0=0;}
-		    else if((i0&0x7fffffff)!=0)
-			{ i0=0xbf800000;}
-		}
-	    } else {
-		i = (0x007fffff)>>j0;
-		if((i0&i)==0) return x; /* x is integral */
-		if(huge+x>(float)0.0) {	/* raise inexact flag */
-		    if(i0<0) i0 += (0x00800000)>>j0;
-		    i0 &= (~i);
-		}
-	    }
-	} else {
-	    if(j0==0x80) return x+x;	/* inf or NaN */
-	    else return x;		/* x is integral */
-	}
-	SET_FLOAT_WORD(x,i0);
-	return x;
-}
diff --git a/libm/src/s_floorl.c b/libm/src/s_floorl.c
deleted file mode 100644
index 2ef0acc..0000000
--- a/libm/src/s_floorl.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- *
- * From: @(#)s_floor.c 5.1 93/09/24
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_floorl.c,v 1.4 2005/04/28 19:45:55 stefanf Exp $";
-#endif
-
-/*
- * floorl(x)
- * Return x rounded toward -inf to integral value
- * Method:
- *	Bit twiddling.
- * Exception:
- *	Inexact flag raised if x not equal to floorl(x).
- */
-
-#include <float.h>
-#include <math.h>
-#include <stdint.h>
-
-#include "fpmath.h"
-
-#ifdef LDBL_IMPLICIT_NBIT
-#define	MANH_SIZE	(LDBL_MANH_SIZE + 1)
-#define	INC_MANH(u, c)	do {					\
-	uint64_t o = u.bits.manh;				\
-	u.bits.manh += (c);					\
-	if (u.bits.manh < o)					\
-		u.bits.exp++;					\
-} while (0)
-#else
-#define	MANH_SIZE	LDBL_MANH_SIZE
-#define	INC_MANH(u, c)	do {					\
-	uint64_t o = u.bits.manh;				\
-	u.bits.manh += (c);					\
-	if (u.bits.manh < o) {					\
-		u.bits.exp++;					\
-		u.bits.manh |= 1llu << (LDBL_MANH_SIZE - 1);	\
-	}							\
-} while (0)
-#endif
-
-static const long double huge = 1.0e300;
-
-long double
-floorl(long double x)
-{
-	union IEEEl2bits u = { .e = x };
-	int e = u.bits.exp - LDBL_MAX_EXP + 1;
-
-	if (e < MANH_SIZE - 1) {
-		if (e < 0) {			/* raise inexact if x != 0 */
-			if (huge + x > 0.0)
-				if (u.bits.exp > 0 ||
-				    (u.bits.manh | u.bits.manl) != 0)
-					u.e = u.bits.sign ? -1.0 : 0.0;
-		} else {
-			uint64_t m = ((1llu << MANH_SIZE) - 1) >> (e + 1);
-			if (((u.bits.manh & m) | u.bits.manl) == 0)
-				return (x);	/* x is integral */
-			if (u.bits.sign) {
-#ifdef LDBL_IMPLICIT_NBIT
-				if (e == 0)
-					u.bits.exp++;
-				else
-#endif
-				INC_MANH(u, 1llu << (MANH_SIZE - e - 1));
-			}
-			if (huge + x > 0.0) {	/* raise inexact flag */
-				u.bits.manh &= ~m;
-				u.bits.manl = 0;
-			}
-		}
-	} else if (e < LDBL_MANT_DIG - 1) {
-		uint64_t m = (uint64_t)-1 >> (64 - LDBL_MANT_DIG + e + 1);
-		if ((u.bits.manl & m) == 0)
-			return (x);	/* x is integral */
-		if (u.bits.sign) {
-			if (e == MANH_SIZE - 1)
-				INC_MANH(u, 1);
-			else {
-				uint64_t o = u.bits.manl;
-				u.bits.manl += 1llu << (LDBL_MANT_DIG - e - 1);
-				if (u.bits.manl < o)	/* got a carry */
-					INC_MANH(u, 1);
-			}
-		}
-		if (huge + x > 0.0)		/* raise inexact flag */
-			u.bits.manl &= ~m;
-	}
-	return (u.e);
-}
diff --git a/libm/src/s_fma.c b/libm/src/s_fma.c
deleted file mode 100644
index 1fcc26c..0000000
--- a/libm/src/s_fma.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_fma.c,v 1.4 2005/03/18 02:27:59 das Exp $"); */
-
-#include <fenv.h>
-#include <float.h>
-#include <math.h>
-
-/*
- * Fused multiply-add: Compute x * y + z with a single rounding error.
- *
- * We use scaling to avoid overflow/underflow, along with the
- * canonical precision-doubling technique adapted from:
- *
- *	Dekker, T.  A Floating-Point Technique for Extending the
- *	Available Precision.  Numer. Math. 18, 224-242 (1971).
- *
- * This algorithm is sensitive to the rounding precision.  FPUs such
- * as the i387 must be set in double-precision mode if variables are
- * to be stored in FP registers in order to avoid incorrect results.
- * This is the default on FreeBSD, but not on many other systems.
- *
- * Hardware instructions should be used on architectures that support it,
- * since this implementation will likely be several times slower.
- */
-#if LDBL_MANT_DIG != 113
-double
-fma(double x, double y, double z)
-{
-	static const double split = 0x1p27 + 1.0;
-	double xs, ys, zs;
-	double c, cc, hx, hy, p, q, tx, ty;
-	double r, rr, s;
-	int oround;
-	int ex, ey, ez;
-	int spread;
-
-	if (z == 0.0)
-		return (x * y);
-	if (x == 0.0 || y == 0.0)
-		return (x * y + z);
-
-	/* Results of frexp() are undefined for these cases. */
-	if (!isfinite(x) || !isfinite(y) || !isfinite(z))
-		return (x * y + z);
-
-	xs = frexp(x, &ex);
-	ys = frexp(y, &ey);
-	zs = frexp(z, &ez);
-	oround = fegetround();
-	spread = ex + ey - ez;
-
-	/*
-	 * If x * y and z are many orders of magnitude apart, the scaling
-	 * will overflow, so we handle these cases specially.  Rounding
-	 * modes other than FE_TONEAREST are painful.
-	 */
-	if (spread > DBL_MANT_DIG * 2) {
-		fenv_t env;
-		feraiseexcept(FE_INEXACT);
-		switch(oround) {
-		case FE_TONEAREST:
-			return (x * y);
-		case FE_TOWARDZERO:
-			if (x > 0.0 ^ y < 0.0 ^ z < 0.0)
-				return (x * y);
-			feholdexcept(&env);
-			r = x * y;
-			if (!fetestexcept(FE_INEXACT))
-				r = nextafter(r, 0);
-			feupdateenv(&env);
-			return (r);
-		case FE_DOWNWARD:
-			if (z > 0.0)
-				return (x * y);
-			feholdexcept(&env);
-			r = x * y;
-			if (!fetestexcept(FE_INEXACT))
-				r = nextafter(r, -INFINITY);
-			feupdateenv(&env);
-			return (r);
-		default:	/* FE_UPWARD */
-			if (z < 0.0)
-				return (x * y);
-			feholdexcept(&env);
-			r = x * y;
-			if (!fetestexcept(FE_INEXACT))
-				r = nextafter(r, INFINITY);
-			feupdateenv(&env);
-			return (r);
-		}
-	}
-	if (spread < -DBL_MANT_DIG) {
-		feraiseexcept(FE_INEXACT);
-		if (!isnormal(z))
-			feraiseexcept(FE_UNDERFLOW);
-		switch (oround) {
-		case FE_TONEAREST:
-			return (z);
-		case FE_TOWARDZERO:
-			if (x > 0.0 ^ y < 0.0 ^ z < 0.0)
-				return (z);
-			else
-				return (nextafter(z, 0));
-		case FE_DOWNWARD:
-			if (x > 0.0 ^ y < 0.0)
-				return (z);
-			else
-				return (nextafter(z, -INFINITY));
-		default:	/* FE_UPWARD */
-			if (x > 0.0 ^ y < 0.0)
-				return (nextafter(z, INFINITY));
-			else
-				return (z);
-		}
-	}
-
-	/*
-	 * Use Dekker's algorithm to perform the multiplication and
-	 * subsequent addition in twice the machine precision.
-	 * Arrange so that x * y = c + cc, and x * y + z = r + rr.
-	 */
-	fesetround(FE_TONEAREST);
-
-	p = xs * split;
-	hx = xs - p;
-	hx += p;
-	tx = xs - hx;
-
-	p = ys * split;
-	hy = ys - p;
-	hy += p;
-	ty = ys - hy;
-
-	p = hx * hy;
-	q = hx * ty + tx * hy;
-	c = p + q;
-	cc = p - c + q + tx * ty;
-
-	zs = ldexp(zs, -spread);
-	r = c + zs;
-	s = r - c;
-	rr = (c - (r - s)) + (zs - s) + cc;
-
-	spread = ex + ey;
-	if (spread + ilogb(r) > -1023) {
-		fesetround(oround);
-		r = r + rr;
-	} else {
-		/*
-		 * The result is subnormal, so we round before scaling to
-		 * avoid double rounding.
-		 */
-		p = ldexp(copysign(0x1p-1022, r), -spread);
-		c = r + p;
-		s = c - r;
-		cc = (r - (c - s)) + (p - s) + rr;
-		fesetround(oround);
-		r = (c + cc) - p;
-	}
-	return (ldexp(r, spread));
-}
-#else	/* LDBL_MANT_DIG == 113 */
-/*
- * 113 bits of precision is more than twice the precision of a double,
- * so it is enough to represent the intermediate product exactly.
- */
-double
-fma(double x, double y, double z)
-{
-	return ((long double)x * y + z);
-}
-#endif	/* LDBL_MANT_DIG != 113 */
-
-#if (LDBL_MANT_DIG == 53)
-__weak_reference(fma, fmal);
-#endif
diff --git a/libm/src/s_fmaf.c b/libm/src/s_fmaf.c
deleted file mode 100644
index 31aaaa9..0000000
--- a/libm/src/s_fmaf.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_fmaf.c,v 1.1 2005/01/22 09:53:18 das Exp $"); */
-
-/*
- * Fused multiply-add: Compute x * y + z with a single rounding error.
- *
- * A double has more than twice as much precision than a float, so
- * direct double-precision arithmetic suffices.
- *
- * XXX We are relying on the compiler to convert from double to float
- *     using the current rounding mode and with the appropriate
- *     side-effects.  But on at least one platform (gcc 3.4.2/sparc64),
- *     this appears to be too much to ask for.  The precision
- *     reduction should be done manually.
- */
-float
-fmaf(float x, float y, float z)
-{
-
-	return ((double)x * y + z);
-}
diff --git a/libm/src/s_fmal.c b/libm/src/s_fmal.c
deleted file mode 100644
index f1736fa..0000000
--- a/libm/src/s_fmal.c
+++ /dev/null
@@ -1,182 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_fmal.c,v 1.2 2005/03/18 02:27:59 das Exp $"); */
-
-#include <fenv.h>
-#include <float.h>
-#include <math.h>
-
-/*
- * Fused multiply-add: Compute x * y + z with a single rounding error.
- *
- * We use scaling to avoid overflow/underflow, along with the
- * canonical precision-doubling technique adapted from:
- *
- *	Dekker, T.  A Floating-Point Technique for Extending the
- *	Available Precision.  Numer. Math. 18, 224-242 (1971).
- */
-long double
-fmal(long double x, long double y, long double z)
-{
-#if LDBL_MANT_DIG == 64
-	static const long double split = 0x1p32L + 1.0;
-#elif LDBL_MANT_DIG == 113
-	static const long double split = 0x1p57L + 1.0;
-#endif
-	long double xs, ys, zs;
-	long double c, cc, hx, hy, p, q, tx, ty;
-	long double r, rr, s;
-	int oround;
-	int ex, ey, ez;
-	int spread;
-
-	if (z == 0.0)
-		return (x * y);
-	if (x == 0.0 || y == 0.0)
-		return (x * y + z);
-
-	/* Results of frexp() are undefined for these cases. */
-	if (!isfinite(x) || !isfinite(y) || !isfinite(z))
-		return (x * y + z);
-
-	xs = frexpl(x, &ex);
-	ys = frexpl(y, &ey);
-	zs = frexpl(z, &ez);
-	oround = fegetround();
-	spread = ex + ey - ez;
-
-	/*
-	 * If x * y and z are many orders of magnitude apart, the scaling
-	 * will overflow, so we handle these cases specially.  Rounding
-	 * modes other than FE_TONEAREST are painful.
-	 */
-	if (spread > LDBL_MANT_DIG * 2) {
-		fenv_t env;
-		feraiseexcept(FE_INEXACT);
-		switch(oround) {
-		case FE_TONEAREST:
-			return (x * y);
-		case FE_TOWARDZERO:
-			if (x > 0.0 ^ y < 0.0 ^ z < 0.0)
-				return (x * y);
-			feholdexcept(&env);
-			r = x * y;
-			if (!fetestexcept(FE_INEXACT))
-				r = nextafterl(r, 0);
-			feupdateenv(&env);
-			return (r);
-		case FE_DOWNWARD:
-			if (z > 0.0)
-				return (x * y);
-			feholdexcept(&env);
-			r = x * y;
-			if (!fetestexcept(FE_INEXACT))
-				r = nextafterl(r, -INFINITY);
-			feupdateenv(&env);
-			return (r);
-		default:	/* FE_UPWARD */
-			if (z < 0.0)
-				return (x * y);
-			feholdexcept(&env);
-			r = x * y;
-			if (!fetestexcept(FE_INEXACT))
-				r = nextafterl(r, INFINITY);
-			feupdateenv(&env);
-			return (r);
-		}
-	}
-	if (spread < -LDBL_MANT_DIG) {
-		feraiseexcept(FE_INEXACT);
-		if (!isnormal(z))
-			feraiseexcept(FE_UNDERFLOW);
-		switch (oround) {
-		case FE_TONEAREST:
-			return (z);
-		case FE_TOWARDZERO:
-			if (x > 0.0 ^ y < 0.0 ^ z < 0.0)
-				return (z);
-			else
-				return (nextafterl(z, 0));
-		case FE_DOWNWARD:
-			if (x > 0.0 ^ y < 0.0)
-				return (z);
-			else
-				return (nextafterl(z, -INFINITY));
-		default:	/* FE_UPWARD */
-			if (x > 0.0 ^ y < 0.0)
-				return (nextafterl(z, INFINITY));
-			else
-				return (z);
-		}
-	}
-
-	/*
-	 * Use Dekker's algorithm to perform the multiplication and
-	 * subsequent addition in twice the machine precision.
-	 * Arrange so that x * y = c + cc, and x * y + z = r + rr.
-	 */
-	fesetround(FE_TONEAREST);
-
-	p = xs * split;
-	hx = xs - p;
-	hx += p;
-	tx = xs - hx;
-
-	p = ys * split;
-	hy = ys - p;
-	hy += p;
-	ty = ys - hy;
-
-	p = hx * hy;
-	q = hx * ty + tx * hy;
-	c = p + q;
-	cc = p - c + q + tx * ty;
-
-	zs = ldexpl(zs, -spread);
-	r = c + zs;
-	s = r - c;
-	rr = (c - (r - s)) + (zs - s) + cc;
-
-	spread = ex + ey;
-	if (spread + ilogbl(r) > -16383) {
-		fesetround(oround);
-		r = r + rr;
-	} else {
-		/*
-		 * The result is subnormal, so we round before scaling to
-		 * avoid double rounding.
-		 */
-		p = ldexpl(copysignl(0x1p-16382L, r), -spread);
-		c = r + p;
-		s = c - r;
-		cc = (r - (c - s)) + (p - s) + rr;
-		fesetround(oround);
-		r = (c + cc) - p;
-	}
-	return (ldexpl(r, spread));
-}
diff --git a/libm/src/s_fmax.c b/libm/src/s_fmax.c
deleted file mode 100644
index 3345f67..0000000
--- a/libm/src/s_fmax.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_fmax.c,v 1.1 2004/06/30 07:04:01 das Exp $"); */
-
-#include <math.h>
-
-#include "fpmath.h"
-
-double
-fmax(double x, double y)
-{
-	union IEEEd2bits u[2];
-
-	u[0].d = x;
-	u[1].d = y;
-
-	/* Check for NaNs to avoid raising spurious exceptions. */
-	if (u[0].bits.exp == 2047 && (u[0].bits.manh | u[0].bits.manl) != 0)
-		return (y);
-	if (u[1].bits.exp == 2047 && (u[1].bits.manh | u[1].bits.manl) != 0)
-		return (x);
-
-	/* Handle comparisons of signed zeroes. */
-	if (u[0].bits.sign != u[1].bits.sign)
-		return (u[u[0].bits.sign].d);
-
-	return (x > y ? x : y);
-}
diff --git a/libm/src/s_fmaxf.c b/libm/src/s_fmaxf.c
deleted file mode 100644
index b67f654..0000000
--- a/libm/src/s_fmaxf.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_fmaxf.c,v 1.1 2004/06/30 07:04:01 das Exp $"); */
-
-#include <math.h>
-
-#include "fpmath.h"
-
-float
-fmaxf(float x, float y)
-{
-	union IEEEf2bits u[2];
-
-	u[0].f = x;
-	u[1].f = y;
-
-	/* Check for NaNs to avoid raising spurious exceptions. */
-	if (u[0].bits.exp == 255 && u[0].bits.man != 0)
-		return (y);
-	if (u[1].bits.exp == 255 && u[1].bits.man != 0)
-		return (x);
-
-	/* Handle comparisons of signed zeroes. */
-	if (u[0].bits.sign != u[1].bits.sign)
-		return (u[u[0].bits.sign].f);
-
-	return (x > y ? x : y);
-}
diff --git a/libm/src/s_fmaxl.c b/libm/src/s_fmaxl.c
deleted file mode 100644
index c1a9dbe..0000000
--- a/libm/src/s_fmaxl.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_fmaxl.c,v 1.1 2004/06/30 07:04:01 das Exp $"); */
-
-#include <math.h>
-
-#include "fpmath.h"
-
-long double
-fmaxl(long double x, long double y)
-{
-	union IEEEl2bits u[2];
-
-	u[0].e = x;
-	mask_nbit_l(u[0]);
-	u[1].e = y;
-	mask_nbit_l(u[1]);
-
-	/* Check for NaNs to avoid raising spurious exceptions. */
-	if (u[0].bits.exp == 32767 && (u[0].bits.manh | u[0].bits.manl) != 0)
-		return (y);
-	if (u[1].bits.exp == 32767 && (u[1].bits.manh | u[1].bits.manl) != 0)
-		return (x);
-
-	/* Handle comparisons of signed zeroes. */
-	if (u[0].bits.sign != u[1].bits.sign)
-		return (u[0].bits.sign ? y : x);
-
-	return (x > y ? x : y);
-}
diff --git a/libm/src/s_fmin.c b/libm/src/s_fmin.c
deleted file mode 100644
index 49b9cc4..0000000
--- a/libm/src/s_fmin.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_fmin.c,v 1.1 2004/06/30 07:04:01 das Exp $"); */
-
-#include <math.h>
-
-#include "fpmath.h"
-
-double
-fmin(double x, double y)
-{
-	union IEEEd2bits u[2];
-
-	u[0].d = x;
-	u[1].d = y;
-
-	/* Check for NaNs to avoid raising spurious exceptions. */
-	if (u[0].bits.exp == 2047 && (u[0].bits.manh | u[0].bits.manl) != 0)
-		return (y);
-	if (u[1].bits.exp == 2047 && (u[1].bits.manh | u[1].bits.manl) != 0)
-		return (x);
-
-	/* Handle comparisons of signed zeroes. */
-	if (u[0].bits.sign != u[1].bits.sign)
-		return (u[u[1].bits.sign].d);
-
-	return (x < y ? x : y);
-}
diff --git a/libm/src/s_fminf.c b/libm/src/s_fminf.c
deleted file mode 100644
index a6fb575..0000000
--- a/libm/src/s_fminf.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_fminf.c,v 1.1 2004/06/30 07:04:01 das Exp $"); */
-
-#include <math.h>
-
-#include "fpmath.h"
-
-float
-fminf(float x, float y)
-{
-	union IEEEf2bits u[2];
-
-	u[0].f = x;
-	u[1].f = y;
-
-	/* Check for NaNs to avoid raising spurious exceptions. */
-	if (u[0].bits.exp == 255 && u[0].bits.man != 0)
-		return (y);
-	if (u[1].bits.exp == 255 && u[1].bits.man != 0)
-		return (x);
-
-	/* Handle comparisons of signed zeroes. */
-	if (u[0].bits.sign != u[1].bits.sign)
-		return (u[u[1].bits.sign].f);
-
-	return (x < y ? x : y);
-}
diff --git a/libm/src/s_fminl.c b/libm/src/s_fminl.c
deleted file mode 100644
index 5f8c50e..0000000
--- a/libm/src/s_fminl.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_fminl.c,v 1.1 2004/06/30 07:04:01 das Exp $"); */
-
-#include <math.h>
-
-#include "fpmath.h"
-
-long double
-fminl(long double x, long double y)
-{
-	union IEEEl2bits u[2];
-
-	u[0].e = x;
-	mask_nbit_l(u[0]);
-	u[1].e = y;
-	mask_nbit_l(u[1]);
-
-	/* Check for NaNs to avoid raising spurious exceptions. */
-	if (u[0].bits.exp == 32767 && (u[0].bits.manh | u[0].bits.manl) != 0)
-		return (y);
-	if (u[1].bits.exp == 32767 && (u[1].bits.manh | u[1].bits.manl) != 0)
-		return (x);
-
-	/* Handle comparisons of signed zeroes. */
-	if (u[0].bits.sign != u[1].bits.sign)
-		return (u[1].bits.sign ? y : x);
-
-	return (x < y ? x : y);
-}
diff --git a/libm/src/s_frexp.c b/libm/src/s_frexp.c
deleted file mode 100644
index d89e135..0000000
--- a/libm/src/s_frexp.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* @(#)s_frexp.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_frexp.c,v 1.10 2005/03/07 21:27:37 das Exp $";
-#endif
-
-/*
- * for non-zero x
- *	x = frexp(arg,&exp);
- * return a double fp quantity x such that 0.5 <= |x| <1.0
- * and the corresponding binary exponent "exp". That is
- *	arg = x*2^exp.
- * If arg is inf, 0.0, or NaN, then frexp(arg,&exp) returns arg
- * with *exp=0.
- */
-
-#include <sys/cdefs.h>
-#include <float.h>
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-two54 =  1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */
-
-double
-frexp(double x, int *eptr)
-{
-	int32_t hx, ix, lx;
-	EXTRACT_WORDS(hx,lx,x);
-	ix = 0x7fffffff&hx;
-	*eptr = 0;
-	if(ix>=0x7ff00000||((ix|lx)==0)) return x;	/* 0,inf,nan */
-	if (ix<0x00100000) {		/* subnormal */
-	    x *= two54;
-	    GET_HIGH_WORD(hx,x);
-	    ix = hx&0x7fffffff;
-	    *eptr = -54;
-	}
-	*eptr += (ix>>20)-1022;
-	hx = (hx&0x800fffff)|0x3fe00000;
-	SET_HIGH_WORD(x,hx);
-	return x;
-}
-
-#if (LDBL_MANT_DIG == 53)
-__weak_reference(frexp, frexpl);
-#endif
diff --git a/libm/src/s_frexpf.c b/libm/src/s_frexpf.c
deleted file mode 100644
index c18cd54..0000000
--- a/libm/src/s_frexpf.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* s_frexpf.c -- float version of s_frexp.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_frexpf.c,v 1.8 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float
-two25 =  3.3554432000e+07; /* 0x4c000000 */
-
-float
-frexpf(float x, int *eptr)
-{
-	int32_t hx,ix;
-	GET_FLOAT_WORD(hx,x);
-	ix = 0x7fffffff&hx;
-	*eptr = 0;
-	if(ix>=0x7f800000||(ix==0)) return x;	/* 0,inf,nan */
-	if (ix<0x00800000) {		/* subnormal */
-	    x *= two25;
-	    GET_FLOAT_WORD(hx,x);
-	    ix = hx&0x7fffffff;
-	    *eptr = -25;
-	}
-	*eptr += (ix>>23)-126;
-	hx = (hx&0x807fffff)|0x3f000000;
-	SET_FLOAT_WORD(x,hx);
-	return x;
-}
diff --git a/libm/src/s_frexpl.c b/libm/src/s_frexpl.c
deleted file mode 100644
index 20b3167..0000000
--- a/libm/src/s_frexpl.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/src/s_frexpl.c,v 1.1 2005/03/07 04:54:51 das Exp $
- */
-
-#include <float.h>
-#include <math.h>
-
-#include "fpmath.h"
-
-#if LDBL_MAX_EXP != 0x4000
-#error "Unsupported long double format"
-#endif
-
-long double
-frexpl(long double x, int *ex)
-{
-	union IEEEl2bits u;
-
-	u.e = x;
-	switch (u.bits.exp) {
-	case 0:		/* 0 or subnormal */
-		if ((u.bits.manl | u.bits.manh) == 0) {
-			*ex = 0;
-		} else {
-			u.e *= 0x1.0p514;
-			*ex = u.bits.exp - 0x4200;
-			u.bits.exp = 0x3ffe;
-		}
-		break;
-	case 0x7fff:	/* infinity or NaN; value of *ex is unspecified */
-		break;
-	default:	/* normal */
-		*ex = u.bits.exp - 0x3ffe;
-		u.bits.exp = 0x3ffe;
-		break;
-	}
-	return (u.e);
-}
diff --git a/libm/src/s_ilogb.c b/libm/src/s_ilogb.c
deleted file mode 100644
index bd4a44b..0000000
--- a/libm/src/s_ilogb.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* @(#)s_ilogb.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_ilogb.c,v 1.9 2004/10/09 17:14:28 stefanf Exp $";
-#endif
-
-/* ilogb(double x)
- * return the binary exponent of non-zero x
- * ilogb(0) = FP_ILOGB0
- * ilogb(NaN) = FP_ILOGBNAN (no signal is raised)
- * ilogb(inf) = INT_MAX (no signal is raised)
- */
-
-#include <limits.h>
-
-#include "math.h"
-#include "math_private.h"
-
-	int ilogb(double x)
-{
-	int32_t hx,lx,ix;
-
-	EXTRACT_WORDS(hx,lx,x);
-	hx &= 0x7fffffff;
-	if(hx<0x00100000) {
-	    if((hx|lx)==0)
-		return FP_ILOGB0;
-	    else			/* subnormal x */
-		if(hx==0) {
-		    for (ix = -1043; lx>0; lx<<=1) ix -=1;
-		} else {
-		    for (ix = -1022,hx<<=11; hx>0; hx<<=1) ix -=1;
-		}
-	    return ix;
-	}
-	else if (hx<0x7ff00000) return (hx>>20)-1023;
-	else if (hx>0x7ff00000 || lx!=0) return FP_ILOGBNAN;
-	else return INT_MAX;
-}
diff --git a/libm/src/s_ilogbf.c b/libm/src/s_ilogbf.c
deleted file mode 100644
index 3c9c4de..0000000
--- a/libm/src/s_ilogbf.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* s_ilogbf.c -- float version of s_ilogb.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_ilogbf.c,v 1.7 2004/10/09 17:14:28 stefanf Exp $";
-#endif
-
-#include <limits.h>
-
-#include "math.h"
-#include "math_private.h"
-
-	int ilogbf(float x)
-{
-	int32_t hx,ix;
-
-	GET_FLOAT_WORD(hx,x);
-	hx &= 0x7fffffff;
-	if(hx<0x00800000) {
-	    if(hx==0)
-		return FP_ILOGB0;
-	    else			/* subnormal x */
-	        for (ix = -126,hx<<=8; hx>0; hx<<=1) ix -=1;
-	    return ix;
-	}
-	else if (hx<0x7f800000) return (hx>>23)-127;
-	else if (hx>0x7f800000) return FP_ILOGBNAN;
-	else return INT_MAX;
-}
diff --git a/libm/src/s_ilogbl.c b/libm/src/s_ilogbl.c
deleted file mode 100644
index 406ad56..0000000
--- a/libm/src/s_ilogbl.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * From: @(#)s_ilogb.c 5.1 93/09/24
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_ilogbl.c,v 1.1 2004/10/11 18:13:52 stefanf Exp $";
-#endif
-
-#include <float.h>
-#include <limits.h>
-#include <math.h>
-
-#include "fpmath.h"
-
-int
-ilogbl(long double x)
-{
-	union IEEEl2bits u;
-	unsigned long m;
-	int b;
-
-	u.e = x;
-	if (u.bits.exp == 0) {
-		if ((u.bits.manl | u.bits.manh) == 0)
-			return (FP_ILOGB0);
-		/* denormalized */
-		if (u.bits.manh == 0) {
-			m = 1lu << (LDBL_MANL_SIZE - 1);
-			for (b = LDBL_MANH_SIZE; !(u.bits.manl & m); m >>= 1)
-				b++;
-		} else {
-			m = 1lu << (LDBL_MANH_SIZE - 1);
-			for (b = 0; !(u.bits.manh & m); m >>= 1)
-				b++;
-		}
-#ifdef LDBL_IMPLICIT_NBIT
-		b++;
-#endif
-		return (LDBL_MIN_EXP - b - 1);
-	} else if (u.bits.exp < (LDBL_MAX_EXP << 1) - 1)
-		return (u.bits.exp - LDBL_MAX_EXP + 1);
-	else if (u.bits.manl != 0 || u.bits.manh != 0)
-		return (FP_ILOGBNAN);
-	else
-		return (INT_MAX);
-}
diff --git a/libm/src/s_isfinite.c b/libm/src/s_isfinite.c
deleted file mode 100644
index 394505d..0000000
--- a/libm/src/s_isfinite.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/src/s_isfinite.c,v 1.1 2004/07/09 03:32:39 das Exp $
- */
-
-#include <math.h>
-
-#include "fpmath.h"
-
-int
-__isfinite(double d)
-{
-	union IEEEd2bits u;
-
-	u.d = d;
-	return (u.bits.exp != 2047);
-}
-
-int
-__isfinitef(float f)
-{
-	union IEEEf2bits u;
-
-	u.f = f;
-	return (u.bits.exp != 255);
-}
-
-int
-__isfinitel(long double e)
-{
-	union IEEEl2bits u;
-
-	u.e = e;
-	return (u.bits.exp != 32767);
-}
diff --git a/libm/src/s_isnan.c b/libm/src/s_isnan.c
deleted file mode 100644
index f76352d..0000000
--- a/libm/src/s_isnan.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/src/s_isnan.c,v 1.8 2004/08/05 01:46:11 das Exp $
- */
-
-#include <math.h>
-
-#include "fpmath.h"
-
-/* Provided by libc */
-#if 1
-int
-(isnan)(double d)
-{
-	union IEEEd2bits u;
-
-	u.d = d;
-	return (u.bits.exp == 2047 && (u.bits.manl != 0 || u.bits.manh != 0));
-}
-#endif
-
-int
-isnanf(float f)
-{
-	union IEEEf2bits u;
-
-	u.f = f;
-	return (u.bits.exp == 255 && u.bits.man != 0);
-}
-
-int
-__isnanl(long double e)
-{
-	union IEEEl2bits u;
-
-	u.e = e;
-	mask_nbit_l(u);
-	return (u.bits.exp == 32767 && (u.bits.manl != 0 || u.bits.manh != 0));
-}
diff --git a/libm/src/s_isnormal.c b/libm/src/s_isnormal.c
deleted file mode 100644
index 1345dba..0000000
--- a/libm/src/s_isnormal.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/src/s_isnormal.c,v 1.1 2004/07/09 03:32:39 das Exp $
- */
-
-#include <math.h>
-
-#include "fpmath.h"
-
-int
-__isnormal(double d)
-{
-	union IEEEd2bits u;
-
-	u.d = d;
-	return (u.bits.exp != 0 && u.bits.exp != 2047);
-}
-
-int
-__isnormalf(float f)
-{
-	union IEEEf2bits u;
-
-	u.f = f;
-	return (u.bits.exp != 0 && u.bits.exp != 255);
-}
-
-int
-__isnormall(long double e)
-{
-	union IEEEl2bits u;
-
-	u.e = e;
-	return (u.bits.exp != 0 && u.bits.exp != 32767);
-}
diff --git a/libm/src/s_llrint.c b/libm/src/s_llrint.c
deleted file mode 100644
index 8a67f3a..0000000
--- a/libm/src/s_llrint.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_llrint.c,v 1.1 2005/01/11 23:12:55 das Exp $"); */
-
-#define type		double
-#define	roundit		rint
-#define dtype		long long
-#define	fn		llrint
-
-#include "s_lrint.c"
diff --git a/libm/src/s_llrintf.c b/libm/src/s_llrintf.c
deleted file mode 100644
index 4d75e38..0000000
--- a/libm/src/s_llrintf.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_llrintf.c,v 1.1 2005/01/11 23:12:55 das Exp $"); */
-
-#define type		float
-#define	roundit		rintf
-#define dtype		long long
-#define	fn		llrintf
-
-#include "s_lrint.c"
diff --git a/libm/src/s_llround.c b/libm/src/s_llround.c
deleted file mode 100644
index 28ab13e..0000000
--- a/libm/src/s_llround.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_llround.c,v 1.2 2005/04/08 00:52:27 das Exp $"); */
-
-#define type		double
-#define	roundit		round
-#define dtype		long long
-#define	DTYPE_MIN	LONGLONG_MIN
-#define	DTYPE_MAX	LONGLONG_MAX
-#define	fn		llround
-
-#include "s_lround.c"
diff --git a/libm/src/s_llroundf.c b/libm/src/s_llroundf.c
deleted file mode 100644
index 3dd6905..0000000
--- a/libm/src/s_llroundf.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_llroundf.c,v 1.2 2005/04/08 00:52:27 das Exp $"); */
-
-#define type		float
-#define	roundit		roundf
-#define dtype		long long
-#define	DTYPE_MIN	LONGLONG_MIN
-#define	DTYPE_MAX	LONGLONG_MAX
-#define	fn		llroundf
-
-#include "s_lround.c"
diff --git a/libm/src/s_llroundl.c b/libm/src/s_llroundl.c
deleted file mode 100644
index 89bae54..0000000
--- a/libm/src/s_llroundl.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_llroundl.c,v 1.1 2005/04/08 01:24:08 das Exp $"); */
-
-#define type		long double
-#define	roundit		roundl
-#define dtype		long long
-#define	DTYPE_MIN	LONGLONG_MIN
-#define	DTYPE_MAX	LONGLONG_MAX
-#define	fn		llroundl
-
-#include "s_lround.c"
diff --git a/libm/src/s_log1p.c b/libm/src/s_log1p.c
deleted file mode 100644
index 56e1516..0000000
--- a/libm/src/s_log1p.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/* @(#)s_log1p.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_log1p.c,v 1.8 2005/12/04 12:28:33 bde Exp $";
-#endif
-
-/* double log1p(double x)
- *
- * Method :
- *   1. Argument Reduction: find k and f such that
- *			1+x = 2^k * (1+f),
- *	   where  sqrt(2)/2 < 1+f < sqrt(2) .
- *
- *      Note. If k=0, then f=x is exact. However, if k!=0, then f
- *	may not be representable exactly. In that case, a correction
- *	term is need. Let u=1+x rounded. Let c = (1+x)-u, then
- *	log(1+x) - log(u) ~ c/u. Thus, we proceed to compute log(u),
- *	and add back the correction term c/u.
- *	(Note: when x > 2**53, one can simply return log(x))
- *
- *   2. Approximation of log1p(f).
- *	Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
- *		 = 2s + 2/3 s**3 + 2/5 s**5 + .....,
- *	     	 = 2s + s*R
- *      We use a special Reme algorithm on [0,0.1716] to generate
- * 	a polynomial of degree 14 to approximate R The maximum error
- *	of this polynomial approximation is bounded by 2**-58.45. In
- *	other words,
- *		        2      4      6      8      10      12      14
- *	    R(z) ~ Lp1*s +Lp2*s +Lp3*s +Lp4*s +Lp5*s  +Lp6*s  +Lp7*s
- *  	(the values of Lp1 to Lp7 are listed in the program)
- *	and
- *	    |      2          14          |     -58.45
- *	    | Lp1*s +...+Lp7*s    -  R(z) | <= 2
- *	    |                             |
- *	Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
- *	In order to guarantee error in log below 1ulp, we compute log
- *	by
- *		log1p(f) = f - (hfsq - s*(hfsq+R)).
- *
- *	3. Finally, log1p(x) = k*ln2 + log1p(f).
- *		 	     = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo)))
- *	   Here ln2 is split into two floating point number:
- *			ln2_hi + ln2_lo,
- *	   where n*ln2_hi is always exact for |n| < 2000.
- *
- * Special cases:
- *	log1p(x) is NaN with signal if x < -1 (including -INF) ;
- *	log1p(+INF) is +INF; log1p(-1) is -INF with signal;
- *	log1p(NaN) is that NaN with no signal.
- *
- * Accuracy:
- *	according to an error analysis, the error is always less than
- *	1 ulp (unit in the last place).
- *
- * Constants:
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
- * to produce the hexadecimal values shown.
- *
- * Note: Assuming log() return accurate answer, the following
- * 	 algorithm can be used to compute log1p(x) to within a few ULP:
- *
- *		u = 1+x;
- *		if(u==1.0) return x ; else
- *			   return log(u)*(x/(u-1.0));
- *
- *	 See HP-15C Advanced Functions Handbook, p.193.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-ln2_hi  =  6.93147180369123816490e-01,	/* 3fe62e42 fee00000 */
-ln2_lo  =  1.90821492927058770002e-10,	/* 3dea39ef 35793c76 */
-two54   =  1.80143985094819840000e+16,  /* 43500000 00000000 */
-Lp1 = 6.666666666666735130e-01,  /* 3FE55555 55555593 */
-Lp2 = 3.999999999940941908e-01,  /* 3FD99999 9997FA04 */
-Lp3 = 2.857142874366239149e-01,  /* 3FD24924 94229359 */
-Lp4 = 2.222219843214978396e-01,  /* 3FCC71C5 1D8E78AF */
-Lp5 = 1.818357216161805012e-01,  /* 3FC74664 96CB03DE */
-Lp6 = 1.531383769920937332e-01,  /* 3FC39A09 D078C69F */
-Lp7 = 1.479819860511658591e-01;  /* 3FC2F112 DF3E5244 */
-
-static const double zero = 0.0;
-
-double
-log1p(double x)
-{
-	double hfsq,f,c,s,z,R,u;
-	int32_t k,hx,hu,ax;
-
-	GET_HIGH_WORD(hx,x);
-	ax = hx&0x7fffffff;
-
-	k = 1;
-	if (hx < 0x3FDA827A) {			/* 1+x < sqrt(2)+ */
-	    if(ax>=0x3ff00000) {		/* x <= -1.0 */
-		if(x==-1.0) return -two54/zero; /* log1p(-1)=+inf */
-		else return (x-x)/(x-x);	/* log1p(x<-1)=NaN */
-	    }
-	    if(ax<0x3e200000) {			/* |x| < 2**-29 */
-		if(two54+x>zero			/* raise inexact */
-	            &&ax<0x3c900000) 		/* |x| < 2**-54 */
-		    return x;
-		else
-		    return x - x*x*0.5;
-	    }
-	    if(hx>0||hx<=((int32_t)0xbfd2bec4)) {
-		k=0;f=x;hu=1;}		/* sqrt(2)/2- <= 1+x < sqrt(2)+ */
-	}
-	if (hx >= 0x7ff00000) return x+x;
-	if(k!=0) {
-	    if(hx<0x43400000) {
-		u  = 1.0+x;
-		GET_HIGH_WORD(hu,u);
-	        k  = (hu>>20)-1023;
-	        c  = (k>0)? 1.0-(u-x):x-(u-1.0);/* correction term */
-		c /= u;
-	    } else {
-		u  = x;
-		GET_HIGH_WORD(hu,u);
-	        k  = (hu>>20)-1023;
-		c  = 0;
-	    }
-	    hu &= 0x000fffff;
-	    /*
-	     * The approximation to sqrt(2) used in thresholds is not
-	     * critical.  However, the ones used above must give less
-	     * strict bounds than the one here so that the k==0 case is
-	     * never reached from here, since here we have committed to
-	     * using the correction term but don't use it if k==0.
-	     */
-	    if(hu<0x6a09e) {			/* u ~< sqrt(2) */
-	        SET_HIGH_WORD(u,hu|0x3ff00000);	/* normalize u */
-	    } else {
-	        k += 1;
-		SET_HIGH_WORD(u,hu|0x3fe00000);	/* normalize u/2 */
-	        hu = (0x00100000-hu)>>2;
-	    }
-	    f = u-1.0;
-	}
-	hfsq=0.5*f*f;
-	if(hu==0) {	/* |f| < 2**-20 */
-	    if(f==zero) if(k==0) return zero;
-			else {c += k*ln2_lo; return k*ln2_hi+c;}
-	    R = hfsq*(1.0-0.66666666666666666*f);
-	    if(k==0) return f-R; else
-	    	     return k*ln2_hi-((R-(k*ln2_lo+c))-f);
-	}
- 	s = f/(2.0+f);
-	z = s*s;
-	R = z*(Lp1+z*(Lp2+z*(Lp3+z*(Lp4+z*(Lp5+z*(Lp6+z*Lp7))))));
-	if(k==0) return f-(hfsq-s*(hfsq+R)); else
-		 return k*ln2_hi-((hfsq-(s*(hfsq+R)+(k*ln2_lo+c)))-f);
-}
diff --git a/libm/src/s_log1pf.c b/libm/src/s_log1pf.c
deleted file mode 100644
index 8364da0..0000000
--- a/libm/src/s_log1pf.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/* s_log1pf.c -- float version of s_log1p.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_log1pf.c,v 1.9 2005/12/04 12:30:44 bde Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float
-ln2_hi =   6.9313812256e-01,	/* 0x3f317180 */
-ln2_lo =   9.0580006145e-06,	/* 0x3717f7d1 */
-two25 =    3.355443200e+07,	/* 0x4c000000 */
-Lp1 = 6.6666668653e-01,	/* 3F2AAAAB */
-Lp2 = 4.0000000596e-01,	/* 3ECCCCCD */
-Lp3 = 2.8571429849e-01, /* 3E924925 */
-Lp4 = 2.2222198546e-01, /* 3E638E29 */
-Lp5 = 1.8183572590e-01, /* 3E3A3325 */
-Lp6 = 1.5313838422e-01, /* 3E1CD04F */
-Lp7 = 1.4798198640e-01; /* 3E178897 */
-
-static const float zero = 0.0;
-
-float
-log1pf(float x)
-{
-	float hfsq,f,c,s,z,R,u;
-	int32_t k,hx,hu,ax;
-
-	GET_FLOAT_WORD(hx,x);
-	ax = hx&0x7fffffff;
-
-	k = 1;
-	if (hx < 0x3ed413d0) {			/* 1+x < sqrt(2)+  */
-	    if(ax>=0x3f800000) {		/* x <= -1.0 */
-		if(x==(float)-1.0) return -two25/zero; /* log1p(-1)=+inf */
-		else return (x-x)/(x-x);	/* log1p(x<-1)=NaN */
-	    }
-	    if(ax<0x31000000) {			/* |x| < 2**-29 */
-		if(two25+x>zero			/* raise inexact */
-	            &&ax<0x24800000) 		/* |x| < 2**-54 */
-		    return x;
-		else
-		    return x - x*x*(float)0.5;
-	    }
-	    if(hx>0||hx<=((int32_t)0xbe95f619)) {
-		k=0;f=x;hu=1;}		/* sqrt(2)/2- <= 1+x < sqrt(2)+ */
-	}
-	if (hx >= 0x7f800000) return x+x;
-	if(k!=0) {
-	    if(hx<0x5a000000) {
-		*(volatile float *)&u = (float)1.0+x;
-		GET_FLOAT_WORD(hu,u);
-	        k  = (hu>>23)-127;
-		/* correction term */
-	        c  = (k>0)? (float)1.0-(u-x):x-(u-(float)1.0);
-		c /= u;
-	    } else {
-		u  = x;
-		GET_FLOAT_WORD(hu,u);
-	        k  = (hu>>23)-127;
-		c  = 0;
-	    }
-	    hu &= 0x007fffff;
-	    /*
-	     * The approximation to sqrt(2) used in thresholds is not
-	     * critical.  However, the ones used above must give less
-	     * strict bounds than the one here so that the k==0 case is
-	     * never reached from here, since here we have committed to
-	     * using the correction term but don't use it if k==0.
-	     */
-	    if(hu<0x3504f4) {			/* u < sqrt(2) */
-	        SET_FLOAT_WORD(u,hu|0x3f800000);/* normalize u */
-	    } else {
-	        k += 1;
-		SET_FLOAT_WORD(u,hu|0x3f000000);	/* normalize u/2 */
-	        hu = (0x00800000-hu)>>2;
-	    }
-	    f = u-(float)1.0;
-	}
-	hfsq=(float)0.5*f*f;
-	if(hu==0) {	/* |f| < 2**-20 */
-	    if(f==zero) if(k==0) return zero;
-			else {c += k*ln2_lo; return k*ln2_hi+c;}
-	    R = hfsq*((float)1.0-(float)0.66666666666666666*f);
-	    if(k==0) return f-R; else
-	    	     return k*ln2_hi-((R-(k*ln2_lo+c))-f);
-	}
- 	s = f/((float)2.0+f);
-	z = s*s;
-	R = z*(Lp1+z*(Lp2+z*(Lp3+z*(Lp4+z*(Lp5+z*(Lp6+z*Lp7))))));
-	if(k==0) return f-(hfsq-s*(hfsq+R)); else
-		 return k*ln2_hi-((hfsq-(s*(hfsq+R)+(k*ln2_lo+c)))-f);
-}
diff --git a/libm/src/s_logb.c b/libm/src/s_logb.c
deleted file mode 100644
index 57f91c4..0000000
--- a/libm/src/s_logb.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* @(#)s_logb.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_logb.c,v 1.10 2005/12/03 11:57:19 bde Exp $";
-#endif
-
-/*
- * double logb(x)
- * IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
- * Use ilogb instead.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-two54 = 1.80143985094819840000e+16;	/* 43500000 00000000 */
-
-double
-logb(double x)
-{
-	int32_t lx,ix;
-	EXTRACT_WORDS(ix,lx,x);
-	ix &= 0x7fffffff;			/* high |x| */
-	if((ix|lx)==0) return -1.0/fabs(x);
-	if(ix>=0x7ff00000) return x*x;
-	if(ix<0x00100000) {
-		x *= two54;		 /* convert subnormal x to normal */
-		GET_HIGH_WORD(ix,x);
-		ix &= 0x7fffffff;
-		return (double) ((ix>>20)-1023-54);
-	} else
-		return (double) ((ix>>20)-1023);
-}
diff --git a/libm/src/s_logbf.c b/libm/src/s_logbf.c
deleted file mode 100644
index c54928c..0000000
--- a/libm/src/s_logbf.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* s_logbf.c -- float version of s_logb.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_logbf.c,v 1.8 2005/12/03 11:57:19 bde Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float
-two25 = 3.355443200e+07;		/* 0x4c000000 */
-
-float
-logbf(float x)
-{
-	int32_t ix;
-	GET_FLOAT_WORD(ix,x);
-	ix &= 0x7fffffff;			/* high |x| */
-	if(ix==0) return (float)-1.0/fabsf(x);
-	if(ix>=0x7f800000) return x*x;
-	if(ix<0x00800000) {
-		x *= two25;		 /* convert subnormal x to normal */
-		GET_FLOAT_WORD(ix,x);
-		ix &= 0x7fffffff;
-		return (float) ((ix>>23)-127-25);
-	} else
-		return (float) ((ix>>23)-127);
-}
diff --git a/libm/src/s_lrint.c b/libm/src/s_lrint.c
deleted file mode 100644
index 74a09d3..0000000
--- a/libm/src/s_lrint.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#include <fenv.h>
-#include <math.h>
-
-#ifndef type
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_lrint.c,v 1.1 2005/01/11 23:12:55 das Exp $"); */
-#define type		double
-#define	roundit		rint
-#define dtype		long
-#define	fn		lrint
-#endif
-
-/*
- * C99 says we should not raise a spurious inexact exception when an
- * invalid exception is raised.  Unfortunately, the set of inputs
- * that overflows depends on the rounding mode when 'dtype' has more
- * significant bits than 'type'.  Hence, we bend over backwards for the
- * sake of correctness; an MD implementation could be more efficient.
- */
-dtype
-fn(type x)
-{
-	fenv_t env;
-	dtype d;
-
-	feholdexcept(&env);
-	d = (dtype)roundit(x);
-	if (fetestexcept(FE_INVALID))
-		feclearexcept(FE_INEXACT);
-	feupdateenv(&env);
-	return (d);
-}
diff --git a/libm/src/s_lrintf.c b/libm/src/s_lrintf.c
deleted file mode 100644
index f258e03..0000000
--- a/libm/src/s_lrintf.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_lrintf.c,v 1.1 2005/01/11 23:12:55 das Exp $"); */
-
-#define type		float
-#define	roundit		rintf
-#define dtype		long
-#define	fn		lrintf
-
-#include "s_lrint.c"
diff --git a/libm/src/s_lround.c b/libm/src/s_lround.c
deleted file mode 100644
index e99f46f..0000000
--- a/libm/src/s_lround.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#include <limits.h>
-#include <fenv.h>
-#include <math.h>
-
-#ifndef type
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_lround.c,v 1.2 2005/04/08 00:52:16 das Exp $"); */
-#define type		double
-#define	roundit		round
-#define dtype		long
-#define	DTYPE_MIN	LONG_MIN
-#define	DTYPE_MAX	LONG_MAX
-#define	fn		lround
-#endif
-
-/*
- * If type has more precision than dtype, the endpoints dtype_(min|max) are
- * of the form xxx.5; they are "out of range" because lround() rounds away
- * from 0.  On the other hand, if type has less precision than dtype, then
- * all values that are out of range are integral, so we might as well assume
- * that everything is in range.  At compile time, INRANGE(x) should reduce to
- * two floating-point comparisons in the former case, or TRUE otherwise.
- */
-static const type dtype_min = DTYPE_MIN - 0.5;
-static const type dtype_max = DTYPE_MAX + 0.5;
-#define	INRANGE(x)	(dtype_max - DTYPE_MAX != 0.5 || \
-			 ((x) > dtype_min && (x) < dtype_max))
-
-dtype
-fn(type x)
-{
-
-	if (INRANGE(x)) {
-		x = roundit(x);
-		return ((dtype)x);
-	} else {
-		feraiseexcept(FE_INVALID);
-		return (DTYPE_MAX);
-	}
-}
diff --git a/libm/src/s_lroundf.c b/libm/src/s_lroundf.c
deleted file mode 100644
index e069c9c..0000000
--- a/libm/src/s_lroundf.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_lroundf.c,v 1.2 2005/04/08 00:52:27 das Exp $"); */
-
-#define type		float
-#define	roundit		roundf
-#define dtype		long
-#define	DTYPE_MIN	LONG_MIN
-#define	DTYPE_MAX	LONG_MAX
-#define	fn		lroundf
-
-#include "s_lround.c"
diff --git a/libm/src/s_lroundl.c b/libm/src/s_lroundl.c
deleted file mode 100644
index 7c3f854..0000000
--- a/libm/src/s_lroundl.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_lroundl.c,v 1.1 2005/04/08 01:24:08 das Exp $"); */
-
-#define type		long double
-#define	roundit		roundl
-#define dtype		long
-#define	DTYPE_MIN	LONG_MIN
-#define	DTYPE_MAX	LONG_MAX
-#define	fn		lroundl
-
-#include "s_lround.c"
diff --git a/libm/src/s_modf.c b/libm/src/s_modf.c
deleted file mode 100644
index 683fbda..0000000
--- a/libm/src/s_modf.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/* @(#)s_modf.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_modf.c,v 1.7 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-/*
- * modf(double x, double *iptr)
- * return fraction part of x, and return x's integral part in *iptr.
- * Method:
- *	Bit twiddling.
- *
- * Exception:
- *	No exception.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double one = 1.0;
-
-double
-modf(double x, double *iptr)
-{
-	int32_t i0,i1,j0;
-	u_int32_t i;
-	EXTRACT_WORDS(i0,i1,x);
-	j0 = ((i0>>20)&0x7ff)-0x3ff;	/* exponent of x */
-	if(j0<20) {			/* integer part in high x */
-	    if(j0<0) {			/* |x|<1 */
-	        INSERT_WORDS(*iptr,i0&0x80000000,0);	/* *iptr = +-0 */
-		return x;
-	    } else {
-		i = (0x000fffff)>>j0;
-		if(((i0&i)|i1)==0) {		/* x is integral */
-		    u_int32_t high;
-		    *iptr = x;
-		    GET_HIGH_WORD(high,x);
-		    INSERT_WORDS(x,high&0x80000000,0);	/* return +-0 */
-		    return x;
-		} else {
-		    INSERT_WORDS(*iptr,i0&(~i),0);
-		    return x - *iptr;
-		}
-	    }
-	} else if (j0>51) {		/* no fraction part */
-	    u_int32_t high;
-	    *iptr = x*one;
-	    GET_HIGH_WORD(high,x);
-	    INSERT_WORDS(x,high&0x80000000,0);	/* return +-0 */
-	    return x;
-	} else {			/* fraction part in low x */
-	    i = ((u_int32_t)(0xffffffff))>>(j0-20);
-	    if((i1&i)==0) { 		/* x is integral */
-	        u_int32_t high;
-		*iptr = x;
-		GET_HIGH_WORD(high,x);
-		INSERT_WORDS(x,high&0x80000000,0);	/* return +-0 */
-		return x;
-	    } else {
-	        INSERT_WORDS(*iptr,i0,i1&(~i));
-		return x - *iptr;
-	    }
-	}
-}
diff --git a/libm/src/s_modff.c b/libm/src/s_modff.c
deleted file mode 100644
index 6c75ffd..0000000
--- a/libm/src/s_modff.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* s_modff.c -- float version of s_modf.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_modff.c,v 1.7 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float one = 1.0;
-
-float
-modff(float x, float *iptr)
-{
-	int32_t i0,j0;
-	u_int32_t i;
-	GET_FLOAT_WORD(i0,x);
-	j0 = ((i0>>23)&0xff)-0x7f;	/* exponent of x */
-	if(j0<23) {			/* integer part in x */
-	    if(j0<0) {			/* |x|<1 */
-	        SET_FLOAT_WORD(*iptr,i0&0x80000000);	/* *iptr = +-0 */
-		return x;
-	    } else {
-		i = (0x007fffff)>>j0;
-		if((i0&i)==0) {			/* x is integral */
-		    u_int32_t ix;
-		    *iptr = x;
-		    GET_FLOAT_WORD(ix,x);
-		    SET_FLOAT_WORD(x,ix&0x80000000);	/* return +-0 */
-		    return x;
-		} else {
-		    SET_FLOAT_WORD(*iptr,i0&(~i));
-		    return x - *iptr;
-		}
-	    }
-	} else {			/* no fraction part */
-	    u_int32_t ix;
-	    *iptr = x*one;
-	    GET_FLOAT_WORD(ix,x);
-	    SET_FLOAT_WORD(x,ix&0x80000000);	/* return +-0 */
-	    return x;
-	}
-}
diff --git a/libm/src/s_nan.c b/libm/src/s_nan.c
deleted file mode 100644
index e366e6b..0000000
--- a/libm/src/s_nan.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/*-
- * Copyright (c) 2007 David Schultz
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/endian.h>
-#include <ctype.h>
-#include <float.h>
-#include <math.h>
-#include <stdint.h>
-#include <strings.h>
-
-#include "math_private.h"
-
-/* digittoint is in the FreeBSD C library, but not Bionic at this point */
-static int
-digittoint(char ch)
-{
-    int d;
-
-    d = ch - '0';
-    if ((unsigned)d < 10) {
-        return d;
-    }
-    d = ch - 'a';
-    if ((unsigned)d < 6) {
-        return d + 10;
-    }
-    d = ch - 'A';
-    if ((unsigned)d < 6) {
-        return d + 10;
-    }
-    return -1;
-}
-
-/*
- * Scan a string of hexadecimal digits (the format nan(3) expects) and
- * make a bit array (using the local endianness). We stop when we
- * encounter an invalid character, NUL, etc.  If we overflow, we do
- * the same as gcc's __builtin_nan(), namely, discard the high order bits.
- *
- * The format this routine accepts needs to be compatible with what is used
- * in contrib/gdtoa/hexnan.c (for strtod/scanf) and what is used in
- * __builtin_nan(). In fact, we're only 100% compatible for strings we
- * consider valid, so we might be violating the C standard. But it's
- * impossible to use nan(3) portably anyway, so this seems good enough.
- */
-void
-_scan_nan(uint32_t *words, int num_words, const char *s)
-{
-	int si;		/* index into s */
-	int bitpos;	/* index into words (in bits) */
-
-	bzero(words, num_words * sizeof(uint32_t));
-
-	/* Allow a leading '0x'. (It's expected, but redundant.) */
-	if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X'))
-		s += 2;
-
-	/* Scan forwards in the string, looking for the end of the sequence. */
-	for (si = 0; isxdigit(s[si]); si++)
-		;
-
-	/* Scan backwards, filling in the bits in words[] as we go. */
-#if _BYTE_ORDER == _LITTLE_ENDIAN
-	for (bitpos = 0; bitpos < 32 * num_words; bitpos += 4) {
-#else
-	for (bitpos = 32 * num_words - 4; bitpos >= 0; bitpos -= 4) {
-#endif
-		if (--si < 0)
-			break;
-		words[bitpos / 32] |= digittoint(s[si]) << (bitpos % 32);
-	}
-}
-
-double
-nan(const char *s)
-{
-	union {
-		double d;
-		uint32_t bits[2];
-	} u;
-
-	_scan_nan(u.bits, 2, s);
-#if _BYTE_ORDER == _LITTLE_ENDIAN
-	u.bits[1] |= 0x7ff80000;
-#else
-	u.bits[0] |= 0x7ff80000;
-#endif
-	return (u.d);
-}
-
-float
-nanf(const char *s)
-{
-	union {
-		float f;
-		uint32_t bits[1];
-	} u;
-
-	_scan_nan(u.bits, 1, s);
-	u.bits[0] |= 0x7fc00000;
-	return (u.f);
-}
-
-#if (LDBL_MANT_DIG == 53)
-__weak_alias(nanl, nan);
-#endif
diff --git a/libm/src/s_nearbyint.c b/libm/src/s_nearbyint.c
deleted file mode 100644
index 246d325..0000000
--- a/libm/src/s_nearbyint.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_nearbyint.c,v 1.1 2004/07/06 04:46:08 das Exp $"); */
-
-#include <fenv.h>
-#include <math.h>
-
-/*
- * We save and restore the floating-point environment to avoid raising
- * an inexact exception.  We can get away with using fesetenv()
- * instead of feclearexcept()/feupdateenv() to restore the environment
- * because the only exception defined for rint() is overflow, and
- * rounding can't overflow as long as emax >= p.
- */
-#define	DECL(type, fn, rint)	\
-type				\
-fn(type x)			\
-{				\
-	type ret;		\
-	fenv_t env;		\
-				\
-	fegetenv(&env);		\
-	ret = rint(x);		\
-	fesetenv(&env);		\
-	return (ret);		\
-}
-
-DECL(double, nearbyint, rint)
-DECL(float, nearbyintf, rintf)
diff --git a/libm/src/s_nextafter.c b/libm/src/s_nextafter.c
deleted file mode 100644
index 3ed0361..0000000
--- a/libm/src/s_nextafter.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/* @(#)s_nextafter.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_nextafter.c,v 1.11 2005/03/07 21:27:37 das Exp $";
-#endif
-
-/* IEEE functions
- *	nextafter(x,y)
- *	return the next machine floating-point number of x in the
- *	direction toward y.
- *   Special cases:
- */
-
-#include <sys/cdefs.h>
-#include <float.h>
-
-#include "math.h"
-#include "math_private.h"
-
-double
-nextafter(double x, double y)
-{
-	volatile double t;
-	int32_t hx,hy,ix,iy;
-	u_int32_t lx,ly;
-
-	EXTRACT_WORDS(hx,lx,x);
-	EXTRACT_WORDS(hy,ly,y);
-	ix = hx&0x7fffffff;		/* |x| */
-	iy = hy&0x7fffffff;		/* |y| */
-
-	if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) ||   /* x is nan */
-	   ((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0))     /* y is nan */
-	   return x+y;
-	if(x==y) return y;		/* x=y, return y */
-	if((ix|lx)==0) {			/* x == 0 */
-	    INSERT_WORDS(x,hy&0x80000000,1);	/* return +-minsubnormal */
-	    t = x*x;
-	    if(t==x) return t; else return x;	/* raise underflow flag */
-	}
-	if(hx>=0) {				/* x > 0 */
-	    if(hx>hy||((hx==hy)&&(lx>ly))) {	/* x > y, x -= ulp */
-		if(lx==0) hx -= 1;
-		lx -= 1;
-	    } else {				/* x < y, x += ulp */
-		lx += 1;
-		if(lx==0) hx += 1;
-	    }
-	} else {				/* x < 0 */
-	    if(hy>=0||hx>hy||((hx==hy)&&(lx>ly))){/* x < y, x -= ulp */
-		if(lx==0) hx -= 1;
-		lx -= 1;
-	    } else {				/* x > y, x += ulp */
-		lx += 1;
-		if(lx==0) hx += 1;
-	    }
-	}
-	hy = hx&0x7ff00000;
-	if(hy>=0x7ff00000) return x+x;	/* overflow  */
-	if(hy<0x00100000) {		/* underflow */
-	    t = x*x;
-	    if(t!=x) {		/* raise underflow flag */
-	        INSERT_WORDS(y,hx,lx);
-		return y;
-	    }
-	}
-	INSERT_WORDS(x,hx,lx);
-	return x;
-}
-
-#if (LDBL_MANT_DIG == 53)
-__weak_reference(nextafter, nexttoward);
-__weak_reference(nextafter, nexttowardl);
-__weak_reference(nextafter, nextafterl);
-#endif
diff --git a/libm/src/s_nextafterf.c b/libm/src/s_nextafterf.c
deleted file mode 100644
index ebeac4a..0000000
--- a/libm/src/s_nextafterf.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/* s_nextafterf.c -- float version of s_nextafter.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_nextafterf.c,v 1.10 2005/03/07 04:55:58 das Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-float
-nextafterf(float x, float y)
-{
-	volatile float t;
-	int32_t hx,hy,ix,iy;
-
-	GET_FLOAT_WORD(hx,x);
-	GET_FLOAT_WORD(hy,y);
-	ix = hx&0x7fffffff;		/* |x| */
-	iy = hy&0x7fffffff;		/* |y| */
-
-	if((ix>0x7f800000) ||   /* x is nan */
-	   (iy>0x7f800000))     /* y is nan */
-	   return x+y;
-	if(x==y) return y;		/* x=y, return y */
-	if(ix==0) {				/* x == 0 */
-	    SET_FLOAT_WORD(x,(hy&0x80000000)|1);/* return +-minsubnormal */
-	    t = x*x;
-	    if(t==x) return t; else return x;	/* raise underflow flag */
-	}
-	if(hx>=0) {				/* x > 0 */
-	    if(hx>hy) {				/* x > y, x -= ulp */
-		hx -= 1;
-	    } else {				/* x < y, x += ulp */
-		hx += 1;
-	    }
-	} else {				/* x < 0 */
-	    if(hy>=0||hx>hy){			/* x < y, x -= ulp */
-		hx -= 1;
-	    } else {				/* x > y, x += ulp */
-		hx += 1;
-	    }
-	}
-	hy = hx&0x7f800000;
-	if(hy>=0x7f800000) return x+x;	/* overflow  */
-	if(hy<0x00800000) {		/* underflow */
-	    t = x*x;
-	    if(t!=x) {		/* raise underflow flag */
-	        SET_FLOAT_WORD(y,hx);
-		return y;
-	    }
-	}
-	SET_FLOAT_WORD(x,hx);
-	return x;
-}
diff --git a/libm/src/s_nextafterl.c b/libm/src/s_nextafterl.c
deleted file mode 100644
index eacfd33..0000000
--- a/libm/src/s_nextafterl.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* @(#)s_nextafter.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_nextafterl.c,v 1.1 2005/03/07 04:56:46 das Exp $";
-#endif
-
-/* IEEE functions
- *	nextafter(x,y)
- *	return the next machine floating-point number of x in the
- *	direction toward y.
- *   Special cases:
- */
-
-#include <sys/cdefs.h>
-#include <float.h>
-
-#include "fpmath.h"
-#include "math.h"
-#include "math_private.h"
-
-#if LDBL_MAX_EXP != 0x4000
-#error "Unsupported long double format"
-#endif
-
-long double
-nextafterl(long double x, long double y)
-{
-	volatile long double t;
-	union IEEEl2bits ux, uy;
-
-	ux.e = x;
-	uy.e = y;
-
-	if ((ux.bits.exp == 0x7fff &&
-	     ((ux.bits.manh&~LDBL_NBIT)|ux.bits.manl) != 0) ||
-	    (uy.bits.exp == 0x7fff &&
-	     ((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl) != 0))
-	   return x+y;	/* x or y is nan */
-	if(x==y) return y;		/* x=y, return y */
-	if(x==0.0) {
-	    ux.bits.manh = 0;			/* return +-minsubnormal */
-	    ux.bits.manl = 1;
-	    ux.bits.sign = uy.bits.sign;
-	    t = ux.e*ux.e;
-	    if(t==ux.e) return t; else return ux.e; /* raise underflow flag */
-	}
-	if(x>0.0 ^ x<y) {			/* x -= ulp */
-	    if(ux.bits.manl==0) {
-		if ((ux.bits.manh&~LDBL_NBIT)==0)
-		    ux.bits.exp -= 1;
-		ux.bits.manh = (ux.bits.manh - 1) | (ux.bits.manh & LDBL_NBIT);
-	    }
-	    ux.bits.manl -= 1;
-	} else {				/* x += ulp */
-	    ux.bits.manl += 1;
-	    if(ux.bits.manl==0) {
-		ux.bits.manh = (ux.bits.manh + 1) | (ux.bits.manh & LDBL_NBIT);
-		if ((ux.bits.manh&~LDBL_NBIT)==0)
-		    ux.bits.exp += 1;
-	    }
-	}
-	if(ux.bits.exp==0x7fff) return x+x;	/* overflow  */
-	if(ux.bits.exp==0) {			/* underflow */
-	    mask_nbit_l(ux);
-	    t = ux.e * ux.e;
-	    if(t!=ux.e)			/* raise underflow flag */
-		return ux.e;
-	}
-	return ux.e;
-}
-
-__strong_reference(nextafterl, nexttowardl);
diff --git a/libm/src/s_nexttoward.c b/libm/src/s_nexttoward.c
deleted file mode 100644
index 55da4ad..0000000
--- a/libm/src/s_nexttoward.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* @(#)s_nextafter.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_nexttoward.c,v 1.1 2005/03/07 04:56:46 das Exp $";
-#endif
-
-/*
- * We assume that a long double has a 15-bit exponent.  On systems
- * where long double is the same as double, nexttoward() is an alias
- * for nextafter(), so we don't use this routine.
- */
-
-#include <float.h>
-
-#include "fpmath.h"
-#include "math.h"
-#include "math_private.h"
-
-#if LDBL_MAX_EXP != 0x4000
-#error "Unsupported long double format"
-#endif
-
-double
-nexttoward(double x, long double y)
-{
-	union IEEEl2bits uy;
-	volatile double t;
-	int32_t hx,ix;
-	u_int32_t lx;
-
-	EXTRACT_WORDS(hx,lx,x);
-	ix = hx&0x7fffffff;		/* |x| */
-	uy.e = y;
-
-	if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) ||
-	    (uy.bits.exp == 0x7fff &&
-	     ((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl) != 0))
-	   return x+y;	/* x or y is nan */
-	if(x==y) return (double)y;		/* x=y, return y */
-	if(x==0.0) {
-	    INSERT_WORDS(x,uy.bits.sign<<31,1);	/* return +-minsubnormal */
-	    t = x*x;
-	    if(t==x) return t; else return x;	/* raise underflow flag */
-	}
-	if(hx>0.0 ^ x < y) {			/* x -= ulp */
-	    if(lx==0) hx -= 1;
-	    lx -= 1;
-	} else {				/* x += ulp */
-	    lx += 1;
-	    if(lx==0) hx += 1;
-	}
-	ix = hx&0x7ff00000;
-	if(ix>=0x7ff00000) return x+x;	/* overflow  */
-	if(ix<0x00100000) {		/* underflow */
-	    t = x*x;
-	    if(t!=x) {		/* raise underflow flag */
-	        INSERT_WORDS(y,hx,lx);
-		return y;
-	    }
-	}
-	INSERT_WORDS(x,hx,lx);
-	return x;
-}
diff --git a/libm/src/s_nexttowardf.c b/libm/src/s_nexttowardf.c
deleted file mode 100644
index 54156e6..0000000
--- a/libm/src/s_nexttowardf.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_nexttowardf.c,v 1.1 2005/03/07 04:57:38 das Exp $";
-#endif
-
-#include <float.h>
-
-#include "fpmath.h"
-#include "math.h"
-#include "math_private.h"
-
-#define	LDBL_INFNAN_EXP	(LDBL_MAX_EXP * 2 - 1)
-
-float
-nexttowardf(float x, long double y)
-{
-	union IEEEl2bits uy;
-	volatile float t;
-	int32_t hx,ix;
-
-	GET_FLOAT_WORD(hx,x);
-	ix = hx&0x7fffffff;		/* |x| */
-	uy.e = y;
-
-	if((ix>0x7f800000) ||
-	   (uy.bits.exp == LDBL_INFNAN_EXP &&
-	    ((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl) != 0))
-	   return x+y;	/* x or y is nan */
-	if(x==y) return (float)y;		/* x=y, return y */
-	if(ix==0) {				/* x == 0 */
-	    SET_FLOAT_WORD(x,(uy.bits.sign<<31)|1);/* return +-minsubnormal */
-	    t = x*x;
-	    if(t==x) return t; else return x;	/* raise underflow flag */
-	}
-	if(hx>=0 ^ x < y)			/* x -= ulp */
-	    hx -= 1;
-	else					/* x += ulp */
-	    hx += 1;
-	ix = hx&0x7f800000;
-	if(ix>=0x7f800000) return x+x;	/* overflow  */
-	if(ix<0x00800000) {		/* underflow */
-	    t = x*x;
-	    if(t!=x) {		/* raise underflow flag */
-	        SET_FLOAT_WORD(y,hx);
-		return y;
-	    }
-	}
-	SET_FLOAT_WORD(x,hx);
-	return x;
-}
diff --git a/libm/src/s_remquo.c b/libm/src/s_remquo.c
deleted file mode 100644
index 9ad1e4c..0000000
--- a/libm/src/s_remquo.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/* @(#)e_fmod.c 1.3 95/01/18 */
-/*-
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_remquo.c,v 1.1 2005/03/25 04:40:44 das Exp $"); */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double Zero[] = {0.0, -0.0,};
-
-/*
- * Return the IEEE remainder and set *quo to the last n bits of the
- * quotient, rounded to the nearest integer.  We choose n=31 because
- * we wind up computing all the integer bits of the quotient anyway as
- * a side-effect of computing the remainder by the shift and subtract
- * method.  In practice, this is far more bits than are needed to use
- * remquo in reduction algorithms.
- */
-double
-remquo(double x, double y, int *quo)
-{
-	int32_t n,hx,hy,hz,ix,iy,sx,i;
-	u_int32_t lx,ly,lz,q,sxy;
-
-	EXTRACT_WORDS(hx,lx,x);
-	EXTRACT_WORDS(hy,ly,y);
-	sxy = (hx ^ hy) & 0x80000000;
-	sx = hx&0x80000000;		/* sign of x */
-	hx ^=sx;		/* |x| */
-	hy &= 0x7fffffff;	/* |y| */
-
-    /* purge off exception values */
-	if((hy|ly)==0||(hx>=0x7ff00000)||	/* y=0,or x not finite */
-	  ((hy|((ly|-ly)>>31))>0x7ff00000))	/* or y is NaN */
-	    return (x*y)/(x*y);
-	if(hx<=hy) {
-	    if((hx<hy)||(lx<ly)) {
-		q = 0;
-		goto fixup;	/* |x|<|y| return x or x-y */
-	    }
-	    if(lx==ly) {
-                *quo = (sxy ? -1 : 1);
-		return Zero[(u_int32_t)sx>>31];	/* |x|=|y| return x*0*/
-	    }
-	}
-
-    /* determine ix = ilogb(x) */
-	if(hx<0x00100000) {	/* subnormal x */
-	    if(hx==0) {
-		for (ix = -1043, i=lx; i>0; i<<=1) ix -=1;
-	    } else {
-		for (ix = -1022,i=(hx<<11); i>0; i<<=1) ix -=1;
-	    }
-	} else ix = (hx>>20)-1023;
-
-    /* determine iy = ilogb(y) */
-	if(hy<0x00100000) {	/* subnormal y */
-	    if(hy==0) {
-		for (iy = -1043, i=ly; i>0; i<<=1) iy -=1;
-	    } else {
-		for (iy = -1022,i=(hy<<11); i>0; i<<=1) iy -=1;
-	    }
-	} else iy = (hy>>20)-1023;
-
-    /* set up {hx,lx}, {hy,ly} and align y to x */
-	if(ix >= -1022) 
-	    hx = 0x00100000|(0x000fffff&hx);
-	else {		/* subnormal x, shift x to normal */
-	    n = -1022-ix;
-	    if(n<=31) {
-	        hx = (hx<<n)|(lx>>(32-n));
-	        lx <<= n;
-	    } else {
-		hx = lx<<(n-32);
-		lx = 0;
-	    }
-	}
-	if(iy >= -1022) 
-	    hy = 0x00100000|(0x000fffff&hy);
-	else {		/* subnormal y, shift y to normal */
-	    n = -1022-iy;
-	    if(n<=31) {
-	        hy = (hy<<n)|(ly>>(32-n));
-	        ly <<= n;
-	    } else {
-		hy = ly<<(n-32);
-		ly = 0;
-	    }
-	}
-
-    /* fix point fmod */
-	n = ix - iy;
-	q = 0;
-	while(n--) {
-	    hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
-	    if(hz<0){hx = hx+hx+(lx>>31); lx = lx+lx;}
-	    else {hx = hz+hz+(lz>>31); lx = lz+lz; q++;}
-	    q <<= 1;
-	}
-	hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
-	if(hz>=0) {hx=hz;lx=lz;q++;}
-
-    /* convert back to floating value and restore the sign */
-	if((hx|lx)==0) {			/* return sign(x)*0 */
-            q &= 0x7fffffff;
-            *quo = (sxy ? -q : q);
-	    return Zero[(u_int32_t)sx>>31];
-	}
-	while(hx<0x00100000) {		/* normalize x */
-	    hx = hx+hx+(lx>>31); lx = lx+lx;
-	    iy -= 1;
-	}
-	if(iy>= -1022) {	/* normalize output */
-	    hx = ((hx-0x00100000)|((iy+1023)<<20));
-	} else {		/* subnormal output */
-	    n = -1022 - iy;
-	    if(n<=20) {
-		lx = (lx>>n)|((u_int32_t)hx<<(32-n));
-		hx >>= n;
-	    } else if (n<=31) {
-                lx = (hx<<(32-n))|(lx>>n); hx = 0;
-	    } else {
-                lx = hx>>(n-32); hx = 0;
-	    }
-	}
-fixup:
-	INSERT_WORDS(x,hx,lx);
-	y = fabs(y);
-	if (y < 0x1p-1021) {
-	    if (x+x>y || (x+x==y && (q & 1))) {
-		q++;
-		x-=y;
-	    }
-	} else if (x>0.5*y || (x==0.5*y && (q & 1))) {
-	    q++;
-	    x-=y;
-	}
-	GET_HIGH_WORD(hx,x);
-	SET_HIGH_WORD(x,hx^sx);
-	q &= 0x7fffffff;
-	*quo = (sxy ? -q : q);
-	return x;
-}
diff --git a/libm/src/s_remquof.c b/libm/src/s_remquof.c
deleted file mode 100644
index 43e05cb..0000000
--- a/libm/src/s_remquof.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/* @(#)e_fmod.c 1.3 95/01/18 */
-/*-
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_remquof.c,v 1.1 2005/03/25 04:40:44 das Exp $"); */
-
-#include "math.h"
-#include "math_private.h"
-
-static const float Zero[] = {0.0, -0.0,};
-
-/*
- * Return the IEEE remainder and set *quo to the last n bits of the
- * quotient, rounded to the nearest integer.  We choose n=31 because
- * we wind up computing all the integer bits of the quotient anyway as
- * a side-effect of computing the remainder by the shift and subtract
- * method.  In practice, this is far more bits than are needed to use
- * remquo in reduction algorithms.
- */
-float
-remquof(float x, float y, int *quo)
-{
-	int32_t n,hx,hy,hz,ix,iy,sx,i;
-	u_int32_t q,sxy;
-
-	GET_FLOAT_WORD(hx,x);
-	GET_FLOAT_WORD(hy,y);
-	sxy = (hx ^ hy) & 0x80000000;
-	sx = hx&0x80000000;		/* sign of x */
-	hx ^=sx;		/* |x| */
-	hy &= 0x7fffffff;	/* |y| */
-
-    /* purge off exception values */
-	if(hy==0||hx>=0x7f800000||hy>0x7f800000) /* y=0,NaN;or x not finite */
-	    return (x*y)/(x*y);
-	if(hx<hy) {
-	    q = 0;
-	    goto fixup;	/* |x|<|y| return x or x-y */
-	} else if(hx==hy) {
-            *quo = (sxy ? -1 : 1);
-	    return Zero[(u_int32_t)sx>>31];	/* |x|=|y| return x*0*/
-	}
-
-    /* determine ix = ilogb(x) */
-	if(hx<0x00800000) {	/* subnormal x */
-	    for (ix = -126,i=(hx<<8); i>0; i<<=1) ix -=1;
-	} else ix = (hx>>23)-127;
-
-    /* determine iy = ilogb(y) */
-	if(hy<0x00800000) {	/* subnormal y */
-	    for (iy = -126,i=(hy<<8); i>0; i<<=1) iy -=1;
-	} else iy = (hy>>23)-127;
-
-    /* set up {hx,lx}, {hy,ly} and align y to x */
-	if(ix >= -126)
-	    hx = 0x00800000|(0x007fffff&hx);
-	else {		/* subnormal x, shift x to normal */
-	    n = -126-ix;
-	    hx <<= n;
-	}
-	if(iy >= -126)
-	    hy = 0x00800000|(0x007fffff&hy);
-	else {		/* subnormal y, shift y to normal */
-	    n = -126-iy;
-	    hy <<= n;
-	}
-
-    /* fix point fmod */
-	n = ix - iy;
-	q = 0;
-	while(n--) {
-	    hz=hx-hy;
-	    if(hz<0) hx = hx << 1;
-	    else {hx = hz << 1; q++;}
-	    q <<= 1;
-	}
-	hz=hx-hy;
-	if(hz>=0) {hx=hz;q++;}
-
-    /* convert back to floating value and restore the sign */
-	if(hx==0) {				/* return sign(x)*0 */
-            q &= 0x7fffffff;
-            *quo = (sxy ? -q : q);
-	    return Zero[(u_int32_t)sx>>31];
-	}
-	while(hx<0x00800000) {		/* normalize x */
-	    hx <<= 1;
-	    iy -= 1;
-	}
-	if(iy>= -126) {		/* normalize output */
-	    hx = ((hx-0x00800000)|((iy+127)<<23));
-	} else {		/* subnormal output */
-	    n = -126 - iy;
-	    hx >>= n;
-	}
-fixup:
-	SET_FLOAT_WORD(x,hx);
-	y = fabsf(y);
-	if (y < 0x1p-125f) {
-	    if (x+x>y || (x+x==y && (q & 1))) {
-		q++;
-		x-=y;
-	    }
-	} else if (x>0.5f*y || (x==0.5f*y && (q & 1))) {
-	    q++;
-	    x-=y;
-	}
-	GET_FLOAT_WORD(hx,x);
-	SET_FLOAT_WORD(x,hx^sx);
-	q &= 0x7fffffff;
-	*quo = (sxy ? -q : q);
-	return x;
-}
diff --git a/libm/src/s_rint.c b/libm/src/s_rint.c
deleted file mode 100644
index a88d7b7..0000000
--- a/libm/src/s_rint.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/* @(#)s_rint.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_rint.c,v 1.13 2005/12/03 07:38:35 bde Exp $";
-#endif
-
-/*
- * rint(x)
- * Return x rounded to integral value according to the prevailing
- * rounding mode.
- * Method:
- *	Using floating addition.
- * Exception:
- *	Inexact flag raised if x not equal to rint(x).
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-TWO52[2]={
-  4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
- -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */
-};
-
-double
-rint(double x)
-{
-	int32_t i0,j0,sx;
-	u_int32_t i,i1;
-	double w,t;
-	EXTRACT_WORDS(i0,i1,x);
-	sx = (i0>>31)&1;
-	j0 = ((i0>>20)&0x7ff)-0x3ff;
-	if(j0<20) {
-	    if(j0<0) {
-		if(((i0&0x7fffffff)|i1)==0) return x;
-		i1 |= (i0&0x0fffff);
-		i0 &= 0xfffe0000;
-		i0 |= ((i1|-i1)>>12)&0x80000;
-		SET_HIGH_WORD(x,i0);
-	        w = TWO52[sx]+x;
-	        t =  w-TWO52[sx];
-		GET_HIGH_WORD(i0,t);
-		SET_HIGH_WORD(t,(i0&0x7fffffff)|(sx<<31));
-	        return t;
-	    } else {
-		i = (0x000fffff)>>j0;
-		if(((i0&i)|i1)==0) return x; /* x is integral */
-		i>>=1;
-		if(((i0&i)|i1)!=0) {
-		    /*
-		     * Some bit is set after the 0.5 bit.  To avoid the
-		     * possibility of errors from double rounding in
-		     * w = TWO52[sx]+x, adjust the 0.25 bit to a lower
-		     * guard bit.  We do this for all j0<=51.  The
-		     * adjustment is trickiest for j0==18 and j0==19
-		     * since then it spans the word boundary.
-		     */
-		    if(j0==19) i1 = 0x40000000; else
-		    if(j0==18) i1 = 0x80000000; else
-		    i0 = (i0&(~i))|((0x20000)>>j0);
-		}
-	    }
-	} else if (j0>51) {
-	    if(j0==0x400) return x+x;	/* inf or NaN */
-	    else return x;		/* x is integral */
-	} else {
-	    i = ((u_int32_t)(0xffffffff))>>(j0-20);
-	    if((i1&i)==0) return x;	/* x is integral */
-	    i>>=1;
-	    if((i1&i)!=0) i1 = (i1&(~i))|((0x40000000)>>(j0-20));
-	}
-	INSERT_WORDS(x,i0,i1);
-	*(volatile double *)&w = TWO52[sx]+x;	/* clip any extra precision */
-	return w-TWO52[sx];
-}
diff --git a/libm/src/s_rintf.c b/libm/src/s_rintf.c
deleted file mode 100644
index 677421a..0000000
--- a/libm/src/s_rintf.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/* s_rintf.c -- float version of s_rint.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_rintf.c,v 1.10 2005/12/03 09:00:29 bde Exp $";
-#endif
-
-#include <sys/types.h>
-#include "math.h"
-#include "math_private.h"
-
-static const float
-TWO23[2]={
-  8.3886080000e+06, /* 0x4b000000 */
- -8.3886080000e+06, /* 0xcb000000 */
-};
-
-float
-rintf(float x)
-{
-	int32_t i0,j0,sx;
-	volatile float w,t;	/* volatile works around gcc bug */
-	GET_FLOAT_WORD(i0,x);
-	sx = (i0>>31)&1;
-	j0 = ((i0>>23)&0xff)-0x7f;
-	if(j0<23) {
-	    if(j0<0) {
-		if((i0&0x7fffffff)==0) return x;
-	        w = TWO23[sx]+x;
-	        t =  w-TWO23[sx];
-		GET_FLOAT_WORD(i0,t);
-		SET_FLOAT_WORD(t,(i0&0x7fffffff)|(sx<<31));
-	        return t;
-	    }
-	    w = TWO23[sx]+x;
-	    return w-TWO23[sx];
-	}
-	if(j0==0x80) return x+x;	/* inf or NaN */
-	else return x;			/* x is integral */
-}
diff --git a/libm/src/s_round.c b/libm/src/s_round.c
deleted file mode 100644
index 274c119..0000000
--- a/libm/src/s_round.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-
- * Copyright (c) 2003, Steven G. Kargl
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice unmodified, this list of conditions, and the following
- *    disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_round.c,v 1.4 2005/12/02 13:45:06 bde Exp $"); */
-
-#include <math.h>
-
-double
-round(double x)
-{
-	double t;
-
-	if (!isfinite(x))
-		return (x);
-
-	if (x >= 0.0) {
-		t = floor(x);
-		if (t - x <= -0.5)
-			t += 1.0;
-		return (t);
-	} else {
-		t = floor(-x);
-		if (t + x <= -0.5)
-			t += 1.0;
-		return (-t);
-	}
-}
diff --git a/libm/src/s_roundf.c b/libm/src/s_roundf.c
deleted file mode 100644
index 823be9b..0000000
--- a/libm/src/s_roundf.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-
- * Copyright (c) 2003, Steven G. Kargl
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice unmodified, this list of conditions, and the following
- *    disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_roundf.c,v 1.4 2005/12/02 13:45:06 bde Exp $"); */
-
-#include <math.h>
-
-float
-roundf(float x)
-{
-	float t;
-
-	if (!isfinite(x))
-		return (x);
-
-	if (x >= 0.0) {
-		t = floorf(x);
-		if (t - x <= -0.5)
-			t += 1.0;
-		return (t);
-	} else {
-		t = floorf(-x);
-		if (t + x <= -0.5)
-			t += 1.0;
-		return (-t);
-	}
-}
diff --git a/libm/src/s_roundl.c b/libm/src/s_roundl.c
deleted file mode 100644
index a65f330..0000000
--- a/libm/src/s_roundl.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-
- * Copyright (c) 2003, Steven G. Kargl
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice unmodified, this list of conditions, and the following
- *    disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_roundl.c,v 1.2 2005/12/02 13:45:06 bde Exp $"); */
-
-#include <math.h>
-
-long double
-roundl(long double x)
-{
-	long double t;
-
-	if (!isfinite(x))
-		return (x);
-
-	if (x >= 0.0) {
-		t = floorl(x);
-		if (t - x <= -0.5)
-			t += 1.0;
-		return (t);
-	} else {
-		t = floorl(-x);
-		if (t + x <= -0.5)
-			t += 1.0;
-		return (-t);
-	}
-}
diff --git a/libm/src/s_scalbln.c b/libm/src/s_scalbln.c
deleted file mode 100644
index 41908d2..0000000
--- a/libm/src/s_scalbln.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*-
- * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_scalbln.c,v 1.2 2005/03/07 04:57:50 das Exp $"); */
-
-#include <limits.h>
-#include <math.h>
-
-double
-scalbln (double x, long n)
-{
-	int in;
-
-	in = (int)n;
-	if (in != n) {
-		if (n > 0)
-			in = INT_MAX;
-		else
-			in = INT_MIN;
-	}
-	return (scalbn(x, in));
-}
-
-float
-scalblnf (float x, long n)
-{
-	int in;
-
-	in = (int)n;
-	if (in != n) {
-		if (n > 0)
-			in = INT_MAX;
-		else
-			in = INT_MIN;
-	}
-	return (scalbnf(x, in));
-}
-
-long double
-scalblnl (long double x, long n)
-{
-	int in;
-
-	in = (int)n;
-	if (in != n) {
-		if (n > 0)
-			in = INT_MAX;
-		else
-			in = INT_MIN;
-	}
-	return (scalbnl(x, (int)n));
-}
diff --git a/libm/src/s_scalbn.c b/libm/src/s_scalbn.c
deleted file mode 100644
index 6218c11..0000000
--- a/libm/src/s_scalbn.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/* @(#)s_scalbn.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_scalbn.c,v 1.11 2005/03/07 21:27:37 das Exp $";
-#endif
-
-/*
- * scalbn (double x, int n)
- * scalbn(x,n) returns x* 2**n  computed by  exponent
- * manipulation rather than by actually performing an
- * exponentiation or a multiplication.
- */
-
-#include <sys/cdefs.h>
-#include <float.h>
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-two54   =  1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
-twom54  =  5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */
-huge   = 1.0e+300,
-tiny   = 1.0e-300;
-
-double
-scalbn (double x, int n)
-{
-	int32_t k,hx,lx;
-	EXTRACT_WORDS(hx,lx,x);
-        k = (hx&0x7ff00000)>>20;		/* extract exponent */
-        if (k==0) {				/* 0 or subnormal x */
-            if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */
-	    x *= two54;
-	    GET_HIGH_WORD(hx,x);
-	    k = ((hx&0x7ff00000)>>20) - 54;
-            if (n< -50000) return tiny*x; 	/*underflow*/
-	    }
-        if (k==0x7ff) return x+x;		/* NaN or Inf */
-        k = k+n;
-        if (k >  0x7fe) return huge*copysign(huge,x); /* overflow  */
-        if (k > 0) 				/* normal result */
-	    {SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x;}
-        if (k <= -54)
-            if (n > 50000) 	/* in case integer overflow in n+k */
-		return huge*copysign(huge,x);	/*overflow*/
-	    else return tiny*copysign(tiny,x); 	/*underflow*/
-        k += 54;				/* subnormal result */
-	SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20));
-        return x*twom54;
-}
-
-// this is normally in FreeBSD's libc.
-double
-ldexp (double x, int n)
-{
-    return scalbn(x,n);
-}
-
-#if (LDBL_MANT_DIG == 53)    //XXX: brian FIXME __weak_reference doesn work
-long double ldexpl (long double x, int n) {
-    return scalbn((double)x,n);
-}
-long double scalbnl (long double x, int n) {
-    return scalbn((double)x,n);
-}
-__weak_reference(scalbn, ldexpl);
-__weak_reference(scalbn, scalbnl);
-#endif
diff --git a/libm/src/s_scalbnf.c b/libm/src/s_scalbnf.c
deleted file mode 100644
index 46c7baf..0000000
--- a/libm/src/s_scalbnf.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* s_scalbnf.c -- float version of s_scalbn.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_scalbnf.c,v 1.8 2005/03/07 04:52:43 das Exp $";
-#endif
-
-#include <sys/cdefs.h>
-
-#include "math.h"
-#include "math_private.h"
-
-static const float
-two25   =  3.355443200e+07,	/* 0x4c000000 */
-twom25  =  2.9802322388e-08,	/* 0x33000000 */
-huge   = 1.0e+30,
-tiny   = 1.0e-30;
-
-float
-scalbnf (float x, int n)
-{
-	int32_t k,ix;
-	GET_FLOAT_WORD(ix,x);
-        k = (ix&0x7f800000)>>23;		/* extract exponent */
-        if (k==0) {				/* 0 or subnormal x */
-            if ((ix&0x7fffffff)==0) return x; /* +-0 */
-	    x *= two25;
-	    GET_FLOAT_WORD(ix,x);
-	    k = ((ix&0x7f800000)>>23) - 25;
-            if (n< -50000) return tiny*x; 	/*underflow*/
-	    }
-        if (k==0xff) return x+x;		/* NaN or Inf */
-        k = k+n;
-        if (k >  0xfe) return huge*copysignf(huge,x); /* overflow  */
-        if (k > 0) 				/* normal result */
-	    {SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23)); return x;}
-        if (k <= -25)
-            if (n > 50000) 	/* in case integer overflow in n+k */
-		return huge*copysignf(huge,x);	/*overflow*/
-	    else return tiny*copysignf(tiny,x);	/*underflow*/
-        k += 25;				/* subnormal result */
-	SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23));
-        return x*twom25;
-}
-
-__strong_reference(scalbnf, ldexpf);
diff --git a/libm/src/s_scalbnl.c b/libm/src/s_scalbnl.c
deleted file mode 100644
index c645d00..0000000
--- a/libm/src/s_scalbnl.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/* @(#)s_scalbn.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_scalbnl.c,v 1.1 2005/03/07 04:52:58 das Exp $";
-#endif
-
-/*
- * scalbnl (long double x, int n)
- * scalbnl(x,n) returns x* 2**n  computed by  exponent
- * manipulation rather than by actually performing an
- * exponentiation or a multiplication.
- */
-
-/*
- * We assume that a long double has a 15-bit exponent.  On systems
- * where long double is the same as double, scalbnl() is an alias
- * for scalbn(), so we don't use this routine.
- */
-
-#include <sys/cdefs.h>
-#include <float.h>
-#include <math.h>
-
-#include "fpmath.h"
-
-#if LDBL_MAX_EXP != 0x4000
-#error "Unsupported long double format"
-#endif
-
-static const long double
-huge = 0x1p16000L,
-tiny = 0x1p-16000L;
-
-long double
-scalbnl (long double x, int n)
-{
-	union IEEEl2bits u;
-	int k;
-	u.e = x;
-        k = u.bits.exp;				/* extract exponent */
-        if (k==0) {				/* 0 or subnormal x */
-            if ((u.bits.manh|u.bits.manl)==0) return x;	/* +-0 */
-	    u.e *= 0x1p+128;
-	    k = u.bits.exp - 128;
-            if (n< -50000) return tiny*x; 	/*underflow*/
-	    }
-        if (k==0x7fff) return x+x;		/* NaN or Inf */
-        k = k+n;
-        if (k >= 0x7fff) return huge*copysignl(huge,x); /* overflow  */
-        if (k > 0) 				/* normal result */
-	    {u.bits.exp = k; return u.e;}
-        if (k <= -128)
-            if (n > 50000) 	/* in case integer overflow in n+k */
-		return huge*copysign(huge,x);	/*overflow*/
-	    else return tiny*copysign(tiny,x); 	/*underflow*/
-        k += 128;				/* subnormal result */
-	u.bits.exp = k;
-        return u.e*0x1p-128;
-}
-
-__strong_reference(scalbnl, ldexpl);
diff --git a/libm/src/s_signbit.c b/libm/src/s_signbit.c
deleted file mode 100644
index ffc08f3..0000000
--- a/libm/src/s_signbit.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/msun/src/s_signbit.c,v 1.1 2004/07/19 08:16:10 das Exp $
- */
-
-#include <math.h>
-
-#include "fpmath.h"
-
-int
-__signbit(double d)
-{
-	union IEEEd2bits u;
-
-	u.d = d;
-	return (u.bits.sign);
-}
-
-int
-__signbitf(float f)
-{
-	union IEEEf2bits u;
-
-	u.f = f;
-	return (u.bits.sign);
-}
-
-int
-__signbitl(long double e)
-{
-	union IEEEl2bits u;
-
-	u.e = e;
-	return (u.bits.sign);
-}
diff --git a/libm/src/s_significand.c b/libm/src/s_significand.c
deleted file mode 100644
index 08bb303..0000000
--- a/libm/src/s_significand.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/* @(#)s_signif.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_significand.c,v 1.9 2003/07/23 04:53:47 peter Exp $";
-#endif
-
-/*
- * significand(x) computes just
- * 	scalb(x, (double) -ilogb(x)),
- * for exercising the fraction-part(F) IEEE 754-1985 test vector.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-double
-significand(double x)
-{
-	return __ieee754_scalb(x,(double) -ilogb(x));
-}
diff --git a/libm/src/s_significandf.c b/libm/src/s_significandf.c
deleted file mode 100644
index b3e341d..0000000
--- a/libm/src/s_significandf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* s_significandf.c -- float version of s_significand.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_significandf.c,v 1.7 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-float
-significandf(float x)
-{
-	return __ieee754_scalbf(x,(float) -ilogbf(x));
-}
diff --git a/libm/src/s_sin.c b/libm/src/s_sin.c
deleted file mode 100644
index e893e23..0000000
--- a/libm/src/s_sin.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* @(#)s_sin.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_sin.c,v 1.10 2005/10/24 14:08:36 bde Exp $";
-#endif
-
-/* sin(x)
- * Return sine function of x.
- *
- * kernel function:
- *	__kernel_sin		... sine function on [-pi/4,pi/4]
- *	__kernel_cos		... cose function on [-pi/4,pi/4]
- *	__ieee754_rem_pio2	... argument reduction routine
- *
- * Method.
- *      Let S,C and T denote the sin, cos and tan respectively on
- *	[-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
- *	in [-pi/4 , +pi/4], and let n = k mod 4.
- *	We have
- *
- *          n        sin(x)      cos(x)        tan(x)
- *     ----------------------------------------------------------
- *	    0	       S	   C		 T
- *	    1	       C	  -S		-1/T
- *	    2	      -S	  -C		 T
- *	    3	      -C	   S		-1/T
- *     ----------------------------------------------------------
- *
- * Special cases:
- *      Let trig be any of sin, cos, or tan.
- *      trig(+-INF)  is NaN, with signals;
- *      trig(NaN)    is that NaN;
- *
- * Accuracy:
- *	TRIG(x) returns trig(x) nearly rounded
- */
-
-#include "math.h"
-#include "math_private.h"
-
-double
-sin(double x)
-{
-	double y[2],z=0.0;
-	int32_t n, ix;
-
-    /* High word of x. */
-	GET_HIGH_WORD(ix,x);
-
-    /* |x| ~< pi/4 */
-	ix &= 0x7fffffff;
-	if(ix <= 0x3fe921fb) {
-	    if(ix<0x3e400000)			/* |x| < 2**-27 */
-	       {if((int)x==0) return x;}	/* generate inexact */
-	    return __kernel_sin(x,z,0);
-	}
-
-    /* sin(Inf or NaN) is NaN */
-	else if (ix>=0x7ff00000) return x-x;
-
-    /* argument reduction needed */
-	else {
-	    n = __ieee754_rem_pio2(x,y);
-	    switch(n&3) {
-		case 0: return  __kernel_sin(y[0],y[1],1);
-		case 1: return  __kernel_cos(y[0],y[1]);
-		case 2: return -__kernel_sin(y[0],y[1],1);
-		default:
-			return -__kernel_cos(y[0],y[1]);
-	    }
-	}
-}
diff --git a/libm/src/s_sinf.c b/libm/src/s_sinf.c
deleted file mode 100644
index 9dc3cae..0000000
--- a/libm/src/s_sinf.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* s_sinf.c -- float version of s_sin.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Optimized by Bruce D. Evans.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_sinf.c,v 1.14 2005/11/28 06:15:10 bde Exp $";
-#endif
-
-#include "math.h"
-#define	INLINE_KERNEL_COSDF
-#define	INLINE_KERNEL_SINDF
-#include "math_private.h"
-#include "k_cosf.c"
-#include "k_sinf.c"
-
-/* Small multiples of pi/2 rounded to double precision. */
-static const double
-s1pio2 = 1*M_PI_2,			/* 0x3FF921FB, 0x54442D18 */
-s2pio2 = 2*M_PI_2,			/* 0x400921FB, 0x54442D18 */
-s3pio2 = 3*M_PI_2,			/* 0x4012D97C, 0x7F3321D2 */
-s4pio2 = 4*M_PI_2;			/* 0x401921FB, 0x54442D18 */
-
-float
-sinf(float x)
-{
-	float y[2];
-	int32_t n, hx, ix;
-
-	GET_FLOAT_WORD(hx,x);
-	ix = hx & 0x7fffffff;
-
-	if(ix <= 0x3f490fda) {		/* |x| ~<= pi/4 */
-	    if(ix<0x39800000)		/* |x| < 2**-12 */
-		if(((int)x)==0) return x;	/* x with inexact if x != 0 */
-	    return __kernel_sindf(x);
-	}
-	if(ix<=0x407b53d1) {		/* |x| ~<= 5*pi/4 */
-	    if(ix<=0x4016cbe3) {	/* |x| ~<= 3pi/4 */
-		if(hx>0)
-		    return __kernel_cosdf(x - s1pio2);
-		else
-		    return -__kernel_cosdf(x + s1pio2);
-	    } else
-		return __kernel_sindf((hx > 0 ? s2pio2 : -s2pio2) - x);
-	}
-	if(ix<=0x40e231d5) {		/* |x| ~<= 9*pi/4 */
-	    if(ix<=0x40afeddf) {	/* |x| ~<= 7*pi/4 */
-		if(hx>0)
-		    return -__kernel_cosdf(x - s3pio2);
-		else
-		    return __kernel_cosdf(x + s3pio2);
-	    } else
-		return __kernel_sindf(x + (hx > 0 ? -s4pio2 : s4pio2));
-	}
-
-    /* sin(Inf or NaN) is NaN */
-	else if (ix>=0x7f800000) return x-x;
-
-    /* general argument reduction needed */
-	else {
-	    n = __ieee754_rem_pio2f(x,y);
-	    switch(n&3) {
-		case 0: return  __kernel_sindf((double)y[0]+y[1]);
-		case 1: return  __kernel_cosdf((double)y[0]+y[1]);
-		case 2: return  __kernel_sindf(-(double)y[0]-y[1]);
-		default:
-			return -__kernel_cosdf((double)y[0]+y[1]);
-	    }
-	}
-}
diff --git a/libm/src/s_tan.c b/libm/src/s_tan.c
deleted file mode 100644
index 7f0b4a0..0000000
--- a/libm/src/s_tan.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/* @(#)s_tan.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_tan.c,v 1.10 2005/11/02 14:01:45 bde Exp $";
-#endif
-
-/* tan(x)
- * Return tangent function of x.
- *
- * kernel function:
- *	__kernel_tan		... tangent function on [-pi/4,pi/4]
- *	__ieee754_rem_pio2	... argument reduction routine
- *
- * Method.
- *      Let S,C and T denote the sin, cos and tan respectively on
- *	[-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
- *	in [-pi/4 , +pi/4], and let n = k mod 4.
- *	We have
- *
- *          n        sin(x)      cos(x)        tan(x)
- *     ----------------------------------------------------------
- *	    0	       S	   C		 T
- *	    1	       C	  -S		-1/T
- *	    2	      -S	  -C		 T
- *	    3	      -C	   S		-1/T
- *     ----------------------------------------------------------
- *
- * Special cases:
- *      Let trig be any of sin, cos, or tan.
- *      trig(+-INF)  is NaN, with signals;
- *      trig(NaN)    is that NaN;
- *
- * Accuracy:
- *	TRIG(x) returns trig(x) nearly rounded
- */
-
-#include "math.h"
-#include "math_private.h"
-
-double
-tan(double x)
-{
-	double y[2],z=0.0;
-	int32_t n, ix;
-
-    /* High word of x. */
-	GET_HIGH_WORD(ix,x);
-
-    /* |x| ~< pi/4 */
-	ix &= 0x7fffffff;
-	if(ix <= 0x3fe921fb) {
-	    if(ix<0x3e300000)			/* x < 2**-28 */
-		if((int)x==0) return x;		/* generate inexact */
-	    return __kernel_tan(x,z,1);
-	}
-
-    /* tan(Inf or NaN) is NaN */
-	else if (ix>=0x7ff00000) return x-x;		/* NaN */
-
-    /* argument reduction needed */
-	else {
-	    n = __ieee754_rem_pio2(x,y);
-	    return __kernel_tan(y[0],y[1],1-((n&1)<<1)); /*   1 -- n even
-							-1 -- n odd */
-	}
-}
diff --git a/libm/src/s_tanf.c b/libm/src/s_tanf.c
deleted file mode 100644
index 7e80d69..0000000
--- a/libm/src/s_tanf.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/* s_tanf.c -- float version of s_tan.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Optimized by Bruce D. Evans.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_tanf.c,v 1.14 2005/11/28 05:35:32 bde Exp $";
-#endif
-
-#include "math.h"
-#define	INLINE_KERNEL_TANDF
-#include "math_private.h"
-#include "k_tanf.c"
-
-/* Small multiples of pi/2 rounded to double precision. */
-static const double
-t1pio2 = 1*M_PI_2,			/* 0x3FF921FB, 0x54442D18 */
-t2pio2 = 2*M_PI_2,			/* 0x400921FB, 0x54442D18 */
-t3pio2 = 3*M_PI_2,			/* 0x4012D97C, 0x7F3321D2 */
-t4pio2 = 4*M_PI_2;			/* 0x401921FB, 0x54442D18 */
-
-float
-tanf(float x)
-{
-	float y[2];
-	int32_t n, hx, ix;
-
-	GET_FLOAT_WORD(hx,x);
-	ix = hx & 0x7fffffff;
-
-	if(ix <= 0x3f490fda) {		/* |x| ~<= pi/4 */
-	    if(ix<0x39800000)		/* |x| < 2**-12 */
-		if(((int)x)==0) return x;	/* x with inexact if x != 0 */
-	    return __kernel_tandf(x,1);
-	}
-	if(ix<=0x407b53d1) {		/* |x| ~<= 5*pi/4 */
-	    if(ix<=0x4016cbe3)		/* |x| ~<= 3pi/4 */
-		return __kernel_tandf(x + (hx>0 ? -t1pio2 : t1pio2), -1);
-	    else
-		return __kernel_tandf(x + (hx>0 ? -t2pio2 : t2pio2), 1);
-	}
-	if(ix<=0x40e231d5) {		/* |x| ~<= 9*pi/4 */
-	    if(ix<=0x40afeddf)		/* |x| ~<= 7*pi/4 */
-		return __kernel_tandf(x + (hx>0 ? -t3pio2 : t3pio2), -1);
-	    else
-		return __kernel_tandf(x + (hx>0 ? -t4pio2 : t4pio2), 1);
-	}
-
-    /* tan(Inf or NaN) is NaN */
-	else if (ix>=0x7f800000) return x-x;
-
-    /* general argument reduction needed */
-	else {
-	    n = __ieee754_rem_pio2f(x,y);
-	    /* integer parameter: 1 -- n even; -1 -- n odd */
-	    return __kernel_tandf((double)y[0]+y[1],1-((n&1)<<1));
-	}
-}
diff --git a/libm/src/s_tanh.c b/libm/src/s_tanh.c
deleted file mode 100644
index 4729145..0000000
--- a/libm/src/s_tanh.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/* @(#)s_tanh.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_tanh.c,v 1.7 2002/05/28 18:15:04 alfred Exp $";
-#endif
-
-/* Tanh(x)
- * Return the Hyperbolic Tangent of x
- *
- * Method :
- *				       x    -x
- *				      e  - e
- *	0. tanh(x) is defined to be -----------
- *				       x    -x
- *				      e  + e
- *	1. reduce x to non-negative by tanh(-x) = -tanh(x).
- *	2.  0      <= x <= 2**-55 : tanh(x) := x*(one+x)
- *					        -t
- *	    2**-55 <  x <=  1     : tanh(x) := -----; t = expm1(-2x)
- *					       t + 2
- *						     2
- *	    1      <= x <=  22.0  : tanh(x) := 1-  ----- ; t=expm1(2x)
- *						   t + 2
- *	    22.0   <  x <= INF    : tanh(x) := 1.
- *
- * Special cases:
- *	tanh(NaN) is NaN;
- *	only tanh(0)=0 is exact for finite argument.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double one=1.0, two=2.0, tiny = 1.0e-300;
-
-double
-tanh(double x)
-{
-	double t,z;
-	int32_t jx,ix;
-
-    /* High word of |x|. */
-	GET_HIGH_WORD(jx,x);
-	ix = jx&0x7fffffff;
-
-    /* x is INF or NaN */
-	if(ix>=0x7ff00000) {
-	    if (jx>=0) return one/x+one;    /* tanh(+-inf)=+-1 */
-	    else       return one/x-one;    /* tanh(NaN) = NaN */
-	}
-
-    /* |x| < 22 */
-	if (ix < 0x40360000) {		/* |x|<22 */
-	    if (ix<0x3c800000) 		/* |x|<2**-55 */
-		return x*(one+x);    	/* tanh(small) = small */
-	    if (ix>=0x3ff00000) {	/* |x|>=1  */
-		t = expm1(two*fabs(x));
-		z = one - two/(t+two);
-	    } else {
-	        t = expm1(-two*fabs(x));
-	        z= -t/(t+two);
-	    }
-    /* |x| > 22, return +-1 */
-	} else {
-	    z = one - tiny;		/* raised inexact flag */
-	}
-	return (jx>=0)? z: -z;
-}
diff --git a/libm/src/s_tanhf.c b/libm/src/s_tanhf.c
deleted file mode 100644
index 0aca6cc..0000000
--- a/libm/src/s_tanhf.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* s_tanhf.c -- float version of s_tanh.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_tanhf.c,v 1.8 2005/12/11 11:40:55 bde Exp $";
-#endif
-
-#include "math.h"
-#include "math_private.h"
-
-static const float one=1.0, two=2.0, tiny = 1.0e-30, huge = 1.0e30;
-float
-tanhf(float x)
-{
-	float t,z;
-	int32_t jx,ix;
-
-	GET_FLOAT_WORD(jx,x);
-	ix = jx&0x7fffffff;
-
-    /* x is INF or NaN */
-	if(ix>=0x7f800000) {
-	    if (jx>=0) return one/x+one;    /* tanh(+-inf)=+-1 */
-	    else       return one/x-one;    /* tanh(NaN) = NaN */
-	}
-
-    /* |x| < 9 */
-	if (ix < 0x41100000) {		/* |x|<9 */
-	    if (ix<0x39800000) {	/* |x|<2**-12 */
-		if(huge+x>one) return x; /* tanh(tiny) = tiny with inexact */
-	    }
-	    if (ix>=0x3f800000) {	/* |x|>=1  */
-		t = expm1f(two*fabsf(x));
-		z = one - two/(t+two);
-	    } else {
-	        t = expm1f(-two*fabsf(x));
-	        z= -t/(t+two);
-	    }
-    /* |x| >= 9, return +-1 */
-	} else {
-	    z = one - tiny;		/* raise inexact flag */
-	}
-	return (jx>=0)? z: -z;
-}
diff --git a/libm/src/s_trunc.c b/libm/src/s_trunc.c
deleted file mode 100644
index d5287eb..0000000
--- a/libm/src/s_trunc.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* @(#)s_floor.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_trunc.c,v 1.1 2004/06/20 09:25:43 das Exp $"); */
-
-/*
- * trunc(x)
- * Return x rounded toward 0 to integral value
- * Method:
- *	Bit twiddling.
- * Exception:
- *	Inexact flag raised if x not equal to trunc(x).
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const double huge = 1.0e300;
-
-double
-trunc(double x)
-{
-	int32_t i0,i1,j0;
-	u_int32_t i,j;
-	EXTRACT_WORDS(i0,i1,x);
-	j0 = ((i0>>20)&0x7ff)-0x3ff;
-	if(j0<20) {
-	    if(j0<0) { 	/* raise inexact if x != 0 */
-		if(huge+x>0.0) {/* |x|<1, so return 0*sign(x) */
-		    i0 &= 0x80000000U;
-		    i1 = 0;
-		}
-	    } else {
-		i = (0x000fffff)>>j0;
-		if(((i0&i)|i1)==0) return x; /* x is integral */
-		if(huge+x>0.0) {	/* raise inexact flag */
-		    i0 &= (~i); i1=0;
-		}
-	    }
-	} else if (j0>51) {
-	    if(j0==0x400) return x+x;	/* inf or NaN */
-	    else return x;		/* x is integral */
-	} else {
-	    i = ((u_int32_t)(0xffffffff))>>(j0-20);
-	    if((i1&i)==0) return x;	/* x is integral */
-	    if(huge+x>0.0)		/* raise inexact flag */
-		i1 &= (~i);
-	}
-	INSERT_WORDS(x,i0,i1);
-	return x;
-}
diff --git a/libm/src/s_truncf.c b/libm/src/s_truncf.c
deleted file mode 100644
index 86b7247..0000000
--- a/libm/src/s_truncf.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/* @(#)s_floor.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include <sys/cdefs.h>
-/* __FBSDID("$FreeBSD: src/lib/msun/src/s_truncf.c,v 1.1 2004/06/20 09:25:43 das Exp $"); */
-
-/*
- * truncf(x)
- * Return x rounded toward 0 to integral value
- * Method:
- *	Bit twiddling.
- * Exception:
- *	Inexact flag raised if x not equal to truncf(x).
- */
-
-#include "math.h"
-#include "math_private.h"
-
-static const float huge = 1.0e30F;
-
-float
-truncf(float x)
-{
-	int32_t i0,j0;
-	u_int32_t i;
-	GET_FLOAT_WORD(i0,x);
-	j0 = ((i0>>23)&0xff)-0x7f;
-	if(j0<23) {
-	    if(j0<0) { 	/* raise inexact if x != 0 */
-		if(huge+x>0.0F)		/* |x|<1, so return 0*sign(x) */
-		    i0 &= 0x80000000;
-	    } else {
-		i = (0x007fffff)>>j0;
-		if((i0&i)==0) return x; /* x is integral */
-		if(huge+x>0.0F)		/* raise inexact flag */
-		    i0 &= (~i);
-	    }
-	} else {
-	    if(j0==0x80) return x+x;	/* inf or NaN */
-	    else return x;		/* x is integral */
-	}
-	SET_FLOAT_WORD(x,i0);
-	return x;
-}
diff --git a/libm/src/s_truncl.c b/libm/src/s_truncl.c
deleted file mode 100644
index 39926a5..0000000
--- a/libm/src/s_truncl.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- *
- * From: @(#)s_floor.c 5.1 93/09/24
- */
-
-#ifndef lint
-static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_truncl.c,v 1.4 2005/04/28 19:45:55 stefanf Exp $";
-#endif
-
-/*
- * truncl(x)
- * Return x rounded toward 0 to integral value
- * Method:
- *	Bit twiddling.
- * Exception:
- *	Inexact flag raised if x not equal to truncl(x).
- */
-
-#include <float.h>
-#include <math.h>
-#include <stdint.h>
-
-#include "fpmath.h"
-
-#ifdef LDBL_IMPLICIT_NBIT
-#define	MANH_SIZE	(LDBL_MANH_SIZE + 1)
-#else
-#define	MANH_SIZE	LDBL_MANH_SIZE
-#endif
-
-static const long double huge = 1.0e300;
-
-long double
-truncl(long double x)
-{
-	union IEEEl2bits u = { .e = x };
-	int e = u.bits.exp - LDBL_MAX_EXP + 1;
-
-	if (e < MANH_SIZE - 1) {
-		if (e < 0) {			/* raise inexact if x != 0 */
-			if (huge + x > 0.0)
-				u.e = 0.0;
-		} else {
-			uint64_t m = ((1llu << MANH_SIZE) - 1) >> (e + 1);
-			if (((u.bits.manh & m) | u.bits.manl) == 0)
-				return (x);	/* x is integral */
-			if (huge + x > 0.0) {	/* raise inexact flag */
-				u.bits.manh &= ~m;
-				u.bits.manl = 0;
-			}
-		}
-	} else if (e < LDBL_MANT_DIG - 1) {
-		uint64_t m = (uint64_t)-1 >> (64 - LDBL_MANT_DIG + e + 1);
-		if ((u.bits.manl & m) == 0)
-			return (x);	/* x is integral */
-		if (huge + x > 0.0)		/* raise inexact flag */
-			u.bits.manl &= ~m;
-	}
-	return (u.e);
-}
diff --git a/libm/src/w_cabs.c b/libm/src/w_cabs.c
deleted file mode 100644
index 577e5e0..0000000
--- a/libm/src/w_cabs.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * cabs() wrapper for hypot().
- *
- * Written by J.T. Conklin, <jtc@wimsey.com>
- * Placed into the Public Domain, 1994.
- */
-
-#ifndef lint
-static const char rcsid[] =
-  "$FreeBSD: src/lib/msun/src/w_cabs.c,v 1.4 2001/06/13 15:16:30 ru Exp $";
-#endif /* not lint */
-
-#include <complex.h>
-#include <math.h>
-
-double
-cabs(z)
-	double complex z;
-{
-	return hypot(creal(z), cimag(z));
-}
-
-double
-z_abs(z)
-	double complex *z;
-{
-	return hypot(creal(*z), cimag(*z));
-}
diff --git a/libm/src/w_cabsf.c b/libm/src/w_cabsf.c
deleted file mode 100644
index fac152f..0000000
--- a/libm/src/w_cabsf.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * cabsf() wrapper for hypotf().
- *
- * Written by J.T. Conklin, <jtc@wimsey.com>
- * Placed into the Public Domain, 1994.
- */
-
-#ifndef lint
-static const char rcsid[] =
-  "$FreeBSD: src/lib/msun/src/w_cabsf.c,v 1.3 2001/06/13 15:16:30 ru Exp $";
-#endif /* not lint */
-
-#include <complex.h>
-#include <math.h>
-#include "math_private.h"
-
-float
-cabsf(z)
-	float complex z;
-{
-
-	return hypotf(crealf(z), cimagf(z));
-}
diff --git a/libm/src/w_dremf.c b/libm/src/w_dremf.c
deleted file mode 100644
index e83ac0e..0000000
--- a/libm/src/w_dremf.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * dremf() wrapper for remainderf().
- *
- * Written by J.T. Conklin, <jtc@wimsey.com>
- * Placed into the Public Domain, 1994.
- */
-/* $FreeBSD: src/lib/msun/src/w_dremf.c,v 1.3 2004/07/28 05:53:18 kan Exp $ */
-
-#include "math.h"
-#include "math_private.h"
-
-float
-dremf(float x, float y)
-{
-	return remainderf(x, y);
-}
diff --git a/libm/upstream-freebsd/lib/msun/bsdsrc/b_exp.c b/libm/upstream-freebsd/lib/msun/bsdsrc/b_exp.c
new file mode 100644
index 0000000..4400992
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/bsdsrc/b_exp.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 1985, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* @(#)exp.c	8.1 (Berkeley) 6/4/93 */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+
+/* EXP(X)
+ * RETURN THE EXPONENTIAL OF X
+ * DOUBLE PRECISION (IEEE 53 bits, VAX D FORMAT 56 BITS)
+ * CODED IN C BY K.C. NG, 1/19/85;
+ * REVISED BY K.C. NG on 2/6/85, 2/15/85, 3/7/85, 3/24/85, 4/16/85, 6/14/86.
+ *
+ * Required system supported functions:
+ *	scalb(x,n)
+ *	copysign(x,y)
+ *	finite(x)
+ *
+ * Method:
+ *	1. Argument Reduction: given the input x, find r and integer k such
+ *	   that
+ *	                   x = k*ln2 + r,  |r| <= 0.5*ln2 .
+ *	   r will be represented as r := z+c for better accuracy.
+ *
+ *	2. Compute exp(r) by
+ *
+ *		exp(r) = 1 + r + r*R1/(2-R1),
+ *	   where
+ *		R1 = x - x^2*(p1+x^2*(p2+x^2*(p3+x^2*(p4+p5*x^2)))).
+ *
+ *	3. exp(x) = 2^k * exp(r) .
+ *
+ * Special cases:
+ *	exp(INF) is INF, exp(NaN) is NaN;
+ *	exp(-INF)=  0;
+ *	for finite argument, only exp(0)=1 is exact.
+ *
+ * Accuracy:
+ *	exp(x) returns the exponential of x nearly rounded. In a test run
+ *	with 1,156,000 random arguments on a VAX, the maximum observed
+ *	error was 0.869 ulps (units in the last place).
+ */
+
+#include "mathimpl.h"
+
+static const double p1 = 0x1.555555555553ep-3;
+static const double p2 = -0x1.6c16c16bebd93p-9;
+static const double p3 = 0x1.1566aaf25de2cp-14;
+static const double p4 = -0x1.bbd41c5d26bf1p-20;
+static const double p5 = 0x1.6376972bea4d0p-25;
+static const double ln2hi = 0x1.62e42fee00000p-1;
+static const double ln2lo = 0x1.a39ef35793c76p-33;
+static const double lnhuge = 0x1.6602b15b7ecf2p9;
+static const double lntiny = -0x1.77af8ebeae354p9;
+static const double invln2 = 0x1.71547652b82fep0;
+
+#if 0
+double exp(x)
+double x;
+{
+	double  z,hi,lo,c;
+	int k;
+
+#if !defined(vax)&&!defined(tahoe)
+	if(x!=x) return(x);	/* x is NaN */
+#endif	/* !defined(vax)&&!defined(tahoe) */
+	if( x <= lnhuge ) {
+		if( x >= lntiny ) {
+
+		    /* argument reduction : x --> x - k*ln2 */
+
+			k=invln2*x+copysign(0.5,x);	/* k=NINT(x/ln2) */
+
+		    /* express x-k*ln2 as hi-lo and let x=hi-lo rounded */
+
+			hi=x-k*ln2hi;
+			x=hi-(lo=k*ln2lo);
+
+		    /* return 2^k*[1+x+x*c/(2+c)]  */
+			z=x*x;
+			c= x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5))));
+			return  scalb(1.0+(hi-(lo-(x*c)/(2.0-c))),k);
+
+		}
+		/* end of x > lntiny */
+
+		else
+		     /* exp(-big#) underflows to zero */
+		     if(finite(x))  return(scalb(1.0,-5000));
+
+		     /* exp(-INF) is zero */
+		     else return(0.0);
+	}
+	/* end of x < lnhuge */
+
+	else
+	/* exp(INF) is INF, exp(+big#) overflows to INF */
+	    return( finite(x) ?  scalb(1.0,5000)  : x);
+}
+#endif
+
+/* returns exp(r = x + c) for |c| < |x| with no overlap.  */
+
+double __exp__D(x, c)
+double x, c;
+{
+	double  z,hi,lo;
+	int k;
+
+	if (x != x)	/* x is NaN */
+		return(x);
+	if ( x <= lnhuge ) {
+		if ( x >= lntiny ) {
+
+		    /* argument reduction : x --> x - k*ln2 */
+			z = invln2*x;
+			k = z + copysign(.5, x);
+
+		    /* express (x+c)-k*ln2 as hi-lo and let x=hi-lo rounded */
+
+			hi=(x-k*ln2hi);			/* Exact. */
+			x= hi - (lo = k*ln2lo-c);
+		    /* return 2^k*[1+x+x*c/(2+c)]  */
+			z=x*x;
+			c= x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5))));
+			c = (x*c)/(2.0-c);
+
+			return  scalb(1.+(hi-(lo - c)), k);
+		}
+		/* end of x > lntiny */
+
+		else
+		     /* exp(-big#) underflows to zero */
+		     if(finite(x))  return(scalb(1.0,-5000));
+
+		     /* exp(-INF) is zero */
+		     else return(0.0);
+	}
+	/* end of x < lnhuge */
+
+	else
+	/* exp(INF) is INF, exp(+big#) overflows to INF */
+	    return( finite(x) ?  scalb(1.0,5000)  : x);
+}
diff --git a/libm/upstream-freebsd/lib/msun/bsdsrc/b_log.c b/libm/upstream-freebsd/lib/msun/bsdsrc/b_log.c
new file mode 100644
index 0000000..5a4b964
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/bsdsrc/b_log.c
@@ -0,0 +1,471 @@
+/*
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* @(#)log.c	8.2 (Berkeley) 11/30/93 */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <math.h>
+#include <errno.h>
+
+#include "mathimpl.h"
+
+/* Table-driven natural logarithm.
+ *
+ * This code was derived, with minor modifications, from:
+ *	Peter Tang, "Table-Driven Implementation of the
+ *	Logarithm in IEEE Floating-Point arithmetic." ACM Trans.
+ *	Math Software, vol 16. no 4, pp 378-400, Dec 1990).
+ *
+ * Calculates log(2^m*F*(1+f/F)), |f/j| <= 1/256,
+ * where F = j/128 for j an integer in [0, 128].
+ *
+ * log(2^m) = log2_hi*m + log2_tail*m
+ * since m is an integer, the dominant term is exact.
+ * m has at most 10 digits (for subnormal numbers),
+ * and log2_hi has 11 trailing zero bits.
+ *
+ * log(F) = logF_hi[j] + logF_lo[j] is in tabular form in log_table.h
+ * logF_hi[] + 512 is exact.
+ *
+ * log(1+f/F) = 2*f/(2*F + f) + 1/12 * (2*f/(2*F + f))**3 + ...
+ * the leading term is calculated to extra precision in two
+ * parts, the larger of which adds exactly to the dominant
+ * m and F terms.
+ * There are two cases:
+ *	1. when m, j are non-zero (m | j), use absolute
+ *	   precision for the leading term.
+ *	2. when m = j = 0, |1-x| < 1/256, and log(x) ~= (x-1).
+ *	   In this case, use a relative precision of 24 bits.
+ * (This is done differently in the original paper)
+ *
+ * Special cases:
+ *	0	return signalling -Inf
+ *	neg	return signalling NaN
+ *	+Inf	return +Inf
+*/
+
+#define N 128
+
+/* Table of log(Fj) = logF_head[j] + logF_tail[j], for Fj = 1+j/128.
+ * Used for generation of extend precision logarithms.
+ * The constant 35184372088832 is 2^45, so the divide is exact.
+ * It ensures correct reading of logF_head, even for inaccurate
+ * decimal-to-binary conversion routines.  (Everybody gets the
+ * right answer for integers less than 2^53.)
+ * Values for log(F) were generated using error < 10^-57 absolute
+ * with the bc -l package.
+*/
+static double	A1 = 	  .08333333333333178827;
+static double	A2 = 	  .01250000000377174923;
+static double	A3 =	 .002232139987919447809;
+static double	A4 =	.0004348877777076145742;
+
+static double logF_head[N+1] = {
+	0.,
+	.007782140442060381246,
+	.015504186535963526694,
+	.023167059281547608406,
+	.030771658666765233647,
+	.038318864302141264488,
+	.045809536031242714670,
+	.053244514518837604555,
+	.060624621816486978786,
+	.067950661908525944454,
+	.075223421237524235039,
+	.082443669210988446138,
+	.089612158689760690322,
+	.096729626458454731618,
+	.103796793681567578460,
+	.110814366340264314203,
+	.117783035656430001836,
+	.124703478501032805070,
+	.131576357788617315236,
+	.138402322859292326029,
+	.145182009844575077295,
+	.151916042025732167530,
+	.158605030176659056451,
+	.165249572895390883786,
+	.171850256926518341060,
+	.178407657472689606947,
+	.184922338493834104156,
+	.191394852999565046047,
+	.197825743329758552135,
+	.204215541428766300668,
+	.210564769107350002741,
+	.216873938300523150246,
+	.223143551314024080056,
+	.229374101064877322642,
+	.235566071312860003672,
+	.241719936886966024758,
+	.247836163904594286577,
+	.253915209980732470285,
+	.259957524436686071567,
+	.265963548496984003577,
+	.271933715484010463114,
+	.277868451003087102435,
+	.283768173130738432519,
+	.289633292582948342896,
+	.295464212893421063199,
+	.301261330578199704177,
+	.307025035294827830512,
+	.312755710004239517729,
+	.318453731118097493890,
+	.324119468654316733591,
+	.329753286372579168528,
+	.335355541920762334484,
+	.340926586970454081892,
+	.346466767346100823488,
+	.351976423156884266063,
+	.357455888922231679316,
+	.362905493689140712376,
+	.368325561158599157352,
+	.373716409793814818840,
+	.379078352934811846353,
+	.384411698910298582632,
+	.389716751140440464951,
+	.394993808240542421117,
+	.400243164127459749579,
+	.405465108107819105498,
+	.410659924985338875558,
+	.415827895143593195825,
+	.420969294644237379543,
+	.426084395310681429691,
+	.431173464818130014464,
+	.436236766774527495726,
+	.441274560805140936281,
+	.446287102628048160113,
+	.451274644139630254358,
+	.456237433481874177232,
+	.461175715122408291790,
+	.466089729924533457960,
+	.470979715219073113985,
+	.475845904869856894947,
+	.480688529345570714212,
+	.485507815781602403149,
+	.490303988045525329653,
+	.495077266798034543171,
+	.499827869556611403822,
+	.504556010751912253908,
+	.509261901790523552335,
+	.513945751101346104405,
+	.518607764208354637958,
+	.523248143765158602036,
+	.527867089620485785417,
+	.532464798869114019908,
+	.537041465897345915436,
+	.541597282432121573947,
+	.546132437597407260909,
+	.550647117952394182793,
+	.555141507540611200965,
+	.559615787935399566777,
+	.564070138285387656651,
+	.568504735352689749561,
+	.572919753562018740922,
+	.577315365035246941260,
+	.581691739635061821900,
+	.586049045003164792433,
+	.590387446602107957005,
+	.594707107746216934174,
+	.599008189645246602594,
+	.603290851438941899687,
+	.607555250224322662688,
+	.611801541106615331955,
+	.616029877215623855590,
+	.620240409751204424537,
+	.624433288012369303032,
+	.628608659422752680256,
+	.632766669570628437213,
+	.636907462236194987781,
+	.641031179420679109171,
+	.645137961373620782978,
+	.649227946625615004450,
+	.653301272011958644725,
+	.657358072709030238911,
+	.661398482245203922502,
+	.665422632544505177065,
+	.669430653942981734871,
+	.673422675212350441142,
+	.677398823590920073911,
+	.681359224807238206267,
+	.685304003098281100392,
+	.689233281238557538017,
+	.693147180560117703862
+};
+
+static double logF_tail[N+1] = {
+	0.,
+	-.00000000000000543229938420049,
+	 .00000000000000172745674997061,
+	-.00000000000001323017818229233,
+	-.00000000000001154527628289872,
+	-.00000000000000466529469958300,
+	 .00000000000005148849572685810,
+	-.00000000000002532168943117445,
+	-.00000000000005213620639136504,
+	-.00000000000001819506003016881,
+	 .00000000000006329065958724544,
+	 .00000000000008614512936087814,
+	-.00000000000007355770219435028,
+	 .00000000000009638067658552277,
+	 .00000000000007598636597194141,
+	 .00000000000002579999128306990,
+	-.00000000000004654729747598444,
+	-.00000000000007556920687451336,
+	 .00000000000010195735223708472,
+	-.00000000000017319034406422306,
+	-.00000000000007718001336828098,
+	 .00000000000010980754099855238,
+	-.00000000000002047235780046195,
+	-.00000000000008372091099235912,
+	 .00000000000014088127937111135,
+	 .00000000000012869017157588257,
+	 .00000000000017788850778198106,
+	 .00000000000006440856150696891,
+	 .00000000000016132822667240822,
+	-.00000000000007540916511956188,
+	-.00000000000000036507188831790,
+	 .00000000000009120937249914984,
+	 .00000000000018567570959796010,
+	-.00000000000003149265065191483,
+	-.00000000000009309459495196889,
+	 .00000000000017914338601329117,
+	-.00000000000001302979717330866,
+	 .00000000000023097385217586939,
+	 .00000000000023999540484211737,
+	 .00000000000015393776174455408,
+	-.00000000000036870428315837678,
+	 .00000000000036920375082080089,
+	-.00000000000009383417223663699,
+	 .00000000000009433398189512690,
+	 .00000000000041481318704258568,
+	-.00000000000003792316480209314,
+	 .00000000000008403156304792424,
+	-.00000000000034262934348285429,
+	 .00000000000043712191957429145,
+	-.00000000000010475750058776541,
+	-.00000000000011118671389559323,
+	 .00000000000037549577257259853,
+	 .00000000000013912841212197565,
+	 .00000000000010775743037572640,
+	 .00000000000029391859187648000,
+	-.00000000000042790509060060774,
+	 .00000000000022774076114039555,
+	 .00000000000010849569622967912,
+	-.00000000000023073801945705758,
+	 .00000000000015761203773969435,
+	 .00000000000003345710269544082,
+	-.00000000000041525158063436123,
+	 .00000000000032655698896907146,
+	-.00000000000044704265010452446,
+	 .00000000000034527647952039772,
+	-.00000000000007048962392109746,
+	 .00000000000011776978751369214,
+	-.00000000000010774341461609578,
+	 .00000000000021863343293215910,
+	 .00000000000024132639491333131,
+	 .00000000000039057462209830700,
+	-.00000000000026570679203560751,
+	 .00000000000037135141919592021,
+	-.00000000000017166921336082431,
+	-.00000000000028658285157914353,
+	-.00000000000023812542263446809,
+	 .00000000000006576659768580062,
+	-.00000000000028210143846181267,
+	 .00000000000010701931762114254,
+	 .00000000000018119346366441110,
+	 .00000000000009840465278232627,
+	-.00000000000033149150282752542,
+	-.00000000000018302857356041668,
+	-.00000000000016207400156744949,
+	 .00000000000048303314949553201,
+	-.00000000000071560553172382115,
+	 .00000000000088821239518571855,
+	-.00000000000030900580513238244,
+	-.00000000000061076551972851496,
+	 .00000000000035659969663347830,
+	 .00000000000035782396591276383,
+	-.00000000000046226087001544578,
+	 .00000000000062279762917225156,
+	 .00000000000072838947272065741,
+	 .00000000000026809646615211673,
+	-.00000000000010960825046059278,
+	 .00000000000002311949383800537,
+	-.00000000000058469058005299247,
+	-.00000000000002103748251144494,
+	-.00000000000023323182945587408,
+	-.00000000000042333694288141916,
+	-.00000000000043933937969737844,
+	 .00000000000041341647073835565,
+	 .00000000000006841763641591466,
+	 .00000000000047585534004430641,
+	 .00000000000083679678674757695,
+	-.00000000000085763734646658640,
+	 .00000000000021913281229340092,
+	-.00000000000062242842536431148,
+	-.00000000000010983594325438430,
+	 .00000000000065310431377633651,
+	-.00000000000047580199021710769,
+	-.00000000000037854251265457040,
+	 .00000000000040939233218678664,
+	 .00000000000087424383914858291,
+	 .00000000000025218188456842882,
+	-.00000000000003608131360422557,
+	-.00000000000050518555924280902,
+	 .00000000000078699403323355317,
+	-.00000000000067020876961949060,
+	 .00000000000016108575753932458,
+	 .00000000000058527188436251509,
+	-.00000000000035246757297904791,
+	-.00000000000018372084495629058,
+	 .00000000000088606689813494916,
+	 .00000000000066486268071468700,
+	 .00000000000063831615170646519,
+	 .00000000000025144230728376072,
+	-.00000000000017239444525614834
+};
+
+#if 0
+double
+#ifdef _ANSI_SOURCE
+log(double x)
+#else
+log(x) double x;
+#endif
+{
+	int m, j;
+	double F, f, g, q, u, u2, v, zero = 0.0, one = 1.0;
+	volatile double u1;
+
+	/* Catch special cases */
+	if (x <= 0)
+		if (x == zero)	/* log(0) = -Inf */
+			return (-one/zero);
+		else		/* log(neg) = NaN */
+			return (zero/zero);
+	else if (!finite(x))
+		return (x+x);		/* x = NaN, Inf */
+
+	/* Argument reduction: 1 <= g < 2; x/2^m = g;	*/
+	/* y = F*(1 + f/F) for |f| <= 2^-8		*/
+
+	m = logb(x);
+	g = ldexp(x, -m);
+	if (m == -1022) {
+		j = logb(g), m += j;
+		g = ldexp(g, -j);
+	}
+	j = N*(g-1) + .5;
+	F = (1.0/N) * j + 1;	/* F*128 is an integer in [128, 512] */
+	f = g - F;
+
+	/* Approximate expansion for log(1+f/F) ~= u + q */
+	g = 1/(2*F+f);
+	u = 2*f*g;
+	v = u*u;
+	q = u*v*(A1 + v*(A2 + v*(A3 + v*A4)));
+
+    /* case 1: u1 = u rounded to 2^-43 absolute.  Since u < 2^-8,
+     * 	       u1 has at most 35 bits, and F*u1 is exact, as F has < 8 bits.
+     *         It also adds exactly to |m*log2_hi + log_F_head[j] | < 750
+    */
+	if (m | j)
+		u1 = u + 513, u1 -= 513;
+
+    /* case 2:	|1-x| < 1/256. The m- and j- dependent terms are zero;
+     * 		u1 = u to 24 bits.
+    */
+	else
+		u1 = u, TRUNC(u1);
+	u2 = (2.0*(f - F*u1) - u1*f) * g;
+			/* u1 + u2 = 2f/(2F+f) to extra precision.	*/
+
+	/* log(x) = log(2^m*F*(1+f/F)) =				*/
+	/* (m*log2_hi+logF_head[j]+u1) + (m*log2_lo+logF_tail[j]+q);	*/
+	/* (exact) + (tiny)						*/
+
+	u1 += m*logF_head[N] + logF_head[j];		/* exact */
+	u2 = (u2 + logF_tail[j]) + q;			/* tiny */
+	u2 += logF_tail[N]*m;
+	return (u1 + u2);
+}
+#endif
+
+/*
+ * Extra precision variant, returning struct {double a, b;};
+ * log(x) = a+b to 63 bits, with a rounded to 26 bits.
+ */
+struct Double
+#ifdef _ANSI_SOURCE
+__log__D(double x)
+#else
+__log__D(x) double x;
+#endif
+{
+	int m, j;
+	double F, f, g, q, u, v, u2;
+	volatile double u1;
+	struct Double r;
+
+	/* Argument reduction: 1 <= g < 2; x/2^m = g;	*/
+	/* y = F*(1 + f/F) for |f| <= 2^-8		*/
+
+	m = logb(x);
+	g = ldexp(x, -m);
+	if (m == -1022) {
+		j = logb(g), m += j;
+		g = ldexp(g, -j);
+	}
+	j = N*(g-1) + .5;
+	F = (1.0/N) * j + 1;
+	f = g - F;
+
+	g = 1/(2*F+f);
+	u = 2*f*g;
+	v = u*u;
+	q = u*v*(A1 + v*(A2 + v*(A3 + v*A4)));
+	if (m | j)
+		u1 = u + 513, u1 -= 513;
+	else
+		u1 = u, TRUNC(u1);
+	u2 = (2.0*(f - F*u1) - u1*f) * g;
+
+	u1 += m*logF_head[N] + logF_head[j];
+
+	u2 +=  logF_tail[j]; u2 += q;
+	u2 += logF_tail[N]*m;
+	r.a = u1 + u2;			/* Only difference is here */
+	TRUNC(r.a);
+	r.b = (u1 - r.a) + u2;
+	return (r);
+}
diff --git a/libm/upstream-freebsd/lib/msun/bsdsrc/b_tgamma.c b/libm/upstream-freebsd/lib/msun/bsdsrc/b_tgamma.c
new file mode 100644
index 0000000..1d0af44
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/bsdsrc/b_tgamma.c
@@ -0,0 +1,317 @@
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* @(#)gamma.c	8.1 (Berkeley) 6/4/93 */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * This code by P. McIlroy, Oct 1992;
+ *
+ * The financial support of UUNET Communications Services is greatfully
+ * acknowledged.
+ */
+
+#include <math.h>
+#include "mathimpl.h"
+
+/* METHOD:
+ * x < 0: Use reflection formula, G(x) = pi/(sin(pi*x)*x*G(x))
+ * 	At negative integers, return NaN and raise invalid.
+ *
+ * x < 6.5:
+ *	Use argument reduction G(x+1) = xG(x) to reach the
+ *	range [1.066124,2.066124].  Use a rational
+ *	approximation centered at the minimum (x0+1) to
+ *	ensure monotonicity.
+ *
+ * x >= 6.5: Use the asymptotic approximation (Stirling's formula)
+ *	adjusted for equal-ripples:
+ *
+ *	log(G(x)) ~= (x-.5)*(log(x)-1) + .5(log(2*pi)-1) + 1/x*P(1/(x*x))
+ *
+ *	Keep extra precision in multiplying (x-.5)(log(x)-1), to
+ *	avoid premature round-off.
+ *
+ * Special values:
+ *	-Inf:			return NaN and raise invalid;
+ *	negative integer:	return NaN and raise invalid;
+ *	other x ~< 177.79:	return +-0 and raise underflow;
+ *	+-0:			return +-Inf and raise divide-by-zero;
+ *	finite x ~> 171.63:	return +Inf and raise overflow;
+ *	+Inf:			return +Inf;
+ *	NaN: 			return NaN.
+ *
+ * Accuracy: tgamma(x) is accurate to within
+ *	x > 0:  error provably < 0.9ulp.
+ *	Maximum observed in 1,000,000 trials was .87ulp.
+ *	x < 0:
+ *	Maximum observed error < 4ulp in 1,000,000 trials.
+ */
+
+static double neg_gam(double);
+static double small_gam(double);
+static double smaller_gam(double);
+static struct Double large_gam(double);
+static struct Double ratfun_gam(double, double);
+
+/*
+ * Rational approximation, A0 + x*x*P(x)/Q(x), on the interval
+ * [1.066.., 2.066..] accurate to 4.25e-19.
+ */
+#define LEFT -.3955078125	/* left boundary for rat. approx */
+#define x0 .461632144968362356785	/* xmin - 1 */
+
+#define a0_hi 0.88560319441088874992
+#define a0_lo -.00000000000000004996427036469019695
+#define P0	 6.21389571821820863029017800727e-01
+#define P1	 2.65757198651533466104979197553e-01
+#define P2	 5.53859446429917461063308081748e-03
+#define P3	 1.38456698304096573887145282811e-03
+#define P4	 2.40659950032711365819348969808e-03
+#define Q0	 1.45019531250000000000000000000e+00
+#define Q1	 1.06258521948016171343454061571e+00
+#define Q2	-2.07474561943859936441469926649e-01
+#define Q3	-1.46734131782005422506287573015e-01
+#define Q4	 3.07878176156175520361557573779e-02
+#define Q5	 5.12449347980666221336054633184e-03
+#define Q6	-1.76012741431666995019222898833e-03
+#define Q7	 9.35021023573788935372153030556e-05
+#define Q8	 6.13275507472443958924745652239e-06
+/*
+ * Constants for large x approximation (x in [6, Inf])
+ * (Accurate to 2.8*10^-19 absolute)
+ */
+#define lns2pi_hi 0.418945312500000
+#define lns2pi_lo -.000006779295327258219670263595
+#define Pa0	 8.33333333333333148296162562474e-02
+#define Pa1	-2.77777777774548123579378966497e-03
+#define Pa2	 7.93650778754435631476282786423e-04
+#define Pa3	-5.95235082566672847950717262222e-04
+#define Pa4	 8.41428560346653702135821806252e-04
+#define Pa5	-1.89773526463879200348872089421e-03
+#define Pa6	 5.69394463439411649408050664078e-03
+#define Pa7	-1.44705562421428915453880392761e-02
+
+static const double zero = 0., one = 1.0, tiny = 1e-300;
+
+double
+tgamma(x)
+	double x;
+{
+	struct Double u;
+
+	if (x >= 6) {
+		if(x > 171.63)
+			return (x / zero);
+		u = large_gam(x);
+		return(__exp__D(u.a, u.b));
+	} else if (x >= 1.0 + LEFT + x0)
+		return (small_gam(x));
+	else if (x > 1.e-17)
+		return (smaller_gam(x));
+	else if (x > -1.e-17) {
+		if (x != 0.0)
+			u.a = one - tiny;	/* raise inexact */
+		return (one/x);
+	} else if (!finite(x))
+		return (x - x);		/* x is NaN or -Inf */
+	else
+		return (neg_gam(x));
+}
+/*
+ * Accurate to max(ulp(1/128) absolute, 2^-66 relative) error.
+ */
+static struct Double
+large_gam(x)
+	double x;
+{
+	double z, p;
+	struct Double t, u, v;
+
+	z = one/(x*x);
+	p = Pa0+z*(Pa1+z*(Pa2+z*(Pa3+z*(Pa4+z*(Pa5+z*(Pa6+z*Pa7))))));
+	p = p/x;
+
+	u = __log__D(x);
+	u.a -= one;
+	v.a = (x -= .5);
+	TRUNC(v.a);
+	v.b = x - v.a;
+	t.a = v.a*u.a;			/* t = (x-.5)*(log(x)-1) */
+	t.b = v.b*u.a + x*u.b;
+	/* return t.a + t.b + lns2pi_hi + lns2pi_lo + p */
+	t.b += lns2pi_lo; t.b += p;
+	u.a = lns2pi_hi + t.b; u.a += t.a;
+	u.b = t.a - u.a;
+	u.b += lns2pi_hi; u.b += t.b;
+	return (u);
+}
+/*
+ * Good to < 1 ulp.  (provably .90 ulp; .87 ulp on 1,000,000 runs.)
+ * It also has correct monotonicity.
+ */
+static double
+small_gam(x)
+	double x;
+{
+	double y, ym1, t;
+	struct Double yy, r;
+	y = x - one;
+	ym1 = y - one;
+	if (y <= 1.0 + (LEFT + x0)) {
+		yy = ratfun_gam(y - x0, 0);
+		return (yy.a + yy.b);
+	}
+	r.a = y;
+	TRUNC(r.a);
+	yy.a = r.a - one;
+	y = ym1;
+	yy.b = r.b = y - yy.a;
+	/* Argument reduction: G(x+1) = x*G(x) */
+	for (ym1 = y-one; ym1 > LEFT + x0; y = ym1--, yy.a--) {
+		t = r.a*yy.a;
+		r.b = r.a*yy.b + y*r.b;
+		r.a = t;
+		TRUNC(r.a);
+		r.b += (t - r.a);
+	}
+	/* Return r*tgamma(y). */
+	yy = ratfun_gam(y - x0, 0);
+	y = r.b*(yy.a + yy.b) + r.a*yy.b;
+	y += yy.a*r.a;
+	return (y);
+}
+/*
+ * Good on (0, 1+x0+LEFT].  Accurate to 1ulp.
+ */
+static double
+smaller_gam(x)
+	double x;
+{
+	double t, d;
+	struct Double r, xx;
+	if (x < x0 + LEFT) {
+		t = x, TRUNC(t);
+		d = (t+x)*(x-t);
+		t *= t;
+		xx.a = (t + x), TRUNC(xx.a);
+		xx.b = x - xx.a; xx.b += t; xx.b += d;
+		t = (one-x0); t += x;
+		d = (one-x0); d -= t; d += x;
+		x = xx.a + xx.b;
+	} else {
+		xx.a =  x, TRUNC(xx.a);
+		xx.b = x - xx.a;
+		t = x - x0;
+		d = (-x0 -t); d += x;
+	}
+	r = ratfun_gam(t, d);
+	d = r.a/x, TRUNC(d);
+	r.a -= d*xx.a; r.a -= d*xx.b; r.a += r.b;
+	return (d + r.a/x);
+}
+/*
+ * returns (z+c)^2 * P(z)/Q(z) + a0
+ */
+static struct Double
+ratfun_gam(z, c)
+	double z, c;
+{
+	double p, q;
+	struct Double r, t;
+
+	q = Q0 +z*(Q1+z*(Q2+z*(Q3+z*(Q4+z*(Q5+z*(Q6+z*(Q7+z*Q8)))))));
+	p = P0 + z*(P1 + z*(P2 + z*(P3 + z*P4)));
+
+	/* return r.a + r.b = a0 + (z+c)^2*p/q, with r.a truncated to 26 bits. */
+	p = p/q;
+	t.a = z, TRUNC(t.a);		/* t ~= z + c */
+	t.b = (z - t.a) + c;
+	t.b *= (t.a + z);
+	q = (t.a *= t.a);		/* t = (z+c)^2 */
+	TRUNC(t.a);
+	t.b += (q - t.a);
+	r.a = p, TRUNC(r.a);		/* r = P/Q */
+	r.b = p - r.a;
+	t.b = t.b*p + t.a*r.b + a0_lo;
+	t.a *= r.a;			/* t = (z+c)^2*(P/Q) */
+	r.a = t.a + a0_hi, TRUNC(r.a);
+	r.b = ((a0_hi-r.a) + t.a) + t.b;
+	return (r);			/* r = a0 + t */
+}
+
+static double
+neg_gam(x)
+	double x;
+{
+	int sgn = 1;
+	struct Double lg, lsine;
+	double y, z;
+
+	y = ceil(x);
+	if (y == x)		/* Negative integer. */
+		return ((x - x) / zero);
+	z = y - x;
+	if (z > 0.5)
+		z = one - z;
+	y = 0.5 * y;
+	if (y == ceil(y))
+		sgn = -1;
+	if (z < .25)
+		z = sin(M_PI*z);
+	else
+		z = cos(M_PI*(0.5-z));
+	/* Special case: G(1-x) = Inf; G(x) may be nonzero. */
+	if (x < -170) {
+		if (x < -190)
+			return ((double)sgn*tiny*tiny);
+		y = one - x;		/* exact: 128 < |x| < 255 */
+		lg = large_gam(y);
+		lsine = __log__D(M_PI/z);	/* = TRUNC(log(u)) + small */
+		lg.a -= lsine.a;		/* exact (opposite signs) */
+		lg.b -= lsine.b;
+		y = -(lg.a + lg.b);
+		z = (y + lg.a) + lg.b;
+		y = __exp__D(y, z);
+		if (sgn < 0) y = -y;
+		return (y);
+	}
+	y = one-x;
+	if (one-y == x)
+		y = tgamma(y);
+	else		/* 1-x is inexact */
+		y = -x*tgamma(-x);
+	if (sgn < 0) y = -y;
+	return (M_PI / (y*z));
+}
diff --git a/libm/upstream-freebsd/lib/msun/bsdsrc/mathimpl.h b/libm/upstream-freebsd/lib/msun/bsdsrc/mathimpl.h
new file mode 100644
index 0000000..04a4b6e
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/bsdsrc/mathimpl.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)mathimpl.h	8.1 (Berkeley) 6/4/93
+ * $FreeBSD$
+ */
+
+#ifndef _MATHIMPL_H_
+#define	_MATHIMPL_H_
+
+#include <sys/cdefs.h>
+#include <math.h>
+
+#include "../src/math_private.h"
+
+/*
+ * TRUNC() is a macro that sets the trailing 27 bits in the mantissa of an
+ * IEEE double variable to zero.  It must be expression-like for syntactic
+ * reasons, and we implement this expression using an inline function
+ * instead of a pure macro to avoid depending on the gcc feature of
+ * statement-expressions.
+ */
+#define	TRUNC(d)	(_b_trunc(&(d)))
+
+static __inline void
+_b_trunc(volatile double *_dp)
+{
+	uint32_t _lw;
+
+	GET_LOW_WORD(_lw, *_dp);
+	SET_LOW_WORD(*_dp, _lw & 0xf8000000);
+}
+
+struct Double {
+	double	a;
+	double	b;
+};
+
+/*
+ * Functions internal to the math package, yet not static.
+ */
+double	__exp__D(double, double);
+struct Double __log__D(double);
+
+#endif /* !_MATHIMPL_H_ */
diff --git a/libm/upstream-freebsd/lib/msun/src/e_acos.c b/libm/upstream-freebsd/lib/msun/src/e_acos.c
new file mode 100644
index 0000000..1f6dca5
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_acos.c
@@ -0,0 +1,111 @@
+
+/* @(#)e_acos.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_acos(x)
+ * Method :                  
+ *	acos(x)  = pi/2 - asin(x)
+ *	acos(-x) = pi/2 + asin(x)
+ * For |x|<=0.5
+ *	acos(x) = pi/2 - (x + x*x^2*R(x^2))	(see asin.c)
+ * For x>0.5
+ * 	acos(x) = pi/2 - (pi/2 - 2asin(sqrt((1-x)/2)))
+ *		= 2asin(sqrt((1-x)/2))  
+ *		= 2s + 2s*z*R(z) 	...z=(1-x)/2, s=sqrt(z)
+ *		= 2f + (2c + 2s*z*R(z))
+ *     where f=hi part of s, and c = (z-f*f)/(s+f) is the correction term
+ *     for f so that f+c ~ sqrt(z).
+ * For x<-0.5
+ *	acos(x) = pi - 2asin(sqrt((1-|x|)/2))
+ *		= pi - 0.5*(s+s*z*R(z)), where z=(1-|x|)/2,s=sqrt(z)
+ *
+ * Special cases:
+ *	if x is NaN, return x itself;
+ *	if |x|>1, return NaN with invalid signal.
+ *
+ * Function needed: sqrt
+ */
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const double
+one=  1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
+pi =  3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */
+pio2_hi =  1.57079632679489655800e+00; /* 0x3FF921FB, 0x54442D18 */
+static volatile double
+pio2_lo =  6.12323399573676603587e-17; /* 0x3C91A626, 0x33145C07 */
+static const double
+pS0 =  1.66666666666666657415e-01, /* 0x3FC55555, 0x55555555 */
+pS1 = -3.25565818622400915405e-01, /* 0xBFD4D612, 0x03EB6F7D */
+pS2 =  2.01212532134862925881e-01, /* 0x3FC9C155, 0x0E884455 */
+pS3 = -4.00555345006794114027e-02, /* 0xBFA48228, 0xB5688F3B */
+pS4 =  7.91534994289814532176e-04, /* 0x3F49EFE0, 0x7501B288 */
+pS5 =  3.47933107596021167570e-05, /* 0x3F023DE1, 0x0DFDF709 */
+qS1 = -2.40339491173441421878e+00, /* 0xC0033A27, 0x1C8A2D4B */
+qS2 =  2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */
+qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */
+qS4 =  7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
+
+double
+__ieee754_acos(double x)
+{
+	double z,p,q,r,w,s,c,df;
+	int32_t hx,ix;
+	GET_HIGH_WORD(hx,x);
+	ix = hx&0x7fffffff;
+	if(ix>=0x3ff00000) {	/* |x| >= 1 */
+	    u_int32_t lx;
+	    GET_LOW_WORD(lx,x);
+	    if(((ix-0x3ff00000)|lx)==0) {	/* |x|==1 */
+		if(hx>0) return 0.0;		/* acos(1) = 0  */
+		else return pi+2.0*pio2_lo;	/* acos(-1)= pi */
+	    }
+	    return (x-x)/(x-x);		/* acos(|x|>1) is NaN */
+	}
+	if(ix<0x3fe00000) {	/* |x| < 0.5 */
+	    if(ix<=0x3c600000) return pio2_hi+pio2_lo;/*if|x|<2**-57*/
+	    z = x*x;
+	    p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
+	    q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
+	    r = p/q;
+	    return pio2_hi - (x - (pio2_lo-x*r));
+	} else  if (hx<0) {		/* x < -0.5 */
+	    z = (one+x)*0.5;
+	    p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
+	    q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
+	    s = sqrt(z);
+	    r = p/q;
+	    w = r*s-pio2_lo;
+	    return pi - 2.0*(s+w);
+	} else {			/* x > 0.5 */
+	    z = (one-x)*0.5;
+	    s = sqrt(z);
+	    df = s;
+	    SET_LOW_WORD(df,0);
+	    c  = (z-df*df)/(s+df);
+	    p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
+	    q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
+	    r = p/q;
+	    w = r*s+c;
+	    return 2.0*(df+w);
+	}
+}
+
+#if LDBL_MANT_DIG == 53
+__weak_reference(acos, acosl);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/e_acosf.c b/libm/upstream-freebsd/lib/msun/src/e_acosf.c
new file mode 100644
index 0000000..c9f62cc
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_acosf.c
@@ -0,0 +1,77 @@
+/* e_acosf.c -- float version of e_acos.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static const float
+one =  1.0000000000e+00, /* 0x3F800000 */
+pi =  3.1415925026e+00, /* 0x40490fda */
+pio2_hi =  1.5707962513e+00; /* 0x3fc90fda */
+static volatile float
+pio2_lo =  7.5497894159e-08; /* 0x33a22168 */
+static const float
+pS0 =  1.6666586697e-01,
+pS1 = -4.2743422091e-02,
+pS2 = -8.6563630030e-03,
+qS1 = -7.0662963390e-01;
+
+float
+__ieee754_acosf(float x)
+{
+	float z,p,q,r,w,s,c,df;
+	int32_t hx,ix;
+	GET_FLOAT_WORD(hx,x);
+	ix = hx&0x7fffffff;
+	if(ix>=0x3f800000) {		/* |x| >= 1 */
+	    if(ix==0x3f800000) {	/* |x| == 1 */
+		if(hx>0) return 0.0;	/* acos(1) = 0 */
+		else return pi+(float)2.0*pio2_lo;	/* acos(-1)= pi */
+	    }
+	    return (x-x)/(x-x);		/* acos(|x|>1) is NaN */
+	}
+	if(ix<0x3f000000) {	/* |x| < 0.5 */
+	    if(ix<=0x32800000) return pio2_hi+pio2_lo;/*if|x|<2**-26*/
+	    z = x*x;
+	    p = z*(pS0+z*(pS1+z*pS2));
+	    q = one+z*qS1;
+	    r = p/q;
+	    return pio2_hi - (x - (pio2_lo-x*r));
+	} else  if (hx<0) {		/* x < -0.5 */
+	    z = (one+x)*(float)0.5;
+	    p = z*(pS0+z*(pS1+z*pS2));
+	    q = one+z*qS1;
+	    s = sqrtf(z);
+	    r = p/q;
+	    w = r*s-pio2_lo;
+	    return pi - (float)2.0*(s+w);
+	} else {			/* x > 0.5 */
+	    int32_t idf;
+	    z = (one-x)*(float)0.5;
+	    s = sqrtf(z);
+	    df = s;
+	    GET_FLOAT_WORD(idf,df);
+	    SET_FLOAT_WORD(df,idf&0xfffff000);
+	    c  = (z-df*df)/(s+df);
+	    p = z*(pS0+z*(pS1+z*pS2));
+	    q = one+z*qS1;
+	    r = p/q;
+	    w = r*s+c;
+	    return (float)2.0*(df+w);
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_acosh.c b/libm/upstream-freebsd/lib/msun/src/e_acosh.c
new file mode 100644
index 0000000..a0cc6cb
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_acosh.c
@@ -0,0 +1,62 @@
+
+/* @(#)e_acosh.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_acosh(x)
+ * Method :
+ *	Based on 
+ *		acosh(x) = log [ x + sqrt(x*x-1) ]
+ *	we have
+ *		acosh(x) := log(x)+ln2,	if x is large; else
+ *		acosh(x) := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else
+ *		acosh(x) := log1p(t+sqrt(2.0*t+t*t)); where t=x-1.
+ *
+ * Special cases:
+ *	acosh(x) is NaN with signal if x<1.
+ *	acosh(NaN) is NaN without signal.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+static const double
+one	= 1.0,
+ln2	= 6.93147180559945286227e-01;  /* 0x3FE62E42, 0xFEFA39EF */
+
+double
+__ieee754_acosh(double x)
+{
+	double t;
+	int32_t hx;
+	u_int32_t lx;
+	EXTRACT_WORDS(hx,lx,x);
+	if(hx<0x3ff00000) {		/* x < 1 */
+	    return (x-x)/(x-x);
+	} else if(hx >=0x41b00000) {	/* x > 2**28 */
+	    if(hx >=0x7ff00000) {	/* x is inf of NaN */
+	        return x+x;
+	    } else 
+		return __ieee754_log(x)+ln2;	/* acosh(huge)=log(2x) */
+	} else if(((hx-0x3ff00000)|lx)==0) {
+	    return 0.0;			/* acosh(1) = 0 */
+	} else if (hx > 0x40000000) {	/* 2**28 > x > 2 */
+	    t=x*x;
+	    return __ieee754_log(2.0*x-one/(x+sqrt(t-one)));
+	} else {			/* 1<x<2 */
+	    t = x-one;
+	    return log1p(t+sqrt(2.0*t+t*t));
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_acoshf.c b/libm/upstream-freebsd/lib/msun/src/e_acoshf.c
new file mode 100644
index 0000000..f529b20
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_acoshf.c
@@ -0,0 +1,48 @@
+/* e_acoshf.c -- float version of e_acosh.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static const float
+one	= 1.0,
+ln2	= 6.9314718246e-01;  /* 0x3f317218 */
+
+float
+__ieee754_acoshf(float x)
+{
+	float t;
+	int32_t hx;
+	GET_FLOAT_WORD(hx,x);
+	if(hx<0x3f800000) {		/* x < 1 */
+	    return (x-x)/(x-x);
+	} else if(hx >=0x4d800000) {	/* x > 2**28 */
+	    if(hx >=0x7f800000) {	/* x is inf of NaN */
+	        return x+x;
+	    } else
+		return __ieee754_logf(x)+ln2;	/* acosh(huge)=log(2x) */
+	} else if (hx==0x3f800000) {
+	    return 0.0;			/* acosh(1) = 0 */
+	} else if (hx > 0x40000000) {	/* 2**28 > x > 2 */
+	    t=x*x;
+	    return __ieee754_logf((float)2.0*x-one/(x+__ieee754_sqrtf(t-one)));
+	} else {			/* 1<x<2 */
+	    t = x-one;
+	    return log1pf(t+__ieee754_sqrtf((float)2.0*t+t*t));
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_acosl.c b/libm/upstream-freebsd/lib/msun/src/e_acosl.c
new file mode 100644
index 0000000..d33c8fe
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_acosl.c
@@ -0,0 +1,87 @@
+
+/* @(#)e_acos.c 1.3 95/01/18 */
+/* FreeBSD: head/lib/msun/src/e_acos.c 176451 2008-02-22 02:30:36Z das */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * See comments in e_acos.c.
+ * Converted to long double by David Schultz <das@FreeBSD.ORG>.
+ */
+
+#include <float.h>
+
+#include "invtrig.h"
+#include "math.h"
+#include "math_private.h"
+
+static const long double
+one=  1.00000000000000000000e+00;
+
+#ifdef __i386__
+/* XXX Work around the fact that gcc truncates long double constants on i386 */
+static volatile double
+pi1 =  3.14159265358979311600e+00,	/*  0x1.921fb54442d18p+1  */
+pi2 =  1.22514845490862001043e-16;	/*  0x1.1a80000000000p-53 */
+#define	pi	((long double)pi1 + pi2)
+#else
+static const long double
+pi =  3.14159265358979323846264338327950280e+00L;
+#endif
+
+long double
+acosl(long double x)
+{
+	union IEEEl2bits u;
+	long double z,p,q,r,w,s,c,df;
+	int16_t expsign, expt;
+	u.e = x;
+	expsign = u.xbits.expsign;
+	expt = expsign & 0x7fff;
+	if(expt >= BIAS) {	/* |x| >= 1 */
+	    if(expt==BIAS && ((u.bits.manh&~LDBL_NBIT)|u.bits.manl)==0) {
+		if (expsign>0) return 0.0;	/* acos(1) = 0  */
+		else return pi+2.0*pio2_lo;	/* acos(-1)= pi */
+	    }
+	    return (x-x)/(x-x);		/* acos(|x|>1) is NaN */
+	}
+	if(expt<BIAS-1) {	/* |x| < 0.5 */
+	    if(expt<ACOS_CONST) return pio2_hi+pio2_lo;/*x tiny: acosl=pi/2*/
+	    z = x*x;
+	    p = P(z);
+	    q = Q(z);
+	    r = p/q;
+	    return pio2_hi - (x - (pio2_lo-x*r));
+	} else  if (expsign<0) {	/* x < -0.5 */
+	    z = (one+x)*0.5;
+	    p = P(z);
+	    q = Q(z);
+	    s = sqrtl(z);
+	    r = p/q;
+	    w = r*s-pio2_lo;
+	    return pi - 2.0*(s+w);
+	} else {			/* x > 0.5 */
+	    z = (one-x)*0.5;
+	    s = sqrtl(z);
+	    u.e = s;
+	    u.bits.manl = 0;
+	    df = u.e;
+	    c  = (z-df*df)/(s+df);
+	    p = P(z);
+	    q = Q(z);
+	    r = p/q;
+	    w = r*s+c;
+	    return 2.0*(df+w);
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_asin.c b/libm/upstream-freebsd/lib/msun/src/e_asin.c
new file mode 100644
index 0000000..27de207
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_asin.c
@@ -0,0 +1,117 @@
+
+/* @(#)e_asin.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_asin(x)
+ * Method :                  
+ *	Since  asin(x) = x + x^3/6 + x^5*3/40 + x^7*15/336 + ...
+ *	we approximate asin(x) on [0,0.5] by
+ *		asin(x) = x + x*x^2*R(x^2)
+ *	where
+ *		R(x^2) is a rational approximation of (asin(x)-x)/x^3 
+ *	and its remez error is bounded by
+ *		|(asin(x)-x)/x^3 - R(x^2)| < 2^(-58.75)
+ *
+ *	For x in [0.5,1]
+ *		asin(x) = pi/2-2*asin(sqrt((1-x)/2))
+ *	Let y = (1-x), z = y/2, s := sqrt(z), and pio2_hi+pio2_lo=pi/2;
+ *	then for x>0.98
+ *		asin(x) = pi/2 - 2*(s+s*z*R(z))
+ *			= pio2_hi - (2*(s+s*z*R(z)) - pio2_lo)
+ *	For x<=0.98, let pio4_hi = pio2_hi/2, then
+ *		f = hi part of s;
+ *		c = sqrt(z) - f = (z-f*f)/(s+f) 	...f+c=sqrt(z)
+ *	and
+ *		asin(x) = pi/2 - 2*(s+s*z*R(z))
+ *			= pio4_hi+(pio4-2s)-(2s*z*R(z)-pio2_lo)
+ *			= pio4_hi+(pio4-2f)-(2s*z*R(z)-(pio2_lo+2c))
+ *
+ * Special cases:
+ *	if x is NaN, return x itself;
+ *	if |x|>1, return NaN with invalid signal.
+ *
+ */
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const double
+one =  1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
+huge =  1.000e+300,
+pio2_hi =  1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */
+pio2_lo =  6.12323399573676603587e-17, /* 0x3C91A626, 0x33145C07 */
+pio4_hi =  7.85398163397448278999e-01, /* 0x3FE921FB, 0x54442D18 */
+	/* coefficient for R(x^2) */
+pS0 =  1.66666666666666657415e-01, /* 0x3FC55555, 0x55555555 */
+pS1 = -3.25565818622400915405e-01, /* 0xBFD4D612, 0x03EB6F7D */
+pS2 =  2.01212532134862925881e-01, /* 0x3FC9C155, 0x0E884455 */
+pS3 = -4.00555345006794114027e-02, /* 0xBFA48228, 0xB5688F3B */
+pS4 =  7.91534994289814532176e-04, /* 0x3F49EFE0, 0x7501B288 */
+pS5 =  3.47933107596021167570e-05, /* 0x3F023DE1, 0x0DFDF709 */
+qS1 = -2.40339491173441421878e+00, /* 0xC0033A27, 0x1C8A2D4B */
+qS2 =  2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */
+qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */
+qS4 =  7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
+
+double
+__ieee754_asin(double x)
+{
+	double t=0.0,w,p,q,c,r,s;
+	int32_t hx,ix;
+	GET_HIGH_WORD(hx,x);
+	ix = hx&0x7fffffff;
+	if(ix>= 0x3ff00000) {		/* |x|>= 1 */
+	    u_int32_t lx;
+	    GET_LOW_WORD(lx,x);
+	    if(((ix-0x3ff00000)|lx)==0)
+		    /* asin(1)=+-pi/2 with inexact */
+		return x*pio2_hi+x*pio2_lo;	
+	    return (x-x)/(x-x);		/* asin(|x|>1) is NaN */   
+	} else if (ix<0x3fe00000) {	/* |x|<0.5 */
+	    if(ix<0x3e500000) {		/* if |x| < 2**-26 */
+		if(huge+x>one) return x;/* return x with inexact if x!=0*/
+	    }
+	    t = x*x;
+	    p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
+	    q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
+	    w = p/q;
+	    return x+x*w;
+	}
+	/* 1> |x|>= 0.5 */
+	w = one-fabs(x);
+	t = w*0.5;
+	p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
+	q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
+	s = sqrt(t);
+	if(ix>=0x3FEF3333) { 	/* if |x| > 0.975 */
+	    w = p/q;
+	    t = pio2_hi-(2.0*(s+s*w)-pio2_lo);
+	} else {
+	    w  = s;
+	    SET_LOW_WORD(w,0);
+	    c  = (t-w*w)/(s+w);
+	    r  = p/q;
+	    p  = 2.0*s*r-(pio2_lo-2.0*c);
+	    q  = pio4_hi-2.0*w;
+	    t  = pio4_hi-(p-q);
+	}    
+	if(hx>0) return t; else return -t;    
+}
+
+#if LDBL_MANT_DIG == 53
+__weak_reference(asin, asinl);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/e_asinf.c b/libm/upstream-freebsd/lib/msun/src/e_asinf.c
new file mode 100644
index 0000000..deaabb6
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_asinf.c
@@ -0,0 +1,65 @@
+/* e_asinf.c -- float version of e_asin.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static const float
+one =  1.0000000000e+00, /* 0x3F800000 */
+huge =  1.000e+30,
+	/* coefficient for R(x^2) */
+pS0 =  1.6666586697e-01,
+pS1 = -4.2743422091e-02,
+pS2 = -8.6563630030e-03,
+qS1 = -7.0662963390e-01;
+
+static const double
+pio2 =  1.570796326794896558e+00;
+
+float
+__ieee754_asinf(float x)
+{
+	double s;
+	float t,w,p,q;
+	int32_t hx,ix;
+	GET_FLOAT_WORD(hx,x);
+	ix = hx&0x7fffffff;
+	if(ix>=0x3f800000) {		/* |x| >= 1 */
+	    if(ix==0x3f800000)		/* |x| == 1 */
+		return x*pio2;		/* asin(+-1) = +-pi/2 with inexact */
+	    return (x-x)/(x-x);		/* asin(|x|>1) is NaN */
+	} else if (ix<0x3f000000) {	/* |x|<0.5 */
+	    if(ix<0x39800000) {		/* |x| < 2**-12 */
+		if(huge+x>one) return x;/* return x with inexact if x!=0*/
+	    }
+	    t = x*x;
+	    p = t*(pS0+t*(pS1+t*pS2));
+	    q = one+t*qS1;
+	    w = p/q;
+	    return x+x*w;
+	}
+	/* 1> |x|>= 0.5 */
+	w = one-fabsf(x);
+	t = w*(float)0.5;
+	p = t*(pS0+t*(pS1+t*pS2));
+	q = one+t*qS1;
+	s = sqrt(t);
+	w = p/q;
+	t = pio2-2.0*(s+s*w);
+	if(hx>0) return t; else return -t;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_asinl.c b/libm/upstream-freebsd/lib/msun/src/e_asinl.c
new file mode 100644
index 0000000..a85765f
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_asinl.c
@@ -0,0 +1,77 @@
+
+/* @(#)e_asin.c 1.3 95/01/18 */
+/* FreeBSD: head/lib/msun/src/e_asin.c 176451 2008-02-22 02:30:36Z das */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * See comments in e_asin.c.
+ * Converted to long double by David Schultz <das@FreeBSD.ORG>.
+ */
+
+#include <float.h>
+
+#include "invtrig.h"
+#include "math.h"
+#include "math_private.h"
+
+static const long double
+one =  1.00000000000000000000e+00,
+huge = 1.000e+300;
+
+long double
+asinl(long double x)
+{
+	union IEEEl2bits u;
+	long double t=0.0,w,p,q,c,r,s;
+	int16_t expsign, expt;
+	u.e = x;
+	expsign = u.xbits.expsign;
+	expt = expsign & 0x7fff;
+	if(expt >= BIAS) {		/* |x|>= 1 */
+		if(expt==BIAS && ((u.bits.manh&~LDBL_NBIT)|u.bits.manl)==0)
+		    /* asin(1)=+-pi/2 with inexact */
+		    return x*pio2_hi+x*pio2_lo;	
+	    return (x-x)/(x-x);		/* asin(|x|>1) is NaN */   
+	} else if (expt<BIAS-1) {	/* |x|<0.5 */
+	    if(expt<ASIN_LINEAR) {	/* if |x| is small, asinl(x)=x */
+		if(huge+x>one) return x;/* return x with inexact if x!=0*/
+	    }
+	    t = x*x;
+	    p = P(t);
+	    q = Q(t);
+	    w = p/q;
+	    return x+x*w;
+	}
+	/* 1> |x|>= 0.5 */
+	w = one-fabsl(x);
+	t = w*0.5;
+	p = P(t);
+	q = Q(t);
+	s = sqrtl(t);
+	if(u.bits.manh>=THRESH) { 	/* if |x| is close to 1 */
+	    w = p/q;
+	    t = pio2_hi-(2.0*(s+s*w)-pio2_lo);
+	} else {
+	    u.e = s;
+	    u.bits.manl = 0;
+	    w = u.e;
+	    c  = (t-w*w)/(s+w);
+	    r  = p/q;
+	    p  = 2.0*s*r-(pio2_lo-2.0*c);
+	    q  = pio4_hi-2.0*w;
+	    t  = pio4_hi-(p-q);
+	}    
+	if(expsign>0) return t; else return -t;    
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_atan2.c b/libm/upstream-freebsd/lib/msun/src/e_atan2.c
new file mode 100644
index 0000000..a4a985b
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_atan2.c
@@ -0,0 +1,129 @@
+
+/* @(#)e_atan2.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_atan2(y,x)
+ * Method :
+ *	1. Reduce y to positive by atan2(y,x)=-atan2(-y,x).
+ *	2. Reduce x to positive by (if x and y are unexceptional): 
+ *		ARG (x+iy) = arctan(y/x)   	   ... if x > 0,
+ *		ARG (x+iy) = pi - arctan[y/(-x)]   ... if x < 0,
+ *
+ * Special cases:
+ *
+ *	ATAN2((anything), NaN ) is NaN;
+ *	ATAN2(NAN , (anything) ) is NaN;
+ *	ATAN2(+-0, +(anything but NaN)) is +-0  ;
+ *	ATAN2(+-0, -(anything but NaN)) is +-pi ;
+ *	ATAN2(+-(anything but 0 and NaN), 0) is +-pi/2;
+ *	ATAN2(+-(anything but INF and NaN), +INF) is +-0 ;
+ *	ATAN2(+-(anything but INF and NaN), -INF) is +-pi;
+ *	ATAN2(+-INF,+INF ) is +-pi/4 ;
+ *	ATAN2(+-INF,-INF ) is +-3pi/4;
+ *	ATAN2(+-INF, (anything but,0,NaN, and INF)) is +-pi/2;
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following 
+ * constants. The decimal values may be used, provided that the 
+ * compiler will convert from decimal to binary accurately enough 
+ * to produce the hexadecimal values shown.
+ */
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static volatile double
+tiny  = 1.0e-300;
+static const double
+zero  = 0.0,
+pi_o_4  = 7.8539816339744827900E-01, /* 0x3FE921FB, 0x54442D18 */
+pi_o_2  = 1.5707963267948965580E+00, /* 0x3FF921FB, 0x54442D18 */
+pi      = 3.1415926535897931160E+00; /* 0x400921FB, 0x54442D18 */
+static volatile double
+pi_lo   = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */
+
+double
+__ieee754_atan2(double y, double x)
+{
+	double z;
+	int32_t k,m,hx,hy,ix,iy;
+	u_int32_t lx,ly;
+
+	EXTRACT_WORDS(hx,lx,x);
+	ix = hx&0x7fffffff;
+	EXTRACT_WORDS(hy,ly,y);
+	iy = hy&0x7fffffff;
+	if(((ix|((lx|-lx)>>31))>0x7ff00000)||
+	   ((iy|((ly|-ly)>>31))>0x7ff00000))	/* x or y is NaN */
+	   return x+y;
+	if((hx-0x3ff00000|lx)==0) return atan(y);   /* x=1.0 */
+	m = ((hy>>31)&1)|((hx>>30)&2);	/* 2*sign(x)+sign(y) */
+
+    /* when y = 0 */
+	if((iy|ly)==0) {
+	    switch(m) {
+		case 0: 
+		case 1: return y; 	/* atan(+-0,+anything)=+-0 */
+		case 2: return  pi+tiny;/* atan(+0,-anything) = pi */
+		case 3: return -pi-tiny;/* atan(-0,-anything) =-pi */
+	    }
+	}
+    /* when x = 0 */
+	if((ix|lx)==0) return (hy<0)?  -pi_o_2-tiny: pi_o_2+tiny;
+	    
+    /* when x is INF */
+	if(ix==0x7ff00000) {
+	    if(iy==0x7ff00000) {
+		switch(m) {
+		    case 0: return  pi_o_4+tiny;/* atan(+INF,+INF) */
+		    case 1: return -pi_o_4-tiny;/* atan(-INF,+INF) */
+		    case 2: return  3.0*pi_o_4+tiny;/*atan(+INF,-INF)*/
+		    case 3: return -3.0*pi_o_4-tiny;/*atan(-INF,-INF)*/
+		}
+	    } else {
+		switch(m) {
+		    case 0: return  zero  ;	/* atan(+...,+INF) */
+		    case 1: return -zero  ;	/* atan(-...,+INF) */
+		    case 2: return  pi+tiny  ;	/* atan(+...,-INF) */
+		    case 3: return -pi-tiny  ;	/* atan(-...,-INF) */
+		}
+	    }
+	}
+    /* when y is INF */
+	if(iy==0x7ff00000) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny;
+
+    /* compute y/x */
+	k = (iy-ix)>>20;
+	if(k > 60) {		 	/* |y/x| >  2**60 */
+	    z=pi_o_2+0.5*pi_lo;
+	    m&=1;
+	}
+	else if(hx<0&&k<-60) z=0.0; 	/* 0 > |y|/x > -2**-60 */
+	else z=atan(fabs(y/x));		/* safe to do y/x */
+	switch (m) {
+	    case 0: return       z  ;	/* atan(+,+) */
+	    case 1: return      -z  ;	/* atan(-,+) */
+	    case 2: return  pi-(z-pi_lo);/* atan(+,-) */
+	    default: /* case 3 */
+	    	    return  (z-pi_lo)-pi;/* atan(-,-) */
+	}
+}
+
+#if LDBL_MANT_DIG == 53
+__weak_reference(atan2, atan2l);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/e_atan2f.c b/libm/upstream-freebsd/lib/msun/src/e_atan2f.c
new file mode 100644
index 0000000..fc77bff
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_atan2f.c
@@ -0,0 +1,96 @@
+/* e_atan2f.c -- float version of e_atan2.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static volatile float
+tiny  = 1.0e-30;
+static const float
+zero  = 0.0,
+pi_o_4  = 7.8539818525e-01, /* 0x3f490fdb */
+pi_o_2  = 1.5707963705e+00, /* 0x3fc90fdb */
+pi      = 3.1415927410e+00; /* 0x40490fdb */
+static volatile float
+pi_lo   = -8.7422776573e-08; /* 0xb3bbbd2e */
+
+float
+__ieee754_atan2f(float y, float x)
+{
+	float z;
+	int32_t k,m,hx,hy,ix,iy;
+
+	GET_FLOAT_WORD(hx,x);
+	ix = hx&0x7fffffff;
+	GET_FLOAT_WORD(hy,y);
+	iy = hy&0x7fffffff;
+	if((ix>0x7f800000)||
+	   (iy>0x7f800000))	/* x or y is NaN */
+	   return x+y;
+	if(hx==0x3f800000) return atanf(y);   /* x=1.0 */
+	m = ((hy>>31)&1)|((hx>>30)&2);	/* 2*sign(x)+sign(y) */
+
+    /* when y = 0 */
+	if(iy==0) {
+	    switch(m) {
+		case 0:
+		case 1: return y; 	/* atan(+-0,+anything)=+-0 */
+		case 2: return  pi+tiny;/* atan(+0,-anything) = pi */
+		case 3: return -pi-tiny;/* atan(-0,-anything) =-pi */
+	    }
+	}
+    /* when x = 0 */
+	if(ix==0) return (hy<0)?  -pi_o_2-tiny: pi_o_2+tiny;
+
+    /* when x is INF */
+	if(ix==0x7f800000) {
+	    if(iy==0x7f800000) {
+		switch(m) {
+		    case 0: return  pi_o_4+tiny;/* atan(+INF,+INF) */
+		    case 1: return -pi_o_4-tiny;/* atan(-INF,+INF) */
+		    case 2: return  (float)3.0*pi_o_4+tiny;/*atan(+INF,-INF)*/
+		    case 3: return (float)-3.0*pi_o_4-tiny;/*atan(-INF,-INF)*/
+		}
+	    } else {
+		switch(m) {
+		    case 0: return  zero  ;	/* atan(+...,+INF) */
+		    case 1: return -zero  ;	/* atan(-...,+INF) */
+		    case 2: return  pi+tiny  ;	/* atan(+...,-INF) */
+		    case 3: return -pi-tiny  ;	/* atan(-...,-INF) */
+		}
+	    }
+	}
+    /* when y is INF */
+	if(iy==0x7f800000) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny;
+
+    /* compute y/x */
+	k = (iy-ix)>>23;
+	if(k > 26) {			/* |y/x| >  2**26 */
+	    z=pi_o_2+(float)0.5*pi_lo;
+	    m&=1;
+	}
+	else if(k<-26&&hx<0) z=0.0; 	/* 0 > |y|/x > -2**-26 */
+	else z=atanf(fabsf(y/x));	/* safe to do y/x */
+	switch (m) {
+	    case 0: return       z  ;	/* atan(+,+) */
+	    case 1: return      -z  ;	/* atan(-,+) */
+	    case 2: return  pi-(z-pi_lo);/* atan(+,-) */
+	    default: /* case 3 */
+	    	    return  (z-pi_lo)-pi;/* atan(-,-) */
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_atan2l.c b/libm/upstream-freebsd/lib/msun/src/e_atan2l.c
new file mode 100644
index 0000000..0326482
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_atan2l.c
@@ -0,0 +1,120 @@
+
+/* @(#)e_atan2.c 1.3 95/01/18 */
+/* FreeBSD: head/lib/msun/src/e_atan2.c 176451 2008-02-22 02:30:36Z das */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * See comments in e_atan2.c.
+ * Converted to long double by David Schultz <das@FreeBSD.ORG>.
+ */
+
+#include <float.h>
+
+#include "invtrig.h"
+#include "math.h"
+#include "math_private.h"
+
+static volatile long double
+tiny  = 1.0e-300;
+static const long double
+zero  = 0.0;
+
+#ifdef __i386__
+/* XXX Work around the fact that gcc truncates long double constants on i386 */
+static volatile double
+pi1 =  3.14159265358979311600e+00,	/*  0x1.921fb54442d18p+1  */
+pi2 =  1.22514845490862001043e-16;	/*  0x1.1a80000000000p-53 */
+#define	pi	((long double)pi1 + pi2)
+#else
+static const long double
+pi =  3.14159265358979323846264338327950280e+00L;
+#endif
+
+long double
+atan2l(long double y, long double x)
+{
+	union IEEEl2bits ux, uy;
+	long double z;
+	int32_t k,m;
+	int16_t exptx, expsignx, expty, expsigny;
+
+	uy.e = y;
+	expsigny = uy.xbits.expsign;
+	expty = expsigny & 0x7fff;
+	ux.e = x;
+	expsignx = ux.xbits.expsign;
+	exptx = expsignx & 0x7fff;
+
+	if ((exptx==BIAS+LDBL_MAX_EXP &&
+	     ((ux.bits.manh&~LDBL_NBIT)|ux.bits.manl)!=0) ||	/* x is NaN */
+	    (expty==BIAS+LDBL_MAX_EXP &&
+	     ((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl)!=0))	/* y is NaN */
+	    return x+y;
+	if (expsignx==BIAS && ((ux.bits.manh&~LDBL_NBIT)|ux.bits.manl)==0)
+	    return atanl(y);					/* x=1.0 */
+	m = ((expsigny>>15)&1)|((expsignx>>14)&2);	/* 2*sign(x)+sign(y) */
+
+    /* when y = 0 */
+	if(expty==0 && ((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl)==0) {
+	    switch(m) {
+		case 0: 
+		case 1: return y; 	/* atan(+-0,+anything)=+-0 */
+		case 2: return  pi+tiny;/* atan(+0,-anything) = pi */
+		case 3: return -pi-tiny;/* atan(-0,-anything) =-pi */
+	    }
+	}
+    /* when x = 0 */
+	if(exptx==0 && ((ux.bits.manh&~LDBL_NBIT)|ux.bits.manl)==0)
+	    return (expsigny<0)?  -pio2_hi-tiny: pio2_hi+tiny;
+
+    /* when x is INF */
+	if(exptx==BIAS+LDBL_MAX_EXP) {
+	    if(expty==BIAS+LDBL_MAX_EXP) {
+		switch(m) {
+		    case 0: return  pio2_hi*0.5+tiny;/* atan(+INF,+INF) */
+		    case 1: return -pio2_hi*0.5-tiny;/* atan(-INF,+INF) */
+		    case 2: return  1.5*pio2_hi+tiny;/*atan(+INF,-INF)*/
+		    case 3: return -1.5*pio2_hi-tiny;/*atan(-INF,-INF)*/
+		}
+	    } else {
+		switch(m) {
+		    case 0: return  zero  ;	/* atan(+...,+INF) */
+		    case 1: return -zero  ;	/* atan(-...,+INF) */
+		    case 2: return  pi+tiny  ;	/* atan(+...,-INF) */
+		    case 3: return -pi-tiny  ;	/* atan(-...,-INF) */
+		}
+	    }
+	}
+    /* when y is INF */
+	if(expty==BIAS+LDBL_MAX_EXP)
+	    return (expsigny<0)? -pio2_hi-tiny: pio2_hi+tiny;
+
+    /* compute y/x */
+	k = expty-exptx;
+	if(k > LDBL_MANT_DIG+2) {			/* |y/x| huge */
+	    z=pio2_hi+pio2_lo;
+	    m&=1;
+	}
+	else if(expsignx<0&&k<-LDBL_MANT_DIG-2) z=0.0; 	/* |y/x| tiny, x<0 */
+	else z=atanl(fabsl(y/x));		/* safe to do y/x */
+	switch (m) {
+	    case 0: return       z  ;	/* atan(+,+) */
+	    case 1: return      -z  ;	/* atan(-,+) */
+	    case 2: return  pi-(z-pi_lo);/* atan(+,-) */
+	    default: /* case 3 */
+	    	    return  (z-pi_lo)-pi;/* atan(-,-) */
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_atanh.c b/libm/upstream-freebsd/lib/msun/src/e_atanh.c
new file mode 100644
index 0000000..ab8a2e1
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_atanh.c
@@ -0,0 +1,62 @@
+
+/* @(#)e_atanh.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_atanh(x)
+ * Method :
+ *    1.Reduced x to positive by atanh(-x) = -atanh(x)
+ *    2.For x>=0.5
+ *                  1              2x                          x
+ *	atanh(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------)
+ *                  2             1 - x                      1 - x
+ *	
+ * 	For x<0.5
+ *	atanh(x) = 0.5*log1p(2x+2x*x/(1-x))
+ *
+ * Special cases:
+ *	atanh(x) is NaN if |x| > 1 with signal;
+ *	atanh(NaN) is that NaN with no signal;
+ *	atanh(+-1) is +-INF with signal.
+ *
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+static const double one = 1.0, huge = 1e300;
+static const double zero = 0.0;
+
+double
+__ieee754_atanh(double x)
+{
+	double t;
+	int32_t hx,ix;
+	u_int32_t lx;
+	EXTRACT_WORDS(hx,lx,x);
+	ix = hx&0x7fffffff;
+	if ((ix|((lx|(-lx))>>31))>0x3ff00000) /* |x|>1 */
+	    return (x-x)/(x-x);
+	if(ix==0x3ff00000) 
+	    return x/zero;
+	if(ix<0x3e300000&&(huge+x)>zero) return x;	/* x<2**-28 */
+	SET_HIGH_WORD(x,ix);
+	if(ix<0x3fe00000) {		/* x < 0.5 */
+	    t = x+x;
+	    t = 0.5*log1p(t+t*x/(one-x));
+	} else 
+	    t = 0.5*log1p((x+x)/(one-x));
+	if(hx>=0) return t; else return -t;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_atanhf.c b/libm/upstream-freebsd/lib/msun/src/e_atanhf.c
new file mode 100644
index 0000000..4bd6a8f
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_atanhf.c
@@ -0,0 +1,45 @@
+/* e_atanhf.c -- float version of e_atanh.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static const float one = 1.0, huge = 1e30;
+
+static const float zero = 0.0;
+
+float
+__ieee754_atanhf(float x)
+{
+	float t;
+	int32_t hx,ix;
+	GET_FLOAT_WORD(hx,x);
+	ix = hx&0x7fffffff;
+	if (ix>0x3f800000) 		/* |x|>1 */
+	    return (x-x)/(x-x);
+	if(ix==0x3f800000)
+	    return x/zero;
+	if(ix<0x31800000&&(huge+x)>zero) return x;	/* x<2**-28 */
+	SET_FLOAT_WORD(x,ix);
+	if(ix<0x3f000000) {		/* x < 0.5 */
+	    t = x+x;
+	    t = (float)0.5*log1pf(t+t*x/(one-x));
+	} else
+	    t = (float)0.5*log1pf((x+x)/(one-x));
+	if(hx>=0) return t; else return -t;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_cosh.c b/libm/upstream-freebsd/lib/msun/src/e_cosh.c
new file mode 100644
index 0000000..a363695
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_cosh.c
@@ -0,0 +1,79 @@
+
+/* @(#)e_cosh.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_cosh(x)
+ * Method : 
+ * mathematically cosh(x) if defined to be (exp(x)+exp(-x))/2
+ *	1. Replace x by |x| (cosh(x) = cosh(-x)). 
+ *	2. 
+ *		                                        [ exp(x) - 1 ]^2 
+ *	    0        <= x <= ln2/2  :  cosh(x) := 1 + -------------------
+ *			       			           2*exp(x)
+ *
+ *		                                  exp(x) +  1/exp(x)
+ *	    ln2/2    <= x <= 22     :  cosh(x) := -------------------
+ *			       			          2
+ *	    22       <= x <= lnovft :  cosh(x) := exp(x)/2 
+ *	    lnovft   <= x <= ln2ovft:  cosh(x) := exp(x/2)/2 * exp(x/2)
+ *	    ln2ovft  <  x	    :  cosh(x) := huge*huge (overflow)
+ *
+ * Special cases:
+ *	cosh(x) is |x| if x is +INF, -INF, or NaN.
+ *	only cosh(0)=1 is exact for finite x.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+static const double one = 1.0, half=0.5, huge = 1.0e300;
+
+double
+__ieee754_cosh(double x)
+{
+	double t,w;
+	int32_t ix;
+
+    /* High word of |x|. */
+	GET_HIGH_WORD(ix,x);
+	ix &= 0x7fffffff;
+
+    /* x is INF or NaN */
+	if(ix>=0x7ff00000) return x*x;	
+
+    /* |x| in [0,0.5*ln2], return 1+expm1(|x|)^2/(2*exp(|x|)) */
+	if(ix<0x3fd62e43) {
+	    t = expm1(fabs(x));
+	    w = one+t;
+	    if (ix<0x3c800000) return w;	/* cosh(tiny) = 1 */
+	    return one+(t*t)/(w+w);
+	}
+
+    /* |x| in [0.5*ln2,22], return (exp(|x|)+1/exp(|x|)/2; */
+	if (ix < 0x40360000) {
+		t = __ieee754_exp(fabs(x));
+		return half*t+half/t;
+	}
+
+    /* |x| in [22, log(maxdouble)] return half*exp(|x|) */
+	if (ix < 0x40862E42)  return half*__ieee754_exp(fabs(x));
+
+    /* |x| in [log(maxdouble), overflowthresold] */
+	if (ix<=0x408633CE)
+	    return __ldexp_exp(fabs(x), -1);
+
+    /* |x| > overflowthresold, cosh(x) overflow */
+	return huge*huge;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_coshf.c b/libm/upstream-freebsd/lib/msun/src/e_coshf.c
new file mode 100644
index 0000000..95a0d6e
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_coshf.c
@@ -0,0 +1,59 @@
+/* e_coshf.c -- float version of e_cosh.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static const float one = 1.0, half=0.5, huge = 1.0e30;
+
+float
+__ieee754_coshf(float x)
+{
+	float t,w;
+	int32_t ix;
+
+	GET_FLOAT_WORD(ix,x);
+	ix &= 0x7fffffff;
+
+    /* x is INF or NaN */
+	if(ix>=0x7f800000) return x*x;
+
+    /* |x| in [0,0.5*ln2], return 1+expm1(|x|)^2/(2*exp(|x|)) */
+	if(ix<0x3eb17218) {
+	    t = expm1f(fabsf(x));
+	    w = one+t;
+	    if (ix<0x39800000) return one;	/* cosh(tiny) = 1 */
+	    return one+(t*t)/(w+w);
+	}
+
+    /* |x| in [0.5*ln2,9], return (exp(|x|)+1/exp(|x|))/2; */
+	if (ix < 0x41100000) {
+		t = __ieee754_expf(fabsf(x));
+		return half*t+half/t;
+	}
+
+    /* |x| in [9, log(maxfloat)] return half*exp(|x|) */
+	if (ix < 0x42b17217)  return half*__ieee754_expf(fabsf(x));
+
+    /* |x| in [log(maxfloat), overflowthresold] */
+	if (ix<=0x42b2d4fc)
+	    return __ldexp_expf(fabsf(x), -1);
+
+    /* |x| > overflowthresold, cosh(x) overflow */
+	return huge*huge;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_exp.c b/libm/upstream-freebsd/lib/msun/src/e_exp.c
new file mode 100644
index 0000000..e432bc8
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_exp.c
@@ -0,0 +1,164 @@
+
+/* @(#)e_exp.c 1.6 04/04/22 */
+/*
+ * ====================================================
+ * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_exp(x)
+ * Returns the exponential of x.
+ *
+ * Method
+ *   1. Argument reduction:
+ *      Reduce x to an r so that |r| <= 0.5*ln2 ~ 0.34658.
+ *	Given x, find r and integer k such that
+ *
+ *               x = k*ln2 + r,  |r| <= 0.5*ln2.  
+ *
+ *      Here r will be represented as r = hi-lo for better 
+ *	accuracy.
+ *
+ *   2. Approximation of exp(r) by a special rational function on
+ *	the interval [0,0.34658]:
+ *	Write
+ *	    R(r**2) = r*(exp(r)+1)/(exp(r)-1) = 2 + r*r/6 - r**4/360 + ...
+ *      We use a special Remes algorithm on [0,0.34658] to generate 
+ * 	a polynomial of degree 5 to approximate R. The maximum error 
+ *	of this polynomial approximation is bounded by 2**-59. In
+ *	other words,
+ *	    R(z) ~ 2.0 + P1*z + P2*z**2 + P3*z**3 + P4*z**4 + P5*z**5
+ *  	(where z=r*r, and the values of P1 to P5 are listed below)
+ *	and
+ *	    |                  5          |     -59
+ *	    | 2.0+P1*z+...+P5*z   -  R(z) | <= 2 
+ *	    |                             |
+ *	The computation of exp(r) thus becomes
+ *                             2*r
+ *		exp(r) = 1 + -------
+ *		              R - r
+ *                                 r*R1(r)	
+ *		       = 1 + r + ----------- (for better accuracy)
+ *		                  2 - R1(r)
+ *	where
+ *			         2       4             10
+ *		R1(r) = r - (P1*r  + P2*r  + ... + P5*r   ).
+ *	
+ *   3. Scale back to obtain exp(x):
+ *	From step 1, we have
+ *	   exp(x) = 2^k * exp(r)
+ *
+ * Special cases:
+ *	exp(INF) is INF, exp(NaN) is NaN;
+ *	exp(-INF) is 0, and
+ *	for finite argument, only exp(0)=1 is exact.
+ *
+ * Accuracy:
+ *	according to an error analysis, the error is always less than
+ *	1 ulp (unit in the last place).
+ *
+ * Misc. info.
+ *	For IEEE double 
+ *	    if x >  7.09782712893383973096e+02 then exp(x) overflow
+ *	    if x < -7.45133219101941108420e+02 then exp(x) underflow
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following 
+ * constants. The decimal values may be used, provided that the 
+ * compiler will convert from decimal to binary accurately enough
+ * to produce the hexadecimal values shown.
+ */
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const double
+one	= 1.0,
+halF[2]	= {0.5,-0.5,},
+huge	= 1.0e+300,
+o_threshold=  7.09782712893383973096e+02,  /* 0x40862E42, 0xFEFA39EF */
+u_threshold= -7.45133219101941108420e+02,  /* 0xc0874910, 0xD52D3051 */
+ln2HI[2]   ={ 6.93147180369123816490e-01,  /* 0x3fe62e42, 0xfee00000 */
+	     -6.93147180369123816490e-01,},/* 0xbfe62e42, 0xfee00000 */
+ln2LO[2]   ={ 1.90821492927058770002e-10,  /* 0x3dea39ef, 0x35793c76 */
+	     -1.90821492927058770002e-10,},/* 0xbdea39ef, 0x35793c76 */
+invln2 =  1.44269504088896338700e+00, /* 0x3ff71547, 0x652b82fe */
+P1   =  1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */
+P2   = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */
+P3   =  6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
+P4   = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
+P5   =  4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
+
+static volatile double
+twom1000= 9.33263618503218878990e-302;     /* 2**-1000=0x01700000,0*/
+
+double
+__ieee754_exp(double x)	/* default IEEE double exp */
+{
+	double y,hi=0.0,lo=0.0,c,t,twopk;
+	int32_t k=0,xsb;
+	u_int32_t hx;
+
+	GET_HIGH_WORD(hx,x);
+	xsb = (hx>>31)&1;		/* sign bit of x */
+	hx &= 0x7fffffff;		/* high word of |x| */
+
+    /* filter out non-finite argument */
+	if(hx >= 0x40862E42) {			/* if |x|>=709.78... */
+            if(hx>=0x7ff00000) {
+	        u_int32_t lx;
+		GET_LOW_WORD(lx,x);
+		if(((hx&0xfffff)|lx)!=0)
+		     return x+x; 		/* NaN */
+		else return (xsb==0)? x:0.0;	/* exp(+-inf)={inf,0} */
+	    }
+	    if(x > o_threshold) return huge*huge; /* overflow */
+	    if(x < u_threshold) return twom1000*twom1000; /* underflow */
+	}
+
+    /* argument reduction */
+	if(hx > 0x3fd62e42) {		/* if  |x| > 0.5 ln2 */ 
+	    if(hx < 0x3FF0A2B2) {	/* and |x| < 1.5 ln2 */
+		hi = x-ln2HI[xsb]; lo=ln2LO[xsb]; k = 1-xsb-xsb;
+	    } else {
+		k  = (int)(invln2*x+halF[xsb]);
+		t  = k;
+		hi = x - t*ln2HI[0];	/* t*ln2HI is exact here */
+		lo = t*ln2LO[0];
+	    }
+	    STRICT_ASSIGN(double, x, hi - lo);
+	} 
+	else if(hx < 0x3e300000)  {	/* when |x|<2**-28 */
+	    if(huge+x>one) return one+x;/* trigger inexact */
+	}
+	else k = 0;
+
+    /* x is now in primary range */
+	t  = x*x;
+	if(k >= -1021)
+	    INSERT_WORDS(twopk,0x3ff00000+(k<<20), 0);
+	else
+	    INSERT_WORDS(twopk,0x3ff00000+((k+1000)<<20), 0);
+	c  = x - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
+	if(k==0) 	return one-((x*c)/(c-2.0)-x); 
+	else 		y = one-((lo-(x*c)/(2.0-c))-hi);
+	if(k >= -1021) {
+	    if (k==1024) return y*2.0*0x1p1023;
+	    return y*twopk;
+	} else {
+	    return y*twopk*twom1000;
+	}
+}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(exp, expl);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/e_expf.c b/libm/upstream-freebsd/lib/msun/src/e_expf.c
new file mode 100644
index 0000000..a479076
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_expf.c
@@ -0,0 +1,97 @@
+/* e_expf.c -- float version of e_exp.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const float
+one	= 1.0,
+halF[2]	= {0.5,-0.5,},
+huge	= 1.0e+30,
+o_threshold=  8.8721679688e+01,  /* 0x42b17180 */
+u_threshold= -1.0397208405e+02,  /* 0xc2cff1b5 */
+ln2HI[2]   ={ 6.9314575195e-01,		/* 0x3f317200 */
+	     -6.9314575195e-01,},	/* 0xbf317200 */
+ln2LO[2]   ={ 1.4286067653e-06,  	/* 0x35bfbe8e */
+	     -1.4286067653e-06,},	/* 0xb5bfbe8e */
+invln2 =  1.4426950216e+00, 		/* 0x3fb8aa3b */
+/*
+ * Domain [-0.34568, 0.34568], range ~[-4.278e-9, 4.447e-9]:
+ * |x*(exp(x)+1)/(exp(x)-1) - p(x)| < 2**-27.74
+ */
+P1 =  1.6666625440e-1,		/*  0xaaaa8f.0p-26 */
+P2 = -2.7667332906e-3;		/* -0xb55215.0p-32 */
+
+static volatile float twom100 = 7.8886090522e-31;      /* 2**-100=0x0d800000 */
+
+float
+__ieee754_expf(float x)
+{
+	float y,hi=0.0,lo=0.0,c,t,twopk;
+	int32_t k=0,xsb;
+	u_int32_t hx;
+
+	GET_FLOAT_WORD(hx,x);
+	xsb = (hx>>31)&1;		/* sign bit of x */
+	hx &= 0x7fffffff;		/* high word of |x| */
+
+    /* filter out non-finite argument */
+	if(hx >= 0x42b17218) {			/* if |x|>=88.721... */
+	    if(hx>0x7f800000)
+		 return x+x;	 		/* NaN */
+            if(hx==0x7f800000)
+		return (xsb==0)? x:0.0;		/* exp(+-inf)={inf,0} */
+	    if(x > o_threshold) return huge*huge; /* overflow */
+	    if(x < u_threshold) return twom100*twom100; /* underflow */
+	}
+
+    /* argument reduction */
+	if(hx > 0x3eb17218) {		/* if  |x| > 0.5 ln2 */
+	    if(hx < 0x3F851592) {	/* and |x| < 1.5 ln2 */
+		hi = x-ln2HI[xsb]; lo=ln2LO[xsb]; k = 1-xsb-xsb;
+	    } else {
+		k  = invln2*x+halF[xsb];
+		t  = k;
+		hi = x - t*ln2HI[0];	/* t*ln2HI is exact here */
+		lo = t*ln2LO[0];
+	    }
+	    STRICT_ASSIGN(float, x, hi - lo);
+	}
+	else if(hx < 0x39000000)  {	/* when |x|<2**-14 */
+	    if(huge+x>one) return one+x;/* trigger inexact */
+	}
+	else k = 0;
+
+    /* x is now in primary range */
+	t  = x*x;
+	if(k >= -125)
+	    SET_FLOAT_WORD(twopk,0x3f800000+(k<<23));
+	else
+	    SET_FLOAT_WORD(twopk,0x3f800000+((k+100)<<23));
+	c  = x - t*(P1+t*P2);
+	if(k==0) 	return one-((x*c)/(c-(float)2.0)-x);
+	else 		y = one-((lo-(x*c)/((float)2.0-c))-hi);
+	if(k >= -125) {
+	    if(k==128) return y*2.0F*0x1p127F;
+	    return y*twopk;
+	} else {
+	    return y*twopk*twom100;
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_fmod.c b/libm/upstream-freebsd/lib/msun/src/e_fmod.c
new file mode 100644
index 0000000..720aa03
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_fmod.c
@@ -0,0 +1,132 @@
+
+/* @(#)e_fmod.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* 
+ * __ieee754_fmod(x,y)
+ * Return x mod y in exact arithmetic
+ * Method: shift and subtract
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+static const double one = 1.0, Zero[] = {0.0, -0.0,};
+
+double
+__ieee754_fmod(double x, double y)
+{
+	int32_t n,hx,hy,hz,ix,iy,sx,i;
+	u_int32_t lx,ly,lz;
+
+	EXTRACT_WORDS(hx,lx,x);
+	EXTRACT_WORDS(hy,ly,y);
+	sx = hx&0x80000000;		/* sign of x */
+	hx ^=sx;		/* |x| */
+	hy &= 0x7fffffff;	/* |y| */
+
+    /* purge off exception values */
+	if((hy|ly)==0||(hx>=0x7ff00000)||	/* y=0,or x not finite */
+	  ((hy|((ly|-ly)>>31))>0x7ff00000))	/* or y is NaN */
+	    return (x*y)/(x*y);
+	if(hx<=hy) {
+	    if((hx<hy)||(lx<ly)) return x;	/* |x|<|y| return x */
+	    if(lx==ly) 
+		return Zero[(u_int32_t)sx>>31];	/* |x|=|y| return x*0*/
+	}
+
+    /* determine ix = ilogb(x) */
+	if(hx<0x00100000) {	/* subnormal x */
+	    if(hx==0) {
+		for (ix = -1043, i=lx; i>0; i<<=1) ix -=1;
+	    } else {
+		for (ix = -1022,i=(hx<<11); i>0; i<<=1) ix -=1;
+	    }
+	} else ix = (hx>>20)-1023;
+
+    /* determine iy = ilogb(y) */
+	if(hy<0x00100000) {	/* subnormal y */
+	    if(hy==0) {
+		for (iy = -1043, i=ly; i>0; i<<=1) iy -=1;
+	    } else {
+		for (iy = -1022,i=(hy<<11); i>0; i<<=1) iy -=1;
+	    }
+	} else iy = (hy>>20)-1023;
+
+    /* set up {hx,lx}, {hy,ly} and align y to x */
+	if(ix >= -1022) 
+	    hx = 0x00100000|(0x000fffff&hx);
+	else {		/* subnormal x, shift x to normal */
+	    n = -1022-ix;
+	    if(n<=31) {
+	        hx = (hx<<n)|(lx>>(32-n));
+	        lx <<= n;
+	    } else {
+		hx = lx<<(n-32);
+		lx = 0;
+	    }
+	}
+	if(iy >= -1022) 
+	    hy = 0x00100000|(0x000fffff&hy);
+	else {		/* subnormal y, shift y to normal */
+	    n = -1022-iy;
+	    if(n<=31) {
+	        hy = (hy<<n)|(ly>>(32-n));
+	        ly <<= n;
+	    } else {
+		hy = ly<<(n-32);
+		ly = 0;
+	    }
+	}
+
+    /* fix point fmod */
+	n = ix - iy;
+	while(n--) {
+	    hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
+	    if(hz<0){hx = hx+hx+(lx>>31); lx = lx+lx;}
+	    else {
+	    	if((hz|lz)==0) 		/* return sign(x)*0 */
+		    return Zero[(u_int32_t)sx>>31];
+	    	hx = hz+hz+(lz>>31); lx = lz+lz;
+	    }
+	}
+	hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
+	if(hz>=0) {hx=hz;lx=lz;}
+
+    /* convert back to floating value and restore the sign */
+	if((hx|lx)==0) 			/* return sign(x)*0 */
+	    return Zero[(u_int32_t)sx>>31];
+	while(hx<0x00100000) {		/* normalize x */
+	    hx = hx+hx+(lx>>31); lx = lx+lx;
+	    iy -= 1;
+	}
+	if(iy>= -1022) {	/* normalize output */
+	    hx = ((hx-0x00100000)|((iy+1023)<<20));
+	    INSERT_WORDS(x,hx|sx,lx);
+	} else {		/* subnormal output */
+	    n = -1022 - iy;
+	    if(n<=20) {
+		lx = (lx>>n)|((u_int32_t)hx<<(32-n));
+		hx >>= n;
+	    } else if (n<=31) {
+		lx = (hx<<(32-n))|(lx>>n); hx = sx;
+	    } else {
+		lx = hx>>(n-32); hx = sx;
+	    }
+	    INSERT_WORDS(x,hx|sx,lx);
+	    x *= one;		/* create necessary signal */
+	}
+	return x;		/* exact output */
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_fmodf.c b/libm/upstream-freebsd/lib/msun/src/e_fmodf.c
new file mode 100644
index 0000000..52ce373
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_fmodf.c
@@ -0,0 +1,104 @@
+/* e_fmodf.c -- float version of e_fmod.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * __ieee754_fmodf(x,y)
+ * Return x mod y in exact arithmetic
+ * Method: shift and subtract
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+static const float one = 1.0, Zero[] = {0.0, -0.0,};
+
+float
+__ieee754_fmodf(float x, float y)
+{
+	int32_t n,hx,hy,hz,ix,iy,sx,i;
+
+	GET_FLOAT_WORD(hx,x);
+	GET_FLOAT_WORD(hy,y);
+	sx = hx&0x80000000;		/* sign of x */
+	hx ^=sx;		/* |x| */
+	hy &= 0x7fffffff;	/* |y| */
+
+    /* purge off exception values */
+	if(hy==0||(hx>=0x7f800000)||		/* y=0,or x not finite */
+	   (hy>0x7f800000))			/* or y is NaN */
+	    return (x*y)/(x*y);
+	if(hx<hy) return x;			/* |x|<|y| return x */
+	if(hx==hy)
+	    return Zero[(u_int32_t)sx>>31];	/* |x|=|y| return x*0*/
+
+    /* determine ix = ilogb(x) */
+	if(hx<0x00800000) {	/* subnormal x */
+	    for (ix = -126,i=(hx<<8); i>0; i<<=1) ix -=1;
+	} else ix = (hx>>23)-127;
+
+    /* determine iy = ilogb(y) */
+	if(hy<0x00800000) {	/* subnormal y */
+	    for (iy = -126,i=(hy<<8); i>=0; i<<=1) iy -=1;
+	} else iy = (hy>>23)-127;
+
+    /* set up {hx,lx}, {hy,ly} and align y to x */
+	if(ix >= -126)
+	    hx = 0x00800000|(0x007fffff&hx);
+	else {		/* subnormal x, shift x to normal */
+	    n = -126-ix;
+	    hx = hx<<n;
+	}
+	if(iy >= -126)
+	    hy = 0x00800000|(0x007fffff&hy);
+	else {		/* subnormal y, shift y to normal */
+	    n = -126-iy;
+	    hy = hy<<n;
+	}
+
+    /* fix point fmod */
+	n = ix - iy;
+	while(n--) {
+	    hz=hx-hy;
+	    if(hz<0){hx = hx+hx;}
+	    else {
+	    	if(hz==0) 		/* return sign(x)*0 */
+		    return Zero[(u_int32_t)sx>>31];
+	    	hx = hz+hz;
+	    }
+	}
+	hz=hx-hy;
+	if(hz>=0) {hx=hz;}
+
+    /* convert back to floating value and restore the sign */
+	if(hx==0) 			/* return sign(x)*0 */
+	    return Zero[(u_int32_t)sx>>31];
+	while(hx<0x00800000) {		/* normalize x */
+	    hx = hx+hx;
+	    iy -= 1;
+	}
+	if(iy>= -126) {		/* normalize output */
+	    hx = ((hx-0x00800000)|((iy+127)<<23));
+	    SET_FLOAT_WORD(x,hx|sx);
+	} else {		/* subnormal output */
+	    n = -126 - iy;
+	    hx >>= n;
+	    SET_FLOAT_WORD(x,hx|sx);
+	    x *= one;		/* create necessary signal */
+	}
+	return x;		/* exact output */
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_fmodl.c b/libm/upstream-freebsd/lib/msun/src/e_fmodl.c
new file mode 100644
index 0000000..e315f76
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_fmodl.c
@@ -0,0 +1,149 @@
+/* @(#)e_fmod.c 1.3 95/01/18 */
+/*-
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <float.h>
+#include <stdint.h>
+
+#include "fpmath.h"
+#include "math.h"
+#include "math_private.h"
+
+#define	BIAS (LDBL_MAX_EXP - 1)
+
+#if LDBL_MANL_SIZE > 32
+typedef	uint64_t manl_t;
+#else
+typedef	uint32_t manl_t;
+#endif
+
+#if LDBL_MANH_SIZE > 32
+typedef	uint64_t manh_t;
+#else
+typedef	uint32_t manh_t;
+#endif
+
+/*
+ * These macros add and remove an explicit integer bit in front of the
+ * fractional mantissa, if the architecture doesn't have such a bit by
+ * default already.
+ */
+#ifdef LDBL_IMPLICIT_NBIT
+#define	SET_NBIT(hx)	((hx) | (1ULL << LDBL_MANH_SIZE))
+#define	HFRAC_BITS	LDBL_MANH_SIZE
+#else
+#define	SET_NBIT(hx)	(hx)
+#define	HFRAC_BITS	(LDBL_MANH_SIZE - 1)
+#endif
+
+#define	MANL_SHIFT	(LDBL_MANL_SIZE - 1)
+
+static const long double one = 1.0, Zero[] = {0.0, -0.0,};
+
+/*
+ * fmodl(x,y)
+ * Return x mod y in exact arithmetic
+ * Method: shift and subtract
+ *
+ * Assumptions:
+ * - The low part of the mantissa fits in a manl_t exactly.
+ * - The high part of the mantissa fits in an int64_t with enough room
+ *   for an explicit integer bit in front of the fractional bits.
+ */
+long double
+fmodl(long double x, long double y)
+{
+	union IEEEl2bits ux, uy;
+	int64_t hx,hz;	/* We need a carry bit even if LDBL_MANH_SIZE is 32. */
+	manh_t hy;
+	manl_t lx,ly,lz;
+	int ix,iy,n,sx;
+
+	ux.e = x;
+	uy.e = y;
+	sx = ux.bits.sign;
+
+    /* purge off exception values */
+	if((uy.bits.exp|uy.bits.manh|uy.bits.manl)==0 || /* y=0 */
+	   (ux.bits.exp == BIAS + LDBL_MAX_EXP) ||	 /* or x not finite */
+	   (uy.bits.exp == BIAS + LDBL_MAX_EXP &&
+	    ((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl)!=0)) /* or y is NaN */
+	    return (x*y)/(x*y);
+	if(ux.bits.exp<=uy.bits.exp) {
+	    if((ux.bits.exp<uy.bits.exp) ||
+	       (ux.bits.manh<=uy.bits.manh &&
+		(ux.bits.manh<uy.bits.manh ||
+		 ux.bits.manl<uy.bits.manl))) {
+		return x;		/* |x|<|y| return x or x-y */
+	    }
+	    if(ux.bits.manh==uy.bits.manh && ux.bits.manl==uy.bits.manl) {
+		return Zero[sx];	/* |x|=|y| return x*0*/
+	    }
+	}
+
+    /* determine ix = ilogb(x) */
+	if(ux.bits.exp == 0) {	/* subnormal x */
+	    ux.e *= 0x1.0p512;
+	    ix = ux.bits.exp - (BIAS + 512);
+	} else {
+	    ix = ux.bits.exp - BIAS;
+	}
+
+    /* determine iy = ilogb(y) */
+	if(uy.bits.exp == 0) {	/* subnormal y */
+	    uy.e *= 0x1.0p512;
+	    iy = uy.bits.exp - (BIAS + 512);
+	} else {
+	    iy = uy.bits.exp - BIAS;
+	}
+
+    /* set up {hx,lx}, {hy,ly} and align y to x */
+	hx = SET_NBIT(ux.bits.manh);
+	hy = SET_NBIT(uy.bits.manh);
+	lx = ux.bits.manl;
+	ly = uy.bits.manl;
+
+    /* fix point fmod */
+	n = ix - iy;
+
+	while(n--) {
+	    hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
+	    if(hz<0){hx = hx+hx+(lx>>MANL_SHIFT); lx = lx+lx;}
+	    else {
+		if ((hz|lz)==0)		/* return sign(x)*0 */
+		    return Zero[sx];
+		hx = hz+hz+(lz>>MANL_SHIFT); lx = lz+lz;
+	    }
+	}
+	hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
+	if(hz>=0) {hx=hz;lx=lz;}
+
+    /* convert back to floating value and restore the sign */
+	if((hx|lx)==0)			/* return sign(x)*0 */
+	    return Zero[sx];
+	while(hx<(1ULL<<HFRAC_BITS)) {	/* normalize x */
+	    hx = hx+hx+(lx>>MANL_SHIFT); lx = lx+lx;
+	    iy -= 1;
+	}
+	ux.bits.manh = hx; /* The mantissa is truncated here if needed. */
+	ux.bits.manl = lx;
+	if (iy < LDBL_MIN_EXP) {
+	    ux.bits.exp = iy + (BIAS + 512);
+	    ux.e *= 0x1p-512;
+	} else {
+	    ux.bits.exp = iy + BIAS;
+	}
+	x = ux.e * one;		/* create necessary signal */
+	return x;		/* exact output */
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_gamma.c b/libm/upstream-freebsd/lib/msun/src/e_gamma.c
new file mode 100644
index 0000000..28fb5cc
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_gamma.c
@@ -0,0 +1,33 @@
+
+/* @(#)e_gamma.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_gamma(x)
+ * Return the logarithm of the Gamma function of x.
+ *
+ * Method: call __ieee754_gamma_r
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+extern int signgam;
+
+double
+__ieee754_gamma(double x)
+{
+	return __ieee754_gamma_r(x,&signgam);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_gamma_r.c b/libm/upstream-freebsd/lib/msun/src/e_gamma_r.c
new file mode 100644
index 0000000..2c423dc
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_gamma_r.c
@@ -0,0 +1,32 @@
+
+/* @(#)e_gamma_r.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_gamma_r(x, signgamp)
+ * Reentrant version of the logarithm of the Gamma function 
+ * with user provide pointer for the sign of Gamma(x). 
+ *
+ * Method: See __ieee754_lgamma_r
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+double
+__ieee754_gamma_r(double x, int *signgamp)
+{
+	return __ieee754_lgamma_r(x,signgamp);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_gammaf.c b/libm/upstream-freebsd/lib/msun/src/e_gammaf.c
new file mode 100644
index 0000000..c1b1668
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_gammaf.c
@@ -0,0 +1,34 @@
+/* e_gammaf.c -- float version of e_gamma.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_gammaf(x)
+ * Return the logarithm of the Gamma function of x.
+ *
+ * Method: call __ieee754_gammaf_r
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+extern int signgam;
+
+float
+__ieee754_gammaf(float x)
+{
+	return __ieee754_gammaf_r(x,&signgam);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_gammaf_r.c b/libm/upstream-freebsd/lib/msun/src/e_gammaf_r.c
new file mode 100644
index 0000000..9d7831b
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_gammaf_r.c
@@ -0,0 +1,33 @@
+/* e_gammaf_r.c -- float version of e_gamma_r.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_gammaf_r(x, signgamp)
+ * Reentrant version of the logarithm of the Gamma function
+ * with user provide pointer for the sign of Gamma(x).
+ *
+ * Method: See __ieee754_lgammaf_r
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+float
+__ieee754_gammaf_r(float x, int *signgamp)
+{
+	return __ieee754_lgammaf_r(x,signgamp);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_hypot.c b/libm/upstream-freebsd/lib/msun/src/e_hypot.c
new file mode 100644
index 0000000..2398e98
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_hypot.c
@@ -0,0 +1,131 @@
+
+/* @(#)e_hypot.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_hypot(x,y)
+ *
+ * Method :                  
+ *	If (assume round-to-nearest) z=x*x+y*y 
+ *	has error less than sqrt(2)/2 ulp, than 
+ *	sqrt(z) has error less than 1 ulp (exercise).
+ *
+ *	So, compute sqrt(x*x+y*y) with some care as 
+ *	follows to get the error below 1 ulp:
+ *
+ *	Assume x>y>0;
+ *	(if possible, set rounding to round-to-nearest)
+ *	1. if x > 2y  use
+ *		x1*x1+(y*y+(x2*(x+x1))) for x*x+y*y
+ *	where x1 = x with lower 32 bits cleared, x2 = x-x1; else
+ *	2. if x <= 2y use
+ *		t1*y1+((x-y)*(x-y)+(t1*y2+t2*y))
+ *	where t1 = 2x with lower 32 bits cleared, t2 = 2x-t1, 
+ *	y1= y with lower 32 bits chopped, y2 = y-y1.
+ *		
+ *	NOTE: scaling may be necessary if some argument is too 
+ *	      large or too tiny
+ *
+ * Special cases:
+ *	hypot(x,y) is INF if x or y is +INF or -INF; else
+ *	hypot(x,y) is NAN if x or y is NAN.
+ *
+ * Accuracy:
+ * 	hypot(x,y) returns sqrt(x^2+y^2) with error less 
+ * 	than 1 ulps (units in the last place) 
+ */
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+double
+__ieee754_hypot(double x, double y)
+{
+	double a,b,t1,t2,y1,y2,w;
+	int32_t j,k,ha,hb;
+
+	GET_HIGH_WORD(ha,x);
+	ha &= 0x7fffffff;
+	GET_HIGH_WORD(hb,y);
+	hb &= 0x7fffffff;
+	if(hb > ha) {a=y;b=x;j=ha; ha=hb;hb=j;} else {a=x;b=y;}
+	a = fabs(a);
+	b = fabs(b);
+	if((ha-hb)>0x3c00000) {return a+b;} /* x/y > 2**60 */
+	k=0;
+	if(ha > 0x5f300000) {	/* a>2**500 */
+	   if(ha >= 0x7ff00000) {	/* Inf or NaN */
+	       u_int32_t low;
+	       /* Use original arg order iff result is NaN; quieten sNaNs. */
+	       w = fabs(x+0.0)-fabs(y+0.0);
+	       GET_LOW_WORD(low,a);
+	       if(((ha&0xfffff)|low)==0) w = a;
+	       GET_LOW_WORD(low,b);
+	       if(((hb^0x7ff00000)|low)==0) w = b;
+	       return w;
+	   }
+	   /* scale a and b by 2**-600 */
+	   ha -= 0x25800000; hb -= 0x25800000;	k += 600;
+	   SET_HIGH_WORD(a,ha);
+	   SET_HIGH_WORD(b,hb);
+	}
+	if(hb < 0x20b00000) {	/* b < 2**-500 */
+	    if(hb <= 0x000fffff) {	/* subnormal b or 0 */
+	        u_int32_t low;
+		GET_LOW_WORD(low,b);
+		if((hb|low)==0) return a;
+		t1=0;
+		SET_HIGH_WORD(t1,0x7fd00000);	/* t1=2^1022 */
+		b *= t1;
+		a *= t1;
+		k -= 1022;
+	    } else {		/* scale a and b by 2^600 */
+	        ha += 0x25800000; 	/* a *= 2^600 */
+		hb += 0x25800000;	/* b *= 2^600 */
+		k -= 600;
+		SET_HIGH_WORD(a,ha);
+		SET_HIGH_WORD(b,hb);
+	    }
+	}
+    /* medium size a and b */
+	w = a-b;
+	if (w>b) {
+	    t1 = 0;
+	    SET_HIGH_WORD(t1,ha);
+	    t2 = a-t1;
+	    w  = sqrt(t1*t1-(b*(-b)-t2*(a+t1)));
+	} else {
+	    a  = a+a;
+	    y1 = 0;
+	    SET_HIGH_WORD(y1,hb);
+	    y2 = b - y1;
+	    t1 = 0;
+	    SET_HIGH_WORD(t1,ha+0x00100000);
+	    t2 = a - t1;
+	    w  = sqrt(t1*y1-(w*(-w)-(t1*y2+t2*b)));
+	}
+	if(k!=0) {
+	    u_int32_t high;
+	    t1 = 1.0;
+	    GET_HIGH_WORD(high,t1);
+	    SET_HIGH_WORD(t1,high+(k<<20));
+	    return t1*w;
+	} else return w;
+}
+
+#if LDBL_MANT_DIG == 53
+__weak_reference(hypot, hypotl);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/e_hypotf.c b/libm/upstream-freebsd/lib/msun/src/e_hypotf.c
new file mode 100644
index 0000000..6d083e4
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_hypotf.c
@@ -0,0 +1,83 @@
+/* e_hypotf.c -- float version of e_hypot.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+float
+__ieee754_hypotf(float x, float y)
+{
+	float a,b,t1,t2,y1,y2,w;
+	int32_t j,k,ha,hb;
+
+	GET_FLOAT_WORD(ha,x);
+	ha &= 0x7fffffff;
+	GET_FLOAT_WORD(hb,y);
+	hb &= 0x7fffffff;
+	if(hb > ha) {a=y;b=x;j=ha; ha=hb;hb=j;} else {a=x;b=y;}
+	a = fabsf(a);
+	b = fabsf(b);
+	if((ha-hb)>0xf000000) {return a+b;} /* x/y > 2**30 */
+	k=0;
+	if(ha > 0x58800000) {	/* a>2**50 */
+	   if(ha >= 0x7f800000) {	/* Inf or NaN */
+	       /* Use original arg order iff result is NaN; quieten sNaNs. */
+	       w = fabsf(x+0.0F)-fabsf(y+0.0F);
+	       if(ha == 0x7f800000) w = a;
+	       if(hb == 0x7f800000) w = b;
+	       return w;
+	   }
+	   /* scale a and b by 2**-68 */
+	   ha -= 0x22000000; hb -= 0x22000000;	k += 68;
+	   SET_FLOAT_WORD(a,ha);
+	   SET_FLOAT_WORD(b,hb);
+	}
+	if(hb < 0x26800000) {	/* b < 2**-50 */
+	    if(hb <= 0x007fffff) {	/* subnormal b or 0 */
+	        if(hb==0) return a;
+		SET_FLOAT_WORD(t1,0x7e800000);	/* t1=2^126 */
+		b *= t1;
+		a *= t1;
+		k -= 126;
+	    } else {		/* scale a and b by 2^68 */
+	        ha += 0x22000000; 	/* a *= 2^68 */
+		hb += 0x22000000;	/* b *= 2^68 */
+		k -= 68;
+		SET_FLOAT_WORD(a,ha);
+		SET_FLOAT_WORD(b,hb);
+	    }
+	}
+    /* medium size a and b */
+	w = a-b;
+	if (w>b) {
+	    SET_FLOAT_WORD(t1,ha&0xfffff000);
+	    t2 = a-t1;
+	    w  = __ieee754_sqrtf(t1*t1-(b*(-b)-t2*(a+t1)));
+	} else {
+	    a  = a+a;
+	    SET_FLOAT_WORD(y1,hb&0xfffff000);
+	    y2 = b - y1;
+	    SET_FLOAT_WORD(t1,(ha+0x00800000)&0xfffff000);
+	    t2 = a - t1;
+	    w  = __ieee754_sqrtf(t1*y1-(w*(-w)-(t1*y2+t2*b)));
+	}
+	if(k!=0) {
+	    SET_FLOAT_WORD(t1,0x3f800000+(k<<23));
+	    return t1*w;
+	} else return w;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_hypotl.c b/libm/upstream-freebsd/lib/msun/src/e_hypotl.c
new file mode 100644
index 0000000..7b5ab89
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_hypotl.c
@@ -0,0 +1,124 @@
+/* From: @(#)e_hypot.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* long double version of hypot().  See e_hypot.c for most comments. */
+
+#include <float.h>
+
+#include "fpmath.h"
+#include "math.h"
+#include "math_private.h"
+
+#define	GET_LDBL_MAN(h, l, v) do {	\
+	union IEEEl2bits uv;		\
+					\
+	uv.e = v;			\
+	h = uv.bits.manh;		\
+	l = uv.bits.manl;		\
+} while (0)
+
+#undef GET_HIGH_WORD
+#define	GET_HIGH_WORD(i, v)	GET_LDBL_EXPSIGN(i, v)
+#undef SET_HIGH_WORD
+#define	SET_HIGH_WORD(v, i)	SET_LDBL_EXPSIGN(v, i)
+
+#define	DESW(exp)	(exp)		/* delta expsign word */
+#define	ESW(exp)	(MAX_EXP - 1 + (exp))	/* expsign word */
+#define	MANT_DIG	LDBL_MANT_DIG
+#define	MAX_EXP		LDBL_MAX_EXP
+
+#if LDBL_MANL_SIZE > 32
+typedef	uint64_t man_t;
+#else
+typedef	uint32_t man_t;
+#endif
+
+long double
+hypotl(long double x, long double y)
+{
+	long double a=x,b=y,t1,t2,y1,y2,w;
+	int32_t j,k,ha,hb;
+
+	GET_HIGH_WORD(ha,x);
+	ha &= 0x7fff;
+	GET_HIGH_WORD(hb,y);
+	hb &= 0x7fff;
+	if(hb > ha) {a=y;b=x;j=ha; ha=hb;hb=j;} else {a=x;b=y;}
+	a = fabsl(a);
+	b = fabsl(b);
+	if((ha-hb)>DESW(MANT_DIG+7)) {return a+b;} /* x/y > 2**(MANT_DIG+7) */
+	k=0;
+	if(ha > ESW(MAX_EXP/2-12)) {	/* a>2**(MAX_EXP/2-12) */
+	   if(ha >= ESW(MAX_EXP)) {	/* Inf or NaN */
+	       man_t manh, manl;
+	       /* Use original arg order iff result is NaN; quieten sNaNs. */
+	       w = fabsl(x+0.0)-fabsl(y+0.0);
+	       GET_LDBL_MAN(manh,manl,a);
+	       if (manh == LDBL_NBIT && manl == 0) w = a;
+	       GET_LDBL_MAN(manh,manl,b);
+	       if (hb >= ESW(MAX_EXP) && manh == LDBL_NBIT && manl == 0) w = b;
+	       return w;
+	   }
+	   /* scale a and b by 2**-(MAX_EXP/2+88) */
+	   ha -= DESW(MAX_EXP/2+88); hb -= DESW(MAX_EXP/2+88);
+	   k += MAX_EXP/2+88;
+	   SET_HIGH_WORD(a,ha);
+	   SET_HIGH_WORD(b,hb);
+	}
+	if(hb < ESW(-(MAX_EXP/2-12))) {	/* b < 2**-(MAX_EXP/2-12) */
+	    if(hb <= 0) {		/* subnormal b or 0 */
+	        man_t manh, manl;
+		GET_LDBL_MAN(manh,manl,b);
+		if((manh|manl)==0) return a;
+		t1=0;
+		SET_HIGH_WORD(t1,ESW(MAX_EXP-2));	/* t1=2^(MAX_EXP-2) */
+		b *= t1;
+		a *= t1;
+		k -= MAX_EXP-2;
+	    } else {		/* scale a and b by 2^(MAX_EXP/2+88) */
+		ha += DESW(MAX_EXP/2+88);
+		hb += DESW(MAX_EXP/2+88);
+		k -= MAX_EXP/2+88;
+		SET_HIGH_WORD(a,ha);
+		SET_HIGH_WORD(b,hb);
+	    }
+	}
+    /* medium size a and b */
+	w = a-b;
+	if (w>b) {
+	    t1 = a;
+	    union IEEEl2bits uv;
+	    uv.e = t1; uv.bits.manl = 0; t1 = uv.e;
+	    t2 = a-t1;
+	    w  = sqrtl(t1*t1-(b*(-b)-t2*(a+t1)));
+	} else {
+	    a  = a+a;
+	    y1 = b;
+	    union IEEEl2bits uv;
+	    uv.e = y1; uv.bits.manl = 0; y1 = uv.e;
+	    y2 = b - y1;
+	    t1 = a;
+	    uv.e = t1; uv.bits.manl = 0; t1 = uv.e;
+	    t2 = a - t1;
+	    w  = sqrtl(t1*y1-(w*(-w)-(t1*y2+t2*b)));
+	}
+	if(k!=0) {
+	    u_int32_t high;
+	    t1 = 1.0;
+	    GET_HIGH_WORD(high,t1);
+	    SET_HIGH_WORD(t1,high+DESW(k));
+	    return t1*w;
+	} else return w;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_j0.c b/libm/upstream-freebsd/lib/msun/src/e_j0.c
new file mode 100644
index 0000000..8320f25
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_j0.c
@@ -0,0 +1,381 @@
+
+/* @(#)e_j0.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_j0(x), __ieee754_y0(x)
+ * Bessel function of the first and second kinds of order zero.
+ * Method -- j0(x):
+ *	1. For tiny x, we use j0(x) = 1 - x^2/4 + x^4/64 - ...
+ *	2. Reduce x to |x| since j0(x)=j0(-x),  and
+ *	   for x in (0,2)
+ *		j0(x) = 1-z/4+ z^2*R0/S0,  where z = x*x;
+ *	   (precision:  |j0-1+z/4-z^2R0/S0 |<2**-63.67 )
+ *	   for x in (2,inf)
+ * 		j0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)-q0(x)*sin(x0))
+ * 	   where x0 = x-pi/4. It is better to compute sin(x0),cos(x0)
+ *	   as follow:
+ *		cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4)
+ *			= 1/sqrt(2) * (cos(x) + sin(x))
+ *		sin(x0) = sin(x)cos(pi/4)-cos(x)sin(pi/4)
+ *			= 1/sqrt(2) * (sin(x) - cos(x))
+ * 	   (To avoid cancellation, use
+ *		sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
+ * 	    to compute the worse one.)
+ *	   
+ *	3 Special cases
+ *		j0(nan)= nan
+ *		j0(0) = 1
+ *		j0(inf) = 0
+ *		
+ * Method -- y0(x):
+ *	1. For x<2.
+ *	   Since 
+ *		y0(x) = 2/pi*(j0(x)*(ln(x/2)+Euler) + x^2/4 - ...)
+ *	   therefore y0(x)-2/pi*j0(x)*ln(x) is an even function.
+ *	   We use the following function to approximate y0,
+ *		y0(x) = U(z)/V(z) + (2/pi)*(j0(x)*ln(x)), z= x^2
+ *	   where 
+ *		U(z) = u00 + u01*z + ... + u06*z^6
+ *		V(z) = 1  + v01*z + ... + v04*z^4
+ *	   with absolute approximation error bounded by 2**-72.
+ *	   Note: For tiny x, U/V = u0 and j0(x)~1, hence
+ *		y0(tiny) = u0 + (2/pi)*ln(tiny), (choose tiny<2**-27)
+ *	2. For x>=2.
+ * 		y0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)+q0(x)*sin(x0))
+ * 	   where x0 = x-pi/4. It is better to compute sin(x0),cos(x0)
+ *	   by the method mentioned above.
+ *	3. Special cases: y0(0)=-inf, y0(x<0)=NaN, y0(inf)=0.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+static double pzero(double), qzero(double);
+
+static const double
+huge 	= 1e300,
+one	= 1.0,
+invsqrtpi=  5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */
+tpi      =  6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */
+ 		/* R0/S0 on [0, 2.00] */
+R02  =  1.56249999999999947958e-02, /* 0x3F8FFFFF, 0xFFFFFFFD */
+R03  = -1.89979294238854721751e-04, /* 0xBF28E6A5, 0xB61AC6E9 */
+R04  =  1.82954049532700665670e-06, /* 0x3EBEB1D1, 0x0C503919 */
+R05  = -4.61832688532103189199e-09, /* 0xBE33D5E7, 0x73D63FCE */
+S01  =  1.56191029464890010492e-02, /* 0x3F8FFCE8, 0x82C8C2A4 */
+S02  =  1.16926784663337450260e-04, /* 0x3F1EA6D2, 0xDD57DBF4 */
+S03  =  5.13546550207318111446e-07, /* 0x3EA13B54, 0xCE84D5A9 */
+S04  =  1.16614003333790000205e-09; /* 0x3E1408BC, 0xF4745D8F */
+
+static const double zero = 0.0;
+
+double
+__ieee754_j0(double x)
+{
+	double z, s,c,ss,cc,r,u,v;
+	int32_t hx,ix;
+
+	GET_HIGH_WORD(hx,x);
+	ix = hx&0x7fffffff;
+	if(ix>=0x7ff00000) return one/(x*x);
+	x = fabs(x);
+	if(ix >= 0x40000000) {	/* |x| >= 2.0 */
+		s = sin(x);
+		c = cos(x);
+		ss = s-c;
+		cc = s+c;
+		if(ix<0x7fe00000) {  /* make sure x+x not overflow */
+		    z = -cos(x+x);
+		    if ((s*c)<zero) cc = z/ss;
+		    else 	    ss = z/cc;
+		}
+	/*
+	 * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
+	 * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
+	 */
+		if(ix>0x48000000) z = (invsqrtpi*cc)/sqrt(x);
+		else {
+		    u = pzero(x); v = qzero(x);
+		    z = invsqrtpi*(u*cc-v*ss)/sqrt(x);
+		}
+		return z;
+	}
+	if(ix<0x3f200000) {	/* |x| < 2**-13 */
+	    if(huge+x>one) {	/* raise inexact if x != 0 */
+	        if(ix<0x3e400000) return one;	/* |x|<2**-27 */
+	        else 	      return one - 0.25*x*x;
+	    }
+	}
+	z = x*x;
+	r =  z*(R02+z*(R03+z*(R04+z*R05)));
+	s =  one+z*(S01+z*(S02+z*(S03+z*S04)));
+	if(ix < 0x3FF00000) {	/* |x| < 1.00 */
+	    return one + z*(-0.25+(r/s));
+	} else {
+	    u = 0.5*x;
+	    return((one+u)*(one-u)+z*(r/s));
+	}
+}
+
+static const double
+u00  = -7.38042951086872317523e-02, /* 0xBFB2E4D6, 0x99CBD01F */
+u01  =  1.76666452509181115538e-01, /* 0x3FC69D01, 0x9DE9E3FC */
+u02  = -1.38185671945596898896e-02, /* 0xBF8C4CE8, 0xB16CFA97 */
+u03  =  3.47453432093683650238e-04, /* 0x3F36C54D, 0x20B29B6B */
+u04  = -3.81407053724364161125e-06, /* 0xBECFFEA7, 0x73D25CAD */
+u05  =  1.95590137035022920206e-08, /* 0x3E550057, 0x3B4EABD4 */
+u06  = -3.98205194132103398453e-11, /* 0xBDC5E43D, 0x693FB3C8 */
+v01  =  1.27304834834123699328e-02, /* 0x3F8A1270, 0x91C9C71A */
+v02  =  7.60068627350353253702e-05, /* 0x3F13ECBB, 0xF578C6C1 */
+v03  =  2.59150851840457805467e-07, /* 0x3E91642D, 0x7FF202FD */
+v04  =  4.41110311332675467403e-10; /* 0x3DFE5018, 0x3BD6D9EF */
+
+double
+__ieee754_y0(double x)
+{
+	double z, s,c,ss,cc,u,v;
+	int32_t hx,ix,lx;
+
+	EXTRACT_WORDS(hx,lx,x);
+        ix = 0x7fffffff&hx;
+    /* Y0(NaN) is NaN, y0(-inf) is Nan, y0(inf) is 0  */
+	if(ix>=0x7ff00000) return  one/(x+x*x); 
+        if((ix|lx)==0) return -one/zero;
+        if(hx<0) return zero/zero;
+        if(ix >= 0x40000000) {  /* |x| >= 2.0 */
+        /* y0(x) = sqrt(2/(pi*x))*(p0(x)*sin(x0)+q0(x)*cos(x0))
+         * where x0 = x-pi/4
+         *      Better formula:
+         *              cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4)
+         *                      =  1/sqrt(2) * (sin(x) + cos(x))
+         *              sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
+         *                      =  1/sqrt(2) * (sin(x) - cos(x))
+         * To avoid cancellation, use
+         *              sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
+         * to compute the worse one.
+         */
+                s = sin(x);
+                c = cos(x);
+                ss = s-c;
+                cc = s+c;
+	/*
+	 * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
+	 * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
+	 */
+                if(ix<0x7fe00000) {  /* make sure x+x not overflow */
+                    z = -cos(x+x);
+                    if ((s*c)<zero) cc = z/ss;
+                    else            ss = z/cc;
+                }
+                if(ix>0x48000000) z = (invsqrtpi*ss)/sqrt(x);
+                else {
+                    u = pzero(x); v = qzero(x);
+                    z = invsqrtpi*(u*ss+v*cc)/sqrt(x);
+                }
+                return z;
+	}
+	if(ix<=0x3e400000) {	/* x < 2**-27 */
+	    return(u00 + tpi*__ieee754_log(x));
+	}
+	z = x*x;
+	u = u00+z*(u01+z*(u02+z*(u03+z*(u04+z*(u05+z*u06)))));
+	v = one+z*(v01+z*(v02+z*(v03+z*v04)));
+	return(u/v + tpi*(__ieee754_j0(x)*__ieee754_log(x)));
+}
+
+/* The asymptotic expansions of pzero is
+ *	1 - 9/128 s^2 + 11025/98304 s^4 - ...,	where s = 1/x.
+ * For x >= 2, We approximate pzero by
+ * 	pzero(x) = 1 + (R/S)
+ * where  R = pR0 + pR1*s^2 + pR2*s^4 + ... + pR5*s^10
+ * 	  S = 1 + pS0*s^2 + ... + pS4*s^10
+ * and
+ *	| pzero(x)-1-R/S | <= 2  ** ( -60.26)
+ */
+static const double pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+  0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
+ -7.03124999999900357484e-02, /* 0xBFB1FFFF, 0xFFFFFD32 */
+ -8.08167041275349795626e+00, /* 0xC02029D0, 0xB44FA779 */
+ -2.57063105679704847262e+02, /* 0xC0701102, 0x7B19E863 */
+ -2.48521641009428822144e+03, /* 0xC0A36A6E, 0xCD4DCAFC */
+ -5.25304380490729545272e+03, /* 0xC0B4850B, 0x36CC643D */
+};
+static const double pS8[5] = {
+  1.16534364619668181717e+02, /* 0x405D2233, 0x07A96751 */
+  3.83374475364121826715e+03, /* 0x40ADF37D, 0x50596938 */
+  4.05978572648472545552e+04, /* 0x40E3D2BB, 0x6EB6B05F */
+  1.16752972564375915681e+05, /* 0x40FC810F, 0x8F9FA9BD */
+  4.76277284146730962675e+04, /* 0x40E74177, 0x4F2C49DC */
+};
+
+static const double pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+ -1.14125464691894502584e-11, /* 0xBDA918B1, 0x47E495CC */
+ -7.03124940873599280078e-02, /* 0xBFB1FFFF, 0xE69AFBC6 */
+ -4.15961064470587782438e+00, /* 0xC010A370, 0xF90C6BBF */
+ -6.76747652265167261021e+01, /* 0xC050EB2F, 0x5A7D1783 */
+ -3.31231299649172967747e+02, /* 0xC074B3B3, 0x6742CC63 */
+ -3.46433388365604912451e+02, /* 0xC075A6EF, 0x28A38BD7 */
+};
+static const double pS5[5] = {
+  6.07539382692300335975e+01, /* 0x404E6081, 0x0C98C5DE */
+  1.05125230595704579173e+03, /* 0x40906D02, 0x5C7E2864 */
+  5.97897094333855784498e+03, /* 0x40B75AF8, 0x8FBE1D60 */
+  9.62544514357774460223e+03, /* 0x40C2CCB8, 0xFA76FA38 */
+  2.40605815922939109441e+03, /* 0x40A2CC1D, 0xC70BE864 */
+};
+
+static const double pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
+ -2.54704601771951915620e-09, /* 0xBE25E103, 0x6FE1AA86 */
+ -7.03119616381481654654e-02, /* 0xBFB1FFF6, 0xF7C0E24B */
+ -2.40903221549529611423e+00, /* 0xC00345B2, 0xAEA48074 */
+ -2.19659774734883086467e+01, /* 0xC035F74A, 0x4CB94E14 */
+ -5.80791704701737572236e+01, /* 0xC04D0A22, 0x420A1A45 */
+ -3.14479470594888503854e+01, /* 0xC03F72AC, 0xA892D80F */
+};
+static const double pS3[5] = {
+  3.58560338055209726349e+01, /* 0x4041ED92, 0x84077DD3 */
+  3.61513983050303863820e+02, /* 0x40769839, 0x464A7C0E */
+  1.19360783792111533330e+03, /* 0x4092A66E, 0x6D1061D6 */
+  1.12799679856907414432e+03, /* 0x40919FFC, 0xB8C39B7E */
+  1.73580930813335754692e+02, /* 0x4065B296, 0xFC379081 */
+};
+
+static const double pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+ -8.87534333032526411254e-08, /* 0xBE77D316, 0xE927026D */
+ -7.03030995483624743247e-02, /* 0xBFB1FF62, 0x495E1E42 */
+ -1.45073846780952986357e+00, /* 0xBFF73639, 0x8A24A843 */
+ -7.63569613823527770791e+00, /* 0xC01E8AF3, 0xEDAFA7F3 */
+ -1.11931668860356747786e+01, /* 0xC02662E6, 0xC5246303 */
+ -3.23364579351335335033e+00, /* 0xC009DE81, 0xAF8FE70F */
+};
+static const double pS2[5] = {
+  2.22202997532088808441e+01, /* 0x40363865, 0x908B5959 */
+  1.36206794218215208048e+02, /* 0x4061069E, 0x0EE8878F */
+  2.70470278658083486789e+02, /* 0x4070E786, 0x42EA079B */
+  1.53875394208320329881e+02, /* 0x40633C03, 0x3AB6FAFF */
+  1.46576176948256193810e+01, /* 0x402D50B3, 0x44391809 */
+};
+
+	static double pzero(double x)
+{
+	const double *p,*q;
+	double z,r,s;
+	int32_t ix;
+	GET_HIGH_WORD(ix,x);
+	ix &= 0x7fffffff;
+	if(ix>=0x40200000)     {p = pR8; q= pS8;}
+	else if(ix>=0x40122E8B){p = pR5; q= pS5;}
+	else if(ix>=0x4006DB6D){p = pR3; q= pS3;}
+	else if(ix>=0x40000000){p = pR2; q= pS2;}
+	z = one/(x*x);
+	r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
+	s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
+	return one+ r/s;
+}
+		
+
+/* For x >= 8, the asymptotic expansions of qzero is
+ *	-1/8 s + 75/1024 s^3 - ..., where s = 1/x.
+ * We approximate pzero by
+ * 	qzero(x) = s*(-1.25 + (R/S))
+ * where  R = qR0 + qR1*s^2 + qR2*s^4 + ... + qR5*s^10
+ * 	  S = 1 + qS0*s^2 + ... + qS5*s^12
+ * and
+ *	| qzero(x)/s +1.25-R/S | <= 2  ** ( -61.22)
+ */
+static const double qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+  0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
+  7.32421874999935051953e-02, /* 0x3FB2BFFF, 0xFFFFFE2C */
+  1.17682064682252693899e+01, /* 0x40278952, 0x5BB334D6 */
+  5.57673380256401856059e+02, /* 0x40816D63, 0x15301825 */
+  8.85919720756468632317e+03, /* 0x40C14D99, 0x3E18F46D */
+  3.70146267776887834771e+04, /* 0x40E212D4, 0x0E901566 */
+};
+static const double qS8[6] = {
+  1.63776026895689824414e+02, /* 0x406478D5, 0x365B39BC */
+  8.09834494656449805916e+03, /* 0x40BFA258, 0x4E6B0563 */
+  1.42538291419120476348e+05, /* 0x41016652, 0x54D38C3F */
+  8.03309257119514397345e+05, /* 0x412883DA, 0x83A52B43 */
+  8.40501579819060512818e+05, /* 0x4129A66B, 0x28DE0B3D */
+ -3.43899293537866615225e+05, /* 0xC114FD6D, 0x2C9530C5 */
+};
+
+static const double qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+  1.84085963594515531381e-11, /* 0x3DB43D8F, 0x29CC8CD9 */
+  7.32421766612684765896e-02, /* 0x3FB2BFFF, 0xD172B04C */
+  5.83563508962056953777e+00, /* 0x401757B0, 0xB9953DD3 */
+  1.35111577286449829671e+02, /* 0x4060E392, 0x0A8788E9 */
+  1.02724376596164097464e+03, /* 0x40900CF9, 0x9DC8C481 */
+  1.98997785864605384631e+03, /* 0x409F17E9, 0x53C6E3A6 */
+};
+static const double qS5[6] = {
+  8.27766102236537761883e+01, /* 0x4054B1B3, 0xFB5E1543 */
+  2.07781416421392987104e+03, /* 0x40A03BA0, 0xDA21C0CE */
+  1.88472887785718085070e+04, /* 0x40D267D2, 0x7B591E6D */
+  5.67511122894947329769e+04, /* 0x40EBB5E3, 0x97E02372 */
+  3.59767538425114471465e+04, /* 0x40E19118, 0x1F7A54A0 */
+ -5.35434275601944773371e+03, /* 0xC0B4EA57, 0xBEDBC609 */
+};
+
+static const double qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
+  4.37741014089738620906e-09, /* 0x3E32CD03, 0x6ADECB82 */
+  7.32411180042911447163e-02, /* 0x3FB2BFEE, 0x0E8D0842 */
+  3.34423137516170720929e+00, /* 0x400AC0FC, 0x61149CF5 */
+  4.26218440745412650017e+01, /* 0x40454F98, 0x962DAEDD */
+  1.70808091340565596283e+02, /* 0x406559DB, 0xE25EFD1F */
+  1.66733948696651168575e+02, /* 0x4064D77C, 0x81FA21E0 */
+};
+static const double qS3[6] = {
+  4.87588729724587182091e+01, /* 0x40486122, 0xBFE343A6 */
+  7.09689221056606015736e+02, /* 0x40862D83, 0x86544EB3 */
+  3.70414822620111362994e+03, /* 0x40ACF04B, 0xE44DFC63 */
+  6.46042516752568917582e+03, /* 0x40B93C6C, 0xD7C76A28 */
+  2.51633368920368957333e+03, /* 0x40A3A8AA, 0xD94FB1C0 */
+ -1.49247451836156386662e+02, /* 0xC062A7EB, 0x201CF40F */
+};
+
+static const double qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+  1.50444444886983272379e-07, /* 0x3E84313B, 0x54F76BDB */
+  7.32234265963079278272e-02, /* 0x3FB2BEC5, 0x3E883E34 */
+  1.99819174093815998816e+00, /* 0x3FFFF897, 0xE727779C */
+  1.44956029347885735348e+01, /* 0x402CFDBF, 0xAAF96FE5 */
+  3.16662317504781540833e+01, /* 0x403FAA8E, 0x29FBDC4A */
+  1.62527075710929267416e+01, /* 0x403040B1, 0x71814BB4 */
+};
+static const double qS2[6] = {
+  3.03655848355219184498e+01, /* 0x403E5D96, 0xF7C07AED */
+  2.69348118608049844624e+02, /* 0x4070D591, 0xE4D14B40 */
+  8.44783757595320139444e+02, /* 0x408A6645, 0x22B3BF22 */
+  8.82935845112488550512e+02, /* 0x408B977C, 0x9C5CC214 */
+  2.12666388511798828631e+02, /* 0x406A9553, 0x0E001365 */
+ -5.31095493882666946917e+00, /* 0xC0153E6A, 0xF8B32931 */
+};
+
+	static double qzero(double x)
+{
+	const double *p,*q;
+	double s,r,z;
+	int32_t ix;
+	GET_HIGH_WORD(ix,x);
+	ix &= 0x7fffffff;
+	if(ix>=0x40200000)     {p = qR8; q= qS8;}
+	else if(ix>=0x40122E8B){p = qR5; q= qS5;}
+	else if(ix>=0x4006DB6D){p = qR3; q= qS3;}
+	else if(ix>=0x40000000){p = qR2; q= qS2;}
+	z = one/(x*x);
+	r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
+	s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
+	return (-.125 + r/s)/x;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_j0f.c b/libm/upstream-freebsd/lib/msun/src/e_j0f.c
new file mode 100644
index 0000000..c45faf3
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_j0f.c
@@ -0,0 +1,337 @@
+/* e_j0f.c -- float version of e_j0.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static float pzerof(float), qzerof(float);
+
+static const float
+huge 	= 1e30,
+one	= 1.0,
+invsqrtpi=  5.6418961287e-01, /* 0x3f106ebb */
+tpi      =  6.3661974669e-01, /* 0x3f22f983 */
+ 		/* R0/S0 on [0, 2.00] */
+R02  =  1.5625000000e-02, /* 0x3c800000 */
+R03  = -1.8997929874e-04, /* 0xb947352e */
+R04  =  1.8295404516e-06, /* 0x35f58e88 */
+R05  = -4.6183270541e-09, /* 0xb19eaf3c */
+S01  =  1.5619102865e-02, /* 0x3c7fe744 */
+S02  =  1.1692678527e-04, /* 0x38f53697 */
+S03  =  5.1354652442e-07, /* 0x3509daa6 */
+S04  =  1.1661400734e-09; /* 0x30a045e8 */
+
+static const float zero = 0.0;
+
+float
+__ieee754_j0f(float x)
+{
+	float z, s,c,ss,cc,r,u,v;
+	int32_t hx,ix;
+
+	GET_FLOAT_WORD(hx,x);
+	ix = hx&0x7fffffff;
+	if(ix>=0x7f800000) return one/(x*x);
+	x = fabsf(x);
+	if(ix >= 0x40000000) {	/* |x| >= 2.0 */
+		s = sinf(x);
+		c = cosf(x);
+		ss = s-c;
+		cc = s+c;
+		if(ix<0x7f000000) {  /* make sure x+x not overflow */
+		    z = -cosf(x+x);
+		    if ((s*c)<zero) cc = z/ss;
+		    else 	    ss = z/cc;
+		}
+	/*
+	 * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
+	 * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
+	 */
+		if(ix>0x80000000) z = (invsqrtpi*cc)/sqrtf(x);
+		else {
+		    u = pzerof(x); v = qzerof(x);
+		    z = invsqrtpi*(u*cc-v*ss)/sqrtf(x);
+		}
+		return z;
+	}
+	if(ix<0x39000000) {	/* |x| < 2**-13 */
+	    if(huge+x>one) {	/* raise inexact if x != 0 */
+	        if(ix<0x32000000) return one;	/* |x|<2**-27 */
+	        else 	      return one - (float)0.25*x*x;
+	    }
+	}
+	z = x*x;
+	r =  z*(R02+z*(R03+z*(R04+z*R05)));
+	s =  one+z*(S01+z*(S02+z*(S03+z*S04)));
+	if(ix < 0x3F800000) {	/* |x| < 1.00 */
+	    return one + z*((float)-0.25+(r/s));
+	} else {
+	    u = (float)0.5*x;
+	    return((one+u)*(one-u)+z*(r/s));
+	}
+}
+
+static const float
+u00  = -7.3804296553e-02, /* 0xbd9726b5 */
+u01  =  1.7666645348e-01, /* 0x3e34e80d */
+u02  = -1.3818567619e-02, /* 0xbc626746 */
+u03  =  3.4745343146e-04, /* 0x39b62a69 */
+u04  = -3.8140706238e-06, /* 0xb67ff53c */
+u05  =  1.9559013964e-08, /* 0x32a802ba */
+u06  = -3.9820518410e-11, /* 0xae2f21eb */
+v01  =  1.2730483897e-02, /* 0x3c509385 */
+v02  =  7.6006865129e-05, /* 0x389f65e0 */
+v03  =  2.5915085189e-07, /* 0x348b216c */
+v04  =  4.4111031494e-10; /* 0x2ff280c2 */
+
+float
+__ieee754_y0f(float x)
+{
+	float z, s,c,ss,cc,u,v;
+	int32_t hx,ix;
+
+	GET_FLOAT_WORD(hx,x);
+        ix = 0x7fffffff&hx;
+    /* Y0(NaN) is NaN, y0(-inf) is Nan, y0(inf) is 0  */
+	if(ix>=0x7f800000) return  one/(x+x*x);
+        if(ix==0) return -one/zero;
+        if(hx<0) return zero/zero;
+        if(ix >= 0x40000000) {  /* |x| >= 2.0 */
+        /* y0(x) = sqrt(2/(pi*x))*(p0(x)*sin(x0)+q0(x)*cos(x0))
+         * where x0 = x-pi/4
+         *      Better formula:
+         *              cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4)
+         *                      =  1/sqrt(2) * (sin(x) + cos(x))
+         *              sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
+         *                      =  1/sqrt(2) * (sin(x) - cos(x))
+         * To avoid cancellation, use
+         *              sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
+         * to compute the worse one.
+         */
+                s = sinf(x);
+                c = cosf(x);
+                ss = s-c;
+                cc = s+c;
+	/*
+	 * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
+	 * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
+	 */
+                if(ix<0x7f000000) {  /* make sure x+x not overflow */
+                    z = -cosf(x+x);
+                    if ((s*c)<zero) cc = z/ss;
+                    else            ss = z/cc;
+                }
+                if(ix>0x80000000) z = (invsqrtpi*ss)/sqrtf(x);
+                else {
+                    u = pzerof(x); v = qzerof(x);
+                    z = invsqrtpi*(u*ss+v*cc)/sqrtf(x);
+                }
+                return z;
+	}
+	if(ix<=0x32000000) {	/* x < 2**-27 */
+	    return(u00 + tpi*__ieee754_logf(x));
+	}
+	z = x*x;
+	u = u00+z*(u01+z*(u02+z*(u03+z*(u04+z*(u05+z*u06)))));
+	v = one+z*(v01+z*(v02+z*(v03+z*v04)));
+	return(u/v + tpi*(__ieee754_j0f(x)*__ieee754_logf(x)));
+}
+
+/* The asymptotic expansions of pzero is
+ *	1 - 9/128 s^2 + 11025/98304 s^4 - ...,	where s = 1/x.
+ * For x >= 2, We approximate pzero by
+ * 	pzero(x) = 1 + (R/S)
+ * where  R = pR0 + pR1*s^2 + pR2*s^4 + ... + pR5*s^10
+ * 	  S = 1 + pS0*s^2 + ... + pS4*s^10
+ * and
+ *	| pzero(x)-1-R/S | <= 2  ** ( -60.26)
+ */
+static const float pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+  0.0000000000e+00, /* 0x00000000 */
+ -7.0312500000e-02, /* 0xbd900000 */
+ -8.0816707611e+00, /* 0xc1014e86 */
+ -2.5706311035e+02, /* 0xc3808814 */
+ -2.4852163086e+03, /* 0xc51b5376 */
+ -5.2530439453e+03, /* 0xc5a4285a */
+};
+static const float pS8[5] = {
+  1.1653436279e+02, /* 0x42e91198 */
+  3.8337448730e+03, /* 0x456f9beb */
+  4.0597855469e+04, /* 0x471e95db */
+  1.1675296875e+05, /* 0x47e4087c */
+  4.7627726562e+04, /* 0x473a0bba */
+};
+static const float pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+ -1.1412546255e-11, /* 0xad48c58a */
+ -7.0312492549e-02, /* 0xbd8fffff */
+ -4.1596107483e+00, /* 0xc0851b88 */
+ -6.7674766541e+01, /* 0xc287597b */
+ -3.3123129272e+02, /* 0xc3a59d9b */
+ -3.4643338013e+02, /* 0xc3ad3779 */
+};
+static const float pS5[5] = {
+  6.0753936768e+01, /* 0x42730408 */
+  1.0512523193e+03, /* 0x44836813 */
+  5.9789707031e+03, /* 0x45bad7c4 */
+  9.6254453125e+03, /* 0x461665c8 */
+  2.4060581055e+03, /* 0x451660ee */
+};
+
+static const float pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
+ -2.5470459075e-09, /* 0xb12f081b */
+ -7.0311963558e-02, /* 0xbd8fffb8 */
+ -2.4090321064e+00, /* 0xc01a2d95 */
+ -2.1965976715e+01, /* 0xc1afba52 */
+ -5.8079170227e+01, /* 0xc2685112 */
+ -3.1447946548e+01, /* 0xc1fb9565 */
+};
+static const float pS3[5] = {
+  3.5856033325e+01, /* 0x420f6c94 */
+  3.6151397705e+02, /* 0x43b4c1ca */
+  1.1936077881e+03, /* 0x44953373 */
+  1.1279968262e+03, /* 0x448cffe6 */
+  1.7358093262e+02, /* 0x432d94b8 */
+};
+
+static const float pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+ -8.8753431271e-08, /* 0xb3be98b7 */
+ -7.0303097367e-02, /* 0xbd8ffb12 */
+ -1.4507384300e+00, /* 0xbfb9b1cc */
+ -7.6356959343e+00, /* 0xc0f4579f */
+ -1.1193166733e+01, /* 0xc1331736 */
+ -3.2336456776e+00, /* 0xc04ef40d */
+};
+static const float pS2[5] = {
+  2.2220300674e+01, /* 0x41b1c32d */
+  1.3620678711e+02, /* 0x430834f0 */
+  2.7047027588e+02, /* 0x43873c32 */
+  1.5387539673e+02, /* 0x4319e01a */
+  1.4657617569e+01, /* 0x416a859a */
+};
+
+	static float pzerof(float x)
+{
+	const float *p,*q;
+	float z,r,s;
+	int32_t ix;
+	GET_FLOAT_WORD(ix,x);
+	ix &= 0x7fffffff;
+	if(ix>=0x41000000)     {p = pR8; q= pS8;}
+	else if(ix>=0x40f71c58){p = pR5; q= pS5;}
+	else if(ix>=0x4036db68){p = pR3; q= pS3;}
+	else if(ix>=0x40000000){p = pR2; q= pS2;}
+	z = one/(x*x);
+	r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
+	s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
+	return one+ r/s;
+}
+
+
+/* For x >= 8, the asymptotic expansions of qzero is
+ *	-1/8 s + 75/1024 s^3 - ..., where s = 1/x.
+ * We approximate pzero by
+ * 	qzero(x) = s*(-1.25 + (R/S))
+ * where  R = qR0 + qR1*s^2 + qR2*s^4 + ... + qR5*s^10
+ * 	  S = 1 + qS0*s^2 + ... + qS5*s^12
+ * and
+ *	| qzero(x)/s +1.25-R/S | <= 2  ** ( -61.22)
+ */
+static const float qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+  0.0000000000e+00, /* 0x00000000 */
+  7.3242187500e-02, /* 0x3d960000 */
+  1.1768206596e+01, /* 0x413c4a93 */
+  5.5767340088e+02, /* 0x440b6b19 */
+  8.8591972656e+03, /* 0x460a6cca */
+  3.7014625000e+04, /* 0x471096a0 */
+};
+static const float qS8[6] = {
+  1.6377603149e+02, /* 0x4323c6aa */
+  8.0983447266e+03, /* 0x45fd12c2 */
+  1.4253829688e+05, /* 0x480b3293 */
+  8.0330925000e+05, /* 0x49441ed4 */
+  8.4050156250e+05, /* 0x494d3359 */
+ -3.4389928125e+05, /* 0xc8a7eb69 */
+};
+
+static const float qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+  1.8408595828e-11, /* 0x2da1ec79 */
+  7.3242180049e-02, /* 0x3d95ffff */
+  5.8356351852e+00, /* 0x40babd86 */
+  1.3511157227e+02, /* 0x43071c90 */
+  1.0272437744e+03, /* 0x448067cd */
+  1.9899779053e+03, /* 0x44f8bf4b */
+};
+static const float qS5[6] = {
+  8.2776611328e+01, /* 0x42a58da0 */
+  2.0778142090e+03, /* 0x4501dd07 */
+  1.8847289062e+04, /* 0x46933e94 */
+  5.6751113281e+04, /* 0x475daf1d */
+  3.5976753906e+04, /* 0x470c88c1 */
+ -5.3543427734e+03, /* 0xc5a752be */
+};
+
+static const float qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
+  4.3774099900e-09, /* 0x3196681b */
+  7.3241114616e-02, /* 0x3d95ff70 */
+  3.3442313671e+00, /* 0x405607e3 */
+  4.2621845245e+01, /* 0x422a7cc5 */
+  1.7080809021e+02, /* 0x432acedf */
+  1.6673394775e+02, /* 0x4326bbe4 */
+};
+static const float qS3[6] = {
+  4.8758872986e+01, /* 0x42430916 */
+  7.0968920898e+02, /* 0x44316c1c */
+  3.7041481934e+03, /* 0x4567825f */
+  6.4604252930e+03, /* 0x45c9e367 */
+  2.5163337402e+03, /* 0x451d4557 */
+ -1.4924745178e+02, /* 0xc3153f59 */
+};
+
+static const float qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+  1.5044444979e-07, /* 0x342189db */
+  7.3223426938e-02, /* 0x3d95f62a */
+  1.9981917143e+00, /* 0x3fffc4bf */
+  1.4495602608e+01, /* 0x4167edfd */
+  3.1666231155e+01, /* 0x41fd5471 */
+  1.6252708435e+01, /* 0x4182058c */
+};
+static const float qS2[6] = {
+  3.0365585327e+01, /* 0x41f2ecb8 */
+  2.6934811401e+02, /* 0x4386ac8f */
+  8.4478375244e+02, /* 0x44533229 */
+  8.8293585205e+02, /* 0x445cbbe5 */
+  2.1266638184e+02, /* 0x4354aa98 */
+ -5.3109550476e+00, /* 0xc0a9f358 */
+};
+
+	static float qzerof(float x)
+{
+	const float *p,*q;
+	float s,r,z;
+	int32_t ix;
+	GET_FLOAT_WORD(ix,x);
+	ix &= 0x7fffffff;
+	if(ix>=0x41000000)     {p = qR8; q= qS8;}
+	else if(ix>=0x40f71c58){p = qR5; q= qS5;}
+	else if(ix>=0x4036db68){p = qR3; q= qS3;}
+	else if(ix>=0x40000000){p = qR2; q= qS2;}
+	z = one/(x*x);
+	r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
+	s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
+	return (-(float).125 + r/s)/x;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_j1.c b/libm/upstream-freebsd/lib/msun/src/e_j1.c
new file mode 100644
index 0000000..63800ad
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_j1.c
@@ -0,0 +1,376 @@
+
+/* @(#)e_j1.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_j1(x), __ieee754_y1(x)
+ * Bessel function of the first and second kinds of order zero.
+ * Method -- j1(x):
+ *	1. For tiny x, we use j1(x) = x/2 - x^3/16 + x^5/384 - ...
+ *	2. Reduce x to |x| since j1(x)=-j1(-x),  and
+ *	   for x in (0,2)
+ *		j1(x) = x/2 + x*z*R0/S0,  where z = x*x;
+ *	   (precision:  |j1/x - 1/2 - R0/S0 |<2**-61.51 )
+ *	   for x in (2,inf)
+ * 		j1(x) = sqrt(2/(pi*x))*(p1(x)*cos(x1)-q1(x)*sin(x1))
+ * 		y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1))
+ * 	   where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1)
+ *	   as follow:
+ *		cos(x1) =  cos(x)cos(3pi/4)+sin(x)sin(3pi/4)
+ *			=  1/sqrt(2) * (sin(x) - cos(x))
+ *		sin(x1) =  sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
+ *			= -1/sqrt(2) * (sin(x) + cos(x))
+ * 	   (To avoid cancellation, use
+ *		sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
+ * 	    to compute the worse one.)
+ *	   
+ *	3 Special cases
+ *		j1(nan)= nan
+ *		j1(0) = 0
+ *		j1(inf) = 0
+ *		
+ * Method -- y1(x):
+ *	1. screen out x<=0 cases: y1(0)=-inf, y1(x<0)=NaN 
+ *	2. For x<2.
+ *	   Since 
+ *		y1(x) = 2/pi*(j1(x)*(ln(x/2)+Euler)-1/x-x/2+5/64*x^3-...)
+ *	   therefore y1(x)-2/pi*j1(x)*ln(x)-1/x is an odd function.
+ *	   We use the following function to approximate y1,
+ *		y1(x) = x*U(z)/V(z) + (2/pi)*(j1(x)*ln(x)-1/x), z= x^2
+ *	   where for x in [0,2] (abs err less than 2**-65.89)
+ *		U(z) = U0[0] + U0[1]*z + ... + U0[4]*z^4
+ *		V(z) = 1  + v0[0]*z + ... + v0[4]*z^5
+ *	   Note: For tiny x, 1/x dominate y1 and hence
+ *		y1(tiny) = -2/pi/tiny, (choose tiny<2**-54)
+ *	3. For x>=2.
+ * 		y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1))
+ * 	   where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1)
+ *	   by method mentioned above.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+static double pone(double), qone(double);
+
+static const double
+huge    = 1e300,
+one	= 1.0,
+invsqrtpi=  5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */
+tpi      =  6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */
+	/* R0/S0 on [0,2] */
+r00  = -6.25000000000000000000e-02, /* 0xBFB00000, 0x00000000 */
+r01  =  1.40705666955189706048e-03, /* 0x3F570D9F, 0x98472C61 */
+r02  = -1.59955631084035597520e-05, /* 0xBEF0C5C6, 0xBA169668 */
+r03  =  4.96727999609584448412e-08, /* 0x3E6AAAFA, 0x46CA0BD9 */
+s01  =  1.91537599538363460805e-02, /* 0x3F939D0B, 0x12637E53 */
+s02  =  1.85946785588630915560e-04, /* 0x3F285F56, 0xB9CDF664 */
+s03  =  1.17718464042623683263e-06, /* 0x3EB3BFF8, 0x333F8498 */
+s04  =  5.04636257076217042715e-09, /* 0x3E35AC88, 0xC97DFF2C */
+s05  =  1.23542274426137913908e-11; /* 0x3DAB2ACF, 0xCFB97ED8 */
+
+static const double zero    = 0.0;
+
+double
+__ieee754_j1(double x)
+{
+	double z, s,c,ss,cc,r,u,v,y;
+	int32_t hx,ix;
+
+	GET_HIGH_WORD(hx,x);
+	ix = hx&0x7fffffff;
+	if(ix>=0x7ff00000) return one/x;
+	y = fabs(x);
+	if(ix >= 0x40000000) {	/* |x| >= 2.0 */
+		s = sin(y);
+		c = cos(y);
+		ss = -s-c;
+		cc = s-c;
+		if(ix<0x7fe00000) {  /* make sure y+y not overflow */
+		    z = cos(y+y);
+		    if ((s*c)>zero) cc = z/ss;
+		    else 	    ss = z/cc;
+		}
+	/*
+	 * j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x)
+	 * y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x)
+	 */
+		if(ix>0x48000000) z = (invsqrtpi*cc)/sqrt(y);
+		else {
+		    u = pone(y); v = qone(y);
+		    z = invsqrtpi*(u*cc-v*ss)/sqrt(y);
+		}
+		if(hx<0) return -z;
+		else  	 return  z;
+	}
+	if(ix<0x3e400000) {	/* |x|<2**-27 */
+	    if(huge+x>one) return 0.5*x;/* inexact if x!=0 necessary */
+	}
+	z = x*x;
+	r =  z*(r00+z*(r01+z*(r02+z*r03)));
+	s =  one+z*(s01+z*(s02+z*(s03+z*(s04+z*s05))));
+	r *= x;
+	return(x*0.5+r/s);
+}
+
+static const double U0[5] = {
+ -1.96057090646238940668e-01, /* 0xBFC91866, 0x143CBC8A */
+  5.04438716639811282616e-02, /* 0x3FA9D3C7, 0x76292CD1 */
+ -1.91256895875763547298e-03, /* 0xBF5F55E5, 0x4844F50F */
+  2.35252600561610495928e-05, /* 0x3EF8AB03, 0x8FA6B88E */
+ -9.19099158039878874504e-08, /* 0xBE78AC00, 0x569105B8 */
+};
+static const double V0[5] = {
+  1.99167318236649903973e-02, /* 0x3F94650D, 0x3F4DA9F0 */
+  2.02552581025135171496e-04, /* 0x3F2A8C89, 0x6C257764 */
+  1.35608801097516229404e-06, /* 0x3EB6C05A, 0x894E8CA6 */
+  6.22741452364621501295e-09, /* 0x3E3ABF1D, 0x5BA69A86 */
+  1.66559246207992079114e-11, /* 0x3DB25039, 0xDACA772A */
+};
+
+double
+__ieee754_y1(double x)
+{
+	double z, s,c,ss,cc,u,v;
+	int32_t hx,ix,lx;
+
+	EXTRACT_WORDS(hx,lx,x);
+        ix = 0x7fffffff&hx;
+    /* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */
+	if(ix>=0x7ff00000) return  one/(x+x*x); 
+        if((ix|lx)==0) return -one/zero;
+        if(hx<0) return zero/zero;
+        if(ix >= 0x40000000) {  /* |x| >= 2.0 */
+                s = sin(x);
+                c = cos(x);
+                ss = -s-c;
+                cc = s-c;
+                if(ix<0x7fe00000) {  /* make sure x+x not overflow */
+                    z = cos(x+x);
+                    if ((s*c)>zero) cc = z/ss;
+                    else            ss = z/cc;
+                }
+        /* y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x0)+q1(x)*cos(x0))
+         * where x0 = x-3pi/4
+         *      Better formula:
+         *              cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4)
+         *                      =  1/sqrt(2) * (sin(x) - cos(x))
+         *              sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
+         *                      = -1/sqrt(2) * (cos(x) + sin(x))
+         * To avoid cancellation, use
+         *              sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
+         * to compute the worse one.
+         */
+                if(ix>0x48000000) z = (invsqrtpi*ss)/sqrt(x);
+                else {
+                    u = pone(x); v = qone(x);
+                    z = invsqrtpi*(u*ss+v*cc)/sqrt(x);
+                }
+                return z;
+        } 
+        if(ix<=0x3c900000) {    /* x < 2**-54 */
+            return(-tpi/x);
+        } 
+        z = x*x;
+        u = U0[0]+z*(U0[1]+z*(U0[2]+z*(U0[3]+z*U0[4])));
+        v = one+z*(V0[0]+z*(V0[1]+z*(V0[2]+z*(V0[3]+z*V0[4]))));
+        return(x*(u/v) + tpi*(__ieee754_j1(x)*__ieee754_log(x)-one/x));
+}
+
+/* For x >= 8, the asymptotic expansions of pone is
+ *	1 + 15/128 s^2 - 4725/2^15 s^4 - ...,	where s = 1/x.
+ * We approximate pone by
+ * 	pone(x) = 1 + (R/S)
+ * where  R = pr0 + pr1*s^2 + pr2*s^4 + ... + pr5*s^10
+ * 	  S = 1 + ps0*s^2 + ... + ps4*s^10
+ * and
+ *	| pone(x)-1-R/S | <= 2  ** ( -60.06)
+ */
+
+static const double pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+  0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
+  1.17187499999988647970e-01, /* 0x3FBDFFFF, 0xFFFFFCCE */
+  1.32394806593073575129e+01, /* 0x402A7A9D, 0x357F7FCE */
+  4.12051854307378562225e+02, /* 0x4079C0D4, 0x652EA590 */
+  3.87474538913960532227e+03, /* 0x40AE457D, 0xA3A532CC */
+  7.91447954031891731574e+03, /* 0x40BEEA7A, 0xC32782DD */
+};
+static const double ps8[5] = {
+  1.14207370375678408436e+02, /* 0x405C8D45, 0x8E656CAC */
+  3.65093083420853463394e+03, /* 0x40AC85DC, 0x964D274F */
+  3.69562060269033463555e+04, /* 0x40E20B86, 0x97C5BB7F */
+  9.76027935934950801311e+04, /* 0x40F7D42C, 0xB28F17BB */
+  3.08042720627888811578e+04, /* 0x40DE1511, 0x697A0B2D */
+};
+
+static const double pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+  1.31990519556243522749e-11, /* 0x3DAD0667, 0xDAE1CA7D */
+  1.17187493190614097638e-01, /* 0x3FBDFFFF, 0xE2C10043 */
+  6.80275127868432871736e+00, /* 0x401B3604, 0x6E6315E3 */
+  1.08308182990189109773e+02, /* 0x405B13B9, 0x452602ED */
+  5.17636139533199752805e+02, /* 0x40802D16, 0xD052D649 */
+  5.28715201363337541807e+02, /* 0x408085B8, 0xBB7E0CB7 */
+};
+static const double ps5[5] = {
+  5.92805987221131331921e+01, /* 0x404DA3EA, 0xA8AF633D */
+  9.91401418733614377743e+02, /* 0x408EFB36, 0x1B066701 */
+  5.35326695291487976647e+03, /* 0x40B4E944, 0x5706B6FB */
+  7.84469031749551231769e+03, /* 0x40BEA4B0, 0xB8A5BB15 */
+  1.50404688810361062679e+03, /* 0x40978030, 0x036F5E51 */
+};
+
+static const double pr3[6] = {
+  3.02503916137373618024e-09, /* 0x3E29FC21, 0xA7AD9EDD */
+  1.17186865567253592491e-01, /* 0x3FBDFFF5, 0x5B21D17B */
+  3.93297750033315640650e+00, /* 0x400F76BC, 0xE85EAD8A */
+  3.51194035591636932736e+01, /* 0x40418F48, 0x9DA6D129 */
+  9.10550110750781271918e+01, /* 0x4056C385, 0x4D2C1837 */
+  4.85590685197364919645e+01, /* 0x4048478F, 0x8EA83EE5 */
+};
+static const double ps3[5] = {
+  3.47913095001251519989e+01, /* 0x40416549, 0xA134069C */
+  3.36762458747825746741e+02, /* 0x40750C33, 0x07F1A75F */
+  1.04687139975775130551e+03, /* 0x40905B7C, 0x5037D523 */
+  8.90811346398256432622e+02, /* 0x408BD67D, 0xA32E31E9 */
+  1.03787932439639277504e+02, /* 0x4059F26D, 0x7C2EED53 */
+};
+
+static const double pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+  1.07710830106873743082e-07, /* 0x3E7CE9D4, 0xF65544F4 */
+  1.17176219462683348094e-01, /* 0x3FBDFF42, 0xBE760D83 */
+  2.36851496667608785174e+00, /* 0x4002F2B7, 0xF98FAEC0 */
+  1.22426109148261232917e+01, /* 0x40287C37, 0x7F71A964 */
+  1.76939711271687727390e+01, /* 0x4031B1A8, 0x177F8EE2 */
+  5.07352312588818499250e+00, /* 0x40144B49, 0xA574C1FE */
+};
+static const double ps2[5] = {
+  2.14364859363821409488e+01, /* 0x40356FBD, 0x8AD5ECDC */
+  1.25290227168402751090e+02, /* 0x405F5293, 0x14F92CD5 */
+  2.32276469057162813669e+02, /* 0x406D08D8, 0xD5A2DBD9 */
+  1.17679373287147100768e+02, /* 0x405D6B7A, 0xDA1884A9 */
+  8.36463893371618283368e+00, /* 0x4020BAB1, 0xF44E5192 */
+};
+
+	static double pone(double x)
+{
+	const double *p,*q;
+	double z,r,s;
+        int32_t ix;
+	GET_HIGH_WORD(ix,x);
+	ix &= 0x7fffffff;
+        if(ix>=0x40200000)     {p = pr8; q= ps8;}
+        else if(ix>=0x40122E8B){p = pr5; q= ps5;}
+        else if(ix>=0x4006DB6D){p = pr3; q= ps3;}
+        else if(ix>=0x40000000){p = pr2; q= ps2;}
+        z = one/(x*x);
+        r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
+        s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
+        return one+ r/s;
+}
+		
+
+/* For x >= 8, the asymptotic expansions of qone is
+ *	3/8 s - 105/1024 s^3 - ..., where s = 1/x.
+ * We approximate pone by
+ * 	qone(x) = s*(0.375 + (R/S))
+ * where  R = qr1*s^2 + qr2*s^4 + ... + qr5*s^10
+ * 	  S = 1 + qs1*s^2 + ... + qs6*s^12
+ * and
+ *	| qone(x)/s -0.375-R/S | <= 2  ** ( -61.13)
+ */
+
+static const double qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+  0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
+ -1.02539062499992714161e-01, /* 0xBFBA3FFF, 0xFFFFFDF3 */
+ -1.62717534544589987888e+01, /* 0xC0304591, 0xA26779F7 */
+ -7.59601722513950107896e+02, /* 0xC087BCD0, 0x53E4B576 */
+ -1.18498066702429587167e+04, /* 0xC0C724E7, 0x40F87415 */
+ -4.84385124285750353010e+04, /* 0xC0E7A6D0, 0x65D09C6A */
+};
+static const double qs8[6] = {
+  1.61395369700722909556e+02, /* 0x40642CA6, 0xDE5BCDE5 */
+  7.82538599923348465381e+03, /* 0x40BE9162, 0xD0D88419 */
+  1.33875336287249578163e+05, /* 0x4100579A, 0xB0B75E98 */
+  7.19657723683240939863e+05, /* 0x4125F653, 0x72869C19 */
+  6.66601232617776375264e+05, /* 0x412457D2, 0x7719AD5C */
+ -2.94490264303834643215e+05, /* 0xC111F969, 0x0EA5AA18 */
+};
+
+static const double qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+ -2.08979931141764104297e-11, /* 0xBDB6FA43, 0x1AA1A098 */
+ -1.02539050241375426231e-01, /* 0xBFBA3FFF, 0xCB597FEF */
+ -8.05644828123936029840e+00, /* 0xC0201CE6, 0xCA03AD4B */
+ -1.83669607474888380239e+02, /* 0xC066F56D, 0x6CA7B9B0 */
+ -1.37319376065508163265e+03, /* 0xC09574C6, 0x6931734F */
+ -2.61244440453215656817e+03, /* 0xC0A468E3, 0x88FDA79D */
+};
+static const double qs5[6] = {
+  8.12765501384335777857e+01, /* 0x405451B2, 0xFF5A11B2 */
+  1.99179873460485964642e+03, /* 0x409F1F31, 0xE77BF839 */
+  1.74684851924908907677e+04, /* 0x40D10F1F, 0x0D64CE29 */
+  4.98514270910352279316e+04, /* 0x40E8576D, 0xAABAD197 */
+  2.79480751638918118260e+04, /* 0x40DB4B04, 0xCF7C364B */
+ -4.71918354795128470869e+03, /* 0xC0B26F2E, 0xFCFFA004 */
+};
+
+static const double qr3[6] = {
+ -5.07831226461766561369e-09, /* 0xBE35CFA9, 0xD38FC84F */
+ -1.02537829820837089745e-01, /* 0xBFBA3FEB, 0x51AEED54 */
+ -4.61011581139473403113e+00, /* 0xC01270C2, 0x3302D9FF */
+ -5.78472216562783643212e+01, /* 0xC04CEC71, 0xC25D16DA */
+ -2.28244540737631695038e+02, /* 0xC06C87D3, 0x4718D55F */
+ -2.19210128478909325622e+02, /* 0xC06B66B9, 0x5F5C1BF6 */
+};
+static const double qs3[6] = {
+  4.76651550323729509273e+01, /* 0x4047D523, 0xCCD367E4 */
+  6.73865112676699709482e+02, /* 0x40850EEB, 0xC031EE3E */
+  3.38015286679526343505e+03, /* 0x40AA684E, 0x448E7C9A */
+  5.54772909720722782367e+03, /* 0x40B5ABBA, 0xA61D54A6 */
+  1.90311919338810798763e+03, /* 0x409DBC7A, 0x0DD4DF4B */
+ -1.35201191444307340817e+02, /* 0xC060E670, 0x290A311F */
+};
+
+static const double qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+ -1.78381727510958865572e-07, /* 0xBE87F126, 0x44C626D2 */
+ -1.02517042607985553460e-01, /* 0xBFBA3E8E, 0x9148B010 */
+ -2.75220568278187460720e+00, /* 0xC0060484, 0x69BB4EDA */
+ -1.96636162643703720221e+01, /* 0xC033A9E2, 0xC168907F */
+ -4.23253133372830490089e+01, /* 0xC04529A3, 0xDE104AAA */
+ -2.13719211703704061733e+01, /* 0xC0355F36, 0x39CF6E52 */
+};
+static const double qs2[6] = {
+  2.95333629060523854548e+01, /* 0x403D888A, 0x78AE64FF */
+  2.52981549982190529136e+02, /* 0x406F9F68, 0xDB821CBA */
+  7.57502834868645436472e+02, /* 0x4087AC05, 0xCE49A0F7 */
+  7.39393205320467245656e+02, /* 0x40871B25, 0x48D4C029 */
+  1.55949003336666123687e+02, /* 0x40637E5E, 0x3C3ED8D4 */
+ -4.95949898822628210127e+00, /* 0xC013D686, 0xE71BE86B */
+};
+
+	static double qone(double x)
+{
+	const double *p,*q;
+	double  s,r,z;
+	int32_t ix;
+	GET_HIGH_WORD(ix,x);
+	ix &= 0x7fffffff;
+	if(ix>=0x40200000)     {p = qr8; q= qs8;}
+	else if(ix>=0x40122E8B){p = qr5; q= qs5;}
+	else if(ix>=0x4006DB6D){p = qr3; q= qs3;}
+	else if(ix>=0x40000000){p = qr2; q= qs2;}
+	z = one/(x*x);
+	r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
+	s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
+	return (.375 + r/s)/x;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_j1f.c b/libm/upstream-freebsd/lib/msun/src/e_j1f.c
new file mode 100644
index 0000000..88e2d83
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_j1f.c
@@ -0,0 +1,333 @@
+/* e_j1f.c -- float version of e_j1.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static float ponef(float), qonef(float);
+
+static const float
+huge    = 1e30,
+one	= 1.0,
+invsqrtpi=  5.6418961287e-01, /* 0x3f106ebb */
+tpi      =  6.3661974669e-01, /* 0x3f22f983 */
+	/* R0/S0 on [0,2] */
+r00  = -6.2500000000e-02, /* 0xbd800000 */
+r01  =  1.4070566976e-03, /* 0x3ab86cfd */
+r02  = -1.5995563444e-05, /* 0xb7862e36 */
+r03  =  4.9672799207e-08, /* 0x335557d2 */
+s01  =  1.9153760746e-02, /* 0x3c9ce859 */
+s02  =  1.8594678841e-04, /* 0x3942fab6 */
+s03  =  1.1771846857e-06, /* 0x359dffc2 */
+s04  =  5.0463624390e-09, /* 0x31ad6446 */
+s05  =  1.2354227016e-11; /* 0x2d59567e */
+
+static const float zero    = 0.0;
+
+float
+__ieee754_j1f(float x)
+{
+	float z, s,c,ss,cc,r,u,v,y;
+	int32_t hx,ix;
+
+	GET_FLOAT_WORD(hx,x);
+	ix = hx&0x7fffffff;
+	if(ix>=0x7f800000) return one/x;
+	y = fabsf(x);
+	if(ix >= 0x40000000) {	/* |x| >= 2.0 */
+		s = sinf(y);
+		c = cosf(y);
+		ss = -s-c;
+		cc = s-c;
+		if(ix<0x7f000000) {  /* make sure y+y not overflow */
+		    z = cosf(y+y);
+		    if ((s*c)>zero) cc = z/ss;
+		    else 	    ss = z/cc;
+		}
+	/*
+	 * j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x)
+	 * y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x)
+	 */
+		if(ix>0x80000000) z = (invsqrtpi*cc)/sqrtf(y);
+		else {
+		    u = ponef(y); v = qonef(y);
+		    z = invsqrtpi*(u*cc-v*ss)/sqrtf(y);
+		}
+		if(hx<0) return -z;
+		else  	 return  z;
+	}
+	if(ix<0x32000000) {	/* |x|<2**-27 */
+	    if(huge+x>one) return (float)0.5*x;/* inexact if x!=0 necessary */
+	}
+	z = x*x;
+	r =  z*(r00+z*(r01+z*(r02+z*r03)));
+	s =  one+z*(s01+z*(s02+z*(s03+z*(s04+z*s05))));
+	r *= x;
+	return(x*(float)0.5+r/s);
+}
+
+static const float U0[5] = {
+ -1.9605709612e-01, /* 0xbe48c331 */
+  5.0443872809e-02, /* 0x3d4e9e3c */
+ -1.9125689287e-03, /* 0xbafaaf2a */
+  2.3525259166e-05, /* 0x37c5581c */
+ -9.1909917899e-08, /* 0xb3c56003 */
+};
+static const float V0[5] = {
+  1.9916731864e-02, /* 0x3ca3286a */
+  2.0255257550e-04, /* 0x3954644b */
+  1.3560879779e-06, /* 0x35b602d4 */
+  6.2274145840e-09, /* 0x31d5f8eb */
+  1.6655924903e-11, /* 0x2d9281cf */
+};
+
+float
+__ieee754_y1f(float x)
+{
+	float z, s,c,ss,cc,u,v;
+	int32_t hx,ix;
+
+	GET_FLOAT_WORD(hx,x);
+        ix = 0x7fffffff&hx;
+    /* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */
+	if(ix>=0x7f800000) return  one/(x+x*x);
+        if(ix==0) return -one/zero;
+        if(hx<0) return zero/zero;
+        if(ix >= 0x40000000) {  /* |x| >= 2.0 */
+                s = sinf(x);
+                c = cosf(x);
+                ss = -s-c;
+                cc = s-c;
+                if(ix<0x7f000000) {  /* make sure x+x not overflow */
+                    z = cosf(x+x);
+                    if ((s*c)>zero) cc = z/ss;
+                    else            ss = z/cc;
+                }
+        /* y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x0)+q1(x)*cos(x0))
+         * where x0 = x-3pi/4
+         *      Better formula:
+         *              cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4)
+         *                      =  1/sqrt(2) * (sin(x) - cos(x))
+         *              sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
+         *                      = -1/sqrt(2) * (cos(x) + sin(x))
+         * To avoid cancellation, use
+         *              sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
+         * to compute the worse one.
+         */
+                if(ix>0x48000000) z = (invsqrtpi*ss)/sqrtf(x);
+                else {
+                    u = ponef(x); v = qonef(x);
+                    z = invsqrtpi*(u*ss+v*cc)/sqrtf(x);
+                }
+                return z;
+        }
+        if(ix<=0x24800000) {    /* x < 2**-54 */
+            return(-tpi/x);
+        }
+        z = x*x;
+        u = U0[0]+z*(U0[1]+z*(U0[2]+z*(U0[3]+z*U0[4])));
+        v = one+z*(V0[0]+z*(V0[1]+z*(V0[2]+z*(V0[3]+z*V0[4]))));
+        return(x*(u/v) + tpi*(__ieee754_j1f(x)*__ieee754_logf(x)-one/x));
+}
+
+/* For x >= 8, the asymptotic expansions of pone is
+ *	1 + 15/128 s^2 - 4725/2^15 s^4 - ...,	where s = 1/x.
+ * We approximate pone by
+ * 	pone(x) = 1 + (R/S)
+ * where  R = pr0 + pr1*s^2 + pr2*s^4 + ... + pr5*s^10
+ * 	  S = 1 + ps0*s^2 + ... + ps4*s^10
+ * and
+ *	| pone(x)-1-R/S | <= 2  ** ( -60.06)
+ */
+
+static const float pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+  0.0000000000e+00, /* 0x00000000 */
+  1.1718750000e-01, /* 0x3df00000 */
+  1.3239480972e+01, /* 0x4153d4ea */
+  4.1205184937e+02, /* 0x43ce06a3 */
+  3.8747453613e+03, /* 0x45722bed */
+  7.9144794922e+03, /* 0x45f753d6 */
+};
+static const float ps8[5] = {
+  1.1420736694e+02, /* 0x42e46a2c */
+  3.6509309082e+03, /* 0x45642ee5 */
+  3.6956207031e+04, /* 0x47105c35 */
+  9.7602796875e+04, /* 0x47bea166 */
+  3.0804271484e+04, /* 0x46f0a88b */
+};
+
+static const float pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+  1.3199052094e-11, /* 0x2d68333f */
+  1.1718749255e-01, /* 0x3defffff */
+  6.8027510643e+00, /* 0x40d9b023 */
+  1.0830818176e+02, /* 0x42d89dca */
+  5.1763616943e+02, /* 0x440168b7 */
+  5.2871520996e+02, /* 0x44042dc6 */
+};
+static const float ps5[5] = {
+  5.9280597687e+01, /* 0x426d1f55 */
+  9.9140142822e+02, /* 0x4477d9b1 */
+  5.3532670898e+03, /* 0x45a74a23 */
+  7.8446904297e+03, /* 0x45f52586 */
+  1.5040468750e+03, /* 0x44bc0180 */
+};
+
+static const float pr3[6] = {
+  3.0250391081e-09, /* 0x314fe10d */
+  1.1718686670e-01, /* 0x3defffab */
+  3.9329774380e+00, /* 0x407bb5e7 */
+  3.5119403839e+01, /* 0x420c7a45 */
+  9.1055007935e+01, /* 0x42b61c2a */
+  4.8559066772e+01, /* 0x42423c7c */
+};
+static const float ps3[5] = {
+  3.4791309357e+01, /* 0x420b2a4d */
+  3.3676245117e+02, /* 0x43a86198 */
+  1.0468714600e+03, /* 0x4482dbe3 */
+  8.9081134033e+02, /* 0x445eb3ed */
+  1.0378793335e+02, /* 0x42cf936c */
+};
+
+static const float pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+  1.0771083225e-07, /* 0x33e74ea8 */
+  1.1717621982e-01, /* 0x3deffa16 */
+  2.3685150146e+00, /* 0x401795c0 */
+  1.2242610931e+01, /* 0x4143e1bc */
+  1.7693971634e+01, /* 0x418d8d41 */
+  5.0735230446e+00, /* 0x40a25a4d */
+};
+static const float ps2[5] = {
+  2.1436485291e+01, /* 0x41ab7dec */
+  1.2529022980e+02, /* 0x42fa9499 */
+  2.3227647400e+02, /* 0x436846c7 */
+  1.1767937469e+02, /* 0x42eb5bd7 */
+  8.3646392822e+00, /* 0x4105d590 */
+};
+
+	static float ponef(float x)
+{
+	const float *p,*q;
+	float z,r,s;
+        int32_t ix;
+	GET_FLOAT_WORD(ix,x);
+	ix &= 0x7fffffff;
+        if(ix>=0x41000000)     {p = pr8; q= ps8;}
+        else if(ix>=0x40f71c58){p = pr5; q= ps5;}
+        else if(ix>=0x4036db68){p = pr3; q= ps3;}
+        else if(ix>=0x40000000){p = pr2; q= ps2;}
+        z = one/(x*x);
+        r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
+        s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
+        return one+ r/s;
+}
+
+
+/* For x >= 8, the asymptotic expansions of qone is
+ *	3/8 s - 105/1024 s^3 - ..., where s = 1/x.
+ * We approximate pone by
+ * 	qone(x) = s*(0.375 + (R/S))
+ * where  R = qr1*s^2 + qr2*s^4 + ... + qr5*s^10
+ * 	  S = 1 + qs1*s^2 + ... + qs6*s^12
+ * and
+ *	| qone(x)/s -0.375-R/S | <= 2  ** ( -61.13)
+ */
+
+static const float qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+  0.0000000000e+00, /* 0x00000000 */
+ -1.0253906250e-01, /* 0xbdd20000 */
+ -1.6271753311e+01, /* 0xc1822c8d */
+ -7.5960174561e+02, /* 0xc43de683 */
+ -1.1849806641e+04, /* 0xc639273a */
+ -4.8438511719e+04, /* 0xc73d3683 */
+};
+static const float qs8[6] = {
+  1.6139537048e+02, /* 0x43216537 */
+  7.8253862305e+03, /* 0x45f48b17 */
+  1.3387534375e+05, /* 0x4802bcd6 */
+  7.1965775000e+05, /* 0x492fb29c */
+  6.6660125000e+05, /* 0x4922be94 */
+ -2.9449025000e+05, /* 0xc88fcb48 */
+};
+
+static const float qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+ -2.0897993405e-11, /* 0xadb7d219 */
+ -1.0253904760e-01, /* 0xbdd1fffe */
+ -8.0564479828e+00, /* 0xc100e736 */
+ -1.8366960144e+02, /* 0xc337ab6b */
+ -1.3731937256e+03, /* 0xc4aba633 */
+ -2.6124443359e+03, /* 0xc523471c */
+};
+static const float qs5[6] = {
+  8.1276550293e+01, /* 0x42a28d98 */
+  1.9917987061e+03, /* 0x44f8f98f */
+  1.7468484375e+04, /* 0x468878f8 */
+  4.9851425781e+04, /* 0x4742bb6d */
+  2.7948074219e+04, /* 0x46da5826 */
+ -4.7191835938e+03, /* 0xc5937978 */
+};
+
+static const float qr3[6] = {
+ -5.0783124372e-09, /* 0xb1ae7d4f */
+ -1.0253783315e-01, /* 0xbdd1ff5b */
+ -4.6101160049e+00, /* 0xc0938612 */
+ -5.7847221375e+01, /* 0xc267638e */
+ -2.2824453735e+02, /* 0xc3643e9a */
+ -2.1921012878e+02, /* 0xc35b35cb */
+};
+static const float qs3[6] = {
+  4.7665153503e+01, /* 0x423ea91e */
+  6.7386511230e+02, /* 0x4428775e */
+  3.3801528320e+03, /* 0x45534272 */
+  5.5477290039e+03, /* 0x45ad5dd5 */
+  1.9031191406e+03, /* 0x44ede3d0 */
+ -1.3520118713e+02, /* 0xc3073381 */
+};
+
+static const float qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+ -1.7838172539e-07, /* 0xb43f8932 */
+ -1.0251704603e-01, /* 0xbdd1f475 */
+ -2.7522056103e+00, /* 0xc0302423 */
+ -1.9663616180e+01, /* 0xc19d4f16 */
+ -4.2325313568e+01, /* 0xc2294d1f */
+ -2.1371921539e+01, /* 0xc1aaf9b2 */
+};
+static const float qs2[6] = {
+  2.9533363342e+01, /* 0x41ec4454 */
+  2.5298155212e+02, /* 0x437cfb47 */
+  7.5750280762e+02, /* 0x443d602e */
+  7.3939318848e+02, /* 0x4438d92a */
+  1.5594900513e+02, /* 0x431bf2f2 */
+ -4.9594988823e+00, /* 0xc09eb437 */
+};
+
+	static float qonef(float x)
+{
+	const float *p,*q;
+	float  s,r,z;
+	int32_t ix;
+	GET_FLOAT_WORD(ix,x);
+	ix &= 0x7fffffff;
+	if(ix>=0x40200000)     {p = qr8; q= qs8;}
+	else if(ix>=0x40f71c58){p = qr5; q= qs5;}
+	else if(ix>=0x4036db68){p = qr3; q= qs3;}
+	else if(ix>=0x40000000){p = qr2; q= qs2;}
+	z = one/(x*x);
+	r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
+	s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
+	return ((float).375 + r/s)/x;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_jn.c b/libm/upstream-freebsd/lib/msun/src/e_jn.c
new file mode 100644
index 0000000..8b0bc62
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_jn.c
@@ -0,0 +1,270 @@
+
+/* @(#)e_jn.c 1.4 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * __ieee754_jn(n, x), __ieee754_yn(n, x)
+ * floating point Bessel's function of the 1st and 2nd kind
+ * of order n
+ *          
+ * Special cases:
+ *	y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal;
+ *	y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal.
+ * Note 2. About jn(n,x), yn(n,x)
+ *	For n=0, j0(x) is called,
+ *	for n=1, j1(x) is called,
+ *	for n<x, forward recursion us used starting
+ *	from values of j0(x) and j1(x).
+ *	for n>x, a continued fraction approximation to
+ *	j(n,x)/j(n-1,x) is evaluated and then backward
+ *	recursion is used starting from a supposed value
+ *	for j(n,x). The resulting value of j(0,x) is
+ *	compared with the actual value to correct the
+ *	supposed value of j(n,x).
+ *
+ *	yn(n,x) is similar in all respects, except
+ *	that forward recursion is used for all
+ *	values of n>1.
+ *	
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+static const double
+invsqrtpi=  5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */
+two   =  2.00000000000000000000e+00, /* 0x40000000, 0x00000000 */
+one   =  1.00000000000000000000e+00; /* 0x3FF00000, 0x00000000 */
+
+static const double zero  =  0.00000000000000000000e+00;
+
+double
+__ieee754_jn(int n, double x)
+{
+	int32_t i,hx,ix,lx, sgn;
+	double a, b, temp, di;
+	double z, w;
+
+    /* J(-n,x) = (-1)^n * J(n, x), J(n, -x) = (-1)^n * J(n, x)
+     * Thus, J(-n,x) = J(n,-x)
+     */
+	EXTRACT_WORDS(hx,lx,x);
+	ix = 0x7fffffff&hx;
+    /* if J(n,NaN) is NaN */
+	if((ix|((u_int32_t)(lx|-lx))>>31)>0x7ff00000) return x+x;
+	if(n<0){		
+		n = -n;
+		x = -x;
+		hx ^= 0x80000000;
+	}
+	if(n==0) return(__ieee754_j0(x));
+	if(n==1) return(__ieee754_j1(x));
+	sgn = (n&1)&(hx>>31);	/* even n -- 0, odd n -- sign(x) */
+	x = fabs(x);
+	if((ix|lx)==0||ix>=0x7ff00000) 	/* if x is 0 or inf */
+	    b = zero;
+	else if((double)n<=x) {   
+		/* Safe to use J(n+1,x)=2n/x *J(n,x)-J(n-1,x) */
+	    if(ix>=0x52D00000) { /* x > 2**302 */
+    /* (x >> n**2) 
+     *	    Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi)
+     *	    Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi)
+     *	    Let s=sin(x), c=cos(x), 
+     *		xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then
+     *
+     *		   n	sin(xn)*sqt2	cos(xn)*sqt2
+     *		----------------------------------
+     *		   0	 s-c		 c+s
+     *		   1	-s-c 		-c+s
+     *		   2	-s+c		-c-s
+     *		   3	 s+c		 c-s
+     */
+		switch(n&3) {
+		    case 0: temp =  cos(x)+sin(x); break;
+		    case 1: temp = -cos(x)+sin(x); break;
+		    case 2: temp = -cos(x)-sin(x); break;
+		    case 3: temp =  cos(x)-sin(x); break;
+		}
+		b = invsqrtpi*temp/sqrt(x);
+	    } else {	
+	        a = __ieee754_j0(x);
+	        b = __ieee754_j1(x);
+	        for(i=1;i<n;i++){
+		    temp = b;
+		    b = b*((double)(i+i)/x) - a; /* avoid underflow */
+		    a = temp;
+	        }
+	    }
+	} else {
+	    if(ix<0x3e100000) {	/* x < 2**-29 */
+    /* x is tiny, return the first Taylor expansion of J(n,x) 
+     * J(n,x) = 1/n!*(x/2)^n  - ...
+     */
+		if(n>33)	/* underflow */
+		    b = zero;
+		else {
+		    temp = x*0.5; b = temp;
+		    for (a=one,i=2;i<=n;i++) {
+			a *= (double)i;		/* a = n! */
+			b *= temp;		/* b = (x/2)^n */
+		    }
+		    b = b/a;
+		}
+	    } else {
+		/* use backward recurrence */
+		/* 			x      x^2      x^2       
+		 *  J(n,x)/J(n-1,x) =  ----   ------   ------   .....
+		 *			2n  - 2(n+1) - 2(n+2)
+		 *
+		 * 			1      1        1       
+		 *  (for large x)   =  ----  ------   ------   .....
+		 *			2n   2(n+1)   2(n+2)
+		 *			-- - ------ - ------ - 
+		 *			 x     x         x
+		 *
+		 * Let w = 2n/x and h=2/x, then the above quotient
+		 * is equal to the continued fraction:
+		 *		    1
+		 *	= -----------------------
+		 *		       1
+		 *	   w - -----------------
+		 *			  1
+		 * 	        w+h - ---------
+		 *		       w+2h - ...
+		 *
+		 * To determine how many terms needed, let
+		 * Q(0) = w, Q(1) = w(w+h) - 1,
+		 * Q(k) = (w+k*h)*Q(k-1) - Q(k-2),
+		 * When Q(k) > 1e4	good for single 
+		 * When Q(k) > 1e9	good for double 
+		 * When Q(k) > 1e17	good for quadruple 
+		 */
+	    /* determine k */
+		double t,v;
+		double q0,q1,h,tmp; int32_t k,m;
+		w  = (n+n)/(double)x; h = 2.0/(double)x;
+		q0 = w;  z = w+h; q1 = w*z - 1.0; k=1;
+		while(q1<1.0e9) {
+			k += 1; z += h;
+			tmp = z*q1 - q0;
+			q0 = q1;
+			q1 = tmp;
+		}
+		m = n+n;
+		for(t=zero, i = 2*(n+k); i>=m; i -= 2) t = one/(i/x-t);
+		a = t;
+		b = one;
+		/*  estimate log((2/x)^n*n!) = n*log(2/x)+n*ln(n)
+		 *  Hence, if n*(log(2n/x)) > ...
+		 *  single 8.8722839355e+01
+		 *  double 7.09782712893383973096e+02
+		 *  long double 1.1356523406294143949491931077970765006170e+04
+		 *  then recurrent value may overflow and the result is
+		 *  likely underflow to zero
+		 */
+		tmp = n;
+		v = two/x;
+		tmp = tmp*__ieee754_log(fabs(v*tmp));
+		if(tmp<7.09782712893383973096e+02) {
+	    	    for(i=n-1,di=(double)(i+i);i>0;i--){
+		        temp = b;
+			b *= di;
+			b  = b/x - a;
+		        a = temp;
+			di -= two;
+	     	    }
+		} else {
+	    	    for(i=n-1,di=(double)(i+i);i>0;i--){
+		        temp = b;
+			b *= di;
+			b  = b/x - a;
+		        a = temp;
+			di -= two;
+		    /* scale b to avoid spurious overflow */
+			if(b>1e100) {
+			    a /= b;
+			    t /= b;
+			    b  = one;
+			}
+	     	    }
+		}
+		z = __ieee754_j0(x);
+		w = __ieee754_j1(x);
+		if (fabs(z) >= fabs(w))
+		    b = (t*z/b);
+		else
+		    b = (t*w/a);
+	    }
+	}
+	if(sgn==1) return -b; else return b;
+}
+
+double
+__ieee754_yn(int n, double x)
+{
+	int32_t i,hx,ix,lx;
+	int32_t sign;
+	double a, b, temp;
+
+	EXTRACT_WORDS(hx,lx,x);
+	ix = 0x7fffffff&hx;
+    /* if Y(n,NaN) is NaN */
+	if((ix|((u_int32_t)(lx|-lx))>>31)>0x7ff00000) return x+x;
+	if((ix|lx)==0) return -one/zero;
+	if(hx<0) return zero/zero;
+	sign = 1;
+	if(n<0){
+		n = -n;
+		sign = 1 - ((n&1)<<1);
+	}
+	if(n==0) return(__ieee754_y0(x));
+	if(n==1) return(sign*__ieee754_y1(x));
+	if(ix==0x7ff00000) return zero;
+	if(ix>=0x52D00000) { /* x > 2**302 */
+    /* (x >> n**2) 
+     *	    Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi)
+     *	    Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi)
+     *	    Let s=sin(x), c=cos(x), 
+     *		xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then
+     *
+     *		   n	sin(xn)*sqt2	cos(xn)*sqt2
+     *		----------------------------------
+     *		   0	 s-c		 c+s
+     *		   1	-s-c 		-c+s
+     *		   2	-s+c		-c-s
+     *		   3	 s+c		 c-s
+     */
+		switch(n&3) {
+		    case 0: temp =  sin(x)-cos(x); break;
+		    case 1: temp = -sin(x)-cos(x); break;
+		    case 2: temp = -sin(x)+cos(x); break;
+		    case 3: temp =  sin(x)+cos(x); break;
+		}
+		b = invsqrtpi*temp/sqrt(x);
+	} else {
+	    u_int32_t high;
+	    a = __ieee754_y0(x);
+	    b = __ieee754_y1(x);
+	/* quit if b is -inf */
+	    GET_HIGH_WORD(high,b);
+	    for(i=1;i<n&&high!=0xfff00000;i++){
+		temp = b;
+		b = ((double)(i+i)/x)*b - a;
+		GET_HIGH_WORD(high,b);
+		a = temp;
+	    }
+	}
+	if(sign>0) return b; else return -b;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_jnf.c b/libm/upstream-freebsd/lib/msun/src/e_jnf.c
new file mode 100644
index 0000000..f564aec
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_jnf.c
@@ -0,0 +1,199 @@
+/* e_jnf.c -- float version of e_jn.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static const float
+two   =  2.0000000000e+00, /* 0x40000000 */
+one   =  1.0000000000e+00; /* 0x3F800000 */
+
+static const float zero  =  0.0000000000e+00;
+
+float
+__ieee754_jnf(int n, float x)
+{
+	int32_t i,hx,ix, sgn;
+	float a, b, temp, di;
+	float z, w;
+
+    /* J(-n,x) = (-1)^n * J(n, x), J(n, -x) = (-1)^n * J(n, x)
+     * Thus, J(-n,x) = J(n,-x)
+     */
+	GET_FLOAT_WORD(hx,x);
+	ix = 0x7fffffff&hx;
+    /* if J(n,NaN) is NaN */
+	if(ix>0x7f800000) return x+x;
+	if(n<0){
+		n = -n;
+		x = -x;
+		hx ^= 0x80000000;
+	}
+	if(n==0) return(__ieee754_j0f(x));
+	if(n==1) return(__ieee754_j1f(x));
+	sgn = (n&1)&(hx>>31);	/* even n -- 0, odd n -- sign(x) */
+	x = fabsf(x);
+	if(ix==0||ix>=0x7f800000) 	/* if x is 0 or inf */
+	    b = zero;
+	else if((float)n<=x) {
+		/* Safe to use J(n+1,x)=2n/x *J(n,x)-J(n-1,x) */
+	    a = __ieee754_j0f(x);
+	    b = __ieee754_j1f(x);
+	    for(i=1;i<n;i++){
+		temp = b;
+		b = b*((float)(i+i)/x) - a; /* avoid underflow */
+		a = temp;
+	    }
+	} else {
+	    if(ix<0x30800000) {	/* x < 2**-29 */
+    /* x is tiny, return the first Taylor expansion of J(n,x)
+     * J(n,x) = 1/n!*(x/2)^n  - ...
+     */
+		if(n>33)	/* underflow */
+		    b = zero;
+		else {
+		    temp = x*(float)0.5; b = temp;
+		    for (a=one,i=2;i<=n;i++) {
+			a *= (float)i;		/* a = n! */
+			b *= temp;		/* b = (x/2)^n */
+		    }
+		    b = b/a;
+		}
+	    } else {
+		/* use backward recurrence */
+		/* 			x      x^2      x^2
+		 *  J(n,x)/J(n-1,x) =  ----   ------   ------   .....
+		 *			2n  - 2(n+1) - 2(n+2)
+		 *
+		 * 			1      1        1
+		 *  (for large x)   =  ----  ------   ------   .....
+		 *			2n   2(n+1)   2(n+2)
+		 *			-- - ------ - ------ -
+		 *			 x     x         x
+		 *
+		 * Let w = 2n/x and h=2/x, then the above quotient
+		 * is equal to the continued fraction:
+		 *		    1
+		 *	= -----------------------
+		 *		       1
+		 *	   w - -----------------
+		 *			  1
+		 * 	        w+h - ---------
+		 *		       w+2h - ...
+		 *
+		 * To determine how many terms needed, let
+		 * Q(0) = w, Q(1) = w(w+h) - 1,
+		 * Q(k) = (w+k*h)*Q(k-1) - Q(k-2),
+		 * When Q(k) > 1e4	good for single
+		 * When Q(k) > 1e9	good for double
+		 * When Q(k) > 1e17	good for quadruple
+		 */
+	    /* determine k */
+		float t,v;
+		float q0,q1,h,tmp; int32_t k,m;
+		w  = (n+n)/(float)x; h = (float)2.0/(float)x;
+		q0 = w;  z = w+h; q1 = w*z - (float)1.0; k=1;
+		while(q1<(float)1.0e9) {
+			k += 1; z += h;
+			tmp = z*q1 - q0;
+			q0 = q1;
+			q1 = tmp;
+		}
+		m = n+n;
+		for(t=zero, i = 2*(n+k); i>=m; i -= 2) t = one/(i/x-t);
+		a = t;
+		b = one;
+		/*  estimate log((2/x)^n*n!) = n*log(2/x)+n*ln(n)
+		 *  Hence, if n*(log(2n/x)) > ...
+		 *  single 8.8722839355e+01
+		 *  double 7.09782712893383973096e+02
+		 *  long double 1.1356523406294143949491931077970765006170e+04
+		 *  then recurrent value may overflow and the result is
+		 *  likely underflow to zero
+		 */
+		tmp = n;
+		v = two/x;
+		tmp = tmp*__ieee754_logf(fabsf(v*tmp));
+		if(tmp<(float)8.8721679688e+01) {
+	    	    for(i=n-1,di=(float)(i+i);i>0;i--){
+		        temp = b;
+			b *= di;
+			b  = b/x - a;
+		        a = temp;
+			di -= two;
+	     	    }
+		} else {
+	    	    for(i=n-1,di=(float)(i+i);i>0;i--){
+		        temp = b;
+			b *= di;
+			b  = b/x - a;
+		        a = temp;
+			di -= two;
+		    /* scale b to avoid spurious overflow */
+			if(b>(float)1e10) {
+			    a /= b;
+			    t /= b;
+			    b  = one;
+			}
+	     	    }
+		}
+		z = __ieee754_j0f(x);
+		w = __ieee754_j1f(x);
+		if (fabsf(z) >= fabsf(w))
+		    b = (t*z/b);
+		else
+		    b = (t*w/a);
+	    }
+	}
+	if(sgn==1) return -b; else return b;
+}
+
+float
+__ieee754_ynf(int n, float x)
+{
+	int32_t i,hx,ix,ib;
+	int32_t sign;
+	float a, b, temp;
+
+	GET_FLOAT_WORD(hx,x);
+	ix = 0x7fffffff&hx;
+    /* if Y(n,NaN) is NaN */
+	if(ix>0x7f800000) return x+x;
+	if(ix==0) return -one/zero;
+	if(hx<0) return zero/zero;
+	sign = 1;
+	if(n<0){
+		n = -n;
+		sign = 1 - ((n&1)<<1);
+	}
+	if(n==0) return(__ieee754_y0f(x));
+	if(n==1) return(sign*__ieee754_y1f(x));
+	if(ix==0x7f800000) return zero;
+
+	a = __ieee754_y0f(x);
+	b = __ieee754_y1f(x);
+	/* quit if b is -inf */
+	GET_FLOAT_WORD(ib,b);
+	for(i=1;i<n&&ib!=0xff800000;i++){
+	    temp = b;
+	    b = ((float)(i+i)/x)*b - a;
+	    GET_FLOAT_WORD(ib,b);
+	    a = temp;
+	}
+	if(sign>0) return b; else return -b;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_lgamma.c b/libm/upstream-freebsd/lib/msun/src/e_lgamma.c
new file mode 100644
index 0000000..4674d9b
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_lgamma.c
@@ -0,0 +1,33 @@
+
+/* @(#)e_lgamma.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_lgamma(x)
+ * Return the logarithm of the Gamma function of x.
+ *
+ * Method: call __ieee754_lgamma_r
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+extern int signgam;
+
+double
+__ieee754_lgamma(double x)
+{
+	return __ieee754_lgamma_r(x,&signgam);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_lgamma_r.c b/libm/upstream-freebsd/lib/msun/src/e_lgamma_r.c
new file mode 100644
index 0000000..1cff592
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_lgamma_r.c
@@ -0,0 +1,297 @@
+
+/* @(#)e_lgamma_r.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_lgamma_r(x, signgamp)
+ * Reentrant version of the logarithm of the Gamma function 
+ * with user provide pointer for the sign of Gamma(x). 
+ *
+ * Method:
+ *   1. Argument Reduction for 0 < x <= 8
+ * 	Since gamma(1+s)=s*gamma(s), for x in [0,8], we may 
+ * 	reduce x to a number in [1.5,2.5] by
+ * 		lgamma(1+s) = log(s) + lgamma(s)
+ *	for example,
+ *		lgamma(7.3) = log(6.3) + lgamma(6.3)
+ *			    = log(6.3*5.3) + lgamma(5.3)
+ *			    = log(6.3*5.3*4.3*3.3*2.3) + lgamma(2.3)
+ *   2. Polynomial approximation of lgamma around its
+ *	minimun ymin=1.461632144968362245 to maintain monotonicity.
+ *	On [ymin-0.23, ymin+0.27] (i.e., [1.23164,1.73163]), use
+ *		Let z = x-ymin;
+ *		lgamma(x) = -1.214862905358496078218 + z^2*poly(z)
+ *	where
+ *		poly(z) is a 14 degree polynomial.
+ *   2. Rational approximation in the primary interval [2,3]
+ *	We use the following approximation:
+ *		s = x-2.0;
+ *		lgamma(x) = 0.5*s + s*P(s)/Q(s)
+ *	with accuracy
+ *		|P/Q - (lgamma(x)-0.5s)| < 2**-61.71
+ *	Our algorithms are based on the following observation
+ *
+ *                             zeta(2)-1    2    zeta(3)-1    3
+ * lgamma(2+s) = s*(1-Euler) + --------- * s  -  --------- * s  + ...
+ *                                 2                 3
+ *
+ *	where Euler = 0.5771... is the Euler constant, which is very
+ *	close to 0.5.
+ *
+ *   3. For x>=8, we have
+ *	lgamma(x)~(x-0.5)log(x)-x+0.5*log(2pi)+1/(12x)-1/(360x**3)+....
+ *	(better formula:
+ *	   lgamma(x)~(x-0.5)*(log(x)-1)-.5*(log(2pi)-1) + ...)
+ *	Let z = 1/x, then we approximation
+ *		f(z) = lgamma(x) - (x-0.5)(log(x)-1)
+ *	by
+ *	  			    3       5             11
+ *		w = w0 + w1*z + w2*z  + w3*z  + ... + w6*z
+ *	where 
+ *		|w - f(z)| < 2**-58.74
+ *		
+ *   4. For negative x, since (G is gamma function)
+ *		-x*G(-x)*G(x) = pi/sin(pi*x),
+ * 	we have
+ * 		G(x) = pi/(sin(pi*x)*(-x)*G(-x))
+ *	since G(-x) is positive, sign(G(x)) = sign(sin(pi*x)) for x<0
+ *	Hence, for x<0, signgam = sign(sin(pi*x)) and 
+ *		lgamma(x) = log(|Gamma(x)|)
+ *			  = log(pi/(|x*sin(pi*x)|)) - lgamma(-x);
+ *	Note: one should avoid compute pi*(-x) directly in the 
+ *	      computation of sin(pi*(-x)).
+ *		
+ *   5. Special Cases
+ *		lgamma(2+s) ~ s*(1-Euler) for tiny s
+ *		lgamma(1) = lgamma(2) = 0
+ *		lgamma(x) ~ -log(|x|) for tiny x
+ *		lgamma(0) = lgamma(neg.integer) = inf and raise divide-by-zero
+ *		lgamma(inf) = inf
+ *		lgamma(-inf) = inf (bug for bug compatible with C99!?)
+ *	
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+static const double
+two52=  4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
+half=  5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
+one =  1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
+pi  =  3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */
+a0  =  7.72156649015328655494e-02, /* 0x3FB3C467, 0xE37DB0C8 */
+a1  =  3.22467033424113591611e-01, /* 0x3FD4A34C, 0xC4A60FAD */
+a2  =  6.73523010531292681824e-02, /* 0x3FB13E00, 0x1A5562A7 */
+a3  =  2.05808084325167332806e-02, /* 0x3F951322, 0xAC92547B */
+a4  =  7.38555086081402883957e-03, /* 0x3F7E404F, 0xB68FEFE8 */
+a5  =  2.89051383673415629091e-03, /* 0x3F67ADD8, 0xCCB7926B */
+a6  =  1.19270763183362067845e-03, /* 0x3F538A94, 0x116F3F5D */
+a7  =  5.10069792153511336608e-04, /* 0x3F40B6C6, 0x89B99C00 */
+a8  =  2.20862790713908385557e-04, /* 0x3F2CF2EC, 0xED10E54D */
+a9  =  1.08011567247583939954e-04, /* 0x3F1C5088, 0x987DFB07 */
+a10 =  2.52144565451257326939e-05, /* 0x3EFA7074, 0x428CFA52 */
+a11 =  4.48640949618915160150e-05, /* 0x3F07858E, 0x90A45837 */
+tc  =  1.46163214496836224576e+00, /* 0x3FF762D8, 0x6356BE3F */
+tf  = -1.21486290535849611461e-01, /* 0xBFBF19B9, 0xBCC38A42 */
+/* tt = -(tail of tf) */
+tt  = -3.63867699703950536541e-18, /* 0xBC50C7CA, 0xA48A971F */
+t0  =  4.83836122723810047042e-01, /* 0x3FDEF72B, 0xC8EE38A2 */
+t1  = -1.47587722994593911752e-01, /* 0xBFC2E427, 0x8DC6C509 */
+t2  =  6.46249402391333854778e-02, /* 0x3FB08B42, 0x94D5419B */
+t3  = -3.27885410759859649565e-02, /* 0xBFA0C9A8, 0xDF35B713 */
+t4  =  1.79706750811820387126e-02, /* 0x3F9266E7, 0x970AF9EC */
+t5  = -1.03142241298341437450e-02, /* 0xBF851F9F, 0xBA91EC6A */
+t6  =  6.10053870246291332635e-03, /* 0x3F78FCE0, 0xE370E344 */
+t7  = -3.68452016781138256760e-03, /* 0xBF6E2EFF, 0xB3E914D7 */
+t8  =  2.25964780900612472250e-03, /* 0x3F6282D3, 0x2E15C915 */
+t9  = -1.40346469989232843813e-03, /* 0xBF56FE8E, 0xBF2D1AF1 */
+t10 =  8.81081882437654011382e-04, /* 0x3F4CDF0C, 0xEF61A8E9 */
+t11 = -5.38595305356740546715e-04, /* 0xBF41A610, 0x9C73E0EC */
+t12 =  3.15632070903625950361e-04, /* 0x3F34AF6D, 0x6C0EBBF7 */
+t13 = -3.12754168375120860518e-04, /* 0xBF347F24, 0xECC38C38 */
+t14 =  3.35529192635519073543e-04, /* 0x3F35FD3E, 0xE8C2D3F4 */
+u0  = -7.72156649015328655494e-02, /* 0xBFB3C467, 0xE37DB0C8 */
+u1  =  6.32827064025093366517e-01, /* 0x3FE4401E, 0x8B005DFF */
+u2  =  1.45492250137234768737e+00, /* 0x3FF7475C, 0xD119BD6F */
+u3  =  9.77717527963372745603e-01, /* 0x3FEF4976, 0x44EA8450 */
+u4  =  2.28963728064692451092e-01, /* 0x3FCD4EAE, 0xF6010924 */
+u5  =  1.33810918536787660377e-02, /* 0x3F8B678B, 0xBF2BAB09 */
+v1  =  2.45597793713041134822e+00, /* 0x4003A5D7, 0xC2BD619C */
+v2  =  2.12848976379893395361e+00, /* 0x40010725, 0xA42B18F5 */
+v3  =  7.69285150456672783825e-01, /* 0x3FE89DFB, 0xE45050AF */
+v4  =  1.04222645593369134254e-01, /* 0x3FBAAE55, 0xD6537C88 */
+v5  =  3.21709242282423911810e-03, /* 0x3F6A5ABB, 0x57D0CF61 */
+s0  = -7.72156649015328655494e-02, /* 0xBFB3C467, 0xE37DB0C8 */
+s1  =  2.14982415960608852501e-01, /* 0x3FCB848B, 0x36E20878 */
+s2  =  3.25778796408930981787e-01, /* 0x3FD4D98F, 0x4F139F59 */
+s3  =  1.46350472652464452805e-01, /* 0x3FC2BB9C, 0xBEE5F2F7 */
+s4  =  2.66422703033638609560e-02, /* 0x3F9B481C, 0x7E939961 */
+s5  =  1.84028451407337715652e-03, /* 0x3F5E26B6, 0x7368F239 */
+s6  =  3.19475326584100867617e-05, /* 0x3F00BFEC, 0xDD17E945 */
+r1  =  1.39200533467621045958e+00, /* 0x3FF645A7, 0x62C4AB74 */
+r2  =  7.21935547567138069525e-01, /* 0x3FE71A18, 0x93D3DCDC */
+r3  =  1.71933865632803078993e-01, /* 0x3FC601ED, 0xCCFBDF27 */
+r4  =  1.86459191715652901344e-02, /* 0x3F9317EA, 0x742ED475 */
+r5  =  7.77942496381893596434e-04, /* 0x3F497DDA, 0xCA41A95B */
+r6  =  7.32668430744625636189e-06, /* 0x3EDEBAF7, 0xA5B38140 */
+w0  =  4.18938533204672725052e-01, /* 0x3FDACFE3, 0x90C97D69 */
+w1  =  8.33333333333329678849e-02, /* 0x3FB55555, 0x5555553B */
+w2  = -2.77777777728775536470e-03, /* 0xBF66C16C, 0x16B02E5C */
+w3  =  7.93650558643019558500e-04, /* 0x3F4A019F, 0x98CF38B6 */
+w4  = -5.95187557450339963135e-04, /* 0xBF4380CB, 0x8C0FE741 */
+w5  =  8.36339918996282139126e-04, /* 0x3F4B67BA, 0x4CDAD5D1 */
+w6  = -1.63092934096575273989e-03; /* 0xBF5AB89D, 0x0B9E43E4 */
+
+static const double zero=  0.00000000000000000000e+00;
+
+	static double sin_pi(double x)
+{
+	double y,z;
+	int n,ix;
+
+	GET_HIGH_WORD(ix,x);
+	ix &= 0x7fffffff;
+
+	if(ix<0x3fd00000) return __kernel_sin(pi*x,zero,0);
+	y = -x;		/* x is assume negative */
+
+    /*
+     * argument reduction, make sure inexact flag not raised if input
+     * is an integer
+     */
+	z = floor(y);
+	if(z!=y) {				/* inexact anyway */
+	    y  *= 0.5;
+	    y   = 2.0*(y - floor(y));		/* y = |x| mod 2.0 */
+	    n   = (int) (y*4.0);
+	} else {
+            if(ix>=0x43400000) {
+                y = zero; n = 0;                 /* y must be even */
+            } else {
+                if(ix<0x43300000) z = y+two52;	/* exact */
+		GET_LOW_WORD(n,z);
+		n &= 1;
+                y  = n;
+                n<<= 2;
+            }
+        }
+	switch (n) {
+	    case 0:   y =  __kernel_sin(pi*y,zero,0); break;
+	    case 1:   
+	    case 2:   y =  __kernel_cos(pi*(0.5-y),zero); break;
+	    case 3:  
+	    case 4:   y =  __kernel_sin(pi*(one-y),zero,0); break;
+	    case 5:
+	    case 6:   y = -__kernel_cos(pi*(y-1.5),zero); break;
+	    default:  y =  __kernel_sin(pi*(y-2.0),zero,0); break;
+	    }
+	return -y;
+}
+
+
+double
+__ieee754_lgamma_r(double x, int *signgamp)
+{
+	double t,y,z,nadj,p,p1,p2,p3,q,r,w;
+	int32_t hx;
+	int i,lx,ix;
+
+	EXTRACT_WORDS(hx,lx,x);
+
+    /* purge off +-inf, NaN, +-0, tiny and negative arguments */
+	*signgamp = 1;
+	ix = hx&0x7fffffff;
+	if(ix>=0x7ff00000) return x*x;
+	if((ix|lx)==0) return one/zero;
+	if(ix<0x3b900000) {	/* |x|<2**-70, return -log(|x|) */
+	    if(hx<0) {
+	        *signgamp = -1;
+	        return -__ieee754_log(-x);
+	    } else return -__ieee754_log(x);
+	}
+	if(hx<0) {
+	    if(ix>=0x43300000) 	/* |x|>=2**52, must be -integer */
+		return one/zero;
+	    t = sin_pi(x);
+	    if(t==zero) return one/zero; /* -integer */
+	    nadj = __ieee754_log(pi/fabs(t*x));
+	    if(t<zero) *signgamp = -1;
+	    x = -x;
+	}
+
+    /* purge off 1 and 2 */
+	if((((ix-0x3ff00000)|lx)==0)||(((ix-0x40000000)|lx)==0)) r = 0;
+    /* for x < 2.0 */
+	else if(ix<0x40000000) {
+	    if(ix<=0x3feccccc) { 	/* lgamma(x) = lgamma(x+1)-log(x) */
+		r = -__ieee754_log(x);
+		if(ix>=0x3FE76944) {y = one-x; i= 0;}
+		else if(ix>=0x3FCDA661) {y= x-(tc-one); i=1;}
+	  	else {y = x; i=2;}
+	    } else {
+	  	r = zero;
+	        if(ix>=0x3FFBB4C3) {y=2.0-x;i=0;} /* [1.7316,2] */
+	        else if(ix>=0x3FF3B4C4) {y=x-tc;i=1;} /* [1.23,1.73] */
+		else {y=x-one;i=2;}
+	    }
+	    switch(i) {
+	      case 0:
+		z = y*y;
+		p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10))));
+		p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11)))));
+		p  = y*p1+p2;
+		r  += (p-0.5*y); break;
+	      case 1:
+		z = y*y;
+		w = z*y;
+		p1 = t0+w*(t3+w*(t6+w*(t9 +w*t12)));	/* parallel comp */
+		p2 = t1+w*(t4+w*(t7+w*(t10+w*t13)));
+		p3 = t2+w*(t5+w*(t8+w*(t11+w*t14)));
+		p  = z*p1-(tt-w*(p2+y*p3));
+		r += (tf + p); break;
+	      case 2:	
+		p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5)))));
+		p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*v5))));
+		r += (-0.5*y + p1/p2);
+	    }
+	}
+	else if(ix<0x40200000) { 			/* x < 8.0 */
+	    i = (int)x;
+	    y = x-(double)i;
+	    p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6))))));
+	    q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6)))));
+	    r = half*y+p/q;
+	    z = one;	/* lgamma(1+s) = log(s) + lgamma(s) */
+	    switch(i) {
+	    case 7: z *= (y+6.0);	/* FALLTHRU */
+	    case 6: z *= (y+5.0);	/* FALLTHRU */
+	    case 5: z *= (y+4.0);	/* FALLTHRU */
+	    case 4: z *= (y+3.0);	/* FALLTHRU */
+	    case 3: z *= (y+2.0);	/* FALLTHRU */
+		    r += __ieee754_log(z); break;
+	    }
+    /* 8.0 <= x < 2**58 */
+	} else if (ix < 0x43900000) {
+	    t = __ieee754_log(x);
+	    z = one/x;
+	    y = z*z;
+	    w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6)))));
+	    r = (x-half)*(t-one)+w;
+	} else 
+    /* 2**58 <= x <= inf */
+	    r =  x*(__ieee754_log(x)-one);
+	if(hx<0) r = nadj - r;
+	return r;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_lgammaf.c b/libm/upstream-freebsd/lib/msun/src/e_lgammaf.c
new file mode 100644
index 0000000..1e2c552
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_lgammaf.c
@@ -0,0 +1,34 @@
+/* e_lgammaf.c -- float version of e_lgamma.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_lgammaf(x)
+ * Return the logarithm of the Gamma function of x.
+ *
+ * Method: call __ieee754_lgammaf_r
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+extern int signgam;
+
+float
+__ieee754_lgammaf(float x)
+{
+	return __ieee754_lgammaf_r(x,&signgam);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_lgammaf_r.c b/libm/upstream-freebsd/lib/msun/src/e_lgammaf_r.c
new file mode 100644
index 0000000..e2d90ef
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_lgammaf_r.c
@@ -0,0 +1,230 @@
+/* e_lgammaf_r.c -- float version of e_lgamma_r.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static const float
+two23=  8.3886080000e+06, /* 0x4b000000 */
+half=  5.0000000000e-01, /* 0x3f000000 */
+one =  1.0000000000e+00, /* 0x3f800000 */
+pi  =  3.1415927410e+00, /* 0x40490fdb */
+a0  =  7.7215664089e-02, /* 0x3d9e233f */
+a1  =  3.2246702909e-01, /* 0x3ea51a66 */
+a2  =  6.7352302372e-02, /* 0x3d89f001 */
+a3  =  2.0580807701e-02, /* 0x3ca89915 */
+a4  =  7.3855509982e-03, /* 0x3bf2027e */
+a5  =  2.8905137442e-03, /* 0x3b3d6ec6 */
+a6  =  1.1927076848e-03, /* 0x3a9c54a1 */
+a7  =  5.1006977446e-04, /* 0x3a05b634 */
+a8  =  2.2086278477e-04, /* 0x39679767 */
+a9  =  1.0801156895e-04, /* 0x38e28445 */
+a10 =  2.5214456400e-05, /* 0x37d383a2 */
+a11 =  4.4864096708e-05, /* 0x383c2c75 */
+tc  =  1.4616321325e+00, /* 0x3fbb16c3 */
+tf  = -1.2148628384e-01, /* 0xbdf8cdcd */
+/* tt = -(tail of tf) */
+tt  =  6.6971006518e-09, /* 0x31e61c52 */
+t0  =  4.8383611441e-01, /* 0x3ef7b95e */
+t1  = -1.4758771658e-01, /* 0xbe17213c */
+t2  =  6.4624942839e-02, /* 0x3d845a15 */
+t3  = -3.2788541168e-02, /* 0xbd064d47 */
+t4  =  1.7970675603e-02, /* 0x3c93373d */
+t5  = -1.0314224288e-02, /* 0xbc28fcfe */
+t6  =  6.1005386524e-03, /* 0x3bc7e707 */
+t7  = -3.6845202558e-03, /* 0xbb7177fe */
+t8  =  2.2596477065e-03, /* 0x3b141699 */
+t9  = -1.4034647029e-03, /* 0xbab7f476 */
+t10 =  8.8108185446e-04, /* 0x3a66f867 */
+t11 = -5.3859531181e-04, /* 0xba0d3085 */
+t12 =  3.1563205994e-04, /* 0x39a57b6b */
+t13 = -3.1275415677e-04, /* 0xb9a3f927 */
+t14 =  3.3552918467e-04, /* 0x39afe9f7 */
+u0  = -7.7215664089e-02, /* 0xbd9e233f */
+u1  =  6.3282704353e-01, /* 0x3f2200f4 */
+u2  =  1.4549225569e+00, /* 0x3fba3ae7 */
+u3  =  9.7771751881e-01, /* 0x3f7a4bb2 */
+u4  =  2.2896373272e-01, /* 0x3e6a7578 */
+u5  =  1.3381091878e-02, /* 0x3c5b3c5e */
+v1  =  2.4559779167e+00, /* 0x401d2ebe */
+v2  =  2.1284897327e+00, /* 0x4008392d */
+v3  =  7.6928514242e-01, /* 0x3f44efdf */
+v4  =  1.0422264785e-01, /* 0x3dd572af */
+v5  =  3.2170924824e-03, /* 0x3b52d5db */
+s0  = -7.7215664089e-02, /* 0xbd9e233f */
+s1  =  2.1498242021e-01, /* 0x3e5c245a */
+s2  =  3.2577878237e-01, /* 0x3ea6cc7a */
+s3  =  1.4635047317e-01, /* 0x3e15dce6 */
+s4  =  2.6642270386e-02, /* 0x3cda40e4 */
+s5  =  1.8402845599e-03, /* 0x3af135b4 */
+s6  =  3.1947532989e-05, /* 0x3805ff67 */
+r1  =  1.3920053244e+00, /* 0x3fb22d3b */
+r2  =  7.2193557024e-01, /* 0x3f38d0c5 */
+r3  =  1.7193385959e-01, /* 0x3e300f6e */
+r4  =  1.8645919859e-02, /* 0x3c98bf54 */
+r5  =  7.7794247773e-04, /* 0x3a4beed6 */
+r6  =  7.3266842264e-06, /* 0x36f5d7bd */
+w0  =  4.1893854737e-01, /* 0x3ed67f1d */
+w1  =  8.3333335817e-02, /* 0x3daaaaab */
+w2  = -2.7777778450e-03, /* 0xbb360b61 */
+w3  =  7.9365057172e-04, /* 0x3a500cfd */
+w4  = -5.9518753551e-04, /* 0xba1c065c */
+w5  =  8.3633989561e-04, /* 0x3a5b3dd2 */
+w6  = -1.6309292987e-03; /* 0xbad5c4e8 */
+
+static const float zero=  0.0000000000e+00;
+
+	static float sin_pif(float x)
+{
+	float y,z;
+	int n,ix;
+
+	GET_FLOAT_WORD(ix,x);
+	ix &= 0x7fffffff;
+
+	if(ix<0x3e800000) return __kernel_sindf(pi*x);
+	y = -x;		/* x is assume negative */
+
+    /*
+     * argument reduction, make sure inexact flag not raised if input
+     * is an integer
+     */
+	z = floorf(y);
+	if(z!=y) {				/* inexact anyway */
+	    y  *= (float)0.5;
+	    y   = (float)2.0*(y - floorf(y));	/* y = |x| mod 2.0 */
+	    n   = (int) (y*(float)4.0);
+	} else {
+            if(ix>=0x4b800000) {
+                y = zero; n = 0;                 /* y must be even */
+            } else {
+                if(ix<0x4b000000) z = y+two23;	/* exact */
+		GET_FLOAT_WORD(n,z);
+		n &= 1;
+                y  = n;
+                n<<= 2;
+            }
+        }
+	switch (n) {
+	    case 0:   y =  __kernel_sindf(pi*y); break;
+	    case 1:
+	    case 2:   y =  __kernel_cosdf(pi*((float)0.5-y)); break;
+	    case 3:
+	    case 4:   y =  __kernel_sindf(pi*(one-y)); break;
+	    case 5:
+	    case 6:   y = -__kernel_cosdf(pi*(y-(float)1.5)); break;
+	    default:  y =  __kernel_sindf(pi*(y-(float)2.0)); break;
+	    }
+	return -y;
+}
+
+
+float
+__ieee754_lgammaf_r(float x, int *signgamp)
+{
+	float t,y,z,nadj,p,p1,p2,p3,q,r,w;
+	int32_t hx;
+	int i,ix;
+
+	GET_FLOAT_WORD(hx,x);
+
+    /* purge off +-inf, NaN, +-0, tiny and negative arguments */
+	*signgamp = 1;
+	ix = hx&0x7fffffff;
+	if(ix>=0x7f800000) return x*x;
+	if(ix==0) return one/zero;
+	if(ix<0x35000000) {	/* |x|<2**-21, return -log(|x|) */
+	    if(hx<0) {
+	        *signgamp = -1;
+	        return -__ieee754_logf(-x);
+	    } else return -__ieee754_logf(x);
+	}
+	if(hx<0) {
+	    if(ix>=0x4b000000) 	/* |x|>=2**23, must be -integer */
+		return one/zero;
+	    t = sin_pif(x);
+	    if(t==zero) return one/zero; /* -integer */
+	    nadj = __ieee754_logf(pi/fabsf(t*x));
+	    if(t<zero) *signgamp = -1;
+	    x = -x;
+	}
+
+    /* purge off 1 and 2 */
+	if (ix==0x3f800000||ix==0x40000000) r = 0;
+    /* for x < 2.0 */
+	else if(ix<0x40000000) {
+	    if(ix<=0x3f666666) { 	/* lgamma(x) = lgamma(x+1)-log(x) */
+		r = -__ieee754_logf(x);
+		if(ix>=0x3f3b4a20) {y = one-x; i= 0;}
+		else if(ix>=0x3e6d3308) {y= x-(tc-one); i=1;}
+	  	else {y = x; i=2;}
+	    } else {
+	  	r = zero;
+	        if(ix>=0x3fdda618) {y=(float)2.0-x;i=0;} /* [1.7316,2] */
+	        else if(ix>=0x3F9da620) {y=x-tc;i=1;} /* [1.23,1.73] */
+		else {y=x-one;i=2;}
+	    }
+	    switch(i) {
+	      case 0:
+		z = y*y;
+		p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10))));
+		p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11)))));
+		p  = y*p1+p2;
+		r  += (p-(float)0.5*y); break;
+	      case 1:
+		z = y*y;
+		w = z*y;
+		p1 = t0+w*(t3+w*(t6+w*(t9 +w*t12)));	/* parallel comp */
+		p2 = t1+w*(t4+w*(t7+w*(t10+w*t13)));
+		p3 = t2+w*(t5+w*(t8+w*(t11+w*t14)));
+		p  = z*p1-(tt-w*(p2+y*p3));
+		r += (tf + p); break;
+	      case 2:
+		p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5)))));
+		p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*v5))));
+		r += (-(float)0.5*y + p1/p2);
+	    }
+	}
+	else if(ix<0x41000000) { 			/* x < 8.0 */
+	    i = (int)x;
+	    y = x-(float)i;
+	    p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6))))));
+	    q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6)))));
+	    r = half*y+p/q;
+	    z = one;	/* lgamma(1+s) = log(s) + lgamma(s) */
+	    switch(i) {
+	    case 7: z *= (y+(float)6.0);	/* FALLTHRU */
+	    case 6: z *= (y+(float)5.0);	/* FALLTHRU */
+	    case 5: z *= (y+(float)4.0);	/* FALLTHRU */
+	    case 4: z *= (y+(float)3.0);	/* FALLTHRU */
+	    case 3: z *= (y+(float)2.0);	/* FALLTHRU */
+		    r += __ieee754_logf(z); break;
+	    }
+    /* 8.0 <= x < 2**58 */
+	} else if (ix < 0x5c800000) {
+	    t = __ieee754_logf(x);
+	    z = one/x;
+	    y = z*z;
+	    w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6)))));
+	    r = (x-half)*(t-one)+w;
+	} else
+    /* 2**58 <= x <= inf */
+	    r =  x*(__ieee754_logf(x)-one);
+	if(hx<0) r = nadj - r;
+	return r;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_log.c b/libm/upstream-freebsd/lib/msun/src/e_log.c
new file mode 100644
index 0000000..204fb48
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_log.c
@@ -0,0 +1,140 @@
+
+/* @(#)e_log.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_log(x)
+ * Return the logrithm of x
+ *
+ * Method :                  
+ *   1. Argument Reduction: find k and f such that 
+ *			x = 2^k * (1+f), 
+ *	   where  sqrt(2)/2 < 1+f < sqrt(2) .
+ *
+ *   2. Approximation of log(1+f).
+ *	Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
+ *		 = 2s + 2/3 s**3 + 2/5 s**5 + .....,
+ *	     	 = 2s + s*R
+ *      We use a special Reme algorithm on [0,0.1716] to generate 
+ * 	a polynomial of degree 14 to approximate R The maximum error 
+ *	of this polynomial approximation is bounded by 2**-58.45. In
+ *	other words,
+ *		        2      4      6      8      10      12      14
+ *	    R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s  +Lg6*s  +Lg7*s
+ *  	(the values of Lg1 to Lg7 are listed in the program)
+ *	and
+ *	    |      2          14          |     -58.45
+ *	    | Lg1*s +...+Lg7*s    -  R(z) | <= 2 
+ *	    |                             |
+ *	Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
+ *	In order to guarantee error in log below 1ulp, we compute log
+ *	by
+ *		log(1+f) = f - s*(f - R)	(if f is not too large)
+ *		log(1+f) = f - (hfsq - s*(hfsq+R)).	(better accuracy)
+ *	
+ *	3. Finally,  log(x) = k*ln2 + log(1+f).  
+ *			    = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo)))
+ *	   Here ln2 is split into two floating point number: 
+ *			ln2_hi + ln2_lo,
+ *	   where n*ln2_hi is always exact for |n| < 2000.
+ *
+ * Special cases:
+ *	log(x) is NaN with signal if x < 0 (including -INF) ; 
+ *	log(+INF) is +INF; log(0) is -INF with signal;
+ *	log(NaN) is that NaN with no signal.
+ *
+ * Accuracy:
+ *	according to an error analysis, the error is always less than
+ *	1 ulp (unit in the last place).
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following 
+ * constants. The decimal values may be used, provided that the 
+ * compiler will convert from decimal to binary accurately enough 
+ * to produce the hexadecimal values shown.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+static const double
+ln2_hi  =  6.93147180369123816490e-01,	/* 3fe62e42 fee00000 */
+ln2_lo  =  1.90821492927058770002e-10,	/* 3dea39ef 35793c76 */
+two54   =  1.80143985094819840000e+16,  /* 43500000 00000000 */
+Lg1 = 6.666666666666735130e-01,  /* 3FE55555 55555593 */
+Lg2 = 3.999999999940941908e-01,  /* 3FD99999 9997FA04 */
+Lg3 = 2.857142874366239149e-01,  /* 3FD24924 94229359 */
+Lg4 = 2.222219843214978396e-01,  /* 3FCC71C5 1D8E78AF */
+Lg5 = 1.818357216161805012e-01,  /* 3FC74664 96CB03DE */
+Lg6 = 1.531383769920937332e-01,  /* 3FC39A09 D078C69F */
+Lg7 = 1.479819860511658591e-01;  /* 3FC2F112 DF3E5244 */
+
+static const double zero   =  0.0;
+
+double
+__ieee754_log(double x)
+{
+	double hfsq,f,s,z,R,w,t1,t2,dk;
+	int32_t k,hx,i,j;
+	u_int32_t lx;
+
+	EXTRACT_WORDS(hx,lx,x);
+
+	k=0;
+	if (hx < 0x00100000) {			/* x < 2**-1022  */
+	    if (((hx&0x7fffffff)|lx)==0) 
+		return -two54/zero;		/* log(+-0)=-inf */
+	    if (hx<0) return (x-x)/zero;	/* log(-#) = NaN */
+	    k -= 54; x *= two54; /* subnormal number, scale up x */
+	    GET_HIGH_WORD(hx,x);
+	} 
+	if (hx >= 0x7ff00000) return x+x;
+	k += (hx>>20)-1023;
+	hx &= 0x000fffff;
+	i = (hx+0x95f64)&0x100000;
+	SET_HIGH_WORD(x,hx|(i^0x3ff00000));	/* normalize x or x/2 */
+	k += (i>>20);
+	f = x-1.0;
+	if((0x000fffff&(2+hx))<3) {	/* -2**-20 <= f < 2**-20 */
+	    if(f==zero) {
+		if(k==0) {
+		    return zero;
+		} else {
+		    dk=(double)k;
+		    return dk*ln2_hi+dk*ln2_lo;
+		}
+	    }
+	    R = f*f*(0.5-0.33333333333333333*f);
+	    if(k==0) return f-R; else {dk=(double)k;
+	    	     return dk*ln2_hi-((R-dk*ln2_lo)-f);}
+	}
+ 	s = f/(2.0+f); 
+	dk = (double)k;
+	z = s*s;
+	i = hx-0x6147a;
+	w = z*z;
+	j = 0x6b851-hx;
+	t1= w*(Lg2+w*(Lg4+w*Lg6)); 
+	t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7))); 
+	i |= j;
+	R = t2+t1;
+	if(i>0) {
+	    hfsq=0.5*f*f;
+	    if(k==0) return f-(hfsq-s*(hfsq+R)); else
+		     return dk*ln2_hi-((hfsq-(s*(hfsq+R)+dk*ln2_lo))-f);
+	} else {
+	    if(k==0) return f-s*(f-R); else
+		     return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f);
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_log10.c b/libm/upstream-freebsd/lib/msun/src/e_log10.c
new file mode 100644
index 0000000..104d257
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_log10.c
@@ -0,0 +1,87 @@
+
+/* @(#)e_log10.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * Return the base 10 logarithm of x.  See e_log.c and k_log.h for most
+ * comments.
+ *
+ *    log10(x) = (f - 0.5*f*f + k_log1p(f)) / ln10 + k * log10(2)
+ * in not-quite-routine extra precision.
+ */
+
+#include "math.h"
+#include "math_private.h"
+#include "k_log.h"
+
+static const double
+two54      =  1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
+ivln10hi   =  4.34294481878168880939e-01, /* 0x3fdbcb7b, 0x15200000 */
+ivln10lo   =  2.50829467116452752298e-11, /* 0x3dbb9438, 0xca9aadd5 */
+log10_2hi  =  3.01029995663611771306e-01, /* 0x3FD34413, 0x509F6000 */
+log10_2lo  =  3.69423907715893078616e-13; /* 0x3D59FEF3, 0x11F12B36 */
+
+static const double zero   =  0.0;
+
+double
+__ieee754_log10(double x)
+{
+	double f,hfsq,hi,lo,r,val_hi,val_lo,w,y,y2;
+	int32_t i,k,hx;
+	u_int32_t lx;
+
+	EXTRACT_WORDS(hx,lx,x);
+
+	k=0;
+	if (hx < 0x00100000) {			/* x < 2**-1022  */
+	    if (((hx&0x7fffffff)|lx)==0)
+		return -two54/zero;		/* log(+-0)=-inf */
+	    if (hx<0) return (x-x)/zero;	/* log(-#) = NaN */
+	    k -= 54; x *= two54; /* subnormal number, scale up x */
+	    GET_HIGH_WORD(hx,x);
+	}
+	if (hx >= 0x7ff00000) return x+x;
+	if (hx == 0x3ff00000 && lx == 0)
+	    return zero;			/* log(1) = +0 */
+	k += (hx>>20)-1023;
+	hx &= 0x000fffff;
+	i = (hx+0x95f64)&0x100000;
+	SET_HIGH_WORD(x,hx|(i^0x3ff00000));	/* normalize x or x/2 */
+	k += (i>>20);
+	y = (double)k;
+	f = x - 1.0;
+	hfsq = 0.5*f*f;
+	r = k_log1p(f);
+
+	/* See e_log2.c for most details. */
+	hi = f - hfsq;
+	SET_LOW_WORD(hi,0);
+	lo = (f - hi) - hfsq + r;
+	val_hi = hi*ivln10hi;
+	y2 = y*log10_2hi;
+	val_lo = y*log10_2lo + (lo+hi)*ivln10lo + lo*ivln10hi;
+
+	/*
+	 * Extra precision in for adding y*log10_2hi is not strictly needed
+	 * since there is no very large cancellation near x = sqrt(2) or
+	 * x = 1/sqrt(2), but we do it anyway since it costs little on CPUs
+	 * with some parallelism and it reduces the error for many args.
+	 */
+	w = y2 + val_hi;
+	val_lo += (y2 - w) + val_hi;
+	val_hi = w;
+
+	return val_lo + val_hi;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_log10f.c b/libm/upstream-freebsd/lib/msun/src/e_log10f.c
new file mode 100644
index 0000000..c876594
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_log10f.c
@@ -0,0 +1,71 @@
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * Float version of e_log10.c.  See the latter for most comments.
+ */
+
+#include "math.h"
+#include "math_private.h"
+#include "k_logf.h"
+
+static const float
+two25      =  3.3554432000e+07, /* 0x4c000000 */
+ivln10hi   =  4.3432617188e-01, /* 0x3ede6000 */
+ivln10lo   = -3.1689971365e-05, /* 0xb804ead9 */
+log10_2hi  =  3.0102920532e-01, /* 0x3e9a2080 */
+log10_2lo  =  7.9034151668e-07; /* 0x355427db */
+
+static const float zero   =  0.0;
+
+float
+__ieee754_log10f(float x)
+{
+	float f,hfsq,hi,lo,r,y;
+	int32_t i,k,hx;
+
+	GET_FLOAT_WORD(hx,x);
+
+	k=0;
+	if (hx < 0x00800000) {			/* x < 2**-126  */
+	    if ((hx&0x7fffffff)==0)
+		return -two25/zero;		/* log(+-0)=-inf */
+	    if (hx<0) return (x-x)/zero;	/* log(-#) = NaN */
+	    k -= 25; x *= two25; /* subnormal number, scale up x */
+	    GET_FLOAT_WORD(hx,x);
+	}
+	if (hx >= 0x7f800000) return x+x;
+	if (hx == 0x3f800000)
+	    return zero;			/* log(1) = +0 */
+	k += (hx>>23)-127;
+	hx &= 0x007fffff;
+	i = (hx+(0x4afb0d))&0x800000;
+	SET_FLOAT_WORD(x,hx|(i^0x3f800000));	/* normalize x or x/2 */
+	k += (i>>23);
+	y = (float)k;
+	f = x - (float)1.0;
+	hfsq = (float)0.5*f*f;
+	r = k_log1pf(f);
+
+	/* See e_log2f.c and e_log2.c for details. */
+	if (sizeof(float_t) > sizeof(float))
+		return (r - hfsq + f) * ((float_t)ivln10lo + ivln10hi) +
+		    y * ((float_t)log10_2lo + log10_2hi);
+	hi = f - hfsq;
+	GET_FLOAT_WORD(hx,hi);
+	SET_FLOAT_WORD(hi,hx&0xfffff000);
+	lo = (f - hi) - hfsq + r;
+	return y*log10_2lo + (lo+hi)*ivln10lo + lo*ivln10hi + hi*ivln10hi +
+	    y*log10_2hi;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_log2.c b/libm/upstream-freebsd/lib/msun/src/e_log2.c
new file mode 100644
index 0000000..1fc44a5
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_log2.c
@@ -0,0 +1,110 @@
+
+/* @(#)e_log10.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * Return the base 2 logarithm of x.  See e_log.c and k_log.h for most
+ * comments.
+ *
+ * This reduces x to {k, 1+f} exactly as in e_log.c, then calls the kernel,
+ * then does the combining and scaling steps
+ *    log2(x) = (f - 0.5*f*f + k_log1p(f)) / ln2 + k
+ * in not-quite-routine extra precision.
+ */
+
+#include "math.h"
+#include "math_private.h"
+#include "k_log.h"
+
+static const double
+two54      =  1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
+ivln2hi    =  1.44269504072144627571e+00, /* 0x3ff71547, 0x65200000 */
+ivln2lo    =  1.67517131648865118353e-10; /* 0x3de705fc, 0x2eefa200 */
+
+static const double zero   =  0.0;
+
+double
+__ieee754_log2(double x)
+{
+	double f,hfsq,hi,lo,r,val_hi,val_lo,w,y;
+	int32_t i,k,hx;
+	u_int32_t lx;
+
+	EXTRACT_WORDS(hx,lx,x);
+
+	k=0;
+	if (hx < 0x00100000) {			/* x < 2**-1022  */
+	    if (((hx&0x7fffffff)|lx)==0)
+		return -two54/zero;		/* log(+-0)=-inf */
+	    if (hx<0) return (x-x)/zero;	/* log(-#) = NaN */
+	    k -= 54; x *= two54; /* subnormal number, scale up x */
+	    GET_HIGH_WORD(hx,x);
+	}
+	if (hx >= 0x7ff00000) return x+x;
+	if (hx == 0x3ff00000 && lx == 0)
+	    return zero;			/* log(1) = +0 */
+	k += (hx>>20)-1023;
+	hx &= 0x000fffff;
+	i = (hx+0x95f64)&0x100000;
+	SET_HIGH_WORD(x,hx|(i^0x3ff00000));	/* normalize x or x/2 */
+	k += (i>>20);
+	y = (double)k;
+	f = x - 1.0;
+	hfsq = 0.5*f*f;
+	r = k_log1p(f);
+
+	/*
+	 * f-hfsq must (for args near 1) be evaluated in extra precision
+	 * to avoid a large cancellation when x is near sqrt(2) or 1/sqrt(2).
+	 * This is fairly efficient since f-hfsq only depends on f, so can
+	 * be evaluated in parallel with R.  Not combining hfsq with R also
+	 * keeps R small (though not as small as a true `lo' term would be),
+	 * so that extra precision is not needed for terms involving R.
+	 *
+	 * Compiler bugs involving extra precision used to break Dekker's
+	 * theorem for spitting f-hfsq as hi+lo, unless double_t was used
+	 * or the multi-precision calculations were avoided when double_t
+	 * has extra precision.  These problems are now automatically
+	 * avoided as a side effect of the optimization of combining the
+	 * Dekker splitting step with the clear-low-bits step.
+	 *
+	 * y must (for args near sqrt(2) and 1/sqrt(2)) be added in extra
+	 * precision to avoid a very large cancellation when x is very near
+	 * these values.  Unlike the above cancellations, this problem is
+	 * specific to base 2.  It is strange that adding +-1 is so much
+	 * harder than adding +-ln2 or +-log10_2.
+	 *
+	 * This uses Dekker's theorem to normalize y+val_hi, so the
+	 * compiler bugs are back in some configurations, sigh.  And I
+	 * don't want to used double_t to avoid them, since that gives a
+	 * pessimization and the support for avoiding the pessimization
+	 * is not yet available.
+	 *
+	 * The multi-precision calculations for the multiplications are
+	 * routine.
+	 */
+	hi = f - hfsq;
+	SET_LOW_WORD(hi,0);
+	lo = (f - hi) - hfsq + r;
+	val_hi = hi*ivln2hi;
+	val_lo = (lo+hi)*ivln2lo + lo*ivln2hi;
+
+	/* spadd(val_hi, val_lo, y), except for not using double_t: */
+	w = y + val_hi;
+	val_lo += (y - w) + val_hi;
+	val_hi = w;
+
+	return val_lo + val_hi;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_log2f.c b/libm/upstream-freebsd/lib/msun/src/e_log2f.c
new file mode 100644
index 0000000..7166346
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_log2f.c
@@ -0,0 +1,81 @@
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * Float version of e_log2.c.  See the latter for most comments.
+ */
+
+#include "math.h"
+#include "math_private.h"
+#include "k_logf.h"
+
+static const float
+two25      =  3.3554432000e+07, /* 0x4c000000 */
+ivln2hi    =  1.4428710938e+00, /* 0x3fb8b000 */
+ivln2lo    = -1.7605285393e-04; /* 0xb9389ad4 */
+
+static const float zero   =  0.0;
+
+float
+__ieee754_log2f(float x)
+{
+	float f,hfsq,hi,lo,r,y;
+	int32_t i,k,hx;
+
+	GET_FLOAT_WORD(hx,x);
+
+	k=0;
+	if (hx < 0x00800000) {			/* x < 2**-126  */
+	    if ((hx&0x7fffffff)==0)
+		return -two25/zero;		/* log(+-0)=-inf */
+	    if (hx<0) return (x-x)/zero;	/* log(-#) = NaN */
+	    k -= 25; x *= two25; /* subnormal number, scale up x */
+	    GET_FLOAT_WORD(hx,x);
+	}
+	if (hx >= 0x7f800000) return x+x;
+	if (hx == 0x3f800000)
+	    return zero;			/* log(1) = +0 */
+	k += (hx>>23)-127;
+	hx &= 0x007fffff;
+	i = (hx+(0x4afb0d))&0x800000;
+	SET_FLOAT_WORD(x,hx|(i^0x3f800000));	/* normalize x or x/2 */
+	k += (i>>23);
+	y = (float)k;
+	f = x - (float)1.0;
+	hfsq = (float)0.5*f*f;
+	r = k_log1pf(f);
+
+	/*
+	 * We no longer need to avoid falling into the multi-precision
+	 * calculations due to compiler bugs breaking Dekker's theorem.
+	 * Keep avoiding this as an optimization.  See e_log2.c for more
+	 * details (some details are here only because the optimization
+	 * is not yet available in double precision).
+	 *
+	 * Another compiler bug turned up.  With gcc on i386,
+	 * (ivln2lo + ivln2hi) would be evaluated in float precision
+	 * despite runtime evaluations using double precision.  So we
+	 * must cast one of its terms to float_t.  This makes the whole
+	 * expression have type float_t, so return is forced to waste
+	 * time clobbering its extra precision.
+	 */
+	if (sizeof(float_t) > sizeof(float))
+		return (r - hfsq + f) * ((float_t)ivln2lo + ivln2hi) + y;
+
+	hi = f - hfsq;
+	GET_FLOAT_WORD(hx,hi);
+	SET_FLOAT_WORD(hi,hx&0xfffff000);
+	lo = (f - hi) - hfsq + r;
+	return (lo+hi)*ivln2lo + lo*ivln2hi + hi*ivln2hi + y;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_logf.c b/libm/upstream-freebsd/lib/msun/src/e_logf.c
new file mode 100644
index 0000000..c3be6ed
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_logf.c
@@ -0,0 +1,88 @@
+/* e_logf.c -- float version of e_log.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static const float
+ln2_hi =   6.9313812256e-01,	/* 0x3f317180 */
+ln2_lo =   9.0580006145e-06,	/* 0x3717f7d1 */
+two25 =    3.355443200e+07,	/* 0x4c000000 */
+/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */
+Lg1 =      0xaaaaaa.0p-24,	/* 0.66666662693 */
+Lg2 =      0xccce13.0p-25,	/* 0.40000972152 */
+Lg3 =      0x91e9ee.0p-25,	/* 0.28498786688 */
+Lg4 =      0xf89e26.0p-26;	/* 0.24279078841 */
+
+static const float zero   =  0.0;
+
+float
+__ieee754_logf(float x)
+{
+	float hfsq,f,s,z,R,w,t1,t2,dk;
+	int32_t k,ix,i,j;
+
+	GET_FLOAT_WORD(ix,x);
+
+	k=0;
+	if (ix < 0x00800000) {			/* x < 2**-126  */
+	    if ((ix&0x7fffffff)==0)
+		return -two25/zero;		/* log(+-0)=-inf */
+	    if (ix<0) return (x-x)/zero;	/* log(-#) = NaN */
+	    k -= 25; x *= two25; /* subnormal number, scale up x */
+	    GET_FLOAT_WORD(ix,x);
+	}
+	if (ix >= 0x7f800000) return x+x;
+	k += (ix>>23)-127;
+	ix &= 0x007fffff;
+	i = (ix+(0x95f64<<3))&0x800000;
+	SET_FLOAT_WORD(x,ix|(i^0x3f800000));	/* normalize x or x/2 */
+	k += (i>>23);
+	f = x-(float)1.0;
+	if((0x007fffff&(0x8000+ix))<0xc000) {	/* -2**-9 <= f < 2**-9 */
+	    if(f==zero) {
+		if(k==0) {
+		    return zero;
+		} else {
+		    dk=(float)k;
+		    return dk*ln2_hi+dk*ln2_lo;
+		}
+	    }
+	    R = f*f*((float)0.5-(float)0.33333333333333333*f);
+	    if(k==0) return f-R; else {dk=(float)k;
+	    	     return dk*ln2_hi-((R-dk*ln2_lo)-f);}
+	}
+ 	s = f/((float)2.0+f);
+	dk = (float)k;
+	z = s*s;
+	i = ix-(0x6147a<<3);
+	w = z*z;
+	j = (0x6b851<<3)-ix;
+	t1= w*(Lg2+w*Lg4);
+	t2= z*(Lg1+w*Lg3);
+	i |= j;
+	R = t2+t1;
+	if(i>0) {
+	    hfsq=(float)0.5*f*f;
+	    if(k==0) return f-(hfsq-s*(hfsq+R)); else
+		     return dk*ln2_hi-((hfsq-(s*(hfsq+R)+dk*ln2_lo))-f);
+	} else {
+	    if(k==0) return f-s*(f-R); else
+		     return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f);
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_pow.c b/libm/upstream-freebsd/lib/msun/src/e_pow.c
new file mode 100644
index 0000000..7607a4a
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_pow.c
@@ -0,0 +1,306 @@
+/* @(#)e_pow.c 1.5 04/04/22 SMI */
+/*
+ * ====================================================
+ * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_pow(x,y) return x**y
+ *
+ *		      n
+ * Method:  Let x =  2   * (1+f)
+ *	1. Compute and return log2(x) in two pieces:
+ *		log2(x) = w1 + w2,
+ *	   where w1 has 53-24 = 29 bit trailing zeros.
+ *	2. Perform y*log2(x) = n+y' by simulating muti-precision 
+ *	   arithmetic, where |y'|<=0.5.
+ *	3. Return x**y = 2**n*exp(y'*log2)
+ *
+ * Special cases:
+ *	1.  (anything) ** 0  is 1
+ *	2.  (anything) ** 1  is itself
+ *	3.  (anything) ** NAN is NAN
+ *	4.  NAN ** (anything except 0) is NAN
+ *	5.  +-(|x| > 1) **  +INF is +INF
+ *	6.  +-(|x| > 1) **  -INF is +0
+ *	7.  +-(|x| < 1) **  +INF is +0
+ *	8.  +-(|x| < 1) **  -INF is +INF
+ *	9.  +-1         ** +-INF is NAN
+ *	10. +0 ** (+anything except 0, NAN)               is +0
+ *	11. -0 ** (+anything except 0, NAN, odd integer)  is +0
+ *	12. +0 ** (-anything except 0, NAN)               is +INF
+ *	13. -0 ** (-anything except 0, NAN, odd integer)  is +INF
+ *	14. -0 ** (odd integer) = -( +0 ** (odd integer) )
+ *	15. +INF ** (+anything except 0,NAN) is +INF
+ *	16. +INF ** (-anything except 0,NAN) is +0
+ *	17. -INF ** (anything)  = -0 ** (-anything)
+ *	18. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer)
+ *	19. (-anything except 0 and inf) ** (non-integer) is NAN
+ *
+ * Accuracy:
+ *	pow(x,y) returns x**y nearly rounded. In particular
+ *			pow(integer,integer)
+ *	always returns the correct integer provided it is 
+ *	representable.
+ *
+ * Constants :
+ * The hexadecimal values are the intended ones for the following 
+ * constants. The decimal values may be used, provided that the 
+ * compiler will convert from decimal to binary accurately enough 
+ * to produce the hexadecimal values shown.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+static const double
+bp[] = {1.0, 1.5,},
+dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */
+dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */
+zero    =  0.0,
+one	=  1.0,
+two	=  2.0,
+two53	=  9007199254740992.0,	/* 0x43400000, 0x00000000 */
+huge	=  1.0e300,
+tiny    =  1.0e-300,
+	/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
+L1  =  5.99999999999994648725e-01, /* 0x3FE33333, 0x33333303 */
+L2  =  4.28571428578550184252e-01, /* 0x3FDB6DB6, 0xDB6FABFF */
+L3  =  3.33333329818377432918e-01, /* 0x3FD55555, 0x518F264D */
+L4  =  2.72728123808534006489e-01, /* 0x3FD17460, 0xA91D4101 */
+L5  =  2.30660745775561754067e-01, /* 0x3FCD864A, 0x93C9DB65 */
+L6  =  2.06975017800338417784e-01, /* 0x3FCA7E28, 0x4A454EEF */
+P1   =  1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */
+P2   = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */
+P3   =  6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
+P4   = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
+P5   =  4.13813679705723846039e-08, /* 0x3E663769, 0x72BEA4D0 */
+lg2  =  6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */
+lg2_h  =  6.93147182464599609375e-01, /* 0x3FE62E43, 0x00000000 */
+lg2_l  = -1.90465429995776804525e-09, /* 0xBE205C61, 0x0CA86C39 */
+ovt =  8.0085662595372944372e-0017, /* -(1024-log2(ovfl+.5ulp)) */
+cp    =  9.61796693925975554329e-01, /* 0x3FEEC709, 0xDC3A03FD =2/(3ln2) */
+cp_h  =  9.61796700954437255859e-01, /* 0x3FEEC709, 0xE0000000 =(float)cp */
+cp_l  = -7.02846165095275826516e-09, /* 0xBE3E2FE0, 0x145B01F5 =tail of cp_h*/
+ivln2    =  1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */
+ivln2_h  =  1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/
+ivln2_l  =  1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
+
+double
+__ieee754_pow(double x, double y)
+{
+	double z,ax,z_h,z_l,p_h,p_l;
+	double y1,t1,t2,r,s,t,u,v,w;
+	int32_t i,j,k,yisint,n;
+	int32_t hx,hy,ix,iy;
+	u_int32_t lx,ly;
+
+	EXTRACT_WORDS(hx,lx,x);
+	EXTRACT_WORDS(hy,ly,y);
+	ix = hx&0x7fffffff;  iy = hy&0x7fffffff;
+
+    /* y==zero: x**0 = 1 */
+	if((iy|ly)==0) return one; 	
+
+    /* x==1: 1**y = 1, even if y is NaN */
+	if (hx==0x3ff00000 && lx == 0) return one;
+
+    /* y!=zero: result is NaN if either arg is NaN */
+	if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) ||
+	   iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0))) 
+		return (x+0.0)+(y+0.0);
+
+    /* determine if y is an odd int when x < 0
+     * yisint = 0	... y is not an integer
+     * yisint = 1	... y is an odd int
+     * yisint = 2	... y is an even int
+     */
+	yisint  = 0;
+	if(hx<0) {	
+	    if(iy>=0x43400000) yisint = 2; /* even integer y */
+	    else if(iy>=0x3ff00000) {
+		k = (iy>>20)-0x3ff;	   /* exponent */
+		if(k>20) {
+		    j = ly>>(52-k);
+		    if((j<<(52-k))==ly) yisint = 2-(j&1);
+		} else if(ly==0) {
+		    j = iy>>(20-k);
+		    if((j<<(20-k))==iy) yisint = 2-(j&1);
+		}
+	    }		
+	} 
+
+    /* special value of y */
+	if(ly==0) { 	
+	    if (iy==0x7ff00000) {	/* y is +-inf */
+	        if(((ix-0x3ff00000)|lx)==0)
+		    return  one;	/* (-1)**+-inf is NaN */
+	        else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */
+		    return (hy>=0)? y: zero;
+	        else			/* (|x|<1)**-,+inf = inf,0 */
+		    return (hy<0)?-y: zero;
+	    } 
+	    if(iy==0x3ff00000) {	/* y is  +-1 */
+		if(hy<0) return one/x; else return x;
+	    }
+	    if(hy==0x40000000) return x*x; /* y is  2 */
+	    if(hy==0x3fe00000) {	/* y is  0.5 */
+		if(hx>=0)	/* x >= +0 */
+		return sqrt(x);	
+	    }
+	}
+
+	ax   = fabs(x);
+    /* special value of x */
+	if(lx==0) {
+	    if(ix==0x7ff00000||ix==0||ix==0x3ff00000){
+		z = ax;			/*x is +-0,+-inf,+-1*/
+		if(hy<0) z = one/z;	/* z = (1/|x|) */
+		if(hx<0) {
+		    if(((ix-0x3ff00000)|yisint)==0) {
+			z = (z-z)/(z-z); /* (-1)**non-int is NaN */
+		    } else if(yisint==1) 
+			z = -z;		/* (x<0)**odd = -(|x|**odd) */
+		}
+		return z;
+	    }
+	}
+    
+    /* CYGNUS LOCAL + fdlibm-5.3 fix: This used to be
+	n = (hx>>31)+1;
+       but ANSI C says a right shift of a signed negative quantity is
+       implementation defined.  */
+	n = ((u_int32_t)hx>>31)-1;
+
+    /* (x<0)**(non-int) is NaN */
+	if((n|yisint)==0) return (x-x)/(x-x);
+
+	s = one; /* s (sign of result -ve**odd) = -1 else = 1 */
+	if((n|(yisint-1))==0) s = -one;/* (-ve)**(odd int) */
+
+    /* |y| is huge */
+	if(iy>0x41e00000) { /* if |y| > 2**31 */
+	    if(iy>0x43f00000){	/* if |y| > 2**64, must o/uflow */
+		if(ix<=0x3fefffff) return (hy<0)? huge*huge:tiny*tiny;
+		if(ix>=0x3ff00000) return (hy>0)? huge*huge:tiny*tiny;
+	    }
+	/* over/underflow if x is not close to one */
+	    if(ix<0x3fefffff) return (hy<0)? s*huge*huge:s*tiny*tiny;
+	    if(ix>0x3ff00000) return (hy>0)? s*huge*huge:s*tiny*tiny;
+	/* now |1-x| is tiny <= 2**-20, suffice to compute 
+	   log(x) by x-x^2/2+x^3/3-x^4/4 */
+	    t = ax-one;		/* t has 20 trailing zeros */
+	    w = (t*t)*(0.5-t*(0.3333333333333333333333-t*0.25));
+	    u = ivln2_h*t;	/* ivln2_h has 21 sig. bits */
+	    v = t*ivln2_l-w*ivln2;
+	    t1 = u+v;
+	    SET_LOW_WORD(t1,0);
+	    t2 = v-(t1-u);
+	} else {
+	    double ss,s2,s_h,s_l,t_h,t_l;
+	    n = 0;
+	/* take care subnormal number */
+	    if(ix<0x00100000)
+		{ax *= two53; n -= 53; GET_HIGH_WORD(ix,ax); }
+	    n  += ((ix)>>20)-0x3ff;
+	    j  = ix&0x000fffff;
+	/* determine interval */
+	    ix = j|0x3ff00000;		/* normalize ix */
+	    if(j<=0x3988E) k=0;		/* |x|<sqrt(3/2) */
+	    else if(j<0xBB67A) k=1;	/* |x|<sqrt(3)   */
+	    else {k=0;n+=1;ix -= 0x00100000;}
+	    SET_HIGH_WORD(ax,ix);
+
+	/* compute ss = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
+	    u = ax-bp[k];		/* bp[0]=1.0, bp[1]=1.5 */
+	    v = one/(ax+bp[k]);
+	    ss = u*v;
+	    s_h = ss;
+	    SET_LOW_WORD(s_h,0);
+	/* t_h=ax+bp[k] High */
+	    t_h = zero;
+	    SET_HIGH_WORD(t_h,((ix>>1)|0x20000000)+0x00080000+(k<<18));
+	    t_l = ax - (t_h-bp[k]);
+	    s_l = v*((u-s_h*t_h)-s_h*t_l);
+	/* compute log(ax) */
+	    s2 = ss*ss;
+	    r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6)))));
+	    r += s_l*(s_h+ss);
+	    s2  = s_h*s_h;
+	    t_h = 3.0+s2+r;
+	    SET_LOW_WORD(t_h,0);
+	    t_l = r-((t_h-3.0)-s2);
+	/* u+v = ss*(1+...) */
+	    u = s_h*t_h;
+	    v = s_l*t_h+t_l*ss;
+	/* 2/(3log2)*(ss+...) */
+	    p_h = u+v;
+	    SET_LOW_WORD(p_h,0);
+	    p_l = v-(p_h-u);
+	    z_h = cp_h*p_h;		/* cp_h+cp_l = 2/(3*log2) */
+	    z_l = cp_l*p_h+p_l*cp+dp_l[k];
+	/* log2(ax) = (ss+..)*2/(3*log2) = n + dp_h + z_h + z_l */
+	    t = (double)n;
+	    t1 = (((z_h+z_l)+dp_h[k])+t);
+	    SET_LOW_WORD(t1,0);
+	    t2 = z_l-(((t1-t)-dp_h[k])-z_h);
+	}
+
+    /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
+	y1  = y;
+	SET_LOW_WORD(y1,0);
+	p_l = (y-y1)*t1+y*t2;
+	p_h = y1*t1;
+	z = p_l+p_h;
+	EXTRACT_WORDS(j,i,z);
+	if (j>=0x40900000) {				/* z >= 1024 */
+	    if(((j-0x40900000)|i)!=0)			/* if z > 1024 */
+		return s*huge*huge;			/* overflow */
+	    else {
+		if(p_l+ovt>z-p_h) return s*huge*huge;	/* overflow */
+	    }
+	} else if((j&0x7fffffff)>=0x4090cc00 ) {	/* z <= -1075 */
+	    if(((j-0xc090cc00)|i)!=0) 		/* z < -1075 */
+		return s*tiny*tiny;		/* underflow */
+	    else {
+		if(p_l<=z-p_h) return s*tiny*tiny;	/* underflow */
+	    }
+	}
+    /*
+     * compute 2**(p_h+p_l)
+     */
+	i = j&0x7fffffff;
+	k = (i>>20)-0x3ff;
+	n = 0;
+	if(i>0x3fe00000) {		/* if |z| > 0.5, set n = [z+0.5] */
+	    n = j+(0x00100000>>(k+1));
+	    k = ((n&0x7fffffff)>>20)-0x3ff;	/* new k for n */
+	    t = zero;
+	    SET_HIGH_WORD(t,n&~(0x000fffff>>k));
+	    n = ((n&0x000fffff)|0x00100000)>>(20-k);
+	    if(j<0) n = -n;
+	    p_h -= t;
+	} 
+	t = p_l+p_h;
+	SET_LOW_WORD(t,0);
+	u = t*lg2_h;
+	v = (p_l-(t-p_h))*lg2+t*lg2_l;
+	z = u+v;
+	w = v-(z-u);
+	t  = z*z;
+	t1  = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
+	r  = (z*t1)/(t1-two)-(w+z*w);
+	z  = one-(r-z);
+	GET_HIGH_WORD(j,z);
+	j += (n<<20);
+	if((j>>20)<=0) z = scalbn(z,n);	/* subnormal output */
+	else SET_HIGH_WORD(z,j);
+	return s*z;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_powf.c b/libm/upstream-freebsd/lib/msun/src/e_powf.c
new file mode 100644
index 0000000..5c46478
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_powf.c
@@ -0,0 +1,249 @@
+/* e_powf.c -- float version of e_pow.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static const float
+bp[] = {1.0, 1.5,},
+dp_h[] = { 0.0, 5.84960938e-01,}, /* 0x3f15c000 */
+dp_l[] = { 0.0, 1.56322085e-06,}, /* 0x35d1cfdc */
+zero    =  0.0,
+one	=  1.0,
+two	=  2.0,
+two24	=  16777216.0,	/* 0x4b800000 */
+huge	=  1.0e30,
+tiny    =  1.0e-30,
+	/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
+L1  =  6.0000002384e-01, /* 0x3f19999a */
+L2  =  4.2857143283e-01, /* 0x3edb6db7 */
+L3  =  3.3333334327e-01, /* 0x3eaaaaab */
+L4  =  2.7272811532e-01, /* 0x3e8ba305 */
+L5  =  2.3066075146e-01, /* 0x3e6c3255 */
+L6  =  2.0697501302e-01, /* 0x3e53f142 */
+P1   =  1.6666667163e-01, /* 0x3e2aaaab */
+P2   = -2.7777778450e-03, /* 0xbb360b61 */
+P3   =  6.6137559770e-05, /* 0x388ab355 */
+P4   = -1.6533901999e-06, /* 0xb5ddea0e */
+P5   =  4.1381369442e-08, /* 0x3331bb4c */
+lg2  =  6.9314718246e-01, /* 0x3f317218 */
+lg2_h  =  6.93145752e-01, /* 0x3f317200 */
+lg2_l  =  1.42860654e-06, /* 0x35bfbe8c */
+ovt =  4.2995665694e-08, /* -(128-log2(ovfl+.5ulp)) */
+cp    =  9.6179670095e-01, /* 0x3f76384f =2/(3ln2) */
+cp_h  =  9.6191406250e-01, /* 0x3f764000 =12b cp */
+cp_l  = -1.1736857402e-04, /* 0xb8f623c6 =tail of cp_h */
+ivln2    =  1.4426950216e+00, /* 0x3fb8aa3b =1/ln2 */
+ivln2_h  =  1.4426879883e+00, /* 0x3fb8aa00 =16b 1/ln2*/
+ivln2_l  =  7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/
+
+float
+__ieee754_powf(float x, float y)
+{
+	float z,ax,z_h,z_l,p_h,p_l;
+	float y1,t1,t2,r,s,sn,t,u,v,w;
+	int32_t i,j,k,yisint,n;
+	int32_t hx,hy,ix,iy,is;
+
+	GET_FLOAT_WORD(hx,x);
+	GET_FLOAT_WORD(hy,y);
+	ix = hx&0x7fffffff;  iy = hy&0x7fffffff;
+
+    /* y==zero: x**0 = 1 */
+	if(iy==0) return one;
+
+    /* x==1: 1**y = 1, even if y is NaN */
+	if (hx==0x3f800000) return one;
+
+    /* y!=zero: result is NaN if either arg is NaN */
+	if(ix > 0x7f800000 ||
+	   iy > 0x7f800000)
+		return (x+0.0F)+(y+0.0F);
+
+    /* determine if y is an odd int when x < 0
+     * yisint = 0	... y is not an integer
+     * yisint = 1	... y is an odd int
+     * yisint = 2	... y is an even int
+     */
+	yisint  = 0;
+	if(hx<0) {
+	    if(iy>=0x4b800000) yisint = 2; /* even integer y */
+	    else if(iy>=0x3f800000) {
+		k = (iy>>23)-0x7f;	   /* exponent */
+		j = iy>>(23-k);
+		if((j<<(23-k))==iy) yisint = 2-(j&1);
+	    }
+	}
+
+    /* special value of y */
+	if (iy==0x7f800000) {	/* y is +-inf */
+	    if (ix==0x3f800000)
+	        return  one;	/* (-1)**+-inf is NaN */
+	    else if (ix > 0x3f800000)/* (|x|>1)**+-inf = inf,0 */
+	        return (hy>=0)? y: zero;
+	    else			/* (|x|<1)**-,+inf = inf,0 */
+	        return (hy<0)?-y: zero;
+	}
+	if(iy==0x3f800000) {	/* y is  +-1 */
+	    if(hy<0) return one/x; else return x;
+	}
+	if(hy==0x40000000) return x*x; /* y is  2 */
+	if(hy==0x3f000000) {	/* y is  0.5 */
+	    if(hx>=0)	/* x >= +0 */
+	    return __ieee754_sqrtf(x);
+	}
+
+	ax   = fabsf(x);
+    /* special value of x */
+	if(ix==0x7f800000||ix==0||ix==0x3f800000){
+	    z = ax;			/*x is +-0,+-inf,+-1*/
+	    if(hy<0) z = one/z;	/* z = (1/|x|) */
+	    if(hx<0) {
+		if(((ix-0x3f800000)|yisint)==0) {
+		    z = (z-z)/(z-z); /* (-1)**non-int is NaN */
+		} else if(yisint==1)
+		    z = -z;		/* (x<0)**odd = -(|x|**odd) */
+	    }
+	    return z;
+	}
+
+	n = ((u_int32_t)hx>>31)-1;
+
+    /* (x<0)**(non-int) is NaN */
+	if((n|yisint)==0) return (x-x)/(x-x);
+
+	sn = one; /* s (sign of result -ve**odd) = -1 else = 1 */
+	if((n|(yisint-1))==0) sn = -one;/* (-ve)**(odd int) */
+
+    /* |y| is huge */
+	if(iy>0x4d000000) { /* if |y| > 2**27 */
+	/* over/underflow if x is not close to one */
+	    if(ix<0x3f7ffff8) return (hy<0)? sn*huge*huge:sn*tiny*tiny;
+	    if(ix>0x3f800007) return (hy>0)? sn*huge*huge:sn*tiny*tiny;
+	/* now |1-x| is tiny <= 2**-20, suffice to compute
+	   log(x) by x-x^2/2+x^3/3-x^4/4 */
+	    t = ax-1;		/* t has 20 trailing zeros */
+	    w = (t*t)*((float)0.5-t*((float)0.333333333333-t*(float)0.25));
+	    u = ivln2_h*t;	/* ivln2_h has 16 sig. bits */
+	    v = t*ivln2_l-w*ivln2;
+	    t1 = u+v;
+	    GET_FLOAT_WORD(is,t1);
+	    SET_FLOAT_WORD(t1,is&0xfffff000);
+	    t2 = v-(t1-u);
+	} else {
+	    float s2,s_h,s_l,t_h,t_l;
+	    n = 0;
+	/* take care subnormal number */
+	    if(ix<0x00800000)
+		{ax *= two24; n -= 24; GET_FLOAT_WORD(ix,ax); }
+	    n  += ((ix)>>23)-0x7f;
+	    j  = ix&0x007fffff;
+	/* determine interval */
+	    ix = j|0x3f800000;		/* normalize ix */
+	    if(j<=0x1cc471) k=0;	/* |x|<sqrt(3/2) */
+	    else if(j<0x5db3d7) k=1;	/* |x|<sqrt(3)   */
+	    else {k=0;n+=1;ix -= 0x00800000;}
+	    SET_FLOAT_WORD(ax,ix);
+
+	/* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
+	    u = ax-bp[k];		/* bp[0]=1.0, bp[1]=1.5 */
+	    v = one/(ax+bp[k]);
+	    s = u*v;
+	    s_h = s;
+	    GET_FLOAT_WORD(is,s_h);
+	    SET_FLOAT_WORD(s_h,is&0xfffff000);
+	/* t_h=ax+bp[k] High */
+	    is = ((ix>>1)&0xfffff000)|0x20000000;
+	    SET_FLOAT_WORD(t_h,is+0x00400000+(k<<21));
+	    t_l = ax - (t_h-bp[k]);
+	    s_l = v*((u-s_h*t_h)-s_h*t_l);
+	/* compute log(ax) */
+	    s2 = s*s;
+	    r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6)))));
+	    r += s_l*(s_h+s);
+	    s2  = s_h*s_h;
+	    t_h = (float)3.0+s2+r;
+	    GET_FLOAT_WORD(is,t_h);
+	    SET_FLOAT_WORD(t_h,is&0xfffff000);
+	    t_l = r-((t_h-(float)3.0)-s2);
+	/* u+v = s*(1+...) */
+	    u = s_h*t_h;
+	    v = s_l*t_h+t_l*s;
+	/* 2/(3log2)*(s+...) */
+	    p_h = u+v;
+	    GET_FLOAT_WORD(is,p_h);
+	    SET_FLOAT_WORD(p_h,is&0xfffff000);
+	    p_l = v-(p_h-u);
+	    z_h = cp_h*p_h;		/* cp_h+cp_l = 2/(3*log2) */
+	    z_l = cp_l*p_h+p_l*cp+dp_l[k];
+	/* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */
+	    t = (float)n;
+	    t1 = (((z_h+z_l)+dp_h[k])+t);
+	    GET_FLOAT_WORD(is,t1);
+	    SET_FLOAT_WORD(t1,is&0xfffff000);
+	    t2 = z_l-(((t1-t)-dp_h[k])-z_h);
+	}
+
+    /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
+	GET_FLOAT_WORD(is,y);
+	SET_FLOAT_WORD(y1,is&0xfffff000);
+	p_l = (y-y1)*t1+y*t2;
+	p_h = y1*t1;
+	z = p_l+p_h;
+	GET_FLOAT_WORD(j,z);
+	if (j>0x43000000)				/* if z > 128 */
+	    return sn*huge*huge;			/* overflow */
+	else if (j==0x43000000) {			/* if z == 128 */
+	    if(p_l+ovt>z-p_h) return sn*huge*huge;	/* overflow */
+	}
+	else if ((j&0x7fffffff)>0x43160000)		/* z <= -150 */
+	    return sn*tiny*tiny;			/* underflow */
+	else if (j==0xc3160000){			/* z == -150 */
+	    if(p_l<=z-p_h) return sn*tiny*tiny;		/* underflow */
+	}
+    /*
+     * compute 2**(p_h+p_l)
+     */
+	i = j&0x7fffffff;
+	k = (i>>23)-0x7f;
+	n = 0;
+	if(i>0x3f000000) {		/* if |z| > 0.5, set n = [z+0.5] */
+	    n = j+(0x00800000>>(k+1));
+	    k = ((n&0x7fffffff)>>23)-0x7f;	/* new k for n */
+	    SET_FLOAT_WORD(t,n&~(0x007fffff>>k));
+	    n = ((n&0x007fffff)|0x00800000)>>(23-k);
+	    if(j<0) n = -n;
+	    p_h -= t;
+	}
+	t = p_l+p_h;
+	GET_FLOAT_WORD(is,t);
+	SET_FLOAT_WORD(t,is&0xffff8000);
+	u = t*lg2_h;
+	v = (p_l-(t-p_h))*lg2+t*lg2_l;
+	z = u+v;
+	w = v-(z-u);
+	t  = z*z;
+	t1  = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
+	r  = (z*t1)/(t1-two)-(w+z*w);
+	z  = one-(r-z);
+	GET_FLOAT_WORD(j,z);
+	j += (n<<23);
+	if((j>>23)<=0) z = scalbnf(z,n);	/* subnormal output */
+	else SET_FLOAT_WORD(z,j);
+	return sn*z;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_rem_pio2.c b/libm/upstream-freebsd/lib/msun/src/e_rem_pio2.c
new file mode 100644
index 0000000..be2630b
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_rem_pio2.c
@@ -0,0 +1,186 @@
+
+/* @(#)e_rem_pio2.c 1.4 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ *
+ * Optimized by Bruce D. Evans.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_rem_pio2(x,y)
+ * 
+ * return the remainder of x rem pi/2 in y[0]+y[1] 
+ * use __kernel_rem_pio2()
+ */
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+/*
+ * invpio2:  53 bits of 2/pi
+ * pio2_1:   first  33 bit of pi/2
+ * pio2_1t:  pi/2 - pio2_1
+ * pio2_2:   second 33 bit of pi/2
+ * pio2_2t:  pi/2 - (pio2_1+pio2_2)
+ * pio2_3:   third  33 bit of pi/2
+ * pio2_3t:  pi/2 - (pio2_1+pio2_2+pio2_3)
+ */
+
+static const double
+zero =  0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
+two24 =  1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */
+invpio2 =  6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */
+pio2_1  =  1.57079632673412561417e+00, /* 0x3FF921FB, 0x54400000 */
+pio2_1t =  6.07710050650619224932e-11, /* 0x3DD0B461, 0x1A626331 */
+pio2_2  =  6.07710050630396597660e-11, /* 0x3DD0B461, 0x1A600000 */
+pio2_2t =  2.02226624879595063154e-21, /* 0x3BA3198A, 0x2E037073 */
+pio2_3  =  2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */
+pio2_3t =  8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */
+
+#ifdef INLINE_REM_PIO2
+static __inline __always_inline
+#endif
+int
+__ieee754_rem_pio2(double x, double *y)
+{
+	double z,w,t,r,fn;
+	double tx[3],ty[2];
+	int32_t e0,i,j,nx,n,ix,hx;
+	u_int32_t low;
+
+	GET_HIGH_WORD(hx,x);		/* high word of x */
+	ix = hx&0x7fffffff;
+#if 0 /* Must be handled in caller. */
+	if(ix<=0x3fe921fb)   /* |x| ~<= pi/4 , no need for reduction */
+	    {y[0] = x; y[1] = 0; return 0;}
+#endif
+	if (ix <= 0x400f6a7a) {		/* |x| ~<= 5pi/4 */
+	    if ((ix & 0xfffff) == 0x921fb)  /* |x| ~= pi/2 or 2pi/2 */
+		goto medium;		/* cancellation -- use medium case */
+	    if (ix <= 0x4002d97c) {	/* |x| ~<= 3pi/4 */
+		if (hx > 0) {
+		    z = x - pio2_1;	/* one round good to 85 bits */
+		    y[0] = z - pio2_1t;
+		    y[1] = (z-y[0])-pio2_1t;
+		    return 1;
+		} else {
+		    z = x + pio2_1;
+		    y[0] = z + pio2_1t;
+		    y[1] = (z-y[0])+pio2_1t;
+		    return -1;
+		}
+	    } else {
+		if (hx > 0) {
+		    z = x - 2*pio2_1;
+		    y[0] = z - 2*pio2_1t;
+		    y[1] = (z-y[0])-2*pio2_1t;
+		    return 2;
+		} else {
+		    z = x + 2*pio2_1;
+		    y[0] = z + 2*pio2_1t;
+		    y[1] = (z-y[0])+2*pio2_1t;
+		    return -2;
+		}
+	    }
+	}
+	if (ix <= 0x401c463b) {		/* |x| ~<= 9pi/4 */
+	    if (ix <= 0x4015fdbc) {	/* |x| ~<= 7pi/4 */
+		if (ix == 0x4012d97c)	/* |x| ~= 3pi/2 */
+		    goto medium;
+		if (hx > 0) {
+		    z = x - 3*pio2_1;
+		    y[0] = z - 3*pio2_1t;
+		    y[1] = (z-y[0])-3*pio2_1t;
+		    return 3;
+		} else {
+		    z = x + 3*pio2_1;
+		    y[0] = z + 3*pio2_1t;
+		    y[1] = (z-y[0])+3*pio2_1t;
+		    return -3;
+		}
+	    } else {
+		if (ix == 0x401921fb)	/* |x| ~= 4pi/2 */
+		    goto medium;
+		if (hx > 0) {
+		    z = x - 4*pio2_1;
+		    y[0] = z - 4*pio2_1t;
+		    y[1] = (z-y[0])-4*pio2_1t;
+		    return 4;
+		} else {
+		    z = x + 4*pio2_1;
+		    y[0] = z + 4*pio2_1t;
+		    y[1] = (z-y[0])+4*pio2_1t;
+		    return -4;
+		}
+	    }
+	}
+	if(ix<0x413921fb) {	/* |x| ~< 2^20*(pi/2), medium size */
+medium:
+	    /* Use a specialized rint() to get fn.  Assume round-to-nearest. */
+	    STRICT_ASSIGN(double,fn,x*invpio2+0x1.8p52);
+	    fn = fn-0x1.8p52;
+#ifdef HAVE_EFFICIENT_IRINT
+	    n  = irint(fn);
+#else
+	    n  = (int32_t)fn;
+#endif
+	    r  = x-fn*pio2_1;
+	    w  = fn*pio2_1t;	/* 1st round good to 85 bit */
+	    {
+	        u_int32_t high;
+	        j  = ix>>20;
+	        y[0] = r-w; 
+		GET_HIGH_WORD(high,y[0]);
+	        i = j-((high>>20)&0x7ff);
+	        if(i>16) {  /* 2nd iteration needed, good to 118 */
+		    t  = r;
+		    w  = fn*pio2_2;	
+		    r  = t-w;
+		    w  = fn*pio2_2t-((t-r)-w);	
+		    y[0] = r-w;
+		    GET_HIGH_WORD(high,y[0]);
+		    i = j-((high>>20)&0x7ff);
+		    if(i>49)  {	/* 3rd iteration need, 151 bits acc */
+		    	t  = r;	/* will cover all possible cases */
+		    	w  = fn*pio2_3;	
+		    	r  = t-w;
+		    	w  = fn*pio2_3t-((t-r)-w);	
+		    	y[0] = r-w;
+		    }
+		}
+	    }
+	    y[1] = (r-y[0])-w;
+	    return n;
+	}
+    /* 
+     * all other (large) arguments
+     */
+	if(ix>=0x7ff00000) {		/* x is inf or NaN */
+	    y[0]=y[1]=x-x; return 0;
+	}
+    /* set z = scalbn(|x|,ilogb(x)-23) */
+	GET_LOW_WORD(low,x);
+	e0 	= (ix>>20)-1046;	/* e0 = ilogb(z)-23; */
+	INSERT_WORDS(z, ix - ((int32_t)(e0<<20)), low);
+	for(i=0;i<2;i++) {
+		tx[i] = (double)((int32_t)(z));
+		z     = (z-tx[i])*two24;
+	}
+	tx[2] = z;
+	nx = 3;
+	while(tx[nx-1]==zero) nx--;	/* skip zero term */
+	n  =  __kernel_rem_pio2(tx,ty,e0,nx,1);
+	if(hx<0) {y[0] = -ty[0]; y[1] = -ty[1]; return -n;}
+	y[0] = ty[0]; y[1] = ty[1]; return n;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_rem_pio2f.c b/libm/upstream-freebsd/lib/msun/src/e_rem_pio2f.c
new file mode 100644
index 0000000..f1ee7a0
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_rem_pio2f.c
@@ -0,0 +1,84 @@
+/* e_rem_pio2f.c -- float version of e_rem_pio2.c
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ * Debugged and optimized by Bruce D. Evans.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_rem_pio2f(x,y)
+ *
+ * return the remainder of x rem pi/2 in *y
+ * use double precision for everything except passing x
+ * use __kernel_rem_pio2() for large x
+ */
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+/*
+ * invpio2:  53 bits of 2/pi
+ * pio2_1:   first 25 bits of pi/2
+ * pio2_1t:  pi/2 - pio2_1
+ */
+
+static const double
+invpio2 =  6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */
+pio2_1  =  1.57079631090164184570e+00, /* 0x3FF921FB, 0x50000000 */
+pio2_1t =  1.58932547735281966916e-08; /* 0x3E5110b4, 0x611A6263 */
+
+#ifdef INLINE_REM_PIO2F
+static __inline __always_inline
+#endif
+int
+__ieee754_rem_pio2f(float x, double *y)
+{
+	double w,r,fn;
+	double tx[1],ty[1];
+	float z;
+	int32_t e0,n,ix,hx;
+
+	GET_FLOAT_WORD(hx,x);
+	ix = hx&0x7fffffff;
+    /* 33+53 bit pi is good enough for medium size */
+	if(ix<0x4dc90fdb) {		/* |x| ~< 2^28*(pi/2), medium size */
+	    /* Use a specialized rint() to get fn.  Assume round-to-nearest. */
+	    STRICT_ASSIGN(double,fn,x*invpio2+0x1.8p52);
+	    fn = fn-0x1.8p52;
+#ifdef HAVE_EFFICIENT_IRINT
+	    n  = irint(fn);
+#else
+	    n  = (int32_t)fn;
+#endif
+	    r  = x-fn*pio2_1;
+	    w  = fn*pio2_1t;
+	    *y = r-w;
+	    return n;
+	}
+    /*
+     * all other (large) arguments
+     */
+	if(ix>=0x7f800000) {		/* x is inf or NaN */
+	    *y=x-x; return 0;
+	}
+    /* set z = scalbn(|x|,ilogb(|x|)-23) */
+	e0 = (ix>>23)-150;		/* e0 = ilogb(|x|)-23; */
+	SET_FLOAT_WORD(z, ix - ((int32_t)(e0<<23)));
+	tx[0] = z;
+	n  =  __kernel_rem_pio2(tx,ty,e0,1,0);
+	if(hx<0) {*y = -ty[0]; return -n;}
+	*y = ty[0]; return n;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_remainder.c b/libm/upstream-freebsd/lib/msun/src/e_remainder.c
new file mode 100644
index 0000000..9be513b
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_remainder.c
@@ -0,0 +1,79 @@
+
+/* @(#)e_remainder.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_remainder(x,p)
+ * Return :                  
+ * 	returns  x REM p  =  x - [x/p]*p as if in infinite 
+ * 	precise arithmetic, where [x/p] is the (infinite bit) 
+ *	integer nearest x/p (in half way case choose the even one).
+ * Method : 
+ *	Based on fmod() return x-[x/p]chopped*p exactlp.
+ */
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const double zero = 0.0;
+
+
+double
+__ieee754_remainder(double x, double p)
+{
+	int32_t hx,hp;
+	u_int32_t sx,lx,lp;
+	double p_half;
+
+	EXTRACT_WORDS(hx,lx,x);
+	EXTRACT_WORDS(hp,lp,p);
+	sx = hx&0x80000000;
+	hp &= 0x7fffffff;
+	hx &= 0x7fffffff;
+
+    /* purge off exception values */
+	if((hp|lp)==0) return (x*p)/(x*p); 	/* p = 0 */
+	if((hx>=0x7ff00000)||			/* x not finite */
+	  ((hp>=0x7ff00000)&&			/* p is NaN */
+	  (((hp-0x7ff00000)|lp)!=0)))
+	    return ((long double)x*p)/((long double)x*p);
+
+
+	if (hp<=0x7fdfffff) x = __ieee754_fmod(x,p+p);	/* now x < 2p */
+	if (((hx-hp)|(lx-lp))==0) return zero*x;
+	x  = fabs(x);
+	p  = fabs(p);
+	if (hp<0x00200000) {
+	    if(x+x>p) {
+		x-=p;
+		if(x+x>=p) x -= p;
+	    }
+	} else {
+	    p_half = 0.5*p;
+	    if(x>p_half) {
+		x-=p;
+		if(x>=p_half) x -= p;
+	    }
+	}
+	GET_HIGH_WORD(hx,x);
+	if ((hx&0x7fffffff)==0) hx = 0;
+	SET_HIGH_WORD(x,hx^sx);
+	return x;
+}
+
+#if LDBL_MANT_DIG == 53
+__weak_reference(remainder, remainderl);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/e_remainderf.c b/libm/upstream-freebsd/lib/msun/src/e_remainderf.c
new file mode 100644
index 0000000..b0014ae
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_remainderf.c
@@ -0,0 +1,65 @@
+/* e_remainderf.c -- float version of e_remainder.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static const float zero = 0.0;
+
+
+float
+__ieee754_remainderf(float x, float p)
+{
+	int32_t hx,hp;
+	u_int32_t sx;
+	float p_half;
+
+	GET_FLOAT_WORD(hx,x);
+	GET_FLOAT_WORD(hp,p);
+	sx = hx&0x80000000;
+	hp &= 0x7fffffff;
+	hx &= 0x7fffffff;
+
+    /* purge off exception values */
+	if(hp==0) return (x*p)/(x*p);	 	/* p = 0 */
+	if((hx>=0x7f800000)||			/* x not finite */
+	  ((hp>0x7f800000)))			/* p is NaN */
+	    return ((long double)x*p)/((long double)x*p);
+
+
+	if (hp<=0x7effffff) x = __ieee754_fmodf(x,p+p);	/* now x < 2p */
+	if ((hx-hp)==0) return zero*x;
+	x  = fabsf(x);
+	p  = fabsf(p);
+	if (hp<0x01000000) {
+	    if(x+x>p) {
+		x-=p;
+		if(x+x>=p) x -= p;
+	    }
+	} else {
+	    p_half = (float)0.5*p;
+	    if(x>p_half) {
+		x-=p;
+		if(x>=p_half) x -= p;
+	    }
+	}
+	GET_FLOAT_WORD(hx,x);
+	if ((hx&0x7fffffff)==0) hx = 0;
+	SET_FLOAT_WORD(x,hx^sx);
+	return x;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_remainderl.c b/libm/upstream-freebsd/lib/msun/src/e_remainderl.c
new file mode 100644
index 0000000..03327b8
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_remainderl.c
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2008 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <math.h>
+
+long double
+remainderl(long double x, long double y)
+{
+	int quo;
+
+	return (remquol(x, y, &quo));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_scalb.c b/libm/upstream-freebsd/lib/msun/src/e_scalb.c
new file mode 100644
index 0000000..c0a7b5b
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_scalb.c
@@ -0,0 +1,47 @@
+
+/* @(#)e_scalb.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * __ieee754_scalb(x, fn) is provide for
+ * passing various standard test suite. One 
+ * should use scalbn() instead.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+#ifdef _SCALB_INT
+double
+__ieee754_scalb(double x, int fn)
+#else
+double
+__ieee754_scalb(double x, double fn)
+#endif
+{
+#ifdef _SCALB_INT
+	return scalbn(x,fn);
+#else
+	if (isnan(x)||isnan(fn)) return x*fn;
+	if (!finite(fn)) {
+	    if(fn>0.0) return x*fn;
+	    else       return x/(-fn);
+	}
+	if (rint(fn)!=fn) return (fn-fn)/(fn-fn);
+	if ( fn > 65000.0) return scalbn(x, 65000);
+	if (-fn > 65000.0) return scalbn(x,-65000);
+	return scalbn(x,(int)fn);
+#endif
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_scalbf.c b/libm/upstream-freebsd/lib/msun/src/e_scalbf.c
new file mode 100644
index 0000000..d49e904
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_scalbf.c
@@ -0,0 +1,43 @@
+/* e_scalbf.c -- float version of e_scalb.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+#ifdef _SCALB_INT
+float
+__ieee754_scalbf(float x, int fn)
+#else
+float
+__ieee754_scalbf(float x, float fn)
+#endif
+{
+#ifdef _SCALB_INT
+	return scalbnf(x,fn);
+#else
+	if ((isnanf)(x)||(isnanf)(fn)) return x*fn;
+	if (!finitef(fn)) {
+	    if(fn>(float)0.0) return x*fn;
+	    else       return x/(-fn);
+	}
+	if (rintf(fn)!=fn) return (fn-fn)/(fn-fn);
+	if ( fn > (float)65000.0) return scalbnf(x, 65000);
+	if (-fn > (float)65000.0) return scalbnf(x,-65000);
+	return scalbnf(x,(int)fn);
+#endif
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_sinh.c b/libm/upstream-freebsd/lib/msun/src/e_sinh.c
new file mode 100644
index 0000000..17442d0
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_sinh.c
@@ -0,0 +1,73 @@
+
+/* @(#)e_sinh.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_sinh(x)
+ * Method : 
+ * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
+ *	1. Replace x by |x| (sinh(-x) = -sinh(x)). 
+ *	2. 
+ *		                                    E + E/(E+1)
+ *	    0        <= x <= 22     :  sinh(x) := --------------, E=expm1(x)
+ *			       			        2
+ *
+ *	    22       <= x <= lnovft :  sinh(x) := exp(x)/2 
+ *	    lnovft   <= x <= ln2ovft:  sinh(x) := exp(x/2)/2 * exp(x/2)
+ *	    ln2ovft  <  x	    :  sinh(x) := x*shuge (overflow)
+ *
+ * Special cases:
+ *	sinh(x) is |x| if x is +INF, -INF, or NaN.
+ *	only sinh(0)=0 is exact for finite x.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+static const double one = 1.0, shuge = 1.0e307;
+
+double
+__ieee754_sinh(double x)
+{
+	double t,h;
+	int32_t ix,jx;
+
+    /* High word of |x|. */
+	GET_HIGH_WORD(jx,x);
+	ix = jx&0x7fffffff;
+
+    /* x is INF or NaN */
+	if(ix>=0x7ff00000) return x+x;	
+
+	h = 0.5;
+	if (jx<0) h = -h;
+    /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
+	if (ix < 0x40360000) {		/* |x|<22 */
+	    if (ix<0x3e300000) 		/* |x|<2**-28 */
+		if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
+	    t = expm1(fabs(x));
+	    if(ix<0x3ff00000) return h*(2.0*t-t*t/(t+one));
+	    return h*(t+t/(t+one));
+	}
+
+    /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */
+	if (ix < 0x40862E42)  return h*__ieee754_exp(fabs(x));
+
+    /* |x| in [log(maxdouble), overflowthresold] */
+	if (ix<=0x408633CE)
+	    return h*2.0*__ldexp_exp(fabs(x), -1);
+
+    /* |x| > overflowthresold, sinh(x) overflow */
+	return x*shuge;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_sinhf.c b/libm/upstream-freebsd/lib/msun/src/e_sinhf.c
new file mode 100644
index 0000000..1be2dc3
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_sinhf.c
@@ -0,0 +1,56 @@
+/* e_sinhf.c -- float version of e_sinh.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static const float one = 1.0, shuge = 1.0e37;
+
+float
+__ieee754_sinhf(float x)
+{
+	float t,h;
+	int32_t ix,jx;
+
+	GET_FLOAT_WORD(jx,x);
+	ix = jx&0x7fffffff;
+
+    /* x is INF or NaN */
+	if(ix>=0x7f800000) return x+x;
+
+	h = 0.5;
+	if (jx<0) h = -h;
+    /* |x| in [0,9], return sign(x)*0.5*(E+E/(E+1))) */
+	if (ix < 0x41100000) {		/* |x|<9 */
+	    if (ix<0x39800000) 		/* |x|<2**-12 */
+		if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
+	    t = expm1f(fabsf(x));
+	    if(ix<0x3f800000) return h*((float)2.0*t-t*t/(t+one));
+	    return h*(t+t/(t+one));
+	}
+
+    /* |x| in [9, logf(maxfloat)] return 0.5*exp(|x|) */
+	if (ix < 0x42b17217)  return h*__ieee754_expf(fabsf(x));
+
+    /* |x| in [logf(maxfloat), overflowthresold] */
+	if (ix<=0x42b2d4fc)
+	    return h*2.0F*__ldexp_expf(fabsf(x), -1);
+
+    /* |x| > overflowthresold, sinh(x) overflow */
+	return x*shuge;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_sqrt.c b/libm/upstream-freebsd/lib/msun/src/e_sqrt.c
new file mode 100644
index 0000000..12fb56e
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_sqrt.c
@@ -0,0 +1,451 @@
+
+/* @(#)e_sqrt.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __ieee754_sqrt(x)
+ * Return correctly rounded sqrt.
+ *           ------------------------------------------
+ *	     |  Use the hardware sqrt if you have one |
+ *           ------------------------------------------
+ * Method: 
+ *   Bit by bit method using integer arithmetic. (Slow, but portable) 
+ *   1. Normalization
+ *	Scale x to y in [1,4) with even powers of 2: 
+ *	find an integer k such that  1 <= (y=x*2^(2k)) < 4, then
+ *		sqrt(x) = 2^k * sqrt(y)
+ *   2. Bit by bit computation
+ *	Let q  = sqrt(y) truncated to i bit after binary point (q = 1),
+ *	     i							 0
+ *                                     i+1         2
+ *	    s  = 2*q , and	y  =  2   * ( y - q  ).		(1)
+ *	     i      i            i                 i
+ *                                                        
+ *	To compute q    from q , one checks whether 
+ *		    i+1       i                       
+ *
+ *			      -(i+1) 2
+ *			(q + 2      ) <= y.			(2)
+ *     			  i
+ *							      -(i+1)
+ *	If (2) is false, then q   = q ; otherwise q   = q  + 2      .
+ *		 	       i+1   i             i+1   i
+ *
+ *	With some algebric manipulation, it is not difficult to see
+ *	that (2) is equivalent to 
+ *                             -(i+1)
+ *			s  +  2       <= y			(3)
+ *			 i                i
+ *
+ *	The advantage of (3) is that s  and y  can be computed by 
+ *				      i      i
+ *	the following recurrence formula:
+ *	    if (3) is false
+ *
+ *	    s     =  s  ,	y    = y   ;			(4)
+ *	     i+1      i		 i+1    i
+ *
+ *	    otherwise,
+ *                         -i                     -(i+1)
+ *	    s	  =  s  + 2  ,  y    = y  -  s  - 2  		(5)
+ *           i+1      i          i+1    i     i
+ *				
+ *	One may easily use induction to prove (4) and (5). 
+ *	Note. Since the left hand side of (3) contain only i+2 bits,
+ *	      it does not necessary to do a full (53-bit) comparison 
+ *	      in (3).
+ *   3. Final rounding
+ *	After generating the 53 bits result, we compute one more bit.
+ *	Together with the remainder, we can decide whether the
+ *	result is exact, bigger than 1/2ulp, or less than 1/2ulp
+ *	(it will never equal to 1/2ulp).
+ *	The rounding mode can be detected by checking whether
+ *	huge + tiny is equal to huge, and whether huge - tiny is
+ *	equal to huge for some floating point number "huge" and "tiny".
+ *		
+ * Special cases:
+ *	sqrt(+-0) = +-0 	... exact
+ *	sqrt(inf) = inf
+ *	sqrt(-ve) = NaN		... with invalid signal
+ *	sqrt(NaN) = NaN		... with invalid signal for signaling NaN
+ *
+ * Other methods : see the appended file at the end of the program below.
+ *---------------
+ */
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static	const double	one	= 1.0, tiny=1.0e-300;
+
+double
+__ieee754_sqrt(double x)
+{
+	double z;
+	int32_t sign = (int)0x80000000;
+	int32_t ix0,s0,q,m,t,i;
+	u_int32_t r,t1,s1,ix1,q1;
+
+	EXTRACT_WORDS(ix0,ix1,x);
+
+    /* take care of Inf and NaN */
+	if((ix0&0x7ff00000)==0x7ff00000) {			
+	    return x*x+x;		/* sqrt(NaN)=NaN, sqrt(+inf)=+inf
+					   sqrt(-inf)=sNaN */
+	} 
+    /* take care of zero */
+	if(ix0<=0) {
+	    if(((ix0&(~sign))|ix1)==0) return x;/* sqrt(+-0) = +-0 */
+	    else if(ix0<0)
+		return (x-x)/(x-x);		/* sqrt(-ve) = sNaN */
+	}
+    /* normalize x */
+	m = (ix0>>20);
+	if(m==0) {				/* subnormal x */
+	    while(ix0==0) {
+		m -= 21;
+		ix0 |= (ix1>>11); ix1 <<= 21;
+	    }
+	    for(i=0;(ix0&0x00100000)==0;i++) ix0<<=1;
+	    m -= i-1;
+	    ix0 |= (ix1>>(32-i));
+	    ix1 <<= i;
+	}
+	m -= 1023;	/* unbias exponent */
+	ix0 = (ix0&0x000fffff)|0x00100000;
+	if(m&1){	/* odd m, double x to make it even */
+	    ix0 += ix0 + ((ix1&sign)>>31);
+	    ix1 += ix1;
+	}
+	m >>= 1;	/* m = [m/2] */
+
+    /* generate sqrt(x) bit by bit */
+	ix0 += ix0 + ((ix1&sign)>>31);
+	ix1 += ix1;
+	q = q1 = s0 = s1 = 0;	/* [q,q1] = sqrt(x) */
+	r = 0x00200000;		/* r = moving bit from right to left */
+
+	while(r!=0) {
+	    t = s0+r; 
+	    if(t<=ix0) { 
+		s0   = t+r; 
+		ix0 -= t; 
+		q   += r; 
+	    } 
+	    ix0 += ix0 + ((ix1&sign)>>31);
+	    ix1 += ix1;
+	    r>>=1;
+	}
+
+	r = sign;
+	while(r!=0) {
+	    t1 = s1+r; 
+	    t  = s0;
+	    if((t<ix0)||((t==ix0)&&(t1<=ix1))) { 
+		s1  = t1+r;
+		if(((t1&sign)==sign)&&(s1&sign)==0) s0 += 1;
+		ix0 -= t;
+		if (ix1 < t1) ix0 -= 1;
+		ix1 -= t1;
+		q1  += r;
+	    }
+	    ix0 += ix0 + ((ix1&sign)>>31);
+	    ix1 += ix1;
+	    r>>=1;
+	}
+
+    /* use floating add to find out rounding direction */
+	if((ix0|ix1)!=0) {
+	    z = one-tiny; /* trigger inexact flag */
+	    if (z>=one) {
+	        z = one+tiny;
+	        if (q1==(u_int32_t)0xffffffff) { q1=0; q += 1;}
+		else if (z>one) {
+		    if (q1==(u_int32_t)0xfffffffe) q+=1;
+		    q1+=2; 
+		} else
+	            q1 += (q1&1);
+	    }
+	}
+	ix0 = (q>>1)+0x3fe00000;
+	ix1 =  q1>>1;
+	if ((q&1)==1) ix1 |= sign;
+	ix0 += (m <<20);
+	INSERT_WORDS(z,ix0,ix1);
+	return z;
+}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(sqrt, sqrtl);
+#endif
+
+/*
+Other methods  (use floating-point arithmetic)
+-------------
+(This is a copy of a drafted paper by Prof W. Kahan 
+and K.C. Ng, written in May, 1986)
+
+	Two algorithms are given here to implement sqrt(x) 
+	(IEEE double precision arithmetic) in software.
+	Both supply sqrt(x) correctly rounded. The first algorithm (in
+	Section A) uses newton iterations and involves four divisions.
+	The second one uses reciproot iterations to avoid division, but
+	requires more multiplications. Both algorithms need the ability
+	to chop results of arithmetic operations instead of round them, 
+	and the INEXACT flag to indicate when an arithmetic operation
+	is executed exactly with no roundoff error, all part of the 
+	standard (IEEE 754-1985). The ability to perform shift, add,
+	subtract and logical AND operations upon 32-bit words is needed
+	too, though not part of the standard.
+
+A.  sqrt(x) by Newton Iteration
+
+   (1)	Initial approximation
+
+	Let x0 and x1 be the leading and the trailing 32-bit words of
+	a floating point number x (in IEEE double format) respectively 
+
+	    1    11		     52				  ...widths
+	   ------------------------------------------------------
+	x: |s|	  e     |	      f				|
+	   ------------------------------------------------------
+	      msb    lsb  msb				      lsb ...order
+
+ 
+	     ------------------------  	     ------------------------
+	x0:  |s|   e    |    f1     |	 x1: |          f2           |
+	     ------------------------  	     ------------------------
+
+	By performing shifts and subtracts on x0 and x1 (both regarded
+	as integers), we obtain an 8-bit approximation of sqrt(x) as
+	follows.
+
+		k  := (x0>>1) + 0x1ff80000;
+		y0 := k - T1[31&(k>>15)].	... y ~ sqrt(x) to 8 bits
+	Here k is a 32-bit integer and T1[] is an integer array containing
+	correction terms. Now magically the floating value of y (y's
+	leading 32-bit word is y0, the value of its trailing word is 0)
+	approximates sqrt(x) to almost 8-bit.
+
+	Value of T1:
+	static int T1[32]= {
+	0,	1024,	3062,	5746,	9193,	13348,	18162,	23592,
+	29598,	36145,	43202,	50740,	58733,	67158,	75992,	85215,
+	83599,	71378,	60428,	50647,	41945,	34246,	27478,	21581,
+	16499,	12183,	8588,	5674,	3403,	1742,	661,	130,};
+
+    (2)	Iterative refinement
+
+	Apply Heron's rule three times to y, we have y approximates 
+	sqrt(x) to within 1 ulp (Unit in the Last Place):
+
+		y := (y+x/y)/2		... almost 17 sig. bits
+		y := (y+x/y)/2		... almost 35 sig. bits
+		y := y-(y-x/y)/2	... within 1 ulp
+
+
+	Remark 1.
+	    Another way to improve y to within 1 ulp is:
+
+		y := (y+x/y)		... almost 17 sig. bits to 2*sqrt(x)
+		y := y - 0x00100006	... almost 18 sig. bits to sqrt(x)
+
+				2
+			    (x-y )*y
+		y := y + 2* ----------	...within 1 ulp
+			       2
+			     3y  + x
+
+
+	This formula has one division fewer than the one above; however,
+	it requires more multiplications and additions. Also x must be
+	scaled in advance to avoid spurious overflow in evaluating the
+	expression 3y*y+x. Hence it is not recommended uless division
+	is slow. If division is very slow, then one should use the 
+	reciproot algorithm given in section B.
+
+    (3) Final adjustment
+
+	By twiddling y's last bit it is possible to force y to be 
+	correctly rounded according to the prevailing rounding mode
+	as follows. Let r and i be copies of the rounding mode and
+	inexact flag before entering the square root program. Also we
+	use the expression y+-ulp for the next representable floating
+	numbers (up and down) of y. Note that y+-ulp = either fixed
+	point y+-1, or multiply y by nextafter(1,+-inf) in chopped
+	mode.
+
+		I := FALSE;	... reset INEXACT flag I
+		R := RZ;	... set rounding mode to round-toward-zero
+		z := x/y;	... chopped quotient, possibly inexact
+		If(not I) then {	... if the quotient is exact
+		    if(z=y) {
+		        I := i;	 ... restore inexact flag
+		        R := r;  ... restore rounded mode
+		        return sqrt(x):=y.
+		    } else {
+			z := z - ulp;	... special rounding
+		    }
+		}
+		i := TRUE;		... sqrt(x) is inexact
+		If (r=RN) then z=z+ulp	... rounded-to-nearest
+		If (r=RP) then {	... round-toward-+inf
+		    y = y+ulp; z=z+ulp;
+		}
+		y := y+z;		... chopped sum
+		y0:=y0-0x00100000;	... y := y/2 is correctly rounded.
+	        I := i;	 		... restore inexact flag
+	        R := r;  		... restore rounded mode
+	        return sqrt(x):=y.
+		    
+    (4)	Special cases
+
+	Square root of +inf, +-0, or NaN is itself;
+	Square root of a negative number is NaN with invalid signal.
+
+
+B.  sqrt(x) by Reciproot Iteration
+
+   (1)	Initial approximation
+
+	Let x0 and x1 be the leading and the trailing 32-bit words of
+	a floating point number x (in IEEE double format) respectively
+	(see section A). By performing shifs and subtracts on x0 and y0,
+	we obtain a 7.8-bit approximation of 1/sqrt(x) as follows.
+
+	    k := 0x5fe80000 - (x0>>1);
+	    y0:= k - T2[63&(k>>14)].	... y ~ 1/sqrt(x) to 7.8 bits
+
+	Here k is a 32-bit integer and T2[] is an integer array 
+	containing correction terms. Now magically the floating
+	value of y (y's leading 32-bit word is y0, the value of
+	its trailing word y1 is set to zero) approximates 1/sqrt(x)
+	to almost 7.8-bit.
+
+	Value of T2:
+	static int T2[64]= {
+	0x1500,	0x2ef8,	0x4d67,	0x6b02,	0x87be,	0xa395,	0xbe7a,	0xd866,
+	0xf14a,	0x1091b,0x11fcd,0x13552,0x14999,0x15c98,0x16e34,0x17e5f,
+	0x18d03,0x19a01,0x1a545,0x1ae8a,0x1b5c4,0x1bb01,0x1bfde,0x1c28d,
+	0x1c2de,0x1c0db,0x1ba73,0x1b11c,0x1a4b5,0x1953d,0x18266,0x16be0,
+	0x1683e,0x179d8,0x18a4d,0x19992,0x1a789,0x1b445,0x1bf61,0x1c989,
+	0x1d16d,0x1d77b,0x1dddf,0x1e2ad,0x1e5bf,0x1e6e8,0x1e654,0x1e3cd,
+	0x1df2a,0x1d635,0x1cb16,0x1be2c,0x1ae4e,0x19bde,0x1868e,0x16e2e,
+	0x1527f,0x1334a,0x11051,0xe951,	0xbe01,	0x8e0d,	0x5924,	0x1edd,};
+
+    (2)	Iterative refinement
+
+	Apply Reciproot iteration three times to y and multiply the
+	result by x to get an approximation z that matches sqrt(x)
+	to about 1 ulp. To be exact, we will have 
+		-1ulp < sqrt(x)-z<1.0625ulp.
+	
+	... set rounding mode to Round-to-nearest
+	   y := y*(1.5-0.5*x*y*y)	... almost 15 sig. bits to 1/sqrt(x)
+	   y := y*((1.5-2^-30)+0.5*x*y*y)... about 29 sig. bits to 1/sqrt(x)
+	... special arrangement for better accuracy
+	   z := x*y			... 29 bits to sqrt(x), with z*y<1
+	   z := z + 0.5*z*(1-z*y)	... about 1 ulp to sqrt(x)
+
+	Remark 2. The constant 1.5-2^-30 is chosen to bias the error so that
+	(a) the term z*y in the final iteration is always less than 1; 
+	(b) the error in the final result is biased upward so that
+		-1 ulp < sqrt(x) - z < 1.0625 ulp
+	    instead of |sqrt(x)-z|<1.03125ulp.
+
+    (3)	Final adjustment
+
+	By twiddling y's last bit it is possible to force y to be 
+	correctly rounded according to the prevailing rounding mode
+	as follows. Let r and i be copies of the rounding mode and
+	inexact flag before entering the square root program. Also we
+	use the expression y+-ulp for the next representable floating
+	numbers (up and down) of y. Note that y+-ulp = either fixed
+	point y+-1, or multiply y by nextafter(1,+-inf) in chopped
+	mode.
+
+	R := RZ;		... set rounding mode to round-toward-zero
+	switch(r) {
+	    case RN:		... round-to-nearest
+	       if(x<= z*(z-ulp)...chopped) z = z - ulp; else
+	       if(x<= z*(z+ulp)...chopped) z = z; else z = z+ulp;
+	       break;
+	    case RZ:case RM:	... round-to-zero or round-to--inf
+	       R:=RP;		... reset rounding mod to round-to-+inf
+	       if(x<z*z ... rounded up) z = z - ulp; else
+	       if(x>=(z+ulp)*(z+ulp) ...rounded up) z = z+ulp;
+	       break;
+	    case RP:		... round-to-+inf
+	       if(x>(z+ulp)*(z+ulp)...chopped) z = z+2*ulp; else
+	       if(x>z*z ...chopped) z = z+ulp;
+	       break;
+	}
+
+	Remark 3. The above comparisons can be done in fixed point. For
+	example, to compare x and w=z*z chopped, it suffices to compare
+	x1 and w1 (the trailing parts of x and w), regarding them as
+	two's complement integers.
+
+	...Is z an exact square root?
+	To determine whether z is an exact square root of x, let z1 be the
+	trailing part of z, and also let x0 and x1 be the leading and
+	trailing parts of x.
+
+	If ((z1&0x03ffffff)!=0)	... not exact if trailing 26 bits of z!=0
+	    I := 1;		... Raise Inexact flag: z is not exact
+	else {
+	    j := 1 - [(x0>>20)&1]	... j = logb(x) mod 2
+	    k := z1 >> 26;		... get z's 25-th and 26-th 
+					    fraction bits
+	    I := i or (k&j) or ((k&(j+j+1))!=(x1&3));
+	}
+	R:= r		... restore rounded mode
+	return sqrt(x):=z.
+
+	If multiplication is cheaper then the foregoing red tape, the 
+	Inexact flag can be evaluated by
+
+	    I := i;
+	    I := (z*z!=x) or I.
+
+	Note that z*z can overwrite I; this value must be sensed if it is 
+	True.
+
+	Remark 4. If z*z = x exactly, then bit 25 to bit 0 of z1 must be
+	zero.
+
+		    --------------------
+		z1: |        f2        | 
+		    --------------------
+		bit 31		   bit 0
+
+	Further more, bit 27 and 26 of z1, bit 0 and 1 of x1, and the odd
+	or even of logb(x) have the following relations:
+
+	-------------------------------------------------
+	bit 27,26 of z1		bit 1,0 of x1	logb(x)
+	-------------------------------------------------
+	00			00		odd and even
+	01			01		even
+	10			10		odd
+	10			00		even
+	11			01		even
+	-------------------------------------------------
+
+    (4)	Special cases (see (4) of Section A).	
+ 
+ */
+ 
diff --git a/libm/upstream-freebsd/lib/msun/src/e_sqrtf.c b/libm/upstream-freebsd/lib/msun/src/e_sqrtf.c
new file mode 100644
index 0000000..7eba4d0
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_sqrtf.c
@@ -0,0 +1,89 @@
+/* e_sqrtf.c -- float version of e_sqrt.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#ifndef lint
+static char rcsid[] = "$FreeBSD$";
+#endif
+
+#include "math.h"
+#include "math_private.h"
+
+static	const float	one	= 1.0, tiny=1.0e-30;
+
+float
+__ieee754_sqrtf(float x)
+{
+	float z;
+	int32_t sign = (int)0x80000000;
+	int32_t ix,s,q,m,t,i;
+	u_int32_t r;
+
+	GET_FLOAT_WORD(ix,x);
+
+    /* take care of Inf and NaN */
+	if((ix&0x7f800000)==0x7f800000) {
+	    return x*x+x;		/* sqrt(NaN)=NaN, sqrt(+inf)=+inf
+					   sqrt(-inf)=sNaN */
+	}
+    /* take care of zero */
+	if(ix<=0) {
+	    if((ix&(~sign))==0) return x;/* sqrt(+-0) = +-0 */
+	    else if(ix<0)
+		return (x-x)/(x-x);		/* sqrt(-ve) = sNaN */
+	}
+    /* normalize x */
+	m = (ix>>23);
+	if(m==0) {				/* subnormal x */
+	    for(i=0;(ix&0x00800000)==0;i++) ix<<=1;
+	    m -= i-1;
+	}
+	m -= 127;	/* unbias exponent */
+	ix = (ix&0x007fffff)|0x00800000;
+	if(m&1)	/* odd m, double x to make it even */
+	    ix += ix;
+	m >>= 1;	/* m = [m/2] */
+
+    /* generate sqrt(x) bit by bit */
+	ix += ix;
+	q = s = 0;		/* q = sqrt(x) */
+	r = 0x01000000;		/* r = moving bit from right to left */
+
+	while(r!=0) {
+	    t = s+r;
+	    if(t<=ix) {
+		s    = t+r;
+		ix  -= t;
+		q   += r;
+	    }
+	    ix += ix;
+	    r>>=1;
+	}
+
+    /* use floating add to find out rounding direction */
+	if(ix!=0) {
+	    z = one-tiny; /* trigger inexact flag */
+	    if (z>=one) {
+	        z = one+tiny;
+		if (z>one)
+		    q += 2;
+		else
+		    q += (q&1);
+	    }
+	}
+	ix = (q>>1)+0x3f000000;
+	ix += (m <<23);
+	SET_FLOAT_WORD(z,ix);
+	return z;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_sqrtl.c b/libm/upstream-freebsd/lib/msun/src/e_sqrtl.c
new file mode 100644
index 0000000..92b84de
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/e_sqrtl.c
@@ -0,0 +1,159 @@
+/*-
+ * Copyright (c) 2007 Steven G. Kargl
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <fenv.h>
+#include <float.h>
+
+#include "fpmath.h"
+#include "math.h"
+
+/* Return (x + ulp) for normal positive x. Assumes no overflow. */
+static inline long double
+inc(long double x)
+{
+	union IEEEl2bits u;
+
+	u.e = x;
+	if (++u.bits.manl == 0) {
+		if (++u.bits.manh == 0) {
+			u.bits.exp++;
+			u.bits.manh |= LDBL_NBIT;
+		}
+	}
+	return (u.e);
+}
+
+/* Return (x - ulp) for normal positive x. Assumes no underflow. */
+static inline long double
+dec(long double x)
+{
+	union IEEEl2bits u;
+
+	u.e = x;
+	if (u.bits.manl-- == 0) {
+		if (u.bits.manh-- == LDBL_NBIT) {
+			u.bits.exp--;
+			u.bits.manh |= LDBL_NBIT;
+		}
+	}
+	return (u.e);
+}
+
+#pragma STDC FENV_ACCESS ON
+
+/*
+ * This is slow, but simple and portable. You should use hardware sqrt
+ * if possible.
+ */
+
+long double
+sqrtl(long double x)
+{
+	union IEEEl2bits u;
+	int k, r;
+	long double lo, xn;
+	fenv_t env;
+
+	u.e = x;
+
+	/* If x = NaN, then sqrt(x) = NaN. */
+	/* If x = Inf, then sqrt(x) = Inf. */
+	/* If x = -Inf, then sqrt(x) = NaN. */
+	if (u.bits.exp == LDBL_MAX_EXP * 2 - 1)
+		return (x * x + x);
+
+	/* If x = +-0, then sqrt(x) = +-0. */
+	if ((u.bits.manh | u.bits.manl | u.bits.exp) == 0)
+		return (x);
+
+	/* If x < 0, then raise invalid and return NaN */
+	if (u.bits.sign)
+		return ((x - x) / (x - x));
+
+	feholdexcept(&env);
+
+	if (u.bits.exp == 0) {
+		/* Adjust subnormal numbers. */
+		u.e *= 0x1.0p514;
+		k = -514;
+	} else {
+		k = 0;
+	}
+	/*
+	 * u.e is a normal number, so break it into u.e = e*2^n where
+	 * u.e = (2*e)*2^2k for odd n and u.e = (4*e)*2^2k for even n.
+	 */
+	if ((u.bits.exp - 0x3ffe) & 1) {	/* n is odd.     */
+		k += u.bits.exp - 0x3fff;	/* 2k = n - 1.   */
+		u.bits.exp = 0x3fff;		/* u.e in [1,2). */
+	} else {
+		k += u.bits.exp - 0x4000;	/* 2k = n - 2.   */
+		u.bits.exp = 0x4000;		/* u.e in [2,4). */
+	}
+
+	/*
+	 * Newton's iteration.
+	 * Split u.e into a high and low part to achieve additional precision.
+	 */
+	xn = sqrt(u.e);			/* 53-bit estimate of sqrtl(x). */
+#if LDBL_MANT_DIG > 100
+	xn = (xn + (u.e / xn)) * 0.5;	/* 106-bit estimate. */
+#endif
+	lo = u.e;
+	u.bits.manl = 0;		/* Zero out lower bits. */
+	lo = (lo - u.e) / xn;		/* Low bits divided by xn. */
+	xn = xn + (u.e / xn);		/* High portion of estimate. */
+	u.e = xn + lo;			/* Combine everything. */
+	u.bits.exp += (k >> 1) - 1;
+
+	feclearexcept(FE_INEXACT);
+	r = fegetround();
+	fesetround(FE_TOWARDZERO);	/* Set to round-toward-zero. */
+	xn = x / u.e;			/* Chopped quotient (inexact?). */
+
+	if (!fetestexcept(FE_INEXACT)) { /* Quotient is exact. */
+		if (xn == u.e) {
+			fesetenv(&env);
+			return (u.e);
+		}
+		/* Round correctly for inputs like x = y**2 - ulp. */
+		xn = dec(xn);		/* xn = xn - ulp. */
+	}
+
+	if (r == FE_TONEAREST) {
+		xn = inc(xn);		/* xn = xn + ulp. */
+	} else if (r == FE_UPWARD) {
+		u.e = inc(u.e);		/* u.e = u.e + ulp. */
+		xn = inc(xn);		/* xn  = xn + ulp. */
+	}
+	u.e = u.e + xn;				/* Chopped sum. */
+	feupdateenv(&env);	/* Restore env and raise inexact */
+	u.bits.exp--;
+	return (u.e);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/fenv-softfloat.h b/libm/upstream-freebsd/lib/msun/src/fenv-softfloat.h
new file mode 100644
index 0000000..02d2a2c
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/fenv-softfloat.h
@@ -0,0 +1,184 @@
+/*-
+ * Copyright (c) 2004-2011 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef	_FENV_H_
+#error "This file is meant to be included only by <fenv.h>."
+#endif
+
+/*
+ * This file implements the functionality of <fenv.h> on platforms that
+ * lack an FPU and use softfloat in libc for floating point.  To use it,
+ * you must write an <fenv.h> that provides the following:
+ *
+ *   - a typedef for fenv_t, which may be an integer or struct type
+ *   - a typedef for fexcept_t (XXX This file assumes fexcept_t is a
+ *     simple integer type containing the exception mask.)
+ *   - definitions of FE_* constants for the five exceptions and four
+ *     rounding modes in IEEE 754, as described in fenv(3)
+ *   - a definition, and the corresponding external symbol, for FE_DFL_ENV
+ *   - a macro __set_env(env, flags, mask, rnd), which sets the given fenv_t
+ *     from the exception flags, mask, and rounding mode
+ *   - macros __env_flags(env), __env_mask(env), and __env_round(env), which
+ *     extract fields from an fenv_t
+ *   - a definition of __fenv_static
+ *
+ * If the architecture supports an optional FPU, it's recommended that you
+ * define fenv_t and fexcept_t to match the hardware ABI.  Otherwise, it
+ * doesn't matter how you define them.
+ */
+
+extern int __softfloat_float_exception_flags;
+extern int __softfloat_float_exception_mask;
+extern int __softfloat_float_rounding_mode;
+void __softfloat_float_raise(int);
+
+__fenv_static inline int
+feclearexcept(int __excepts)
+{
+
+	__softfloat_float_exception_flags &= ~__excepts;
+	return (0);
+}
+
+__fenv_static inline int
+fegetexceptflag(fexcept_t *__flagp, int __excepts)
+{
+
+	*__flagp = __softfloat_float_exception_flags & __excepts;
+	return (0);
+}
+
+__fenv_static inline int
+fesetexceptflag(const fexcept_t *__flagp, int __excepts)
+{
+
+	__softfloat_float_exception_flags &= ~__excepts;
+	__softfloat_float_exception_flags |= *__flagp & __excepts;
+	return (0);
+}
+
+__fenv_static inline int
+feraiseexcept(int __excepts)
+{
+
+	__softfloat_float_raise(__excepts);
+	return (0);
+}
+
+__fenv_static inline int
+fetestexcept(int __excepts)
+{
+
+	return (__softfloat_float_exception_flags & __excepts);
+}
+
+__fenv_static inline int
+fegetround(void)
+{
+
+	return (__softfloat_float_rounding_mode);
+}
+
+__fenv_static inline int
+fesetround(int __round)
+{
+
+	__softfloat_float_rounding_mode = __round;
+	return (0);
+}
+
+__fenv_static inline int
+fegetenv(fenv_t *__envp)
+{
+
+	__set_env(*__envp, __softfloat_float_exception_flags,
+	    __softfloat_float_exception_mask, __softfloat_float_rounding_mode);
+	return (0);
+}
+
+__fenv_static inline int
+feholdexcept(fenv_t *__envp)
+{
+	fenv_t __env;
+
+	fegetenv(__envp);
+	__softfloat_float_exception_flags = 0;
+	__softfloat_float_exception_mask = 0;
+	return (0);
+}
+
+__fenv_static inline int
+fesetenv(const fenv_t *__envp)
+{
+
+	__softfloat_float_exception_flags = __env_flags(*__envp);
+	__softfloat_float_exception_mask = __env_mask(*__envp);
+	__softfloat_float_rounding_mode = __env_round(*__envp);
+	return (0);
+}
+
+__fenv_static inline int
+feupdateenv(const fenv_t *__envp)
+{
+	int __oflags = __softfloat_float_exception_flags;
+
+	fesetenv(__envp);
+	feraiseexcept(__oflags);
+	return (0);
+}
+
+#if __BSD_VISIBLE
+
+/* We currently provide no external definitions of the functions below. */
+
+static inline int
+feenableexcept(int __mask)
+{
+	int __omask = __softfloat_float_exception_mask;
+
+	__softfloat_float_exception_mask |= __mask;
+	return (__omask);
+}
+
+static inline int
+fedisableexcept(int __mask)
+{
+	int __omask = __softfloat_float_exception_mask;
+
+	__softfloat_float_exception_mask &= ~__mask;
+	return (__omask);
+}
+
+static inline int
+fegetexcept(void)
+{
+
+	return (__softfloat_float_exception_mask);
+}
+
+#endif /* __BSD_VISIBLE */
diff --git a/libm/upstream-freebsd/lib/msun/src/k_cos.c b/libm/upstream-freebsd/lib/msun/src/k_cos.c
new file mode 100644
index 0000000..c4702e6
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/k_cos.c
@@ -0,0 +1,79 @@
+
+/* @(#)k_cos.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * __kernel_cos( x,  y )
+ * kernel cos function on [-pi/4, pi/4], pi/4 ~ 0.785398164
+ * Input x is assumed to be bounded by ~pi/4 in magnitude.
+ * Input y is the tail of x. 
+ *
+ * Algorithm
+ *	1. Since cos(-x) = cos(x), we need only to consider positive x.
+ *	2. if x < 2^-27 (hx<0x3e400000 0), return 1 with inexact if x!=0.
+ *	3. cos(x) is approximated by a polynomial of degree 14 on
+ *	   [0,pi/4]
+ *		  	                 4            14
+ *	   	cos(x) ~ 1 - x*x/2 + C1*x + ... + C6*x
+ *	   where the remez error is
+ *	
+ * 	|              2     4     6     8     10    12     14 |     -58
+ * 	|cos(x)-(1-.5*x +C1*x +C2*x +C3*x +C4*x +C5*x  +C6*x  )| <= 2
+ * 	|    					               | 
+ * 
+ * 	               4     6     8     10    12     14 
+ *	4. let r = C1*x +C2*x +C3*x +C4*x +C5*x  +C6*x  , then
+ *	       cos(x) ~ 1 - x*x/2 + r
+ *	   since cos(x+y) ~ cos(x) - sin(x)*y 
+ *			  ~ cos(x) - x*y,
+ *	   a correction term is necessary in cos(x) and hence
+ *		cos(x+y) = 1 - (x*x/2 - (r - x*y))
+ *	   For better accuracy, rearrange to
+ *		cos(x+y) ~ w + (tmp + (r-x*y))
+ *	   where w = 1 - x*x/2 and tmp is a tiny correction term
+ *	   (1 - x*x/2 == w + tmp exactly in infinite precision).
+ *	   The exactness of w + tmp in infinite precision depends on w
+ *	   and tmp having the same precision as x.  If they have extra
+ *	   precision due to compiler bugs, then the extra precision is
+ *	   only good provided it is retained in all terms of the final
+ *	   expression for cos().  Retention happens in all cases tested
+ *	   under FreeBSD, so don't pessimize things by forcibly clipping
+ *	   any extra precision in w.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+static const double
+one =  1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
+C1  =  4.16666666666666019037e-02, /* 0x3FA55555, 0x5555554C */
+C2  = -1.38888888888741095749e-03, /* 0xBF56C16C, 0x16C15177 */
+C3  =  2.48015872894767294178e-05, /* 0x3EFA01A0, 0x19CB1590 */
+C4  = -2.75573143513906633035e-07, /* 0xBE927E4F, 0x809C52AD */
+C5  =  2.08757232129817482790e-09, /* 0x3E21EE9E, 0xBDB4B1C4 */
+C6  = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */
+
+double
+__kernel_cos(double x, double y)
+{
+	double hz,z,r,w;
+
+	z  = x*x;
+	w  = z*z;
+	r  = z*(C1+z*(C2+z*C3)) + w*w*(C4+z*(C5+z*C6));
+	hz = 0.5*z;
+	w  = one-hz;
+	return w + (((one-w)-hz) + (z*r-x*y));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/k_cosf.c b/libm/upstream-freebsd/lib/msun/src/k_cosf.c
new file mode 100644
index 0000000..f7a2c0a
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/k_cosf.c
@@ -0,0 +1,46 @@
+/* k_cosf.c -- float version of k_cos.c
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ * Debugged and optimized by Bruce D. Evans.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#ifndef INLINE_KERNEL_COSDF
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+#endif
+
+#include "math.h"
+#include "math_private.h"
+
+/* |cos(x) - c(x)| < 2**-34.1 (~[-5.37e-11, 5.295e-11]). */
+static const double
+one =  1.0,
+C0  = -0x1ffffffd0c5e81.0p-54,	/* -0.499999997251031003120 */
+C1  =  0x155553e1053a42.0p-57,	/*  0.0416666233237390631894 */
+C2  = -0x16c087e80f1e27.0p-62,	/* -0.00138867637746099294692 */
+C3  =  0x199342e0ee5069.0p-68;	/*  0.0000243904487962774090654 */
+
+#ifdef INLINE_KERNEL_COSDF
+static __inline
+#endif
+float
+__kernel_cosdf(double x)
+{
+	double r, w, z;
+
+	/* Try to optimize for parallel evaluation as in k_tanf.c. */
+	z = x*x;
+	w = z*z;
+	r = C2+z*C3;
+	return ((one+z*C0) + w*C1) + (w*z)*r;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/k_exp.c b/libm/upstream-freebsd/lib/msun/src/k_exp.c
new file mode 100644
index 0000000..f592f69
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/k_exp.c
@@ -0,0 +1,108 @@
+/*-
+ * Copyright (c) 2011 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const uint32_t k = 1799;		/* constant for reduction */
+static const double kln2 =  1246.97177782734161156;	/* k * ln2 */
+
+/*
+ * Compute exp(x), scaled to avoid spurious overflow.  An exponent is
+ * returned separately in 'expt'.
+ *
+ * Input:  ln(DBL_MAX) <= x < ln(2 * DBL_MAX / DBL_MIN_DENORM) ~= 1454.91
+ * Output: 2**1023 <= y < 2**1024
+ */
+static double
+__frexp_exp(double x, int *expt)
+{
+	double exp_x;
+	uint32_t hx;
+
+	/*
+	 * We use exp(x) = exp(x - kln2) * 2**k, carefully chosen to
+	 * minimize |exp(kln2) - 2**k|.  We also scale the exponent of
+	 * exp_x to MAX_EXP so that the result can be multiplied by
+	 * a tiny number without losing accuracy due to denormalization.
+	 */
+	exp_x = exp(x - kln2);
+	GET_HIGH_WORD(hx, exp_x);
+	*expt = (hx >> 20) - (0x3ff + 1023) + k;
+	SET_HIGH_WORD(exp_x, (hx & 0xfffff) | ((0x3ff + 1023) << 20));
+	return (exp_x);
+}
+
+/*
+ * __ldexp_exp(x, expt) and __ldexp_cexp(x, expt) compute exp(x) * 2**expt.
+ * They are intended for large arguments (real part >= ln(DBL_MAX))
+ * where care is needed to avoid overflow.
+ *
+ * The present implementation is narrowly tailored for our hyperbolic and
+ * exponential functions.  We assume expt is small (0 or -1), and the caller
+ * has filtered out very large x, for which overflow would be inevitable.
+ */
+
+double
+__ldexp_exp(double x, int expt)
+{
+	double exp_x, scale;
+	int ex_expt;
+
+	exp_x = __frexp_exp(x, &ex_expt);
+	expt += ex_expt;
+	INSERT_WORDS(scale, (0x3ff + expt) << 20, 0);
+	return (exp_x * scale);
+}
+
+double complex
+__ldexp_cexp(double complex z, int expt)
+{
+	double x, y, exp_x, scale1, scale2;
+	int ex_expt, half_expt;
+
+	x = creal(z);
+	y = cimag(z);
+	exp_x = __frexp_exp(x, &ex_expt);
+	expt += ex_expt;
+
+	/*
+	 * Arrange so that scale1 * scale2 == 2**expt.  We use this to
+	 * compensate for scalbn being horrendously slow.
+	 */
+	half_expt = expt / 2;
+	INSERT_WORDS(scale1, (0x3ff + half_expt) << 20, 0);
+	half_expt = expt - half_expt;
+	INSERT_WORDS(scale2, (0x3ff + half_expt) << 20, 0);
+
+	return (cpack(cos(y) * exp_x * scale1 * scale2,
+	    sin(y) * exp_x * scale1 * scale2));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/k_expf.c b/libm/upstream-freebsd/lib/msun/src/k_expf.c
new file mode 100644
index 0000000..548a008
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/k_expf.c
@@ -0,0 +1,87 @@
+/*-
+ * Copyright (c) 2011 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const uint32_t k = 235;			/* constant for reduction */
+static const float kln2 =  162.88958740F;	/* k * ln2 */
+
+/*
+ * See k_exp.c for details.
+ *
+ * Input:  ln(FLT_MAX) <= x < ln(2 * FLT_MAX / FLT_MIN_DENORM) ~= 192.7
+ * Output: 2**127 <= y < 2**128
+ */
+static float
+__frexp_expf(float x, int *expt)
+{
+	float exp_x;
+	uint32_t hx;
+
+	exp_x = expf(x - kln2);
+	GET_FLOAT_WORD(hx, exp_x);
+	*expt = (hx >> 23) - (0x7f + 127) + k;
+	SET_FLOAT_WORD(exp_x, (hx & 0x7fffff) | ((0x7f + 127) << 23));
+	return (exp_x);
+}
+
+float
+__ldexp_expf(float x, int expt)
+{
+	float exp_x, scale;
+	int ex_expt;
+
+	exp_x = __frexp_expf(x, &ex_expt);
+	expt += ex_expt;
+	SET_FLOAT_WORD(scale, (0x7f + expt) << 23);
+	return (exp_x * scale);
+}
+
+float complex
+__ldexp_cexpf(float complex z, int expt)
+{
+	float x, y, exp_x, scale1, scale2;
+	int ex_expt, half_expt;
+
+	x = crealf(z);
+	y = cimagf(z);
+	exp_x = __frexp_expf(x, &ex_expt);
+	expt += ex_expt;
+
+	half_expt = expt / 2;
+	SET_FLOAT_WORD(scale1, (0x7f + half_expt) << 23);
+	half_expt = expt - half_expt;
+	SET_FLOAT_WORD(scale2, (0x7f + half_expt) << 23);
+
+	return (cpackf(cosf(y) * exp_x * scale1 * scale2,
+	    sinf(y) * exp_x * scale1 * scale2));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/k_log.h b/libm/upstream-freebsd/lib/msun/src/k_log.h
new file mode 100644
index 0000000..aaff8bd
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/k_log.h
@@ -0,0 +1,100 @@
+
+/* @(#)e_log.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * k_log1p(f):
+ * Return log(1+f) - f for 1+f in ~[sqrt(2)/2, sqrt(2)].
+ *
+ * The following describes the overall strategy for computing
+ * logarithms in base e.  The argument reduction and adding the final
+ * term of the polynomial are done by the caller for increased accuracy
+ * when different bases are used.
+ *
+ * Method :                  
+ *   1. Argument Reduction: find k and f such that 
+ *			x = 2^k * (1+f), 
+ *	   where  sqrt(2)/2 < 1+f < sqrt(2) .
+ *
+ *   2. Approximation of log(1+f).
+ *	Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
+ *		 = 2s + 2/3 s**3 + 2/5 s**5 + .....,
+ *	     	 = 2s + s*R
+ *      We use a special Reme algorithm on [0,0.1716] to generate 
+ * 	a polynomial of degree 14 to approximate R The maximum error 
+ *	of this polynomial approximation is bounded by 2**-58.45. In
+ *	other words,
+ *		        2      4      6      8      10      12      14
+ *	    R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s  +Lg6*s  +Lg7*s
+ *  	(the values of Lg1 to Lg7 are listed in the program)
+ *	and
+ *	    |      2          14          |     -58.45
+ *	    | Lg1*s +...+Lg7*s    -  R(z) | <= 2 
+ *	    |                             |
+ *	Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
+ *	In order to guarantee error in log below 1ulp, we compute log
+ *	by
+ *		log(1+f) = f - s*(f - R)	(if f is not too large)
+ *		log(1+f) = f - (hfsq - s*(hfsq+R)).	(better accuracy)
+ *	
+ *	3. Finally,  log(x) = k*ln2 + log(1+f).  
+ *			    = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo)))
+ *	   Here ln2 is split into two floating point number: 
+ *			ln2_hi + ln2_lo,
+ *	   where n*ln2_hi is always exact for |n| < 2000.
+ *
+ * Special cases:
+ *	log(x) is NaN with signal if x < 0 (including -INF) ; 
+ *	log(+INF) is +INF; log(0) is -INF with signal;
+ *	log(NaN) is that NaN with no signal.
+ *
+ * Accuracy:
+ *	according to an error analysis, the error is always less than
+ *	1 ulp (unit in the last place).
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following 
+ * constants. The decimal values may be used, provided that the 
+ * compiler will convert from decimal to binary accurately enough 
+ * to produce the hexadecimal values shown.
+ */
+
+static const double
+Lg1 = 6.666666666666735130e-01,  /* 3FE55555 55555593 */
+Lg2 = 3.999999999940941908e-01,  /* 3FD99999 9997FA04 */
+Lg3 = 2.857142874366239149e-01,  /* 3FD24924 94229359 */
+Lg4 = 2.222219843214978396e-01,  /* 3FCC71C5 1D8E78AF */
+Lg5 = 1.818357216161805012e-01,  /* 3FC74664 96CB03DE */
+Lg6 = 1.531383769920937332e-01,  /* 3FC39A09 D078C69F */
+Lg7 = 1.479819860511658591e-01;  /* 3FC2F112 DF3E5244 */
+
+/*
+ * We always inline k_log1p(), since doing so produces a
+ * substantial performance improvement (~40% on amd64).
+ */
+static inline double
+k_log1p(double f)
+{
+	double hfsq,s,z,R,w,t1,t2;
+
+ 	s = f/(2.0+f);
+	z = s*s;
+	w = z*z;
+	t1= w*(Lg2+w*(Lg4+w*Lg6));
+	t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
+	R = t2+t1;
+	hfsq=0.5*f*f;
+	return s*(hfsq+R);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/k_logf.h b/libm/upstream-freebsd/lib/msun/src/k_logf.h
new file mode 100644
index 0000000..71c547e
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/k_logf.h
@@ -0,0 +1,39 @@
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * Float version of k_log.h.  See the latter for most comments.
+ */
+
+static const float
+/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */
+Lg1 =      0xaaaaaa.0p-24,	/* 0.66666662693 */
+Lg2 =      0xccce13.0p-25,	/* 0.40000972152 */
+Lg3 =      0x91e9ee.0p-25,	/* 0.28498786688 */
+Lg4 =      0xf89e26.0p-26;	/* 0.24279078841 */
+
+static inline float
+k_log1pf(float f)
+{
+	float hfsq,s,z,R,w,t1,t2;
+
+ 	s = f/((float)2.0+f);
+	z = s*s;
+	w = z*z;
+	t1= w*(Lg2+w*Lg4);
+	t2= z*(Lg1+w*Lg3);
+	R = t2+t1;
+	hfsq=(float)0.5*f*f;
+	return s*(hfsq+R);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/k_rem_pio2.c b/libm/upstream-freebsd/lib/msun/src/k_rem_pio2.c
new file mode 100644
index 0000000..3942441
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/k_rem_pio2.c
@@ -0,0 +1,443 @@
+
+/* @(#)k_rem_pio2.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * __kernel_rem_pio2(x,y,e0,nx,prec)
+ * double x[],y[]; int e0,nx,prec;
+ * 
+ * __kernel_rem_pio2 return the last three digits of N with 
+ *		y = x - N*pi/2
+ * so that |y| < pi/2.
+ *
+ * The method is to compute the integer (mod 8) and fraction parts of 
+ * (2/pi)*x without doing the full multiplication. In general we
+ * skip the part of the product that are known to be a huge integer (
+ * more accurately, = 0 mod 8 ). Thus the number of operations are
+ * independent of the exponent of the input.
+ *
+ * (2/pi) is represented by an array of 24-bit integers in ipio2[].
+ *
+ * Input parameters:
+ * 	x[]	The input value (must be positive) is broken into nx 
+ *		pieces of 24-bit integers in double precision format.
+ *		x[i] will be the i-th 24 bit of x. The scaled exponent 
+ *		of x[0] is given in input parameter e0 (i.e., x[0]*2^e0 
+ *		match x's up to 24 bits.
+ *
+ *		Example of breaking a double positive z into x[0]+x[1]+x[2]:
+ *			e0 = ilogb(z)-23
+ *			z  = scalbn(z,-e0)
+ *		for i = 0,1,2
+ *			x[i] = floor(z)
+ *			z    = (z-x[i])*2**24
+ *
+ *
+ *	y[]	output result in an array of double precision numbers.
+ *		The dimension of y[] is:
+ *			24-bit  precision	1
+ *			53-bit  precision	2
+ *			64-bit  precision	2
+ *			113-bit precision	3
+ *		The actual value is the sum of them. Thus for 113-bit
+ *		precison, one may have to do something like:
+ *
+ *		long double t,w,r_head, r_tail;
+ *		t = (long double)y[2] + (long double)y[1];
+ *		w = (long double)y[0];
+ *		r_head = t+w;
+ *		r_tail = w - (r_head - t);
+ *
+ *	e0	The exponent of x[0]. Must be <= 16360 or you need to
+ *              expand the ipio2 table.
+ *
+ *	nx	dimension of x[]
+ *
+ *  	prec	an integer indicating the precision:
+ *			0	24  bits (single)
+ *			1	53  bits (double)
+ *			2	64  bits (extended)
+ *			3	113 bits (quad)
+ *
+ * External function:
+ *	double scalbn(), floor();
+ *
+ *
+ * Here is the description of some local variables:
+ *
+ * 	jk	jk+1 is the initial number of terms of ipio2[] needed
+ *		in the computation. The minimum and recommended value
+ *		for jk is 3,4,4,6 for single, double, extended, and quad.
+ *		jk+1 must be 2 larger than you might expect so that our
+ *		recomputation test works. (Up to 24 bits in the integer
+ *		part (the 24 bits of it that we compute) and 23 bits in
+ *		the fraction part may be lost to cancelation before we
+ *		recompute.)
+ *
+ * 	jz	local integer variable indicating the number of 
+ *		terms of ipio2[] used. 
+ *
+ *	jx	nx - 1
+ *
+ *	jv	index for pointing to the suitable ipio2[] for the
+ *		computation. In general, we want
+ *			( 2^e0*x[0] * ipio2[jv-1]*2^(-24jv) )/8
+ *		is an integer. Thus
+ *			e0-3-24*jv >= 0 or (e0-3)/24 >= jv
+ *		Hence jv = max(0,(e0-3)/24).
+ *
+ *	jp	jp+1 is the number of terms in PIo2[] needed, jp = jk.
+ *
+ * 	q[]	double array with integral value, representing the
+ *		24-bits chunk of the product of x and 2/pi.
+ *
+ *	q0	the corresponding exponent of q[0]. Note that the
+ *		exponent for q[i] would be q0-24*i.
+ *
+ *	PIo2[]	double precision array, obtained by cutting pi/2
+ *		into 24 bits chunks. 
+ *
+ *	f[]	ipio2[] in floating point 
+ *
+ *	iq[]	integer array by breaking up q[] in 24-bits chunk.
+ *
+ *	fq[]	final product of x*(2/pi) in fq[0],..,fq[jk]
+ *
+ *	ih	integer. If >0 it indicates q[] is >= 0.5, hence
+ *		it also indicates the *sign* of the result.
+ *
+ */
+
+
+/*
+ * Constants:
+ * The hexadecimal values are the intended ones for the following 
+ * constants. The decimal values may be used, provided that the 
+ * compiler will convert from decimal to binary accurately enough 
+ * to produce the hexadecimal values shown.
+ */
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const int init_jk[] = {3,4,4,6}; /* initial value for jk */
+
+/*
+ * Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi
+ *
+ *		integer array, contains the (24*i)-th to (24*i+23)-th 
+ *		bit of 2/pi after binary point. The corresponding 
+ *		floating value is
+ *
+ *			ipio2[i] * 2^(-24(i+1)).
+ *
+ * NB: This table must have at least (e0-3)/24 + jk terms.
+ *     For quad precision (e0 <= 16360, jk = 6), this is 686.
+ */
+static const int32_t ipio2[] = {
+0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, 
+0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, 
+0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, 
+0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41, 
+0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8, 
+0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF, 
+0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5, 
+0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08, 
+0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3, 
+0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880, 
+0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B, 
+
+#if LDBL_MAX_EXP > 1024
+#if LDBL_MAX_EXP > 16384
+#error "ipio2 table needs to be expanded"
+#endif
+0x47C419, 0xC367CD, 0xDCE809, 0x2A8359, 0xC4768B, 0x961CA6,
+0xDDAF44, 0xD15719, 0x053EA5, 0xFF0705, 0x3F7E33, 0xE832C2,
+0xDE4F98, 0x327DBB, 0xC33D26, 0xEF6B1E, 0x5EF89F, 0x3A1F35,
+0xCAF27F, 0x1D87F1, 0x21907C, 0x7C246A, 0xFA6ED5, 0x772D30,
+0x433B15, 0xC614B5, 0x9D19C3, 0xC2C4AD, 0x414D2C, 0x5D000C,
+0x467D86, 0x2D71E3, 0x9AC69B, 0x006233, 0x7CD2B4, 0x97A7B4,
+0xD55537, 0xF63ED7, 0x1810A3, 0xFC764D, 0x2A9D64, 0xABD770,
+0xF87C63, 0x57B07A, 0xE71517, 0x5649C0, 0xD9D63B, 0x3884A7,
+0xCB2324, 0x778AD6, 0x23545A, 0xB91F00, 0x1B0AF1, 0xDFCE19,
+0xFF319F, 0x6A1E66, 0x615799, 0x47FBAC, 0xD87F7E, 0xB76522,
+0x89E832, 0x60BFE6, 0xCDC4EF, 0x09366C, 0xD43F5D, 0xD7DE16,
+0xDE3B58, 0x929BDE, 0x2822D2, 0xE88628, 0x4D58E2, 0x32CAC6,
+0x16E308, 0xCB7DE0, 0x50C017, 0xA71DF3, 0x5BE018, 0x34132E,
+0x621283, 0x014883, 0x5B8EF5, 0x7FB0AD, 0xF2E91E, 0x434A48,
+0xD36710, 0xD8DDAA, 0x425FAE, 0xCE616A, 0xA4280A, 0xB499D3,
+0xF2A606, 0x7F775C, 0x83C2A3, 0x883C61, 0x78738A, 0x5A8CAF,
+0xBDD76F, 0x63A62D, 0xCBBFF4, 0xEF818D, 0x67C126, 0x45CA55,
+0x36D9CA, 0xD2A828, 0x8D61C2, 0x77C912, 0x142604, 0x9B4612,
+0xC459C4, 0x44C5C8, 0x91B24D, 0xF31700, 0xAD43D4, 0xE54929,
+0x10D5FD, 0xFCBE00, 0xCC941E, 0xEECE70, 0xF53E13, 0x80F1EC,
+0xC3E7B3, 0x28F8C7, 0x940593, 0x3E71C1, 0xB3092E, 0xF3450B,
+0x9C1288, 0x7B20AB, 0x9FB52E, 0xC29247, 0x2F327B, 0x6D550C,
+0x90A772, 0x1FE76B, 0x96CB31, 0x4A1679, 0xE27941, 0x89DFF4,
+0x9794E8, 0x84E6E2, 0x973199, 0x6BED88, 0x365F5F, 0x0EFDBB,
+0xB49A48, 0x6CA467, 0x427271, 0x325D8D, 0xB8159F, 0x09E5BC,
+0x25318D, 0x3974F7, 0x1C0530, 0x010C0D, 0x68084B, 0x58EE2C,
+0x90AA47, 0x02E774, 0x24D6BD, 0xA67DF7, 0x72486E, 0xEF169F,
+0xA6948E, 0xF691B4, 0x5153D1, 0xF20ACF, 0x339820, 0x7E4BF5,
+0x6863B2, 0x5F3EDD, 0x035D40, 0x7F8985, 0x295255, 0xC06437,
+0x10D86D, 0x324832, 0x754C5B, 0xD4714E, 0x6E5445, 0xC1090B,
+0x69F52A, 0xD56614, 0x9D0727, 0x50045D, 0xDB3BB4, 0xC576EA,
+0x17F987, 0x7D6B49, 0xBA271D, 0x296996, 0xACCCC6, 0x5414AD,
+0x6AE290, 0x89D988, 0x50722C, 0xBEA404, 0x940777, 0x7030F3,
+0x27FC00, 0xA871EA, 0x49C266, 0x3DE064, 0x83DD97, 0x973FA3,
+0xFD9443, 0x8C860D, 0xDE4131, 0x9D3992, 0x8C70DD, 0xE7B717,
+0x3BDF08, 0x2B3715, 0xA0805C, 0x93805A, 0x921110, 0xD8E80F,
+0xAF806C, 0x4BFFDB, 0x0F9038, 0x761859, 0x15A562, 0xBBCB61,
+0xB989C7, 0xBD4010, 0x04F2D2, 0x277549, 0xF6B6EB, 0xBB22DB,
+0xAA140A, 0x2F2689, 0x768364, 0x333B09, 0x1A940E, 0xAA3A51,
+0xC2A31D, 0xAEEDAF, 0x12265C, 0x4DC26D, 0x9C7A2D, 0x9756C0,
+0x833F03, 0xF6F009, 0x8C402B, 0x99316D, 0x07B439, 0x15200C,
+0x5BC3D8, 0xC492F5, 0x4BADC6, 0xA5CA4E, 0xCD37A7, 0x36A9E6,
+0x9492AB, 0x6842DD, 0xDE6319, 0xEF8C76, 0x528B68, 0x37DBFC,
+0xABA1AE, 0x3115DF, 0xA1AE00, 0xDAFB0C, 0x664D64, 0xB705ED,
+0x306529, 0xBF5657, 0x3AFF47, 0xB9F96A, 0xF3BE75, 0xDF9328,
+0x3080AB, 0xF68C66, 0x15CB04, 0x0622FA, 0x1DE4D9, 0xA4B33D,
+0x8F1B57, 0x09CD36, 0xE9424E, 0xA4BE13, 0xB52333, 0x1AAAF0,
+0xA8654F, 0xA5C1D2, 0x0F3F0B, 0xCD785B, 0x76F923, 0x048B7B,
+0x721789, 0x53A6C6, 0xE26E6F, 0x00EBEF, 0x584A9B, 0xB7DAC4,
+0xBA66AA, 0xCFCF76, 0x1D02D1, 0x2DF1B1, 0xC1998C, 0x77ADC3,
+0xDA4886, 0xA05DF7, 0xF480C6, 0x2FF0AC, 0x9AECDD, 0xBC5C3F,
+0x6DDED0, 0x1FC790, 0xB6DB2A, 0x3A25A3, 0x9AAF00, 0x9353AD,
+0x0457B6, 0xB42D29, 0x7E804B, 0xA707DA, 0x0EAA76, 0xA1597B,
+0x2A1216, 0x2DB7DC, 0xFDE5FA, 0xFEDB89, 0xFDBE89, 0x6C76E4,
+0xFCA906, 0x70803E, 0x156E85, 0xFF87FD, 0x073E28, 0x336761,
+0x86182A, 0xEABD4D, 0xAFE7B3, 0x6E6D8F, 0x396795, 0x5BBF31,
+0x48D784, 0x16DF30, 0x432DC7, 0x356125, 0xCE70C9, 0xB8CB30,
+0xFD6CBF, 0xA200A4, 0xE46C05, 0xA0DD5A, 0x476F21, 0xD21262,
+0x845CB9, 0x496170, 0xE0566B, 0x015299, 0x375550, 0xB7D51E,
+0xC4F133, 0x5F6E13, 0xE4305D, 0xA92E85, 0xC3B21D, 0x3632A1,
+0xA4B708, 0xD4B1EA, 0x21F716, 0xE4698F, 0x77FF27, 0x80030C,
+0x2D408D, 0xA0CD4F, 0x99A520, 0xD3A2B3, 0x0A5D2F, 0x42F9B4,
+0xCBDA11, 0xD0BE7D, 0xC1DB9B, 0xBD17AB, 0x81A2CA, 0x5C6A08,
+0x17552E, 0x550027, 0xF0147F, 0x8607E1, 0x640B14, 0x8D4196,
+0xDEBE87, 0x2AFDDA, 0xB6256B, 0x34897B, 0xFEF305, 0x9EBFB9,
+0x4F6A68, 0xA82A4A, 0x5AC44F, 0xBCF82D, 0x985AD7, 0x95C7F4,
+0x8D4D0D, 0xA63A20, 0x5F57A4, 0xB13F14, 0x953880, 0x0120CC,
+0x86DD71, 0xB6DEC9, 0xF560BF, 0x11654D, 0x6B0701, 0xACB08C,
+0xD0C0B2, 0x485551, 0x0EFB1E, 0xC37295, 0x3B06A3, 0x3540C0,
+0x7BDC06, 0xCC45E0, 0xFA294E, 0xC8CAD6, 0x41F3E8, 0xDE647C,
+0xD8649B, 0x31BED9, 0xC397A4, 0xD45877, 0xC5E369, 0x13DAF0,
+0x3C3ABA, 0x461846, 0x5F7555, 0xF5BDD2, 0xC6926E, 0x5D2EAC,
+0xED440E, 0x423E1C, 0x87C461, 0xE9FD29, 0xF3D6E7, 0xCA7C22,
+0x35916F, 0xC5E008, 0x8DD7FF, 0xE26A6E, 0xC6FDB0, 0xC10893,
+0x745D7C, 0xB2AD6B, 0x9D6ECD, 0x7B723E, 0x6A11C6, 0xA9CFF7,
+0xDF7329, 0xBAC9B5, 0x5100B7, 0x0DB2E2, 0x24BA74, 0x607DE5,
+0x8AD874, 0x2C150D, 0x0C1881, 0x94667E, 0x162901, 0x767A9F,
+0xBEFDFD, 0xEF4556, 0x367ED9, 0x13D9EC, 0xB9BA8B, 0xFC97C4,
+0x27A831, 0xC36EF1, 0x36C594, 0x56A8D8, 0xB5A8B4, 0x0ECCCF,
+0x2D8912, 0x34576F, 0x89562C, 0xE3CE99, 0xB920D6, 0xAA5E6B,
+0x9C2A3E, 0xCC5F11, 0x4A0BFD, 0xFBF4E1, 0x6D3B8E, 0x2C86E2,
+0x84D4E9, 0xA9B4FC, 0xD1EEEF, 0xC9352E, 0x61392F, 0x442138,
+0xC8D91B, 0x0AFC81, 0x6A4AFB, 0xD81C2F, 0x84B453, 0x8C994E,
+0xCC2254, 0xDC552A, 0xD6C6C0, 0x96190B, 0xB8701A, 0x649569,
+0x605A26, 0xEE523F, 0x0F117F, 0x11B5F4, 0xF5CBFC, 0x2DBC34,
+0xEEBC34, 0xCC5DE8, 0x605EDD, 0x9B8E67, 0xEF3392, 0xB817C9,
+0x9B5861, 0xBC57E1, 0xC68351, 0x103ED8, 0x4871DD, 0xDD1C2D,
+0xA118AF, 0x462C21, 0xD7F359, 0x987AD9, 0xC0549E, 0xFA864F,
+0xFC0656, 0xAE79E5, 0x362289, 0x22AD38, 0xDC9367, 0xAAE855,
+0x382682, 0x9BE7CA, 0xA40D51, 0xB13399, 0x0ED7A9, 0x480569,
+0xF0B265, 0xA7887F, 0x974C88, 0x36D1F9, 0xB39221, 0x4A827B,
+0x21CF98, 0xDC9F40, 0x5547DC, 0x3A74E1, 0x42EB67, 0xDF9DFE,
+0x5FD45E, 0xA4677B, 0x7AACBA, 0xA2F655, 0x23882B, 0x55BA41,
+0x086E59, 0x862A21, 0x834739, 0xE6E389, 0xD49EE5, 0x40FB49,
+0xE956FF, 0xCA0F1C, 0x8A59C5, 0x2BFA94, 0xC5C1D3, 0xCFC50F,
+0xAE5ADB, 0x86C547, 0x624385, 0x3B8621, 0x94792C, 0x876110,
+0x7B4C2A, 0x1A2C80, 0x12BF43, 0x902688, 0x893C78, 0xE4C4A8,
+0x7BDBE5, 0xC23AC4, 0xEAF426, 0x8A67F7, 0xBF920D, 0x2BA365,
+0xB1933D, 0x0B7CBD, 0xDC51A4, 0x63DD27, 0xDDE169, 0x19949A,
+0x9529A8, 0x28CE68, 0xB4ED09, 0x209F44, 0xCA984E, 0x638270,
+0x237C7E, 0x32B90F, 0x8EF5A7, 0xE75614, 0x08F121, 0x2A9DB5,
+0x4D7E6F, 0x5119A5, 0xABF9B5, 0xD6DF82, 0x61DD96, 0x023616,
+0x9F3AC4, 0xA1A283, 0x6DED72, 0x7A8D39, 0xA9B882, 0x5C326B,
+0x5B2746, 0xED3400, 0x7700D2, 0x55F4FC, 0x4D5901, 0x8071E0,
+#endif
+
+};
+
+static const double PIo2[] = {
+  1.57079625129699707031e+00, /* 0x3FF921FB, 0x40000000 */
+  7.54978941586159635335e-08, /* 0x3E74442D, 0x00000000 */
+  5.39030252995776476554e-15, /* 0x3CF84698, 0x80000000 */
+  3.28200341580791294123e-22, /* 0x3B78CC51, 0x60000000 */
+  1.27065575308067607349e-29, /* 0x39F01B83, 0x80000000 */
+  1.22933308981111328932e-36, /* 0x387A2520, 0x40000000 */
+  2.73370053816464559624e-44, /* 0x36E38222, 0x80000000 */
+  2.16741683877804819444e-51, /* 0x3569F31D, 0x00000000 */
+};
+
+static const double			
+zero   = 0.0,
+one    = 1.0,
+two24   =  1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */
+twon24  =  5.96046447753906250000e-08; /* 0x3E700000, 0x00000000 */
+
+int
+__kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec)
+{
+	int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih;
+	double z,fw,f[20],fq[20],q[20];
+
+    /* initialize jk*/
+	jk = init_jk[prec];
+	jp = jk;
+
+    /* determine jx,jv,q0, note that 3>q0 */
+	jx =  nx-1;
+	jv = (e0-3)/24; if(jv<0) jv=0;
+	q0 =  e0-24*(jv+1);
+
+    /* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */
+	j = jv-jx; m = jx+jk;
+	for(i=0;i<=m;i++,j++) f[i] = (j<0)? zero : (double) ipio2[j];
+
+    /* compute q[0],q[1],...q[jk] */
+	for (i=0;i<=jk;i++) {
+	    for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
+	}
+
+	jz = jk;
+recompute:
+    /* distill q[] into iq[] reversingly */
+	for(i=0,j=jz,z=q[jz];j>0;i++,j--) {
+	    fw    =  (double)((int32_t)(twon24* z));
+	    iq[i] =  (int32_t)(z-two24*fw);
+	    z     =  q[j-1]+fw;
+	}
+
+    /* compute n */
+	z  = scalbn(z,q0);		/* actual value of z */
+	z -= 8.0*floor(z*0.125);		/* trim off integer >= 8 */
+	n  = (int32_t) z;
+	z -= (double)n;
+	ih = 0;
+	if(q0>0) {	/* need iq[jz-1] to determine n */
+	    i  = (iq[jz-1]>>(24-q0)); n += i;
+	    iq[jz-1] -= i<<(24-q0);
+	    ih = iq[jz-1]>>(23-q0);
+	} 
+	else if(q0==0) ih = iq[jz-1]>>23;
+	else if(z>=0.5) ih=2;
+
+	if(ih>0) {	/* q > 0.5 */
+	    n += 1; carry = 0;
+	    for(i=0;i<jz ;i++) {	/* compute 1-q */
+		j = iq[i];
+		if(carry==0) {
+		    if(j!=0) {
+			carry = 1; iq[i] = 0x1000000- j;
+		    }
+		} else  iq[i] = 0xffffff - j;
+	    }
+	    if(q0>0) {		/* rare case: chance is 1 in 12 */
+	        switch(q0) {
+	        case 1:
+	    	   iq[jz-1] &= 0x7fffff; break;
+	    	case 2:
+	    	   iq[jz-1] &= 0x3fffff; break;
+	        }
+	    }
+	    if(ih==2) {
+		z = one - z;
+		if(carry!=0) z -= scalbn(one,q0);
+	    }
+	}
+
+    /* check if recomputation is needed */
+	if(z==zero) {
+	    j = 0;
+	    for (i=jz-1;i>=jk;i--) j |= iq[i];
+	    if(j==0) { /* need recomputation */
+		for(k=1;iq[jk-k]==0;k++);   /* k = no. of terms needed */
+
+		for(i=jz+1;i<=jz+k;i++) {   /* add q[jz+1] to q[jz+k] */
+		    f[jx+i] = (double) ipio2[jv+i];
+		    for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j];
+		    q[i] = fw;
+		}
+		jz += k;
+		goto recompute;
+	    }
+	}
+
+    /* chop off zero terms */
+	if(z==0.0) {
+	    jz -= 1; q0 -= 24;
+	    while(iq[jz]==0) { jz--; q0-=24;}
+	} else { /* break z into 24-bit if necessary */
+	    z = scalbn(z,-q0);
+	    if(z>=two24) { 
+		fw = (double)((int32_t)(twon24*z));
+		iq[jz] = (int32_t)(z-two24*fw);
+		jz += 1; q0 += 24;
+		iq[jz] = (int32_t) fw;
+	    } else iq[jz] = (int32_t) z ;
+	}
+
+    /* convert integer "bit" chunk to floating-point value */
+	fw = scalbn(one,q0);
+	for(i=jz;i>=0;i--) {
+	    q[i] = fw*(double)iq[i]; fw*=twon24;
+	}
+
+    /* compute PIo2[0,...,jp]*q[jz,...,0] */
+	for(i=jz;i>=0;i--) {
+	    for(fw=0.0,k=0;k<=jp&&k<=jz-i;k++) fw += PIo2[k]*q[i+k];
+	    fq[jz-i] = fw;
+	}
+
+    /* compress fq[] into y[] */
+	switch(prec) {
+	    case 0:
+		fw = 0.0;
+		for (i=jz;i>=0;i--) fw += fq[i];
+		y[0] = (ih==0)? fw: -fw; 
+		break;
+	    case 1:
+	    case 2:
+		fw = 0.0;
+		for (i=jz;i>=0;i--) fw += fq[i]; 
+		STRICT_ASSIGN(double,fw,fw);
+		y[0] = (ih==0)? fw: -fw; 
+		fw = fq[0]-fw;
+		for (i=1;i<=jz;i++) fw += fq[i];
+		y[1] = (ih==0)? fw: -fw; 
+		break;
+	    case 3:	/* painful */
+		for (i=jz;i>0;i--) {
+		    fw      = fq[i-1]+fq[i]; 
+		    fq[i]  += fq[i-1]-fw;
+		    fq[i-1] = fw;
+		}
+		for (i=jz;i>1;i--) {
+		    fw      = fq[i-1]+fq[i]; 
+		    fq[i]  += fq[i-1]-fw;
+		    fq[i-1] = fw;
+		}
+		for (fw=0.0,i=jz;i>=2;i--) fw += fq[i]; 
+		if(ih==0) {
+		    y[0] =  fq[0]; y[1] =  fq[1]; y[2] =  fw;
+		} else {
+		    y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw;
+		}
+	}
+	return n&7;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/k_sin.c b/libm/upstream-freebsd/lib/msun/src/k_sin.c
new file mode 100644
index 0000000..12ee8c1
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/k_sin.c
@@ -0,0 +1,70 @@
+
+/* @(#)k_sin.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __kernel_sin( x, y, iy)
+ * kernel sin function on ~[-pi/4, pi/4] (except on -0), pi/4 ~ 0.7854
+ * Input x is assumed to be bounded by ~pi/4 in magnitude.
+ * Input y is the tail of x.
+ * Input iy indicates whether y is 0. (if iy=0, y assume to be 0). 
+ *
+ * Algorithm
+ *	1. Since sin(-x) = -sin(x), we need only to consider positive x. 
+ *	2. Callers must return sin(-0) = -0 without calling here since our
+ *	   odd polynomial is not evaluated in a way that preserves -0.
+ *	   Callers may do the optimization sin(x) ~ x for tiny x.
+ *	3. sin(x) is approximated by a polynomial of degree 13 on
+ *	   [0,pi/4]
+ *		  	         3            13
+ *	   	sin(x) ~ x + S1*x + ... + S6*x
+ *	   where
+ *	
+ * 	|sin(x)         2     4     6     8     10     12  |     -58
+ * 	|----- - (1+S1*x +S2*x +S3*x +S4*x +S5*x  +S6*x   )| <= 2
+ * 	|  x 					           | 
+ * 
+ *	4. sin(x+y) = sin(x) + sin'(x')*y
+ *		    ~ sin(x) + (1-x*x/2)*y
+ *	   For better accuracy, let 
+ *		     3      2      2      2      2
+ *		r = x *(S2+x *(S3+x *(S4+x *(S5+x *S6))))
+ *	   then                   3    2
+ *		sin(x) = x + (S1*x + (x *(r-y/2)+y))
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+static const double
+half =  5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
+S1  = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549 */
+S2  =  8.33333333332248946124e-03, /* 0x3F811111, 0x1110F8A6 */
+S3  = -1.98412698298579493134e-04, /* 0xBF2A01A0, 0x19C161D5 */
+S4  =  2.75573137070700676789e-06, /* 0x3EC71DE3, 0x57B1FE7D */
+S5  = -2.50507602534068634195e-08, /* 0xBE5AE5E6, 0x8A2B9CEB */
+S6  =  1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */
+
+double
+__kernel_sin(double x, double y, int iy)
+{
+	double z,r,v,w;
+
+	z	=  x*x;
+	w	=  z*z;
+	r	=  S2+z*(S3+z*S4) + z*w*(S5+z*S6);
+	v	=  z*x;
+	if(iy==0) return x+v*(S1+z*r);
+	else      return x-((z*(half*y-v*r)-y)-v*S1);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/k_sinf.c b/libm/upstream-freebsd/lib/msun/src/k_sinf.c
new file mode 100644
index 0000000..0841759
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/k_sinf.c
@@ -0,0 +1,46 @@
+/* k_sinf.c -- float version of k_sin.c
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ * Optimized by Bruce D. Evans.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#ifndef INLINE_KERNEL_SINDF
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+#endif
+
+#include "math.h"
+#include "math_private.h"
+
+/* |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]). */
+static const double
+S1 = -0x15555554cbac77.0p-55,	/* -0.166666666416265235595 */
+S2 =  0x111110896efbb2.0p-59,	/*  0.0083333293858894631756 */
+S3 = -0x1a00f9e2cae774.0p-65,	/* -0.000198393348360966317347 */
+S4 =  0x16cd878c3b46a7.0p-71;	/*  0.0000027183114939898219064 */
+
+#ifdef INLINE_KERNEL_SINDF
+static __inline
+#endif
+float
+__kernel_sindf(double x)
+{
+	double r, s, w, z;
+
+	/* Try to optimize for parallel evaluation as in k_tanf.c. */
+	z = x*x;
+	w = z*z;
+	r = S3+z*S4;
+	s = z*x;
+	return (x + s*(S1+z*S2)) + s*w*r;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/k_tan.c b/libm/upstream-freebsd/lib/msun/src/k_tan.c
new file mode 100644
index 0000000..2e86c3b
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/k_tan.c
@@ -0,0 +1,132 @@
+/* @(#)k_tan.c 1.5 04/04/22 SMI */
+
+/*
+ * ====================================================
+ * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/* INDENT OFF */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* __kernel_tan( x, y, k )
+ * kernel tan function on ~[-pi/4, pi/4] (except on -0), pi/4 ~ 0.7854
+ * Input x is assumed to be bounded by ~pi/4 in magnitude.
+ * Input y is the tail of x.
+ * Input k indicates whether tan (if k = 1) or -1/tan (if k = -1) is returned.
+ *
+ * Algorithm
+ *	1. Since tan(-x) = -tan(x), we need only to consider positive x.
+ *	2. Callers must return tan(-0) = -0 without calling here since our
+ *	   odd polynomial is not evaluated in a way that preserves -0.
+ *	   Callers may do the optimization tan(x) ~ x for tiny x.
+ *	3. tan(x) is approximated by a odd polynomial of degree 27 on
+ *	   [0,0.67434]
+ *		  	         3             27
+ *	   	tan(x) ~ x + T1*x + ... + T13*x
+ *	   where
+ *
+ * 	        |tan(x)         2     4            26   |     -59.2
+ * 	        |----- - (1+T1*x +T2*x +.... +T13*x    )| <= 2
+ * 	        |  x 					|
+ *
+ *	   Note: tan(x+y) = tan(x) + tan'(x)*y
+ *		          ~ tan(x) + (1+x*x)*y
+ *	   Therefore, for better accuracy in computing tan(x+y), let
+ *		     3      2      2       2       2
+ *		r = x *(T2+x *(T3+x *(...+x *(T12+x *T13))))
+ *	   then
+ *		 		    3    2
+ *		tan(x+y) = x + (T1*x + (x *(r+y)+y))
+ *
+ *      4. For x in [0.67434,pi/4],  let y = pi/4 - x, then
+ *		tan(x) = tan(pi/4-y) = (1-tan(y))/(1+tan(y))
+ *		       = 1 - 2*(tan(y) - (tan(y)^2)/(1+tan(y)))
+ */
+
+#include "math.h"
+#include "math_private.h"
+static const double xxx[] = {
+		 3.33333333333334091986e-01,	/* 3FD55555, 55555563 */
+		 1.33333333333201242699e-01,	/* 3FC11111, 1110FE7A */
+		 5.39682539762260521377e-02,	/* 3FABA1BA, 1BB341FE */
+		 2.18694882948595424599e-02,	/* 3F9664F4, 8406D637 */
+		 8.86323982359930005737e-03,	/* 3F8226E3, E96E8493 */
+		 3.59207910759131235356e-03,	/* 3F6D6D22, C9560328 */
+		 1.45620945432529025516e-03,	/* 3F57DBC8, FEE08315 */
+		 5.88041240820264096874e-04,	/* 3F4344D8, F2F26501 */
+		 2.46463134818469906812e-04,	/* 3F3026F7, 1A8D1068 */
+		 7.81794442939557092300e-05,	/* 3F147E88, A03792A6 */
+		 7.14072491382608190305e-05,	/* 3F12B80F, 32F0A7E9 */
+		-1.85586374855275456654e-05,	/* BEF375CB, DB605373 */
+		 2.59073051863633712884e-05,	/* 3EFB2A70, 74BF7AD4 */
+/* one */	 1.00000000000000000000e+00,	/* 3FF00000, 00000000 */
+/* pio4 */	 7.85398163397448278999e-01,	/* 3FE921FB, 54442D18 */
+/* pio4lo */	 3.06161699786838301793e-17	/* 3C81A626, 33145C07 */
+};
+#define	one	xxx[13]
+#define	pio4	xxx[14]
+#define	pio4lo	xxx[15]
+#define	T	xxx
+/* INDENT ON */
+
+double
+__kernel_tan(double x, double y, int iy) {
+	double z, r, v, w, s;
+	int32_t ix, hx;
+
+	GET_HIGH_WORD(hx,x);
+	ix = hx & 0x7fffffff;			/* high word of |x| */
+	if (ix >= 0x3FE59428) {	/* |x| >= 0.6744 */
+		if (hx < 0) {
+			x = -x;
+			y = -y;
+		}
+		z = pio4 - x;
+		w = pio4lo - y;
+		x = z + w;
+		y = 0.0;
+	}
+	z = x * x;
+	w = z * z;
+	/*
+	 * Break x^5*(T[1]+x^2*T[2]+...) into
+	 * x^5(T[1]+x^4*T[3]+...+x^20*T[11]) +
+	 * x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12]))
+	 */
+	r = T[1] + w * (T[3] + w * (T[5] + w * (T[7] + w * (T[9] +
+		w * T[11]))));
+	v = z * (T[2] + w * (T[4] + w * (T[6] + w * (T[8] + w * (T[10] +
+		w * T[12])))));
+	s = z * x;
+	r = y + z * (s * (r + v) + y);
+	r += T[0] * s;
+	w = x + r;
+	if (ix >= 0x3FE59428) {
+		v = (double) iy;
+		return (double) (1 - ((hx >> 30) & 2)) *
+			(v - 2.0 * (x - (w * w / (w + v) - r)));
+	}
+	if (iy == 1)
+		return w;
+	else {
+		/*
+		 * if allow error up to 2 ulp, simply return
+		 * -1.0 / (x+r) here
+		 */
+		/* compute -1.0 / (x+r) accurately */
+		double a, t;
+		z = w;
+		SET_LOW_WORD(z,0);
+		v = r - (z - x);	/* z+v = r+x */
+		t = a = -1.0 / w;	/* a = -1.0/w */
+		SET_LOW_WORD(t,0);
+		s = 1.0 + t * z;
+		return t + a * (s + t * v);
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/k_tanf.c b/libm/upstream-freebsd/lib/msun/src/k_tanf.c
new file mode 100644
index 0000000..52f1aaa
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/k_tanf.c
@@ -0,0 +1,66 @@
+/* k_tanf.c -- float version of k_tan.c
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ * Optimized by Bruce D. Evans.
+ */
+
+/*
+ * ====================================================
+ * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#ifndef INLINE_KERNEL_TANDF
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+#endif
+
+#include "math.h"
+#include "math_private.h"
+
+/* |tan(x)/x - t(x)| < 2**-25.5 (~[-2e-08, 2e-08]). */
+static const double
+T[] =  {
+  0x15554d3418c99f.0p-54,	/* 0.333331395030791399758 */
+  0x1112fd38999f72.0p-55,	/* 0.133392002712976742718 */
+  0x1b54c91d865afe.0p-57,	/* 0.0533812378445670393523 */
+  0x191df3908c33ce.0p-58,	/* 0.0245283181166547278873 */
+  0x185dadfcecf44e.0p-61,	/* 0.00297435743359967304927 */
+  0x1362b9bf971bcd.0p-59,	/* 0.00946564784943673166728 */
+};
+
+#ifdef INLINE_KERNEL_TANDF
+static __inline
+#endif
+float
+__kernel_tandf(double x, int iy)
+{
+	double z,r,w,s,t,u;
+
+	z	=  x*x;
+	/*
+	 * Split up the polynomial into small independent terms to give
+	 * opportunities for parallel evaluation.  The chosen splitting is
+	 * micro-optimized for Athlons (XP, X64).  It costs 2 multiplications
+	 * relative to Horner's method on sequential machines.
+	 *
+	 * We add the small terms from lowest degree up for efficiency on
+	 * non-sequential machines (the lowest degree terms tend to be ready
+	 * earlier).  Apart from this, we don't care about order of
+	 * operations, and don't need to to care since we have precision to
+	 * spare.  However, the chosen splitting is good for accuracy too,
+	 * and would give results as accurate as Horner's method if the
+	 * small terms were added from highest degree down.
+	 */
+	r = T[4]+z*T[5];
+	t = T[2]+z*T[3];
+	w = z*z;
+	s = z*x;
+	u = T[0]+z*T[1];
+	r = (x+s*u)+(s*w)*(t+w*r);
+	if(iy==1) return r;
+	else return -1.0/r;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/math_private.h b/libm/upstream-freebsd/lib/msun/src/math_private.h
new file mode 100644
index 0000000..5662df0
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/math_private.h
@@ -0,0 +1,472 @@
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+ * from: @(#)fdlibm.h 5.1 93/09/24
+ * $FreeBSD$
+ */
+
+#ifndef _MATH_PRIVATE_H_
+#define	_MATH_PRIVATE_H_
+
+#include <sys/types.h>
+#include <machine/endian.h>
+
+/*
+ * The original fdlibm code used statements like:
+ *	n0 = ((*(int*)&one)>>29)^1;		* index of high word *
+ *	ix0 = *(n0+(int*)&x);			* high word of x *
+ *	ix1 = *((1-n0)+(int*)&x);		* low word of x *
+ * to dig two 32 bit words out of the 64 bit IEEE floating point
+ * value.  That is non-ANSI, and, moreover, the gcc instruction
+ * scheduler gets it wrong.  We instead use the following macros.
+ * Unlike the original code, we determine the endianness at compile
+ * time, not at run time; I don't see much benefit to selecting
+ * endianness at run time.
+ */
+
+/*
+ * A union which permits us to convert between a double and two 32 bit
+ * ints.
+ */
+
+#ifdef __arm__
+#if defined(__VFP_FP__)
+#define	IEEE_WORD_ORDER	BYTE_ORDER
+#else
+#define	IEEE_WORD_ORDER	BIG_ENDIAN
+#endif
+#else /* __arm__ */
+#define	IEEE_WORD_ORDER	BYTE_ORDER
+#endif
+
+#if IEEE_WORD_ORDER == BIG_ENDIAN
+
+typedef union
+{
+  double value;
+  struct
+  {
+    u_int32_t msw;
+    u_int32_t lsw;
+  } parts;
+  struct
+  {
+    u_int64_t w;
+  } xparts;
+} ieee_double_shape_type;
+
+#endif
+
+#if IEEE_WORD_ORDER == LITTLE_ENDIAN
+
+typedef union
+{
+  double value;
+  struct
+  {
+    u_int32_t lsw;
+    u_int32_t msw;
+  } parts;
+  struct
+  {
+    u_int64_t w;
+  } xparts;
+} ieee_double_shape_type;
+
+#endif
+
+/* Get two 32 bit ints from a double.  */
+
+#define EXTRACT_WORDS(ix0,ix1,d)				\
+do {								\
+  ieee_double_shape_type ew_u;					\
+  ew_u.value = (d);						\
+  (ix0) = ew_u.parts.msw;					\
+  (ix1) = ew_u.parts.lsw;					\
+} while (0)
+
+/* Get a 64-bit int from a double. */
+#define EXTRACT_WORD64(ix,d)					\
+do {								\
+  ieee_double_shape_type ew_u;					\
+  ew_u.value = (d);						\
+  (ix) = ew_u.xparts.w;						\
+} while (0)
+
+/* Get the more significant 32 bit int from a double.  */
+
+#define GET_HIGH_WORD(i,d)					\
+do {								\
+  ieee_double_shape_type gh_u;					\
+  gh_u.value = (d);						\
+  (i) = gh_u.parts.msw;						\
+} while (0)
+
+/* Get the less significant 32 bit int from a double.  */
+
+#define GET_LOW_WORD(i,d)					\
+do {								\
+  ieee_double_shape_type gl_u;					\
+  gl_u.value = (d);						\
+  (i) = gl_u.parts.lsw;						\
+} while (0)
+
+/* Set a double from two 32 bit ints.  */
+
+#define INSERT_WORDS(d,ix0,ix1)					\
+do {								\
+  ieee_double_shape_type iw_u;					\
+  iw_u.parts.msw = (ix0);					\
+  iw_u.parts.lsw = (ix1);					\
+  (d) = iw_u.value;						\
+} while (0)
+
+/* Set a double from a 64-bit int. */
+#define INSERT_WORD64(d,ix)					\
+do {								\
+  ieee_double_shape_type iw_u;					\
+  iw_u.xparts.w = (ix);						\
+  (d) = iw_u.value;						\
+} while (0)
+
+/* Set the more significant 32 bits of a double from an int.  */
+
+#define SET_HIGH_WORD(d,v)					\
+do {								\
+  ieee_double_shape_type sh_u;					\
+  sh_u.value = (d);						\
+  sh_u.parts.msw = (v);						\
+  (d) = sh_u.value;						\
+} while (0)
+
+/* Set the less significant 32 bits of a double from an int.  */
+
+#define SET_LOW_WORD(d,v)					\
+do {								\
+  ieee_double_shape_type sl_u;					\
+  sl_u.value = (d);						\
+  sl_u.parts.lsw = (v);						\
+  (d) = sl_u.value;						\
+} while (0)
+
+/*
+ * A union which permits us to convert between a float and a 32 bit
+ * int.
+ */
+
+typedef union
+{
+  float value;
+  /* FIXME: Assumes 32 bit int.  */
+  unsigned int word;
+} ieee_float_shape_type;
+
+/* Get a 32 bit int from a float.  */
+
+#define GET_FLOAT_WORD(i,d)					\
+do {								\
+  ieee_float_shape_type gf_u;					\
+  gf_u.value = (d);						\
+  (i) = gf_u.word;						\
+} while (0)
+
+/* Set a float from a 32 bit int.  */
+
+#define SET_FLOAT_WORD(d,i)					\
+do {								\
+  ieee_float_shape_type sf_u;					\
+  sf_u.word = (i);						\
+  (d) = sf_u.value;						\
+} while (0)
+
+/* Get expsign as a 16 bit int from a long double.  */
+
+#define	GET_LDBL_EXPSIGN(i,d)					\
+do {								\
+  union IEEEl2bits ge_u;					\
+  ge_u.e = (d);							\
+  (i) = ge_u.xbits.expsign;					\
+} while (0)
+
+/* Set expsign of a long double from a 16 bit int.  */
+
+#define	SET_LDBL_EXPSIGN(d,v)					\
+do {								\
+  union IEEEl2bits se_u;					\
+  se_u.e = (d);							\
+  se_u.xbits.expsign = (v);					\
+  (d) = se_u.e;							\
+} while (0)
+
+#ifdef __i386__
+/* Long double constants are broken on i386. */
+#define	LD80C(m, ex, v) {						\
+	.xbits.man = __CONCAT(m, ULL),					\
+	.xbits.expsign = (0x3fff + (ex)) | ((v) < 0 ? 0x8000 : 0),	\
+}
+#else
+/* The above works on non-i386 too, but we use this to check v. */
+#define	LD80C(m, ex, v)	{ .e = (v), }
+#endif
+
+#ifdef FLT_EVAL_METHOD
+/*
+ * Attempt to get strict C99 semantics for assignment with non-C99 compilers.
+ */
+#if FLT_EVAL_METHOD == 0 || __GNUC__ == 0
+#define	STRICT_ASSIGN(type, lval, rval)	((lval) = (rval))
+#else
+#define	STRICT_ASSIGN(type, lval, rval) do {	\
+	volatile type __lval;			\
+						\
+	if (sizeof(type) >= sizeof(long double))	\
+		(lval) = (rval);		\
+	else {					\
+		__lval = (rval);		\
+		(lval) = __lval;		\
+	}					\
+} while (0)
+#endif
+#endif /* FLT_EVAL_METHOD */
+
+/* Support switching the mode to FP_PE if necessary. */
+#if defined(__i386__) && !defined(NO_FPSETPREC)
+#define	ENTERI()				\
+	long double __retval;			\
+	fp_prec_t __oprec;			\
+						\
+	if ((__oprec = fpgetprec()) != FP_PE)	\
+		fpsetprec(FP_PE)
+#define	RETURNI(x) do {				\
+	__retval = (x);				\
+	if (__oprec != FP_PE)			\
+		fpsetprec(__oprec);		\
+	RETURNF(__retval);			\
+} while (0)
+#else
+#define	ENTERI(x)
+#define	RETURNI(x)	RETURNF(x)
+#endif
+
+/* Default return statement if hack*_t() is not used. */
+#define      RETURNF(v)      return (v)
+
+/*
+ * Common routine to process the arguments to nan(), nanf(), and nanl().
+ */
+void _scan_nan(uint32_t *__words, int __num_words, const char *__s);
+
+#ifdef _COMPLEX_H
+
+/*
+ * C99 specifies that complex numbers have the same representation as
+ * an array of two elements, where the first element is the real part
+ * and the second element is the imaginary part.
+ */
+typedef union {
+	float complex f;
+	float a[2];
+} float_complex;
+typedef union {
+	double complex f;
+	double a[2];
+} double_complex;
+typedef union {
+	long double complex f;
+	long double a[2];
+} long_double_complex;
+#define	REALPART(z)	((z).a[0])
+#define	IMAGPART(z)	((z).a[1])
+
+/*
+ * Inline functions that can be used to construct complex values.
+ *
+ * The C99 standard intends x+I*y to be used for this, but x+I*y is
+ * currently unusable in general since gcc introduces many overflow,
+ * underflow, sign and efficiency bugs by rewriting I*y as
+ * (0.0+I)*(y+0.0*I) and laboriously computing the full complex product.
+ * In particular, I*Inf is corrupted to NaN+I*Inf, and I*-0 is corrupted
+ * to -0.0+I*0.0.
+ */
+static __inline float complex
+cpackf(float x, float y)
+{
+	float_complex z;
+
+	REALPART(z) = x;
+	IMAGPART(z) = y;
+	return (z.f);
+}
+
+static __inline double complex
+cpack(double x, double y)
+{
+	double_complex z;
+
+	REALPART(z) = x;
+	IMAGPART(z) = y;
+	return (z.f);
+}
+
+static __inline long double complex
+cpackl(long double x, long double y)
+{
+	long_double_complex z;
+
+	REALPART(z) = x;
+	IMAGPART(z) = y;
+	return (z.f);
+}
+#endif /* _COMPLEX_H */
+ 
+#ifdef __GNUCLIKE_ASM
+
+/* Asm versions of some functions. */
+
+#ifdef __amd64__
+static __inline int
+irint(double x)
+{
+	int n;
+
+	asm("cvtsd2si %1,%0" : "=r" (n) : "x" (x));
+	return (n);
+}
+#define	HAVE_EFFICIENT_IRINT
+#endif
+
+#ifdef __i386__
+static __inline int
+irint(double x)
+{
+	int n;
+
+	asm("fistl %0" : "=m" (n) : "t" (x));
+	return (n);
+}
+#define	HAVE_EFFICIENT_IRINT
+#endif
+
+#if defined(__amd64__) || defined(__i386__)
+static __inline int
+irintl(long double x)
+{
+	int n;
+
+	asm("fistl %0" : "=m" (n) : "t" (x));
+	return (n);
+}
+#define	HAVE_EFFICIENT_IRINTL
+#endif
+
+#endif /* __GNUCLIKE_ASM */
+
+/*
+ * ieee style elementary functions
+ *
+ * We rename functions here to improve other sources' diffability
+ * against fdlibm.
+ */
+#define	__ieee754_sqrt	sqrt
+#define	__ieee754_acos	acos
+#define	__ieee754_acosh	acosh
+#define	__ieee754_log	log
+#define	__ieee754_log2	log2
+#define	__ieee754_atanh	atanh
+#define	__ieee754_asin	asin
+#define	__ieee754_atan2	atan2
+#define	__ieee754_exp	exp
+#define	__ieee754_cosh	cosh
+#define	__ieee754_fmod	fmod
+#define	__ieee754_pow	pow
+#define	__ieee754_lgamma lgamma
+#define	__ieee754_gamma	gamma
+#define	__ieee754_lgamma_r lgamma_r
+#define	__ieee754_gamma_r gamma_r
+#define	__ieee754_log10	log10
+#define	__ieee754_sinh	sinh
+#define	__ieee754_hypot	hypot
+#define	__ieee754_j0	j0
+#define	__ieee754_j1	j1
+#define	__ieee754_y0	y0
+#define	__ieee754_y1	y1
+#define	__ieee754_jn	jn
+#define	__ieee754_yn	yn
+#define	__ieee754_remainder remainder
+#define	__ieee754_scalb	scalb
+#define	__ieee754_sqrtf	sqrtf
+#define	__ieee754_acosf	acosf
+#define	__ieee754_acoshf acoshf
+#define	__ieee754_logf	logf
+#define	__ieee754_atanhf atanhf
+#define	__ieee754_asinf	asinf
+#define	__ieee754_atan2f atan2f
+#define	__ieee754_expf	expf
+#define	__ieee754_coshf	coshf
+#define	__ieee754_fmodf	fmodf
+#define	__ieee754_powf	powf
+#define	__ieee754_lgammaf lgammaf
+#define	__ieee754_gammaf gammaf
+#define	__ieee754_lgammaf_r lgammaf_r
+#define	__ieee754_gammaf_r gammaf_r
+#define	__ieee754_log10f log10f
+#define	__ieee754_log2f log2f
+#define	__ieee754_sinhf	sinhf
+#define	__ieee754_hypotf hypotf
+#define	__ieee754_j0f	j0f
+#define	__ieee754_j1f	j1f
+#define	__ieee754_y0f	y0f
+#define	__ieee754_y1f	y1f
+#define	__ieee754_jnf	jnf
+#define	__ieee754_ynf	ynf
+#define	__ieee754_remainderf remainderf
+#define	__ieee754_scalbf scalbf
+
+/* fdlibm kernel function */
+int	__kernel_rem_pio2(double*,double*,int,int,int);
+
+/* double precision kernel functions */
+#ifndef INLINE_REM_PIO2
+int	__ieee754_rem_pio2(double,double*);
+#endif
+double	__kernel_sin(double,double,int);
+double	__kernel_cos(double,double);
+double	__kernel_tan(double,double,int);
+double	__ldexp_exp(double,int);
+#ifdef _COMPLEX_H
+double complex __ldexp_cexp(double complex,int);
+#endif
+
+/* float precision kernel functions */
+#ifndef INLINE_REM_PIO2F
+int	__ieee754_rem_pio2f(float,double*);
+#endif
+#ifndef INLINE_KERNEL_SINDF
+float	__kernel_sindf(double);
+#endif
+#ifndef INLINE_KERNEL_COSDF
+float	__kernel_cosdf(double);
+#endif
+#ifndef INLINE_KERNEL_TANDF
+float	__kernel_tandf(double,int);
+#endif
+float	__ldexp_expf(float,int);
+#ifdef _COMPLEX_H
+float complex __ldexp_cexpf(float complex,int);
+#endif
+
+/* long double precision kernel functions */
+long double __kernel_sinl(long double, long double, int);
+long double __kernel_cosl(long double, long double);
+long double __kernel_tanl(long double, long double, int);
+
+#endif /* !_MATH_PRIVATE_H_ */
diff --git a/libm/upstream-freebsd/lib/msun/src/s_asinh.c b/libm/upstream-freebsd/lib/msun/src/s_asinh.c
new file mode 100644
index 0000000..f3fdf74
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_asinh.c
@@ -0,0 +1,56 @@
+/* @(#)s_asinh.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* asinh(x)
+ * Method :
+ *	Based on
+ *		asinh(x) = sign(x) * log [ |x| + sqrt(x*x+1) ]
+ *	we have
+ *	asinh(x) := x  if  1+x*x=1,
+ *		 := sign(x)*(log(x)+ln2)) for large |x|, else
+ *		 := sign(x)*log(2|x|+1/(|x|+sqrt(x*x+1))) if|x|>2, else
+ *		 := sign(x)*log1p(|x| + x^2/(1 + sqrt(1+x^2)))
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+static const double
+one =  1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
+ln2 =  6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */
+huge=  1.00000000000000000000e+300;
+
+double
+asinh(double x)
+{
+	double t,w;
+	int32_t hx,ix;
+	GET_HIGH_WORD(hx,x);
+	ix = hx&0x7fffffff;
+	if(ix>=0x7ff00000) return x+x;	/* x is inf or NaN */
+	if(ix< 0x3e300000) {	/* |x|<2**-28 */
+	    if(huge+x>one) return x;	/* return x inexact except 0 */
+	}
+	if(ix>0x41b00000) {	/* |x| > 2**28 */
+	    w = __ieee754_log(fabs(x))+ln2;
+	} else if (ix>0x40000000) {	/* 2**28 > |x| > 2.0 */
+	    t = fabs(x);
+	    w = __ieee754_log(2.0*t+one/(__ieee754_sqrt(x*x+one)+t));
+	} else {		/* 2.0 > |x| > 2**-28 */
+	    t = x*x;
+	    w =log1p(fabs(x)+t/(one+__ieee754_sqrt(one+t)));
+	}
+	if(hx>0) return w; else return -w;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_asinhf.c b/libm/upstream-freebsd/lib/msun/src/s_asinhf.c
new file mode 100644
index 0000000..c1620dd
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_asinhf.c
@@ -0,0 +1,48 @@
+/* s_asinhf.c -- float version of s_asinh.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static const float
+one =  1.0000000000e+00, /* 0x3F800000 */
+ln2 =  6.9314718246e-01, /* 0x3f317218 */
+huge=  1.0000000000e+30;
+
+float
+asinhf(float x)
+{
+	float t,w;
+	int32_t hx,ix;
+	GET_FLOAT_WORD(hx,x);
+	ix = hx&0x7fffffff;
+	if(ix>=0x7f800000) return x+x;	/* x is inf or NaN */
+	if(ix< 0x31800000) {	/* |x|<2**-28 */
+	    if(huge+x>one) return x;	/* return x inexact except 0 */
+	}
+	if(ix>0x4d800000) {	/* |x| > 2**28 */
+	    w = __ieee754_logf(fabsf(x))+ln2;
+	} else if (ix>0x40000000) {	/* 2**28 > |x| > 2.0 */
+	    t = fabsf(x);
+	    w = __ieee754_logf((float)2.0*t+one/(__ieee754_sqrtf(x*x+one)+t));
+	} else {		/* 2.0 > |x| > 2**-28 */
+	    t = x*x;
+	    w =log1pf(fabsf(x)+t/(one+__ieee754_sqrtf(one+t)));
+	}
+	if(hx>0) return w; else return -w;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_atan.c b/libm/upstream-freebsd/lib/msun/src/s_atan.c
new file mode 100644
index 0000000..566f5dc
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_atan.c
@@ -0,0 +1,124 @@
+/* @(#)s_atan.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* atan(x)
+ * Method
+ *   1. Reduce x to positive by atan(x) = -atan(-x).
+ *   2. According to the integer k=4t+0.25 chopped, t=x, the argument
+ *      is further reduced to one of the following intervals and the
+ *      arctangent of t is evaluated by the corresponding formula:
+ *
+ *      [0,7/16]      atan(x) = t-t^3*(a1+t^2*(a2+...(a10+t^2*a11)...)
+ *      [7/16,11/16]  atan(x) = atan(1/2) + atan( (t-0.5)/(1+t/2) )
+ *      [11/16.19/16] atan(x) = atan( 1 ) + atan( (t-1)/(1+t) )
+ *      [19/16,39/16] atan(x) = atan(3/2) + atan( (t-1.5)/(1+1.5t) )
+ *      [39/16,INF]   atan(x) = atan(INF) + atan( -1/t )
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following
+ * constants. The decimal values may be used, provided that the
+ * compiler will convert from decimal to binary accurately enough
+ * to produce the hexadecimal values shown.
+ */
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const double atanhi[] = {
+  4.63647609000806093515e-01, /* atan(0.5)hi 0x3FDDAC67, 0x0561BB4F */
+  7.85398163397448278999e-01, /* atan(1.0)hi 0x3FE921FB, 0x54442D18 */
+  9.82793723247329054082e-01, /* atan(1.5)hi 0x3FEF730B, 0xD281F69B */
+  1.57079632679489655800e+00, /* atan(inf)hi 0x3FF921FB, 0x54442D18 */
+};
+
+static const double atanlo[] = {
+  2.26987774529616870924e-17, /* atan(0.5)lo 0x3C7A2B7F, 0x222F65E2 */
+  3.06161699786838301793e-17, /* atan(1.0)lo 0x3C81A626, 0x33145C07 */
+  1.39033110312309984516e-17, /* atan(1.5)lo 0x3C700788, 0x7AF0CBBD */
+  6.12323399573676603587e-17, /* atan(inf)lo 0x3C91A626, 0x33145C07 */
+};
+
+static const double aT[] = {
+  3.33333333333329318027e-01, /* 0x3FD55555, 0x5555550D */
+ -1.99999999998764832476e-01, /* 0xBFC99999, 0x9998EBC4 */
+  1.42857142725034663711e-01, /* 0x3FC24924, 0x920083FF */
+ -1.11111104054623557880e-01, /* 0xBFBC71C6, 0xFE231671 */
+  9.09088713343650656196e-02, /* 0x3FB745CD, 0xC54C206E */
+ -7.69187620504482999495e-02, /* 0xBFB3B0F2, 0xAF749A6D */
+  6.66107313738753120669e-02, /* 0x3FB10D66, 0xA0D03D51 */
+ -5.83357013379057348645e-02, /* 0xBFADDE2D, 0x52DEFD9A */
+  4.97687799461593236017e-02, /* 0x3FA97B4B, 0x24760DEB */
+ -3.65315727442169155270e-02, /* 0xBFA2B444, 0x2C6A6C2F */
+  1.62858201153657823623e-02, /* 0x3F90AD3A, 0xE322DA11 */
+};
+
+	static const double
+one   = 1.0,
+huge   = 1.0e300;
+
+double
+atan(double x)
+{
+	double w,s1,s2,z;
+	int32_t ix,hx,id;
+
+	GET_HIGH_WORD(hx,x);
+	ix = hx&0x7fffffff;
+	if(ix>=0x44100000) {	/* if |x| >= 2^66 */
+	    u_int32_t low;
+	    GET_LOW_WORD(low,x);
+	    if(ix>0x7ff00000||
+		(ix==0x7ff00000&&(low!=0)))
+		return x+x;		/* NaN */
+	    if(hx>0) return  atanhi[3]+*(volatile double *)&atanlo[3];
+	    else     return -atanhi[3]-*(volatile double *)&atanlo[3];
+	} if (ix < 0x3fdc0000) {	/* |x| < 0.4375 */
+	    if (ix < 0x3e400000) {	/* |x| < 2^-27 */
+		if(huge+x>one) return x;	/* raise inexact */
+	    }
+	    id = -1;
+	} else {
+	x = fabs(x);
+	if (ix < 0x3ff30000) {		/* |x| < 1.1875 */
+	    if (ix < 0x3fe60000) {	/* 7/16 <=|x|<11/16 */
+		id = 0; x = (2.0*x-one)/(2.0+x);
+	    } else {			/* 11/16<=|x|< 19/16 */
+		id = 1; x  = (x-one)/(x+one);
+	    }
+	} else {
+	    if (ix < 0x40038000) {	/* |x| < 2.4375 */
+		id = 2; x  = (x-1.5)/(one+1.5*x);
+	    } else {			/* 2.4375 <= |x| < 2^66 */
+		id = 3; x  = -1.0/x;
+	    }
+	}}
+    /* end of argument reduction */
+	z = x*x;
+	w = z*z;
+    /* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */
+	s1 = z*(aT[0]+w*(aT[2]+w*(aT[4]+w*(aT[6]+w*(aT[8]+w*aT[10])))));
+	s2 = w*(aT[1]+w*(aT[3]+w*(aT[5]+w*(aT[7]+w*aT[9]))));
+	if (id<0) return x - x*(s1+s2);
+	else {
+	    z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x);
+	    return (hx<0)? -z:z;
+	}
+}
+
+#if LDBL_MANT_DIG == 53
+__weak_reference(atan, atanl);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/s_atanf.c b/libm/upstream-freebsd/lib/msun/src/s_atanf.c
new file mode 100644
index 0000000..b3a371f
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_atanf.c
@@ -0,0 +1,92 @@
+/* s_atanf.c -- float version of s_atan.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static const float atanhi[] = {
+  4.6364760399e-01, /* atan(0.5)hi 0x3eed6338 */
+  7.8539812565e-01, /* atan(1.0)hi 0x3f490fda */
+  9.8279368877e-01, /* atan(1.5)hi 0x3f7b985e */
+  1.5707962513e+00, /* atan(inf)hi 0x3fc90fda */
+};
+
+static const float atanlo[] = {
+  5.0121582440e-09, /* atan(0.5)lo 0x31ac3769 */
+  3.7748947079e-08, /* atan(1.0)lo 0x33222168 */
+  3.4473217170e-08, /* atan(1.5)lo 0x33140fb4 */
+  7.5497894159e-08, /* atan(inf)lo 0x33a22168 */
+};
+
+static const float aT[] = {
+  3.3333328366e-01,
+ -1.9999158382e-01,
+  1.4253635705e-01,
+ -1.0648017377e-01,
+  6.1687607318e-02,
+};
+
+static const float
+one   = 1.0,
+huge   = 1.0e30;
+
+float
+atanf(float x)
+{
+	float w,s1,s2,z;
+	int32_t ix,hx,id;
+
+	GET_FLOAT_WORD(hx,x);
+	ix = hx&0x7fffffff;
+	if(ix>=0x4c800000) {	/* if |x| >= 2**26 */
+	    if(ix>0x7f800000)
+		return x+x;		/* NaN */
+	    if(hx>0) return  atanhi[3]+*(volatile float *)&atanlo[3];
+	    else     return -atanhi[3]-*(volatile float *)&atanlo[3];
+	} if (ix < 0x3ee00000) {	/* |x| < 0.4375 */
+	    if (ix < 0x39800000) {	/* |x| < 2**-12 */
+		if(huge+x>one) return x;	/* raise inexact */
+	    }
+	    id = -1;
+	} else {
+	x = fabsf(x);
+	if (ix < 0x3f980000) {		/* |x| < 1.1875 */
+	    if (ix < 0x3f300000) {	/* 7/16 <=|x|<11/16 */
+		id = 0; x = ((float)2.0*x-one)/((float)2.0+x);
+	    } else {			/* 11/16<=|x|< 19/16 */
+		id = 1; x  = (x-one)/(x+one);
+	    }
+	} else {
+	    if (ix < 0x401c0000) {	/* |x| < 2.4375 */
+		id = 2; x  = (x-(float)1.5)/(one+(float)1.5*x);
+	    } else {			/* 2.4375 <= |x| < 2**26 */
+		id = 3; x  = -(float)1.0/x;
+	    }
+	}}
+    /* end of argument reduction */
+	z = x*x;
+	w = z*z;
+    /* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */
+	s1 = z*(aT[0]+w*(aT[2]+w*aT[4]));
+	s2 = w*(aT[1]+w*aT[3]);
+	if (id<0) return x - x*(s1+s2);
+	else {
+	    z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x);
+	    return (hx<0)? -z:z;
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_atanl.c b/libm/upstream-freebsd/lib/msun/src/s_atanl.c
new file mode 100644
index 0000000..ff29c3c
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_atanl.c
@@ -0,0 +1,85 @@
+/* @(#)s_atan.c 5.1 93/09/24 */
+/* FreeBSD: head/lib/msun/src/s_atan.c 176451 2008-02-22 02:30:36Z das */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * See comments in s_atan.c.
+ * Converted to long double by David Schultz <das@FreeBSD.ORG>.
+ */
+
+#include <float.h>
+
+#include "invtrig.h"
+#include "math.h"
+#include "math_private.h"
+
+static const long double
+one   = 1.0,
+huge   = 1.0e300;
+
+long double
+atanl(long double x)
+{
+	union IEEEl2bits u;
+	long double w,s1,s2,z;
+	int id;
+	int16_t expsign, expt;
+	int32_t expman;
+
+	u.e = x;
+	expsign = u.xbits.expsign;
+	expt = expsign & 0x7fff;
+	if(expt >= ATAN_CONST) {	/* if |x| is large, atan(x)~=pi/2 */
+	    if(expt == BIAS + LDBL_MAX_EXP &&
+	       ((u.bits.manh&~LDBL_NBIT)|u.bits.manl)!=0)
+		return x+x;		/* NaN */
+	    if(expsign>0) return  atanhi[3]+atanlo[3];
+	    else     return -atanhi[3]-atanlo[3];
+	}
+	/* Extract the exponent and the first few bits of the mantissa. */
+	/* XXX There should be a more convenient way to do this. */
+	expman = (expt << 8) | ((u.bits.manh >> (MANH_SIZE - 9)) & 0xff);
+	if (expman < ((BIAS - 2) << 8) + 0xc0) {	/* |x| < 0.4375 */
+	    if (expt < ATAN_LINEAR) {	/* if |x| is small, atanl(x)~=x */
+		if(huge+x>one) return x;	/* raise inexact */
+	    }
+	    id = -1;
+	} else {
+	x = fabsl(x);
+	if (expman < (BIAS << 8) + 0x30) {		/* |x| < 1.1875 */
+	    if (expman < ((BIAS - 1) << 8) + 0x60) {	/* 7/16 <=|x|<11/16 */
+		id = 0; x = (2.0*x-one)/(2.0+x);
+	    } else {			/* 11/16<=|x|< 19/16 */
+		id = 1; x  = (x-one)/(x+one);
+	    }
+	} else {
+	    if (expman < ((BIAS + 1) << 8) + 0x38) {	/* |x| < 2.4375 */
+		id = 2; x  = (x-1.5)/(one+1.5*x);
+	    } else {			/* 2.4375 <= |x| < 2^ATAN_CONST */
+		id = 3; x  = -1.0/x;
+	    }
+	}}
+    /* end of argument reduction */
+	z = x*x;
+	w = z*z;
+    /* break sum aT[i]z**(i+1) into odd and even poly */
+	s1 = z*T_even(w);
+	s2 = w*T_odd(w);
+	if (id<0) return x - x*(s1+s2);
+	else {
+	    z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x);
+	    return (expsign<0)? -z:z;
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_carg.c b/libm/upstream-freebsd/lib/msun/src/s_carg.c
new file mode 100644
index 0000000..ea1a0d7
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_carg.c
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+double
+carg(double complex z)
+{
+
+	return (atan2(cimag(z), creal(z)));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cargf.c b/libm/upstream-freebsd/lib/msun/src/s_cargf.c
new file mode 100644
index 0000000..90232d0
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_cargf.c
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+float
+cargf(float complex z)
+{
+
+	return (atan2f(cimagf(z), crealf(z)));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cargl.c b/libm/upstream-freebsd/lib/msun/src/s_cargl.c
new file mode 100644
index 0000000..0555083
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_cargl.c
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2005-2008 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+long double
+cargl(long double complex z)
+{
+
+	return (atan2l(cimagl(z), creall(z)));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cbrt.c b/libm/upstream-freebsd/lib/msun/src/s_cbrt.c
new file mode 100644
index 0000000..910f75b
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_cbrt.c
@@ -0,0 +1,117 @@
+/* @(#)s_cbrt.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ * Optimized by Bruce D. Evans.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+/* cbrt(x)
+ * Return cube root of x
+ */
+static const u_int32_t
+	B1 = 715094163, /* B1 = (1023-1023/3-0.03306235651)*2**20 */
+	B2 = 696219795; /* B2 = (1023-1023/3-54/3-0.03306235651)*2**20 */
+
+/* |1/cbrt(x) - p(x)| < 2**-23.5 (~[-7.93e-8, 7.929e-8]). */
+static const double
+P0 =  1.87595182427177009643,		/* 0x3ffe03e6, 0x0f61e692 */
+P1 = -1.88497979543377169875,		/* 0xbffe28e0, 0x92f02420 */
+P2 =  1.621429720105354466140,		/* 0x3ff9f160, 0x4a49d6c2 */
+P3 = -0.758397934778766047437,		/* 0xbfe844cb, 0xbee751d9 */
+P4 =  0.145996192886612446982;		/* 0x3fc2b000, 0xd4e4edd7 */
+
+double
+cbrt(double x)
+{
+	int32_t	hx;
+	union {
+	    double value;
+	    uint64_t bits;
+	} u;
+	double r,s,t=0.0,w;
+	u_int32_t sign;
+	u_int32_t high,low;
+
+	EXTRACT_WORDS(hx,low,x);
+	sign=hx&0x80000000; 		/* sign= sign(x) */
+	hx  ^=sign;
+	if(hx>=0x7ff00000) return(x+x); /* cbrt(NaN,INF) is itself */
+
+    /*
+     * Rough cbrt to 5 bits:
+     *    cbrt(2**e*(1+m) ~= 2**(e/3)*(1+(e%3+m)/3)
+     * where e is integral and >= 0, m is real and in [0, 1), and "/" and
+     * "%" are integer division and modulus with rounding towards minus
+     * infinity.  The RHS is always >= the LHS and has a maximum relative
+     * error of about 1 in 16.  Adding a bias of -0.03306235651 to the
+     * (e%3+m)/3 term reduces the error to about 1 in 32. With the IEEE
+     * floating point representation, for finite positive normal values,
+     * ordinary integer divison of the value in bits magically gives
+     * almost exactly the RHS of the above provided we first subtract the
+     * exponent bias (1023 for doubles) and later add it back.  We do the
+     * subtraction virtually to keep e >= 0 so that ordinary integer
+     * division rounds towards minus infinity; this is also efficient.
+     */
+	if(hx<0x00100000) { 		/* zero or subnormal? */
+	    if((hx|low)==0)
+		return(x);		/* cbrt(0) is itself */
+	    SET_HIGH_WORD(t,0x43500000); /* set t= 2**54 */
+	    t*=x;
+	    GET_HIGH_WORD(high,t);
+	    INSERT_WORDS(t,sign|((high&0x7fffffff)/3+B2),0);
+	} else
+	    INSERT_WORDS(t,sign|(hx/3+B1),0);
+
+    /*
+     * New cbrt to 23 bits:
+     *    cbrt(x) = t*cbrt(x/t**3) ~= t*P(t**3/x)
+     * where P(r) is a polynomial of degree 4 that approximates 1/cbrt(r)
+     * to within 2**-23.5 when |r - 1| < 1/10.  The rough approximation
+     * has produced t such than |t/cbrt(x) - 1| ~< 1/32, and cubing this
+     * gives us bounds for r = t**3/x.
+     *
+     * Try to optimize for parallel evaluation as in k_tanf.c.
+     */
+	r=(t*t)*(t/x);
+	t=t*((P0+r*(P1+r*P2))+((r*r)*r)*(P3+r*P4));
+
+    /*
+     * Round t away from zero to 23 bits (sloppily except for ensuring that
+     * the result is larger in magnitude than cbrt(x) but not much more than
+     * 2 23-bit ulps larger).  With rounding towards zero, the error bound
+     * would be ~5/6 instead of ~4/6.  With a maximum error of 2 23-bit ulps
+     * in the rounded t, the infinite-precision error in the Newton
+     * approximation barely affects third digit in the final error
+     * 0.667; the error in the rounded t can be up to about 3 23-bit ulps
+     * before the final error is larger than 0.667 ulps.
+     */
+	u.value=t;
+	u.bits=(u.bits+0x80000000)&0xffffffffc0000000ULL;
+	t=u.value;
+
+    /* one step Newton iteration to 53 bits with error < 0.667 ulps */
+	s=t*t;				/* t*t is exact */
+	r=x/s;				/* error <= 0.5 ulps; |r| < |t| */
+	w=t+t;				/* t+t is exact */
+	r=(r-t)/(w+r);			/* r-t is exact; w+r ~= 3*t */
+	t=t+t*r;			/* error <= 0.5 + 0.5/3 + epsilon */
+
+	return(t);
+}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(cbrt, cbrtl);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cbrtf.c b/libm/upstream-freebsd/lib/msun/src/s_cbrtf.c
new file mode 100644
index 0000000..454f974
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_cbrtf.c
@@ -0,0 +1,73 @@
+/* s_cbrtf.c -- float version of s_cbrt.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ * Debugged and optimized by Bruce D. Evans.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+/* cbrtf(x)
+ * Return cube root of x
+ */
+static const unsigned
+	B1 = 709958130, /* B1 = (127-127.0/3-0.03306235651)*2**23 */
+	B2 = 642849266; /* B2 = (127-127.0/3-24/3-0.03306235651)*2**23 */
+
+float
+cbrtf(float x)
+{
+	double r,T;
+	float t;
+	int32_t hx;
+	u_int32_t sign;
+	u_int32_t high;
+
+	GET_FLOAT_WORD(hx,x);
+	sign=hx&0x80000000; 		/* sign= sign(x) */
+	hx  ^=sign;
+	if(hx>=0x7f800000) return(x+x); /* cbrt(NaN,INF) is itself */
+
+    /* rough cbrt to 5 bits */
+	if(hx<0x00800000) { 		/* zero or subnormal? */
+	    if(hx==0)
+		return(x);		/* cbrt(+-0) is itself */
+	    SET_FLOAT_WORD(t,0x4b800000); /* set t= 2**24 */
+	    t*=x;
+	    GET_FLOAT_WORD(high,t);
+	    SET_FLOAT_WORD(t,sign|((high&0x7fffffff)/3+B2));
+	} else
+	    SET_FLOAT_WORD(t,sign|(hx/3+B1));
+
+    /*
+     * First step Newton iteration (solving t*t-x/t == 0) to 16 bits.  In
+     * double precision so that its terms can be arranged for efficiency
+     * without causing overflow or underflow.
+     */
+	T=t;
+	r=T*T*T;
+	T=T*((double)x+x+r)/(x+r+r);
+
+    /*
+     * Second step Newton iteration to 47 bits.  In double precision for
+     * efficiency and accuracy.
+     */
+	r=T*T*T;
+	T=T*((double)x+x+r)/(x+r+r);
+
+    /* rounding to 24 bits is perfect in round-to-nearest mode */
+	return(T);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cbrtl.c b/libm/upstream-freebsd/lib/msun/src/s_cbrtl.c
new file mode 100644
index 0000000..2236c0f
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_cbrtl.c
@@ -0,0 +1,143 @@
+/*-
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2009-2011, Bruce D. Evans, Steven G. Kargl, David Schultz.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ * The argument reduction and testing for exceptional cases was
+ * written by Steven G. Kargl with input from Bruce D. Evans
+ * and David A. Schultz.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <float.h>
+#ifdef __i386__
+#include <ieeefp.h>
+#endif
+
+#include "fpmath.h"    
+#include "math.h"
+#include "math_private.h"
+
+#define	BIAS	(LDBL_MAX_EXP - 1)
+
+static const unsigned
+    B1 = 709958130;	/* B1 = (127-127.0/3-0.03306235651)*2**23 */
+
+long double
+cbrtl(long double x)
+{
+	union IEEEl2bits u, v;
+	long double r, s, t, w;
+	double dr, dt, dx;
+	float ft, fx;
+	uint32_t hx;
+	uint16_t expsign;
+	int k;
+
+	u.e = x;
+	expsign = u.xbits.expsign;
+	k = expsign & 0x7fff;
+
+	/*
+	 * If x = +-Inf, then cbrt(x) = +-Inf.
+	 * If x = NaN, then cbrt(x) = NaN.
+	 */
+	if (k == BIAS + LDBL_MAX_EXP)
+		return (x + x);
+
+	ENTERI();
+	if (k == 0) {
+		/* If x = +-0, then cbrt(x) = +-0. */
+		if ((u.bits.manh | u.bits.manl) == 0)
+			RETURNI(x);
+		/* Adjust subnormal numbers. */
+		u.e *= 0x1.0p514;
+		k = u.bits.exp;
+		k -= BIAS + 514;
+ 	} else
+		k -= BIAS;
+	u.xbits.expsign = BIAS;
+	v.e = 1; 
+
+	x = u.e;
+	switch (k % 3) {
+	case 1:
+	case -2:
+		x = 2*x;
+		k--;
+		break;
+	case 2:
+	case -1:
+		x = 4*x;
+		k -= 2;
+		break;
+	}
+	v.xbits.expsign = (expsign & 0x8000) | (BIAS + k / 3);
+
+	/*
+	 * The following is the guts of s_cbrtf, with the handling of
+	 * special values removed and extra care for accuracy not taken,
+	 * but with most of the extra accuracy not discarded.
+	 */
+
+	/* ~5-bit estimate: */
+	fx = x;
+	GET_FLOAT_WORD(hx, fx);
+	SET_FLOAT_WORD(ft, ((hx & 0x7fffffff) / 3 + B1));
+
+	/* ~16-bit estimate: */
+	dx = x;
+	dt = ft;
+	dr = dt * dt * dt;
+	dt = dt * (dx + dx + dr) / (dx + dr + dr);
+
+	/* ~47-bit estimate: */
+	dr = dt * dt * dt;
+	dt = dt * (dx + dx + dr) / (dx + dr + dr);
+
+#if LDBL_MANT_DIG == 64
+	/*
+	 * dt is cbrtl(x) to ~47 bits (after x has been reduced to 1 <= x < 8).
+	 * Round it away from zero to 32 bits (32 so that t*t is exact, and
+	 * away from zero for technical reasons).
+	 */
+	volatile double vd2 = 0x1.0p32;
+	volatile double vd1 = 0x1.0p-31;
+	#define vd ((long double)vd2 + vd1)
+
+	t = dt + vd - 0x1.0p32;
+#elif LDBL_MANT_DIG == 113
+	/*
+	 * Round dt away from zero to 47 bits.  Since we don't trust the 47,
+	 * add 2 47-bit ulps instead of 1 to round up.  Rounding is slow and
+	 * might be avoidable in this case, since on most machines dt will
+	 * have been evaluated in 53-bit precision and the technical reasons
+	 * for rounding up might not apply to either case in cbrtl() since
+	 * dt is much more accurate than needed.
+	 */
+	t = dt + 0x2.0p-46 + 0x1.0p60L - 0x1.0p60;
+#else
+#error "Unsupported long double format"
+#endif
+
+	/*
+     	 * Final step Newton iteration to 64 or 113 bits with
+	 * error < 0.667 ulps
+	 */
+	s=t*t;				/* t*t is exact */
+	r=x/s;				/* error <= 0.5 ulps; |r| < |t| */
+	w=t+t;				/* t+t is exact */
+	r=(r-t)/(w+r);			/* r-t is exact; w+r ~= 3*t */
+	t=t+t*r;			/* error <= 0.5 + 0.5/3 + epsilon */
+
+	t *= v.e;
+	RETURNI(t);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_ccosh.c b/libm/upstream-freebsd/lib/msun/src/s_ccosh.c
new file mode 100644
index 0000000..9ea962b
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_ccosh.c
@@ -0,0 +1,155 @@
+/*-
+ * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Hyperbolic cosine of a complex argument z = x + i y.
+ *
+ * cosh(z) = cosh(x+iy)
+ *         = cosh(x) cos(y) + i sinh(x) sin(y).
+ *
+ * Exceptional values are noted in the comments within the source code.
+ * These values and the return value were taken from n1124.pdf.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+static const double huge = 0x1p1023;
+
+double complex
+ccosh(double complex z)
+{
+	double x, y, h;
+	int32_t hx, hy, ix, iy, lx, ly;
+
+	x = creal(z);
+	y = cimag(z);
+
+	EXTRACT_WORDS(hx, lx, x);
+	EXTRACT_WORDS(hy, ly, y);
+
+	ix = 0x7fffffff & hx;
+	iy = 0x7fffffff & hy;
+
+	/* Handle the nearly-non-exceptional cases where x and y are finite. */
+	if (ix < 0x7ff00000 && iy < 0x7ff00000) {
+		if ((iy | ly) == 0)
+			return (cpack(cosh(x), x * y));
+		if (ix < 0x40360000)	/* small x: normal case */
+			return (cpack(cosh(x) * cos(y), sinh(x) * sin(y)));
+
+		/* |x| >= 22, so cosh(x) ~= exp(|x|) */
+		if (ix < 0x40862e42) {
+			/* x < 710: exp(|x|) won't overflow */
+			h = exp(fabs(x)) * 0.5;
+			return (cpack(h * cos(y), copysign(h, x) * sin(y)));
+		} else if (ix < 0x4096bbaa) {
+			/* x < 1455: scale to avoid overflow */
+			z = __ldexp_cexp(cpack(fabs(x), y), -1);
+			return (cpack(creal(z), cimag(z) * copysign(1, x)));
+		} else {
+			/* x >= 1455: the result always overflows */
+			h = huge * x;
+			return (cpack(h * h * cos(y), h * sin(y)));
+		}
+	}
+
+	/*
+	 * cosh(+-0 +- I Inf) = dNaN + I sign(d(+-0, dNaN))0.
+	 * The sign of 0 in the result is unspecified.  Choice = normally
+	 * the same as dNaN.  Raise the invalid floating-point exception.
+	 *
+	 * cosh(+-0 +- I NaN) = d(NaN) + I sign(d(+-0, NaN))0.
+	 * The sign of 0 in the result is unspecified.  Choice = normally
+	 * the same as d(NaN).
+	 */
+	if ((ix | lx) == 0 && iy >= 0x7ff00000)
+		return (cpack(y - y, copysign(0, x * (y - y))));
+
+	/*
+	 * cosh(+-Inf +- I 0) = +Inf + I (+-)(+-)0.
+	 *
+	 * cosh(NaN +- I 0)   = d(NaN) + I sign(d(NaN, +-0))0.
+	 * The sign of 0 in the result is unspecified.
+	 */
+	if ((iy | ly) == 0 && ix >= 0x7ff00000) {
+		if (((hx & 0xfffff) | lx) == 0)
+			return (cpack(x * x, copysign(0, x) * y));
+		return (cpack(x * x, copysign(0, (x + x) * y)));
+	}
+
+	/*
+	 * cosh(x +- I Inf) = dNaN + I dNaN.
+	 * Raise the invalid floating-point exception for finite nonzero x.
+	 *
+	 * cosh(x + I NaN) = d(NaN) + I d(NaN).
+	 * Optionally raises the invalid floating-point exception for finite
+	 * nonzero x.  Choice = don't raise (except for signaling NaNs).
+	 */
+	if (ix < 0x7ff00000 && iy >= 0x7ff00000)
+		return (cpack(y - y, x * (y - y)));
+
+	/*
+	 * cosh(+-Inf + I NaN)  = +Inf + I d(NaN).
+	 *
+	 * cosh(+-Inf +- I Inf) = +Inf + I dNaN.
+	 * The sign of Inf in the result is unspecified.  Choice = always +.
+	 * Raise the invalid floating-point exception.
+	 *
+	 * cosh(+-Inf + I y)   = +Inf cos(y) +- I Inf sin(y)
+	 */
+	if (ix >= 0x7ff00000 && ((hx & 0xfffff) | lx) == 0) {
+		if (iy >= 0x7ff00000)
+			return (cpack(x * x, x * (y - y)));
+		return (cpack((x * x) * cos(y), x * sin(y)));
+	}
+
+	/*
+	 * cosh(NaN + I NaN)  = d(NaN) + I d(NaN).
+	 *
+	 * cosh(NaN +- I Inf) = d(NaN) + I d(NaN).
+	 * Optionally raises the invalid floating-point exception.
+	 * Choice = raise.
+	 *
+	 * cosh(NaN + I y)    = d(NaN) + I d(NaN).
+	 * Optionally raises the invalid floating-point exception for finite
+	 * nonzero y.  Choice = don't raise (except for signaling NaNs).
+	 */
+	return (cpack((x * x) * (y - y), (x + x) * (y - y)));
+}
+
+double complex
+ccos(double complex z)
+{
+
+	/* ccos(z) = ccosh(I * z) */
+	return (ccosh(cpack(-cimag(z), creal(z))));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_ccoshf.c b/libm/upstream-freebsd/lib/msun/src/s_ccoshf.c
new file mode 100644
index 0000000..1de9ad4
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_ccoshf.c
@@ -0,0 +1,104 @@
+/*-
+ * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Hyperbolic cosine of a complex argument.  See s_ccosh.c for details.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+static const float huge = 0x1p127;
+
+float complex
+ccoshf(float complex z)
+{
+	float x, y, h;
+	int32_t hx, hy, ix, iy;
+
+	x = crealf(z);
+	y = cimagf(z);
+
+	GET_FLOAT_WORD(hx, x);
+	GET_FLOAT_WORD(hy, y);
+
+	ix = 0x7fffffff & hx;
+	iy = 0x7fffffff & hy;
+
+	if (ix < 0x7f800000 && iy < 0x7f800000) {
+		if (iy == 0)
+			return (cpackf(coshf(x), x * y));
+		if (ix < 0x41100000)	/* small x: normal case */
+			return (cpackf(coshf(x) * cosf(y), sinhf(x) * sinf(y)));
+
+		/* |x| >= 9, so cosh(x) ~= exp(|x|) */
+		if (ix < 0x42b17218) {
+			/* x < 88.7: expf(|x|) won't overflow */
+			h = expf(fabsf(x)) * 0.5f;
+			return (cpackf(h * cosf(y), copysignf(h, x) * sinf(y)));
+		} else if (ix < 0x4340b1e7) {
+			/* x < 192.7: scale to avoid overflow */
+			z = __ldexp_cexpf(cpackf(fabsf(x), y), -1);
+			return (cpackf(crealf(z), cimagf(z) * copysignf(1, x)));
+		} else {
+			/* x >= 192.7: the result always overflows */
+			h = huge * x;
+			return (cpackf(h * h * cosf(y), h * sinf(y)));
+		}
+	}
+
+	if (ix == 0 && iy >= 0x7f800000)
+		return (cpackf(y - y, copysignf(0, x * (y - y))));
+
+	if (iy == 0 && ix >= 0x7f800000) {
+		if ((hx & 0x7fffff) == 0)
+			return (cpackf(x * x, copysignf(0, x) * y));
+		return (cpackf(x * x, copysignf(0, (x + x) * y)));
+	}
+
+	if (ix < 0x7f800000 && iy >= 0x7f800000)
+		return (cpackf(y - y, x * (y - y)));
+
+	if (ix >= 0x7f800000 && (hx & 0x7fffff) == 0) {
+		if (iy >= 0x7f800000)
+			return (cpackf(x * x, x * (y - y)));
+		return (cpackf((x * x) * cosf(y), x * sinf(y)));
+	}
+
+	return (cpackf((x * x) * (y - y), (x + x) * (y - y)));
+}
+
+float complex
+ccosf(float complex z)
+{
+
+	return (ccoshf(cpackf(-cimagf(z), crealf(z))));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_ceil.c b/libm/upstream-freebsd/lib/msun/src/s_ceil.c
new file mode 100644
index 0000000..929f813
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_ceil.c
@@ -0,0 +1,77 @@
+/* @(#)s_ceil.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * ceil(x)
+ * Return x rounded toward -inf to integral value
+ * Method:
+ *	Bit twiddling.
+ * Exception:
+ *	Inexact flag raised if x not equal to ceil(x).
+ */
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const double huge = 1.0e300;
+
+double
+ceil(double x)
+{
+	int32_t i0,i1,j0;
+	u_int32_t i,j;
+	EXTRACT_WORDS(i0,i1,x);
+	j0 = ((i0>>20)&0x7ff)-0x3ff;
+	if(j0<20) {
+	    if(j0<0) { 	/* raise inexact if x != 0 */
+		if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */
+		    if(i0<0) {i0=0x80000000;i1=0;}
+		    else if((i0|i1)!=0) { i0=0x3ff00000;i1=0;}
+		}
+	    } else {
+		i = (0x000fffff)>>j0;
+		if(((i0&i)|i1)==0) return x; /* x is integral */
+		if(huge+x>0.0) {	/* raise inexact flag */
+		    if(i0>0) i0 += (0x00100000)>>j0;
+		    i0 &= (~i); i1=0;
+		}
+	    }
+	} else if (j0>51) {
+	    if(j0==0x400) return x+x;	/* inf or NaN */
+	    else return x;		/* x is integral */
+	} else {
+	    i = ((u_int32_t)(0xffffffff))>>(j0-20);
+	    if((i1&i)==0) return x;	/* x is integral */
+	    if(huge+x>0.0) { 		/* raise inexact flag */
+		if(i0>0) {
+		    if(j0==20) i0+=1;
+		    else {
+			j = i1 + (1<<(52-j0));
+			if(j<i1) i0+=1;	/* got a carry */
+			i1 = j;
+		    }
+		}
+		i1 &= (~i);
+	    }
+	}
+	INSERT_WORDS(x,i0,i1);
+	return x;
+}
+
+#if LDBL_MANT_DIG == 53
+__weak_reference(ceil, ceill);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/s_ceilf.c b/libm/upstream-freebsd/lib/msun/src/s_ceilf.c
new file mode 100644
index 0000000..23bfe04
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_ceilf.c
@@ -0,0 +1,52 @@
+/* s_ceilf.c -- float version of s_ceil.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static const float huge = 1.0e30;
+
+float
+ceilf(float x)
+{
+	int32_t i0,j0;
+	u_int32_t i;
+
+	GET_FLOAT_WORD(i0,x);
+	j0 = ((i0>>23)&0xff)-0x7f;
+	if(j0<23) {
+	    if(j0<0) { 	/* raise inexact if x != 0 */
+		if(huge+x>(float)0.0) {/* return 0*sign(x) if |x|<1 */
+		    if(i0<0) {i0=0x80000000;}
+		    else if(i0!=0) { i0=0x3f800000;}
+		}
+	    } else {
+		i = (0x007fffff)>>j0;
+		if((i0&i)==0) return x; /* x is integral */
+		if(huge+x>(float)0.0) {	/* raise inexact flag */
+		    if(i0>0) i0 += (0x00800000)>>j0;
+		    i0 &= (~i);
+		}
+	    }
+	} else {
+	    if(j0==0x80) return x+x;	/* inf or NaN */
+	    else return x;		/* x is integral */
+	}
+	SET_FLOAT_WORD(x,i0);
+	return x;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_ceill.c b/libm/upstream-freebsd/lib/msun/src/s_ceill.c
new file mode 100644
index 0000000..2d1045f
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_ceill.c
@@ -0,0 +1,101 @@
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ * From: @(#)s_ceil.c 5.1 93/09/24
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * ceill(x)
+ * Return x rounded toward -inf to integral value
+ * Method:
+ *	Bit twiddling.
+ * Exception:
+ *	Inexact flag raised if x not equal to ceill(x).
+ */
+
+#include <float.h>
+#include <math.h>
+#include <stdint.h>
+
+#include "fpmath.h"
+
+#ifdef LDBL_IMPLICIT_NBIT
+#define	MANH_SIZE	(LDBL_MANH_SIZE + 1)
+#define	INC_MANH(u, c)	do {					\
+	uint64_t o = u.bits.manh;				\
+	u.bits.manh += (c);					\
+	if (u.bits.manh < o)					\
+		u.bits.exp++;					\
+} while (0)
+#else
+#define	MANH_SIZE	LDBL_MANH_SIZE
+#define	INC_MANH(u, c)	do {					\
+	uint64_t o = u.bits.manh;				\
+	u.bits.manh += (c);					\
+	if (u.bits.manh < o) {					\
+		u.bits.exp++;					\
+		u.bits.manh |= 1llu << (LDBL_MANH_SIZE - 1);	\
+	}							\
+} while (0)
+#endif
+
+static const long double huge = 1.0e300;
+
+long double
+ceill(long double x)
+{
+	union IEEEl2bits u = { .e = x };
+	int e = u.bits.exp - LDBL_MAX_EXP + 1;
+
+	if (e < MANH_SIZE - 1) {
+		if (e < 0) {			/* raise inexact if x != 0 */
+			if (huge + x > 0.0)
+				if (u.bits.exp > 0 ||
+				    (u.bits.manh | u.bits.manl) != 0)
+					u.e = u.bits.sign ? -0.0 : 1.0;
+		} else {
+			uint64_t m = ((1llu << MANH_SIZE) - 1) >> (e + 1);
+			if (((u.bits.manh & m) | u.bits.manl) == 0)
+				return (x);	/* x is integral */
+			if (!u.bits.sign) {
+#ifdef LDBL_IMPLICIT_NBIT
+				if (e == 0)
+					u.bits.exp++;
+				else
+#endif
+				INC_MANH(u, 1llu << (MANH_SIZE - e - 1));
+			}
+			if (huge + x > 0.0) {	/* raise inexact flag */
+				u.bits.manh &= ~m;
+				u.bits.manl = 0;
+			}
+		}
+	} else if (e < LDBL_MANT_DIG - 1) {
+		uint64_t m = (uint64_t)-1 >> (64 - LDBL_MANT_DIG + e + 1);
+		if ((u.bits.manl & m) == 0)
+			return (x);	/* x is integral */
+		if (!u.bits.sign) {
+			if (e == MANH_SIZE - 1)
+				INC_MANH(u, 1);
+			else {
+				uint64_t o = u.bits.manl;
+				u.bits.manl += 1llu << (LDBL_MANT_DIG - e - 1);
+				if (u.bits.manl < o)	/* got a carry */
+					INC_MANH(u, 1);
+			}
+		}
+		if (huge + x > 0.0)		/* raise inexact flag */
+			u.bits.manl &= ~m;
+	}
+	return (u.e);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cexp.c b/libm/upstream-freebsd/lib/msun/src/s_cexp.c
new file mode 100644
index 0000000..abe178f
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_cexp.c
@@ -0,0 +1,89 @@
+/*-
+ * Copyright (c) 2011 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+static const uint32_t
+exp_ovfl  = 0x40862e42,			/* high bits of MAX_EXP * ln2 ~= 710 */
+cexp_ovfl = 0x4096b8e4;			/* (MAX_EXP - MIN_DENORM_EXP) * ln2 */
+
+double complex
+cexp(double complex z)
+{
+	double x, y, exp_x;
+	uint32_t hx, hy, lx, ly;
+
+	x = creal(z);
+	y = cimag(z);
+
+	EXTRACT_WORDS(hy, ly, y);
+	hy &= 0x7fffffff;
+
+	/* cexp(x + I 0) = exp(x) + I 0 */
+	if ((hy | ly) == 0)
+		return (cpack(exp(x), y));
+	EXTRACT_WORDS(hx, lx, x);
+	/* cexp(0 + I y) = cos(y) + I sin(y) */
+	if (((hx & 0x7fffffff) | lx) == 0)
+		return (cpack(cos(y), sin(y)));
+
+	if (hy >= 0x7ff00000) {
+		if (lx != 0 || (hx & 0x7fffffff) != 0x7ff00000) {
+			/* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */
+			return (cpack(y - y, y - y));
+		} else if (hx & 0x80000000) {
+			/* cexp(-Inf +- I Inf|NaN) = 0 + I 0 */
+			return (cpack(0.0, 0.0));
+		} else {
+			/* cexp(+Inf +- I Inf|NaN) = Inf + I NaN */
+			return (cpack(x, y - y));
+		}
+	}
+
+	if (hx >= exp_ovfl && hx <= cexp_ovfl) {
+		/*
+		 * x is between 709.7 and 1454.3, so we must scale to avoid
+		 * overflow in exp(x).
+		 */
+		return (__ldexp_cexp(z, 0));
+	} else {
+		/*
+		 * Cases covered here:
+		 *  -  x < exp_ovfl and exp(x) won't overflow (common case)
+		 *  -  x > cexp_ovfl, so exp(x) * s overflows for all s > 0
+		 *  -  x = +-Inf (generated by exp())
+		 *  -  x = NaN (spurious inexact exception from y)
+		 */
+		exp_x = exp(x);
+		return (cpack(exp_x * cos(y), exp_x * sin(y)));
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cexpf.c b/libm/upstream-freebsd/lib/msun/src/s_cexpf.c
new file mode 100644
index 0000000..0e30d08
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_cexpf.c
@@ -0,0 +1,89 @@
+/*-
+ * Copyright (c) 2011 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+static const uint32_t
+exp_ovfl  = 0x42b17218,		/* MAX_EXP * ln2 ~= 88.722839355 */
+cexp_ovfl = 0x43400074;		/* (MAX_EXP - MIN_DENORM_EXP) * ln2 */
+
+float complex
+cexpf(float complex z)
+{
+	float x, y, exp_x;
+	uint32_t hx, hy;
+
+	x = crealf(z);
+	y = cimagf(z);
+
+	GET_FLOAT_WORD(hy, y);
+	hy &= 0x7fffffff;
+
+	/* cexp(x + I 0) = exp(x) + I 0 */
+	if (hy == 0)
+		return (cpackf(expf(x), y));
+	GET_FLOAT_WORD(hx, x);
+	/* cexp(0 + I y) = cos(y) + I sin(y) */
+	if ((hx & 0x7fffffff) == 0)
+		return (cpackf(cosf(y), sinf(y)));
+
+	if (hy >= 0x7f800000) {
+		if ((hx & 0x7fffffff) != 0x7f800000) {
+			/* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */
+			return (cpackf(y - y, y - y));
+		} else if (hx & 0x80000000) {
+			/* cexp(-Inf +- I Inf|NaN) = 0 + I 0 */
+			return (cpackf(0.0, 0.0));
+		} else {
+			/* cexp(+Inf +- I Inf|NaN) = Inf + I NaN */
+			return (cpackf(x, y - y));
+		}
+	}
+
+	if (hx >= exp_ovfl && hx <= cexp_ovfl) {
+		/*
+		 * x is between 88.7 and 192, so we must scale to avoid
+		 * overflow in expf(x).
+		 */
+		return (__ldexp_cexpf(z, 0));
+	} else {
+		/*
+		 * Cases covered here:
+		 *  -  x < exp_ovfl and exp(x) won't overflow (common case)
+		 *  -  x > cexp_ovfl, so exp(x) * s overflows for all s > 0
+		 *  -  x = +-Inf (generated by exp())
+		 *  -  x = NaN (spurious inexact exception from y)
+		 */
+		exp_x = expf(x);
+		return (cpackf(exp_x * cosf(y), exp_x * sinf(y)));
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cimag.c b/libm/upstream-freebsd/lib/msun/src/s_cimag.c
new file mode 100644
index 0000000..cbf6720
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_cimag.c
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2004 Stefan Farfeleder
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <complex.h>
+#include "math_private.h"
+
+double
+cimag(double complex z)
+{
+	const double_complex z1 = { .f = z };
+
+	return (IMAGPART(z1));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cimagf.c b/libm/upstream-freebsd/lib/msun/src/s_cimagf.c
new file mode 100644
index 0000000..4e483a2
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_cimagf.c
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2004 Stefan Farfeleder
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <complex.h>
+#include "math_private.h"
+
+float
+cimagf(float complex z)
+{
+	const float_complex z1 = { .f = z };
+
+	return (IMAGPART(z1));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cimagl.c b/libm/upstream-freebsd/lib/msun/src/s_cimagl.c
new file mode 100644
index 0000000..c50e967
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_cimagl.c
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2004 Stefan Farfeleder
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <complex.h>
+#include "math_private.h"
+
+long double
+cimagl(long double complex z)
+{
+	const long_double_complex z1 = { .f = z };
+
+	return (IMAGPART(z1));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_conj.c b/libm/upstream-freebsd/lib/msun/src/s_conj.c
new file mode 100644
index 0000000..5770c29
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_conj.c
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2004 Stefan Farfeleder
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <complex.h>
+
+#include "math_private.h"
+
+double complex
+conj(double complex z)
+{
+
+	return (cpack(creal(z), -cimag(z)));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_conjf.c b/libm/upstream-freebsd/lib/msun/src/s_conjf.c
new file mode 100644
index 0000000..b090760
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_conjf.c
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2004 Stefan Farfeleder
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <complex.h>
+
+#include "math_private.h"
+
+float complex
+conjf(float complex z)
+{
+
+	return (cpackf(crealf(z), -cimagf(z)));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_conjl.c b/libm/upstream-freebsd/lib/msun/src/s_conjl.c
new file mode 100644
index 0000000..0e431ef
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_conjl.c
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2004 Stefan Farfeleder
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <complex.h>
+
+#include "math_private.h"
+
+long double complex
+conjl(long double complex z)
+{
+
+	return (cpackl(creall(z), -cimagl(z)));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_copysign.c b/libm/upstream-freebsd/lib/msun/src/s_copysign.c
new file mode 100644
index 0000000..a5f3870
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_copysign.c
@@ -0,0 +1,33 @@
+/* @(#)s_copysign.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * copysign(double x, double y)
+ * copysign(x,y) returns a value with the magnitude of x and
+ * with the sign bit of y.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+double
+copysign(double x, double y)
+{
+	u_int32_t hx,hy;
+	GET_HIGH_WORD(hx,x);
+	GET_HIGH_WORD(hy,y);
+	SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000));
+        return x;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_copysignf.c b/libm/upstream-freebsd/lib/msun/src/s_copysignf.c
new file mode 100644
index 0000000..05ca1e3
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_copysignf.c
@@ -0,0 +1,36 @@
+/* s_copysignf.c -- float version of s_copysign.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * copysignf(float x, float y)
+ * copysignf(x,y) returns a value with the magnitude of x and
+ * with the sign bit of y.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+float
+copysignf(float x, float y)
+{
+	u_int32_t ix,iy;
+	GET_FLOAT_WORD(ix,x);
+	GET_FLOAT_WORD(iy,y);
+	SET_FLOAT_WORD(x,(ix&0x7fffffff)|(iy&0x80000000));
+        return x;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_copysignl.c b/libm/upstream-freebsd/lib/msun/src/s_copysignl.c
new file mode 100644
index 0000000..8d39f84
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_copysignl.c
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 2004 Stefan Farfeleder
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <math.h>
+
+#include "fpmath.h"
+
+long double
+copysignl(long double x, long double y)
+{
+	union IEEEl2bits ux, uy;
+
+	ux.e = x;
+	uy.e = y;
+	ux.bits.sign = uy.bits.sign;
+	return (ux.e);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cos.c b/libm/upstream-freebsd/lib/msun/src/s_cos.c
new file mode 100644
index 0000000..29804f4
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_cos.c
@@ -0,0 +1,89 @@
+/* @(#)s_cos.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* cos(x)
+ * Return cosine function of x.
+ *
+ * kernel function:
+ *	__kernel_sin		... sine function on [-pi/4,pi/4]
+ *	__kernel_cos		... cosine function on [-pi/4,pi/4]
+ *	__ieee754_rem_pio2	... argument reduction routine
+ *
+ * Method.
+ *      Let S,C and T denote the sin, cos and tan respectively on
+ *	[-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
+ *	in [-pi/4 , +pi/4], and let n = k mod 4.
+ *	We have
+ *
+ *          n        sin(x)      cos(x)        tan(x)
+ *     ----------------------------------------------------------
+ *	    0	       S	   C		 T
+ *	    1	       C	  -S		-1/T
+ *	    2	      -S	  -C		 T
+ *	    3	      -C	   S		-1/T
+ *     ----------------------------------------------------------
+ *
+ * Special cases:
+ *      Let trig be any of sin, cos, or tan.
+ *      trig(+-INF)  is NaN, with signals;
+ *      trig(NaN)    is that NaN;
+ *
+ * Accuracy:
+ *	TRIG(x) returns trig(x) nearly rounded
+ */
+
+#include <float.h>
+
+#include "math.h"
+#define INLINE_REM_PIO2
+#include "math_private.h"
+#include "e_rem_pio2.c"
+
+double
+cos(double x)
+{
+	double y[2],z=0.0;
+	int32_t n, ix;
+
+    /* High word of x. */
+	GET_HIGH_WORD(ix,x);
+
+    /* |x| ~< pi/4 */
+	ix &= 0x7fffffff;
+	if(ix <= 0x3fe921fb) {
+	    if(ix<0x3e46a09e)			/* if x < 2**-27 * sqrt(2) */
+		if(((int)x)==0) return 1.0;	/* generate inexact */
+	    return __kernel_cos(x,z);
+	}
+
+    /* cos(Inf or NaN) is NaN */
+	else if (ix>=0x7ff00000) return x-x;
+
+    /* argument reduction needed */
+	else {
+	    n = __ieee754_rem_pio2(x,y);
+	    switch(n&3) {
+		case 0: return  __kernel_cos(y[0],y[1]);
+		case 1: return -__kernel_sin(y[0],y[1],1);
+		case 2: return -__kernel_cos(y[0],y[1]);
+		default:
+		        return  __kernel_sin(y[0],y[1],1);
+	    }
+	}
+}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(cos, cosl);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cosf.c b/libm/upstream-freebsd/lib/msun/src/s_cosf.c
new file mode 100644
index 0000000..b701fd2
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_cosf.c
@@ -0,0 +1,87 @@
+/* s_cosf.c -- float version of s_cos.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ * Optimized by Bruce D. Evans.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <float.h>
+
+#include "math.h"
+#define	INLINE_KERNEL_COSDF
+#define	INLINE_KERNEL_SINDF
+#define INLINE_REM_PIO2F
+#include "math_private.h"
+#include "e_rem_pio2f.c"
+#include "k_cosf.c"
+#include "k_sinf.c"
+
+/* Small multiples of pi/2 rounded to double precision. */
+static const double
+c1pio2 = 1*M_PI_2,			/* 0x3FF921FB, 0x54442D18 */
+c2pio2 = 2*M_PI_2,			/* 0x400921FB, 0x54442D18 */
+c3pio2 = 3*M_PI_2,			/* 0x4012D97C, 0x7F3321D2 */
+c4pio2 = 4*M_PI_2;			/* 0x401921FB, 0x54442D18 */
+
+float
+cosf(float x)
+{
+	double y;
+	int32_t n, hx, ix;
+
+	GET_FLOAT_WORD(hx,x);
+	ix = hx & 0x7fffffff;
+
+	if(ix <= 0x3f490fda) {		/* |x| ~<= pi/4 */
+	    if(ix<0x39800000)		/* |x| < 2**-12 */
+		if(((int)x)==0) return 1.0;	/* 1 with inexact if x != 0 */
+	    return __kernel_cosdf(x);
+	}
+	if(ix<=0x407b53d1) {		/* |x| ~<= 5*pi/4 */
+	    if(ix>0x4016cbe3)		/* |x|  ~> 3*pi/4 */
+		return -__kernel_cosdf(x + (hx > 0 ? -c2pio2 : c2pio2));
+	    else {
+		if(hx>0)
+		    return __kernel_sindf(c1pio2 - x);
+		else
+		    return __kernel_sindf(x + c1pio2);
+	    }
+	}
+	if(ix<=0x40e231d5) {		/* |x| ~<= 9*pi/4 */
+	    if(ix>0x40afeddf)		/* |x|  ~> 7*pi/4 */
+		return __kernel_cosdf(x + (hx > 0 ? -c4pio2 : c4pio2));
+	    else {
+		if(hx>0)
+		    return __kernel_sindf(x - c3pio2);
+		else
+		    return __kernel_sindf(-c3pio2 - x);
+	    }
+	}
+
+    /* cos(Inf or NaN) is NaN */
+	else if (ix>=0x7f800000) return x-x;
+
+    /* general argument reduction needed */
+	else {
+	    n = __ieee754_rem_pio2f(x,&y);
+	    switch(n&3) {
+		case 0: return  __kernel_cosdf(y);
+		case 1: return  __kernel_sindf(-y);
+		case 2: return -__kernel_cosdf(y);
+		default:
+		        return  __kernel_sindf(y);
+	    }
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cosl.c b/libm/upstream-freebsd/lib/msun/src/s_cosl.c
new file mode 100644
index 0000000..22e74cf
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_cosl.c
@@ -0,0 +1,95 @@
+/*-
+ * Copyright (c) 2007 Steven G. Kargl
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * Limited testing on pseudorandom numbers drawn within [-2e8:4e8] shows
+ * an accuracy of <= 0.7412 ULP.
+ */
+
+#include <float.h>
+#ifdef __i386__
+#include <ieeefp.h>
+#endif
+
+#include "math.h"
+#include "math_private.h"
+#if LDBL_MANT_DIG == 64
+#include "../ld80/e_rem_pio2l.h"
+#elif LDBL_MANT_DIG == 113
+#include "../ld128/e_rem_pio2l.h"
+#else
+#error "Unsupported long double format"
+#endif
+
+long double
+cosl(long double x)
+{
+	union IEEEl2bits z;
+	int e0;
+	long double y[2];
+	long double hi, lo;
+
+	z.e = x;
+	z.bits.sign = 0;
+
+	/* If x = +-0 or x is a subnormal number, then cos(x) = 1 */
+	if (z.bits.exp == 0)
+		return (1.0);
+
+	/* If x = NaN or Inf, then cos(x) = NaN. */
+	if (z.bits.exp == 32767)
+		return ((x - x) / (x - x));
+
+	ENTERI();
+
+	/* Optimize the case where x is already within range. */
+	if (z.e < M_PI_4)
+		RETURNI(__kernel_cosl(z.e, 0));
+
+	e0 = __ieee754_rem_pio2l(x, y);
+	hi = y[0];
+	lo = y[1];
+
+	switch (e0 & 3) {
+	case 0:
+	    hi = __kernel_cosl(hi, lo);
+	    break;
+	case 1:
+	    hi = - __kernel_sinl(hi, lo, 1);
+	    break;
+	case 2:
+	    hi = - __kernel_cosl(hi, lo);
+	    break;
+	case 3:
+	    hi = __kernel_sinl(hi, lo, 1);
+	    break;
+	}
+	
+	RETURNI(hi);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cproj.c b/libm/upstream-freebsd/lib/msun/src/s_cproj.c
new file mode 100644
index 0000000..8e9404c
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_cproj.c
@@ -0,0 +1,47 @@
+/*-
+ * Copyright (c) 2008 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+double complex
+cproj(double complex z)
+{
+
+	if (!isinf(creal(z)) && !isinf(cimag(z)))
+		return (z);
+	else
+		return (cpack(INFINITY, copysign(0.0, cimag(z))));
+}
+
+#if LDBL_MANT_DIG == 53
+__weak_reference(cproj, cprojl);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cprojf.c b/libm/upstream-freebsd/lib/msun/src/s_cprojf.c
new file mode 100644
index 0000000..68ea77b
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_cprojf.c
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2008 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+float complex
+cprojf(float complex z)
+{
+
+	if (!isinf(crealf(z)) && !isinf(cimagf(z)))
+		return (z);
+	else
+		return (cpackf(INFINITY, copysignf(0.0, cimagf(z))));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cprojl.c b/libm/upstream-freebsd/lib/msun/src/s_cprojl.c
new file mode 100644
index 0000000..07385bc
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_cprojl.c
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2008 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+long double complex
+cprojl(long double complex z)
+{
+
+	if (!isinf(creall(z)) && !isinf(cimagl(z)))
+		return (z);
+	else
+		return (cpackl(INFINITY, copysignl(0.0, cimagl(z))));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_creal.c b/libm/upstream-freebsd/lib/msun/src/s_creal.c
new file mode 100644
index 0000000..3295ff2
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_creal.c
@@ -0,0 +1,35 @@
+/*-
+ * Copyright (c) 2004 Stefan Farfeleder
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <complex.h>
+
+double
+creal(double complex z)
+{
+	return z;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_crealf.c b/libm/upstream-freebsd/lib/msun/src/s_crealf.c
new file mode 100644
index 0000000..5819b86
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_crealf.c
@@ -0,0 +1,35 @@
+/*-
+ * Copyright (c) 2004 Stefan Farfeleder
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <complex.h>
+
+float
+crealf(float complex z)
+{
+	return z;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_creall.c b/libm/upstream-freebsd/lib/msun/src/s_creall.c
new file mode 100644
index 0000000..e4946f9
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_creall.c
@@ -0,0 +1,35 @@
+/*-
+ * Copyright (c) 2004 Stefan Farfeleder
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <complex.h>
+
+long double
+creall(long double complex z)
+{
+	return z;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_csinh.c b/libm/upstream-freebsd/lib/msun/src/s_csinh.c
new file mode 100644
index 0000000..c192f30
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_csinh.c
@@ -0,0 +1,157 @@
+/*-
+ * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Hyperbolic sine of a complex argument z = x + i y.
+ *
+ * sinh(z) = sinh(x+iy)
+ *         = sinh(x) cos(y) + i cosh(x) sin(y).
+ *
+ * Exceptional values are noted in the comments within the source code.
+ * These values and the return value were taken from n1124.pdf.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+static const double huge = 0x1p1023;
+
+double complex
+csinh(double complex z)
+{
+	double x, y, h;
+	int32_t hx, hy, ix, iy, lx, ly;
+
+	x = creal(z);
+	y = cimag(z);
+
+	EXTRACT_WORDS(hx, lx, x);
+	EXTRACT_WORDS(hy, ly, y);
+
+	ix = 0x7fffffff & hx;
+	iy = 0x7fffffff & hy;
+
+	/* Handle the nearly-non-exceptional cases where x and y are finite. */
+	if (ix < 0x7ff00000 && iy < 0x7ff00000) {
+		if ((iy | ly) == 0)
+			return (cpack(sinh(x), y));
+		if (ix < 0x40360000)	/* small x: normal case */
+			return (cpack(sinh(x) * cos(y), cosh(x) * sin(y)));
+
+		/* |x| >= 22, so cosh(x) ~= exp(|x|) */
+		if (ix < 0x40862e42) {
+			/* x < 710: exp(|x|) won't overflow */
+			h = exp(fabs(x)) * 0.5;
+			return (cpack(copysign(h, x) * cos(y), h * sin(y)));
+		} else if (ix < 0x4096bbaa) {
+			/* x < 1455: scale to avoid overflow */
+			z = __ldexp_cexp(cpack(fabs(x), y), -1);
+			return (cpack(creal(z) * copysign(1, x), cimag(z)));
+		} else {
+			/* x >= 1455: the result always overflows */
+			h = huge * x;
+			return (cpack(h * cos(y), h * h * sin(y)));
+		}
+	}
+
+	/*
+	 * sinh(+-0 +- I Inf) = sign(d(+-0, dNaN))0 + I dNaN.
+	 * The sign of 0 in the result is unspecified.  Choice = normally
+	 * the same as dNaN.  Raise the invalid floating-point exception.
+	 *
+	 * sinh(+-0 +- I NaN) = sign(d(+-0, NaN))0 + I d(NaN).
+	 * The sign of 0 in the result is unspecified.  Choice = normally
+	 * the same as d(NaN).
+	 */
+	if ((ix | lx) == 0 && iy >= 0x7ff00000)
+		return (cpack(copysign(0, x * (y - y)), y - y));
+
+	/*
+	 * sinh(+-Inf +- I 0) = +-Inf + I +-0.
+	 *
+	 * sinh(NaN +- I 0)   = d(NaN) + I +-0.
+	 */
+	if ((iy | ly) == 0 && ix >= 0x7ff00000) {
+		if (((hx & 0xfffff) | lx) == 0)
+			return (cpack(x, y));
+		return (cpack(x, copysign(0, y)));
+	}
+
+	/*
+	 * sinh(x +- I Inf) = dNaN + I dNaN.
+	 * Raise the invalid floating-point exception for finite nonzero x.
+	 *
+	 * sinh(x + I NaN) = d(NaN) + I d(NaN).
+	 * Optionally raises the invalid floating-point exception for finite
+	 * nonzero x.  Choice = don't raise (except for signaling NaNs).
+	 */
+	if (ix < 0x7ff00000 && iy >= 0x7ff00000)
+		return (cpack(y - y, x * (y - y)));
+
+	/*
+	 * sinh(+-Inf + I NaN)  = +-Inf + I d(NaN).
+	 * The sign of Inf in the result is unspecified.  Choice = normally
+	 * the same as d(NaN).
+	 *
+	 * sinh(+-Inf +- I Inf) = +Inf + I dNaN.
+	 * The sign of Inf in the result is unspecified.  Choice = always +.
+	 * Raise the invalid floating-point exception.
+	 *
+	 * sinh(+-Inf + I y)   = +-Inf cos(y) + I Inf sin(y)
+	 */
+	if (ix >= 0x7ff00000 && ((hx & 0xfffff) | lx) == 0) {
+		if (iy >= 0x7ff00000)
+			return (cpack(x * x, x * (y - y)));
+		return (cpack(x * cos(y), INFINITY * sin(y)));
+	}
+
+	/*
+	 * sinh(NaN + I NaN)  = d(NaN) + I d(NaN).
+	 *
+	 * sinh(NaN +- I Inf) = d(NaN) + I d(NaN).
+	 * Optionally raises the invalid floating-point exception.
+	 * Choice = raise.
+	 *
+	 * sinh(NaN + I y)    = d(NaN) + I d(NaN).
+	 * Optionally raises the invalid floating-point exception for finite
+	 * nonzero y.  Choice = don't raise (except for signaling NaNs).
+	 */
+	return (cpack((x * x) * (y - y), (x + x) * (y - y)));
+}
+
+double complex
+csin(double complex z)
+{
+
+	/* csin(z) = -I * csinh(I * z) */
+	z = csinh(cpack(-cimag(z), creal(z)));
+	return (cpack(cimag(z), -creal(z)));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_csinhf.c b/libm/upstream-freebsd/lib/msun/src/s_csinhf.c
new file mode 100644
index 0000000..c523125
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_csinhf.c
@@ -0,0 +1,105 @@
+/*-
+ * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Hyperbolic sine of a complex argument z.  See s_csinh.c for details.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+static const float huge = 0x1p127;
+
+float complex
+csinhf(float complex z)
+{
+	float x, y, h;
+	int32_t hx, hy, ix, iy;
+
+	x = crealf(z);
+	y = cimagf(z);
+
+	GET_FLOAT_WORD(hx, x);
+	GET_FLOAT_WORD(hy, y);
+
+	ix = 0x7fffffff & hx;
+	iy = 0x7fffffff & hy;
+
+	if (ix < 0x7f800000 && iy < 0x7f800000) {
+		if (iy == 0)
+			return (cpackf(sinhf(x), y));
+		if (ix < 0x41100000)	/* small x: normal case */
+			return (cpackf(sinhf(x) * cosf(y), coshf(x) * sinf(y)));
+
+		/* |x| >= 9, so cosh(x) ~= exp(|x|) */
+		if (ix < 0x42b17218) {
+			/* x < 88.7: expf(|x|) won't overflow */
+			h = expf(fabsf(x)) * 0.5f;
+			return (cpackf(copysignf(h, x) * cosf(y), h * sinf(y)));
+		} else if (ix < 0x4340b1e7) {
+			/* x < 192.7: scale to avoid overflow */
+			z = __ldexp_cexpf(cpackf(fabsf(x), y), -1);
+			return (cpackf(crealf(z) * copysignf(1, x), cimagf(z)));
+		} else {
+			/* x >= 192.7: the result always overflows */
+			h = huge * x;
+			return (cpackf(h * cosf(y), h * h * sinf(y)));
+		}
+	}
+
+	if (ix == 0 && iy >= 0x7f800000)
+		return (cpackf(copysignf(0, x * (y - y)), y - y));
+
+	if (iy == 0 && ix >= 0x7f800000) {
+		if ((hx & 0x7fffff) == 0)
+			return (cpackf(x, y));
+		return (cpackf(x, copysignf(0, y)));
+	}
+
+	if (ix < 0x7f800000 && iy >= 0x7f800000)
+		return (cpackf(y - y, x * (y - y)));
+
+	if (ix >= 0x7f800000 && (hx & 0x7fffff) == 0) {
+		if (iy >= 0x7f800000)
+			return (cpackf(x * x, x * (y - y)));
+		return (cpackf(x * cosf(y), INFINITY * sinf(y)));
+	}
+
+	return (cpackf((x * x) * (y - y), (x + x) * (y - y)));
+}
+
+float complex
+csinf(float complex z)
+{
+
+	z = csinhf(cpackf(-cimagf(z), crealf(z)));
+	return (cpackf(cimagf(z), -crealf(z)));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_csqrt.c b/libm/upstream-freebsd/lib/msun/src/s_csqrt.c
new file mode 100644
index 0000000..18a7ae3
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_csqrt.c
@@ -0,0 +1,112 @@
+/*-
+ * Copyright (c) 2007 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <float.h>
+#include <math.h>
+
+#include "math_private.h"
+
+/*
+ * gcc doesn't implement complex multiplication or division correctly,
+ * so we need to handle infinities specially. We turn on this pragma to
+ * notify conforming c99 compilers that the fast-but-incorrect code that
+ * gcc generates is acceptable, since the special cases have already been
+ * handled.
+ */
+#pragma	STDC CX_LIMITED_RANGE	ON
+
+/* We risk spurious overflow for components >= DBL_MAX / (1 + sqrt(2)). */
+#define	THRESH	0x1.a827999fcef32p+1022
+
+double complex
+csqrt(double complex z)
+{
+	double complex result;
+	double a, b;
+	double t;
+	int scale;
+
+	a = creal(z);
+	b = cimag(z);
+
+	/* Handle special cases. */
+	if (z == 0)
+		return (cpack(0, b));
+	if (isinf(b))
+		return (cpack(INFINITY, b));
+	if (isnan(a)) {
+		t = (b - b) / (b - b);	/* raise invalid if b is not a NaN */
+		return (cpack(a, t));	/* return NaN + NaN i */
+	}
+	if (isinf(a)) {
+		/*
+		 * csqrt(inf + NaN i)  = inf +  NaN i
+		 * csqrt(inf + y i)    = inf +  0 i
+		 * csqrt(-inf + NaN i) = NaN +- inf i
+		 * csqrt(-inf + y i)   = 0   +  inf i
+		 */
+		if (signbit(a))
+			return (cpack(fabs(b - b), copysign(a, b)));
+		else
+			return (cpack(a, copysign(b - b, b)));
+	}
+	/*
+	 * The remaining special case (b is NaN) is handled just fine by
+	 * the normal code path below.
+	 */
+
+	/* Scale to avoid overflow. */
+	if (fabs(a) >= THRESH || fabs(b) >= THRESH) {
+		a *= 0.25;
+		b *= 0.25;
+		scale = 1;
+	} else {
+		scale = 0;
+	}
+
+	/* Algorithm 312, CACM vol 10, Oct 1967. */
+	if (a >= 0) {
+		t = sqrt((a + hypot(a, b)) * 0.5);
+		result = cpack(t, b / (2 * t));
+	} else {
+		t = sqrt((-a + hypot(a, b)) * 0.5);
+		result = cpack(fabs(b) / (2 * t), copysign(t, b));
+	}
+
+	/* Rescale. */
+	if (scale)
+		return (result * 2);
+	else
+		return (result);
+}
+
+#if LDBL_MANT_DIG == 53
+__weak_reference(csqrt, csqrtl);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/s_csqrtf.c b/libm/upstream-freebsd/lib/msun/src/s_csqrtf.c
new file mode 100644
index 0000000..da7fe18
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_csqrtf.c
@@ -0,0 +1,88 @@
+/*-
+ * Copyright (c) 2007 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+/*
+ * gcc doesn't implement complex multiplication or division correctly,
+ * so we need to handle infinities specially. We turn on this pragma to
+ * notify conforming c99 compilers that the fast-but-incorrect code that
+ * gcc generates is acceptable, since the special cases have already been
+ * handled.
+ */
+#pragma	STDC CX_LIMITED_RANGE	ON
+
+float complex
+csqrtf(float complex z)
+{
+	float a = crealf(z), b = cimagf(z);
+	double t;
+
+	/* Handle special cases. */
+	if (z == 0)
+		return (cpackf(0, b));
+	if (isinf(b))
+		return (cpackf(INFINITY, b));
+	if (isnan(a)) {
+		t = (b - b) / (b - b);	/* raise invalid if b is not a NaN */
+		return (cpackf(a, t));	/* return NaN + NaN i */
+	}
+	if (isinf(a)) {
+		/*
+		 * csqrtf(inf + NaN i)  = inf +  NaN i
+		 * csqrtf(inf + y i)    = inf +  0 i
+		 * csqrtf(-inf + NaN i) = NaN +- inf i
+		 * csqrtf(-inf + y i)   = 0   +  inf i
+		 */
+		if (signbit(a))
+			return (cpackf(fabsf(b - b), copysignf(a, b)));
+		else
+			return (cpackf(a, copysignf(b - b, b)));
+	}
+	/*
+	 * The remaining special case (b is NaN) is handled just fine by
+	 * the normal code path below.
+	 */
+
+	/*
+	 * We compute t in double precision to avoid overflow and to
+	 * provide correct rounding in nearly all cases.
+	 * This is Algorithm 312, CACM vol 10, Oct 1967.
+	 */
+	if (a >= 0) {
+		t = sqrt((a + hypot(a, b)) * 0.5);
+		return (cpackf(t, b / (2.0 * t)));
+	} else {
+		t = sqrt((-a + hypot(a, b)) * 0.5);
+		return (cpackf(fabsf(b) / (2.0 * t), copysignf(t, b)));
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_csqrtl.c b/libm/upstream-freebsd/lib/msun/src/s_csqrtl.c
new file mode 100644
index 0000000..dd18e1e
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_csqrtl.c
@@ -0,0 +1,108 @@
+/*-
+ * Copyright (c) 2007-2008 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <float.h>
+#include <math.h>
+
+#include "math_private.h"
+
+/*
+ * gcc doesn't implement complex multiplication or division correctly,
+ * so we need to handle infinities specially. We turn on this pragma to
+ * notify conforming c99 compilers that the fast-but-incorrect code that
+ * gcc generates is acceptable, since the special cases have already been
+ * handled.
+ */
+#pragma	STDC CX_LIMITED_RANGE	ON
+
+/* We risk spurious overflow for components >= LDBL_MAX / (1 + sqrt(2)). */
+#define	THRESH	(LDBL_MAX / 2.414213562373095048801688724209698L)
+
+long double complex
+csqrtl(long double complex z)
+{
+	long double complex result;
+	long double a, b;
+	long double t;
+	int scale;
+
+	a = creall(z);
+	b = cimagl(z);
+
+	/* Handle special cases. */
+	if (z == 0)
+		return (cpackl(0, b));
+	if (isinf(b))
+		return (cpackl(INFINITY, b));
+	if (isnan(a)) {
+		t = (b - b) / (b - b);	/* raise invalid if b is not a NaN */
+		return (cpackl(a, t));	/* return NaN + NaN i */
+	}
+	if (isinf(a)) {
+		/*
+		 * csqrt(inf + NaN i)  = inf +  NaN i
+		 * csqrt(inf + y i)    = inf +  0 i
+		 * csqrt(-inf + NaN i) = NaN +- inf i
+		 * csqrt(-inf + y i)   = 0   +  inf i
+		 */
+		if (signbit(a))
+			return (cpackl(fabsl(b - b), copysignl(a, b)));
+		else
+			return (cpackl(a, copysignl(b - b, b)));
+	}
+	/*
+	 * The remaining special case (b is NaN) is handled just fine by
+	 * the normal code path below.
+	 */
+
+	/* Scale to avoid overflow. */
+	if (fabsl(a) >= THRESH || fabsl(b) >= THRESH) {
+		a *= 0.25;
+		b *= 0.25;
+		scale = 1;
+	} else {
+		scale = 0;
+	}
+
+	/* Algorithm 312, CACM vol 10, Oct 1967. */
+	if (a >= 0) {
+		t = sqrtl((a + hypotl(a, b)) * 0.5);
+		result = cpackl(t, b / (2 * t));
+	} else {
+		t = sqrtl((-a + hypotl(a, b)) * 0.5);
+		result = cpackl(fabsl(b) / (2 * t), copysignl(t, b));
+	}
+
+	/* Rescale. */
+	if (scale)
+		return (result * 2);
+	else
+		return (result);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_ctanh.c b/libm/upstream-freebsd/lib/msun/src/s_ctanh.c
new file mode 100644
index 0000000..d427e28
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_ctanh.c
@@ -0,0 +1,144 @@
+/*-
+ * Copyright (c) 2011 David Schultz
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Hyperbolic tangent of a complex argument z = x + i y.
+ *
+ * The algorithm is from:
+ *
+ *   W. Kahan.  Branch Cuts for Complex Elementary Functions or Much
+ *   Ado About Nothing's Sign Bit.  In The State of the Art in
+ *   Numerical Analysis, pp. 165 ff.  Iserles and Powell, eds., 1987.
+ *
+ * Method:
+ *
+ *   Let t    = tan(x)
+ *       beta = 1/cos^2(y)
+ *       s    = sinh(x)
+ *       rho  = cosh(x)
+ *
+ *   We have:
+ *
+ *   tanh(z) = sinh(z) / cosh(z)
+ *
+ *             sinh(x) cos(y) + i cosh(x) sin(y)
+ *           = ---------------------------------
+ *             cosh(x) cos(y) + i sinh(x) sin(y)
+ *
+ *             cosh(x) sinh(x) / cos^2(y) + i tan(y)
+ *           = -------------------------------------
+ *                    1 + sinh^2(x) / cos^2(y)
+ *
+ *             beta rho s + i t
+ *           = ----------------
+ *               1 + beta s^2
+ *
+ * Modifications:
+ *
+ *   I omitted the original algorithm's handling of overflow in tan(x) after
+ *   verifying with nearpi.c that this can't happen in IEEE single or double
+ *   precision.  I also handle large x differently.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+double complex
+ctanh(double complex z)
+{
+	double x, y;
+	double t, beta, s, rho, denom;
+	uint32_t hx, ix, lx;
+
+	x = creal(z);
+	y = cimag(z);
+
+	EXTRACT_WORDS(hx, lx, x);
+	ix = hx & 0x7fffffff;
+
+	/*
+	 * ctanh(NaN + i 0) = NaN + i 0
+	 *
+	 * ctanh(NaN + i y) = NaN + i NaN		for y != 0
+	 *
+	 * The imaginary part has the sign of x*sin(2*y), but there's no
+	 * special effort to get this right.
+	 *
+	 * ctanh(+-Inf +- i Inf) = +-1 +- 0
+	 *
+	 * ctanh(+-Inf + i y) = +-1 + 0 sin(2y)		for y finite
+	 *
+	 * The imaginary part of the sign is unspecified.  This special
+	 * case is only needed to avoid a spurious invalid exception when
+	 * y is infinite.
+	 */
+	if (ix >= 0x7ff00000) {
+		if ((ix & 0xfffff) | lx)	/* x is NaN */
+			return (cpack(x, (y == 0 ? y : x * y)));
+		SET_HIGH_WORD(x, hx - 0x40000000);	/* x = copysign(1, x) */
+		return (cpack(x, copysign(0, isinf(y) ? y : sin(y) * cos(y))));
+	}
+
+	/*
+	 * ctanh(x + i NAN) = NaN + i NaN
+	 * ctanh(x +- i Inf) = NaN + i NaN
+	 */
+	if (!isfinite(y))
+		return (cpack(y - y, y - y));
+
+	/*
+	 * ctanh(+-huge + i +-y) ~= +-1 +- i 2sin(2y)/exp(2x), using the
+	 * approximation sinh^2(huge) ~= exp(2*huge) / 4.
+	 * We use a modified formula to avoid spurious overflow.
+	 */
+	if (ix >= 0x40360000) {	/* x >= 22 */
+		double exp_mx = exp(-fabs(x));
+		return (cpack(copysign(1, x),
+		    4 * sin(y) * cos(y) * exp_mx * exp_mx));
+	}
+
+	/* Kahan's algorithm */
+	t = tan(y);
+	beta = 1.0 + t * t;	/* = 1 / cos^2(y) */
+	s = sinh(x);
+	rho = sqrt(1 + s * s);	/* = cosh(x) */
+	denom = 1 + beta * s * s;
+	return (cpack((beta * rho * s) / denom, t / denom));
+}
+
+double complex
+ctan(double complex z)
+{
+
+	/* ctan(z) = -I * ctanh(I * z) */
+	z = ctanh(cpack(-cimag(z), creal(z)));
+	return (cpack(cimag(z), -creal(z)));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_ctanhf.c b/libm/upstream-freebsd/lib/msun/src/s_ctanhf.c
new file mode 100644
index 0000000..4be28d8
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_ctanhf.c
@@ -0,0 +1,84 @@
+/*-
+ * Copyright (c) 2011 David Schultz
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Hyperbolic tangent of a complex argument z.  See s_ctanh.c for details.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+float complex
+ctanhf(float complex z)
+{
+	float x, y;
+	float t, beta, s, rho, denom;
+	uint32_t hx, ix;
+
+	x = crealf(z);
+	y = cimagf(z);
+
+	GET_FLOAT_WORD(hx, x);
+	ix = hx & 0x7fffffff;
+
+	if (ix >= 0x7f800000) {
+		if (ix & 0x7fffff)
+			return (cpackf(x, (y == 0 ? y : x * y)));
+		SET_FLOAT_WORD(x, hx - 0x40000000);
+		return (cpackf(x,
+		    copysignf(0, isinf(y) ? y : sinf(y) * cosf(y))));
+	}
+
+	if (!isfinite(y))
+		return (cpackf(y - y, y - y));
+
+	if (ix >= 0x41300000) {	/* x >= 11 */
+		float exp_mx = expf(-fabsf(x));
+		return (cpackf(copysignf(1, x),
+		    4 * sinf(y) * cosf(y) * exp_mx * exp_mx));
+	}
+
+	t = tanf(y);
+	beta = 1.0 + t * t;
+	s = sinhf(x);
+	rho = sqrtf(1 + s * s);
+	denom = 1 + beta * s * s;
+	return (cpackf((beta * rho * s) / denom, t / denom));
+}
+
+float complex
+ctanf(float complex z)
+{
+
+	z = ctanhf(cpackf(-cimagf(z), crealf(z)));
+	return (cpackf(cimagf(z), -crealf(z)));
+}
+
diff --git a/libm/upstream-freebsd/lib/msun/src/s_erf.c b/libm/upstream-freebsd/lib/msun/src/s_erf.c
new file mode 100644
index 0000000..0886e5e
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_erf.c
@@ -0,0 +1,301 @@
+/* @(#)s_erf.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* double erf(double x)
+ * double erfc(double x)
+ *			     x
+ *		      2      |\
+ *     erf(x)  =  ---------  | exp(-t*t)dt
+ *	 	   sqrt(pi) \|
+ *			     0
+ *
+ *     erfc(x) =  1-erf(x)
+ *  Note that
+ *		erf(-x) = -erf(x)
+ *		erfc(-x) = 2 - erfc(x)
+ *
+ * Method:
+ *	1. For |x| in [0, 0.84375]
+ *	    erf(x)  = x + x*R(x^2)
+ *          erfc(x) = 1 - erf(x)           if x in [-.84375,0.25]
+ *                  = 0.5 + ((0.5-x)-x*R)  if x in [0.25,0.84375]
+ *	   where R = P/Q where P is an odd poly of degree 8 and
+ *	   Q is an odd poly of degree 10.
+ *						 -57.90
+ *			| R - (erf(x)-x)/x | <= 2
+ *
+ *
+ *	   Remark. The formula is derived by noting
+ *          erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....)
+ *	   and that
+ *          2/sqrt(pi) = 1.128379167095512573896158903121545171688
+ *	   is close to one. The interval is chosen because the fix
+ *	   point of erf(x) is near 0.6174 (i.e., erf(x)=x when x is
+ *	   near 0.6174), and by some experiment, 0.84375 is chosen to
+ * 	   guarantee the error is less than one ulp for erf.
+ *
+ *      2. For |x| in [0.84375,1.25], let s = |x| - 1, and
+ *         c = 0.84506291151 rounded to single (24 bits)
+ *         	erf(x)  = sign(x) * (c  + P1(s)/Q1(s))
+ *         	erfc(x) = (1-c)  - P1(s)/Q1(s) if x > 0
+ *			  1+(c+P1(s)/Q1(s))    if x < 0
+ *         	|P1/Q1 - (erf(|x|)-c)| <= 2**-59.06
+ *	   Remark: here we use the taylor series expansion at x=1.
+ *		erf(1+s) = erf(1) + s*Poly(s)
+ *			 = 0.845.. + P1(s)/Q1(s)
+ *	   That is, we use rational approximation to approximate
+ *			erf(1+s) - (c = (single)0.84506291151)
+ *	   Note that |P1/Q1|< 0.078 for x in [0.84375,1.25]
+ *	   where
+ *		P1(s) = degree 6 poly in s
+ *		Q1(s) = degree 6 poly in s
+ *
+ *      3. For x in [1.25,1/0.35(~2.857143)],
+ *         	erfc(x) = (1/x)*exp(-x*x-0.5625+R1/S1)
+ *         	erf(x)  = 1 - erfc(x)
+ *	   where
+ *		R1(z) = degree 7 poly in z, (z=1/x^2)
+ *		S1(z) = degree 8 poly in z
+ *
+ *      4. For x in [1/0.35,28]
+ *         	erfc(x) = (1/x)*exp(-x*x-0.5625+R2/S2) if x > 0
+ *			= 2.0 - (1/x)*exp(-x*x-0.5625+R2/S2) if -6<x<0
+ *			= 2.0 - tiny		(if x <= -6)
+ *         	erf(x)  = sign(x)*(1.0 - erfc(x)) if x < 6, else
+ *         	erf(x)  = sign(x)*(1.0 - tiny)
+ *	   where
+ *		R2(z) = degree 6 poly in z, (z=1/x^2)
+ *		S2(z) = degree 7 poly in z
+ *
+ *      Note1:
+ *	   To compute exp(-x*x-0.5625+R/S), let s be a single
+ *	   precision number and s := x; then
+ *		-x*x = -s*s + (s-x)*(s+x)
+ *	        exp(-x*x-0.5626+R/S) =
+ *			exp(-s*s-0.5625)*exp((s-x)*(s+x)+R/S);
+ *      Note2:
+ *	   Here 4 and 5 make use of the asymptotic series
+ *			  exp(-x*x)
+ *		erfc(x) ~ ---------- * ( 1 + Poly(1/x^2) )
+ *			  x*sqrt(pi)
+ *	   We use rational approximation to approximate
+ *      	g(s)=f(1/x^2) = log(erfc(x)*x) - x*x + 0.5625
+ *	   Here is the error bound for R1/S1 and R2/S2
+ *      	|R1/S1 - f(x)|  < 2**(-62.57)
+ *      	|R2/S2 - f(x)|  < 2**(-61.52)
+ *
+ *      5. For inf > x >= 28
+ *         	erf(x)  = sign(x) *(1 - tiny)  (raise inexact)
+ *         	erfc(x) = tiny*tiny (raise underflow) if x > 0
+ *			= 2 - tiny if x<0
+ *
+ *      7. Special case:
+ *         	erf(0)  = 0, erf(inf)  = 1, erf(-inf) = -1,
+ *         	erfc(0) = 1, erfc(inf) = 0, erfc(-inf) = 2,
+ *	   	erfc/erf(NaN) is NaN
+ */
+
+
+#include "math.h"
+#include "math_private.h"
+
+static const double
+tiny	    = 1e-300,
+half=  5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
+one =  1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
+two =  2.00000000000000000000e+00, /* 0x40000000, 0x00000000 */
+	/* c = (float)0.84506291151 */
+erx =  8.45062911510467529297e-01, /* 0x3FEB0AC1, 0x60000000 */
+/*
+ * Coefficients for approximation to  erf on [0,0.84375]
+ */
+efx =  1.28379167095512586316e-01, /* 0x3FC06EBA, 0x8214DB69 */
+efx8=  1.02703333676410069053e+00, /* 0x3FF06EBA, 0x8214DB69 */
+pp0  =  1.28379167095512558561e-01, /* 0x3FC06EBA, 0x8214DB68 */
+pp1  = -3.25042107247001499370e-01, /* 0xBFD4CD7D, 0x691CB913 */
+pp2  = -2.84817495755985104766e-02, /* 0xBF9D2A51, 0xDBD7194F */
+pp3  = -5.77027029648944159157e-03, /* 0xBF77A291, 0x236668E4 */
+pp4  = -2.37630166566501626084e-05, /* 0xBEF8EAD6, 0x120016AC */
+qq1  =  3.97917223959155352819e-01, /* 0x3FD97779, 0xCDDADC09 */
+qq2  =  6.50222499887672944485e-02, /* 0x3FB0A54C, 0x5536CEBA */
+qq3  =  5.08130628187576562776e-03, /* 0x3F74D022, 0xC4D36B0F */
+qq4  =  1.32494738004321644526e-04, /* 0x3F215DC9, 0x221C1A10 */
+qq5  = -3.96022827877536812320e-06, /* 0xBED09C43, 0x42A26120 */
+/*
+ * Coefficients for approximation to  erf  in [0.84375,1.25]
+ */
+pa0  = -2.36211856075265944077e-03, /* 0xBF6359B8, 0xBEF77538 */
+pa1  =  4.14856118683748331666e-01, /* 0x3FDA8D00, 0xAD92B34D */
+pa2  = -3.72207876035701323847e-01, /* 0xBFD7D240, 0xFBB8C3F1 */
+pa3  =  3.18346619901161753674e-01, /* 0x3FD45FCA, 0x805120E4 */
+pa4  = -1.10894694282396677476e-01, /* 0xBFBC6398, 0x3D3E28EC */
+pa5  =  3.54783043256182359371e-02, /* 0x3FA22A36, 0x599795EB */
+pa6  = -2.16637559486879084300e-03, /* 0xBF61BF38, 0x0A96073F */
+qa1  =  1.06420880400844228286e-01, /* 0x3FBB3E66, 0x18EEE323 */
+qa2  =  5.40397917702171048937e-01, /* 0x3FE14AF0, 0x92EB6F33 */
+qa3  =  7.18286544141962662868e-02, /* 0x3FB2635C, 0xD99FE9A7 */
+qa4  =  1.26171219808761642112e-01, /* 0x3FC02660, 0xE763351F */
+qa5  =  1.36370839120290507362e-02, /* 0x3F8BEDC2, 0x6B51DD1C */
+qa6  =  1.19844998467991074170e-02, /* 0x3F888B54, 0x5735151D */
+/*
+ * Coefficients for approximation to  erfc in [1.25,1/0.35]
+ */
+ra0  = -9.86494403484714822705e-03, /* 0xBF843412, 0x600D6435 */
+ra1  = -6.93858572707181764372e-01, /* 0xBFE63416, 0xE4BA7360 */
+ra2  = -1.05586262253232909814e+01, /* 0xC0251E04, 0x41B0E726 */
+ra3  = -6.23753324503260060396e+01, /* 0xC04F300A, 0xE4CBA38D */
+ra4  = -1.62396669462573470355e+02, /* 0xC0644CB1, 0x84282266 */
+ra5  = -1.84605092906711035994e+02, /* 0xC067135C, 0xEBCCABB2 */
+ra6  = -8.12874355063065934246e+01, /* 0xC0545265, 0x57E4D2F2 */
+ra7  = -9.81432934416914548592e+00, /* 0xC023A0EF, 0xC69AC25C */
+sa1  =  1.96512716674392571292e+01, /* 0x4033A6B9, 0xBD707687 */
+sa2  =  1.37657754143519042600e+02, /* 0x4061350C, 0x526AE721 */
+sa3  =  4.34565877475229228821e+02, /* 0x407B290D, 0xD58A1A71 */
+sa4  =  6.45387271733267880336e+02, /* 0x40842B19, 0x21EC2868 */
+sa5  =  4.29008140027567833386e+02, /* 0x407AD021, 0x57700314 */
+sa6  =  1.08635005541779435134e+02, /* 0x405B28A3, 0xEE48AE2C */
+sa7  =  6.57024977031928170135e+00, /* 0x401A47EF, 0x8E484A93 */
+sa8  = -6.04244152148580987438e-02, /* 0xBFAEEFF2, 0xEE749A62 */
+/*
+ * Coefficients for approximation to  erfc in [1/.35,28]
+ */
+rb0  = -9.86494292470009928597e-03, /* 0xBF843412, 0x39E86F4A */
+rb1  = -7.99283237680523006574e-01, /* 0xBFE993BA, 0x70C285DE */
+rb2  = -1.77579549177547519889e+01, /* 0xC031C209, 0x555F995A */
+rb3  = -1.60636384855821916062e+02, /* 0xC064145D, 0x43C5ED98 */
+rb4  = -6.37566443368389627722e+02, /* 0xC083EC88, 0x1375F228 */
+rb5  = -1.02509513161107724954e+03, /* 0xC0900461, 0x6A2E5992 */
+rb6  = -4.83519191608651397019e+02, /* 0xC07E384E, 0x9BDC383F */
+sb1  =  3.03380607434824582924e+01, /* 0x403E568B, 0x261D5190 */
+sb2  =  3.25792512996573918826e+02, /* 0x40745CAE, 0x221B9F0A */
+sb3  =  1.53672958608443695994e+03, /* 0x409802EB, 0x189D5118 */
+sb4  =  3.19985821950859553908e+03, /* 0x40A8FFB7, 0x688C246A */
+sb5  =  2.55305040643316442583e+03, /* 0x40A3F219, 0xCEDF3BE6 */
+sb6  =  4.74528541206955367215e+02, /* 0x407DA874, 0xE79FE763 */
+sb7  = -2.24409524465858183362e+01; /* 0xC03670E2, 0x42712D62 */
+
+double
+erf(double x)
+{
+	int32_t hx,ix,i;
+	double R,S,P,Q,s,y,z,r;
+	GET_HIGH_WORD(hx,x);
+	ix = hx&0x7fffffff;
+	if(ix>=0x7ff00000) {		/* erf(nan)=nan */
+	    i = ((u_int32_t)hx>>31)<<1;
+	    return (double)(1-i)+one/x;	/* erf(+-inf)=+-1 */
+	}
+
+	if(ix < 0x3feb0000) {		/* |x|<0.84375 */
+	    if(ix < 0x3e300000) { 	/* |x|<2**-28 */
+	        if (ix < 0x00800000)
+		    return 0.125*(8.0*x+efx8*x);  /*avoid underflow */
+		return x + efx*x;
+	    }
+	    z = x*x;
+	    r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
+	    s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
+	    y = r/s;
+	    return x + x*y;
+	}
+	if(ix < 0x3ff40000) {		/* 0.84375 <= |x| < 1.25 */
+	    s = fabs(x)-one;
+	    P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
+	    Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
+	    if(hx>=0) return erx + P/Q; else return -erx - P/Q;
+	}
+	if (ix >= 0x40180000) {		/* inf>|x|>=6 */
+	    if(hx>=0) return one-tiny; else return tiny-one;
+	}
+	x = fabs(x);
+ 	s = one/(x*x);
+	if(ix< 0x4006DB6E) {	/* |x| < 1/0.35 */
+	    R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
+				ra5+s*(ra6+s*ra7))))));
+	    S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
+				sa5+s*(sa6+s*(sa7+s*sa8)))))));
+	} else {	/* |x| >= 1/0.35 */
+	    R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
+				rb5+s*rb6)))));
+	    S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
+				sb5+s*(sb6+s*sb7))))));
+	}
+	z  = x;
+	SET_LOW_WORD(z,0);
+	r  =  __ieee754_exp(-z*z-0.5625)*__ieee754_exp((z-x)*(z+x)+R/S);
+	if(hx>=0) return one-r/x; else return  r/x-one;
+}
+
+double
+erfc(double x)
+{
+	int32_t hx,ix;
+	double R,S,P,Q,s,y,z,r;
+	GET_HIGH_WORD(hx,x);
+	ix = hx&0x7fffffff;
+	if(ix>=0x7ff00000) {			/* erfc(nan)=nan */
+						/* erfc(+-inf)=0,2 */
+	    return (double)(((u_int32_t)hx>>31)<<1)+one/x;
+	}
+
+	if(ix < 0x3feb0000) {		/* |x|<0.84375 */
+	    if(ix < 0x3c700000)  	/* |x|<2**-56 */
+		return one-x;
+	    z = x*x;
+	    r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
+	    s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
+	    y = r/s;
+	    if(hx < 0x3fd00000) {  	/* x<1/4 */
+		return one-(x+x*y);
+	    } else {
+		r = x*y;
+		r += (x-half);
+	        return half - r ;
+	    }
+	}
+	if(ix < 0x3ff40000) {		/* 0.84375 <= |x| < 1.25 */
+	    s = fabs(x)-one;
+	    P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
+	    Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
+	    if(hx>=0) {
+	        z  = one-erx; return z - P/Q;
+	    } else {
+		z = erx+P/Q; return one+z;
+	    }
+	}
+	if (ix < 0x403c0000) {		/* |x|<28 */
+	    x = fabs(x);
+ 	    s = one/(x*x);
+	    if(ix< 0x4006DB6D) {	/* |x| < 1/.35 ~ 2.857143*/
+	        R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
+				ra5+s*(ra6+s*ra7))))));
+	        S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
+				sa5+s*(sa6+s*(sa7+s*sa8)))))));
+	    } else {			/* |x| >= 1/.35 ~ 2.857143 */
+		if(hx<0&&ix>=0x40180000) return two-tiny;/* x < -6 */
+	        R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
+				rb5+s*rb6)))));
+	        S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
+				sb5+s*(sb6+s*sb7))))));
+	    }
+	    z  = x;
+	    SET_LOW_WORD(z,0);
+	    r  =  __ieee754_exp(-z*z-0.5625)*
+			__ieee754_exp((z-x)*(z+x)+R/S);
+	    if(hx>0) return r/x; else return two-r/x;
+	} else {
+	    if(hx>0) return tiny*tiny; else return two-tiny;
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_erff.c b/libm/upstream-freebsd/lib/msun/src/s_erff.c
new file mode 100644
index 0000000..a44e135
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_erff.c
@@ -0,0 +1,210 @@
+/* s_erff.c -- float version of s_erf.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static const float
+tiny	    = 1e-30,
+half=  5.0000000000e-01, /* 0x3F000000 */
+one =  1.0000000000e+00, /* 0x3F800000 */
+two =  2.0000000000e+00, /* 0x40000000 */
+	/* c = (subfloat)0.84506291151 */
+erx =  8.4506291151e-01, /* 0x3f58560b */
+/*
+ * Coefficients for approximation to  erf on [0,0.84375]
+ */
+efx =  1.2837916613e-01, /* 0x3e0375d4 */
+efx8=  1.0270333290e+00, /* 0x3f8375d4 */
+pp0  =  1.2837916613e-01, /* 0x3e0375d4 */
+pp1  = -3.2504209876e-01, /* 0xbea66beb */
+pp2  = -2.8481749818e-02, /* 0xbce9528f */
+pp3  = -5.7702702470e-03, /* 0xbbbd1489 */
+pp4  = -2.3763017452e-05, /* 0xb7c756b1 */
+qq1  =  3.9791721106e-01, /* 0x3ecbbbce */
+qq2  =  6.5022252500e-02, /* 0x3d852a63 */
+qq3  =  5.0813062117e-03, /* 0x3ba68116 */
+qq4  =  1.3249473704e-04, /* 0x390aee49 */
+qq5  = -3.9602282413e-06, /* 0xb684e21a */
+/*
+ * Coefficients for approximation to  erf  in [0.84375,1.25]
+ */
+pa0  = -2.3621185683e-03, /* 0xbb1acdc6 */
+pa1  =  4.1485610604e-01, /* 0x3ed46805 */
+pa2  = -3.7220788002e-01, /* 0xbebe9208 */
+pa3  =  3.1834661961e-01, /* 0x3ea2fe54 */
+pa4  = -1.1089469492e-01, /* 0xbde31cc2 */
+pa5  =  3.5478305072e-02, /* 0x3d1151b3 */
+pa6  = -2.1663755178e-03, /* 0xbb0df9c0 */
+qa1  =  1.0642088205e-01, /* 0x3dd9f331 */
+qa2  =  5.4039794207e-01, /* 0x3f0a5785 */
+qa3  =  7.1828655899e-02, /* 0x3d931ae7 */
+qa4  =  1.2617121637e-01, /* 0x3e013307 */
+qa5  =  1.3637083583e-02, /* 0x3c5f6e13 */
+qa6  =  1.1984500103e-02, /* 0x3c445aa3 */
+/*
+ * Coefficients for approximation to  erfc in [1.25,1/0.35]
+ */
+ra0  = -9.8649440333e-03, /* 0xbc21a093 */
+ra1  = -6.9385856390e-01, /* 0xbf31a0b7 */
+ra2  = -1.0558626175e+01, /* 0xc128f022 */
+ra3  = -6.2375331879e+01, /* 0xc2798057 */
+ra4  = -1.6239666748e+02, /* 0xc322658c */
+ra5  = -1.8460508728e+02, /* 0xc3389ae7 */
+ra6  = -8.1287437439e+01, /* 0xc2a2932b */
+ra7  = -9.8143291473e+00, /* 0xc11d077e */
+sa1  =  1.9651271820e+01, /* 0x419d35ce */
+sa2  =  1.3765776062e+02, /* 0x4309a863 */
+sa3  =  4.3456588745e+02, /* 0x43d9486f */
+sa4  =  6.4538726807e+02, /* 0x442158c9 */
+sa5  =  4.2900814819e+02, /* 0x43d6810b */
+sa6  =  1.0863500214e+02, /* 0x42d9451f */
+sa7  =  6.5702495575e+00, /* 0x40d23f7c */
+sa8  = -6.0424413532e-02, /* 0xbd777f97 */
+/*
+ * Coefficients for approximation to  erfc in [1/.35,28]
+ */
+rb0  = -9.8649431020e-03, /* 0xbc21a092 */
+rb1  = -7.9928326607e-01, /* 0xbf4c9dd4 */
+rb2  = -1.7757955551e+01, /* 0xc18e104b */
+rb3  = -1.6063638306e+02, /* 0xc320a2ea */
+rb4  = -6.3756646729e+02, /* 0xc41f6441 */
+rb5  = -1.0250950928e+03, /* 0xc480230b */
+rb6  = -4.8351919556e+02, /* 0xc3f1c275 */
+sb1  =  3.0338060379e+01, /* 0x41f2b459 */
+sb2  =  3.2579251099e+02, /* 0x43a2e571 */
+sb3  =  1.5367296143e+03, /* 0x44c01759 */
+sb4  =  3.1998581543e+03, /* 0x4547fdbb */
+sb5  =  2.5530502930e+03, /* 0x451f90ce */
+sb6  =  4.7452853394e+02, /* 0x43ed43a7 */
+sb7  = -2.2440952301e+01; /* 0xc1b38712 */
+
+float
+erff(float x)
+{
+	int32_t hx,ix,i;
+	float R,S,P,Q,s,y,z,r;
+	GET_FLOAT_WORD(hx,x);
+	ix = hx&0x7fffffff;
+	if(ix>=0x7f800000) {		/* erf(nan)=nan */
+	    i = ((u_int32_t)hx>>31)<<1;
+	    return (float)(1-i)+one/x;	/* erf(+-inf)=+-1 */
+	}
+
+	if(ix < 0x3f580000) {		/* |x|<0.84375 */
+	    if(ix < 0x31800000) { 	/* |x|<2**-28 */
+	        if (ix < 0x04000000)
+		    /*avoid underflow */
+		    return (float)0.125*((float)8.0*x+efx8*x);
+		return x + efx*x;
+	    }
+	    z = x*x;
+	    r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
+	    s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
+	    y = r/s;
+	    return x + x*y;
+	}
+	if(ix < 0x3fa00000) {		/* 0.84375 <= |x| < 1.25 */
+	    s = fabsf(x)-one;
+	    P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
+	    Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
+	    if(hx>=0) return erx + P/Q; else return -erx - P/Q;
+	}
+	if (ix >= 0x40c00000) {		/* inf>|x|>=6 */
+	    if(hx>=0) return one-tiny; else return tiny-one;
+	}
+	x = fabsf(x);
+ 	s = one/(x*x);
+	if(ix< 0x4036DB6E) {	/* |x| < 1/0.35 */
+	    R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
+				ra5+s*(ra6+s*ra7))))));
+	    S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
+				sa5+s*(sa6+s*(sa7+s*sa8)))))));
+	} else {	/* |x| >= 1/0.35 */
+	    R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
+				rb5+s*rb6)))));
+	    S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
+				sb5+s*(sb6+s*sb7))))));
+	}
+	GET_FLOAT_WORD(ix,x);
+	SET_FLOAT_WORD(z,ix&0xfffff000);
+	r  =  __ieee754_expf(-z*z-(float)0.5625)*__ieee754_expf((z-x)*(z+x)+R/S);
+	if(hx>=0) return one-r/x; else return  r/x-one;
+}
+
+float
+erfcf(float x)
+{
+	int32_t hx,ix;
+	float R,S,P,Q,s,y,z,r;
+	GET_FLOAT_WORD(hx,x);
+	ix = hx&0x7fffffff;
+	if(ix>=0x7f800000) {			/* erfc(nan)=nan */
+						/* erfc(+-inf)=0,2 */
+	    return (float)(((u_int32_t)hx>>31)<<1)+one/x;
+	}
+
+	if(ix < 0x3f580000) {		/* |x|<0.84375 */
+	    if(ix < 0x23800000)  	/* |x|<2**-56 */
+		return one-x;
+	    z = x*x;
+	    r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
+	    s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
+	    y = r/s;
+	    if(hx < 0x3e800000) {  	/* x<1/4 */
+		return one-(x+x*y);
+	    } else {
+		r = x*y;
+		r += (x-half);
+	        return half - r ;
+	    }
+	}
+	if(ix < 0x3fa00000) {		/* 0.84375 <= |x| < 1.25 */
+	    s = fabsf(x)-one;
+	    P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
+	    Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
+	    if(hx>=0) {
+	        z  = one-erx; return z - P/Q;
+	    } else {
+		z = erx+P/Q; return one+z;
+	    }
+	}
+	if (ix < 0x41e00000) {		/* |x|<28 */
+	    x = fabsf(x);
+ 	    s = one/(x*x);
+	    if(ix< 0x4036DB6D) {	/* |x| < 1/.35 ~ 2.857143*/
+	        R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
+				ra5+s*(ra6+s*ra7))))));
+	        S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
+				sa5+s*(sa6+s*(sa7+s*sa8)))))));
+	    } else {			/* |x| >= 1/.35 ~ 2.857143 */
+		if(hx<0&&ix>=0x40c00000) return two-tiny;/* x < -6 */
+	        R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
+				rb5+s*rb6)))));
+	        S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
+				sb5+s*(sb6+s*sb7))))));
+	    }
+	    GET_FLOAT_WORD(ix,x);
+	    SET_FLOAT_WORD(z,ix&0xfffff000);
+	    r  =  __ieee754_expf(-z*z-(float)0.5625)*
+			__ieee754_expf((z-x)*(z+x)+R/S);
+	    if(hx>0) return r/x; else return two-r/x;
+	} else {
+	    if(hx>0) return tiny*tiny; else return two-tiny;
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_exp2.c b/libm/upstream-freebsd/lib/msun/src/s_exp2.c
new file mode 100644
index 0000000..485b4e3
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_exp2.c
@@ -0,0 +1,396 @@
+/*-
+ * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+#define	TBLBITS	8
+#define	TBLSIZE	(1 << TBLBITS)
+
+static const double
+    huge     = 0x1p1000,
+    redux    = 0x1.8p52 / TBLSIZE,
+    P1	     = 0x1.62e42fefa39efp-1,
+    P2	     = 0x1.ebfbdff82c575p-3,
+    P3	     = 0x1.c6b08d704a0a6p-5,
+    P4	     = 0x1.3b2ab88f70400p-7,
+    P5	     = 0x1.5d88003875c74p-10;
+
+static volatile double twom1000 = 0x1p-1000;
+
+static const double tbl[TBLSIZE * 2] = {
+/*	exp2(z + eps)		eps	*/
+	0x1.6a09e667f3d5dp-1,	 0x1.9880p-44,
+	0x1.6b052fa751744p-1,	 0x1.8000p-50,
+	0x1.6c012750bd9fep-1,	-0x1.8780p-45,
+	0x1.6cfdcddd476bfp-1,	 0x1.ec00p-46,
+	0x1.6dfb23c651a29p-1,	-0x1.8000p-50,
+	0x1.6ef9298593ae3p-1,	-0x1.c000p-52,
+	0x1.6ff7df9519386p-1,	-0x1.fd80p-45,
+	0x1.70f7466f42da3p-1,	-0x1.c880p-45,
+	0x1.71f75e8ec5fc3p-1,	 0x1.3c00p-46,
+	0x1.72f8286eacf05p-1,	-0x1.8300p-44,
+	0x1.73f9a48a58152p-1,	-0x1.0c00p-47,
+	0x1.74fbd35d7ccfcp-1,	 0x1.f880p-45,
+	0x1.75feb564267f1p-1,	 0x1.3e00p-47,
+	0x1.77024b1ab6d48p-1,	-0x1.7d00p-45,
+	0x1.780694fde5d38p-1,	-0x1.d000p-50,
+	0x1.790b938ac1d00p-1,	 0x1.3000p-49,
+	0x1.7a11473eb0178p-1,	-0x1.d000p-49,
+	0x1.7b17b0976d060p-1,	 0x1.0400p-45,
+	0x1.7c1ed0130c133p-1,	 0x1.0000p-53,
+	0x1.7d26a62ff8636p-1,	-0x1.6900p-45,
+	0x1.7e2f336cf4e3bp-1,	-0x1.2e00p-47,
+	0x1.7f3878491c3e8p-1,	-0x1.4580p-45,
+	0x1.80427543e1b4ep-1,	 0x1.3000p-44,
+	0x1.814d2add1071ap-1,	 0x1.f000p-47,
+	0x1.82589994ccd7ep-1,	-0x1.1c00p-45,
+	0x1.8364c1eb942d0p-1,	 0x1.9d00p-45,
+	0x1.8471a4623cab5p-1,	 0x1.7100p-43,
+	0x1.857f4179f5bbcp-1,	 0x1.2600p-45,
+	0x1.868d99b4491afp-1,	-0x1.2c40p-44,
+	0x1.879cad931a395p-1,	-0x1.3000p-45,
+	0x1.88ac7d98a65b8p-1,	-0x1.a800p-45,
+	0x1.89bd0a4785800p-1,	-0x1.d000p-49,
+	0x1.8ace5422aa223p-1,	 0x1.3280p-44,
+	0x1.8be05bad619fap-1,	 0x1.2b40p-43,
+	0x1.8cf3216b54383p-1,	-0x1.ed00p-45,
+	0x1.8e06a5e08664cp-1,	-0x1.0500p-45,
+	0x1.8f1ae99157807p-1,	 0x1.8280p-45,
+	0x1.902fed0282c0ep-1,	-0x1.cb00p-46,
+	0x1.9145b0b91ff96p-1,	-0x1.5e00p-47,
+	0x1.925c353aa2ff9p-1,	 0x1.5400p-48,
+	0x1.93737b0cdc64ap-1,	 0x1.7200p-46,
+	0x1.948b82b5f98aep-1,	-0x1.9000p-47,
+	0x1.95a44cbc852cbp-1,	 0x1.5680p-45,
+	0x1.96bdd9a766f21p-1,	-0x1.6d00p-44,
+	0x1.97d829fde4e2ap-1,	-0x1.1000p-47,
+	0x1.98f33e47a23a3p-1,	 0x1.d000p-45,
+	0x1.9a0f170ca0604p-1,	-0x1.8a40p-44,
+	0x1.9b2bb4d53ff89p-1,	 0x1.55c0p-44,
+	0x1.9c49182a3f15bp-1,	 0x1.6b80p-45,
+	0x1.9d674194bb8c5p-1,	-0x1.c000p-49,
+	0x1.9e86319e3238ep-1,	 0x1.7d00p-46,
+	0x1.9fa5e8d07f302p-1,	 0x1.6400p-46,
+	0x1.a0c667b5de54dp-1,	-0x1.5000p-48,
+	0x1.a1e7aed8eb8f6p-1,	 0x1.9e00p-47,
+	0x1.a309bec4a2e27p-1,	 0x1.ad80p-45,
+	0x1.a42c980460a5dp-1,	-0x1.af00p-46,
+	0x1.a5503b23e259bp-1,	 0x1.b600p-47,
+	0x1.a674a8af46213p-1,	 0x1.8880p-44,
+	0x1.a799e1330b3a7p-1,	 0x1.1200p-46,
+	0x1.a8bfe53c12e8dp-1,	 0x1.6c00p-47,
+	0x1.a9e6b5579fcd2p-1,	-0x1.9b80p-45,
+	0x1.ab0e521356fb8p-1,	 0x1.b700p-45,
+	0x1.ac36bbfd3f381p-1,	 0x1.9000p-50,
+	0x1.ad5ff3a3c2780p-1,	 0x1.4000p-49,
+	0x1.ae89f995ad2a3p-1,	-0x1.c900p-45,
+	0x1.afb4ce622f367p-1,	 0x1.6500p-46,
+	0x1.b0e07298db790p-1,	 0x1.fd40p-45,
+	0x1.b20ce6c9a89a9p-1,	 0x1.2700p-46,
+	0x1.b33a2b84f1a4bp-1,	 0x1.d470p-43,
+	0x1.b468415b747e7p-1,	-0x1.8380p-44,
+	0x1.b59728de5593ap-1,	 0x1.8000p-54,
+	0x1.b6c6e29f1c56ap-1,	 0x1.ad00p-47,
+	0x1.b7f76f2fb5e50p-1,	 0x1.e800p-50,
+	0x1.b928cf22749b2p-1,	-0x1.4c00p-47,
+	0x1.ba5b030a10603p-1,	-0x1.d700p-47,
+	0x1.bb8e0b79a6f66p-1,	 0x1.d900p-47,
+	0x1.bcc1e904bc1ffp-1,	 0x1.2a00p-47,
+	0x1.bdf69c3f3a16fp-1,	-0x1.f780p-46,
+	0x1.bf2c25bd71db8p-1,	-0x1.0a00p-46,
+	0x1.c06286141b2e9p-1,	-0x1.1400p-46,
+	0x1.c199bdd8552e0p-1,	 0x1.be00p-47,
+	0x1.c2d1cd9fa64eep-1,	-0x1.9400p-47,
+	0x1.c40ab5fffd02fp-1,	-0x1.ed00p-47,
+	0x1.c544778fafd15p-1,	 0x1.9660p-44,
+	0x1.c67f12e57d0cbp-1,	-0x1.a100p-46,
+	0x1.c7ba88988c1b6p-1,	-0x1.8458p-42,
+	0x1.c8f6d9406e733p-1,	-0x1.a480p-46,
+	0x1.ca3405751c4dfp-1,	 0x1.b000p-51,
+	0x1.cb720dcef9094p-1,	 0x1.1400p-47,
+	0x1.ccb0f2e6d1689p-1,	 0x1.0200p-48,
+	0x1.cdf0b555dc412p-1,	 0x1.3600p-48,
+	0x1.cf3155b5bab3bp-1,	-0x1.6900p-47,
+	0x1.d072d4a0789bcp-1,	 0x1.9a00p-47,
+	0x1.d1b532b08c8fap-1,	-0x1.5e00p-46,
+	0x1.d2f87080d8a85p-1,	 0x1.d280p-46,
+	0x1.d43c8eacaa203p-1,	 0x1.1a00p-47,
+	0x1.d5818dcfba491p-1,	 0x1.f000p-50,
+	0x1.d6c76e862e6a1p-1,	-0x1.3a00p-47,
+	0x1.d80e316c9834ep-1,	-0x1.cd80p-47,
+	0x1.d955d71ff6090p-1,	 0x1.4c00p-48,
+	0x1.da9e603db32aep-1,	 0x1.f900p-48,
+	0x1.dbe7cd63a8325p-1,	 0x1.9800p-49,
+	0x1.dd321f301b445p-1,	-0x1.5200p-48,
+	0x1.de7d5641c05bfp-1,	-0x1.d700p-46,
+	0x1.dfc97337b9aecp-1,	-0x1.6140p-46,
+	0x1.e11676b197d5ep-1,	 0x1.b480p-47,
+	0x1.e264614f5a3e7p-1,	 0x1.0ce0p-43,
+	0x1.e3b333b16ee5cp-1,	 0x1.c680p-47,
+	0x1.e502ee78b3fb4p-1,	-0x1.9300p-47,
+	0x1.e653924676d68p-1,	-0x1.5000p-49,
+	0x1.e7a51fbc74c44p-1,	-0x1.7f80p-47,
+	0x1.e8f7977cdb726p-1,	-0x1.3700p-48,
+	0x1.ea4afa2a490e8p-1,	 0x1.5d00p-49,
+	0x1.eb9f4867ccae4p-1,	 0x1.61a0p-46,
+	0x1.ecf482d8e680dp-1,	 0x1.5500p-48,
+	0x1.ee4aaa2188514p-1,	 0x1.6400p-51,
+	0x1.efa1bee615a13p-1,	-0x1.e800p-49,
+	0x1.f0f9c1cb64106p-1,	-0x1.a880p-48,
+	0x1.f252b376bb963p-1,	-0x1.c900p-45,
+	0x1.f3ac948dd7275p-1,	 0x1.a000p-53,
+	0x1.f50765b6e4524p-1,	-0x1.4f00p-48,
+	0x1.f6632798844fdp-1,	 0x1.a800p-51,
+	0x1.f7bfdad9cbe38p-1,	 0x1.abc0p-48,
+	0x1.f91d802243c82p-1,	-0x1.4600p-50,
+	0x1.fa7c1819e908ep-1,	-0x1.b0c0p-47,
+	0x1.fbdba3692d511p-1,	-0x1.0e00p-51,
+	0x1.fd3c22b8f7194p-1,	-0x1.0de8p-46,
+	0x1.fe9d96b2a23eep-1,	 0x1.e430p-49,
+	0x1.0000000000000p+0,	 0x0.0000p+0,
+	0x1.00b1afa5abcbep+0,	-0x1.3400p-52,
+	0x1.0163da9fb3303p+0,	-0x1.2170p-46,
+	0x1.02168143b0282p+0,	 0x1.a400p-52,
+	0x1.02c9a3e77806cp+0,	 0x1.f980p-49,
+	0x1.037d42e11bbcap+0,	-0x1.7400p-51,
+	0x1.04315e86e7f89p+0,	 0x1.8300p-50,
+	0x1.04e5f72f65467p+0,	-0x1.a3f0p-46,
+	0x1.059b0d315855ap+0,	-0x1.2840p-47,
+	0x1.0650a0e3c1f95p+0,	 0x1.1600p-48,
+	0x1.0706b29ddf71ap+0,	 0x1.5240p-46,
+	0x1.07bd42b72a82dp+0,	-0x1.9a00p-49,
+	0x1.0874518759bd0p+0,	 0x1.6400p-49,
+	0x1.092bdf66607c8p+0,	-0x1.0780p-47,
+	0x1.09e3ecac6f383p+0,	-0x1.8000p-54,
+	0x1.0a9c79b1f3930p+0,	 0x1.fa00p-48,
+	0x1.0b5586cf988fcp+0,	-0x1.ac80p-48,
+	0x1.0c0f145e46c8ap+0,	 0x1.9c00p-50,
+	0x1.0cc922b724816p+0,	 0x1.5200p-47,
+	0x1.0d83b23395dd8p+0,	-0x1.ad00p-48,
+	0x1.0e3ec32d3d1f3p+0,	 0x1.bac0p-46,
+	0x1.0efa55fdfa9a6p+0,	-0x1.4e80p-47,
+	0x1.0fb66affed2f0p+0,	-0x1.d300p-47,
+	0x1.1073028d7234bp+0,	 0x1.1500p-48,
+	0x1.11301d0125b5bp+0,	 0x1.c000p-49,
+	0x1.11edbab5e2af9p+0,	 0x1.6bc0p-46,
+	0x1.12abdc06c31d5p+0,	 0x1.8400p-49,
+	0x1.136a814f2047dp+0,	-0x1.ed00p-47,
+	0x1.1429aaea92de9p+0,	 0x1.8e00p-49,
+	0x1.14e95934f3138p+0,	 0x1.b400p-49,
+	0x1.15a98c8a58e71p+0,	 0x1.5300p-47,
+	0x1.166a45471c3dfp+0,	 0x1.3380p-47,
+	0x1.172b83c7d5211p+0,	 0x1.8d40p-45,
+	0x1.17ed48695bb9fp+0,	-0x1.5d00p-47,
+	0x1.18af9388c8d93p+0,	-0x1.c880p-46,
+	0x1.1972658375d66p+0,	 0x1.1f00p-46,
+	0x1.1a35beb6fcba7p+0,	 0x1.0480p-46,
+	0x1.1af99f81387e3p+0,	-0x1.7390p-43,
+	0x1.1bbe084045d54p+0,	 0x1.4e40p-45,
+	0x1.1c82f95281c43p+0,	-0x1.a200p-47,
+	0x1.1d4873168b9b2p+0,	 0x1.3800p-49,
+	0x1.1e0e75eb44031p+0,	 0x1.ac00p-49,
+	0x1.1ed5022fcd938p+0,	 0x1.1900p-47,
+	0x1.1f9c18438cdf7p+0,	-0x1.b780p-46,
+	0x1.2063b88628d8fp+0,	 0x1.d940p-45,
+	0x1.212be3578a81ep+0,	 0x1.8000p-50,
+	0x1.21f49917ddd41p+0,	 0x1.b340p-45,
+	0x1.22bdda2791323p+0,	 0x1.9f80p-46,
+	0x1.2387a6e7561e7p+0,	-0x1.9c80p-46,
+	0x1.2451ffb821427p+0,	 0x1.2300p-47,
+	0x1.251ce4fb2a602p+0,	-0x1.3480p-46,
+	0x1.25e85711eceb0p+0,	 0x1.2700p-46,
+	0x1.26b4565e27d16p+0,	 0x1.1d00p-46,
+	0x1.2780e341de00fp+0,	 0x1.1ee0p-44,
+	0x1.284dfe1f5633ep+0,	-0x1.4c00p-46,
+	0x1.291ba7591bb30p+0,	-0x1.3d80p-46,
+	0x1.29e9df51fdf09p+0,	 0x1.8b00p-47,
+	0x1.2ab8a66d10e9bp+0,	-0x1.27c0p-45,
+	0x1.2b87fd0dada3ap+0,	 0x1.a340p-45,
+	0x1.2c57e39771af9p+0,	-0x1.0800p-46,
+	0x1.2d285a6e402d9p+0,	-0x1.ed00p-47,
+	0x1.2df961f641579p+0,	-0x1.4200p-48,
+	0x1.2ecafa93e2ecfp+0,	-0x1.4980p-45,
+	0x1.2f9d24abd8822p+0,	-0x1.6300p-46,
+	0x1.306fe0a31b625p+0,	-0x1.2360p-44,
+	0x1.31432edeea50bp+0,	-0x1.0df8p-40,
+	0x1.32170fc4cd7b8p+0,	-0x1.2480p-45,
+	0x1.32eb83ba8e9a2p+0,	-0x1.5980p-45,
+	0x1.33c08b2641766p+0,	 0x1.ed00p-46,
+	0x1.3496266e3fa27p+0,	-0x1.c000p-50,
+	0x1.356c55f929f0fp+0,	-0x1.0d80p-44,
+	0x1.36431a2de88b9p+0,	 0x1.2c80p-45,
+	0x1.371a7373aaa39p+0,	 0x1.0600p-45,
+	0x1.37f26231e74fep+0,	-0x1.6600p-46,
+	0x1.38cae6d05d838p+0,	-0x1.ae00p-47,
+	0x1.39a401b713ec3p+0,	-0x1.4720p-43,
+	0x1.3a7db34e5a020p+0,	 0x1.8200p-47,
+	0x1.3b57fbfec6e95p+0,	 0x1.e800p-44,
+	0x1.3c32dc313a8f2p+0,	 0x1.f800p-49,
+	0x1.3d0e544ede122p+0,	-0x1.7a00p-46,
+	0x1.3dea64c1234bbp+0,	 0x1.6300p-45,
+	0x1.3ec70df1c4eccp+0,	-0x1.8a60p-43,
+	0x1.3fa4504ac7e8cp+0,	-0x1.cdc0p-44,
+	0x1.40822c367a0bbp+0,	 0x1.5b80p-45,
+	0x1.4160a21f72e95p+0,	 0x1.ec00p-46,
+	0x1.423fb27094646p+0,	-0x1.3600p-46,
+	0x1.431f5d950a920p+0,	 0x1.3980p-45,
+	0x1.43ffa3f84b9ebp+0,	 0x1.a000p-48,
+	0x1.44e0860618919p+0,	-0x1.6c00p-48,
+	0x1.45c2042a7d201p+0,	-0x1.bc00p-47,
+	0x1.46a41ed1d0016p+0,	-0x1.2800p-46,
+	0x1.4786d668b3326p+0,	 0x1.0e00p-44,
+	0x1.486a2b5c13c00p+0,	-0x1.d400p-45,
+	0x1.494e1e192af04p+0,	 0x1.c200p-47,
+	0x1.4a32af0d7d372p+0,	-0x1.e500p-46,
+	0x1.4b17dea6db801p+0,	 0x1.7800p-47,
+	0x1.4bfdad53629e1p+0,	-0x1.3800p-46,
+	0x1.4ce41b817c132p+0,	 0x1.0800p-47,
+	0x1.4dcb299fddddbp+0,	 0x1.c700p-45,
+	0x1.4eb2d81d8ab96p+0,	-0x1.ce00p-46,
+	0x1.4f9b2769d2d02p+0,	 0x1.9200p-46,
+	0x1.508417f4531c1p+0,	-0x1.8c00p-47,
+	0x1.516daa2cf662ap+0,	-0x1.a000p-48,
+	0x1.5257de83f51eap+0,	 0x1.a080p-43,
+	0x1.5342b569d4edap+0,	-0x1.6d80p-45,
+	0x1.542e2f4f6ac1ap+0,	-0x1.2440p-44,
+	0x1.551a4ca5d94dbp+0,	 0x1.83c0p-43,
+	0x1.56070dde9116bp+0,	 0x1.4b00p-45,
+	0x1.56f4736b529dep+0,	 0x1.15a0p-43,
+	0x1.57e27dbe2c40ep+0,	-0x1.9e00p-45,
+	0x1.58d12d497c76fp+0,	-0x1.3080p-45,
+	0x1.59c0827ff0b4cp+0,	 0x1.dec0p-43,
+	0x1.5ab07dd485427p+0,	-0x1.4000p-51,
+	0x1.5ba11fba87af4p+0,	 0x1.0080p-44,
+	0x1.5c9268a59460bp+0,	-0x1.6c80p-45,
+	0x1.5d84590998e3fp+0,	 0x1.69a0p-43,
+	0x1.5e76f15ad20e1p+0,	-0x1.b400p-46,
+	0x1.5f6a320dcebcap+0,	 0x1.7700p-46,
+	0x1.605e1b976dcb8p+0,	 0x1.6f80p-45,
+	0x1.6152ae6cdf715p+0,	 0x1.1000p-47,
+	0x1.6247eb03a5531p+0,	-0x1.5d00p-46,
+	0x1.633dd1d1929b5p+0,	-0x1.2d00p-46,
+	0x1.6434634ccc313p+0,	-0x1.a800p-49,
+	0x1.652b9febc8efap+0,	-0x1.8600p-45,
+	0x1.6623882553397p+0,	 0x1.1fe0p-40,
+	0x1.671c1c708328ep+0,	-0x1.7200p-44,
+	0x1.68155d44ca97ep+0,	 0x1.6800p-49,
+	0x1.690f4b19e9471p+0,	-0x1.9780p-45,
+};
+
+/*
+ * exp2(x): compute the base 2 exponential of x
+ *
+ * Accuracy: Peak error < 0.503 ulp for normalized results.
+ *
+ * Method: (accurate tables)
+ *
+ *   Reduce x:
+ *     x = 2**k + y, for integer k and |y| <= 1/2.
+ *     Thus we have exp2(x) = 2**k * exp2(y).
+ *
+ *   Reduce y:
+ *     y = i/TBLSIZE + z - eps[i] for integer i near y * TBLSIZE.
+ *     Thus we have exp2(y) = exp2(i/TBLSIZE) * exp2(z - eps[i]),
+ *     with |z - eps[i]| <= 2**-9 + 2**-39 for the table used.
+ *
+ *   We compute exp2(i/TBLSIZE) via table lookup and exp2(z - eps[i]) via
+ *   a degree-5 minimax polynomial with maximum error under 1.3 * 2**-61.
+ *   The values in exp2t[] and eps[] are chosen such that
+ *   exp2t[i] = exp2(i/TBLSIZE + eps[i]), and eps[i] is a small offset such
+ *   that exp2t[i] is accurate to 2**-64.
+ *
+ *   Note that the range of i is +-TBLSIZE/2, so we actually index the tables
+ *   by i0 = i + TBLSIZE/2.  For cache efficiency, exp2t[] and eps[] are
+ *   virtual tables, interleaved in the real table tbl[].
+ *
+ *   This method is due to Gal, with many details due to Gal and Bachelis:
+ *
+ *	Gal, S. and Bachelis, B.  An Accurate Elementary Mathematical Library
+ *	for the IEEE Floating Point Standard.  TOMS 17(1), 26-46 (1991).
+ */
+double
+exp2(double x)
+{
+	double r, t, twopk, twopkp1000, z;
+	uint32_t hx, ix, lx, i0;
+	int k;
+
+	/* Filter out exceptional cases. */
+	GET_HIGH_WORD(hx,x);
+	ix = hx & 0x7fffffff;		/* high word of |x| */
+	if(ix >= 0x40900000) {			/* |x| >= 1024 */
+		if(ix >= 0x7ff00000) {
+			GET_LOW_WORD(lx,x);
+			if(((ix & 0xfffff) | lx) != 0 || (hx & 0x80000000) == 0)
+				return (x + x);	/* x is NaN or +Inf */
+			else 
+				return (0.0);	/* x is -Inf */
+		}
+		if(x >= 0x1.0p10)
+			return (huge * huge); /* overflow */
+		if(x <= -0x1.0ccp10)
+			return (twom1000 * twom1000); /* underflow */
+	} else if (ix < 0x3c900000) {		/* |x| < 0x1p-54 */
+		return (1.0 + x);
+	}
+
+	/* Reduce x, computing z, i0, and k. */
+	STRICT_ASSIGN(double, t, x + redux);
+	GET_LOW_WORD(i0, t);
+	i0 += TBLSIZE / 2;
+	k = (i0 >> TBLBITS) << 20;
+	i0 = (i0 & (TBLSIZE - 1)) << 1;
+	t -= redux;
+	z = x - t;
+
+	/* Compute r = exp2(y) = exp2t[i0] * p(z - eps[i]). */
+	t = tbl[i0];		/* exp2t[i0] */
+	z -= tbl[i0 + 1];	/* eps[i0]   */
+	if (k >= -1021 << 20)
+		INSERT_WORDS(twopk, 0x3ff00000 + k, 0);
+	else
+		INSERT_WORDS(twopkp1000, 0x3ff00000 + k + (1000 << 20), 0);
+	r = t + t * z * (P1 + z * (P2 + z * (P3 + z * (P4 + z * P5))));
+
+	/* Scale by 2**(k>>20). */
+	if(k >= -1021 << 20) {
+		if (k == 1024 << 20)
+			return (r * 2.0 * 0x1p1023);
+		return (r * twopk);
+	} else {
+		return (r * twopkp1000 * twom1000);
+	}
+}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(exp2, exp2l);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/s_exp2f.c b/libm/upstream-freebsd/lib/msun/src/s_exp2f.c
new file mode 100644
index 0000000..0a97bf6
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_exp2f.c
@@ -0,0 +1,136 @@
+/*-
+ * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+#define	TBLBITS	4
+#define	TBLSIZE	(1 << TBLBITS)
+
+static const float
+    huge    = 0x1p100f,
+    redux   = 0x1.8p23f / TBLSIZE,
+    P1	    = 0x1.62e430p-1f,
+    P2	    = 0x1.ebfbe0p-3f,
+    P3	    = 0x1.c6b348p-5f,
+    P4	    = 0x1.3b2c9cp-7f;
+
+static volatile float twom100 = 0x1p-100f;
+
+static const double exp2ft[TBLSIZE] = {
+	0x1.6a09e667f3bcdp-1,
+	0x1.7a11473eb0187p-1,
+	0x1.8ace5422aa0dbp-1,
+	0x1.9c49182a3f090p-1,
+	0x1.ae89f995ad3adp-1,
+	0x1.c199bdd85529cp-1,
+	0x1.d5818dcfba487p-1,
+	0x1.ea4afa2a490dap-1,
+	0x1.0000000000000p+0,
+	0x1.0b5586cf9890fp+0,
+	0x1.172b83c7d517bp+0,
+	0x1.2387a6e756238p+0,
+	0x1.306fe0a31b715p+0,
+	0x1.3dea64c123422p+0,
+	0x1.4bfdad5362a27p+0,
+	0x1.5ab07dd485429p+0,
+};
+	
+/*
+ * exp2f(x): compute the base 2 exponential of x
+ *
+ * Accuracy: Peak error < 0.501 ulp; location of peak: -0.030110927.
+ *
+ * Method: (equally-spaced tables)
+ *
+ *   Reduce x:
+ *     x = 2**k + y, for integer k and |y| <= 1/2.
+ *     Thus we have exp2f(x) = 2**k * exp2(y).
+ *
+ *   Reduce y:
+ *     y = i/TBLSIZE + z for integer i near y * TBLSIZE.
+ *     Thus we have exp2(y) = exp2(i/TBLSIZE) * exp2(z),
+ *     with |z| <= 2**-(TBLSIZE+1).
+ *
+ *   We compute exp2(i/TBLSIZE) via table lookup and exp2(z) via a
+ *   degree-4 minimax polynomial with maximum error under 1.4 * 2**-33.
+ *   Using double precision for everything except the reduction makes
+ *   roundoff error insignificant and simplifies the scaling step.
+ *
+ *   This method is due to Tang, but I do not use his suggested parameters:
+ *
+ *	Tang, P.  Table-driven Implementation of the Exponential Function
+ *	in IEEE Floating-Point Arithmetic.  TOMS 15(2), 144-157 (1989).
+ */
+float
+exp2f(float x)
+{
+	double tv, twopk, u, z;
+	float t;
+	uint32_t hx, ix, i0;
+	int32_t k;
+
+	/* Filter out exceptional cases. */
+	GET_FLOAT_WORD(hx, x);
+	ix = hx & 0x7fffffff;		/* high word of |x| */
+	if(ix >= 0x43000000) {			/* |x| >= 128 */
+		if(ix >= 0x7f800000) {
+			if ((ix & 0x7fffff) != 0 || (hx & 0x80000000) == 0)
+				return (x + x);	/* x is NaN or +Inf */
+			else 
+				return (0.0);	/* x is -Inf */
+		}
+		if(x >= 0x1.0p7f)
+			return (huge * huge);	/* overflow */
+		if(x <= -0x1.2cp7f)
+			return (twom100 * twom100); /* underflow */
+	} else if (ix <= 0x33000000) {		/* |x| <= 0x1p-25 */
+		return (1.0f + x);
+	}
+
+	/* Reduce x, computing z, i0, and k. */
+	STRICT_ASSIGN(float, t, x + redux);
+	GET_FLOAT_WORD(i0, t);
+	i0 += TBLSIZE / 2;
+	k = (i0 >> TBLBITS) << 20;
+	i0 &= TBLSIZE - 1;
+	t -= redux;
+	z = x - t;
+	INSERT_WORDS(twopk, 0x3ff00000 + k, 0);
+
+	/* Compute r = exp2(y) = exp2ft[i0] * p(z). */
+	tv = exp2ft[i0];
+	u = tv * z;
+	tv = tv + u * (P1 + z * P2) + u * (z * z) * (P3 + z * P4);
+
+	/* Scale by 2**(k>>20). */
+	return (tv * twopk);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_expm1.c b/libm/upstream-freebsd/lib/msun/src/s_expm1.c
new file mode 100644
index 0000000..5aa1917
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_expm1.c
@@ -0,0 +1,217 @@
+/* @(#)s_expm1.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* expm1(x)
+ * Returns exp(x)-1, the exponential of x minus 1.
+ *
+ * Method
+ *   1. Argument reduction:
+ *	Given x, find r and integer k such that
+ *
+ *               x = k*ln2 + r,  |r| <= 0.5*ln2 ~ 0.34658
+ *
+ *      Here a correction term c will be computed to compensate
+ *	the error in r when rounded to a floating-point number.
+ *
+ *   2. Approximating expm1(r) by a special rational function on
+ *	the interval [0,0.34658]:
+ *	Since
+ *	    r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 - r^4/360 + ...
+ *	we define R1(r*r) by
+ *	    r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 * R1(r*r)
+ *	That is,
+ *	    R1(r**2) = 6/r *((exp(r)+1)/(exp(r)-1) - 2/r)
+ *		     = 6/r * ( 1 + 2.0*(1/(exp(r)-1) - 1/r))
+ *		     = 1 - r^2/60 + r^4/2520 - r^6/100800 + ...
+ *      We use a special Reme algorithm on [0,0.347] to generate
+ * 	a polynomial of degree 5 in r*r to approximate R1. The
+ *	maximum error of this polynomial approximation is bounded
+ *	by 2**-61. In other words,
+ *	    R1(z) ~ 1.0 + Q1*z + Q2*z**2 + Q3*z**3 + Q4*z**4 + Q5*z**5
+ *	where 	Q1  =  -1.6666666666666567384E-2,
+ * 		Q2  =   3.9682539681370365873E-4,
+ * 		Q3  =  -9.9206344733435987357E-6,
+ * 		Q4  =   2.5051361420808517002E-7,
+ * 		Q5  =  -6.2843505682382617102E-9;
+ *		z   =  r*r,
+ *	with error bounded by
+ *	    |                  5           |     -61
+ *	    | 1.0+Q1*z+...+Q5*z   -  R1(z) | <= 2
+ *	    |                              |
+ *
+ *	expm1(r) = exp(r)-1 is then computed by the following
+ * 	specific way which minimize the accumulation rounding error:
+ *			       2     3
+ *			      r     r    [ 3 - (R1 + R1*r/2)  ]
+ *	      expm1(r) = r + --- + --- * [--------------------]
+ *		              2     2    [ 6 - r*(3 - R1*r/2) ]
+ *
+ *	To compensate the error in the argument reduction, we use
+ *		expm1(r+c) = expm1(r) + c + expm1(r)*c
+ *			   ~ expm1(r) + c + r*c
+ *	Thus c+r*c will be added in as the correction terms for
+ *	expm1(r+c). Now rearrange the term to avoid optimization
+ * 	screw up:
+ *		        (      2                                    2 )
+ *		        ({  ( r    [ R1 -  (3 - R1*r/2) ]  )  }    r  )
+ *	 expm1(r+c)~r - ({r*(--- * [--------------------]-c)-c} - --- )
+ *	                ({  ( 2    [ 6 - r*(3 - R1*r/2) ]  )  }    2  )
+ *                      (                                             )
+ *
+ *		   = r - E
+ *   3. Scale back to obtain expm1(x):
+ *	From step 1, we have
+ *	   expm1(x) = either 2^k*[expm1(r)+1] - 1
+ *		    = or     2^k*[expm1(r) + (1-2^-k)]
+ *   4. Implementation notes:
+ *	(A). To save one multiplication, we scale the coefficient Qi
+ *	     to Qi*2^i, and replace z by (x^2)/2.
+ *	(B). To achieve maximum accuracy, we compute expm1(x) by
+ *	  (i)   if x < -56*ln2, return -1.0, (raise inexact if x!=inf)
+ *	  (ii)  if k=0, return r-E
+ *	  (iii) if k=-1, return 0.5*(r-E)-0.5
+ *        (iv)	if k=1 if r < -0.25, return 2*((r+0.5)- E)
+ *	       	       else	     return  1.0+2.0*(r-E);
+ *	  (v)   if (k<-2||k>56) return 2^k(1-(E-r)) - 1 (or exp(x)-1)
+ *	  (vi)  if k <= 20, return 2^k((1-2^-k)-(E-r)), else
+ *	  (vii) return 2^k(1-((E+2^-k)-r))
+ *
+ * Special cases:
+ *	expm1(INF) is INF, expm1(NaN) is NaN;
+ *	expm1(-INF) is -1, and
+ *	for finite argument, only expm1(0)=0 is exact.
+ *
+ * Accuracy:
+ *	according to an error analysis, the error is always less than
+ *	1 ulp (unit in the last place).
+ *
+ * Misc. info.
+ *	For IEEE double
+ *	    if x >  7.09782712893383973096e+02 then expm1(x) overflow
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following
+ * constants. The decimal values may be used, provided that the
+ * compiler will convert from decimal to binary accurately enough
+ * to produce the hexadecimal values shown.
+ */
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const double
+one		= 1.0,
+huge		= 1.0e+300,
+tiny		= 1.0e-300,
+o_threshold	= 7.09782712893383973096e+02,/* 0x40862E42, 0xFEFA39EF */
+ln2_hi		= 6.93147180369123816490e-01,/* 0x3fe62e42, 0xfee00000 */
+ln2_lo		= 1.90821492927058770002e-10,/* 0x3dea39ef, 0x35793c76 */
+invln2		= 1.44269504088896338700e+00,/* 0x3ff71547, 0x652b82fe */
+/* Scaled Q's: Qn_here = 2**n * Qn_above, for R(2*z) where z = hxs = x*x/2: */
+Q1  =  -3.33333333333331316428e-02, /* BFA11111 111110F4 */
+Q2  =   1.58730158725481460165e-03, /* 3F5A01A0 19FE5585 */
+Q3  =  -7.93650757867487942473e-05, /* BF14CE19 9EAADBB7 */
+Q4  =   4.00821782732936239552e-06, /* 3ED0CFCA 86E65239 */
+Q5  =  -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */
+
+double
+expm1(double x)
+{
+	double y,hi,lo,c,t,e,hxs,hfx,r1,twopk;
+	int32_t k,xsb;
+	u_int32_t hx;
+
+	GET_HIGH_WORD(hx,x);
+	xsb = hx&0x80000000;		/* sign bit of x */
+	hx &= 0x7fffffff;		/* high word of |x| */
+
+    /* filter out huge and non-finite argument */
+	if(hx >= 0x4043687A) {			/* if |x|>=56*ln2 */
+	    if(hx >= 0x40862E42) {		/* if |x|>=709.78... */
+                if(hx>=0x7ff00000) {
+		    u_int32_t low;
+		    GET_LOW_WORD(low,x);
+		    if(((hx&0xfffff)|low)!=0)
+		         return x+x; 	 /* NaN */
+		    else return (xsb==0)? x:-1.0;/* exp(+-inf)={inf,-1} */
+	        }
+	        if(x > o_threshold) return huge*huge; /* overflow */
+	    }
+	    if(xsb!=0) { /* x < -56*ln2, return -1.0 with inexact */
+		if(x+tiny<0.0)		/* raise inexact */
+		return tiny-one;	/* return -1 */
+	    }
+	}
+
+    /* argument reduction */
+	if(hx > 0x3fd62e42) {		/* if  |x| > 0.5 ln2 */
+	    if(hx < 0x3FF0A2B2) {	/* and |x| < 1.5 ln2 */
+		if(xsb==0)
+		    {hi = x - ln2_hi; lo =  ln2_lo;  k =  1;}
+		else
+		    {hi = x + ln2_hi; lo = -ln2_lo;  k = -1;}
+	    } else {
+		k  = invln2*x+((xsb==0)?0.5:-0.5);
+		t  = k;
+		hi = x - t*ln2_hi;	/* t*ln2_hi is exact here */
+		lo = t*ln2_lo;
+	    }
+	    STRICT_ASSIGN(double, x, hi - lo);
+	    c  = (hi-x)-lo;
+	}
+	else if(hx < 0x3c900000) {  	/* when |x|<2**-54, return x */
+	    t = huge+x;	/* return x with inexact flags when x!=0 */
+	    return x - (t-(huge+x));
+	}
+	else k = 0;
+
+    /* x is now in primary range */
+	hfx = 0.5*x;
+	hxs = x*hfx;
+	r1 = one+hxs*(Q1+hxs*(Q2+hxs*(Q3+hxs*(Q4+hxs*Q5))));
+	t  = 3.0-r1*hfx;
+	e  = hxs*((r1-t)/(6.0 - x*t));
+	if(k==0) return x - (x*e-hxs);		/* c is 0 */
+	else {
+	    INSERT_WORDS(twopk,0x3ff00000+(k<<20),0);	/* 2^k */
+	    e  = (x*(e-c)-c);
+	    e -= hxs;
+	    if(k== -1) return 0.5*(x-e)-0.5;
+	    if(k==1) {
+	       	if(x < -0.25) return -2.0*(e-(x+0.5));
+	       	else 	      return  one+2.0*(x-e);
+	    }
+	    if (k <= -2 || k>56) {   /* suffice to return exp(x)-1 */
+	        y = one-(e-x);
+		if (k == 1024) y = y*2.0*0x1p1023;
+		else y = y*twopk;
+	        return y-one;
+	    }
+	    t = one;
+	    if(k<20) {
+	        SET_HIGH_WORD(t,0x3ff00000 - (0x200000>>k));  /* t=1-2^-k */
+	       	y = t-(e-x);
+		y = y*twopk;
+	   } else {
+		SET_HIGH_WORD(t,((0x3ff-k)<<20));	/* 2^-k */
+	       	y = x-(e+t);
+	       	y += one;
+		y = y*twopk;
+	    }
+	}
+	return y;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_expm1f.c b/libm/upstream-freebsd/lib/msun/src/s_expm1f.c
new file mode 100644
index 0000000..fb37494
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_expm1f.c
@@ -0,0 +1,123 @@
+/* s_expm1f.c -- float version of s_expm1.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const float
+one		= 1.0,
+huge		= 1.0e+30,
+tiny		= 1.0e-30,
+o_threshold	= 8.8721679688e+01,/* 0x42b17180 */
+ln2_hi		= 6.9313812256e-01,/* 0x3f317180 */
+ln2_lo		= 9.0580006145e-06,/* 0x3717f7d1 */
+invln2		= 1.4426950216e+00,/* 0x3fb8aa3b */
+/*
+ * Domain [-0.34568, 0.34568], range ~[-6.694e-10, 6.696e-10]:
+ * |6 / x * (1 + 2 * (1 / (exp(x) - 1) - 1 / x)) - q(x)| < 2**-30.04
+ * Scaled coefficients: Qn_here = 2**n * Qn_for_q (see s_expm1.c):
+ */
+Q1 = -3.3333212137e-2,		/* -0x888868.0p-28 */
+Q2 =  1.5807170421e-3;		/*  0xcf3010.0p-33 */
+
+float
+expm1f(float x)
+{
+	float y,hi,lo,c,t,e,hxs,hfx,r1,twopk;
+	int32_t k,xsb;
+	u_int32_t hx;
+
+	GET_FLOAT_WORD(hx,x);
+	xsb = hx&0x80000000;		/* sign bit of x */
+	hx &= 0x7fffffff;		/* high word of |x| */
+
+    /* filter out huge and non-finite argument */
+	if(hx >= 0x4195b844) {			/* if |x|>=27*ln2 */
+	    if(hx >= 0x42b17218) {		/* if |x|>=88.721... */
+                if(hx>0x7f800000)
+		    return x+x; 	 /* NaN */
+		if(hx==0x7f800000)
+		    return (xsb==0)? x:-1.0;/* exp(+-inf)={inf,-1} */
+	        if(x > o_threshold) return huge*huge; /* overflow */
+	    }
+	    if(xsb!=0) { /* x < -27*ln2, return -1.0 with inexact */
+		if(x+tiny<(float)0.0)	/* raise inexact */
+		return tiny-one;	/* return -1 */
+	    }
+	}
+
+    /* argument reduction */
+	if(hx > 0x3eb17218) {		/* if  |x| > 0.5 ln2 */
+	    if(hx < 0x3F851592) {	/* and |x| < 1.5 ln2 */
+		if(xsb==0)
+		    {hi = x - ln2_hi; lo =  ln2_lo;  k =  1;}
+		else
+		    {hi = x + ln2_hi; lo = -ln2_lo;  k = -1;}
+	    } else {
+		k  = invln2*x+((xsb==0)?(float)0.5:(float)-0.5);
+		t  = k;
+		hi = x - t*ln2_hi;	/* t*ln2_hi is exact here */
+		lo = t*ln2_lo;
+	    }
+	    STRICT_ASSIGN(float, x, hi - lo);
+	    c  = (hi-x)-lo;
+	}
+	else if(hx < 0x33000000) {  	/* when |x|<2**-25, return x */
+	    t = huge+x;	/* return x with inexact flags when x!=0 */
+	    return x - (t-(huge+x));
+	}
+	else k = 0;
+
+    /* x is now in primary range */
+	hfx = (float)0.5*x;
+	hxs = x*hfx;
+	r1 = one+hxs*(Q1+hxs*Q2);
+	t  = (float)3.0-r1*hfx;
+	e  = hxs*((r1-t)/((float)6.0 - x*t));
+	if(k==0) return x - (x*e-hxs);		/* c is 0 */
+	else {
+	    SET_FLOAT_WORD(twopk,0x3f800000+(k<<23));	/* 2^k */
+	    e  = (x*(e-c)-c);
+	    e -= hxs;
+	    if(k== -1) return (float)0.5*(x-e)-(float)0.5;
+	    if(k==1) {
+	       	if(x < (float)-0.25) return -(float)2.0*(e-(x+(float)0.5));
+	       	else 	      return  one+(float)2.0*(x-e);
+	    }
+	    if (k <= -2 || k>56) {   /* suffice to return exp(x)-1 */
+	        y = one-(e-x);
+		if (k == 128) y = y*2.0F*0x1p127F;
+		else y = y*twopk;
+	        return y-one;
+	    }
+	    t = one;
+	    if(k<23) {
+	        SET_FLOAT_WORD(t,0x3f800000 - (0x1000000>>k)); /* t=1-2^-k */
+	       	y = t-(e-x);
+		y = y*twopk;
+	   } else {
+		SET_FLOAT_WORD(t,((0x7f-k)<<23));	/* 2^-k */
+	       	y = x-(e+t);
+	       	y += one;
+		y = y*twopk;
+	    }
+	}
+	return y;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fabs.c b/libm/upstream-freebsd/lib/msun/src/s_fabs.c
new file mode 100644
index 0000000..15529e5
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_fabs.c
@@ -0,0 +1,31 @@
+/* @(#)s_fabs.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#ifndef lint
+static char rcsid[] = "$FreeBSD$";
+#endif
+
+/*
+ * fabs(x) returns the absolute value of x.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+double
+fabs(double x)
+{
+	u_int32_t high;
+	GET_HIGH_WORD(high,x);
+	SET_HIGH_WORD(x,high&0x7fffffff);
+        return x;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fabsf.c b/libm/upstream-freebsd/lib/msun/src/s_fabsf.c
new file mode 100644
index 0000000..e9383d0
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_fabsf.c
@@ -0,0 +1,33 @@
+/* s_fabsf.c -- float version of s_fabs.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * fabsf(x) returns the absolute value of x.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+float
+fabsf(float x)
+{
+	u_int32_t ix;
+	GET_FLOAT_WORD(ix,x);
+	SET_FLOAT_WORD(x,ix&0x7fffffff);
+        return x;
+}
diff --git a/libm/src/s_fabsl.c b/libm/upstream-freebsd/lib/msun/src/s_fabsl.c
similarity index 100%
rename from libm/src/s_fabsl.c
rename to libm/upstream-freebsd/lib/msun/src/s_fabsl.c
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fdim.c b/libm/upstream-freebsd/lib/msun/src/s_fdim.c
new file mode 100644
index 0000000..2f347fd
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_fdim.c
@@ -0,0 +1,46 @@
+/*-
+ * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <math.h>
+
+#define	DECL(type, fn)			\
+type					\
+fn(type x, type y)			\
+{					\
+					\
+	if (isnan(x))			\
+		return (x);		\
+	if (isnan(y))			\
+		return (y);		\
+	return (x > y ? x - y : 0.0);	\
+}
+
+DECL(double, fdim)
+DECL(float, fdimf)
+DECL(long double, fdiml)
diff --git a/libm/upstream-freebsd/lib/msun/src/s_finite.c b/libm/upstream-freebsd/lib/msun/src/s_finite.c
new file mode 100644
index 0000000..4c51352
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_finite.c
@@ -0,0 +1,29 @@
+/* @(#)s_finite.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * finite(x) returns 1 is x is finite, else 0;
+ * no branching!
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+	int finite(double x)
+{
+	int32_t hx;
+	GET_HIGH_WORD(hx,x);
+	return (int)((u_int32_t)((hx&0x7fffffff)-0x7ff00000)>>31);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_finitef.c b/libm/upstream-freebsd/lib/msun/src/s_finitef.c
new file mode 100644
index 0000000..c62239e
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_finitef.c
@@ -0,0 +1,32 @@
+/* s_finitef.c -- float version of s_finite.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * finitef(x) returns 1 is x is finite, else 0;
+ * no branching!
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+	int finitef(float x)
+{
+	int32_t ix;
+	GET_FLOAT_WORD(ix,x);
+	return (int)((u_int32_t)((ix&0x7fffffff)-0x7f800000)>>31);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_floor.c b/libm/upstream-freebsd/lib/msun/src/s_floor.c
new file mode 100644
index 0000000..65f696a
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_floor.c
@@ -0,0 +1,78 @@
+/* @(#)s_floor.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * floor(x)
+ * Return x rounded toward -inf to integral value
+ * Method:
+ *	Bit twiddling.
+ * Exception:
+ *	Inexact flag raised if x not equal to floor(x).
+ */
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const double huge = 1.0e300;
+
+double
+floor(double x)
+{
+	int32_t i0,i1,j0;
+	u_int32_t i,j;
+	EXTRACT_WORDS(i0,i1,x);
+	j0 = ((i0>>20)&0x7ff)-0x3ff;
+	if(j0<20) {
+	    if(j0<0) { 	/* raise inexact if x != 0 */
+		if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */
+		    if(i0>=0) {i0=i1=0;}
+		    else if(((i0&0x7fffffff)|i1)!=0)
+			{ i0=0xbff00000;i1=0;}
+		}
+	    } else {
+		i = (0x000fffff)>>j0;
+		if(((i0&i)|i1)==0) return x; /* x is integral */
+		if(huge+x>0.0) {	/* raise inexact flag */
+		    if(i0<0) i0 += (0x00100000)>>j0;
+		    i0 &= (~i); i1=0;
+		}
+	    }
+	} else if (j0>51) {
+	    if(j0==0x400) return x+x;	/* inf or NaN */
+	    else return x;		/* x is integral */
+	} else {
+	    i = ((u_int32_t)(0xffffffff))>>(j0-20);
+	    if((i1&i)==0) return x;	/* x is integral */
+	    if(huge+x>0.0) { 		/* raise inexact flag */
+		if(i0<0) {
+		    if(j0==20) i0+=1;
+		    else {
+			j = i1+(1<<(52-j0));
+			if(j<i1) i0 +=1 ; 	/* got a carry */
+			i1=j;
+		    }
+		}
+		i1 &= (~i);
+	    }
+	}
+	INSERT_WORDS(x,i0,i1);
+	return x;
+}
+
+#if LDBL_MANT_DIG == 53
+__weak_reference(floor, floorl);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/s_floorf.c b/libm/upstream-freebsd/lib/msun/src/s_floorf.c
new file mode 100644
index 0000000..6b510de
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_floorf.c
@@ -0,0 +1,61 @@
+/* s_floorf.c -- float version of s_floor.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * floorf(x)
+ * Return x rounded toward -inf to integral value
+ * Method:
+ *	Bit twiddling.
+ * Exception:
+ *	Inexact flag raised if x not equal to floorf(x).
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+static const float huge = 1.0e30;
+
+float
+floorf(float x)
+{
+	int32_t i0,j0;
+	u_int32_t i;
+	GET_FLOAT_WORD(i0,x);
+	j0 = ((i0>>23)&0xff)-0x7f;
+	if(j0<23) {
+	    if(j0<0) { 	/* raise inexact if x != 0 */
+		if(huge+x>(float)0.0) {/* return 0*sign(x) if |x|<1 */
+		    if(i0>=0) {i0=0;}
+		    else if((i0&0x7fffffff)!=0)
+			{ i0=0xbf800000;}
+		}
+	    } else {
+		i = (0x007fffff)>>j0;
+		if((i0&i)==0) return x; /* x is integral */
+		if(huge+x>(float)0.0) {	/* raise inexact flag */
+		    if(i0<0) i0 += (0x00800000)>>j0;
+		    i0 &= (~i);
+		}
+	    }
+	} else {
+	    if(j0==0x80) return x+x;	/* inf or NaN */
+	    else return x;		/* x is integral */
+	}
+	SET_FLOAT_WORD(x,i0);
+	return x;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_floorl.c b/libm/upstream-freebsd/lib/msun/src/s_floorl.c
new file mode 100644
index 0000000..6cec3e7
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_floorl.c
@@ -0,0 +1,101 @@
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ * From: @(#)s_floor.c 5.1 93/09/24
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * floorl(x)
+ * Return x rounded toward -inf to integral value
+ * Method:
+ *	Bit twiddling.
+ * Exception:
+ *	Inexact flag raised if x not equal to floorl(x).
+ */
+
+#include <float.h>
+#include <math.h>
+#include <stdint.h>
+
+#include "fpmath.h"
+
+#ifdef LDBL_IMPLICIT_NBIT
+#define	MANH_SIZE	(LDBL_MANH_SIZE + 1)
+#define	INC_MANH(u, c)	do {					\
+	uint64_t o = u.bits.manh;				\
+	u.bits.manh += (c);					\
+	if (u.bits.manh < o)					\
+		u.bits.exp++;					\
+} while (0)
+#else
+#define	MANH_SIZE	LDBL_MANH_SIZE
+#define	INC_MANH(u, c)	do {					\
+	uint64_t o = u.bits.manh;				\
+	u.bits.manh += (c);					\
+	if (u.bits.manh < o) {					\
+		u.bits.exp++;					\
+		u.bits.manh |= 1llu << (LDBL_MANH_SIZE - 1);	\
+	}							\
+} while (0)
+#endif
+
+static const long double huge = 1.0e300;
+
+long double
+floorl(long double x)
+{
+	union IEEEl2bits u = { .e = x };
+	int e = u.bits.exp - LDBL_MAX_EXP + 1;
+
+	if (e < MANH_SIZE - 1) {
+		if (e < 0) {			/* raise inexact if x != 0 */
+			if (huge + x > 0.0)
+				if (u.bits.exp > 0 ||
+				    (u.bits.manh | u.bits.manl) != 0)
+					u.e = u.bits.sign ? -1.0 : 0.0;
+		} else {
+			uint64_t m = ((1llu << MANH_SIZE) - 1) >> (e + 1);
+			if (((u.bits.manh & m) | u.bits.manl) == 0)
+				return (x);	/* x is integral */
+			if (u.bits.sign) {
+#ifdef LDBL_IMPLICIT_NBIT
+				if (e == 0)
+					u.bits.exp++;
+				else
+#endif
+				INC_MANH(u, 1llu << (MANH_SIZE - e - 1));
+			}
+			if (huge + x > 0.0) {	/* raise inexact flag */
+				u.bits.manh &= ~m;
+				u.bits.manl = 0;
+			}
+		}
+	} else if (e < LDBL_MANT_DIG - 1) {
+		uint64_t m = (uint64_t)-1 >> (64 - LDBL_MANT_DIG + e + 1);
+		if ((u.bits.manl & m) == 0)
+			return (x);	/* x is integral */
+		if (u.bits.sign) {
+			if (e == MANH_SIZE - 1)
+				INC_MANH(u, 1);
+			else {
+				uint64_t o = u.bits.manl;
+				u.bits.manl += 1llu << (LDBL_MANT_DIG - e - 1);
+				if (u.bits.manl < o)	/* got a carry */
+					INC_MANH(u, 1);
+			}
+		}
+		if (huge + x > 0.0)		/* raise inexact flag */
+			u.bits.manl &= ~m;
+	}
+	return (u.e);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fma.c b/libm/upstream-freebsd/lib/msun/src/s_fma.c
new file mode 100644
index 0000000..dfbd13c
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_fma.c
@@ -0,0 +1,284 @@
+/*-
+ * Copyright (c) 2005-2011 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <fenv.h>
+#include <float.h>
+#include <math.h>
+
+#include "math_private.h"
+
+/*
+ * A struct dd represents a floating-point number with twice the precision
+ * of a double.  We maintain the invariant that "hi" stores the 53 high-order
+ * bits of the result.
+ */
+struct dd {
+	double hi;
+	double lo;
+};
+
+/*
+ * Compute a+b exactly, returning the exact result in a struct dd.  We assume
+ * that both a and b are finite, but make no assumptions about their relative
+ * magnitudes.
+ */
+static inline struct dd
+dd_add(double a, double b)
+{
+	struct dd ret;
+	double s;
+
+	ret.hi = a + b;
+	s = ret.hi - a;
+	ret.lo = (a - (ret.hi - s)) + (b - s);
+	return (ret);
+}
+
+/*
+ * Compute a+b, with a small tweak:  The least significant bit of the
+ * result is adjusted into a sticky bit summarizing all the bits that
+ * were lost to rounding.  This adjustment negates the effects of double
+ * rounding when the result is added to another number with a higher
+ * exponent.  For an explanation of round and sticky bits, see any reference
+ * on FPU design, e.g.,
+ *
+ *     J. Coonen.  An Implementation Guide to a Proposed Standard for
+ *     Floating-Point Arithmetic.  Computer, vol. 13, no. 1, Jan 1980.
+ */
+static inline double
+add_adjusted(double a, double b)
+{
+	struct dd sum;
+	uint64_t hibits, lobits;
+
+	sum = dd_add(a, b);
+	if (sum.lo != 0) {
+		EXTRACT_WORD64(hibits, sum.hi);
+		if ((hibits & 1) == 0) {
+			/* hibits += (int)copysign(1.0, sum.hi * sum.lo) */
+			EXTRACT_WORD64(lobits, sum.lo);
+			hibits += 1 - ((hibits ^ lobits) >> 62);
+			INSERT_WORD64(sum.hi, hibits);
+		}
+	}
+	return (sum.hi);
+}
+
+/*
+ * Compute ldexp(a+b, scale) with a single rounding error. It is assumed
+ * that the result will be subnormal, and care is taken to ensure that
+ * double rounding does not occur.
+ */
+static inline double
+add_and_denormalize(double a, double b, int scale)
+{
+	struct dd sum;
+	uint64_t hibits, lobits;
+	int bits_lost;
+
+	sum = dd_add(a, b);
+
+	/*
+	 * If we are losing at least two bits of accuracy to denormalization,
+	 * then the first lost bit becomes a round bit, and we adjust the
+	 * lowest bit of sum.hi to make it a sticky bit summarizing all the
+	 * bits in sum.lo. With the sticky bit adjusted, the hardware will
+	 * break any ties in the correct direction.
+	 *
+	 * If we are losing only one bit to denormalization, however, we must
+	 * break the ties manually.
+	 */
+	if (sum.lo != 0) {
+		EXTRACT_WORD64(hibits, sum.hi);
+		bits_lost = -((int)(hibits >> 52) & 0x7ff) - scale + 1;
+		if (bits_lost != 1 ^ (int)(hibits & 1)) {
+			/* hibits += (int)copysign(1.0, sum.hi * sum.lo) */
+			EXTRACT_WORD64(lobits, sum.lo);
+			hibits += 1 - (((hibits ^ lobits) >> 62) & 2);
+			INSERT_WORD64(sum.hi, hibits);
+		}
+	}
+	return (ldexp(sum.hi, scale));
+}
+
+/*
+ * Compute a*b exactly, returning the exact result in a struct dd.  We assume
+ * that both a and b are normalized, so no underflow or overflow will occur.
+ * The current rounding mode must be round-to-nearest.
+ */
+static inline struct dd
+dd_mul(double a, double b)
+{
+	static const double split = 0x1p27 + 1.0;
+	struct dd ret;
+	double ha, hb, la, lb, p, q;
+
+	p = a * split;
+	ha = a - p;
+	ha += p;
+	la = a - ha;
+
+	p = b * split;
+	hb = b - p;
+	hb += p;
+	lb = b - hb;
+
+	p = ha * hb;
+	q = ha * lb + la * hb;
+
+	ret.hi = p + q;
+	ret.lo = p - ret.hi + q + la * lb;
+	return (ret);
+}
+
+/*
+ * Fused multiply-add: Compute x * y + z with a single rounding error.
+ *
+ * We use scaling to avoid overflow/underflow, along with the
+ * canonical precision-doubling technique adapted from:
+ *
+ *	Dekker, T.  A Floating-Point Technique for Extending the
+ *	Available Precision.  Numer. Math. 18, 224-242 (1971).
+ *
+ * This algorithm is sensitive to the rounding precision.  FPUs such
+ * as the i387 must be set in double-precision mode if variables are
+ * to be stored in FP registers in order to avoid incorrect results.
+ * This is the default on FreeBSD, but not on many other systems.
+ *
+ * Hardware instructions should be used on architectures that support it,
+ * since this implementation will likely be several times slower.
+ */
+double
+fma(double x, double y, double z)
+{
+	double xs, ys, zs, adj;
+	struct dd xy, r;
+	int oround;
+	int ex, ey, ez;
+	int spread;
+
+	/*
+	 * Handle special cases. The order of operations and the particular
+	 * return values here are crucial in handling special cases involving
+	 * infinities, NaNs, overflows, and signed zeroes correctly.
+	 */
+	if (x == 0.0 || y == 0.0)
+		return (x * y + z);
+	if (z == 0.0)
+		return (x * y);
+	if (!isfinite(x) || !isfinite(y))
+		return (x * y + z);
+	if (!isfinite(z))
+		return (z);
+
+	xs = frexp(x, &ex);
+	ys = frexp(y, &ey);
+	zs = frexp(z, &ez);
+	oround = fegetround();
+	spread = ex + ey - ez;
+
+	/*
+	 * If x * y and z are many orders of magnitude apart, the scaling
+	 * will overflow, so we handle these cases specially.  Rounding
+	 * modes other than FE_TONEAREST are painful.
+	 */
+	if (spread < -DBL_MANT_DIG) {
+		feraiseexcept(FE_INEXACT);
+		if (!isnormal(z))
+			feraiseexcept(FE_UNDERFLOW);
+		switch (oround) {
+		case FE_TONEAREST:
+			return (z);
+		case FE_TOWARDZERO:
+			if (x > 0.0 ^ y < 0.0 ^ z < 0.0)
+				return (z);
+			else
+				return (nextafter(z, 0));
+		case FE_DOWNWARD:
+			if (x > 0.0 ^ y < 0.0)
+				return (z);
+			else
+				return (nextafter(z, -INFINITY));
+		default:	/* FE_UPWARD */
+			if (x > 0.0 ^ y < 0.0)
+				return (nextafter(z, INFINITY));
+			else
+				return (z);
+		}
+	}
+	if (spread <= DBL_MANT_DIG * 2)
+		zs = ldexp(zs, -spread);
+	else
+		zs = copysign(DBL_MIN, zs);
+
+	fesetround(FE_TONEAREST);
+
+	/*
+	 * Basic approach for round-to-nearest:
+	 *
+	 *     (xy.hi, xy.lo) = x * y		(exact)
+	 *     (r.hi, r.lo)   = xy.hi + z	(exact)
+	 *     adj = xy.lo + r.lo		(inexact; low bit is sticky)
+	 *     result = r.hi + adj		(correctly rounded)
+	 */
+	xy = dd_mul(xs, ys);
+	r = dd_add(xy.hi, zs);
+
+	spread = ex + ey;
+
+	if (r.hi == 0.0) {
+		/*
+		 * When the addends cancel to 0, ensure that the result has
+		 * the correct sign.
+		 */
+		fesetround(oround);
+		volatile double vzs = zs; /* XXX gcc CSE bug workaround */
+		return (xy.hi + vzs + ldexp(xy.lo, spread));
+	}
+
+	if (oround != FE_TONEAREST) {
+		/*
+		 * There is no need to worry about double rounding in directed
+		 * rounding modes.
+		 */
+		fesetround(oround);
+		adj = r.lo + xy.lo;
+		return (ldexp(r.hi + adj, spread));
+	}
+
+	adj = add_adjusted(r.lo, xy.lo);
+	if (spread + ilogb(r.hi) > -1023)
+		return (ldexp(r.hi + adj, spread));
+	else
+		return (add_and_denormalize(r.hi, adj, spread));
+}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(fma, fmal);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fmaf.c b/libm/upstream-freebsd/lib/msun/src/s_fmaf.c
new file mode 100644
index 0000000..3695823
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_fmaf.c
@@ -0,0 +1,69 @@
+/*-
+ * Copyright (c) 2005-2011 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <fenv.h>
+
+#include "math.h"
+#include "math_private.h"
+
+/*
+ * Fused multiply-add: Compute x * y + z with a single rounding error.
+ *
+ * A double has more than twice as much precision than a float, so
+ * direct double-precision arithmetic suffices, except where double
+ * rounding occurs.
+ */
+float
+fmaf(float x, float y, float z)
+{
+	double xy, result;
+	uint32_t hr, lr;
+
+	xy = (double)x * y;
+	result = xy + z;
+	EXTRACT_WORDS(hr, lr, result);
+	/* Common case: The double precision result is fine. */
+	if ((lr & 0x1fffffff) != 0x10000000 ||	/* not a halfway case */
+	    (hr & 0x7ff00000) == 0x7ff00000 ||	/* NaN */
+	    result - xy == z ||			/* exact */
+	    fegetround() != FE_TONEAREST)	/* not round-to-nearest */
+		return (result);
+
+	/*
+	 * If result is inexact, and exactly halfway between two float values,
+	 * we need to adjust the low-order bit in the direction of the error.
+	 */
+	fesetround(FE_TOWARDZERO);
+	volatile double vxy = xy;  /* XXX work around gcc CSE bug */
+	double adjusted_result = vxy + z;
+	fesetround(FE_TONEAREST);
+	if (result == adjusted_result)
+		SET_LOW_WORD(adjusted_result, lr + 1);
+	return (adjusted_result);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fmal.c b/libm/upstream-freebsd/lib/msun/src/s_fmal.c
new file mode 100644
index 0000000..c2a6913
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_fmal.c
@@ -0,0 +1,268 @@
+/*-
+ * Copyright (c) 2005-2011 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <fenv.h>
+#include <float.h>
+#include <math.h>
+
+#include "fpmath.h"
+
+/*
+ * A struct dd represents a floating-point number with twice the precision
+ * of a long double.  We maintain the invariant that "hi" stores the high-order
+ * bits of the result.
+ */
+struct dd {
+	long double hi;
+	long double lo;
+};
+
+/*
+ * Compute a+b exactly, returning the exact result in a struct dd.  We assume
+ * that both a and b are finite, but make no assumptions about their relative
+ * magnitudes.
+ */
+static inline struct dd
+dd_add(long double a, long double b)
+{
+	struct dd ret;
+	long double s;
+
+	ret.hi = a + b;
+	s = ret.hi - a;
+	ret.lo = (a - (ret.hi - s)) + (b - s);
+	return (ret);
+}
+
+/*
+ * Compute a+b, with a small tweak:  The least significant bit of the
+ * result is adjusted into a sticky bit summarizing all the bits that
+ * were lost to rounding.  This adjustment negates the effects of double
+ * rounding when the result is added to another number with a higher
+ * exponent.  For an explanation of round and sticky bits, see any reference
+ * on FPU design, e.g.,
+ *
+ *     J. Coonen.  An Implementation Guide to a Proposed Standard for
+ *     Floating-Point Arithmetic.  Computer, vol. 13, no. 1, Jan 1980.
+ */
+static inline long double
+add_adjusted(long double a, long double b)
+{
+	struct dd sum;
+	union IEEEl2bits u;
+
+	sum = dd_add(a, b);
+	if (sum.lo != 0) {
+		u.e = sum.hi;
+		if ((u.bits.manl & 1) == 0)
+			sum.hi = nextafterl(sum.hi, INFINITY * sum.lo);
+	}
+	return (sum.hi);
+}
+
+/*
+ * Compute ldexp(a+b, scale) with a single rounding error. It is assumed
+ * that the result will be subnormal, and care is taken to ensure that
+ * double rounding does not occur.
+ */
+static inline long double
+add_and_denormalize(long double a, long double b, int scale)
+{
+	struct dd sum;
+	int bits_lost;
+	union IEEEl2bits u;
+
+	sum = dd_add(a, b);
+
+	/*
+	 * If we are losing at least two bits of accuracy to denormalization,
+	 * then the first lost bit becomes a round bit, and we adjust the
+	 * lowest bit of sum.hi to make it a sticky bit summarizing all the
+	 * bits in sum.lo. With the sticky bit adjusted, the hardware will
+	 * break any ties in the correct direction.
+	 *
+	 * If we are losing only one bit to denormalization, however, we must
+	 * break the ties manually.
+	 */
+	if (sum.lo != 0) {
+		u.e = sum.hi;
+		bits_lost = -u.bits.exp - scale + 1;
+		if (bits_lost != 1 ^ (int)(u.bits.manl & 1))
+			sum.hi = nextafterl(sum.hi, INFINITY * sum.lo);
+	}
+	return (ldexp(sum.hi, scale));
+}
+
+/*
+ * Compute a*b exactly, returning the exact result in a struct dd.  We assume
+ * that both a and b are normalized, so no underflow or overflow will occur.
+ * The current rounding mode must be round-to-nearest.
+ */
+static inline struct dd
+dd_mul(long double a, long double b)
+{
+#if LDBL_MANT_DIG == 64
+	static const long double split = 0x1p32L + 1.0;
+#elif LDBL_MANT_DIG == 113
+	static const long double split = 0x1p57L + 1.0;
+#endif
+	struct dd ret;
+	long double ha, hb, la, lb, p, q;
+
+	p = a * split;
+	ha = a - p;
+	ha += p;
+	la = a - ha;
+
+	p = b * split;
+	hb = b - p;
+	hb += p;
+	lb = b - hb;
+
+	p = ha * hb;
+	q = ha * lb + la * hb;
+
+	ret.hi = p + q;
+	ret.lo = p - ret.hi + q + la * lb;
+	return (ret);
+}
+
+/*
+ * Fused multiply-add: Compute x * y + z with a single rounding error.
+ *
+ * We use scaling to avoid overflow/underflow, along with the
+ * canonical precision-doubling technique adapted from:
+ *
+ *	Dekker, T.  A Floating-Point Technique for Extending the
+ *	Available Precision.  Numer. Math. 18, 224-242 (1971).
+ */
+long double
+fmal(long double x, long double y, long double z)
+{
+	long double xs, ys, zs, adj;
+	struct dd xy, r;
+	int oround;
+	int ex, ey, ez;
+	int spread;
+
+	/*
+	 * Handle special cases. The order of operations and the particular
+	 * return values here are crucial in handling special cases involving
+	 * infinities, NaNs, overflows, and signed zeroes correctly.
+	 */
+	if (x == 0.0 || y == 0.0)
+		return (x * y + z);
+	if (z == 0.0)
+		return (x * y);
+	if (!isfinite(x) || !isfinite(y))
+		return (x * y + z);
+	if (!isfinite(z))
+		return (z);
+
+	xs = frexpl(x, &ex);
+	ys = frexpl(y, &ey);
+	zs = frexpl(z, &ez);
+	oround = fegetround();
+	spread = ex + ey - ez;
+
+	/*
+	 * If x * y and z are many orders of magnitude apart, the scaling
+	 * will overflow, so we handle these cases specially.  Rounding
+	 * modes other than FE_TONEAREST are painful.
+	 */
+	if (spread < -LDBL_MANT_DIG) {
+		feraiseexcept(FE_INEXACT);
+		if (!isnormal(z))
+			feraiseexcept(FE_UNDERFLOW);
+		switch (oround) {
+		case FE_TONEAREST:
+			return (z);
+		case FE_TOWARDZERO:
+			if (x > 0.0 ^ y < 0.0 ^ z < 0.0)
+				return (z);
+			else
+				return (nextafterl(z, 0));
+		case FE_DOWNWARD:
+			if (x > 0.0 ^ y < 0.0)
+				return (z);
+			else
+				return (nextafterl(z, -INFINITY));
+		default:	/* FE_UPWARD */
+			if (x > 0.0 ^ y < 0.0)
+				return (nextafterl(z, INFINITY));
+			else
+				return (z);
+		}
+	}
+	if (spread <= LDBL_MANT_DIG * 2)
+		zs = ldexpl(zs, -spread);
+	else
+		zs = copysignl(LDBL_MIN, zs);
+
+	fesetround(FE_TONEAREST);
+
+	/*
+	 * Basic approach for round-to-nearest:
+	 *
+	 *     (xy.hi, xy.lo) = x * y		(exact)
+	 *     (r.hi, r.lo)   = xy.hi + z	(exact)
+	 *     adj = xy.lo + r.lo		(inexact; low bit is sticky)
+	 *     result = r.hi + adj		(correctly rounded)
+	 */
+	xy = dd_mul(xs, ys);
+	r = dd_add(xy.hi, zs);
+
+	spread = ex + ey;
+
+	if (r.hi == 0.0) {
+		/*
+		 * When the addends cancel to 0, ensure that the result has
+		 * the correct sign.
+		 */
+		fesetround(oround);
+		volatile long double vzs = zs; /* XXX gcc CSE bug workaround */
+		return (xy.hi + vzs + ldexpl(xy.lo, spread));
+	}
+
+	if (oround != FE_TONEAREST) {
+		/*
+		 * There is no need to worry about double rounding in directed
+		 * rounding modes.
+		 */
+		fesetround(oround);
+		adj = r.lo + xy.lo;
+		return (ldexpl(r.hi + adj, spread));
+	}
+
+	adj = add_adjusted(r.lo, xy.lo);
+	if (spread + ilogbl(r.hi) > -16383)
+		return (ldexpl(r.hi + adj, spread));
+	else
+		return (add_and_denormalize(r.hi, adj, spread));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fmax.c b/libm/upstream-freebsd/lib/msun/src/s_fmax.c
new file mode 100644
index 0000000..b51b865
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_fmax.c
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <math.h>
+
+#include "fpmath.h"
+
+double
+fmax(double x, double y)
+{
+	union IEEEd2bits u[2];
+
+	u[0].d = x;
+	u[1].d = y;
+
+	/* Check for NaNs to avoid raising spurious exceptions. */
+	if (u[0].bits.exp == 2047 && (u[0].bits.manh | u[0].bits.manl) != 0)
+		return (y);
+	if (u[1].bits.exp == 2047 && (u[1].bits.manh | u[1].bits.manl) != 0)
+		return (x);
+
+	/* Handle comparisons of signed zeroes. */
+	if (u[0].bits.sign != u[1].bits.sign)
+		return (u[u[0].bits.sign].d);
+
+	return (x > y ? x : y);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fmaxf.c b/libm/upstream-freebsd/lib/msun/src/s_fmaxf.c
new file mode 100644
index 0000000..423da54
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_fmaxf.c
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <math.h>
+
+#include "fpmath.h"
+
+float
+fmaxf(float x, float y)
+{
+	union IEEEf2bits u[2];
+
+	u[0].f = x;
+	u[1].f = y;
+
+	/* Check for NaNs to avoid raising spurious exceptions. */
+	if (u[0].bits.exp == 255 && u[0].bits.man != 0)
+		return (y);
+	if (u[1].bits.exp == 255 && u[1].bits.man != 0)
+		return (x);
+
+	/* Handle comparisons of signed zeroes. */
+	if (u[0].bits.sign != u[1].bits.sign)
+		return (u[u[0].bits.sign].f);
+
+	return (x > y ? x : y);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fmaxl.c b/libm/upstream-freebsd/lib/msun/src/s_fmaxl.c
new file mode 100644
index 0000000..0ac48a9
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_fmaxl.c
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <math.h>
+
+#include "fpmath.h"
+
+long double
+fmaxl(long double x, long double y)
+{
+	union IEEEl2bits u[2];
+
+	u[0].e = x;
+	mask_nbit_l(u[0]);
+	u[1].e = y;
+	mask_nbit_l(u[1]);
+
+	/* Check for NaNs to avoid raising spurious exceptions. */
+	if (u[0].bits.exp == 32767 && (u[0].bits.manh | u[0].bits.manl) != 0)
+		return (y);
+	if (u[1].bits.exp == 32767 && (u[1].bits.manh | u[1].bits.manl) != 0)
+		return (x);
+
+	/* Handle comparisons of signed zeroes. */
+	if (u[0].bits.sign != u[1].bits.sign)
+		return (u[0].bits.sign ? y : x);
+
+	return (x > y ? x : y);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fmin.c b/libm/upstream-freebsd/lib/msun/src/s_fmin.c
new file mode 100644
index 0000000..3500c84
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_fmin.c
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <math.h>
+
+#include "fpmath.h"
+
+double
+fmin(double x, double y)
+{
+	union IEEEd2bits u[2];
+
+	u[0].d = x;
+	u[1].d = y;
+
+	/* Check for NaNs to avoid raising spurious exceptions. */
+	if (u[0].bits.exp == 2047 && (u[0].bits.manh | u[0].bits.manl) != 0)
+		return (y);
+	if (u[1].bits.exp == 2047 && (u[1].bits.manh | u[1].bits.manl) != 0)
+		return (x);
+
+	/* Handle comparisons of signed zeroes. */
+	if (u[0].bits.sign != u[1].bits.sign)
+		return (u[u[1].bits.sign].d);
+
+	return (x < y ? x : y);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fminf.c b/libm/upstream-freebsd/lib/msun/src/s_fminf.c
new file mode 100644
index 0000000..76a5c76
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_fminf.c
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <math.h>
+
+#include "fpmath.h"
+
+float
+fminf(float x, float y)
+{
+	union IEEEf2bits u[2];
+
+	u[0].f = x;
+	u[1].f = y;
+
+	/* Check for NaNs to avoid raising spurious exceptions. */
+	if (u[0].bits.exp == 255 && u[0].bits.man != 0)
+		return (y);
+	if (u[1].bits.exp == 255 && u[1].bits.man != 0)
+		return (x);
+
+	/* Handle comparisons of signed zeroes. */
+	if (u[0].bits.sign != u[1].bits.sign)
+		return (u[u[1].bits.sign].f);
+
+	return (x < y ? x : y);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fminl.c b/libm/upstream-freebsd/lib/msun/src/s_fminl.c
new file mode 100644
index 0000000..f9d3ebb
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_fminl.c
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <math.h>
+
+#include "fpmath.h"
+
+long double
+fminl(long double x, long double y)
+{
+	union IEEEl2bits u[2];
+
+	u[0].e = x;
+	mask_nbit_l(u[0]);
+	u[1].e = y;
+	mask_nbit_l(u[1]);
+
+	/* Check for NaNs to avoid raising spurious exceptions. */
+	if (u[0].bits.exp == 32767 && (u[0].bits.manh | u[0].bits.manl) != 0)
+		return (y);
+	if (u[1].bits.exp == 32767 && (u[1].bits.manh | u[1].bits.manl) != 0)
+		return (x);
+
+	/* Handle comparisons of signed zeroes. */
+	if (u[0].bits.sign != u[1].bits.sign)
+		return (u[1].bits.sign ? y : x);
+
+	return (x < y ? x : y);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_frexp.c b/libm/upstream-freebsd/lib/msun/src/s_frexp.c
new file mode 100644
index 0000000..318a991
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_frexp.c
@@ -0,0 +1,56 @@
+/* @(#)s_frexp.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * for non-zero x
+ *	x = frexp(arg,&exp);
+ * return a double fp quantity x such that 0.5 <= |x| <1.0
+ * and the corresponding binary exponent "exp". That is
+ *	arg = x*2^exp.
+ * If arg is inf, 0.0, or NaN, then frexp(arg,&exp) returns arg
+ * with *exp=0.
+ */
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const double
+two54 =  1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */
+
+double
+frexp(double x, int *eptr)
+{
+	int32_t hx, ix, lx;
+	EXTRACT_WORDS(hx,lx,x);
+	ix = 0x7fffffff&hx;
+	*eptr = 0;
+	if(ix>=0x7ff00000||((ix|lx)==0)) return x;	/* 0,inf,nan */
+	if (ix<0x00100000) {		/* subnormal */
+	    x *= two54;
+	    GET_HIGH_WORD(hx,x);
+	    ix = hx&0x7fffffff;
+	    *eptr = -54;
+	}
+	*eptr += (ix>>20)-1022;
+	hx = (hx&0x800fffff)|0x3fe00000;
+	SET_HIGH_WORD(x,hx);
+	return x;
+}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(frexp, frexpl);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/s_frexpf.c b/libm/upstream-freebsd/lib/msun/src/s_frexpf.c
new file mode 100644
index 0000000..5a7c486
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_frexpf.c
@@ -0,0 +1,43 @@
+/* s_frexpf.c -- float version of s_frexp.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static const float
+two25 =  3.3554432000e+07; /* 0x4c000000 */
+
+float
+frexpf(float x, int *eptr)
+{
+	int32_t hx,ix;
+	GET_FLOAT_WORD(hx,x);
+	ix = 0x7fffffff&hx;
+	*eptr = 0;
+	if(ix>=0x7f800000||(ix==0)) return x;	/* 0,inf,nan */
+	if (ix<0x00800000) {		/* subnormal */
+	    x *= two25;
+	    GET_FLOAT_WORD(hx,x);
+	    ix = hx&0x7fffffff;
+	    *eptr = -25;
+	}
+	*eptr += (ix>>23)-126;
+	hx = (hx&0x807fffff)|0x3f000000;
+	SET_FLOAT_WORD(x,hx);
+	return x;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_frexpl.c b/libm/upstream-freebsd/lib/msun/src/s_frexpl.c
new file mode 100644
index 0000000..d34f55d
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_frexpl.c
@@ -0,0 +1,62 @@
+/*-
+ * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <float.h>
+#include <math.h>
+
+#include "fpmath.h"
+
+#if LDBL_MAX_EXP != 0x4000
+#error "Unsupported long double format"
+#endif
+
+long double
+frexpl(long double x, int *ex)
+{
+	union IEEEl2bits u;
+
+	u.e = x;
+	switch (u.bits.exp) {
+	case 0:		/* 0 or subnormal */
+		if ((u.bits.manl | u.bits.manh) == 0) {
+			*ex = 0;
+		} else {
+			u.e *= 0x1.0p514;
+			*ex = u.bits.exp - 0x4200;
+			u.bits.exp = 0x3ffe;
+		}
+		break;
+	case 0x7fff:	/* infinity or NaN; value of *ex is unspecified */
+		break;
+	default:	/* normal */
+		*ex = u.bits.exp - 0x3ffe;
+		u.bits.exp = 0x3ffe;
+		break;
+	}
+	return (u.e);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_ilogb.c b/libm/upstream-freebsd/lib/msun/src/s_ilogb.c
new file mode 100644
index 0000000..a930bc9
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_ilogb.c
@@ -0,0 +1,48 @@
+/* @(#)s_ilogb.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* ilogb(double x)
+ * return the binary exponent of non-zero x
+ * ilogb(0) = FP_ILOGB0
+ * ilogb(NaN) = FP_ILOGBNAN (no signal is raised)
+ * ilogb(inf) = INT_MAX (no signal is raised)
+ */
+
+#include <limits.h>
+
+#include "math.h"
+#include "math_private.h"
+
+	int ilogb(double x)
+{
+	int32_t hx,lx,ix;
+
+	EXTRACT_WORDS(hx,lx,x);
+	hx &= 0x7fffffff;
+	if(hx<0x00100000) {
+	    if((hx|lx)==0)
+		return FP_ILOGB0;
+	    else			/* subnormal x */
+		if(hx==0) {
+		    for (ix = -1043; lx>0; lx<<=1) ix -=1;
+		} else {
+		    for (ix = -1022,hx<<=11; hx>0; hx<<=1) ix -=1;
+		}
+	    return ix;
+	}
+	else if (hx<0x7ff00000) return (hx>>20)-1023;
+	else if (hx>0x7ff00000 || lx!=0) return FP_ILOGBNAN;
+	else return INT_MAX;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_ilogbf.c b/libm/upstream-freebsd/lib/msun/src/s_ilogbf.c
new file mode 100644
index 0000000..93fe295
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_ilogbf.c
@@ -0,0 +1,40 @@
+/* s_ilogbf.c -- float version of s_ilogb.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <limits.h>
+
+#include "math.h"
+#include "math_private.h"
+
+	int ilogbf(float x)
+{
+	int32_t hx,ix;
+
+	GET_FLOAT_WORD(hx,x);
+	hx &= 0x7fffffff;
+	if(hx<0x00800000) {
+	    if(hx==0)
+		return FP_ILOGB0;
+	    else			/* subnormal x */
+	        for (ix = -126,hx<<=8; hx>0; hx<<=1) ix -=1;
+	    return ix;
+	}
+	else if (hx<0x7f800000) return (hx>>23)-127;
+	else if (hx>0x7f800000) return FP_ILOGBNAN;
+	else return INT_MAX;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_ilogbl.c b/libm/upstream-freebsd/lib/msun/src/s_ilogbl.c
new file mode 100644
index 0000000..3211f44
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_ilogbl.c
@@ -0,0 +1,53 @@
+/*
+ * From: @(#)s_ilogb.c 5.1 93/09/24
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <float.h>
+#include <limits.h>
+#include <math.h>
+
+#include "fpmath.h"
+
+int
+ilogbl(long double x)
+{
+	union IEEEl2bits u;
+	unsigned long m;
+	int b;
+
+	u.e = x;
+	if (u.bits.exp == 0) {
+		if ((u.bits.manl | u.bits.manh) == 0)
+			return (FP_ILOGB0);
+		/* denormalized */
+		if (u.bits.manh == 0) {
+			m = 1lu << (LDBL_MANL_SIZE - 1);
+			for (b = LDBL_MANH_SIZE; !(u.bits.manl & m); m >>= 1)
+				b++;
+		} else {
+			m = 1lu << (LDBL_MANH_SIZE - 1);
+			for (b = 0; !(u.bits.manh & m); m >>= 1)
+				b++;
+		}
+#ifdef LDBL_IMPLICIT_NBIT
+		b++;
+#endif
+		return (LDBL_MIN_EXP - b - 1);
+	} else if (u.bits.exp < (LDBL_MAX_EXP << 1) - 1)
+		return (u.bits.exp - LDBL_MAX_EXP + 1);
+	else if (u.bits.manl != 0 || u.bits.manh != 0)
+		return (FP_ILOGBNAN);
+	else
+		return (INT_MAX);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_isfinite.c b/libm/upstream-freebsd/lib/msun/src/s_isfinite.c
new file mode 100644
index 0000000..c9d1bd7
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_isfinite.c
@@ -0,0 +1,58 @@
+/*-
+ * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <math.h>
+
+#include "fpmath.h"
+
+int
+__isfinite(double d)
+{
+	union IEEEd2bits u;
+
+	u.d = d;
+	return (u.bits.exp != 2047);
+}
+
+int
+__isfinitef(float f)
+{
+	union IEEEf2bits u;
+
+	u.f = f;
+	return (u.bits.exp != 255);
+}
+
+int
+__isfinitel(long double e)
+{
+	union IEEEl2bits u;
+
+	u.e = e;
+	return (u.bits.exp != 32767);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_isnan.c b/libm/upstream-freebsd/lib/msun/src/s_isnan.c
new file mode 100644
index 0000000..a54ded3
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_isnan.c
@@ -0,0 +1,65 @@
+/*-
+ * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <math.h>
+
+#include "fpmath.h"
+
+/* Provided by libc.so */
+#ifndef PIC
+#undef isnan
+int
+isnan(double d)
+{
+	union IEEEd2bits u;
+
+	u.d = d;
+	return (u.bits.exp == 2047 && (u.bits.manl != 0 || u.bits.manh != 0));
+}
+#endif /* !PIC */
+
+int
+__isnanf(float f)
+{
+	union IEEEf2bits u;
+
+	u.f = f;
+	return (u.bits.exp == 255 && u.bits.man != 0);
+}
+
+int
+__isnanl(long double e)
+{
+	union IEEEl2bits u;
+
+	u.e = e;
+	mask_nbit_l(u);
+	return (u.bits.exp == 32767 && (u.bits.manl != 0 || u.bits.manh != 0));
+}
+
+__weak_reference(__isnanf, isnanf);
diff --git a/libm/upstream-freebsd/lib/msun/src/s_isnormal.c b/libm/upstream-freebsd/lib/msun/src/s_isnormal.c
new file mode 100644
index 0000000..49f2a74
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_isnormal.c
@@ -0,0 +1,58 @@
+/*-
+ * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <math.h>
+
+#include "fpmath.h"
+
+int
+__isnormal(double d)
+{
+	union IEEEd2bits u;
+
+	u.d = d;
+	return (u.bits.exp != 0 && u.bits.exp != 2047);
+}
+
+int
+__isnormalf(float f)
+{
+	union IEEEf2bits u;
+
+	u.f = f;
+	return (u.bits.exp != 0 && u.bits.exp != 255);
+}
+
+int
+__isnormall(long double e)
+{
+	union IEEEl2bits u;
+
+	u.e = e;
+	return (u.bits.exp != 0 && u.bits.exp != 32767);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_llrint.c b/libm/upstream-freebsd/lib/msun/src/s_llrint.c
new file mode 100644
index 0000000..7c959ec
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_llrint.c
@@ -0,0 +1,9 @@
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#define type		double
+#define	roundit		rint
+#define dtype		long long
+#define	fn		llrint
+
+#include "s_lrint.c"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_llrintf.c b/libm/upstream-freebsd/lib/msun/src/s_llrintf.c
new file mode 100644
index 0000000..7ec6015
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_llrintf.c
@@ -0,0 +1,9 @@
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#define type		float
+#define	roundit		rintf
+#define dtype		long long
+#define	fn		llrintf
+
+#include "s_lrint.c"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_llrintl.c b/libm/upstream-freebsd/lib/msun/src/s_llrintl.c
new file mode 100644
index 0000000..6ef8375
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_llrintl.c
@@ -0,0 +1,9 @@
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#define type		long double
+#define	roundit		rintl
+#define dtype		long long
+#define	fn		llrintl
+
+#include "s_lrint.c"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_llround.c b/libm/upstream-freebsd/lib/msun/src/s_llround.c
new file mode 100644
index 0000000..827dfc1
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_llround.c
@@ -0,0 +1,11 @@
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#define type		double
+#define	roundit		round
+#define dtype		long long
+#define	DTYPE_MIN	LLONG_MIN
+#define	DTYPE_MAX	LLONG_MAX
+#define	fn		llround
+
+#include "s_lround.c"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_llroundf.c b/libm/upstream-freebsd/lib/msun/src/s_llroundf.c
new file mode 100644
index 0000000..c037a18
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_llroundf.c
@@ -0,0 +1,11 @@
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#define type		float
+#define	roundit		roundf
+#define dtype		long long
+#define	DTYPE_MIN	LLONG_MIN
+#define	DTYPE_MAX	LLONG_MAX
+#define	fn		llroundf
+
+#include "s_lround.c"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_llroundl.c b/libm/upstream-freebsd/lib/msun/src/s_llroundl.c
new file mode 100644
index 0000000..02c44eb
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_llroundl.c
@@ -0,0 +1,11 @@
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#define type		long double
+#define	roundit		roundl
+#define dtype		long long
+#define	DTYPE_MIN	LLONG_MIN
+#define	DTYPE_MAX	LLONG_MAX
+#define	fn		llroundl
+
+#include "s_lround.c"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_log1p.c b/libm/upstream-freebsd/lib/msun/src/s_log1p.c
new file mode 100644
index 0000000..b062a8a
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_log1p.c
@@ -0,0 +1,175 @@
+/* @(#)s_log1p.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* double log1p(double x)
+ *
+ * Method :
+ *   1. Argument Reduction: find k and f such that
+ *			1+x = 2^k * (1+f),
+ *	   where  sqrt(2)/2 < 1+f < sqrt(2) .
+ *
+ *      Note. If k=0, then f=x is exact. However, if k!=0, then f
+ *	may not be representable exactly. In that case, a correction
+ *	term is need. Let u=1+x rounded. Let c = (1+x)-u, then
+ *	log(1+x) - log(u) ~ c/u. Thus, we proceed to compute log(u),
+ *	and add back the correction term c/u.
+ *	(Note: when x > 2**53, one can simply return log(x))
+ *
+ *   2. Approximation of log1p(f).
+ *	Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
+ *		 = 2s + 2/3 s**3 + 2/5 s**5 + .....,
+ *	     	 = 2s + s*R
+ *      We use a special Reme algorithm on [0,0.1716] to generate
+ * 	a polynomial of degree 14 to approximate R The maximum error
+ *	of this polynomial approximation is bounded by 2**-58.45. In
+ *	other words,
+ *		        2      4      6      8      10      12      14
+ *	    R(z) ~ Lp1*s +Lp2*s +Lp3*s +Lp4*s +Lp5*s  +Lp6*s  +Lp7*s
+ *  	(the values of Lp1 to Lp7 are listed in the program)
+ *	and
+ *	    |      2          14          |     -58.45
+ *	    | Lp1*s +...+Lp7*s    -  R(z) | <= 2
+ *	    |                             |
+ *	Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
+ *	In order to guarantee error in log below 1ulp, we compute log
+ *	by
+ *		log1p(f) = f - (hfsq - s*(hfsq+R)).
+ *
+ *	3. Finally, log1p(x) = k*ln2 + log1p(f).
+ *		 	     = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo)))
+ *	   Here ln2 is split into two floating point number:
+ *			ln2_hi + ln2_lo,
+ *	   where n*ln2_hi is always exact for |n| < 2000.
+ *
+ * Special cases:
+ *	log1p(x) is NaN with signal if x < -1 (including -INF) ;
+ *	log1p(+INF) is +INF; log1p(-1) is -INF with signal;
+ *	log1p(NaN) is that NaN with no signal.
+ *
+ * Accuracy:
+ *	according to an error analysis, the error is always less than
+ *	1 ulp (unit in the last place).
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following
+ * constants. The decimal values may be used, provided that the
+ * compiler will convert from decimal to binary accurately enough
+ * to produce the hexadecimal values shown.
+ *
+ * Note: Assuming log() return accurate answer, the following
+ * 	 algorithm can be used to compute log1p(x) to within a few ULP:
+ *
+ *		u = 1+x;
+ *		if(u==1.0) return x ; else
+ *			   return log(u)*(x/(u-1.0));
+ *
+ *	 See HP-15C Advanced Functions Handbook, p.193.
+ */
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const double
+ln2_hi  =  6.93147180369123816490e-01,	/* 3fe62e42 fee00000 */
+ln2_lo  =  1.90821492927058770002e-10,	/* 3dea39ef 35793c76 */
+two54   =  1.80143985094819840000e+16,  /* 43500000 00000000 */
+Lp1 = 6.666666666666735130e-01,  /* 3FE55555 55555593 */
+Lp2 = 3.999999999940941908e-01,  /* 3FD99999 9997FA04 */
+Lp3 = 2.857142874366239149e-01,  /* 3FD24924 94229359 */
+Lp4 = 2.222219843214978396e-01,  /* 3FCC71C5 1D8E78AF */
+Lp5 = 1.818357216161805012e-01,  /* 3FC74664 96CB03DE */
+Lp6 = 1.531383769920937332e-01,  /* 3FC39A09 D078C69F */
+Lp7 = 1.479819860511658591e-01;  /* 3FC2F112 DF3E5244 */
+
+static const double zero = 0.0;
+
+double
+log1p(double x)
+{
+	double hfsq,f,c,s,z,R,u;
+	int32_t k,hx,hu,ax;
+
+	GET_HIGH_WORD(hx,x);
+	ax = hx&0x7fffffff;
+
+	k = 1;
+	if (hx < 0x3FDA827A) {			/* 1+x < sqrt(2)+ */
+	    if(ax>=0x3ff00000) {		/* x <= -1.0 */
+		if(x==-1.0) return -two54/zero; /* log1p(-1)=+inf */
+		else return (x-x)/(x-x);	/* log1p(x<-1)=NaN */
+	    }
+	    if(ax<0x3e200000) {			/* |x| < 2**-29 */
+		if(two54+x>zero			/* raise inexact */
+	            &&ax<0x3c900000) 		/* |x| < 2**-54 */
+		    return x;
+		else
+		    return x - x*x*0.5;
+	    }
+	    if(hx>0||hx<=((int32_t)0xbfd2bec4)) {
+		k=0;f=x;hu=1;}		/* sqrt(2)/2- <= 1+x < sqrt(2)+ */
+	}
+	if (hx >= 0x7ff00000) return x+x;
+	if(k!=0) {
+	    if(hx<0x43400000) {
+		STRICT_ASSIGN(double,u,1.0+x);
+		GET_HIGH_WORD(hu,u);
+	        k  = (hu>>20)-1023;
+	        c  = (k>0)? 1.0-(u-x):x-(u-1.0);/* correction term */
+		c /= u;
+	    } else {
+		u  = x;
+		GET_HIGH_WORD(hu,u);
+	        k  = (hu>>20)-1023;
+		c  = 0;
+	    }
+	    hu &= 0x000fffff;
+	    /*
+	     * The approximation to sqrt(2) used in thresholds is not
+	     * critical.  However, the ones used above must give less
+	     * strict bounds than the one here so that the k==0 case is
+	     * never reached from here, since here we have committed to
+	     * using the correction term but don't use it if k==0.
+	     */
+	    if(hu<0x6a09e) {			/* u ~< sqrt(2) */
+	        SET_HIGH_WORD(u,hu|0x3ff00000);	/* normalize u */
+	    } else {
+	        k += 1;
+		SET_HIGH_WORD(u,hu|0x3fe00000);	/* normalize u/2 */
+	        hu = (0x00100000-hu)>>2;
+	    }
+	    f = u-1.0;
+	}
+	hfsq=0.5*f*f;
+	if(hu==0) {	/* |f| < 2**-20 */
+	    if(f==zero) {
+		if(k==0) {
+		    return zero;
+		} else {
+		    c += k*ln2_lo;
+		    return k*ln2_hi+c;
+		}
+	    }
+	    R = hfsq*(1.0-0.66666666666666666*f);
+	    if(k==0) return f-R; else
+	    	     return k*ln2_hi-((R-(k*ln2_lo+c))-f);
+	}
+ 	s = f/(2.0+f);
+	z = s*s;
+	R = z*(Lp1+z*(Lp2+z*(Lp3+z*(Lp4+z*(Lp5+z*(Lp6+z*Lp7))))));
+	if(k==0) return f-(hfsq-s*(hfsq+R)); else
+		 return k*ln2_hi-((hfsq-(s*(hfsq+R)+(k*ln2_lo+c)))-f);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_log1pf.c b/libm/upstream-freebsd/lib/msun/src/s_log1pf.c
new file mode 100644
index 0000000..01d3457
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_log1pf.c
@@ -0,0 +1,114 @@
+/* s_log1pf.c -- float version of s_log1p.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const float
+ln2_hi =   6.9313812256e-01,	/* 0x3f317180 */
+ln2_lo =   9.0580006145e-06,	/* 0x3717f7d1 */
+two25 =    3.355443200e+07,	/* 0x4c000000 */
+Lp1 = 6.6666668653e-01,	/* 3F2AAAAB */
+Lp2 = 4.0000000596e-01,	/* 3ECCCCCD */
+Lp3 = 2.8571429849e-01, /* 3E924925 */
+Lp4 = 2.2222198546e-01, /* 3E638E29 */
+Lp5 = 1.8183572590e-01, /* 3E3A3325 */
+Lp6 = 1.5313838422e-01, /* 3E1CD04F */
+Lp7 = 1.4798198640e-01; /* 3E178897 */
+
+static const float zero = 0.0;
+
+float
+log1pf(float x)
+{
+	float hfsq,f,c,s,z,R,u;
+	int32_t k,hx,hu,ax;
+
+	GET_FLOAT_WORD(hx,x);
+	ax = hx&0x7fffffff;
+
+	k = 1;
+	if (hx < 0x3ed413d0) {			/* 1+x < sqrt(2)+  */
+	    if(ax>=0x3f800000) {		/* x <= -1.0 */
+		if(x==(float)-1.0) return -two25/zero; /* log1p(-1)=+inf */
+		else return (x-x)/(x-x);	/* log1p(x<-1)=NaN */
+	    }
+	    if(ax<0x38000000) {			/* |x| < 2**-15 */
+		if(two25+x>zero			/* raise inexact */
+	            &&ax<0x33800000) 		/* |x| < 2**-24 */
+		    return x;
+		else
+		    return x - x*x*(float)0.5;
+	    }
+	    if(hx>0||hx<=((int32_t)0xbe95f619)) {
+		k=0;f=x;hu=1;}		/* sqrt(2)/2- <= 1+x < sqrt(2)+ */
+	}
+	if (hx >= 0x7f800000) return x+x;
+	if(k!=0) {
+	    if(hx<0x5a000000) {
+		STRICT_ASSIGN(float,u,(float)1.0+x);
+		GET_FLOAT_WORD(hu,u);
+	        k  = (hu>>23)-127;
+		/* correction term */
+	        c  = (k>0)? (float)1.0-(u-x):x-(u-(float)1.0);
+		c /= u;
+	    } else {
+		u  = x;
+		GET_FLOAT_WORD(hu,u);
+	        k  = (hu>>23)-127;
+		c  = 0;
+	    }
+	    hu &= 0x007fffff;
+	    /*
+	     * The approximation to sqrt(2) used in thresholds is not
+	     * critical.  However, the ones used above must give less
+	     * strict bounds than the one here so that the k==0 case is
+	     * never reached from here, since here we have committed to
+	     * using the correction term but don't use it if k==0.
+	     */
+	    if(hu<0x3504f4) {			/* u < sqrt(2) */
+	        SET_FLOAT_WORD(u,hu|0x3f800000);/* normalize u */
+	    } else {
+	        k += 1;
+		SET_FLOAT_WORD(u,hu|0x3f000000);	/* normalize u/2 */
+	        hu = (0x00800000-hu)>>2;
+	    }
+	    f = u-(float)1.0;
+	}
+	hfsq=(float)0.5*f*f;
+	if(hu==0) {	/* |f| < 2**-20 */
+	    if(f==zero) {
+		if(k==0) {
+		    return zero;
+		} else {
+		    c += k*ln2_lo;
+		    return k*ln2_hi+c;
+		}
+	    }
+	    R = hfsq*((float)1.0-(float)0.66666666666666666*f);
+	    if(k==0) return f-R; else
+	    	     return k*ln2_hi-((R-(k*ln2_lo+c))-f);
+	}
+ 	s = f/((float)2.0+f);
+	z = s*s;
+	R = z*(Lp1+z*(Lp2+z*(Lp3+z*(Lp4+z*(Lp5+z*(Lp6+z*Lp7))))));
+	if(k==0) return f-(hfsq-s*(hfsq+R)); else
+		 return k*ln2_hi-((hfsq-(s*(hfsq+R)+(k*ln2_lo+c)))-f);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_logb.c b/libm/upstream-freebsd/lib/msun/src/s_logb.c
new file mode 100644
index 0000000..a47e354
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_logb.c
@@ -0,0 +1,49 @@
+/* @(#)s_logb.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * double logb(x)
+ * IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
+ * Use ilogb instead.
+ */
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const double
+two54 = 1.80143985094819840000e+16;	/* 43500000 00000000 */
+
+double
+logb(double x)
+{
+	int32_t lx,ix;
+	EXTRACT_WORDS(ix,lx,x);
+	ix &= 0x7fffffff;			/* high |x| */
+	if((ix|lx)==0) return -1.0/fabs(x);
+	if(ix>=0x7ff00000) return x*x;
+	if(ix<0x00100000) {
+		x *= two54;		 /* convert subnormal x to normal */
+		GET_HIGH_WORD(ix,x);
+		ix &= 0x7fffffff;
+		return (double) ((ix>>20)-1023-54);
+	} else
+		return (double) ((ix>>20)-1023);
+}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(logb, logbl);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/s_logbf.c b/libm/upstream-freebsd/lib/msun/src/s_logbf.c
new file mode 100644
index 0000000..3ab190d
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_logbf.c
@@ -0,0 +1,40 @@
+/* s_logbf.c -- float version of s_logb.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static const float
+two25 = 3.355443200e+07;		/* 0x4c000000 */
+
+float
+logbf(float x)
+{
+	int32_t ix;
+	GET_FLOAT_WORD(ix,x);
+	ix &= 0x7fffffff;			/* high |x| */
+	if(ix==0) return (float)-1.0/fabsf(x);
+	if(ix>=0x7f800000) return x*x;
+	if(ix<0x00800000) {
+		x *= two25;		 /* convert subnormal x to normal */
+		GET_FLOAT_WORD(ix,x);
+		ix &= 0x7fffffff;
+		return (float) ((ix>>23)-127-25);
+	} else
+		return (float) ((ix>>23)-127);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_logbl.c b/libm/upstream-freebsd/lib/msun/src/s_logbl.c
new file mode 100644
index 0000000..7e88e36
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_logbl.c
@@ -0,0 +1,55 @@
+/*
+ * From: @(#)s_ilogb.c 5.1 93/09/24
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#ifndef lint
+static char rcsid[] = "$FreeBSD$";
+#endif
+
+#include <float.h>
+#include <limits.h>
+#include <math.h>
+
+#include "fpmath.h"
+
+long double
+logbl(long double x)
+{
+	union IEEEl2bits u;
+	unsigned long m;
+	int b;
+
+	u.e = x;
+	if (u.bits.exp == 0) {
+		if ((u.bits.manl | u.bits.manh) == 0) {	/* x == 0 */
+			u.bits.sign = 1;
+			return (1.0L / u.e);
+		}
+		/* denormalized */
+		if (u.bits.manh == 0) {
+			m = 1lu << (LDBL_MANL_SIZE - 1);
+			for (b = LDBL_MANH_SIZE; !(u.bits.manl & m); m >>= 1)
+				b++;
+		} else {
+			m = 1lu << (LDBL_MANH_SIZE - 1);
+			for (b = 0; !(u.bits.manh & m); m >>= 1)
+				b++;
+		}
+#ifdef LDBL_IMPLICIT_NBIT
+		b++;
+#endif
+		return ((long double)(LDBL_MIN_EXP - b - 1));
+	}
+	if (u.bits.exp < (LDBL_MAX_EXP << 1) - 1)	/* normal */
+		return ((long double)(u.bits.exp - LDBL_MAX_EXP + 1));
+	else						/* +/- inf or nan */
+		return (x * x);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_lrint.c b/libm/upstream-freebsd/lib/msun/src/s_lrint.c
new file mode 100644
index 0000000..27ff5ff
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_lrint.c
@@ -0,0 +1,58 @@
+/*-
+ * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <fenv.h>
+#include <math.h>
+
+#ifndef type
+__FBSDID("$FreeBSD$");
+#define type		double
+#define	roundit		rint
+#define dtype		long
+#define	fn		lrint
+#endif
+
+/*
+ * C99 says we should not raise a spurious inexact exception when an
+ * invalid exception is raised.  Unfortunately, the set of inputs
+ * that overflows depends on the rounding mode when 'dtype' has more
+ * significant bits than 'type'.  Hence, we bend over backwards for the
+ * sake of correctness; an MD implementation could be more efficient.
+ */
+dtype
+fn(type x)
+{
+	fenv_t env;
+	dtype d;
+
+	feholdexcept(&env);
+	d = (dtype)roundit(x);
+	if (fetestexcept(FE_INVALID))
+		feclearexcept(FE_INEXACT);
+	feupdateenv(&env);
+	return (d);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_lrintf.c b/libm/upstream-freebsd/lib/msun/src/s_lrintf.c
new file mode 100644
index 0000000..a757ded
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_lrintf.c
@@ -0,0 +1,9 @@
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#define type		float
+#define	roundit		rintf
+#define dtype		long
+#define	fn		lrintf
+
+#include "s_lrint.c"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_lrintl.c b/libm/upstream-freebsd/lib/msun/src/s_lrintl.c
new file mode 100644
index 0000000..497b442
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_lrintl.c
@@ -0,0 +1,9 @@
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#define type		long double
+#define	roundit		rintl
+#define dtype		long
+#define	fn		lrintl
+
+#include "s_lrint.c"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_lround.c b/libm/upstream-freebsd/lib/msun/src/s_lround.c
new file mode 100644
index 0000000..3cff489
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_lround.c
@@ -0,0 +1,66 @@
+/*-
+ * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <sys/limits.h>
+#include <fenv.h>
+#include <math.h>
+
+#ifndef type
+__FBSDID("$FreeBSD$");
+#define type		double
+#define	roundit		round
+#define dtype		long
+#define	DTYPE_MIN	LONG_MIN
+#define	DTYPE_MAX	LONG_MAX
+#define	fn		lround
+#endif
+
+/*
+ * If type has more precision than dtype, the endpoints dtype_(min|max) are
+ * of the form xxx.5; they are "out of range" because lround() rounds away
+ * from 0.  On the other hand, if type has less precision than dtype, then
+ * all values that are out of range are integral, so we might as well assume
+ * that everything is in range.  At compile time, INRANGE(x) should reduce to
+ * two floating-point comparisons in the former case, or TRUE otherwise.
+ */
+static const type dtype_min = DTYPE_MIN - 0.5;
+static const type dtype_max = DTYPE_MAX + 0.5;
+#define	INRANGE(x)	(dtype_max - DTYPE_MAX != 0.5 || \
+			 ((x) > dtype_min && (x) < dtype_max))
+
+dtype
+fn(type x)
+{
+
+	if (INRANGE(x)) {
+		x = roundit(x);
+		return ((dtype)x);
+	} else {
+		feraiseexcept(FE_INVALID);
+		return (DTYPE_MAX);
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_lroundf.c b/libm/upstream-freebsd/lib/msun/src/s_lroundf.c
new file mode 100644
index 0000000..e24fe7f
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_lroundf.c
@@ -0,0 +1,11 @@
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#define type		float
+#define	roundit		roundf
+#define dtype		long
+#define	DTYPE_MIN	LONG_MIN
+#define	DTYPE_MAX	LONG_MAX
+#define	fn		lroundf
+
+#include "s_lround.c"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_lroundl.c b/libm/upstream-freebsd/lib/msun/src/s_lroundl.c
new file mode 100644
index 0000000..e410827
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_lroundl.c
@@ -0,0 +1,11 @@
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#define type		long double
+#define	roundit		roundl
+#define dtype		long
+#define	DTYPE_MIN	LONG_MIN
+#define	DTYPE_MAX	LONG_MAX
+#define	fn		lroundl
+
+#include "s_lround.c"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_modf.c b/libm/upstream-freebsd/lib/msun/src/s_modf.c
new file mode 100644
index 0000000..ab13191
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_modf.c
@@ -0,0 +1,79 @@
+/* @(#)s_modf.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#ifndef lint
+static char rcsid[] = "$FreeBSD$";
+#endif
+
+/*
+ * modf(double x, double *iptr)
+ * return fraction part of x, and return x's integral part in *iptr.
+ * Method:
+ *	Bit twiddling.
+ *
+ * Exception:
+ *	No exception.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+static const double one = 1.0;
+
+double
+modf(double x, double *iptr)
+{
+	int32_t i0,i1,j0;
+	u_int32_t i;
+	EXTRACT_WORDS(i0,i1,x);
+	j0 = ((i0>>20)&0x7ff)-0x3ff;	/* exponent of x */
+	if(j0<20) {			/* integer part in high x */
+	    if(j0<0) {			/* |x|<1 */
+	        INSERT_WORDS(*iptr,i0&0x80000000,0);	/* *iptr = +-0 */
+		return x;
+	    } else {
+		i = (0x000fffff)>>j0;
+		if(((i0&i)|i1)==0) {		/* x is integral */
+		    u_int32_t high;
+		    *iptr = x;
+		    GET_HIGH_WORD(high,x);
+		    INSERT_WORDS(x,high&0x80000000,0);	/* return +-0 */
+		    return x;
+		} else {
+		    INSERT_WORDS(*iptr,i0&(~i),0);
+		    return x - *iptr;
+		}
+	    }
+	} else if (j0>51) {		/* no fraction part */
+	    u_int32_t high;
+	    if (j0 == 0x400) {		/* inf/NaN */
+		*iptr = x;
+		return 0.0 / x;
+	    }
+	    *iptr = x*one;
+	    GET_HIGH_WORD(high,x);
+	    INSERT_WORDS(x,high&0x80000000,0);	/* return +-0 */
+	    return x;
+	} else {			/* fraction part in low x */
+	    i = ((u_int32_t)(0xffffffff))>>(j0-20);
+	    if((i1&i)==0) { 		/* x is integral */
+	        u_int32_t high;
+		*iptr = x;
+		GET_HIGH_WORD(high,x);
+		INSERT_WORDS(x,high&0x80000000,0);	/* return +-0 */
+		return x;
+	    } else {
+	        INSERT_WORDS(*iptr,i0,i1&(~i));
+		return x - *iptr;
+	    }
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_modff.c b/libm/upstream-freebsd/lib/msun/src/s_modff.c
new file mode 100644
index 0000000..062259c
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_modff.c
@@ -0,0 +1,57 @@
+/* s_modff.c -- float version of s_modf.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static const float one = 1.0;
+
+float
+modff(float x, float *iptr)
+{
+	int32_t i0,j0;
+	u_int32_t i;
+	GET_FLOAT_WORD(i0,x);
+	j0 = ((i0>>23)&0xff)-0x7f;	/* exponent of x */
+	if(j0<23) {			/* integer part in x */
+	    if(j0<0) {			/* |x|<1 */
+	        SET_FLOAT_WORD(*iptr,i0&0x80000000);	/* *iptr = +-0 */
+		return x;
+	    } else {
+		i = (0x007fffff)>>j0;
+		if((i0&i)==0) {			/* x is integral */
+		    u_int32_t ix;
+		    *iptr = x;
+		    GET_FLOAT_WORD(ix,x);
+		    SET_FLOAT_WORD(x,ix&0x80000000);	/* return +-0 */
+		    return x;
+		} else {
+		    SET_FLOAT_WORD(*iptr,i0&(~i));
+		    return x - *iptr;
+		}
+	    }
+	} else {			/* no fraction part */
+	    u_int32_t ix;
+	    *iptr = x*one;
+	    if (x != x)			/* NaN */
+		return x;
+	    GET_FLOAT_WORD(ix,x);
+	    SET_FLOAT_WORD(x,ix&0x80000000);	/* return +-0 */
+	    return x;
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_modfl.c b/libm/upstream-freebsd/lib/msun/src/s_modfl.c
new file mode 100644
index 0000000..3dcdf86
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_modfl.c
@@ -0,0 +1,101 @@
+/*-
+ * Copyright (c) 2007 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Derived from s_modf.c, which has the following Copyright:
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ * $FreeBSD$
+ */
+
+#include <float.h>
+#include <math.h>
+#include <sys/types.h>
+
+#include "fpmath.h"
+
+#if LDBL_MANL_SIZE > 32
+#define	MASK	((uint64_t)-1)
+#else
+#define	MASK	((uint32_t)-1)
+#endif
+/* Return the last n bits of a word, representing the fractional part. */
+#define	GETFRAC(bits, n)	((bits) & ~(MASK << (n)))
+/* The number of fraction bits in manh, not counting the integer bit */
+#define	HIBITS	(LDBL_MANT_DIG - LDBL_MANL_SIZE)
+
+static const long double zero[] = { 0.0L, -0.0L };
+
+long double
+modfl(long double x, long double *iptr)
+{
+	union IEEEl2bits ux;
+	int e;
+
+	ux.e = x;
+	e = ux.bits.exp - LDBL_MAX_EXP + 1;
+	if (e < HIBITS) {			/* Integer part is in manh. */
+		if (e < 0) {			/* |x|<1 */
+			*iptr = zero[ux.bits.sign];
+			return (x);
+		} else {
+			if ((GETFRAC(ux.bits.manh, HIBITS - 1 - e) |
+			     ux.bits.manl) == 0) {	/* X is an integer. */
+				*iptr = x;
+				return (zero[ux.bits.sign]);
+			} else {
+				/* Clear all but the top e+1 bits. */
+				ux.bits.manh >>= HIBITS - 1 - e;
+				ux.bits.manh <<= HIBITS - 1 - e;
+				ux.bits.manl = 0;
+				*iptr = ux.e;
+				return (x - ux.e);
+			}
+		}
+	} else if (e >= LDBL_MANT_DIG - 1) {	/* x has no fraction part. */
+		*iptr = x;
+		if (x != x)			/* Handle NaNs. */
+			return (x);
+		return (zero[ux.bits.sign]);
+	} else {				/* Fraction part is in manl. */
+		if (GETFRAC(ux.bits.manl, LDBL_MANT_DIG - 1 - e) == 0) {
+			/* x is integral. */
+			*iptr = x;
+			return (zero[ux.bits.sign]);
+		} else {
+			/* Clear all but the top e+1 bits. */
+			ux.bits.manl >>= LDBL_MANT_DIG - 1 - e;
+			ux.bits.manl <<= LDBL_MANT_DIG - 1 - e;
+			*iptr = ux.e;
+			return (x - ux.e);
+		}
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_nan.c b/libm/upstream-freebsd/lib/msun/src/s_nan.c
new file mode 100644
index 0000000..890f471
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_nan.c
@@ -0,0 +1,110 @@
+/*-
+ * Copyright (c) 2007 David Schultz
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/endian.h>
+#include <ctype.h>
+#include <float.h>
+#include <math.h>
+#include <stdint.h>
+#include <strings.h>
+
+#include "math_private.h"
+
+/*
+ * Scan a string of hexadecimal digits (the format nan(3) expects) and
+ * make a bit array (using the local endianness). We stop when we
+ * encounter an invalid character, NUL, etc.  If we overflow, we do
+ * the same as gcc's __builtin_nan(), namely, discard the high order bits.
+ *
+ * The format this routine accepts needs to be compatible with what is used
+ * in contrib/gdtoa/hexnan.c (for strtod/scanf) and what is used in
+ * __builtin_nan(). In fact, we're only 100% compatible for strings we
+ * consider valid, so we might be violating the C standard. But it's
+ * impossible to use nan(3) portably anyway, so this seems good enough.
+ */
+void
+_scan_nan(uint32_t *words, int num_words, const char *s)
+{
+	int si;		/* index into s */
+	int bitpos;	/* index into words (in bits) */
+
+	bzero(words, num_words * sizeof(uint32_t));
+
+	/* Allow a leading '0x'. (It's expected, but redundant.) */
+	if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X'))
+		s += 2;
+
+	/* Scan forwards in the string, looking for the end of the sequence. */
+	for (si = 0; isxdigit(s[si]); si++)
+		;
+
+	/* Scan backwards, filling in the bits in words[] as we go. */
+#if _BYTE_ORDER == _LITTLE_ENDIAN
+	for (bitpos = 0; bitpos < 32 * num_words; bitpos += 4) {
+#else
+	for (bitpos = 32 * num_words - 4; bitpos >= 0; bitpos -= 4) {
+#endif
+		if (--si < 0)
+			break;
+		words[bitpos / 32] |= digittoint(s[si]) << (bitpos % 32);
+	}
+}
+
+double
+nan(const char *s)
+{
+	union {
+		double d;
+		uint32_t bits[2];
+	} u;
+
+	_scan_nan(u.bits, 2, s);
+#if _BYTE_ORDER == _LITTLE_ENDIAN
+	u.bits[1] |= 0x7ff80000;
+#else
+	u.bits[0] |= 0x7ff80000;
+#endif
+	return (u.d);
+}
+
+float
+nanf(const char *s)
+{
+	union {
+		float f;
+		uint32_t bits[1];
+	} u;
+
+	_scan_nan(u.bits, 1, s);
+	u.bits[0] |= 0x7fc00000;
+	return (u.f);
+}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(nan, nanl);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/s_nearbyint.c b/libm/upstream-freebsd/lib/msun/src/s_nearbyint.c
new file mode 100644
index 0000000..12493d2
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_nearbyint.c
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <fenv.h>
+#include <math.h>
+
+/*
+ * We save and restore the floating-point environment to avoid raising
+ * an inexact exception.  We can get away with using fesetenv()
+ * instead of feclearexcept()/feupdateenv() to restore the environment
+ * because the only exception defined for rint() is overflow, and
+ * rounding can't overflow as long as emax >= p.
+ */
+#define	DECL(type, fn, rint)	\
+type				\
+fn(type x)			\
+{				\
+	type ret;		\
+	fenv_t env;		\
+				\
+	fegetenv(&env);		\
+	ret = rint(x);		\
+	fesetenv(&env);		\
+	return (ret);		\
+}
+
+DECL(double, nearbyint, rint)
+DECL(float, nearbyintf, rintf)
+DECL(long double, nearbyintl, rintl)
diff --git a/libm/upstream-freebsd/lib/msun/src/s_nextafter.c b/libm/upstream-freebsd/lib/msun/src/s_nextafter.c
new file mode 100644
index 0000000..52dd21c
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_nextafter.c
@@ -0,0 +1,83 @@
+/* @(#)s_nextafter.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* IEEE functions
+ *	nextafter(x,y)
+ *	return the next machine floating-point number of x in the
+ *	direction toward y.
+ *   Special cases:
+ */
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+double
+nextafter(double x, double y)
+{
+	volatile double t;
+	int32_t hx,hy,ix,iy;
+	u_int32_t lx,ly;
+
+	EXTRACT_WORDS(hx,lx,x);
+	EXTRACT_WORDS(hy,ly,y);
+	ix = hx&0x7fffffff;		/* |x| */
+	iy = hy&0x7fffffff;		/* |y| */
+
+	if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) ||   /* x is nan */
+	   ((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0))     /* y is nan */
+	   return x+y;
+	if(x==y) return y;		/* x=y, return y */
+	if((ix|lx)==0) {			/* x == 0 */
+	    INSERT_WORDS(x,hy&0x80000000,1);	/* return +-minsubnormal */
+	    t = x*x;
+	    if(t==x) return t; else return x;	/* raise underflow flag */
+	}
+	if(hx>=0) {				/* x > 0 */
+	    if(hx>hy||((hx==hy)&&(lx>ly))) {	/* x > y, x -= ulp */
+		if(lx==0) hx -= 1;
+		lx -= 1;
+	    } else {				/* x < y, x += ulp */
+		lx += 1;
+		if(lx==0) hx += 1;
+	    }
+	} else {				/* x < 0 */
+	    if(hy>=0||hx>hy||((hx==hy)&&(lx>ly))){/* x < y, x -= ulp */
+		if(lx==0) hx -= 1;
+		lx -= 1;
+	    } else {				/* x > y, x += ulp */
+		lx += 1;
+		if(lx==0) hx += 1;
+	    }
+	}
+	hy = hx&0x7ff00000;
+	if(hy>=0x7ff00000) return x+x;	/* overflow  */
+	if(hy<0x00100000) {		/* underflow */
+	    t = x*x;
+	    if(t!=x) {		/* raise underflow flag */
+	        INSERT_WORDS(y,hx,lx);
+		return y;
+	    }
+	}
+	INSERT_WORDS(x,hx,lx);
+	return x;
+}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(nextafter, nexttoward);
+__weak_reference(nextafter, nexttowardl);
+__weak_reference(nextafter, nextafterl);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/s_nextafterf.c b/libm/upstream-freebsd/lib/msun/src/s_nextafterf.c
new file mode 100644
index 0000000..96e21ef
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_nextafterf.c
@@ -0,0 +1,66 @@
+/* s_nextafterf.c -- float version of s_nextafter.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+float
+nextafterf(float x, float y)
+{
+	volatile float t;
+	int32_t hx,hy,ix,iy;
+
+	GET_FLOAT_WORD(hx,x);
+	GET_FLOAT_WORD(hy,y);
+	ix = hx&0x7fffffff;		/* |x| */
+	iy = hy&0x7fffffff;		/* |y| */
+
+	if((ix>0x7f800000) ||   /* x is nan */
+	   (iy>0x7f800000))     /* y is nan */
+	   return x+y;
+	if(x==y) return y;		/* x=y, return y */
+	if(ix==0) {				/* x == 0 */
+	    SET_FLOAT_WORD(x,(hy&0x80000000)|1);/* return +-minsubnormal */
+	    t = x*x;
+	    if(t==x) return t; else return x;	/* raise underflow flag */
+	}
+	if(hx>=0) {				/* x > 0 */
+	    if(hx>hy) {				/* x > y, x -= ulp */
+		hx -= 1;
+	    } else {				/* x < y, x += ulp */
+		hx += 1;
+	    }
+	} else {				/* x < 0 */
+	    if(hy>=0||hx>hy){			/* x < y, x -= ulp */
+		hx -= 1;
+	    } else {				/* x > y, x += ulp */
+		hx += 1;
+	    }
+	}
+	hy = hx&0x7f800000;
+	if(hy>=0x7f800000) return x+x;	/* overflow  */
+	if(hy<0x00800000) {		/* underflow */
+	    t = x*x;
+	    if(t!=x) {		/* raise underflow flag */
+	        SET_FLOAT_WORD(y,hx);
+		return y;
+	    }
+	}
+	SET_FLOAT_WORD(x,hx);
+	return x;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_nextafterl.c b/libm/upstream-freebsd/lib/msun/src/s_nextafterl.c
new file mode 100644
index 0000000..9c61a43
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_nextafterl.c
@@ -0,0 +1,80 @@
+/* @(#)s_nextafter.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* IEEE functions
+ *	nextafter(x,y)
+ *	return the next machine floating-point number of x in the
+ *	direction toward y.
+ *   Special cases:
+ */
+
+#include <float.h>
+
+#include "fpmath.h"
+#include "math.h"
+#include "math_private.h"
+
+#if LDBL_MAX_EXP != 0x4000
+#error "Unsupported long double format"
+#endif
+
+long double
+nextafterl(long double x, long double y)
+{
+	volatile long double t;
+	union IEEEl2bits ux, uy;
+
+	ux.e = x;
+	uy.e = y;
+
+	if ((ux.bits.exp == 0x7fff &&
+	     ((ux.bits.manh&~LDBL_NBIT)|ux.bits.manl) != 0) ||
+	    (uy.bits.exp == 0x7fff &&
+	     ((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl) != 0))
+	   return x+y;	/* x or y is nan */
+	if(x==y) return y;		/* x=y, return y */
+	if(x==0.0) {
+	    ux.bits.manh = 0;			/* return +-minsubnormal */
+	    ux.bits.manl = 1;
+	    ux.bits.sign = uy.bits.sign;
+	    t = ux.e*ux.e;
+	    if(t==ux.e) return t; else return ux.e; /* raise underflow flag */
+	}
+	if(x>0.0 ^ x<y) {			/* x -= ulp */
+	    if(ux.bits.manl==0) {
+		if ((ux.bits.manh&~LDBL_NBIT)==0)
+		    ux.bits.exp -= 1;
+		ux.bits.manh = (ux.bits.manh - 1) | (ux.bits.manh & LDBL_NBIT);
+	    }
+	    ux.bits.manl -= 1;
+	} else {				/* x += ulp */
+	    ux.bits.manl += 1;
+	    if(ux.bits.manl==0) {
+		ux.bits.manh = (ux.bits.manh + 1) | (ux.bits.manh & LDBL_NBIT);
+		if ((ux.bits.manh&~LDBL_NBIT)==0)
+		    ux.bits.exp += 1;
+	    }
+	}
+	if(ux.bits.exp==0x7fff) return x+x;	/* overflow  */
+	if(ux.bits.exp==0) {			/* underflow */
+	    mask_nbit_l(ux);
+	    t = ux.e * ux.e;
+	    if(t!=ux.e)			/* raise underflow flag */
+		return ux.e;
+	}
+	return ux.e;
+}
+
+__strong_reference(nextafterl, nexttowardl);
diff --git a/libm/upstream-freebsd/lib/msun/src/s_nexttoward.c b/libm/upstream-freebsd/lib/msun/src/s_nexttoward.c
new file mode 100644
index 0000000..b2a50d3
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_nexttoward.c
@@ -0,0 +1,72 @@
+/* @(#)s_nextafter.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * We assume that a long double has a 15-bit exponent.  On systems
+ * where long double is the same as double, nexttoward() is an alias
+ * for nextafter(), so we don't use this routine.
+ */
+
+#include <float.h>
+
+#include "fpmath.h"
+#include "math.h"
+#include "math_private.h"
+
+#if LDBL_MAX_EXP != 0x4000
+#error "Unsupported long double format"
+#endif
+
+double
+nexttoward(double x, long double y)
+{
+	union IEEEl2bits uy;
+	volatile double t;
+	int32_t hx,ix;
+	u_int32_t lx;
+
+	EXTRACT_WORDS(hx,lx,x);
+	ix = hx&0x7fffffff;		/* |x| */
+	uy.e = y;
+
+	if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) ||
+	    (uy.bits.exp == 0x7fff &&
+	     ((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl) != 0))
+	   return x+y;	/* x or y is nan */
+	if(x==y) return (double)y;		/* x=y, return y */
+	if(x==0.0) {
+	    INSERT_WORDS(x,uy.bits.sign<<31,1);	/* return +-minsubnormal */
+	    t = x*x;
+	    if(t==x) return t; else return x;	/* raise underflow flag */
+	}
+	if(hx>0.0 ^ x < y) {			/* x -= ulp */
+	    if(lx==0) hx -= 1;
+	    lx -= 1;
+	} else {				/* x += ulp */
+	    lx += 1;
+	    if(lx==0) hx += 1;
+	}
+	ix = hx&0x7ff00000;
+	if(ix>=0x7ff00000) return x+x;	/* overflow  */
+	if(ix<0x00100000) {		/* underflow */
+	    t = x*x;
+	    if(t!=x) {		/* raise underflow flag */
+	        INSERT_WORDS(x,hx,lx);
+		return x;
+	    }
+	}
+	INSERT_WORDS(x,hx,lx);
+	return x;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_nexttowardf.c b/libm/upstream-freebsd/lib/msun/src/s_nexttowardf.c
new file mode 100644
index 0000000..9ddfff9
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_nexttowardf.c
@@ -0,0 +1,59 @@
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <float.h>
+
+#include "fpmath.h"
+#include "math.h"
+#include "math_private.h"
+
+#define	LDBL_INFNAN_EXP	(LDBL_MAX_EXP * 2 - 1)
+
+float
+nexttowardf(float x, long double y)
+{
+	union IEEEl2bits uy;
+	volatile float t;
+	int32_t hx,ix;
+
+	GET_FLOAT_WORD(hx,x);
+	ix = hx&0x7fffffff;		/* |x| */
+	uy.e = y;
+
+	if((ix>0x7f800000) ||
+	   (uy.bits.exp == LDBL_INFNAN_EXP &&
+	    ((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl) != 0))
+	   return x+y;	/* x or y is nan */
+	if(x==y) return (float)y;		/* x=y, return y */
+	if(ix==0) {				/* x == 0 */
+	    SET_FLOAT_WORD(x,(uy.bits.sign<<31)|1);/* return +-minsubnormal */
+	    t = x*x;
+	    if(t==x) return t; else return x;	/* raise underflow flag */
+	}
+	if(hx>=0 ^ x < y)			/* x -= ulp */
+	    hx -= 1;
+	else					/* x += ulp */
+	    hx += 1;
+	ix = hx&0x7f800000;
+	if(ix>=0x7f800000) return x+x;	/* overflow  */
+	if(ix<0x00800000) {		/* underflow */
+	    t = x*x;
+	    if(t!=x) {		/* raise underflow flag */
+	        SET_FLOAT_WORD(x,hx);
+		return x;
+	    }
+	}
+	SET_FLOAT_WORD(x,hx);
+	return x;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_remquo.c b/libm/upstream-freebsd/lib/msun/src/s_remquo.c
new file mode 100644
index 0000000..d811c69
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_remquo.c
@@ -0,0 +1,159 @@
+/* @(#)e_fmod.c 1.3 95/01/18 */
+/*-
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const double Zero[] = {0.0, -0.0,};
+
+/*
+ * Return the IEEE remainder and set *quo to the last n bits of the
+ * quotient, rounded to the nearest integer.  We choose n=31 because
+ * we wind up computing all the integer bits of the quotient anyway as
+ * a side-effect of computing the remainder by the shift and subtract
+ * method.  In practice, this is far more bits than are needed to use
+ * remquo in reduction algorithms.
+ */
+double
+remquo(double x, double y, int *quo)
+{
+	int32_t n,hx,hy,hz,ix,iy,sx,i;
+	u_int32_t lx,ly,lz,q,sxy;
+
+	EXTRACT_WORDS(hx,lx,x);
+	EXTRACT_WORDS(hy,ly,y);
+	sxy = (hx ^ hy) & 0x80000000;
+	sx = hx&0x80000000;		/* sign of x */
+	hx ^=sx;		/* |x| */
+	hy &= 0x7fffffff;	/* |y| */
+
+    /* purge off exception values */
+	if((hy|ly)==0||(hx>=0x7ff00000)||	/* y=0,or x not finite */
+	  ((hy|((ly|-ly)>>31))>0x7ff00000))	/* or y is NaN */
+	    return (x*y)/(x*y);
+	if(hx<=hy) {
+	    if((hx<hy)||(lx<ly)) {
+		q = 0;
+		goto fixup;	/* |x|<|y| return x or x-y */
+	    }
+	    if(lx==ly) {
+		*quo = (sxy ? -1 : 1);
+		return Zero[(u_int32_t)sx>>31];	/* |x|=|y| return x*0*/
+	    }
+	}
+
+    /* determine ix = ilogb(x) */
+	if(hx<0x00100000) {	/* subnormal x */
+	    if(hx==0) {
+		for (ix = -1043, i=lx; i>0; i<<=1) ix -=1;
+	    } else {
+		for (ix = -1022,i=(hx<<11); i>0; i<<=1) ix -=1;
+	    }
+	} else ix = (hx>>20)-1023;
+
+    /* determine iy = ilogb(y) */
+	if(hy<0x00100000) {	/* subnormal y */
+	    if(hy==0) {
+		for (iy = -1043, i=ly; i>0; i<<=1) iy -=1;
+	    } else {
+		for (iy = -1022,i=(hy<<11); i>0; i<<=1) iy -=1;
+	    }
+	} else iy = (hy>>20)-1023;
+
+    /* set up {hx,lx}, {hy,ly} and align y to x */
+	if(ix >= -1022) 
+	    hx = 0x00100000|(0x000fffff&hx);
+	else {		/* subnormal x, shift x to normal */
+	    n = -1022-ix;
+	    if(n<=31) {
+	        hx = (hx<<n)|(lx>>(32-n));
+	        lx <<= n;
+	    } else {
+		hx = lx<<(n-32);
+		lx = 0;
+	    }
+	}
+	if(iy >= -1022) 
+	    hy = 0x00100000|(0x000fffff&hy);
+	else {		/* subnormal y, shift y to normal */
+	    n = -1022-iy;
+	    if(n<=31) {
+	        hy = (hy<<n)|(ly>>(32-n));
+	        ly <<= n;
+	    } else {
+		hy = ly<<(n-32);
+		ly = 0;
+	    }
+	}
+
+    /* fix point fmod */
+	n = ix - iy;
+	q = 0;
+	while(n--) {
+	    hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
+	    if(hz<0){hx = hx+hx+(lx>>31); lx = lx+lx;}
+	    else {hx = hz+hz+(lz>>31); lx = lz+lz; q++;}
+	    q <<= 1;
+	}
+	hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
+	if(hz>=0) {hx=hz;lx=lz;q++;}
+
+    /* convert back to floating value and restore the sign */
+	if((hx|lx)==0) {			/* return sign(x)*0 */
+	    q &= 0x7fffffff;
+	    *quo = (sxy ? -q : q);
+	    return Zero[(u_int32_t)sx>>31];
+	}
+	while(hx<0x00100000) {		/* normalize x */
+	    hx = hx+hx+(lx>>31); lx = lx+lx;
+	    iy -= 1;
+	}
+	if(iy>= -1022) {	/* normalize output */
+	    hx = ((hx-0x00100000)|((iy+1023)<<20));
+	} else {		/* subnormal output */
+	    n = -1022 - iy;
+	    if(n<=20) {
+		lx = (lx>>n)|((u_int32_t)hx<<(32-n));
+		hx >>= n;
+	    } else if (n<=31) {
+		lx = (hx<<(32-n))|(lx>>n); hx = 0;
+	    } else {
+		lx = hx>>(n-32); hx = 0;
+	    }
+	}
+fixup:
+	INSERT_WORDS(x,hx,lx);
+	y = fabs(y);
+	if (y < 0x1p-1021) {
+	    if (x+x>y || (x+x==y && (q & 1))) {
+		q++;
+		x-=y;
+	    }
+	} else if (x>0.5*y || (x==0.5*y && (q & 1))) {
+	    q++;
+	    x-=y;
+	}
+	GET_HIGH_WORD(hx,x);
+	SET_HIGH_WORD(x,hx^sx);
+	q &= 0x7fffffff;
+	*quo = (sxy ? -q : q);
+	return x;
+}
+
+#if LDBL_MANT_DIG == 53
+__weak_reference(remquo, remquol);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/s_remquof.c b/libm/upstream-freebsd/lib/msun/src/s_remquof.c
new file mode 100644
index 0000000..f7b4c00
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_remquof.c
@@ -0,0 +1,122 @@
+/* @(#)e_fmod.c 1.3 95/01/18 */
+/*-
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static const float Zero[] = {0.0, -0.0,};
+
+/*
+ * Return the IEEE remainder and set *quo to the last n bits of the
+ * quotient, rounded to the nearest integer.  We choose n=31 because
+ * we wind up computing all the integer bits of the quotient anyway as
+ * a side-effect of computing the remainder by the shift and subtract
+ * method.  In practice, this is far more bits than are needed to use
+ * remquo in reduction algorithms.
+ */
+float
+remquof(float x, float y, int *quo)
+{
+	int32_t n,hx,hy,hz,ix,iy,sx,i;
+	u_int32_t q,sxy;
+
+	GET_FLOAT_WORD(hx,x);
+	GET_FLOAT_WORD(hy,y);
+	sxy = (hx ^ hy) & 0x80000000;
+	sx = hx&0x80000000;		/* sign of x */
+	hx ^=sx;		/* |x| */
+	hy &= 0x7fffffff;	/* |y| */
+
+    /* purge off exception values */
+	if(hy==0||hx>=0x7f800000||hy>0x7f800000) /* y=0,NaN;or x not finite */
+	    return (x*y)/(x*y);
+	if(hx<hy) {
+	    q = 0;
+	    goto fixup;	/* |x|<|y| return x or x-y */
+	} else if(hx==hy) {
+	    *quo = (sxy ? -1 : 1);
+	    return Zero[(u_int32_t)sx>>31];	/* |x|=|y| return x*0*/
+	}
+
+    /* determine ix = ilogb(x) */
+	if(hx<0x00800000) {	/* subnormal x */
+	    for (ix = -126,i=(hx<<8); i>0; i<<=1) ix -=1;
+	} else ix = (hx>>23)-127;
+
+    /* determine iy = ilogb(y) */
+	if(hy<0x00800000) {	/* subnormal y */
+	    for (iy = -126,i=(hy<<8); i>0; i<<=1) iy -=1;
+	} else iy = (hy>>23)-127;
+
+    /* set up {hx,lx}, {hy,ly} and align y to x */
+	if(ix >= -126)
+	    hx = 0x00800000|(0x007fffff&hx);
+	else {		/* subnormal x, shift x to normal */
+	    n = -126-ix;
+	    hx <<= n;
+	}
+	if(iy >= -126)
+	    hy = 0x00800000|(0x007fffff&hy);
+	else {		/* subnormal y, shift y to normal */
+	    n = -126-iy;
+	    hy <<= n;
+	}
+
+    /* fix point fmod */
+	n = ix - iy;
+	q = 0;
+	while(n--) {
+	    hz=hx-hy;
+	    if(hz<0) hx = hx << 1;
+	    else {hx = hz << 1; q++;}
+	    q <<= 1;
+	}
+	hz=hx-hy;
+	if(hz>=0) {hx=hz;q++;}
+
+    /* convert back to floating value and restore the sign */
+	if(hx==0) {				/* return sign(x)*0 */
+	    q &= 0x7fffffff;
+	    *quo = (sxy ? -q : q);
+	    return Zero[(u_int32_t)sx>>31];
+	}
+	while(hx<0x00800000) {		/* normalize x */
+	    hx <<= 1;
+	    iy -= 1;
+	}
+	if(iy>= -126) {		/* normalize output */
+	    hx = ((hx-0x00800000)|((iy+127)<<23));
+	} else {		/* subnormal output */
+	    n = -126 - iy;
+	    hx >>= n;
+	}
+fixup:
+	SET_FLOAT_WORD(x,hx);
+	y = fabsf(y);
+	if (y < 0x1p-125f) {
+	    if (x+x>y || (x+x==y && (q & 1))) {
+		q++;
+		x-=y;
+	    }
+	} else if (x>0.5f*y || (x==0.5f*y && (q & 1))) {
+	    q++;
+	    x-=y;
+	}
+	GET_FLOAT_WORD(hx,x);
+	SET_FLOAT_WORD(x,hx^sx);
+	q &= 0x7fffffff;
+	*quo = (sxy ? -q : q);
+	return x;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_remquol.c b/libm/upstream-freebsd/lib/msun/src/s_remquol.c
new file mode 100644
index 0000000..712651c
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_remquol.c
@@ -0,0 +1,178 @@
+/* @(#)e_fmod.c 1.3 95/01/18 */
+/*-
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice 
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <float.h>
+#include <stdint.h>
+
+#include "fpmath.h"
+#include "math.h"
+#include "math_private.h"
+
+#define	BIAS (LDBL_MAX_EXP - 1)
+
+#if LDBL_MANL_SIZE > 32
+typedef	uint64_t manl_t;
+#else
+typedef	uint32_t manl_t;
+#endif
+
+#if LDBL_MANH_SIZE > 32
+typedef	uint64_t manh_t;
+#else
+typedef	uint32_t manh_t;
+#endif
+
+/*
+ * These macros add and remove an explicit integer bit in front of the
+ * fractional mantissa, if the architecture doesn't have such a bit by
+ * default already.
+ */
+#ifdef LDBL_IMPLICIT_NBIT
+#define	SET_NBIT(hx)	((hx) | (1ULL << LDBL_MANH_SIZE))
+#define	HFRAC_BITS	LDBL_MANH_SIZE
+#else
+#define	SET_NBIT(hx)	(hx)
+#define	HFRAC_BITS	(LDBL_MANH_SIZE - 1)
+#endif
+
+#define	MANL_SHIFT	(LDBL_MANL_SIZE - 1)
+
+static const long double Zero[] = {0.0L, -0.0L};
+
+/*
+ * Return the IEEE remainder and set *quo to the last n bits of the
+ * quotient, rounded to the nearest integer.  We choose n=31 because
+ * we wind up computing all the integer bits of the quotient anyway as
+ * a side-effect of computing the remainder by the shift and subtract
+ * method.  In practice, this is far more bits than are needed to use
+ * remquo in reduction algorithms.
+ *
+ * Assumptions:
+ * - The low part of the mantissa fits in a manl_t exactly.
+ * - The high part of the mantissa fits in an int64_t with enough room
+ *   for an explicit integer bit in front of the fractional bits.
+ */
+long double
+remquol(long double x, long double y, int *quo)
+{
+	union IEEEl2bits ux, uy;
+	int64_t hx,hz;	/* We need a carry bit even if LDBL_MANH_SIZE is 32. */
+	manh_t hy;
+	manl_t lx,ly,lz;
+	int ix,iy,n,q,sx,sxy;
+
+	ux.e = x;
+	uy.e = y;
+	sx = ux.bits.sign;
+	sxy = sx ^ uy.bits.sign;
+	ux.bits.sign = 0;	/* |x| */
+	uy.bits.sign = 0;	/* |y| */
+	x = ux.e;
+
+    /* purge off exception values */
+	if((uy.bits.exp|uy.bits.manh|uy.bits.manl)==0 || /* y=0 */
+	   (ux.bits.exp == BIAS + LDBL_MAX_EXP) ||	 /* or x not finite */
+	   (uy.bits.exp == BIAS + LDBL_MAX_EXP &&
+	    ((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl)!=0)) /* or y is NaN */
+	    return (x*y)/(x*y);
+	if(ux.bits.exp<=uy.bits.exp) {
+	    if((ux.bits.exp<uy.bits.exp) ||
+	       (ux.bits.manh<=uy.bits.manh &&
+		(ux.bits.manh<uy.bits.manh ||
+		 ux.bits.manl<uy.bits.manl))) {
+		q = 0;
+		goto fixup;	/* |x|<|y| return x or x-y */
+	    }
+	    if(ux.bits.manh==uy.bits.manh && ux.bits.manl==uy.bits.manl) {
+		*quo = (sxy ? -1 : 1);
+		return Zero[sx];	/* |x|=|y| return x*0*/
+	    }
+	}
+
+    /* determine ix = ilogb(x) */
+	if(ux.bits.exp == 0) {	/* subnormal x */
+	    ux.e *= 0x1.0p512;
+	    ix = ux.bits.exp - (BIAS + 512);
+	} else {
+	    ix = ux.bits.exp - BIAS;
+	}
+
+    /* determine iy = ilogb(y) */
+	if(uy.bits.exp == 0) {	/* subnormal y */
+	    uy.e *= 0x1.0p512;
+	    iy = uy.bits.exp - (BIAS + 512);
+	} else {
+	    iy = uy.bits.exp - BIAS;
+	}
+
+    /* set up {hx,lx}, {hy,ly} and align y to x */
+	hx = SET_NBIT(ux.bits.manh);
+	hy = SET_NBIT(uy.bits.manh);
+	lx = ux.bits.manl;
+	ly = uy.bits.manl;
+
+    /* fix point fmod */
+	n = ix - iy;
+	q = 0;
+
+	while(n--) {
+	    hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
+	    if(hz<0){hx = hx+hx+(lx>>MANL_SHIFT); lx = lx+lx;}
+	    else {hx = hz+hz+(lz>>MANL_SHIFT); lx = lz+lz; q++;}
+	    q <<= 1;
+	}
+	hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
+	if(hz>=0) {hx=hz;lx=lz;q++;}
+
+    /* convert back to floating value and restore the sign */
+	if((hx|lx)==0) {			/* return sign(x)*0 */
+	    q &= 0x7fffffff;
+	    *quo = (sxy ? -q : q);
+	    return Zero[sx];
+	}
+	while(hx<(1ULL<<HFRAC_BITS)) {	/* normalize x */
+	    hx = hx+hx+(lx>>MANL_SHIFT); lx = lx+lx;
+	    iy -= 1;
+	}
+	ux.bits.manh = hx; /* The integer bit is truncated here if needed. */
+	ux.bits.manl = lx;
+	if (iy < LDBL_MIN_EXP) {
+	    ux.bits.exp = iy + (BIAS + 512);
+	    ux.e *= 0x1p-512;
+	} else {
+	    ux.bits.exp = iy + BIAS;
+	}
+	ux.bits.sign = 0;
+	x = ux.e;
+fixup:
+	y = fabsl(y);
+	if (y < LDBL_MIN * 2) {
+	    if (x+x>y || (x+x==y && (q & 1))) {
+		q++;
+		x-=y;
+	    }
+	} else if (x>0.5*y || (x==0.5*y && (q & 1))) {
+	    q++;
+	    x-=y;
+	}
+
+	ux.e = x;
+	ux.bits.sign ^= sx;
+	x = ux.e;
+
+	q &= 0x7fffffff;
+	*quo = (sxy ? -q : q);
+	return x;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_rint.c b/libm/upstream-freebsd/lib/msun/src/s_rint.c
new file mode 100644
index 0000000..c56f8fb
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_rint.c
@@ -0,0 +1,92 @@
+/* @(#)s_rint.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * rint(x)
+ * Return x rounded to integral value according to the prevailing
+ * rounding mode.
+ * Method:
+ *	Using floating addition.
+ * Exception:
+ *	Inexact flag raised if x not equal to rint(x).
+ */
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const double
+TWO52[2]={
+  4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
+ -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */
+};
+
+double
+rint(double x)
+{
+	int32_t i0,j0,sx;
+	u_int32_t i,i1;
+	double w,t;
+	EXTRACT_WORDS(i0,i1,x);
+	sx = (i0>>31)&1;
+	j0 = ((i0>>20)&0x7ff)-0x3ff;
+	if(j0<20) {
+	    if(j0<0) {
+		if(((i0&0x7fffffff)|i1)==0) return x;
+		i1 |= (i0&0x0fffff);
+		i0 &= 0xfffe0000;
+		i0 |= ((i1|-i1)>>12)&0x80000;
+		SET_HIGH_WORD(x,i0);
+	        STRICT_ASSIGN(double,w,TWO52[sx]+x);
+	        t =  w-TWO52[sx];
+		GET_HIGH_WORD(i0,t);
+		SET_HIGH_WORD(t,(i0&0x7fffffff)|(sx<<31));
+	        return t;
+	    } else {
+		i = (0x000fffff)>>j0;
+		if(((i0&i)|i1)==0) return x; /* x is integral */
+		i>>=1;
+		if(((i0&i)|i1)!=0) {
+		    /*
+		     * Some bit is set after the 0.5 bit.  To avoid the
+		     * possibility of errors from double rounding in
+		     * w = TWO52[sx]+x, adjust the 0.25 bit to a lower
+		     * guard bit.  We do this for all j0<=51.  The
+		     * adjustment is trickiest for j0==18 and j0==19
+		     * since then it spans the word boundary.
+		     */
+		    if(j0==19) i1 = 0x40000000; else
+		    if(j0==18) i1 = 0x80000000; else
+		    i0 = (i0&(~i))|((0x20000)>>j0);
+		}
+	    }
+	} else if (j0>51) {
+	    if(j0==0x400) return x+x;	/* inf or NaN */
+	    else return x;		/* x is integral */
+	} else {
+	    i = ((u_int32_t)(0xffffffff))>>(j0-20);
+	    if((i1&i)==0) return x;	/* x is integral */
+	    i>>=1;
+	    if((i1&i)!=0) i1 = (i1&(~i))|((0x40000000)>>(j0-20));
+	}
+	INSERT_WORDS(x,i0,i1);
+	STRICT_ASSIGN(double,w,TWO52[sx]+x);
+	return w-TWO52[sx];
+}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(rint, rintl);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/s_rintf.c b/libm/upstream-freebsd/lib/msun/src/s_rintf.c
new file mode 100644
index 0000000..f8743a4
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_rintf.c
@@ -0,0 +1,53 @@
+/* s_rintf.c -- float version of s_rint.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <float.h>
+#include <stdint.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const float
+TWO23[2]={
+  8.3886080000e+06, /* 0x4b000000 */
+ -8.3886080000e+06, /* 0xcb000000 */
+};
+
+float
+rintf(float x)
+{
+	int32_t i0,j0,sx;
+	float w,t;
+	GET_FLOAT_WORD(i0,x);
+	sx = (i0>>31)&1;
+	j0 = ((i0>>23)&0xff)-0x7f;
+	if(j0<23) {
+	    if(j0<0) {
+		if((i0&0x7fffffff)==0) return x;
+		STRICT_ASSIGN(float,w,TWO23[sx]+x);
+	        t =  w-TWO23[sx];
+		GET_FLOAT_WORD(i0,t);
+		SET_FLOAT_WORD(t,(i0&0x7fffffff)|(sx<<31));
+	        return t;
+	    }
+	    STRICT_ASSIGN(float,w,TWO23[sx]+x);
+	    return w-TWO23[sx];
+	}
+	if(j0==0x80) return x+x;	/* inf or NaN */
+	else return x;			/* x is integral */
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_rintl.c b/libm/upstream-freebsd/lib/msun/src/s_rintl.c
new file mode 100644
index 0000000..b43df89
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_rintl.c
@@ -0,0 +1,90 @@
+/*-
+ * Copyright (c) 2008 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <float.h>
+#include <math.h>
+
+#include "fpmath.h"
+
+#if LDBL_MAX_EXP != 0x4000
+/* We also require the usual bias, min exp and expsign packing. */
+#error "Unsupported long double format"
+#endif
+
+#define	BIAS	(LDBL_MAX_EXP - 1)
+
+static const float
+shift[2] = {
+#if LDBL_MANT_DIG == 64
+	0x1.0p63, -0x1.0p63
+#elif LDBL_MANT_DIG == 113
+	0x1.0p112, -0x1.0p112
+#else
+#error "Unsupported long double format"
+#endif
+};
+static const float zero[2] = { 0.0, -0.0 };
+
+long double
+rintl(long double x)
+{
+	union IEEEl2bits u;
+	uint32_t expsign;
+	int ex, sign;
+
+	u.e = x;
+	expsign = u.xbits.expsign;
+	ex = expsign & 0x7fff;
+
+	if (ex >= BIAS + LDBL_MANT_DIG - 1) {
+		if (ex == BIAS + LDBL_MAX_EXP)
+			return (x + x);	/* Inf, NaN, or unsupported format */
+		return (x);		/* finite and already an integer */
+	}
+	sign = expsign >> 15;
+
+	/*
+	 * The following code assumes that intermediate results are
+	 * evaluated in long double precision. If they are evaluated in
+	 * greater precision, double rounding may occur, and if they are
+	 * evaluated in less precision (as on i386), results will be
+	 * wildly incorrect.
+	 */
+	x += shift[sign];
+	x -= shift[sign];
+
+	/*
+	 * If the result is +-0, then it must have the same sign as x, but
+	 * the above calculation doesn't always give this.  Fix up the sign.
+	 */
+	if (ex < BIAS && x == 0.0L)
+		return (zero[sign]);
+
+	return (x);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_round.c b/libm/upstream-freebsd/lib/msun/src/s_round.c
new file mode 100644
index 0000000..65de31b
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_round.c
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c) 2003, Steven G. Kargl
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <math.h>
+
+double
+round(double x)
+{
+	double t;
+
+	if (!isfinite(x))
+		return (x);
+
+	if (x >= 0.0) {
+		t = floor(x);
+		if (t - x <= -0.5)
+			t += 1.0;
+		return (t);
+	} else {
+		t = floor(-x);
+		if (t + x <= -0.5)
+			t += 1.0;
+		return (-t);
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_roundf.c b/libm/upstream-freebsd/lib/msun/src/s_roundf.c
new file mode 100644
index 0000000..952e8e7
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_roundf.c
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c) 2003, Steven G. Kargl
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <math.h>
+
+float
+roundf(float x)
+{
+	float t;
+
+	if (!isfinite(x))
+		return (x);
+
+	if (x >= 0.0) {
+		t = floorf(x);
+		if (t - x <= -0.5)
+			t += 1.0;
+		return (t);
+	} else {
+		t = floorf(-x);
+		if (t + x <= -0.5)
+			t += 1.0;
+		return (-t);
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_roundl.c b/libm/upstream-freebsd/lib/msun/src/s_roundl.c
new file mode 100644
index 0000000..a70b617
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_roundl.c
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c) 2003, Steven G. Kargl
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <math.h>
+
+long double
+roundl(long double x)
+{
+	long double t;
+
+	if (!isfinite(x))
+		return (x);
+
+	if (x >= 0.0) {
+		t = floorl(x);
+		if (t - x <= -0.5)
+			t += 1.0;
+		return (t);
+	} else {
+		t = floorl(-x);
+		if (t + x <= -0.5)
+			t += 1.0;
+		return (-t);
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_scalbln.c b/libm/upstream-freebsd/lib/msun/src/s_scalbln.c
new file mode 100644
index 0000000..d609d4e
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_scalbln.c
@@ -0,0 +1,76 @@
+/*-
+ * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <limits.h>
+#include <math.h>
+
+double
+scalbln (double x, long n)
+{
+	int in;
+
+	in = (int)n;
+	if (in != n) {
+		if (n > 0)
+			in = INT_MAX;
+		else
+			in = INT_MIN;
+	}
+	return (scalbn(x, in));
+}
+
+float
+scalblnf (float x, long n)
+{
+	int in;
+
+	in = (int)n;
+	if (in != n) {
+		if (n > 0)
+			in = INT_MAX;
+		else
+			in = INT_MIN;
+	}
+	return (scalbnf(x, in));
+}
+
+long double
+scalblnl (long double x, long n)
+{
+	int in;
+
+	in = (int)n;
+	if (in != n) {
+		if (n > 0)
+			in = INT_MAX;
+		else
+			in = INT_MIN;
+	}
+	return (scalbnl(x, (int)n));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_scalbn.c b/libm/upstream-freebsd/lib/msun/src/s_scalbn.c
new file mode 100644
index 0000000..e7efaab
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_scalbn.c
@@ -0,0 +1,66 @@
+/* @(#)s_scalbn.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#ifndef lint
+static char rcsid[] = "$FreeBSD$";
+#endif
+
+/*
+ * scalbn (double x, int n)
+ * scalbn(x,n) returns x* 2**n  computed by  exponent
+ * manipulation rather than by actually performing an
+ * exponentiation or a multiplication.
+ */
+
+#include <sys/cdefs.h>
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const double
+two54   =  1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
+twom54  =  5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */
+huge   = 1.0e+300,
+tiny   = 1.0e-300;
+
+double
+scalbn (double x, int n)
+{
+	int32_t k,hx,lx;
+	EXTRACT_WORDS(hx,lx,x);
+        k = (hx&0x7ff00000)>>20;		/* extract exponent */
+        if (k==0) {				/* 0 or subnormal x */
+            if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */
+	    x *= two54;
+	    GET_HIGH_WORD(hx,x);
+	    k = ((hx&0x7ff00000)>>20) - 54;
+            if (n< -50000) return tiny*x; 	/*underflow*/
+	    }
+        if (k==0x7ff) return x+x;		/* NaN or Inf */
+        k = k+n;
+        if (k >  0x7fe) return huge*copysign(huge,x); /* overflow  */
+        if (k > 0) 				/* normal result */
+	    {SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x;}
+        if (k <= -54)
+            if (n > 50000) 	/* in case integer overflow in n+k */
+		return huge*copysign(huge,x);	/*overflow*/
+	    else return tiny*copysign(tiny,x); 	/*underflow*/
+        k += 54;				/* subnormal result */
+	SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20));
+        return x*twom54;
+}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(scalbn, ldexpl);
+__weak_reference(scalbn, scalbnl);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/s_scalbnf.c b/libm/upstream-freebsd/lib/msun/src/s_scalbnf.c
new file mode 100644
index 0000000..7666c74
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_scalbnf.c
@@ -0,0 +1,58 @@
+/* s_scalbnf.c -- float version of s_scalbn.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#ifndef lint
+static char rcsid[] = "$FreeBSD$";
+#endif
+
+#include <sys/cdefs.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const float
+two25   =  3.355443200e+07,	/* 0x4c000000 */
+twom25  =  2.9802322388e-08,	/* 0x33000000 */
+huge   = 1.0e+30,
+tiny   = 1.0e-30;
+
+float
+scalbnf (float x, int n)
+{
+	int32_t k,ix;
+	GET_FLOAT_WORD(ix,x);
+        k = (ix&0x7f800000)>>23;		/* extract exponent */
+        if (k==0) {				/* 0 or subnormal x */
+            if ((ix&0x7fffffff)==0) return x; /* +-0 */
+	    x *= two25;
+	    GET_FLOAT_WORD(ix,x);
+	    k = ((ix&0x7f800000)>>23) - 25;
+            if (n< -50000) return tiny*x; 	/*underflow*/
+	    }
+        if (k==0xff) return x+x;		/* NaN or Inf */
+        k = k+n;
+        if (k >  0xfe) return huge*copysignf(huge,x); /* overflow  */
+        if (k > 0) 				/* normal result */
+	    {SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23)); return x;}
+        if (k <= -25)
+            if (n > 50000) 	/* in case integer overflow in n+k */
+		return huge*copysignf(huge,x);	/*overflow*/
+	    else return tiny*copysignf(tiny,x);	/*underflow*/
+        k += 25;				/* subnormal result */
+	SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23));
+        return x*twom25;
+}
+
+__strong_reference(scalbnf, ldexpf);
diff --git a/libm/upstream-freebsd/lib/msun/src/s_scalbnl.c b/libm/upstream-freebsd/lib/msun/src/s_scalbnl.c
new file mode 100644
index 0000000..fc89f8d
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_scalbnl.c
@@ -0,0 +1,71 @@
+/* @(#)s_scalbn.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#ifndef lint
+static char rcsid[] = "$FreeBSD$";
+#endif
+
+/*
+ * scalbnl (long double x, int n)
+ * scalbnl(x,n) returns x* 2**n  computed by  exponent
+ * manipulation rather than by actually performing an
+ * exponentiation or a multiplication.
+ */
+
+/*
+ * We assume that a long double has a 15-bit exponent.  On systems
+ * where long double is the same as double, scalbnl() is an alias
+ * for scalbn(), so we don't use this routine.
+ */
+
+#include <sys/cdefs.h>
+#include <float.h>
+#include <math.h>
+
+#include "fpmath.h"
+
+#if LDBL_MAX_EXP != 0x4000
+#error "Unsupported long double format"
+#endif
+
+static const long double
+huge = 0x1p16000L,
+tiny = 0x1p-16000L;
+
+long double
+scalbnl (long double x, int n)
+{
+	union IEEEl2bits u;
+	int k;
+	u.e = x;
+        k = u.bits.exp;				/* extract exponent */
+        if (k==0) {				/* 0 or subnormal x */
+            if ((u.bits.manh|u.bits.manl)==0) return x;	/* +-0 */
+	    u.e *= 0x1p+128;
+	    k = u.bits.exp - 128;
+            if (n< -50000) return tiny*x; 	/*underflow*/
+	    }
+        if (k==0x7fff) return x+x;		/* NaN or Inf */
+        k = k+n;
+        if (k >= 0x7fff) return huge*copysignl(huge,x); /* overflow  */
+        if (k > 0) 				/* normal result */
+	    {u.bits.exp = k; return u.e;}
+        if (k <= -128)
+            if (n > 50000) 	/* in case integer overflow in n+k */
+		return huge*copysign(huge,x);	/*overflow*/
+	    else return tiny*copysign(tiny,x); 	/*underflow*/
+        k += 128;				/* subnormal result */
+	u.bits.exp = k;
+        return u.e*0x1p-128;
+}
+
+__strong_reference(scalbnl, ldexpl);
diff --git a/libm/upstream-freebsd/lib/msun/src/s_signbit.c b/libm/upstream-freebsd/lib/msun/src/s_signbit.c
new file mode 100644
index 0000000..01eb3ab
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_signbit.c
@@ -0,0 +1,58 @@
+/*-
+ * Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <math.h>
+
+#include "fpmath.h"
+
+int
+__signbit(double d)
+{
+	union IEEEd2bits u;
+
+	u.d = d;
+	return (u.bits.sign);
+}
+
+int
+__signbitf(float f)
+{
+	union IEEEf2bits u;
+
+	u.f = f;
+	return (u.bits.sign);
+}
+
+int
+__signbitl(long double e)
+{
+	union IEEEl2bits u;
+
+	u.e = e;
+	return (u.bits.sign);
+}
diff --git a/libm/src/s_signgam.c b/libm/upstream-freebsd/lib/msun/src/s_signgam.c
similarity index 100%
rename from libm/src/s_signgam.c
rename to libm/upstream-freebsd/lib/msun/src/s_signgam.c
diff --git a/libm/upstream-freebsd/lib/msun/src/s_significand.c b/libm/upstream-freebsd/lib/msun/src/s_significand.c
new file mode 100644
index 0000000..356e300
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_significand.c
@@ -0,0 +1,29 @@
+/* @(#)s_signif.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * significand(x) computes just
+ * 	scalb(x, (double) -ilogb(x)),
+ * for exercising the fraction-part(F) IEEE 754-1985 test vector.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+double
+significand(double x)
+{
+	return __ieee754_scalb(x,(double) -ilogb(x));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_significandf.c b/libm/upstream-freebsd/lib/msun/src/s_significandf.c
new file mode 100644
index 0000000..ad030e2
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_significandf.c
@@ -0,0 +1,26 @@
+/* s_significandf.c -- float version of s_significand.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+float
+significandf(float x)
+{
+	return __ieee754_scalbf(x,(float) -ilogbf(x));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_sin.c b/libm/upstream-freebsd/lib/msun/src/s_sin.c
new file mode 100644
index 0000000..17ea846
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_sin.c
@@ -0,0 +1,89 @@
+/* @(#)s_sin.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* sin(x)
+ * Return sine function of x.
+ *
+ * kernel function:
+ *	__kernel_sin		... sine function on [-pi/4,pi/4]
+ *	__kernel_cos		... cose function on [-pi/4,pi/4]
+ *	__ieee754_rem_pio2	... argument reduction routine
+ *
+ * Method.
+ *      Let S,C and T denote the sin, cos and tan respectively on
+ *	[-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
+ *	in [-pi/4 , +pi/4], and let n = k mod 4.
+ *	We have
+ *
+ *          n        sin(x)      cos(x)        tan(x)
+ *     ----------------------------------------------------------
+ *	    0	       S	   C		 T
+ *	    1	       C	  -S		-1/T
+ *	    2	      -S	  -C		 T
+ *	    3	      -C	   S		-1/T
+ *     ----------------------------------------------------------
+ *
+ * Special cases:
+ *      Let trig be any of sin, cos, or tan.
+ *      trig(+-INF)  is NaN, with signals;
+ *      trig(NaN)    is that NaN;
+ *
+ * Accuracy:
+ *	TRIG(x) returns trig(x) nearly rounded
+ */
+
+#include <float.h>
+
+#include "math.h"
+#define INLINE_REM_PIO2
+#include "math_private.h"
+#include "e_rem_pio2.c"
+
+double
+sin(double x)
+{
+	double y[2],z=0.0;
+	int32_t n, ix;
+
+    /* High word of x. */
+	GET_HIGH_WORD(ix,x);
+
+    /* |x| ~< pi/4 */
+	ix &= 0x7fffffff;
+	if(ix <= 0x3fe921fb) {
+	    if(ix<0x3e500000)			/* |x| < 2**-26 */
+	       {if((int)x==0) return x;}	/* generate inexact */
+	    return __kernel_sin(x,z,0);
+	}
+
+    /* sin(Inf or NaN) is NaN */
+	else if (ix>=0x7ff00000) return x-x;
+
+    /* argument reduction needed */
+	else {
+	    n = __ieee754_rem_pio2(x,y);
+	    switch(n&3) {
+		case 0: return  __kernel_sin(y[0],y[1],1);
+		case 1: return  __kernel_cos(y[0],y[1]);
+		case 2: return -__kernel_sin(y[0],y[1],1);
+		default:
+			return -__kernel_cos(y[0],y[1]);
+	    }
+	}
+}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(sin, sinl);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/s_sinf.c b/libm/upstream-freebsd/lib/msun/src/s_sinf.c
new file mode 100644
index 0000000..41b5dc1
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_sinf.c
@@ -0,0 +1,85 @@
+/* s_sinf.c -- float version of s_sin.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ * Optimized by Bruce D. Evans.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <float.h>
+
+#include "math.h"
+#define	INLINE_KERNEL_COSDF
+#define	INLINE_KERNEL_SINDF
+#define INLINE_REM_PIO2F
+#include "math_private.h"
+#include "e_rem_pio2f.c"
+#include "k_cosf.c"
+#include "k_sinf.c"
+
+/* Small multiples of pi/2 rounded to double precision. */
+static const double
+s1pio2 = 1*M_PI_2,			/* 0x3FF921FB, 0x54442D18 */
+s2pio2 = 2*M_PI_2,			/* 0x400921FB, 0x54442D18 */
+s3pio2 = 3*M_PI_2,			/* 0x4012D97C, 0x7F3321D2 */
+s4pio2 = 4*M_PI_2;			/* 0x401921FB, 0x54442D18 */
+
+float
+sinf(float x)
+{
+	double y;
+	int32_t n, hx, ix;
+
+	GET_FLOAT_WORD(hx,x);
+	ix = hx & 0x7fffffff;
+
+	if(ix <= 0x3f490fda) {		/* |x| ~<= pi/4 */
+	    if(ix<0x39800000)		/* |x| < 2**-12 */
+		if(((int)x)==0) return x;	/* x with inexact if x != 0 */
+	    return __kernel_sindf(x);
+	}
+	if(ix<=0x407b53d1) {		/* |x| ~<= 5*pi/4 */
+	    if(ix<=0x4016cbe3) {	/* |x| ~<= 3pi/4 */
+		if(hx>0)
+		    return __kernel_cosdf(x - s1pio2);
+		else
+		    return -__kernel_cosdf(x + s1pio2);
+	    } else
+		return __kernel_sindf((hx > 0 ? s2pio2 : -s2pio2) - x);
+	}
+	if(ix<=0x40e231d5) {		/* |x| ~<= 9*pi/4 */
+	    if(ix<=0x40afeddf) {	/* |x| ~<= 7*pi/4 */
+		if(hx>0)
+		    return -__kernel_cosdf(x - s3pio2);
+		else
+		    return __kernel_cosdf(x + s3pio2);
+	    } else
+		return __kernel_sindf(x + (hx > 0 ? -s4pio2 : s4pio2));
+	}
+
+    /* sin(Inf or NaN) is NaN */
+	else if (ix>=0x7f800000) return x-x;
+
+    /* general argument reduction needed */
+	else {
+	    n = __ieee754_rem_pio2f(x,&y);
+	    switch(n&3) {
+		case 0: return  __kernel_sindf(y);
+		case 1: return  __kernel_cosdf(y);
+		case 2: return  __kernel_sindf(-y);
+		default:
+			return -__kernel_cosdf(y);
+	    }
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_sinl.c b/libm/upstream-freebsd/lib/msun/src/s_sinl.c
new file mode 100644
index 0000000..f454f8f
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_sinl.c
@@ -0,0 +1,93 @@
+/*-
+ * Copyright (c) 2007 Steven G. Kargl
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <float.h>
+#ifdef __i386__
+#include <ieeefp.h>
+#endif
+
+#include "math.h"
+#include "math_private.h"
+#if LDBL_MANT_DIG == 64
+#include "../ld80/e_rem_pio2l.h"
+#elif LDBL_MANT_DIG == 113
+#include "../ld128/e_rem_pio2l.h"
+#else
+#error "Unsupported long double format"
+#endif
+
+long double
+sinl(long double x)
+{
+	union IEEEl2bits z;
+	int e0, s;
+	long double y[2];
+	long double hi, lo;
+
+	z.e = x;
+	s = z.bits.sign;
+	z.bits.sign = 0;
+
+	/* If x = +-0 or x is a subnormal number, then sin(x) = x */
+	if (z.bits.exp == 0)
+		return (x);
+
+	/* If x = NaN or Inf, then sin(x) = NaN. */
+	if (z.bits.exp == 32767)
+		return ((x - x) / (x - x));
+
+	ENTERI();
+
+	/* Optimize the case where x is already within range. */
+	if (z.e < M_PI_4) {
+		hi = __kernel_sinl(z.e, 0, 0);
+		RETURNI(s ? -hi : hi);
+	}
+
+	e0 = __ieee754_rem_pio2l(x, y);
+	hi = y[0];
+	lo = y[1];
+
+	switch (e0 & 3) {
+	case 0:
+	    hi = __kernel_sinl(hi, lo, 1);
+	    break;
+	case 1:
+	    hi = __kernel_cosl(hi, lo);
+	    break;
+	case 2:
+	    hi = - __kernel_sinl(hi, lo, 1);
+	    break;
+	case 3:
+	    hi = - __kernel_cosl(hi, lo);
+	    break;
+	}
+	
+	RETURNI(hi);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_tan.c b/libm/upstream-freebsd/lib/msun/src/s_tan.c
new file mode 100644
index 0000000..196c27e
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_tan.c
@@ -0,0 +1,83 @@
+/* @(#)s_tan.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* tan(x)
+ * Return tangent function of x.
+ *
+ * kernel function:
+ *	__kernel_tan		... tangent function on [-pi/4,pi/4]
+ *	__ieee754_rem_pio2	... argument reduction routine
+ *
+ * Method.
+ *      Let S,C and T denote the sin, cos and tan respectively on
+ *	[-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
+ *	in [-pi/4 , +pi/4], and let n = k mod 4.
+ *	We have
+ *
+ *          n        sin(x)      cos(x)        tan(x)
+ *     ----------------------------------------------------------
+ *	    0	       S	   C		 T
+ *	    1	       C	  -S		-1/T
+ *	    2	      -S	  -C		 T
+ *	    3	      -C	   S		-1/T
+ *     ----------------------------------------------------------
+ *
+ * Special cases:
+ *      Let trig be any of sin, cos, or tan.
+ *      trig(+-INF)  is NaN, with signals;
+ *      trig(NaN)    is that NaN;
+ *
+ * Accuracy:
+ *	TRIG(x) returns trig(x) nearly rounded
+ */
+
+#include <float.h>
+
+#include "math.h"
+#define INLINE_REM_PIO2
+#include "math_private.h"
+#include "e_rem_pio2.c"
+
+double
+tan(double x)
+{
+	double y[2],z=0.0;
+	int32_t n, ix;
+
+    /* High word of x. */
+	GET_HIGH_WORD(ix,x);
+
+    /* |x| ~< pi/4 */
+	ix &= 0x7fffffff;
+	if(ix <= 0x3fe921fb) {
+	    if(ix<0x3e400000)			/* x < 2**-27 */
+		if((int)x==0) return x;		/* generate inexact */
+	    return __kernel_tan(x,z,1);
+	}
+
+    /* tan(Inf or NaN) is NaN */
+	else if (ix>=0x7ff00000) return x-x;		/* NaN */
+
+    /* argument reduction needed */
+	else {
+	    n = __ieee754_rem_pio2(x,y);
+	    return __kernel_tan(y[0],y[1],1-((n&1)<<1)); /*   1 -- n even
+							-1 -- n odd */
+	}
+}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(tan, tanl);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/s_tanf.c b/libm/upstream-freebsd/lib/msun/src/s_tanf.c
new file mode 100644
index 0000000..4fe8c17
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_tanf.c
@@ -0,0 +1,72 @@
+/* s_tanf.c -- float version of s_tan.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ * Optimized by Bruce D. Evans.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <float.h>
+
+#include "math.h"
+#define	INLINE_KERNEL_TANDF
+#define INLINE_REM_PIO2F
+#include "math_private.h"
+#include "e_rem_pio2f.c"
+#include "k_tanf.c"
+
+/* Small multiples of pi/2 rounded to double precision. */
+static const double
+t1pio2 = 1*M_PI_2,			/* 0x3FF921FB, 0x54442D18 */
+t2pio2 = 2*M_PI_2,			/* 0x400921FB, 0x54442D18 */
+t3pio2 = 3*M_PI_2,			/* 0x4012D97C, 0x7F3321D2 */
+t4pio2 = 4*M_PI_2;			/* 0x401921FB, 0x54442D18 */
+
+float
+tanf(float x)
+{
+	double y;
+	int32_t n, hx, ix;
+
+	GET_FLOAT_WORD(hx,x);
+	ix = hx & 0x7fffffff;
+
+	if(ix <= 0x3f490fda) {		/* |x| ~<= pi/4 */
+	    if(ix<0x39800000)		/* |x| < 2**-12 */
+		if(((int)x)==0) return x;	/* x with inexact if x != 0 */
+	    return __kernel_tandf(x,1);
+	}
+	if(ix<=0x407b53d1) {		/* |x| ~<= 5*pi/4 */
+	    if(ix<=0x4016cbe3)		/* |x| ~<= 3pi/4 */
+		return __kernel_tandf(x + (hx>0 ? -t1pio2 : t1pio2), -1);
+	    else
+		return __kernel_tandf(x + (hx>0 ? -t2pio2 : t2pio2), 1);
+	}
+	if(ix<=0x40e231d5) {		/* |x| ~<= 9*pi/4 */
+	    if(ix<=0x40afeddf)		/* |x| ~<= 7*pi/4 */
+		return __kernel_tandf(x + (hx>0 ? -t3pio2 : t3pio2), -1);
+	    else
+		return __kernel_tandf(x + (hx>0 ? -t4pio2 : t4pio2), 1);
+	}
+
+    /* tan(Inf or NaN) is NaN */
+	else if (ix>=0x7f800000) return x-x;
+
+    /* general argument reduction needed */
+	else {
+	    n = __ieee754_rem_pio2f(x,&y);
+	    /* integer parameter: 1 -- n even; -1 -- n odd */
+	    return __kernel_tandf(y,1-((n&1)<<1));
+	}
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_tanh.c b/libm/upstream-freebsd/lib/msun/src/s_tanh.c
new file mode 100644
index 0000000..96e3565
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_tanh.c
@@ -0,0 +1,77 @@
+/* @(#)s_tanh.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* Tanh(x)
+ * Return the Hyperbolic Tangent of x
+ *
+ * Method :
+ *				       x    -x
+ *				      e  - e
+ *	0. tanh(x) is defined to be -----------
+ *				       x    -x
+ *				      e  + e
+ *	1. reduce x to non-negative by tanh(-x) = -tanh(x).
+ *	2.  0      <= x <  2**-28 : tanh(x) := x with inexact if x != 0
+ *					        -t
+ *	    2**-28 <= x <  1      : tanh(x) := -----; t = expm1(-2x)
+ *					       t + 2
+ *						     2
+ *	    1      <= x <  22     : tanh(x) := 1 - -----; t = expm1(2x)
+ *						   t + 2
+ *	    22     <= x <= INF    : tanh(x) := 1.
+ *
+ * Special cases:
+ *	tanh(NaN) is NaN;
+ *	only tanh(0)=0 is exact for finite argument.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+static const double one = 1.0, two = 2.0, tiny = 1.0e-300, huge = 1.0e300;
+
+double
+tanh(double x)
+{
+	double t,z;
+	int32_t jx,ix;
+
+	GET_HIGH_WORD(jx,x);
+	ix = jx&0x7fffffff;
+
+    /* x is INF or NaN */
+	if(ix>=0x7ff00000) {
+	    if (jx>=0) return one/x+one;    /* tanh(+-inf)=+-1 */
+	    else       return one/x-one;    /* tanh(NaN) = NaN */
+	}
+
+    /* |x| < 22 */
+	if (ix < 0x40360000) {		/* |x|<22 */
+	    if (ix<0x3e300000) {	/* |x|<2**-28 */
+		if(huge+x>one) return x; /* tanh(tiny) = tiny with inexact */
+	    }
+	    if (ix>=0x3ff00000) {	/* |x|>=1  */
+		t = expm1(two*fabs(x));
+		z = one - two/(t+two);
+	    } else {
+	        t = expm1(-two*fabs(x));
+	        z= -t/(t+two);
+	    }
+    /* |x| >= 22, return +-1 */
+	} else {
+	    z = one - tiny;		/* raise inexact flag */
+	}
+	return (jx>=0)? z: -z;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_tanhf.c b/libm/upstream-freebsd/lib/msun/src/s_tanhf.c
new file mode 100644
index 0000000..04f09c6
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_tanhf.c
@@ -0,0 +1,55 @@
+/* s_tanhf.c -- float version of s_tanh.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "math.h"
+#include "math_private.h"
+
+static const float one=1.0, two=2.0, tiny = 1.0e-30, huge = 1.0e30;
+float
+tanhf(float x)
+{
+	float t,z;
+	int32_t jx,ix;
+
+	GET_FLOAT_WORD(jx,x);
+	ix = jx&0x7fffffff;
+
+    /* x is INF or NaN */
+	if(ix>=0x7f800000) {
+	    if (jx>=0) return one/x+one;    /* tanh(+-inf)=+-1 */
+	    else       return one/x-one;    /* tanh(NaN) = NaN */
+	}
+
+    /* |x| < 9 */
+	if (ix < 0x41100000) {		/* |x|<9 */
+	    if (ix<0x39800000) {	/* |x|<2**-12 */
+		if(huge+x>one) return x; /* tanh(tiny) = tiny with inexact */
+	    }
+	    if (ix>=0x3f800000) {	/* |x|>=1  */
+		t = expm1f(two*fabsf(x));
+		z = one - two/(t+two);
+	    } else {
+	        t = expm1f(-two*fabsf(x));
+	        z= -t/(t+two);
+	    }
+    /* |x| >= 9, return +-1 */
+	} else {
+	    z = one - tiny;		/* raise inexact flag */
+	}
+	return (jx>=0)? z: -z;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_tanl.c b/libm/upstream-freebsd/lib/msun/src/s_tanl.c
new file mode 100644
index 0000000..eadc837
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_tanl.c
@@ -0,0 +1,95 @@
+/*-
+ * Copyright (c) 2007 Steven G. Kargl
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * Limited testing on pseudorandom numbers drawn within [0:4e8] shows
+ * an accuracy of <= 1.5 ULP where 247024 values of x out of 40 million
+ * possibles resulted in tan(x) that exceeded 0.5 ULP (ie., 0.6%).
+ */
+
+#include <float.h>
+#ifdef __i386__
+#include <ieeefp.h>
+#endif
+
+#include "math.h"
+#include "math_private.h"
+#if LDBL_MANT_DIG == 64
+#include "../ld80/e_rem_pio2l.h"
+#elif LDBL_MANT_DIG == 113
+#include "../ld128/e_rem_pio2l.h"
+#else
+#error "Unsupported long double format"
+#endif
+
+long double
+tanl(long double x)
+{
+	union IEEEl2bits z;
+	int e0, s;
+	long double y[2];
+	long double hi, lo;
+
+	z.e = x;
+	s = z.bits.sign;
+	z.bits.sign = 0;
+
+	/* If x = +-0 or x is subnormal, then tan(x) = x. */
+	if (z.bits.exp == 0)
+		return (x);
+
+	/* If x = NaN or Inf, then tan(x) = NaN. */
+	if (z.bits.exp == 32767)
+		return ((x - x) / (x - x));
+
+	ENTERI();
+
+	/* Optimize the case where x is already within range. */
+	if (z.e < M_PI_4) {
+		hi = __kernel_tanl(z.e, 0, 0);
+		RETURNI(s ? -hi : hi);
+	}
+
+	e0 = __ieee754_rem_pio2l(x, y);
+	hi = y[0];
+	lo = y[1];
+
+	switch (e0 & 3) {
+	case 0:
+	case 2:
+	    hi = __kernel_tanl(hi, lo, 0);
+	    break;
+	case 1:
+	case 3:
+	    hi = __kernel_tanl(hi, lo, 1);
+	    break;
+	}
+
+	RETURNI(hi);
+}
diff --git a/libm/src/s_tgammaf.c b/libm/upstream-freebsd/lib/msun/src/s_tgammaf.c
similarity index 100%
rename from libm/src/s_tgammaf.c
rename to libm/upstream-freebsd/lib/msun/src/s_tgammaf.c
diff --git a/libm/upstream-freebsd/lib/msun/src/s_trunc.c b/libm/upstream-freebsd/lib/msun/src/s_trunc.c
new file mode 100644
index 0000000..63a6753
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_trunc.c
@@ -0,0 +1,67 @@
+/* @(#)s_floor.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * trunc(x)
+ * Return x rounded toward 0 to integral value
+ * Method:
+ *	Bit twiddling.
+ * Exception:
+ *	Inexact flag raised if x not equal to trunc(x).
+ */
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const double huge = 1.0e300;
+
+double
+trunc(double x)
+{
+	int32_t i0,i1,j0;
+	u_int32_t i;
+	EXTRACT_WORDS(i0,i1,x);
+	j0 = ((i0>>20)&0x7ff)-0x3ff;
+	if(j0<20) {
+	    if(j0<0) { 	/* raise inexact if x != 0 */
+		if(huge+x>0.0) {/* |x|<1, so return 0*sign(x) */
+		    i0 &= 0x80000000U;
+		    i1 = 0;
+		}
+	    } else {
+		i = (0x000fffff)>>j0;
+		if(((i0&i)|i1)==0) return x; /* x is integral */
+		if(huge+x>0.0) {	/* raise inexact flag */
+		    i0 &= (~i); i1=0;
+		}
+	    }
+	} else if (j0>51) {
+	    if(j0==0x400) return x+x;	/* inf or NaN */
+	    else return x;		/* x is integral */
+	} else {
+	    i = ((u_int32_t)(0xffffffff))>>(j0-20);
+	    if((i1&i)==0) return x;	/* x is integral */
+	    if(huge+x>0.0)		/* raise inexact flag */
+		i1 &= (~i);
+	}
+	INSERT_WORDS(x,i0,i1);
+	return x;
+}
+
+#if LDBL_MANT_DIG == 53
+__weak_reference(trunc, truncl);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/s_truncf.c b/libm/upstream-freebsd/lib/msun/src/s_truncf.c
new file mode 100644
index 0000000..384eaee
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_truncf.c
@@ -0,0 +1,53 @@
+/* @(#)s_floor.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * truncf(x)
+ * Return x rounded toward 0 to integral value
+ * Method:
+ *	Bit twiddling.
+ * Exception:
+ *	Inexact flag raised if x not equal to truncf(x).
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+static const float huge = 1.0e30F;
+
+float
+truncf(float x)
+{
+	int32_t i0,j0;
+	u_int32_t i;
+	GET_FLOAT_WORD(i0,x);
+	j0 = ((i0>>23)&0xff)-0x7f;
+	if(j0<23) {
+	    if(j0<0) { 	/* raise inexact if x != 0 */
+		if(huge+x>0.0F)		/* |x|<1, so return 0*sign(x) */
+		    i0 &= 0x80000000;
+	    } else {
+		i = (0x007fffff)>>j0;
+		if((i0&i)==0) return x; /* x is integral */
+		if(huge+x>0.0F)		/* raise inexact flag */
+		    i0 &= (~i);
+	    }
+	} else {
+	    if(j0==0x80) return x+x;	/* inf or NaN */
+	    else return x;		/* x is integral */
+	}
+	SET_FLOAT_WORD(x,i0);
+	return x;
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_truncl.c b/libm/upstream-freebsd/lib/msun/src/s_truncl.c
new file mode 100644
index 0000000..9e2b511
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/s_truncl.c
@@ -0,0 +1,68 @@
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ * From: @(#)s_floor.c 5.1 93/09/24
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * truncl(x)
+ * Return x rounded toward 0 to integral value
+ * Method:
+ *	Bit twiddling.
+ * Exception:
+ *	Inexact flag raised if x not equal to truncl(x).
+ */
+
+#include <float.h>
+#include <math.h>
+#include <stdint.h>
+
+#include "fpmath.h"
+
+#ifdef LDBL_IMPLICIT_NBIT
+#define	MANH_SIZE	(LDBL_MANH_SIZE + 1)
+#else
+#define	MANH_SIZE	LDBL_MANH_SIZE
+#endif
+
+static const long double huge = 1.0e300;
+static const float zero[] = { 0.0, -0.0 };
+
+long double
+truncl(long double x)
+{
+	union IEEEl2bits u = { .e = x };
+	int e = u.bits.exp - LDBL_MAX_EXP + 1;
+
+	if (e < MANH_SIZE - 1) {
+		if (e < 0) {			/* raise inexact if x != 0 */
+			if (huge + x > 0.0)
+				u.e = zero[u.bits.sign];
+		} else {
+			uint64_t m = ((1llu << MANH_SIZE) - 1) >> (e + 1);
+			if (((u.bits.manh & m) | u.bits.manl) == 0)
+				return (x);	/* x is integral */
+			if (huge + x > 0.0) {	/* raise inexact flag */
+				u.bits.manh &= ~m;
+				u.bits.manl = 0;
+			}
+		}
+	} else if (e < LDBL_MANT_DIG - 1) {
+		uint64_t m = (uint64_t)-1 >> (64 - LDBL_MANT_DIG + e + 1);
+		if ((u.bits.manl & m) == 0)
+			return (x);	/* x is integral */
+		if (huge + x > 0.0)		/* raise inexact flag */
+			u.bits.manl &= ~m;
+	}
+	return (u.e);
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/w_cabs.c b/libm/upstream-freebsd/lib/msun/src/w_cabs.c
new file mode 100644
index 0000000..543b858
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/w_cabs.c
@@ -0,0 +1,23 @@
+/*
+ * cabs() wrapper for hypot().
+ *
+ * Written by J.T. Conklin, <jtc@wimsey.com>
+ * Placed into the Public Domain, 1994.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <float.h>
+#include <math.h>
+
+double
+cabs(double complex z)
+{
+	return hypot(creal(z), cimag(z));
+}
+
+#if LDBL_MANT_DIG == 53
+__weak_reference(cabs, cabsl);
+#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/w_cabsf.c b/libm/upstream-freebsd/lib/msun/src/w_cabsf.c
new file mode 100644
index 0000000..e7bfe22
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/w_cabsf.c
@@ -0,0 +1,23 @@
+/*
+ * cabsf() wrapper for hypotf().
+ *
+ * Written by J.T. Conklin, <jtc@wimsey.com>
+ * Placed into the Public Domain, 1994.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+  "$FreeBSD$";
+#endif /* not lint */
+
+#include <complex.h>
+#include <math.h>
+#include "math_private.h"
+
+float
+cabsf(z)
+	float complex z;
+{
+
+	return hypotf(crealf(z), cimagf(z));
+}
diff --git a/libm/upstream-freebsd/lib/msun/src/w_cabsl.c b/libm/upstream-freebsd/lib/msun/src/w_cabsl.c
new file mode 100644
index 0000000..b715e0c
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/w_cabsl.c
@@ -0,0 +1,20 @@
+/*
+ * cabs() wrapper for hypot().
+ *
+ * Written by J.T. Conklin, <jtc@wimsey.com>
+ * Placed into the Public Domain, 1994.
+ *
+ * Modified by Steven G. Kargl for the long double type.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+long double
+cabsl(long double complex z)
+{
+	return hypotl(creall(z), cimagl(z));
+}
diff --git a/libm/src/w_drem.c b/libm/upstream-freebsd/lib/msun/src/w_drem.c
similarity index 100%
rename from libm/src/w_drem.c
rename to libm/upstream-freebsd/lib/msun/src/w_drem.c
diff --git a/libm/upstream-freebsd/lib/msun/src/w_dremf.c b/libm/upstream-freebsd/lib/msun/src/w_dremf.c
new file mode 100644
index 0000000..4bfcff2
--- /dev/null
+++ b/libm/upstream-freebsd/lib/msun/src/w_dremf.c
@@ -0,0 +1,16 @@
+/*
+ * dremf() wrapper for remainderf().
+ *
+ * Written by J.T. Conklin, <jtc@wimsey.com>
+ * Placed into the Public Domain, 1994.
+ */
+/* $FreeBSD$ */
+
+#include "math.h"
+#include "math_private.h"
+
+float
+dremf(float x, float y)
+{
+	return remainderf(x, y);
+}
diff --git a/libthread_db/libthread_db.c b/libthread_db/libthread_db.c
index e749377..bd78ae6 100644
--- a/libthread_db/libthread_db.c
+++ b/libthread_db/libthread_db.c
@@ -161,7 +161,7 @@
 td_thr_get_info(td_thrhandle_t const * handle, td_thrinfo_t * info)
 {
     info->ti_tid = handle->tid;
-    info->ti_lid = handle->tid; // Our pthreads uses kernel ids for tids
+    info->ti_lid = handle->tid;
     info->ti_state = TD_THR_SLEEP; /* XXX this needs to be read from /proc/<pid>/task/<tid>.
                                       This is only used to see if the thread is a zombie or not */
     return TD_OK;
diff --git a/linker/Android.mk b/linker/Android.mk
index e8c81db..5a18f6a 100644
--- a/linker/Android.mk
+++ b/linker/Android.mk
@@ -1,37 +1,31 @@
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES:= \
-	arch/$(TARGET_ARCH)/begin.S \
-	debugger.c \
-	dlfcn.c \
-	linker.cpp \
-	linker_environ.c \
-	linker_format.c \
-	linker_phdr.c \
-	rt.c
+ifeq ($(TARGET_ARCH),x86)
+    linker_begin_extension := c
+else
+    linker_begin_extension := S
+endif
 
-LOCAL_LDFLAGS := -shared
+LOCAL_SRC_FILES:= \
+    arch/$(TARGET_ARCH)/begin.$(linker_begin_extension) \
+    debugger.cpp \
+    dlfcn.cpp \
+    linker.cpp \
+    linker_environ.cpp \
+    linker_phdr.cpp \
+    rt.cpp
+
+LOCAL_LDFLAGS := -shared -Wl,--exclude-libs,ALL
 
 LOCAL_CFLAGS += -fno-stack-protector \
         -Wstrict-overflow=5 \
         -fvisibility=hidden \
-        -std=gnu99 \
-        -Wall -Wextra
+        -Wall -Wextra -Werror
 
-# Set LINKER_DEBUG to either 1 or 0
-#
-LOCAL_CFLAGS += -DLINKER_DEBUG=0
-
-# We need to access Bionic private headers in the linker...
+# We need to access Bionic private headers in the linker.
 LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/
 
-# ...one of which is <private/bionic_tls.h>, for which we
-# need HAVE_ARM_TLS_REGISTER.
-ifeq ($(TARGET_ARCH)-$(ARCH_ARM_HAVE_TLS_REGISTER),arm-true)
-    LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER
-endif
-
 ifeq ($(TARGET_ARCH),arm)
     LOCAL_CFLAGS += -DANDROID_ARM_LINKER
 endif
diff --git a/linker/README.TXT b/linker/README.TXT
deleted file mode 100644
index 1770c87..0000000
--- a/linker/README.TXT
+++ /dev/null
@@ -1,106 +0,0 @@
-Android Dynamic Linker Design Notes
-===================================
-
-Introduction:
--------------
-
-This document provides several notes related to the design of the Android
-dynamic linker.
-
-
-Initialization and Termination functions:
------------------------------------------
-
-The Unix Sys V Binary Interface standard states that an
-executable can have the following entries in its .dynamic
-section:
-
-  DT_INIT
-      Points to the address of an initialization function
-      that must be called when the file is loaded.
-
-  DT_INIT_ARRAY
-      Points to an array of function addresses that must be
-      called, in-order, to perform initialization. Some of
-      the entries in the array can be 0 or -1, and should
-      be ignored.
-
-      Note: this is generally stored in a .init_array section
-
-  DT_INIT_ARRAYSZ
-      The size of the DT_INITARRAY, if any
-
-  DT_FINI
-      Points to the address of a finalization function which
-      must be called when the file is unloaded or the process
-      terminated.
-
-  DT_FINI_ARRAY
-      Same as DT_INITARRAY but for finalizers. Note that the
-      functions must be called in reverse-order though
-
-      Note: this is generally stored in a .fini_array section
-
-  DT_FINI_ARRAYSZ
-      Size of FT_FINIARRAY
-
-  DT_PREINIT_ARRAY
-      An array similar to DT_INIT_ARRAY which must *only* be
-      present in executables, not shared libraries, which contains
-      a list of functions that need to be called before any other
-      initialization function (i.e. DT_INIT and/or DT_INIT_ARRAY)
-      in the executable or any of its libraries.
-
-      Note: this is generally stored in a .preinit_array section
-
-  DT_PREINIT_ARRAYSZ
-      The size of DT_PREINIT_ARRAY
-
-If both a DT_INIT and DT_INITARRAY entry are present, the DT_INIT
-function must be called before the DT_INITARRAY functions.
-
-Consequently, the DT_FINIARRAY must be parsed in reverse order before
-the DT_FINI function, if both are available.
-
-Note that the implementation of static C++ constructors is very
-much processor dependent, and may use different ELF sections.
-
-On the ARM (see "C++ ABI for ARM" document), the static constructors
-must be called explicitly from the DT_INIT_ARRAY, and each one of them
-shall register a destructor by calling the special __eabi_atexit()
-function (provided by the C library). The DT_FINI_ARRAY is not used
-by static C++ destructors.
-
-On x86, the lists of constructors and destructors are placed in special
-sections named ".ctors" and ".dtors", and the DT_INIT / DT_FINI functions
-are in charge of calling them explicitly.
-
-
-Debugging:
-----------
-
-It is possible to enable debug output in the dynamic linker. To do so,
-follow these steps:
-
-1/ Modify the line in Android.mk that says:
-
-    LOCAL_CFLAGS += -DLINKER_DEBUG=0
-
-  Into the following:
-
-    LOCAL_CFLAGS += -DLINKER_DEBUG=1
-
-2/ Force-rebuild the dynamic linker:
-
-    cd bionic/linker
-    mm -B
-
-3/ Rebuild a new system image.
-
-You can increase the verbosity of debug traces by defining the DEBUG
-environment variable to a numeric value from 0 to 2. This will only
-affect new processes being launched.
-
-By default, traces are sent to logcat, with the "linker" tag. You can
-change this to go to stdout instead by setting the definition of
-LINKER_DEBUG_TO_LOG to 0 in "linker_debug.h".
diff --git a/linker/arch/x86/begin.S b/linker/arch/x86/begin.S
deleted file mode 100644
index baa386f..0000000
--- a/linker/arch/x86/begin.S
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-.text
-.align 4
-.type _start, @function
-.globl _start
-
-_start:
-        /* save the elfdata ptr to %eax, AND push it onto the stack */
-        mov    %esp, %eax
-        pushl  %esp
-
-        pushl  %eax
-        call   __linker_init
-
-        /* linker init returns (%eax) the _entry address in the main image */
-        /* entry point expects sp to point to elfdata */
-        popl   %esp
-        jmp    *%eax
-
-#include "arch-x86/bionic/__stack_chk_fail_local.S"
diff --git a/linker/arch/x86/begin.c b/linker/arch/x86/begin.c
new file mode 100755
index 0000000..051a16a
--- /dev/null
+++ b/linker/arch/x86/begin.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdint.h>
+#include <sys/cdefs.h>
+
+extern unsigned __linker_init(void* raw_args);
+
+__LIBC_HIDDEN__ void _start() {
+  void (*start)(void);
+
+  void* raw_args = (void*) ((uintptr_t) __builtin_frame_address(0) + sizeof(void*));
+  start = (void(*)(void))__linker_init(raw_args);
+
+  /* linker init returns (%eax) the _entry address in the main image */
+  /* entry point expects sp to point to raw_args */
+
+  __asm__ (
+     "mov %0, %%esp\n\t"
+     "jmp *%1\n\t"
+     : : "r"(raw_args), "r"(start) :
+  );
+
+  /* Unreachable */
+}
+
+/* Since linker has its own version of crtbegin (this file) it should have */
+/* own version of __stack_chk_fail_local for the case when it's built with */
+/* stack protector feature */
+
+#include "arch-x86/bionic/__stack_chk_fail_local.h"
diff --git a/linker/debugger.c b/linker/debugger.c
deleted file mode 100644
index e4d4ae9..0000000
--- a/linker/debugger.c
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdbool.h>
-#include <signal.h>
-#include <sys/prctl.h>
-#include <errno.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-
-extern int tgkill(int tgid, int tid, int sig);
-
-void notify_gdb_of_libraries();
-
-#define DEBUGGER_SOCKET_NAME "android:debuggerd"
-
-typedef enum {
-    // dump a crash
-    DEBUGGER_ACTION_CRASH,
-    // dump a tombstone file
-    DEBUGGER_ACTION_DUMP_TOMBSTONE,
-    // dump a backtrace only back to the socket
-    DEBUGGER_ACTION_DUMP_BACKTRACE,
-} debugger_action_t;
-
-/* message sent over the socket */
-typedef struct {
-    debugger_action_t action;
-    pid_t tid;
-} debugger_msg_t;
-
-#define  RETRY_ON_EINTR(ret,cond) \
-    do { \
-        ret = (cond); \
-    } while (ret < 0 && errno == EINTR)
-
-// see man(2) prctl, specifically the section about PR_GET_NAME
-#define MAX_TASK_NAME_LEN (16)
-
-static int socket_abstract_client(const char *name, int type)
-{
-    struct sockaddr_un addr;
-    size_t namelen;
-    socklen_t alen;
-    int s, err;
-
-    namelen  = strlen(name);
-
-    // Test with length +1 for the *initial* '\0'.
-    if ((namelen + 1) > sizeof(addr.sun_path)) {
-        errno = EINVAL;
-        return -1;
-    }
-
-    /* This is used for abstract socket namespace, we need
-     * an initial '\0' at the start of the Unix socket path.
-     *
-     * Note: The path in this case is *not* supposed to be
-     * '\0'-terminated. ("man 7 unix" for the gory details.)
-     */
-    memset (&addr, 0, sizeof addr);
-    addr.sun_family = AF_LOCAL;
-    addr.sun_path[0] = 0;
-    memcpy(addr.sun_path + 1, name, namelen);
-
-    alen = namelen + offsetof(struct sockaddr_un, sun_path) + 1;
-
-    s = socket(AF_LOCAL, type, 0);
-    if(s < 0) return -1;
-
-    RETRY_ON_EINTR(err,connect(s, (struct sockaddr *) &addr, alen));
-    if (err < 0) {
-        close(s);
-        s = -1;
-    }
-
-    return s;
-}
-
-#include "linker_format.h"
-#include <../libc/private/logd.h>
-
-/*
- * Writes a summary of the signal to the log file.  We do this so that, if
- * for some reason we're not able to contact debuggerd, there is still some
- * indication of the failure in the log.
- *
- * We could be here as a result of native heap corruption, or while a
- * mutex is being held, so we don't want to use any libc functions that
- * could allocate memory or hold a lock.
- *
- * "info" will be NULL if the siginfo_t information was not available.
- */
-static void logSignalSummary(int signum, const siginfo_t* info)
-{
-    char buffer[128];
-    char threadname[MAX_TASK_NAME_LEN + 1]; // one more for termination
-
-    char* signame;
-    switch (signum) {
-        case SIGILL:    signame = "SIGILL";     break;
-        case SIGABRT:   signame = "SIGABRT";    break;
-        case SIGBUS:    signame = "SIGBUS";     break;
-        case SIGFPE:    signame = "SIGFPE";     break;
-        case SIGSEGV:   signame = "SIGSEGV";    break;
-#if defined(SIGSTKFLT)
-        case SIGSTKFLT: signame = "SIGSTKFLT";  break;
-#endif
-        case SIGPIPE:   signame = "SIGPIPE";    break;
-        default:        signame = "???";        break;
-    }
-
-    if (prctl(PR_GET_NAME, (unsigned long)threadname, 0, 0, 0) != 0) {
-        strcpy(threadname, "<name unknown>");
-    } else {
-        // short names are null terminated by prctl, but the manpage
-        // implies that 16 byte names are not.
-        threadname[MAX_TASK_NAME_LEN] = 0;
-    }
-    if (info != NULL) {
-        format_buffer(buffer, sizeof(buffer),
-            "Fatal signal %d (%s) at 0x%08x (code=%d), thread %d (%s)",
-            signum, signame, info->si_addr, info->si_code, gettid(), threadname);
-    } else {
-        format_buffer(buffer, sizeof(buffer),
-            "Fatal signal %d (%s), thread %d (%s)",
-            signum, signame, gettid(), threadname);
-    }
-
-    __libc_android_log_write(ANDROID_LOG_FATAL, "libc", buffer);
-}
-
-/*
- * Returns true if the handler for signal "signum" has SA_SIGINFO set.
- */
-static bool haveSiginfo(int signum)
-{
-    struct sigaction oldact, newact;
-
-    memset(&newact, 0, sizeof(newact));
-    newact.sa_handler = SIG_DFL;
-    newact.sa_flags = SA_RESTART;
-    sigemptyset(&newact.sa_mask);
-
-    if (sigaction(signum, &newact, &oldact) < 0) {
-        __libc_android_log_write(ANDROID_LOG_FATAL, "libc",
-            "Failed testing for SA_SIGINFO");
-        return 0;
-    }
-    bool ret = (oldact.sa_flags & SA_SIGINFO) != 0;
-
-    if (sigaction(signum, &oldact, NULL) < 0) {
-        __libc_android_log_write(ANDROID_LOG_FATAL, "libc",
-            "Restore failed in test for SA_SIGINFO");
-    }
-    return ret;
-}
-
-/*
- * Catches fatal signals so we can ask debuggerd to ptrace us before
- * we crash.
- */
-void debugger_signal_handler(int n, siginfo_t* info, void* unused __attribute__((unused)))
-{
-    char msgbuf[128];
-    unsigned tid;
-    int s;
-
-    /*
-     * It's possible somebody cleared the SA_SIGINFO flag, which would mean
-     * our "info" arg holds an undefined value.
-     */
-    if (!haveSiginfo(n)) {
-        info = NULL;
-    }
-
-    logSignalSummary(n, info);
-
-    tid = gettid();
-    s = socket_abstract_client(DEBUGGER_SOCKET_NAME, SOCK_STREAM);
-
-    if (s >= 0) {
-        /* debugger knows our pid from the credentials on the
-         * local socket but we need to tell it our tid.  It
-         * is paranoid and will verify that we are giving a tid
-         * that's actually in our process
-         */
-        int  ret;
-        debugger_msg_t msg;
-        msg.action = DEBUGGER_ACTION_CRASH;
-        msg.tid = tid;
-        RETRY_ON_EINTR(ret, write(s, &msg, sizeof(msg)));
-        if (ret == sizeof(msg)) {
-            /* if the write failed, there is no point to read on
-             * the file descriptor. */
-            RETRY_ON_EINTR(ret, read(s, &tid, 1));
-            int savedErrno = errno;
-            notify_gdb_of_libraries();
-            errno = savedErrno;
-        }
-
-        if (ret < 0) {
-            /* read or write failed -- broken connection? */
-            format_buffer(msgbuf, sizeof(msgbuf),
-                "Failed while talking to debuggerd: %s", strerror(errno));
-            __libc_android_log_write(ANDROID_LOG_FATAL, "libc", msgbuf);
-        }
-
-        close(s);
-    } else {
-        /* socket failed; maybe process ran out of fds */
-        format_buffer(msgbuf, sizeof(msgbuf),
-            "Unable to open connection to debuggerd: %s", strerror(errno));
-        __libc_android_log_write(ANDROID_LOG_FATAL, "libc", msgbuf);
-    }
-
-    /* remove our net so we fault for real when we return */
-    signal(n, SIG_DFL);
-
-    /*
-     * These signals are not re-thrown when we resume.  This means that
-     * crashing due to (say) SIGPIPE doesn't work the way you'd expect it
-     * to.  We work around this by throwing them manually.  We don't want
-     * to do this for *all* signals because it'll screw up the address for
-     * faults like SIGSEGV.
-     */
-    switch (n) {
-        case SIGABRT:
-        case SIGFPE:
-        case SIGPIPE:
-#ifdef SIGSTKFLT
-        case SIGSTKFLT:
-#endif
-            (void) tgkill(getpid(), gettid(), n);
-            break;
-        default:    // SIGILL, SIGBUS, SIGSEGV
-            break;
-    }
-}
-
-void debugger_init()
-{
-    struct sigaction act;
-    memset(&act, 0, sizeof(act));
-    act.sa_sigaction = debugger_signal_handler;
-    act.sa_flags = SA_RESTART | SA_SIGINFO;
-    sigemptyset(&act.sa_mask);
-
-    sigaction(SIGILL, &act, NULL);
-    sigaction(SIGABRT, &act, NULL);
-    sigaction(SIGBUS, &act, NULL);
-    sigaction(SIGFPE, &act, NULL);
-    sigaction(SIGSEGV, &act, NULL);
-#if defined(SIGSTKFLT)
-    sigaction(SIGSTKFLT, &act, NULL);
-#endif
-    sigaction(SIGPIPE, &act, NULL);
-}
diff --git a/linker/debugger.cpp b/linker/debugger.cpp
new file mode 100644
index 0000000..586cd2f
--- /dev/null
+++ b/linker/debugger.cpp
@@ -0,0 +1,264 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "linker.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+#include <sys/prctl.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#include <private/debug_format.h>
+#include <private/logd.h>
+
+extern "C" int tgkill(int tgid, int tid, int sig);
+
+#define DEBUGGER_SOCKET_NAME "android:debuggerd"
+
+enum debugger_action_t {
+    // dump a crash
+    DEBUGGER_ACTION_CRASH,
+    // dump a tombstone file
+    DEBUGGER_ACTION_DUMP_TOMBSTONE,
+    // dump a backtrace only back to the socket
+    DEBUGGER_ACTION_DUMP_BACKTRACE,
+};
+
+/* message sent over the socket */
+struct debugger_msg_t {
+    debugger_action_t action;
+    pid_t tid;
+};
+
+// see man(2) prctl, specifically the section about PR_GET_NAME
+#define MAX_TASK_NAME_LEN (16)
+
+static int socket_abstract_client(const char* name, int type) {
+    sockaddr_un addr;
+
+    // Test with length +1 for the *initial* '\0'.
+    size_t namelen = strlen(name);
+    if ((namelen + 1) > sizeof(addr.sun_path)) {
+        errno = EINVAL;
+        return -1;
+    }
+
+    /* This is used for abstract socket namespace, we need
+     * an initial '\0' at the start of the Unix socket path.
+     *
+     * Note: The path in this case is *not* supposed to be
+     * '\0'-terminated. ("man 7 unix" for the gory details.)
+     */
+    memset(&addr, 0, sizeof(addr));
+    addr.sun_family = AF_LOCAL;
+    addr.sun_path[0] = 0;
+    memcpy(addr.sun_path + 1, name, namelen);
+
+    socklen_t alen = namelen + offsetof(sockaddr_un, sun_path) + 1;
+
+    int s = socket(AF_LOCAL, type, 0);
+    if (s == -1) {
+        return -1;
+    }
+
+    int err = TEMP_FAILURE_RETRY(connect(s, (sockaddr*) &addr, alen));
+    if (err == -1) {
+        close(s);
+        s = -1;
+    }
+
+    return s;
+}
+
+/*
+ * Writes a summary of the signal to the log file.  We do this so that, if
+ * for some reason we're not able to contact debuggerd, there is still some
+ * indication of the failure in the log.
+ *
+ * We could be here as a result of native heap corruption, or while a
+ * mutex is being held, so we don't want to use any libc functions that
+ * could allocate memory or hold a lock.
+ */
+static void logSignalSummary(int signum, const siginfo_t* info) {
+    const char* signal_name;
+    switch (signum) {
+        case SIGILL:    signal_name = "SIGILL";     break;
+        case SIGABRT:   signal_name = "SIGABRT";    break;
+        case SIGBUS:    signal_name = "SIGBUS";     break;
+        case SIGFPE:    signal_name = "SIGFPE";     break;
+        case SIGSEGV:   signal_name = "SIGSEGV";    break;
+#if defined(SIGSTKFLT)
+        case SIGSTKFLT: signal_name = "SIGSTKFLT";  break;
+#endif
+        case SIGPIPE:   signal_name = "SIGPIPE";    break;
+        default:        signal_name = "???";        break;
+    }
+
+    char thread_name[MAX_TASK_NAME_LEN + 1]; // one more for termination
+    if (prctl(PR_GET_NAME, (unsigned long)thread_name, 0, 0, 0) != 0) {
+        strcpy(thread_name, "<name unknown>");
+    } else {
+        // short names are null terminated by prctl, but the man page
+        // implies that 16 byte names are not.
+        thread_name[MAX_TASK_NAME_LEN] = 0;
+    }
+
+    // "info" will be NULL if the siginfo_t information was not available.
+    if (info != NULL) {
+        __libc_format_log(ANDROID_LOG_FATAL, "libc",
+                          "Fatal signal %d (%s) at 0x%08x (code=%d), thread %d (%s)",
+                          signum, signal_name, reinterpret_cast<uintptr_t>(info->si_addr),
+                          info->si_code, gettid(), thread_name);
+    } else {
+        __libc_format_log(ANDROID_LOG_FATAL, "libc",
+                          "Fatal signal %d (%s), thread %d (%s)",
+                          signum, signal_name, gettid(), thread_name);
+    }
+}
+
+/*
+ * Returns true if the handler for signal "signum" has SA_SIGINFO set.
+ */
+static bool haveSiginfo(int signum) {
+    struct sigaction oldact, newact;
+
+    memset(&newact, 0, sizeof(newact));
+    newact.sa_handler = SIG_DFL;
+    newact.sa_flags = SA_RESTART;
+    sigemptyset(&newact.sa_mask);
+
+    if (sigaction(signum, &newact, &oldact) < 0) {
+        __libc_android_log_write(ANDROID_LOG_FATAL, "libc",
+            "Failed testing for SA_SIGINFO");
+        return 0;
+    }
+    bool ret = (oldact.sa_flags & SA_SIGINFO) != 0;
+
+    if (sigaction(signum, &oldact, NULL) < 0) {
+        __libc_android_log_write(ANDROID_LOG_FATAL, "libc",
+            "Restore failed in test for SA_SIGINFO");
+    }
+    return ret;
+}
+
+/*
+ * Catches fatal signals so we can ask debuggerd to ptrace us before
+ * we crash.
+ */
+void debuggerd_signal_handler(int n, siginfo_t* info, void*) {
+    /*
+     * It's possible somebody cleared the SA_SIGINFO flag, which would mean
+     * our "info" arg holds an undefined value.
+     */
+    if (!haveSiginfo(n)) {
+        info = NULL;
+    }
+
+    logSignalSummary(n, info);
+
+    pid_t tid = gettid();
+    int s = socket_abstract_client(DEBUGGER_SOCKET_NAME, SOCK_STREAM);
+
+    if (s >= 0) {
+        /* debugger knows our pid from the credentials on the
+         * local socket but we need to tell it our tid.  It
+         * is paranoid and will verify that we are giving a tid
+         * that's actually in our process
+         */
+        int  ret;
+        debugger_msg_t msg;
+        msg.action = DEBUGGER_ACTION_CRASH;
+        msg.tid = tid;
+        ret = TEMP_FAILURE_RETRY(write(s, &msg, sizeof(msg)));
+        if (ret == sizeof(msg)) {
+            /* if the write failed, there is no point to read on
+             * the file descriptor. */
+            ret = TEMP_FAILURE_RETRY(read(s, &tid, 1));
+            int saved_errno = errno;
+            notify_gdb_of_libraries();
+            errno = saved_errno;
+        }
+
+        if (ret < 0) {
+            /* read or write failed -- broken connection? */
+            __libc_format_log(ANDROID_LOG_FATAL, "libc", "Failed while talking to debuggerd: %s",
+                              strerror(errno));
+        }
+
+        close(s);
+    } else {
+        /* socket failed; maybe process ran out of fds */
+        __libc_format_log(ANDROID_LOG_FATAL, "libc", "Unable to open connection to debuggerd: %s",
+                          strerror(errno));
+    }
+
+    /* remove our net so we fault for real when we return */
+    signal(n, SIG_DFL);
+
+    /*
+     * These signals are not re-thrown when we resume.  This means that
+     * crashing due to (say) SIGPIPE doesn't work the way you'd expect it
+     * to.  We work around this by throwing them manually.  We don't want
+     * to do this for *all* signals because it'll screw up the address for
+     * faults like SIGSEGV.
+     */
+    switch (n) {
+        case SIGABRT:
+        case SIGFPE:
+        case SIGPIPE:
+#ifdef SIGSTKFLT
+        case SIGSTKFLT:
+#endif
+            (void) tgkill(getpid(), gettid(), n);
+            break;
+        default:    // SIGILL, SIGBUS, SIGSEGV
+            break;
+    }
+}
+
+void debuggerd_init() {
+    struct sigaction act;
+    memset(&act, 0, sizeof(act));
+    act.sa_sigaction = debuggerd_signal_handler;
+    act.sa_flags = SA_RESTART | SA_SIGINFO;
+    sigemptyset(&act.sa_mask);
+
+    sigaction(SIGILL, &act, NULL);
+    sigaction(SIGABRT, &act, NULL);
+    sigaction(SIGBUS, &act, NULL);
+    sigaction(SIGFPE, &act, NULL);
+    sigaction(SIGSEGV, &act, NULL);
+#if defined(SIGSTKFLT)
+    sigaction(SIGSTKFLT, &act, NULL);
+#endif
+    sigaction(SIGPIPE, &act, NULL);
+}
diff --git a/linker/dlfcn.c b/linker/dlfcn.c
deleted file mode 100644
index 07e00ac..0000000
--- a/linker/dlfcn.c
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <dlfcn.h>
-#include <pthread.h>
-#include <stdio.h>
-#include "linker.h"
-#include "linker_format.h"
-
-/* This file hijacks the symbols stubbed out in libdl.so. */
-
-#define DL_SUCCESS                    0
-#define DL_ERR_CANNOT_LOAD_LIBRARY    1
-#define DL_ERR_INVALID_LIBRARY_HANDLE 2
-#define DL_ERR_BAD_SYMBOL_NAME        3
-#define DL_ERR_SYMBOL_NOT_FOUND       4
-#define DL_ERR_SYMBOL_NOT_GLOBAL      5
-
-static char dl_err_buf[1024];
-static const char *dl_err_str;
-
-static const char *dl_errors[] = {
-    [DL_ERR_CANNOT_LOAD_LIBRARY] = "Cannot load library",
-    [DL_ERR_INVALID_LIBRARY_HANDLE] = "Invalid library handle",
-    [DL_ERR_BAD_SYMBOL_NAME] = "Invalid symbol name",
-    [DL_ERR_SYMBOL_NOT_FOUND] = "Symbol not found",
-    [DL_ERR_SYMBOL_NOT_GLOBAL] = "Symbol is not global",
-};
-
-#define likely(expr)   __builtin_expect (expr, 1)
-#define unlikely(expr) __builtin_expect (expr, 0)
-
-pthread_mutex_t dl_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER;
-
-static void set_dlerror(int err)
-{
-    format_buffer(dl_err_buf, sizeof(dl_err_buf), "%s: %s", dl_errors[err],
-             linker_get_error());
-    dl_err_str = (const char *)&dl_err_buf[0];
-};
-
-void *dlopen(const char *filename, int flag)
-{
-    soinfo *ret;
-
-    pthread_mutex_lock(&dl_lock);
-    ret = find_library(filename);
-    if (unlikely(ret == NULL)) {
-        set_dlerror(DL_ERR_CANNOT_LOAD_LIBRARY);
-    } else {
-        soinfo_call_constructors(ret);
-        ret->refcount++;
-    }
-    pthread_mutex_unlock(&dl_lock);
-    return ret;
-}
-
-const char *dlerror(void)
-{
-    const char *tmp = dl_err_str;
-    dl_err_str = NULL;
-    return (const char *)tmp;
-}
-
-void *dlsym(void *handle, const char *symbol)
-{
-    soinfo *found;
-    Elf32_Sym *sym;
-    unsigned bind;
-
-    pthread_mutex_lock(&dl_lock);
-
-    if(unlikely(handle == 0)) {
-        set_dlerror(DL_ERR_INVALID_LIBRARY_HANDLE);
-        goto err;
-    }
-    if(unlikely(symbol == 0)) {
-        set_dlerror(DL_ERR_BAD_SYMBOL_NAME);
-        goto err;
-    }
-
-    if(handle == RTLD_DEFAULT) {
-        sym = lookup(symbol, &found, NULL);
-    } else if(handle == RTLD_NEXT) {
-        void *ret_addr = __builtin_return_address(0);
-        soinfo *si = find_containing_library(ret_addr);
-
-        sym = NULL;
-        if(si && si->next) {
-            sym = lookup(symbol, &found, si->next);
-        }
-    } else {
-        found = (soinfo*)handle;
-        sym = soinfo_lookup(found, symbol);
-    }
-
-    if(likely(sym != 0)) {
-        bind = ELF32_ST_BIND(sym->st_info);
-
-        if(likely((bind == STB_GLOBAL) && (sym->st_shndx != 0))) {
-            unsigned ret = sym->st_value + found->base;
-            pthread_mutex_unlock(&dl_lock);
-            return (void*)ret;
-        }
-
-        set_dlerror(DL_ERR_SYMBOL_NOT_GLOBAL);
-    }
-    else
-        set_dlerror(DL_ERR_SYMBOL_NOT_FOUND);
-
-err:
-    pthread_mutex_unlock(&dl_lock);
-    return 0;
-}
-
-int dladdr(const void *addr, Dl_info *info)
-{
-    int ret = 0;
-
-    pthread_mutex_lock(&dl_lock);
-
-    /* Determine if this address can be found in any library currently mapped */
-    soinfo *si = find_containing_library(addr);
-
-    if(si) {
-        memset(info, 0, sizeof(Dl_info));
-
-        info->dli_fname = si->name;
-        info->dli_fbase = (void*)si->base;
-
-        /* Determine if any symbol in the library contains the specified address */
-        Elf32_Sym *sym = soinfo_find_symbol(si, addr);
-
-        if(sym != NULL) {
-            info->dli_sname = si->strtab + sym->st_name;
-            info->dli_saddr = (void*)(si->base + sym->st_value);
-        }
-
-        ret = 1;
-    }
-
-    pthread_mutex_unlock(&dl_lock);
-
-    return ret;
-}
-
-int dlclose(void* handle) {
-    pthread_mutex_lock(&dl_lock);
-    int result = soinfo_unload((soinfo*)handle);
-    pthread_mutex_unlock(&dl_lock);
-    return result;
-}
-
-#if defined(ANDROID_ARM_LINKER)
-//                     0000000 00011111 111112 22222222 2333333 333344444444445555555
-//                     0123456 78901234 567890 12345678 9012345 678901234567890123456
-#define ANDROID_LIBDL_STRTAB \
-                      "dlopen\0dlclose\0dlsym\0dlerror\0dladdr\0dl_unwind_find_exidx\0"
-
-#elif defined(ANDROID_X86_LINKER) || defined(ANDROID_MIPS_LINKER)
-//                     0000000 00011111 111112 22222222 2333333 3333444444444455
-//                     0123456 78901234 567890 12345678 9012345 6789012345678901
-#define ANDROID_LIBDL_STRTAB \
-                      "dlopen\0dlclose\0dlsym\0dlerror\0dladdr\0dl_iterate_phdr\0"
-#else
-#error Unsupported architecture. Only ARM, MIPS, and x86 are presently supported.
-#endif
-
-
-static Elf32_Sym libdl_symtab[] = {
-      // total length of libdl_info.strtab, including trailing 0
-      // This is actually the the STH_UNDEF entry. Technically, it's
-      // supposed to have st_name == 0, but instead, it points to an index
-      // in the strtab with a \0 to make iterating through the symtab easier.
-    { st_name: sizeof(ANDROID_LIBDL_STRTAB) - 1,
-    },
-    { st_name: 0,   // starting index of the name in libdl_info.strtab
-      st_value: (Elf32_Addr) &dlopen,
-      st_info: STB_GLOBAL << 4,
-      st_shndx: 1,
-    },
-    { st_name: 7,
-      st_value: (Elf32_Addr) &dlclose,
-      st_info: STB_GLOBAL << 4,
-      st_shndx: 1,
-    },
-    { st_name: 15,
-      st_value: (Elf32_Addr) &dlsym,
-      st_info: STB_GLOBAL << 4,
-      st_shndx: 1,
-    },
-    { st_name: 21,
-      st_value: (Elf32_Addr) &dlerror,
-      st_info: STB_GLOBAL << 4,
-      st_shndx: 1,
-    },
-    { st_name: 29,
-      st_value: (Elf32_Addr) &dladdr,
-      st_info: STB_GLOBAL << 4,
-      st_shndx: 1,
-    },
-#ifdef ANDROID_ARM_LINKER
-    { st_name: 36,
-      st_value: (Elf32_Addr) &dl_unwind_find_exidx,
-      st_info: STB_GLOBAL << 4,
-      st_shndx: 1,
-    },
-#elif defined(ANDROID_X86_LINKER) || defined(ANDROID_MIPS_LINKER)
-    { st_name: 36,
-      st_value: (Elf32_Addr) &dl_iterate_phdr,
-      st_info: STB_GLOBAL << 4,
-      st_shndx: 1,
-    },
-#endif
-};
-
-/* Fake out a hash table with a single bucket.
- * A search of the hash table will look through
- * libdl_symtab starting with index [1], then
- * use libdl_chains to find the next index to
- * look at.  libdl_chains should be set up to
- * walk through every element in libdl_symtab,
- * and then end with 0 (sentinel value).
- *
- * I.e., libdl_chains should look like
- * { 0, 2, 3, ... N, 0 } where N is the number
- * of actual symbols, or nelems(libdl_symtab)-1
- * (since the first element of libdl_symtab is not
- * a real symbol).
- *
- * (see _elf_lookup())
- *
- * Note that adding any new symbols here requires
- * stubbing them out in libdl.
- */
-static unsigned libdl_buckets[1] = { 1 };
-static unsigned libdl_chains[7] = { 0, 2, 3, 4, 5, 6, 0 };
-
-soinfo libdl_info = {
-    name: "libdl.so",
-    flags: FLAG_LINKED,
-
-    strtab: ANDROID_LIBDL_STRTAB,
-    symtab: libdl_symtab,
-
-    nbucket: 1,
-    nchain: 7,
-    bucket: libdl_buckets,
-    chain: libdl_chains,
-};
diff --git a/linker/dlfcn.cpp b/linker/dlfcn.cpp
new file mode 100644
index 0000000..0b38ec4
--- /dev/null
+++ b/linker/dlfcn.cpp
@@ -0,0 +1,247 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "linker.h"
+
+#include <dlfcn.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <bionic/pthread_internal.h>
+#include <private/bionic_tls.h>
+#include <private/ScopedPthreadMutexLocker.h>
+#include <private/ThreadLocalBuffer.h>
+
+/* This file hijacks the symbols stubbed out in libdl.so. */
+
+static pthread_mutex_t gDlMutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER;
+
+static const char* __bionic_set_dlerror(char* new_value) {
+  void* tls = const_cast<void*>(__get_tls());
+  char** dlerror_slot = &reinterpret_cast<char**>(tls)[TLS_SLOT_DLERROR];
+
+  const char* old_value = *dlerror_slot;
+  *dlerror_slot = new_value;
+  return old_value;
+}
+
+static void __bionic_format_dlerror(const char* msg, const char* detail) {
+  char* buffer = __get_thread()->dlerror_buffer;
+  strlcpy(buffer, msg, __BIONIC_DLERROR_BUFFER_SIZE);
+  if (detail != NULL) {
+    strlcat(buffer, ": ", __BIONIC_DLERROR_BUFFER_SIZE);
+    strlcat(buffer, detail, __BIONIC_DLERROR_BUFFER_SIZE);
+  }
+
+  __bionic_set_dlerror(buffer);
+}
+
+const char* dlerror() {
+  const char* old_value = __bionic_set_dlerror(NULL);
+  return old_value;
+}
+
+void android_update_LD_LIBRARY_PATH(const char* ld_library_path) {
+  ScopedPthreadMutexLocker locker(&gDlMutex);
+  do_android_update_LD_LIBRARY_PATH(ld_library_path);
+}
+
+void* dlopen(const char* filename, int flags) {
+  ScopedPthreadMutexLocker locker(&gDlMutex);
+  soinfo* result = do_dlopen(filename, flags);
+  if (result == NULL) {
+    __bionic_format_dlerror("dlopen failed", linker_get_error_buffer());
+    return NULL;
+  }
+  return result;
+}
+
+void* dlsym(void* handle, const char* symbol) {
+  ScopedPthreadMutexLocker locker(&gDlMutex);
+
+  if (handle == NULL) {
+    __bionic_format_dlerror("dlsym library handle is null", NULL);
+    return NULL;
+  }
+  if (symbol == NULL) {
+    __bionic_format_dlerror("dlsym symbol name is null", NULL);
+    return NULL;
+  }
+
+  soinfo* found = NULL;
+  Elf32_Sym* sym = NULL;
+  if (handle == RTLD_DEFAULT) {
+    sym = dlsym_linear_lookup(symbol, &found, NULL);
+  } else if (handle == RTLD_NEXT) {
+    void* ret_addr = __builtin_return_address(0);
+    soinfo* si = find_containing_library(ret_addr);
+
+    sym = NULL;
+    if (si && si->next) {
+      sym = dlsym_linear_lookup(symbol, &found, si->next);
+    }
+  } else {
+    found = reinterpret_cast<soinfo*>(handle);
+    sym = dlsym_handle_lookup(found, symbol);
+  }
+
+  if (sym != NULL) {
+    unsigned bind = ELF32_ST_BIND(sym->st_info);
+
+    if (bind == STB_GLOBAL && sym->st_shndx != 0) {
+      unsigned ret = sym->st_value + found->load_bias;
+      return (void*) ret;
+    }
+
+    __bionic_format_dlerror("symbol found but not global", symbol);
+    return NULL;
+  } else {
+    __bionic_format_dlerror("undefined symbol", symbol);
+    return NULL;
+  }
+}
+
+int dladdr(const void* addr, Dl_info* info) {
+  ScopedPthreadMutexLocker locker(&gDlMutex);
+
+  // Determine if this address can be found in any library currently mapped.
+  soinfo* si = find_containing_library(addr);
+  if (si == NULL) {
+    return 0;
+  }
+
+  memset(info, 0, sizeof(Dl_info));
+
+  info->dli_fname = si->name;
+  // Address at which the shared object is loaded.
+  info->dli_fbase = (void*) si->base;
+
+  // Determine if any symbol in the library contains the specified address.
+  Elf32_Sym *sym = dladdr_find_symbol(si, addr);
+  if (sym != NULL) {
+    info->dli_sname = si->strtab + sym->st_name;
+    info->dli_saddr = (void*)(si->load_bias + sym->st_value);
+  }
+
+  return 1;
+}
+
+int dlclose(void* handle) {
+  ScopedPthreadMutexLocker locker(&gDlMutex);
+  return do_dlclose(reinterpret_cast<soinfo*>(handle));
+}
+
+#if defined(ANDROID_ARM_LINKER)
+//   0000000 00011111 111112 22222222 2333333 3333444444444455555555556666666 6667
+//   0123456 78901234 567890 12345678 9012345 6789012345678901234567890123456 7890
+#define ANDROID_LIBDL_STRTAB \
+    "dlopen\0dlclose\0dlsym\0dlerror\0dladdr\0android_update_LD_LIBRARY_PATH\0dl_unwind_find_exidx\0"
+
+#elif defined(ANDROID_X86_LINKER) || defined(ANDROID_MIPS_LINKER)
+//   0000000 00011111 111112 22222222 2333333 3333444444444455555555556666666 6667
+//   0123456 78901234 567890 12345678 9012345 6789012345678901234567890123456 7890
+#define ANDROID_LIBDL_STRTAB \
+    "dlopen\0dlclose\0dlsym\0dlerror\0dladdr\0android_update_LD_LIBRARY_PATH\0dl_iterate_phdr\0"
+#else
+#error Unsupported architecture. Only ARM, MIPS, and x86 are presently supported.
+#endif
+
+// name_offset: starting index of the name in libdl_info.strtab
+#define ELF32_SYM_INITIALIZER(name_offset, value, shndx) \
+    { name_offset, \
+      reinterpret_cast<Elf32_Addr>(reinterpret_cast<void*>(value)), \
+      /* st_size */ 0, \
+      (shndx == 0) ? 0 : (STB_GLOBAL << 4), \
+      /* st_other */ 0, \
+      shndx }
+
+static Elf32_Sym gLibDlSymtab[] = {
+  // Total length of libdl_info.strtab, including trailing 0.
+  // This is actually the STH_UNDEF entry. Technically, it's
+  // supposed to have st_name == 0, but instead, it points to an index
+  // in the strtab with a \0 to make iterating through the symtab easier.
+  ELF32_SYM_INITIALIZER(sizeof(ANDROID_LIBDL_STRTAB) - 1, NULL, 0),
+  ELF32_SYM_INITIALIZER( 0, &dlopen, 1),
+  ELF32_SYM_INITIALIZER( 7, &dlclose, 1),
+  ELF32_SYM_INITIALIZER(15, &dlsym, 1),
+  ELF32_SYM_INITIALIZER(21, &dlerror, 1),
+  ELF32_SYM_INITIALIZER(29, &dladdr, 1),
+  ELF32_SYM_INITIALIZER(36, &android_update_LD_LIBRARY_PATH, 1),
+#if defined(ANDROID_ARM_LINKER)
+  ELF32_SYM_INITIALIZER(67, &dl_unwind_find_exidx, 1),
+#elif defined(ANDROID_X86_LINKER) || defined(ANDROID_MIPS_LINKER)
+  ELF32_SYM_INITIALIZER(67, &dl_iterate_phdr, 1),
+#endif
+};
+
+// Fake out a hash table with a single bucket.
+// A search of the hash table will look through
+// gLibDlSymtab starting with index [1], then
+// use gLibDlChains to find the next index to
+// look at.  gLibDlChains should be set up to
+// walk through every element in gLibDlSymtab,
+// and then end with 0 (sentinel value).
+//
+// That is, gLibDlChains should look like
+// { 0, 2, 3, ... N, 0 } where N is the number
+// of actual symbols, or nelems(gLibDlSymtab)-1
+// (since the first element of gLibDlSymtab is not
+// a real symbol).
+//
+// (see soinfo_elf_lookup())
+//
+// Note that adding any new symbols here requires
+// stubbing them out in libdl.
+static unsigned gLibDlBuckets[1] = { 1 };
+static unsigned gLibDlChains[8] = { 0, 2, 3, 4, 5, 6, 7, 0 };
+
+// This is used by the dynamic linker. Every process gets these symbols for free.
+soinfo libdl_info = {
+    "libdl.so",
+
+    phdr: 0, phnum: 0,
+    entry: 0, base: 0, size: 0,
+    unused: 0, dynamic: 0, unused2: 0, unused3: 0,
+    next: 0,
+
+    flags: FLAG_LINKED,
+
+    strtab: ANDROID_LIBDL_STRTAB,
+    symtab: gLibDlSymtab,
+
+    nbucket: 1,
+    nchain: 8,
+    bucket: gLibDlBuckets,
+    chain: gLibDlChains,
+
+    plt_got: 0, plt_rel: 0, plt_rel_count: 0, rel: 0, rel_count: 0,
+    preinit_array: 0, preinit_array_count: 0, init_array: 0, init_array_count: 0,
+    fini_array: 0, fini_array_count: 0, init_func: 0, fini_func: 0,
+
+#if defined(ANDROID_ARM_LINKER)
+    ARM_exidx: 0, ARM_exidx_count: 0,
+#elif defined(ANDROID_MIPS_LINKER)
+    mips_symtabno: 0, mips_local_gotno: 0, mips_gotsym: 0,
+#endif
+
+    refcount: 0,
+    { l_addr: 0, l_name: 0, l_ld: 0, l_next: 0, l_prev: 0, },
+    constructors_called: false,
+    load_bias: 0,
+    has_text_relocations: false,
+    has_DT_SYMBOLIC: true,
+};
diff --git a/linker/linker.cpp b/linker/linker.cpp
old mode 100644
new mode 100755
index 46d1335..cbdca8e
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -31,7 +31,6 @@
 #include <fcntl.h>
 #include <linux/auxvec.h>
 #include <pthread.h>
-#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -42,17 +41,15 @@
 
 // Private C library headers.
 #include <private/bionic_tls.h>
+#include <private/KernelArgumentBlock.h>
 #include <private/logd.h>
+#include <private/ScopedPthreadMutexLocker.h>
 
 #include "linker.h"
 #include "linker_debug.h"
 #include "linker_environ.h"
-#include "linker_format.h"
 #include "linker_phdr.h"
 
-#define ALLOW_SYMBOLS_FROM_MAIN 1
-#define SO_MAX 128
-
 /* Assume average path length of 64 and max 8 paths */
 #define LDPATH_BUFSIZE 512
 #define LDPATH_MAX 8
@@ -74,41 +71,40 @@
  * - cleaner error reporting
  * - after linking, set as much stuff as possible to READONLY
  *   and NOEXEC
- * - linker hardcodes PAGE_SIZE and PAGE_MASK because the kernel
- *   headers provide versions that are negative...
- * - allocate space for soinfo structs dynamically instead of
- *   having a hard limit (SO_MAX)
  */
 
+static bool soinfo_link_image(soinfo* si);
 
-static int soinfo_link_image(soinfo *si);
+// We can't use malloc(3) in the dynamic linker. We use a linked list of anonymous
+// maps, each a single page in size. The pages are broken up into as many struct soinfo
+// objects as will fit, and they're all threaded together on a free list.
+#define SOINFO_PER_POOL ((PAGE_SIZE - sizeof(soinfo_pool_t*)) / sizeof(soinfo))
+struct soinfo_pool_t {
+  soinfo_pool_t* next;
+  soinfo info[SOINFO_PER_POOL];
+};
+static struct soinfo_pool_t* gSoInfoPools = NULL;
+static soinfo* gSoInfoFreeList = NULL;
 
-static int socount = 0;
-static soinfo sopool[SO_MAX];
-static soinfo *freelist = NULL;
-static soinfo *solist = &libdl_info;
-static soinfo *sonext = &libdl_info;
-#if ALLOW_SYMBOLS_FROM_MAIN
-static soinfo *somain; /* main process, always the one after libdl_info */
-#endif
+static soinfo* solist = &libdl_info;
+static soinfo* sonext = &libdl_info;
+static soinfo* somain; /* main process, always the one after libdl_info */
 
+static const char* const gSoPaths[] = {
+  "/vendor/lib",
+  "/system/lib",
+  NULL
+};
 
-static char ldpaths_buf[LDPATH_BUFSIZE];
-static const char *ldpaths[LDPATH_MAX + 1];
+static char gLdPathsBuffer[LDPATH_BUFSIZE];
+static const char* gLdPaths[LDPATH_MAX + 1];
 
-static char ldpreloads_buf[LDPRELOAD_BUFSIZE];
-static const char *ldpreload_names[LDPRELOAD_MAX + 1];
+static char gLdPreloadsBuffer[LDPRELOAD_BUFSIZE];
+static const char* gLdPreloadNames[LDPRELOAD_MAX + 1];
 
-static soinfo *preloads[LDPRELOAD_MAX + 1];
+static soinfo* gLdPreloads[LDPRELOAD_MAX + 1];
 
-#if LINKER_DEBUG
-int debug_verbosity;
-#endif
-
-static int pid;
-
-/* This boolean is set if the program being loaded is setuid */
-static bool program_is_setuid;
+__LIBC_HIDDEN__ int gLdDebugVerbosity;
 
 enum RelocationKind {
     kRelocAbsolute = 0,
@@ -150,7 +146,7 @@
     {                                                                           \
         const char* msg = "ERROR: " #name " called from the dynamic linker!\n"; \
          __libc_android_log_write(ANDROID_LOG_FATAL, "linker", msg);            \
-        write(2, msg, sizeof(msg));                                             \
+        write(2, msg, strlen(msg));                                             \
         abort();                                                                \
     }
 #define UNUSED __attribute__((unused))
@@ -161,31 +157,26 @@
 
 static char tmp_err_buf[768];
 static char __linker_dl_err_buf[768];
-#define BASENAME(s) (strrchr(s, '/') != NULL ? strrchr(s, '/') + 1 : s)
-#define DL_ERR(fmt, x...) \
-    do { \
-        format_buffer(__linker_dl_err_buf, sizeof(__linker_dl_err_buf), \
-                      "%s(%s:%d): " fmt, \
-                      __FUNCTION__, BASENAME(__FILE__), __LINE__, ##x); \
-        ERROR(fmt "\n", ##x); \
-    } while(0)
 
-const char *linker_get_error(void)
-{
-    return (const char *)&__linker_dl_err_buf[0];
+char* linker_get_error_buffer() {
+  return &__linker_dl_err_buf[0];
+}
+
+size_t linker_get_error_buffer_size() {
+  return sizeof(__linker_dl_err_buf);
 }
 
 /*
  * This function is an empty stub where GDB locates a breakpoint to get notified
  * about linker activity.
  */
-extern "C" void __attribute__((noinline)) __attribute__((visibility("default"))) rtld_db_dlactivity(void);
+extern "C" void __attribute__((noinline)) __attribute__((visibility("default"))) rtld_db_dlactivity();
 
 static r_debug _r_debug = {1, NULL, &rtld_db_dlactivity,
                                   RT_CONSISTENT, 0};
 static link_map* r_debug_tail = 0;
 
-static pthread_mutex_t _r_debug_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t gDebugMutex = PTHREAD_MUTEX_INITIALIZER;
 
 static void insert_soinfo_into_debug_map(soinfo * info) {
     // Copy the necessary fields into the debug structure.
@@ -232,7 +223,7 @@
         return;
     }
 
-    pthread_mutex_lock(&_r_debug_lock);
+    ScopedPthreadMutexLocker locker(&gDebugMutex);
 
     _r_debug.r_state = RT_ADD;
     rtld_db_dlactivity();
@@ -241,8 +232,6 @@
 
     _r_debug.r_state = RT_CONSISTENT;
     rtld_db_dlactivity();
-
-    pthread_mutex_unlock(&_r_debug_lock);
 }
 
 static void notify_gdb_of_unload(soinfo* info) {
@@ -251,7 +240,7 @@
         return;
     }
 
-    pthread_mutex_lock(&_r_debug_lock);
+    ScopedPthreadMutexLocker locker(&gDebugMutex);
 
     _r_debug.r_state = RT_DELETE;
     rtld_db_dlactivity();
@@ -260,50 +249,74 @@
 
     _r_debug.r_state = RT_CONSISTENT;
     rtld_db_dlactivity();
-
-    pthread_mutex_unlock(&_r_debug_lock);
 }
 
-extern "C" void notify_gdb_of_libraries()
-{
+void notify_gdb_of_libraries() {
     _r_debug.r_state = RT_ADD;
     rtld_db_dlactivity();
     _r_debug.r_state = RT_CONSISTENT;
     rtld_db_dlactivity();
 }
 
-static soinfo *soinfo_alloc(const char *name)
-{
-    if (strlen(name) >= SOINFO_NAME_LEN) {
-        DL_ERR("library name \"%s\" too long", name);
-        return NULL;
+static bool ensure_free_list_non_empty() {
+  if (gSoInfoFreeList != NULL) {
+    return true;
+  }
+
+  // Allocate a new pool.
+  soinfo_pool_t* pool = reinterpret_cast<soinfo_pool_t*>(mmap(NULL, sizeof(*pool),
+                                                              PROT_READ|PROT_WRITE,
+                                                              MAP_PRIVATE|MAP_ANONYMOUS, 0, 0));
+  if (pool == MAP_FAILED) {
+    return false;
+  }
+
+  // Add the pool to our list of pools.
+  pool->next = gSoInfoPools;
+  gSoInfoPools = pool;
+
+  // Chain the entries in the new pool onto the free list.
+  gSoInfoFreeList = &pool->info[0];
+  soinfo* next = NULL;
+  for (int i = SOINFO_PER_POOL - 1; i >= 0; --i) {
+    pool->info[i].next = next;
+    next = &pool->info[i];
+  }
+
+  return true;
+}
+
+static void set_soinfo_pool_protection(int protection) {
+  for (soinfo_pool_t* p = gSoInfoPools; p != NULL; p = p->next) {
+    if (mprotect(p, sizeof(*p), protection) == -1) {
+      abort(); // Can't happen.
     }
+  }
+}
 
-    /* The freelist is populated when we call soinfo_free(), which in turn is
-       done only by dlclose(), which is not likely to be used.
-    */
-    if (!freelist) {
-        if (socount == SO_MAX) {
-            DL_ERR("too many libraries when loading \"%s\"", name);
-            return NULL;
-        }
-        freelist = sopool + socount++;
-        freelist->next = NULL;
-    }
+static soinfo* soinfo_alloc(const char* name) {
+  if (strlen(name) >= SOINFO_NAME_LEN) {
+    DL_ERR("library name \"%s\" too long", name);
+    return NULL;
+  }
 
-    soinfo* si = freelist;
-    freelist = freelist->next;
+  if (!ensure_free_list_non_empty()) {
+    DL_ERR("out of memory when loading \"%s\"", name);
+    return NULL;
+  }
 
-    /* Make sure we get a clean block of soinfo */
-    memset(si, 0, sizeof(soinfo));
-    strlcpy((char*) si->name, name, sizeof(si->name));
-    sonext->next = si;
-    si->next = NULL;
-    si->refcount = 0;
-    sonext = si;
+  // Take the head element off the free list.
+  soinfo* si = gSoInfoFreeList;
+  gSoInfoFreeList = gSoInfoFreeList->next;
 
-    TRACE("%5d name %s: allocated soinfo @ %p\n", pid, name, si);
-    return si;
+  // Initialize the new element.
+  memset(si, 0, sizeof(soinfo));
+  strlcpy(si->name, name, sizeof(si->name));
+  sonext->next = si;
+  sonext = si;
+
+  TRACE("name %s: allocated soinfo @ %p\n", name, si);
+  return si;
 }
 
 static void soinfo_free(soinfo* si)
@@ -314,15 +327,15 @@
 
     soinfo *prev = NULL, *trav;
 
-    TRACE("%5d name %s: freeing soinfo @ %p\n", pid, si->name, si);
+    TRACE("name %s: freeing soinfo @ %p\n", si->name, si);
 
-    for(trav = solist; trav != NULL; trav = trav->next){
+    for (trav = solist; trav != NULL; trav = trav->next) {
         if (trav == si)
             break;
         prev = trav;
     }
     if (trav == NULL) {
-        /* si was not ni solist */
+        /* si was not in solist */
         DL_ERR("name \"%s\" is not in solist!", si->name);
         return;
     }
@@ -331,9 +344,48 @@
        always the static libdl_info.
     */
     prev->next = si->next;
-    if (si == sonext) sonext = prev;
-    si->next = freelist;
-    freelist = si;
+    if (si == sonext) {
+        sonext = prev;
+    }
+    si->next = gSoInfoFreeList;
+    gSoInfoFreeList = si;
+}
+
+
+static void parse_path(const char* path, const char* delimiters,
+                       const char** array, char* buf, size_t buf_size, size_t max_count) {
+  if (path == NULL) {
+    return;
+  }
+
+  size_t len = strlcpy(buf, path, buf_size);
+
+  size_t i = 0;
+  char* buf_p = buf;
+  while (i < max_count && (array[i] = strsep(&buf_p, delimiters))) {
+    if (*array[i] != '\0') {
+      ++i;
+    }
+  }
+
+  // Forget the last path if we had to truncate; this occurs if the 2nd to
+  // last char isn't '\0' (i.e. wasn't originally a delimiter).
+  if (i > 0 && len >= buf_size && buf[buf_size - 2] != '\0') {
+    array[i - 1] = NULL;
+  } else {
+    array[i] = NULL;
+  }
+}
+
+static void parse_LD_LIBRARY_PATH(const char* path) {
+  parse_path(path, ":", gLdPaths,
+             gLdPathsBuffer, sizeof(gLdPathsBuffer), LDPATH_MAX);
+}
+
+static void parse_LD_PRELOAD(const char* path) {
+  // We have historically supported ':' as well as ' ' in LD_PRELOAD.
+  parse_path(path, " :", gLdPreloadNames,
+             gLdPreloadsBuffer, sizeof(gLdPreloadsBuffer), LDPRELOAD_MAX);
 }
 
 #ifdef ANDROID_ARM_LINKER
@@ -345,7 +397,7 @@
  *
  * Intended to be called by libc's __gnu_Unwind_Find_exidx().
  *
- * This function is exposed via dlfcn.c and libdl.so.
+ * This function is exposed via dlfcn.cpp and libdl.so.
  */
 _Unwind_Ptr dl_unwind_find_exidx(_Unwind_Ptr pc, int *pcount)
 {
@@ -387,29 +439,29 @@
 
 #endif
 
-static Elf32_Sym *soinfo_elf_lookup(soinfo *si, unsigned hash, const char *name)
-{
-    Elf32_Sym *s;
-    Elf32_Sym *symtab = si->symtab;
-    const char *strtab = si->strtab;
+static Elf32_Sym* soinfo_elf_lookup(soinfo* si, unsigned hash, const char* name) {
+    Elf32_Sym* s;
+    Elf32_Sym* symtab = si->symtab;
+    const char* strtab = si->strtab;
     unsigned n;
 
-    TRACE_TYPE(LOOKUP, "%5d SEARCH %s in %s@0x%08x %08x %d\n", pid,
+    TRACE_TYPE(LOOKUP, "SEARCH %s in %s@0x%08x %08x %d\n",
                name, si->name, si->base, hash, hash % si->nbucket);
     n = hash % si->nbucket;
 
-    for(n = si->bucket[hash % si->nbucket]; n != 0; n = si->chain[n]){
+    for (n = si->bucket[hash % si->nbucket]; n != 0; n = si->chain[n]) {
         s = symtab + n;
-        if(strcmp(strtab + s->st_name, name)) continue;
+        if (strcmp(strtab + s->st_name, name)) continue;
 
             /* only concern ourselves with global and weak symbol definitions */
         switch(ELF32_ST_BIND(s->st_info)){
         case STB_GLOBAL:
         case STB_WEAK:
-            if(s->st_shndx == SHN_UNDEF)
+            if (s->st_shndx == SHN_UNDEF) {
                 continue;
+            }
 
-            TRACE_TYPE(LOOKUP, "%5d FOUND %s in %s (%08x) %d\n", pid,
+            TRACE_TYPE(LOOKUP, "FOUND %s in %s (%08x) %d\n",
                        name, si->name, s->st_value, s->st_size);
             return s;
         }
@@ -418,9 +470,8 @@
     return NULL;
 }
 
-static unsigned elfhash(const char *_name)
-{
-    const unsigned char *name = (const unsigned char *) _name;
+static unsigned elfhash(const char* _name) {
+    const unsigned char* name = (const unsigned char*) _name;
     unsigned h = 0, g;
 
     while(*name) {
@@ -432,139 +483,168 @@
     return h;
 }
 
-static Elf32_Sym *
-soinfo_do_lookup(soinfo *si, const char *name, Elf32_Addr *offset,
-                 soinfo *needed[], bool ignore_local)
-{
+static Elf32_Sym* soinfo_do_lookup(soinfo* si, const char* name, soinfo** lsi, soinfo* needed[]) {
     unsigned elf_hash = elfhash(name);
-    Elf32_Sym *s = NULL;
-    soinfo *lsi = si;
-    int i;
+    Elf32_Sym* s = NULL;
 
-    if (!ignore_local) {
-        /* Look for symbols in the local scope (the object who is
-         * searching). This happens with C++ templates on i386 for some
-         * reason.
-         *
-         * Notes on weak symbols:
-         * The ELF specs are ambiguous about treatment of weak definitions in
-         * dynamic linking.  Some systems return the first definition found
-         * and some the first non-weak definition.   This is system dependent.
-         * Here we return the first definition found for simplicity.  */
+    if (si != NULL && somain != NULL) {
 
-        s = soinfo_elf_lookup(si, elf_hash, name);
-        if(s != NULL)
-            goto done;
+        /*
+         * Local scope is executable scope. Just start looking into it right away
+         * for the shortcut.
+         */
+
+        if (si == somain) {
+            s = soinfo_elf_lookup(si, elf_hash, name);
+            if (s != NULL) {
+                *lsi = si;
+                goto done;
+            }
+        } else {
+            /* Order of symbol lookup is controlled by DT_SYMBOLIC flag */
+
+            /*
+             * If this object was built with symbolic relocations disabled, the
+             * first place to look to resolve external references is the main
+             * executable.
+             */
+
+            if (!si->has_DT_SYMBOLIC) {
+                DEBUG("%s: looking up %s in executable %s\n",
+                      si->name, name, somain->name);
+                s = soinfo_elf_lookup(somain, elf_hash, name);
+                if (s != NULL) {
+                    *lsi = somain;
+                    goto done;
+                }
+            }
+
+            /* Look for symbols in the local scope (the object who is
+             * searching). This happens with C++ templates on i386 for some
+             * reason.
+             *
+             * Notes on weak symbols:
+             * The ELF specs are ambiguous about treatment of weak definitions in
+             * dynamic linking.  Some systems return the first definition found
+             * and some the first non-weak definition.   This is system dependent.
+             * Here we return the first definition found for simplicity.  */
+
+            s = soinfo_elf_lookup(si, elf_hash, name);
+            if (s != NULL) {
+                *lsi = si;
+                goto done;
+            }
+
+            /*
+             * If this object was built with -Bsymbolic and symbol is not found
+             * in the local scope, try to find the symbol in the main executable.
+             */
+
+            if (si->has_DT_SYMBOLIC) {
+                DEBUG("%s: looking up %s in executable %s after local scope\n",
+                      si->name, name, somain->name);
+                s = soinfo_elf_lookup(somain, elf_hash, name);
+                if (s != NULL) {
+                    *lsi = somain;
+                    goto done;
+                }
+            }
+        }
     }
 
     /* Next, look for it in the preloads list */
-    for(i = 0; preloads[i] != NULL; i++) {
-        lsi = preloads[i];
-        s = soinfo_elf_lookup(lsi, elf_hash, name);
-        if(s != NULL)
+    for (int i = 0; gLdPreloads[i] != NULL; i++) {
+        s = soinfo_elf_lookup(gLdPreloads[i], elf_hash, name);
+        if (s != NULL) {
+            *lsi = gLdPreloads[i];
             goto done;
+        }
     }
 
-    for(i = 0; needed[i] != NULL; i++) {
-        lsi = needed[i];
-        DEBUG("%5d %s: looking up %s in %s\n",
-              pid, si->name, name, lsi->name);
-        s = soinfo_elf_lookup(lsi, elf_hash, name);
-        if (s != NULL)
+    for (int i = 0; needed[i] != NULL; i++) {
+        DEBUG("%s: looking up %s in %s\n",
+              si->name, name, needed[i]->name);
+        s = soinfo_elf_lookup(needed[i], elf_hash, name);
+        if (s != NULL) {
+            *lsi = needed[i];
             goto done;
+        }
     }
 
-#if ALLOW_SYMBOLS_FROM_MAIN
-    /* If we are resolving relocations while dlopen()ing a library, it's OK for
-     * the library to resolve a symbol that's defined in the executable itself,
-     * although this is rare and is generally a bad idea.
-     */
-    if (somain) {
-        lsi = somain;
-        DEBUG("%5d %s: looking up %s in executable %s\n",
-              pid, si->name, name, lsi->name);
-        s = soinfo_elf_lookup(lsi, elf_hash, name);
-    }
-#endif
-
 done:
-    if(s != NULL) {
-        TRACE_TYPE(LOOKUP, "%5d si %s sym %s s->st_value = 0x%08x, "
+    if (s != NULL) {
+        TRACE_TYPE(LOOKUP, "si %s sym %s s->st_value = 0x%08x, "
                    "found in %s, base = 0x%08x, load bias = 0x%08x\n",
-                   pid, si->name, name, s->st_value,
-                   lsi->name, lsi->base, lsi->load_bias);
-        *offset = lsi->load_bias;
+                   si->name, name, s->st_value,
+                   (*lsi)->name, (*lsi)->base, (*lsi)->load_bias);
         return s;
     }
 
     return NULL;
 }
 
-/* This is used by dl_sym().  It performs symbol lookup only within the
+/* This is used by dlsym(3).  It performs symbol lookup only within the
    specified soinfo object and not in any of its dependencies.
+
+   TODO: Only looking in the specified soinfo seems wrong. dlsym(3) says
+   that it should do a breadth first search through the dependency
+   tree. This agrees with the ELF spec (aka System V Application
+   Binary Interface) where in Chapter 5 it discuss resolving "Shared
+   Object Dependencies" in breadth first search order.
  */
-Elf32_Sym *soinfo_lookup(soinfo *si, const char *name)
+Elf32_Sym* dlsym_handle_lookup(soinfo* si, const char* name)
 {
     return soinfo_elf_lookup(si, elfhash(name), name);
 }
 
-/* This is used by dl_sym().  It performs a global symbol lookup.
+/* This is used by dlsym(3) to performs a global symbol lookup. If the
+   start value is null (for RTLD_DEFAULT), the search starts at the
+   beginning of the global solist. Otherwise the search starts at the
+   specified soinfo (for RTLD_NEXT).
  */
-Elf32_Sym *lookup(const char *name, soinfo **found, soinfo *start)
-{
-    unsigned elf_hash = elfhash(name);
-    Elf32_Sym *s = NULL;
-    soinfo *si;
+Elf32_Sym* dlsym_linear_lookup(const char* name, soinfo** found, soinfo* start) {
+  unsigned elf_hash = elfhash(name);
 
-    if(start == NULL) {
-        start = solist;
+  if (start == NULL) {
+    start = solist;
+  }
+
+  Elf32_Sym* s = NULL;
+  for (soinfo* si = start; (s == NULL) && (si != NULL); si = si->next) {
+    s = soinfo_elf_lookup(si, elf_hash, name);
+    if (s != NULL) {
+      *found = si;
+      break;
     }
+  }
 
-    for(si = start; (s == NULL) && (si != NULL); si = si->next)
-    {
-        if(si->flags & FLAG_ERROR)
-            continue;
-        s = soinfo_elf_lookup(si, elf_hash, name);
-        if (s != NULL) {
-            *found = si;
-            break;
-        }
-    }
+  if (s != NULL) {
+    TRACE_TYPE(LOOKUP, "%s s->st_value = 0x%08x, found->base = 0x%08x\n",
+               name, s->st_value, (*found)->base);
+  }
 
-    if(s != NULL) {
-        TRACE_TYPE(LOOKUP, "%5d %s s->st_value = 0x%08x, "
-                   "si->base = 0x%08x\n", pid, name, s->st_value, si->base);
-        return s;
-    }
-
-    return NULL;
+  return s;
 }
 
-soinfo *find_containing_library(const void *addr)
-{
-    soinfo *si;
-
-    for(si = solist; si != NULL; si = si->next)
-    {
-        if((unsigned)addr >= si->base && (unsigned)addr - si->base < si->size) {
+soinfo* find_containing_library(const void* addr) {
+    for (soinfo* si = solist; si != NULL; si = si->next) {
+        if ((unsigned)addr >= si->base && (unsigned)addr - si->base < si->size) {
             return si;
         }
     }
-
     return NULL;
 }
 
-Elf32_Sym *soinfo_find_symbol(soinfo* si, const void *addr)
-{
+Elf32_Sym* dladdr_find_symbol(soinfo* si, const void* addr) {
     unsigned int i;
     unsigned soaddr = (unsigned)addr - si->base;
 
     /* Search the library's symbol table for any defined symbol which
      * contains this address */
-    for(i=0; i<si->nchain; i++) {
+    for (i=0; i<si->nchain; i++) {
         Elf32_Sym *sym = &si->symtab[i];
 
-        if(sym->st_shndx != SHN_UNDEF &&
+        if (sym->st_shndx != SHN_UNDEF &&
            soaddr >= sym->st_value &&
            soaddr < sym->st_value + sym->st_size) {
             return sym;
@@ -575,13 +655,11 @@
 }
 
 #if 0
-static void dump(soinfo *si)
+static void dump(soinfo* si)
 {
-    Elf32_Sym *s = si->symtab;
-    unsigned n;
-
-    for(n = 0; n < si->nchain; n++) {
-        TRACE("%5d %04d> %08x: %02x %04x %08x %08x %s\n", pid, n, s,
+    Elf32_Sym* s = si->symtab;
+    for (unsigned n = 0; n < si->nchain; n++) {
+        TRACE("%04d> %08x: %02x %04x %08x %08x %s\n", n, s,
                s->st_info, s->st_shndx, s->st_value, s->st_size,
                si->strtab + s->st_name);
         s++;
@@ -589,266 +667,69 @@
 }
 #endif
 
-static const char * const sopaths[] = {
-    "/vendor/lib",
-    "/system/lib",
-    0
-};
-
-static int _open_lib(const char* name) {
-    // TODO: why not just call open?
-    struct stat sb;
-    if (stat(name, &sb) == -1 || !S_ISREG(sb.st_mode)) {
-        return -1;
+static int open_library_on_path(const char* name, const char* const paths[]) {
+  char buf[512];
+  for (size_t i = 0; paths[i] != NULL; ++i) {
+    int n = __libc_format_buffer(buf, sizeof(buf), "%s/%s", paths[i], name);
+    if (n < 0 || n >= static_cast<int>(sizeof(buf))) {
+      PRINT("Warning: ignoring very long library path: %s/%s\n", paths[i], name);
+      continue;
     }
-    return TEMP_FAILURE_RETRY(open(name, O_RDONLY));
+    int fd = TEMP_FAILURE_RETRY(open(buf, O_RDONLY | O_CLOEXEC));
+    if (fd != -1) {
+      return fd;
+    }
+  }
+  return -1;
 }
 
-static int open_library(const char *name)
-{
-    int fd;
-    char buf[512];
-    const char * const*path;
-    int n;
+static int open_library(const char* name) {
+  TRACE("[ opening %s ]\n", name);
 
-    TRACE("[ %5d opening %s ]\n", pid, name);
-
-    if(name == 0) return -1;
-    if(strlen(name) > 256) return -1;
-
-    if ((name[0] == '/') && ((fd = _open_lib(name)) >= 0))
-        return fd;
-
-    for (path = ldpaths; *path; path++) {
-        n = format_buffer(buf, sizeof(buf), "%s/%s", *path, name);
-        if (n < 0 || n >= (int)sizeof(buf)) {
-            WARN("Ignoring very long library path: %s/%s\n", *path, name);
-            continue;
-        }
-        if ((fd = _open_lib(buf)) >= 0)
-            return fd;
+  // If the name contains a slash, we should attempt to open it directly and not search the paths.
+  if (strchr(name, '/') != NULL) {
+    int fd = TEMP_FAILURE_RETRY(open(name, O_RDONLY | O_CLOEXEC));
+    if (fd != -1) {
+      return fd;
     }
-    for (path = sopaths; *path; path++) {
-        n = format_buffer(buf, sizeof(buf), "%s/%s", *path, name);
-        if (n < 0 || n >= (int)sizeof(buf)) {
-            WARN("Ignoring very long library path: %s/%s\n", *path, name);
-            continue;
-        }
-        if ((fd = _open_lib(buf)) >= 0)
-            return fd;
-    }
+    // ...but nvidia binary blobs (at least) rely on this behavior, so fall through for now.
+  }
 
-    return -1;
+  // Otherwise we try LD_LIBRARY_PATH first, and fall back to the built-in well known paths.
+  int fd = open_library_on_path(name, gLdPaths);
+  if (fd == -1) {
+    fd = open_library_on_path(name, gSoPaths);
+  }
+  return fd;
 }
 
-// Returns 'true' if the library is prelinked or on failure so we error out
-// either way. We no longer support prelinking.
-static bool is_prelinked(int fd, const char* name)
-{
-    struct prelink_info_t {
-        long mmap_addr;
-        char tag[4]; // "PRE ".
-    };
-
-    off_t sz = lseek(fd, -sizeof(prelink_info_t), SEEK_END);
-    if (sz < 0) {
-        DL_ERR("lseek failed: %s", strerror(errno));
-        return true;
-    }
-
-    prelink_info_t info;
-    int rc = TEMP_FAILURE_RETRY(read(fd, &info, sizeof(info)));
-    if (rc != sizeof(info)) {
-        DL_ERR("could not read prelink_info_t structure for \"%s\":", name, strerror(errno));
-        return true;
-    }
-
-    if (memcmp(info.tag, "PRE ", 4) == 0) {
-        DL_ERR("prelinked libraries no longer supported: %s", name);
-        return true;
-    }
-    return false;
-}
-
-/* verify_elf_header
- *      Verifies the content of an ELF header.
- *
- * Args:
- *
- * Returns:
- *       0 on success
- *      -1 if no valid ELF object is found @ base.
- */
-static int
-verify_elf_header(const Elf32_Ehdr* hdr)
-{
-    if (hdr->e_ident[EI_MAG0] != ELFMAG0) return -1;
-    if (hdr->e_ident[EI_MAG1] != ELFMAG1) return -1;
-    if (hdr->e_ident[EI_MAG2] != ELFMAG2) return -1;
-    if (hdr->e_ident[EI_MAG3] != ELFMAG3) return -1;
-    if (hdr->e_type != ET_DYN) return -1;
-
-    /* TODO: Should we verify anything else in the header? */
-#ifdef ANDROID_ARM_LINKER
-    if (hdr->e_machine != EM_ARM) return -1;
-#elif defined(ANDROID_X86_LINKER)
-    if (hdr->e_machine != EM_386) return -1;
-#elif defined(ANDROID_MIPS_LINKER)
-    if (hdr->e_machine != EM_MIPS) return -1;
-#endif
-    return 0;
-}
-
-struct scoped_fd {
-    ~scoped_fd() {
-        if (fd != -1) {
-            close(fd);
-        }
-    }
-    int fd;
-};
-
-struct soinfo_ptr {
-    soinfo_ptr(const char* name) {
-        const char* bname = strrchr(name, '/');
-        ptr = soinfo_alloc(bname ? bname + 1 : name);
-    }
-    ~soinfo_ptr() {
-        soinfo_free(ptr);
-    }
-    soinfo* release() {
-        soinfo* result = ptr;
-        ptr = NULL;
-        return result;
-    }
-    soinfo* ptr;
-};
-
-// TODO: rewrite linker_phdr.h to use a class, then lose this.
-struct phdr_ptr {
-    phdr_ptr() : phdr_mmap(NULL) {}
-    ~phdr_ptr() {
-        if (phdr_mmap != NULL) {
-            phdr_table_unload(phdr_mmap, phdr_size);
-        }
-    }
-    void* phdr_mmap;
-    Elf32_Addr phdr_size;
-};
-
-static soinfo* load_library(const char* name)
-{
+static soinfo* load_library(const char* name) {
     // Open the file.
-    scoped_fd fd;
-    fd.fd = open_library(name);
-    if (fd.fd == -1) {
+    int fd = open_library(name);
+    if (fd == -1) {
         DL_ERR("library \"%s\" not found", name);
         return NULL;
     }
 
-    // Read the ELF header.
-    Elf32_Ehdr header[1];
-    int ret = TEMP_FAILURE_RETRY(read(fd.fd, (void*)header, sizeof(header)));
-    if (ret < 0) {
-        DL_ERR("can't read file \"%s\": %s", name, strerror(errno));
-        return NULL;
-    }
-    if (ret != (int)sizeof(header)) {
-        DL_ERR("too small to be an ELF executable: %s", name);
-        return NULL;
-    }
-    if (verify_elf_header(header) < 0) {
-        DL_ERR("not a valid ELF executable: %s", name);
+    // Read the ELF header and load the segments.
+    ElfReader elf_reader(name, fd);
+    if (!elf_reader.Load()) {
         return NULL;
     }
 
-    // Read the program header table.
-    const Elf32_Phdr* phdr_table;
-    phdr_ptr phdr_holder;
-    ret = phdr_table_load(fd.fd, header->e_phoff, header->e_phnum,
-                          &phdr_holder.phdr_mmap, &phdr_holder.phdr_size, &phdr_table);
-    if (ret < 0) {
-        DL_ERR("can't load program header table: %s: %s", name, strerror(errno));
+    const char* bname = strrchr(name, '/');
+    soinfo* si = soinfo_alloc(bname ? bname + 1 : name);
+    if (si == NULL) {
         return NULL;
     }
-    size_t phdr_count = header->e_phnum;
-
-    // Get the load extents.
-    Elf32_Addr ext_sz = phdr_table_get_load_size(phdr_table, phdr_count);
-    TRACE("[ %5d - '%s' wants sz=0x%08x ]\n", pid, name, ext_sz);
-    if (ext_sz == 0) {
-        DL_ERR("no loadable segments in file: %s", name);
-        return NULL;
-    }
-
-    // We no longer support pre-linked libraries.
-    if (is_prelinked(fd.fd, name)) {
-        return NULL;
-    }
-
-    // Reserve address space for all loadable segments.
-    void* load_start = NULL;
-    Elf32_Addr load_size = 0;
-    Elf32_Addr load_bias = 0;
-    ret = phdr_table_reserve_memory(phdr_table,
-                                    phdr_count,
-                                    &load_start,
-                                    &load_size,
-                                    &load_bias);
-    if (ret < 0) {
-        DL_ERR("can't reserve %d bytes in address space for \"%s\": %s",
-               ext_sz, name, strerror(errno));
-        return NULL;
-    }
-
-    TRACE("[ %5d allocated memory for %s @ %p (0x%08x) ]\n",
-          pid, name, load_start, load_size);
-
-    /* Map all the segments in our address space with default protections */
-    ret = phdr_table_load_segments(phdr_table,
-                                   phdr_count,
-                                   load_bias,
-                                   fd.fd);
-    if (ret < 0) {
-        DL_ERR("can't map loadable segments for \"%s\": %s",
-               name, strerror(errno));
-        return NULL;
-    }
-
-    soinfo_ptr si(name);
-    if (si.ptr == NULL) {
-        return NULL;
-    }
-
-    si.ptr->base = (Elf32_Addr) load_start;
-    si.ptr->size = load_size;
-    si.ptr->load_bias = load_bias;
-    si.ptr->flags = 0;
-    si.ptr->entry = 0;
-    si.ptr->dynamic = (unsigned *)-1;
-    si.ptr->phnum = phdr_count;
-    si.ptr->phdr = phdr_table_get_loaded_phdr(phdr_table, phdr_count, load_bias);
-    if (si.ptr->phdr == NULL) {
-        DL_ERR("can't find loaded PHDR for \"%s\"", name);
-        return NULL;
-    }
-
-    return si.release();
-}
-
-static soinfo *
-init_library(soinfo *si)
-{
-    /* At this point we know that whatever is loaded @ base is a valid ELF
-     * shared library whose segments are properly mapped in. */
-    TRACE("[ %5d init_library base=0x%08x sz=0x%08x name='%s') ]\n",
-          pid, si->base, si->size, si->name);
-
-    if(soinfo_link_image(si)) {
-        munmap((void *)si->base, si->size);
-        return NULL;
-    }
-
+    si->base = elf_reader.load_start();
+    si->size = elf_reader.load_size();
+    si->load_bias = elf_reader.load_bias();
+    si->flags = 0;
+    si->entry = 0;
+    si->dynamic = NULL;
+    si->phnum = elf_reader.phdr_count();
+    si->phdr = elf_reader.loaded_phdr();
     return si;
 }
 
@@ -863,111 +744,141 @@
     bname = strrchr(name, '/');
     bname = bname ? bname + 1 : name;
 
-    for(si = solist; si != NULL; si = si->next){
-        if(!strcmp(bname, si->name)) {
+    for (si = solist; si != NULL; si = si->next) {
+        if (!strcmp(bname, si->name)) {
             return si;
         }
     }
     return NULL;
 }
 
-soinfo *find_library(const char *name)
-{
-    soinfo *si;
+static soinfo* find_library_internal(const char* name) {
+  if (name == NULL) {
+    return somain;
+  }
 
-#if ALLOW_SYMBOLS_FROM_MAIN
-    if (name == NULL)
-        return somain;
-#else
-    if (name == NULL)
-        return NULL;
-#endif
-
-    si = find_loaded_library(name);
-    if (si != NULL) {
-        if(si->flags & FLAG_ERROR) {
-            DL_ERR("\"%s\" failed to load previously", name);
-            return NULL;
-        }
-        if(si->flags & FLAG_LINKED) return si;
-        DL_ERR("OOPS: recursive link to \"%s\"", si->name);
-        return NULL;
+  soinfo* si = find_loaded_library(name);
+  if (si != NULL) {
+    if (si->flags & FLAG_LINKED) {
+      return si;
     }
+    DL_ERR("OOPS: recursive link to \"%s\"", si->name);
+    return NULL;
+  }
 
-    TRACE("[ %5d '%s' has not been loaded yet.  Locating...]\n", pid, name);
-    si = load_library(name);
-    if(si == NULL)
-        return NULL;
-    return init_library(si);
+  TRACE("[ '%s' has not been loaded yet.  Locating...]\n", name);
+  si = load_library(name);
+  if (si == NULL) {
+    return NULL;
+  }
+
+  // At this point we know that whatever is loaded @ base is a valid ELF
+  // shared library whose segments are properly mapped in.
+  TRACE("[ init_library base=0x%08x sz=0x%08x name='%s') ]\n",
+        si->base, si->size, si->name);
+
+  if (!soinfo_link_image(si)) {
+    munmap(reinterpret_cast<void*>(si->base), si->size);
+    soinfo_free(si);
+    return NULL;
+  }
+
+  return si;
 }
 
-static void call_destructors(soinfo *si);
+static soinfo* find_library(const char* name) {
+  soinfo* si = find_library_internal(name);
+  if (si != NULL) {
+    si->refcount++;
+  }
+  return si;
+}
 
-int soinfo_unload(soinfo* si) {
-    if (si->refcount == 1) {
-        TRACE("%5d unloading '%s'\n", pid, si->name);
-        call_destructors(si);
+static int soinfo_unload(soinfo* si) {
+  if (si->refcount == 1) {
+    TRACE("unloading '%s'\n", si->name);
+    si->CallDestructors();
 
-        for (unsigned* d = si->dynamic; *d; d += 2) {
-            if(d[0] == DT_NEEDED){
-                soinfo *lsi = find_loaded_library(si->strtab + d[1]);
-                if (lsi) {
-                    TRACE("%5d %s needs to unload %s\n", pid,
-                          si->name, lsi->name);
-                    soinfo_unload(lsi);
-                } else {
-                    // TODO: should we return -1 in this case?
-                    DL_ERR("\"%s\": could not unload dependent library",
-                           si->name);
-                }
-            }
+    for (Elf32_Dyn* d = si->dynamic; d->d_tag != DT_NULL; ++d) {
+      if (d->d_tag == DT_NEEDED) {
+        const char* library_name = si->strtab + d->d_un.d_val;
+        soinfo* lsi = find_loaded_library(library_name);
+        if (lsi != NULL) {
+          TRACE("%s needs to unload %s\n", si->name, lsi->name);
+          soinfo_unload(lsi);
+        } else {
+          // TODO: should we return -1 in this case?
+          DL_ERR("\"%s\": could not unload dependent library", si->name);
         }
-
-        munmap((char *)si->base, si->size);
-        notify_gdb_of_unload(si);
-        soinfo_free(si);
-        si->refcount = 0;
-    } else {
-        si->refcount--;
-        PRINT("%5d not unloading '%s', decrementing refcount to %d\n",
-              pid, si->name, si->refcount);
+      }
     }
-    return 0;
+
+    munmap(reinterpret_cast<void*>(si->base), si->size);
+    notify_gdb_of_unload(si);
+    soinfo_free(si);
+    si->refcount = 0;
+  } else {
+    si->refcount--;
+    TRACE("not unloading '%s', decrementing refcount to %d\n", si->name, si->refcount);
+  }
+  return 0;
+}
+
+void do_android_update_LD_LIBRARY_PATH(const char* ld_library_path) {
+  if (!get_AT_SECURE()) {
+    parse_LD_LIBRARY_PATH(ld_library_path);
+  }
+}
+
+soinfo* do_dlopen(const char* name, int flags) {
+  if ((flags & ~(RTLD_NOW|RTLD_LAZY|RTLD_LOCAL|RTLD_GLOBAL)) != 0) {
+    DL_ERR("invalid flags to dlopen: %x", flags);
+    return NULL;
+  }
+  set_soinfo_pool_protection(PROT_READ | PROT_WRITE);
+  soinfo* si = find_library(name);
+  if (si != NULL) {
+    si->CallConstructors();
+  }
+  set_soinfo_pool_protection(PROT_READ);
+  return si;
+}
+
+int do_dlclose(soinfo* si) {
+  set_soinfo_pool_protection(PROT_READ | PROT_WRITE);
+  int result = soinfo_unload(si);
+  set_soinfo_pool_protection(PROT_READ);
+  return result;
 }
 
 /* TODO: don't use unsigned for addrs below. It works, but is not
  * ideal. They should probably be either uint32_t, Elf32_Addr, or unsigned
  * long.
  */
-static int soinfo_relocate(soinfo *si, Elf32_Rel *rel, unsigned count,
-                           soinfo *needed[])
+static int soinfo_relocate(soinfo* si, Elf32_Rel* rel, unsigned count,
+                           soinfo* needed[])
 {
-    Elf32_Sym *symtab = si->symtab;
-    const char *strtab = si->strtab;
-    Elf32_Sym *s;
-    Elf32_Addr offset;
-    Elf32_Rel *start = rel;
+    Elf32_Sym* symtab = si->symtab;
+    const char* strtab = si->strtab;
+    Elf32_Sym* s;
+    Elf32_Rel* start = rel;
+    soinfo* lsi;
 
     for (size_t idx = 0; idx < count; ++idx, ++rel) {
         unsigned type = ELF32_R_TYPE(rel->r_info);
         unsigned sym = ELF32_R_SYM(rel->r_info);
         unsigned reloc = (unsigned)(rel->r_offset + si->load_bias);
         unsigned sym_addr = 0;
-        char *sym_name = NULL;
+        char* sym_name = NULL;
 
-        DEBUG("%5d Processing '%s' relocation at index %d\n", pid,
-              si->name, idx);
+        DEBUG("Processing '%s' relocation at index %d\n", si->name, idx);
         if (type == 0) { // R_*_NONE
             continue;
         }
-        if(sym != 0) {
+        if (sym != 0) {
             sym_name = (char *)(strtab + symtab[sym].st_name);
-            bool ignore_local = false;
-#if defined(ANDROID_ARM_LINKER)
-            ignore_local = (type == R_ARM_COPY);
-#endif
-            s = soinfo_do_lookup(si, sym_name, &offset, needed, ignore_local);
-            if(s == NULL) {
+            s = soinfo_do_lookup(si, sym_name, &lsi, needed);
+            if (s == NULL) {
                 /* We only allow an undefined symbol if this is a weak
                    reference..   */
                 s = &symtab[sym];
@@ -1025,14 +936,14 @@
             } else {
                 /* We got a definition.  */
 #if 0
-                if((base == 0) && (si->base != 0)){
+                if ((base == 0) && (si->base != 0)) {
                         /* linking from libraries to main image is bad */
                     DL_ERR("cannot locate \"%s\"...",
                            strtab + symtab[sym].st_name);
                     return -1;
                 }
 #endif
-                sym_addr = (unsigned)(s->st_value + offset);
+                sym_addr = (unsigned)(s->st_value + lsi->load_bias);
             }
             count_relocation(kRelocSymbol);
         } else {
@@ -1047,28 +958,25 @@
         case R_ARM_JUMP_SLOT:
             count_relocation(kRelocAbsolute);
             MARK(rel->r_offset);
-            TRACE_TYPE(RELO, "%5d RELO JMP_SLOT %08x <- %08x %s\n", pid,
-                       reloc, sym_addr, sym_name);
+            TRACE_TYPE(RELO, "RELO JMP_SLOT %08x <- %08x %s\n", reloc, sym_addr, sym_name);
             *((unsigned*)reloc) = sym_addr;
             break;
         case R_ARM_GLOB_DAT:
             count_relocation(kRelocAbsolute);
             MARK(rel->r_offset);
-            TRACE_TYPE(RELO, "%5d RELO GLOB_DAT %08x <- %08x %s\n", pid,
-                       reloc, sym_addr, sym_name);
+            TRACE_TYPE(RELO, "RELO GLOB_DAT %08x <- %08x %s\n", reloc, sym_addr, sym_name);
             *((unsigned*)reloc) = sym_addr;
             break;
         case R_ARM_ABS32:
             count_relocation(kRelocAbsolute);
             MARK(rel->r_offset);
-            TRACE_TYPE(RELO, "%5d RELO ABS %08x <- %08x %s\n", pid,
-                       reloc, sym_addr, sym_name);
+            TRACE_TYPE(RELO, "RELO ABS %08x <- %08x %s\n", reloc, sym_addr, sym_name);
             *((unsigned*)reloc) += sym_addr;
             break;
         case R_ARM_REL32:
             count_relocation(kRelocRelative);
             MARK(rel->r_offset);
-            TRACE_TYPE(RELO, "%5d RELO REL32 %08x <- %08x - %08x %s\n", pid,
+            TRACE_TYPE(RELO, "RELO REL32 %08x <- %08x - %08x %s\n",
                        reloc, sym_addr, rel->r_offset, sym_name);
             *((unsigned*)reloc) += sym_addr - rel->r_offset;
             break;
@@ -1076,29 +984,20 @@
         case R_386_JMP_SLOT:
             count_relocation(kRelocAbsolute);
             MARK(rel->r_offset);
-            TRACE_TYPE(RELO, "%5d RELO JMP_SLOT %08x <- %08x %s\n", pid,
-                       reloc, sym_addr, sym_name);
+            TRACE_TYPE(RELO, "RELO JMP_SLOT %08x <- %08x %s\n", reloc, sym_addr, sym_name);
             *((unsigned*)reloc) = sym_addr;
             break;
         case R_386_GLOB_DAT:
             count_relocation(kRelocAbsolute);
             MARK(rel->r_offset);
-            TRACE_TYPE(RELO, "%5d RELO GLOB_DAT %08x <- %08x %s\n", pid,
-                       reloc, sym_addr, sym_name);
+            TRACE_TYPE(RELO, "RELO GLOB_DAT %08x <- %08x %s\n", reloc, sym_addr, sym_name);
             *((unsigned*)reloc) = sym_addr;
             break;
 #elif defined(ANDROID_MIPS_LINKER)
-    case R_MIPS_JUMP_SLOT:
-            count_relocation(kRelocAbsolute);
-            MARK(rel->r_offset);
-            TRACE_TYPE(RELO, "%5d RELO JMP_SLOT %08x <- %08x %s\n", pid,
-                       reloc, sym_addr, sym_name);
-            *((unsigned*)reloc) = sym_addr;
-            break;
     case R_MIPS_REL32:
             count_relocation(kRelocAbsolute);
             MARK(rel->r_offset);
-            TRACE_TYPE(RELO, "%5d RELO REL32 %08x <- %08x %s\n", pid,
+            TRACE_TYPE(RELO, "RELO REL32 %08x <- %08x %s\n",
                        reloc, sym_addr, (sym_name) ? sym_name : "*SECTIONHDR*");
             if (s) {
                 *((unsigned*)reloc) += sym_addr;
@@ -1116,11 +1015,10 @@
             count_relocation(kRelocRelative);
             MARK(rel->r_offset);
             if (sym) {
-                DL_ERR("odd RELATIVE form...", pid);
+                DL_ERR("odd RELATIVE form...");
                 return -1;
             }
-            TRACE_TYPE(RELO, "%5d RELO RELATIVE %08x <- +%08x\n", pid,
-                       reloc, si->base);
+            TRACE_TYPE(RELO, "RELO RELATIVE %08x <- +%08x\n", reloc, si->base);
             *((unsigned*)reloc) += si->base;
             break;
 
@@ -1129,17 +1027,15 @@
             count_relocation(kRelocRelative);
             MARK(rel->r_offset);
 
-            TRACE_TYPE(RELO, "%5d RELO R_386_32 %08x <- +%08x %s\n", pid,
-                       reloc, sym_addr, sym_name);
+            TRACE_TYPE(RELO, "RELO R_386_32 %08x <- +%08x %s\n", reloc, sym_addr, sym_name);
             *((unsigned *)reloc) += (unsigned)sym_addr;
             break;
 
         case R_386_PC32:
             count_relocation(kRelocRelative);
             MARK(rel->r_offset);
-            TRACE_TYPE(RELO, "%5d RELO R_386_PC32 %08x <- "
-                       "+%08x (%08x - %08x) %s\n", pid, reloc,
-                       (sym_addr - reloc), sym_addr, reloc, sym_name);
+            TRACE_TYPE(RELO, "RELO R_386_PC32 %08x <- +%08x (%08x - %08x) %s\n",
+                       reloc, (sym_addr - reloc), sym_addr, reloc, sym_name);
             *((unsigned *)reloc) += (unsigned)(sym_addr - reloc);
             break;
 #endif /* ANDROID_X86_LINKER */
@@ -1163,13 +1059,29 @@
             }
             count_relocation(kRelocCopy);
             MARK(rel->r_offset);
-            TRACE_TYPE(RELO, "%5d RELO %08x <- %d @ %08x %s\n", pid,
-                       reloc, s->st_size, sym_addr, sym_name);
+            TRACE_TYPE(RELO, "RELO %08x <- %d @ %08x %s\n", reloc, s->st_size, sym_addr, sym_name);
             if (reloc == sym_addr) {
-                DL_ERR("Internal linker error detected. reloc == symaddr");
+                Elf32_Sym *src = soinfo_do_lookup(NULL, sym_name, &lsi, needed);
+
+                if (src == NULL) {
+                    DL_ERR("%s R_ARM_COPY relocation source cannot be resolved", si->name);
+                    return -1;
+                }
+                if (lsi->has_DT_SYMBOLIC) {
+                    DL_ERR("%s invalid R_ARM_COPY relocation against DT_SYMBOLIC shared "
+                           "library %s (built with -Bsymbolic?)", si->name, lsi->name);
+                    return -1;
+                }
+                if (s->st_size < src->st_size) {
+                    DL_ERR("%s R_ARM_COPY relocation size mismatch (%d < %d)",
+                           si->name, s->st_size, src->st_size);
+                    return -1;
+                }
+                memcpy((void*)reloc, (void*)(src->st_value + lsi->load_bias), src->st_size);
+            } else {
+                DL_ERR("%s R_ARM_COPY relocation target cannot be resolved", si->name);
                 return -1;
             }
-            memcpy((void*)reloc, (void*)sym_addr, s->st_size);
             break;
 #endif /* ANDROID_ARM_LINKER */
 
@@ -1221,13 +1133,13 @@
     sym = symtab + gotsym;
     got = si->plt_got + local_gotno;
     for (g = gotsym; g < symtabno; g++, sym++, got++) {
-        const char *sym_name;
-        unsigned base;
-        Elf32_Sym *s;
+        const char* sym_name;
+        Elf32_Sym* s;
+        soinfo* lsi;
 
         /* This is an undefined reference... try to locate it */
         sym_name = si->strtab + sym->st_name;
-        s = soinfo_do_lookup(si, sym_name, &base, needed, false);
+        s = soinfo_do_lookup(si, sym_name, &lsi, needed);
         if (s == NULL) {
             /* We only allow an undefined symbol if this is a weak
                reference..   */
@@ -1243,7 +1155,7 @@
              * For reference see NetBSD link loader
              * http://cvsweb.netbsd.org/bsdweb.cgi/src/libexec/ld.elf_so/arch/mips/mips_reloc.c?rev=1.53&content-type=text/x-cvsweb-markup
              */
-             *got = base + s->st_value;
+             *got = lsi->load_bias + s->st_value;
         }
     }
     return 0;
@@ -1265,112 +1177,95 @@
  *
  *   DT_FINI_ARRAY must be parsed in reverse order.
  */
+void soinfo::CallArray(const char* array_name UNUSED, unsigned* array, int count, bool reverse) {
+  if (array == NULL) {
+    return;
+  }
 
-static void call_array(unsigned *ctor, int count, int reverse)
-{
-    int n, inc = 1;
+  int step = 1;
+  if (reverse) {
+    array += (count-1);
+    step = -1;
+  }
 
-    if (reverse) {
-        ctor += (count-1);
-        inc   = -1;
-    }
+  TRACE("[ Calling %s @ %p [%d] for '%s' ]\n", array_name, array, count, name);
 
-    for(n = count; n > 0; n--) {
-        TRACE("[ %5d Looking at %s *0x%08x == 0x%08x ]\n", pid,
-              reverse ? "dtor" : "ctor",
-              (unsigned)ctor, (unsigned)*ctor);
-        void (*func)() = (void (*)()) *ctor;
-        ctor += inc;
-        if(((int) func == 0) || ((int) func == -1)) continue;
-        TRACE("[ %5d Calling func @ 0x%08x ]\n", pid, (unsigned)func);
-        func();
-    }
+  for (int n = count; n > 0; n--) {
+    TRACE("[ Looking at %s[%d] *%p == 0x%08x ]\n", array_name, n, array, *array);
+    void (*func)() = (void (*)()) *array;
+    array += step;
+    CallFunction("function", func);
+  }
+
+  TRACE("[ Done calling %s for '%s' ]\n", array_name, name);
 }
 
-static void soinfo_call_preinit_constructors(soinfo *si)
-{
-  TRACE("[ %5d Calling preinit_array @ 0x%08x [%d] for '%s' ]\n",
-      pid, (unsigned)si->preinit_array, si->preinit_array_count,
-      si->name);
-  call_array(si->preinit_array, si->preinit_array_count, 0);
-  TRACE("[ %5d Done calling preinit_array for '%s' ]\n", pid, si->name);
+void soinfo::CallFunction(const char* function_name UNUSED, void (*function)()) {
+  if (function == NULL || reinterpret_cast<uintptr_t>(function) == static_cast<uintptr_t>(-1)) {
+    return;
+  }
+
+  TRACE("[ Calling %s @ %p for '%s' ]\n", function_name, function, name);
+  function();
+  TRACE("[ Done calling %s for '%s' ]\n", function_name, name);
+
+  // The function may have called dlopen(3) or dlclose(3), so we need to ensure our data structures
+  // are still writable. This happens with our debug malloc (see http://b/7941716).
+  set_soinfo_pool_protection(PROT_READ | PROT_WRITE);
 }
 
-void soinfo_call_constructors(soinfo *si)
-{
-    if (si->constructors_called)
-        return;
+void soinfo::CallPreInitConstructors() {
+  CallArray("DT_PREINIT_ARRAY", preinit_array, preinit_array_count, false);
+}
 
-    // Set this before actually calling the constructors, otherwise it doesn't
-    // protect against recursive constructor calls. One simple example of
-    // constructor recursion is the libc debug malloc, which is implemented in
-    // libc_malloc_debug_leak.so:
-    // 1. The program depends on libc, so libc's constructor is called here.
-    // 2. The libc constructor calls dlopen() to load libc_malloc_debug_leak.so.
-    // 3. dlopen() calls soinfo_call_constructors() with the newly created
-    //    soinfo for libc_malloc_debug_leak.so.
-    // 4. The debug so depends on libc, so soinfo_call_constructors() is
-    //    called again with the libc soinfo. If it doesn't trigger the early-
-    //    out above, the libc constructor will be called again (recursively!).
-    si->constructors_called = 1;
+void soinfo::CallConstructors() {
+  if (constructors_called) {
+    return;
+  }
 
-    if (!(si->flags & FLAG_EXE) && si->preinit_array) {
-      DL_ERR("shared library \"%s\" has a preinit_array table @ 0x%08x. "
-          "This is INVALID.", si->name, (unsigned) si->preinit_array);
-    }
+  // We set constructors_called before actually calling the constructors, otherwise it doesn't
+  // protect against recursive constructor calls. One simple example of constructor recursion
+  // is the libc debug malloc, which is implemented in libc_malloc_debug_leak.so:
+  // 1. The program depends on libc, so libc's constructor is called here.
+  // 2. The libc constructor calls dlopen() to load libc_malloc_debug_leak.so.
+  // 3. dlopen() calls the constructors on the newly created
+  //    soinfo for libc_malloc_debug_leak.so.
+  // 4. The debug .so depends on libc, so CallConstructors is
+  //    called again with the libc soinfo. If it doesn't trigger the early-
+  //    out above, the libc constructor will be called again (recursively!).
+  constructors_called = true;
 
-    if (si->dynamic) {
-        unsigned *d;
-        for(d = si->dynamic; *d; d += 2) {
-            if(d[0] == DT_NEEDED){
-                soinfo* lsi = find_loaded_library(si->strtab + d[1]);
-                if (!lsi) {
-                    DL_ERR("\"%s\": could not initialize dependent library",
-                           si->name);
-                } else {
-                    soinfo_call_constructors(lsi);
-                }
-            }
+  if (!(flags & FLAG_EXE) && preinit_array) {
+    DL_ERR("shared library \"%s\" has a preinit_array table @ %p", name, preinit_array);
+    return;
+  }
+
+  if (dynamic != NULL) {
+    for (Elf32_Dyn* d = dynamic; d->d_tag != DT_NULL; ++d) {
+      if (d->d_tag == DT_NEEDED) {
+        const char* library_name = strtab + d->d_un.d_val;
+        soinfo* lsi = find_loaded_library(library_name);
+        if (lsi == NULL) {
+          DL_ERR("\"%s\": could not initialize dependent library", name);
+        } else {
+          lsi->CallConstructors();
         }
+      }
     }
+  }
 
-    if (si->init_func) {
-        TRACE("[ %5d Calling init_func @ 0x%08x for '%s' ]\n", pid,
-              (unsigned)si->init_func, si->name);
-        si->init_func();
-        TRACE("[ %5d Done calling init_func for '%s' ]\n", pid, si->name);
-    }
-
-    if (si->init_array) {
-        TRACE("[ %5d Calling init_array @ 0x%08x [%d] for '%s' ]\n", pid,
-              (unsigned)si->init_array, si->init_array_count, si->name);
-        call_array(si->init_array, si->init_array_count, 0);
-        TRACE("[ %5d Done calling init_array for '%s' ]\n", pid, si->name);
-    }
-
+  CallFunction("DT_INIT", init_func);
+  CallArray("DT_INIT_ARRAY", init_array, init_array_count, false);
 }
 
-static void call_destructors(soinfo *si)
-{
-    if (si->fini_array) {
-        TRACE("[ %5d Calling fini_array @ 0x%08x [%d] for '%s' ]\n", pid,
-              (unsigned)si->fini_array, si->fini_array_count, si->name);
-        call_array(si->fini_array, si->fini_array_count, 1);
-        TRACE("[ %5d Done calling fini_array for '%s' ]\n", pid, si->name);
-    }
-
-    if (si->fini_func) {
-        TRACE("[ %5d Calling fini_func @ 0x%08x for '%s' ]\n", pid,
-              (unsigned)si->fini_func, si->name);
-        si->fini_func();
-        TRACE("[ %5d Done calling fini_func for '%s' ]\n", pid, si->name);
-    }
+void soinfo::CallDestructors() {
+  CallArray("DT_FINI_ARRAY", fini_array, fini_array_count, true);
+  CallFunction("DT_FINI", fini_func);
 }
 
 /* Force any of the closed stdin, stdout and stderr to be associated with
    /dev/null. */
-static int nullify_closed_stdio (void)
-{
+static int nullify_closed_stdio() {
     int dev_null, i, status;
     int return_value = 0;
 
@@ -1379,7 +1274,7 @@
         DL_ERR("cannot open /dev/null: %s", strerror(errno));
         return -1;
     }
-    TRACE("[ %5d Opened /dev/null file-descriptor=%d]\n", pid, dev_null);
+    TRACE("[ Opened /dev/null file-descriptor=%d]\n", dev_null);
 
     /* If any of the stdio file descriptors is valid and not associated
        with /dev/null, dup /dev/null to it.  */
@@ -1389,7 +1284,7 @@
             continue;
         }
 
-        TRACE("[ %5d Nullifying stdio file descriptor %d]\n", pid, i);
+        TRACE("[ Nullifying stdio file descriptor %d]\n", i);
         status = TEMP_FAILURE_RETRY(fcntl(i, F_GETFL));
 
         /* If file is opened, we are good. */
@@ -1418,7 +1313,7 @@
 
     /* If /dev/null is not one of the stdio file descriptors, close it. */
     if (dev_null > 2) {
-        TRACE("[ %5d Closing /dev/null file-descriptor=%d]\n", pid, dev_null);
+        TRACE("[ Closing /dev/null file-descriptor=%d]\n", dev_null);
         status = TEMP_FAILURE_RETRY(close(dev_null));
         if (status == -1) {
             DL_ERR("close failed: %s", strerror(errno));
@@ -1429,35 +1324,32 @@
     return return_value;
 }
 
-static int soinfo_link_image(soinfo *si)
-{
-    unsigned *d;
+static bool soinfo_link_image(soinfo* si) {
     /* "base" might wrap around UINT32_MAX. */
     Elf32_Addr base = si->load_bias;
     const Elf32_Phdr *phdr = si->phdr;
     int phnum = si->phnum;
-    int relocating_linker = (si->flags & FLAG_LINKER) != 0;
-    soinfo **needed, **pneeded;
-    size_t dynamic_count;
+    bool relocating_linker = (si->flags & FLAG_LINKER) != 0;
 
     /* We can't debug anything until the linker is relocated */
     if (!relocating_linker) {
-        INFO("[ %5d linking %s ]\n", pid, si->name);
-        DEBUG("%5d si->base = 0x%08x si->flags = 0x%08x\n", pid,
-            si->base, si->flags);
+        INFO("[ linking %s ]\n", si->name);
+        DEBUG("si->base = 0x%08x si->flags = 0x%08x\n", si->base, si->flags);
     }
 
     /* Extract dynamic section */
+    size_t dynamic_count;
+    Elf32_Word dynamic_flags;
     phdr_table_get_dynamic_section(phdr, phnum, base, &si->dynamic,
-                                   &dynamic_count);
+                                   &dynamic_count, &dynamic_flags);
     if (si->dynamic == NULL) {
         if (!relocating_linker) {
-            DL_ERR("missing PT_DYNAMIC?!");
+            DL_ERR("missing PT_DYNAMIC in \"%s\"", si->name);
         }
-        goto fail;
+        return false;
     } else {
         if (!relocating_linker) {
-            DEBUG("%5d dynamic = %p\n", pid, si->dynamic);
+            DEBUG("dynamic = %p\n", si->dynamic);
         }
     }
 
@@ -1467,91 +1359,104 @@
 #endif
 
     /* extract useful information from dynamic section */
-    for(d = si->dynamic; *d; d++){
-        DEBUG("%5d d = %p, d[0] = 0x%08x d[1] = 0x%08x\n", pid, d, d[0], d[1]);
-        switch(*d++){
+    uint32_t needed_count = 0;
+    for (Elf32_Dyn* d = si->dynamic; d->d_tag != DT_NULL; ++d) {
+        DEBUG("d = %p, d[0](tag) = 0x%08x d[1](val) = 0x%08x\n", d, d->d_tag, d->d_un.d_val);
+        switch(d->d_tag){
         case DT_HASH:
-            si->nbucket = ((unsigned *) (base + *d))[0];
-            si->nchain = ((unsigned *) (base + *d))[1];
-            si->bucket = (unsigned *) (base + *d + 8);
-            si->chain = (unsigned *) (base + *d + 8 + si->nbucket * 4);
+            si->nbucket = ((unsigned *) (base + d->d_un.d_ptr))[0];
+            si->nchain = ((unsigned *) (base + d->d_un.d_ptr))[1];
+            si->bucket = (unsigned *) (base + d->d_un.d_ptr + 8);
+            si->chain = (unsigned *) (base + d->d_un.d_ptr + 8 + si->nbucket * 4);
             break;
         case DT_STRTAB:
-            si->strtab = (const char *) (base + *d);
+            si->strtab = (const char *) (base + d->d_un.d_ptr);
             break;
         case DT_SYMTAB:
-            si->symtab = (Elf32_Sym *) (base + *d);
+            si->symtab = (Elf32_Sym *) (base + d->d_un.d_ptr);
             break;
         case DT_PLTREL:
-            if(*d != DT_REL) {
-                DL_ERR("DT_RELA not supported");
-                goto fail;
+            if (d->d_un.d_val != DT_REL) {
+                DL_ERR("unsupported DT_RELA in \"%s\"", si->name);
+                return false;
             }
             break;
         case DT_JMPREL:
-            si->plt_rel = (Elf32_Rel*) (base + *d);
+            si->plt_rel = (Elf32_Rel*) (base + d->d_un.d_ptr);
             break;
         case DT_PLTRELSZ:
-            si->plt_rel_count = *d / 8;
+            si->plt_rel_count = d->d_un.d_val / sizeof(Elf32_Rel);
             break;
         case DT_REL:
-            si->rel = (Elf32_Rel*) (base + *d);
+            si->rel = (Elf32_Rel*) (base + d->d_un.d_ptr);
             break;
         case DT_RELSZ:
-            si->rel_count = *d / 8;
+            si->rel_count = d->d_un.d_val / sizeof(Elf32_Rel);
             break;
         case DT_PLTGOT:
             /* Save this in case we decide to do lazy binding. We don't yet. */
-            si->plt_got = (unsigned *)(base + *d);
+            si->plt_got = (unsigned *)(base + d->d_un.d_ptr);
             break;
         case DT_DEBUG:
-#if !defined(ANDROID_MIPS_LINKER)
             // Set the DT_DEBUG entry to the address of _r_debug for GDB
-            *d = (int) &_r_debug;
-#endif
+            // if the dynamic table is writable
+            if ((dynamic_flags & PF_W) != 0) {
+                d->d_un.d_val = (int) &_r_debug;
+            }
             break;
          case DT_RELA:
-            DL_ERR("DT_RELA not supported");
-            goto fail;
+            DL_ERR("unsupported DT_RELA in \"%s\"", si->name);
+            return false;
         case DT_INIT:
-            si->init_func = (void (*)(void))(base + *d);
-            DEBUG("%5d %s constructors (init func) found at %p\n",
-                  pid, si->name, si->init_func);
+            si->init_func = (void (*)(void))(base + d->d_un.d_ptr);
+            DEBUG("%s constructors (init func) found at %p\n", si->name, si->init_func);
             break;
         case DT_FINI:
-            si->fini_func = (void (*)(void))(base + *d);
-            DEBUG("%5d %s destructors (fini func) found at %p\n",
-                  pid, si->name, si->fini_func);
+            si->fini_func = (void (*)(void))(base + d->d_un.d_ptr);
+            DEBUG("%s destructors (fini func) found at %p\n", si->name, si->fini_func);
             break;
         case DT_INIT_ARRAY:
-            si->init_array = (unsigned *)(base + *d);
-            DEBUG("%5d %s constructors (init_array) found at %p\n",
-                  pid, si->name, si->init_array);
+            si->init_array = (unsigned *)(base + d->d_un.d_ptr);
+            DEBUG("%s constructors (init_array) found at %p\n", si->name, si->init_array);
             break;
         case DT_INIT_ARRAYSZ:
-            si->init_array_count = ((unsigned)*d) / sizeof(Elf32_Addr);
+            si->init_array_count = ((unsigned)d->d_un.d_val) / sizeof(Elf32_Addr);
             break;
         case DT_FINI_ARRAY:
-            si->fini_array = (unsigned *)(base + *d);
-            DEBUG("%5d %s destructors (fini_array) found at %p\n",
-                  pid, si->name, si->fini_array);
+            si->fini_array = (unsigned *)(base + d->d_un.d_ptr);
+            DEBUG("%s destructors (fini_array) found at %p\n", si->name, si->fini_array);
             break;
         case DT_FINI_ARRAYSZ:
-            si->fini_array_count = ((unsigned)*d) / sizeof(Elf32_Addr);
+            si->fini_array_count = ((unsigned)d->d_un.d_val) / sizeof(Elf32_Addr);
             break;
         case DT_PREINIT_ARRAY:
-            si->preinit_array = (unsigned *)(base + *d);
-            DEBUG("%5d %s constructors (preinit_array) found at %p\n",
-                  pid, si->name, si->preinit_array);
+            si->preinit_array = (unsigned *)(base + d->d_un.d_ptr);
+            DEBUG("%s constructors (preinit_array) found at %p\n", si->name, si->preinit_array);
             break;
         case DT_PREINIT_ARRAYSZ:
-            si->preinit_array_count = ((unsigned)*d) / sizeof(Elf32_Addr);
+            si->preinit_array_count = ((unsigned)d->d_un.d_val) / sizeof(Elf32_Addr);
             break;
         case DT_TEXTREL:
             si->has_text_relocations = true;
             break;
-#if defined(ANDROID_MIPS_LINKER)
+        case DT_SYMBOLIC:
+            si->has_DT_SYMBOLIC = true;
+            break;
         case DT_NEEDED:
+            ++needed_count;
+            break;
+#if defined DT_FLAGS
+        // TODO: why is DT_FLAGS not defined?
+        case DT_FLAGS:
+            if (d->d_un.d_val & DF_TEXTREL) {
+                si->has_text_relocations = true;
+            }
+            if (d->d_un.d_val & DF_SYMBOLIC) {
+                si->has_DT_SYMBOLIC = true;
+            }
+            break;
+#endif
+#if defined(ANDROID_MIPS_LINKER)
         case DT_STRSZ:
         case DT_SYMENT:
         case DT_RELENT:
@@ -1559,7 +1464,7 @@
         case DT_MIPS_RLD_MAP:
             // Set the DT_MIPS_RLD_MAP entry to the address of _r_debug for GDB.
             {
-              r_debug** dp = (r_debug**) *d;
+              r_debug** dp = (r_debug**) d->d_un.d_ptr;
               *dp = &_r_debug;
             }
             break;
@@ -1567,76 +1472,78 @@
         case DT_MIPS_FLAGS:
         case DT_MIPS_BASE_ADDRESS:
         case DT_MIPS_UNREFEXTNO:
-        case DT_MIPS_RWPLT:
-            break;
-
-        case DT_MIPS_PLTGOT:
-#if 0
-            /* not yet... */
-            si->mips_pltgot = (unsigned *)(si->base + *d);
-#endif
             break;
 
         case DT_MIPS_SYMTABNO:
-            si->mips_symtabno = *d;
+            si->mips_symtabno = d->d_un.d_val;
             break;
 
         case DT_MIPS_LOCAL_GOTNO:
-            si->mips_local_gotno = *d;
+            si->mips_local_gotno = d->d_un.d_val;
             break;
 
         case DT_MIPS_GOTSYM:
-            si->mips_gotsym = *d;
+            si->mips_gotsym = d->d_un.d_val;
             break;
 
         default:
-            DEBUG("%5d Unused DT entry: type 0x%08x arg 0x%08x\n",
-                  pid, d[-1], d[0]);
+            DEBUG("Unused DT entry: type 0x%08x arg 0x%08x\n", d->d_tag, d->d_un.d_val);
             break;
 #endif
         }
     }
 
-    DEBUG("%5d si->base = 0x%08x, si->strtab = %p, si->symtab = %p\n",
-           pid, si->base, si->strtab, si->symtab);
+    DEBUG("si->base = 0x%08x, si->strtab = %p, si->symtab = %p\n",
+          si->base, si->strtab, si->symtab);
 
-    if((si->strtab == 0) || (si->symtab == 0)) {
-        DL_ERR("missing essential tables");
-        goto fail;
+    // Sanity checks.
+    if (relocating_linker && needed_count != 0) {
+        DL_ERR("linker cannot have DT_NEEDED dependencies on other libraries");
+        return false;
+    }
+    if (si->nbucket == 0) {
+        DL_ERR("empty/missing DT_HASH in \"%s\" (built with --hash-style=gnu?)", si->name);
+        return false;
+    }
+    if (si->strtab == 0) {
+        DL_ERR("empty/missing DT_STRTAB in \"%s\"", si->name);
+        return false;
+    }
+    if (si->symtab == 0) {
+        DL_ERR("empty/missing DT_SYMTAB in \"%s\"", si->name);
+        return false;
     }
 
     /* if this is the main executable, then load all of the preloads now */
-    if(si->flags & FLAG_EXE) {
-        int i;
-        memset(preloads, 0, sizeof(preloads));
-        for(i = 0; ldpreload_names[i] != NULL; i++) {
-            soinfo *lsi = find_library(ldpreload_names[i]);
-            if(lsi == 0) {
-                strlcpy(tmp_err_buf, linker_get_error(), sizeof(tmp_err_buf));
+    if (si->flags & FLAG_EXE) {
+        memset(gLdPreloads, 0, sizeof(gLdPreloads));
+        for (size_t i = 0; gLdPreloadNames[i] != NULL; i++) {
+            soinfo* lsi = find_library(gLdPreloadNames[i]);
+            if (lsi == NULL) {
+                strlcpy(tmp_err_buf, linker_get_error_buffer(), sizeof(tmp_err_buf));
                 DL_ERR("could not load library \"%s\" needed by \"%s\"; caused by %s",
-                       ldpreload_names[i], si->name, tmp_err_buf);
-                goto fail;
+                       gLdPreloadNames[i], si->name, tmp_err_buf);
+                return false;
             }
-            lsi->refcount++;
-            preloads[i] = lsi;
+            gLdPreloads[i] = lsi;
         }
     }
 
-    /* dynamic_count is an upper bound for the number of needed libs */
-    pneeded = needed = (soinfo**) alloca((1 + dynamic_count) * sizeof(soinfo*));
+    soinfo** needed = (soinfo**) alloca((1 + needed_count) * sizeof(soinfo*));
+    soinfo** pneeded = needed;
 
-    for(d = si->dynamic; *d; d += 2) {
-        if(d[0] == DT_NEEDED){
-            DEBUG("%5d %s needs %s\n", pid, si->name, si->strtab + d[1]);
-            soinfo *lsi = find_library(si->strtab + d[1]);
-            if(lsi == 0) {
-                strlcpy(tmp_err_buf, linker_get_error(), sizeof(tmp_err_buf));
+    for (Elf32_Dyn* d = si->dynamic; d->d_tag != DT_NULL; ++d) {
+        if (d->d_tag == DT_NEEDED) {
+            const char* library_name = si->strtab + d->d_un.d_val;
+            DEBUG("%s needs %s\n", si->name, library_name);
+            soinfo* lsi = find_library(library_name);
+            if (lsi == NULL) {
+                strlcpy(tmp_err_buf, linker_get_error_buffer(), sizeof(tmp_err_buf));
                 DL_ERR("could not load library \"%s\" needed by \"%s\"; caused by %s",
-                       si->strtab + d[1], si->name, tmp_err_buf);
-                goto fail;
+                       library_name, si->name, tmp_err_buf);
+                return false;
             }
             *pneeded++ = lsi;
-            lsi->refcount++;
         }
     }
     *pneeded = NULL;
@@ -1650,29 +1557,31 @@
         if (phdr_table_unprotect_segments(si->phdr, si->phnum, si->load_bias) < 0) {
             DL_ERR("can't unprotect loadable segments for \"%s\": %s",
                    si->name, strerror(errno));
-            goto fail;
+            return false;
         }
     }
 
-    if(si->plt_rel) {
-        DEBUG("[ %5d relocating %s plt ]\n", pid, si->name );
-        if(soinfo_relocate(si, si->plt_rel, si->plt_rel_count, needed))
-            goto fail;
+    if (si->plt_rel != NULL) {
+        DEBUG("[ relocating %s plt ]\n", si->name );
+        if (soinfo_relocate(si, si->plt_rel, si->plt_rel_count, needed)) {
+            return false;
+        }
     }
-    if(si->rel) {
-        DEBUG("[ %5d relocating %s ]\n", pid, si->name );
-        if(soinfo_relocate(si, si->rel, si->rel_count, needed))
-            goto fail;
+    if (si->rel != NULL) {
+        DEBUG("[ relocating %s ]\n", si->name );
+        if (soinfo_relocate(si, si->rel, si->rel_count, needed)) {
+            return false;
+        }
     }
 
 #ifdef ANDROID_MIPS_LINKER
-    if(mips_relocate_got(si, needed)) {
-        goto fail;
+    if (mips_relocate_got(si, needed)) {
+        return false;
     }
 #endif
 
     si->flags |= FLAG_LINKED;
-    DEBUG("[ %5d finished linking %s ]\n", pid, si->name);
+    DEBUG("[ finished linking %s ]\n", si->name);
 
     if (si->has_text_relocations) {
         /* All relocations are done, we can protect our segments back to
@@ -1680,7 +1589,7 @@
         if (phdr_table_protect_segments(si->phdr, si->phnum, si->load_bias) < 0) {
             DL_ERR("can't protect segments for \"%s\": %s",
                    si->name, strerror(errno));
-            goto fail;
+            return false;
         }
     }
 
@@ -1688,62 +1597,16 @@
     if (phdr_table_protect_gnu_relro(si->phdr, si->phnum, si->load_bias) < 0) {
         DL_ERR("can't enable GNU RELRO protection for \"%s\": %s",
                si->name, strerror(errno));
-        goto fail;
+        return false;
     }
 
-    /* If this is a SET?ID program, dup /dev/null to opened stdin,
-       stdout and stderr to close a security hole described in:
-
-    ftp://ftp.freebsd.org/pub/FreeBSD/CERT/advisories/FreeBSD-SA-02:23.stdio.asc
-
-     */
-    if (program_is_setuid) {
+    // If this is a setuid/setgid program, close the security hole described in
+    // ftp://ftp.freebsd.org/pub/FreeBSD/CERT/advisories/FreeBSD-SA-02:23.stdio.asc
+    if (get_AT_SECURE()) {
         nullify_closed_stdio();
     }
     notify_gdb_of_load(si);
-    return 0;
-
-fail:
-    ERROR("failed to link %s\n", si->name);
-    si->flags |= FLAG_ERROR;
-    return -1;
-}
-
-static void parse_path(const char* path, const char* delimiters,
-                       const char** array, char* buf, size_t buf_size, size_t max_count)
-{
-    if (path == NULL) {
-        return;
-    }
-
-    size_t len = strlcpy(buf, path, buf_size);
-
-    size_t i = 0;
-    char* buf_p = buf;
-    while (i < max_count && (array[i] = strsep(&buf_p, delimiters))) {
-        if (*array[i] != '\0') {
-            ++i;
-        }
-    }
-
-    // Forget the last path if we had to truncate; this occurs if the 2nd to
-    // last char isn't '\0' (i.e. wasn't originally a delimiter).
-    if (i > 0 && len >= buf_size && buf[buf_size - 2] != '\0') {
-        array[i - 1] = NULL;
-    } else {
-        array[i] = NULL;
-    }
-}
-
-static void parse_LD_LIBRARY_PATH(const char* path) {
-    parse_path(path, ":", ldpaths,
-               ldpaths_buf, sizeof(ldpaths_buf), LDPATH_MAX);
-}
-
-static void parse_LD_PRELOAD(const char* path) {
-    // We have historically supported ':' as well as ' ' in LD_PRELOAD.
-    parse_path(path, " :", ldpreload_names,
-               ldpreloads_buf, sizeof(ldpreloads_buf), LDPRELOAD_MAX);
+    return true;
 }
 
 /*
@@ -1751,20 +1614,8 @@
  * fixed it's own GOT. It is safe to make references to externs
  * and other non-local data at this point.
  */
-static unsigned __linker_init_post_relocation(unsigned **elfdata, unsigned linker_base)
-{
-    static soinfo linker_soinfo;
-
-    int argc = (int) *elfdata;
-    char **argv = (char**) (elfdata + 1);
-    unsigned *vecs = (unsigned*) (argv + argc + 1);
-    unsigned *v;
-    soinfo *si;
-    int i;
-    const char *ldpath_env = NULL;
-    const char *ldpreload_env = NULL;
-
-    /* NOTE: we store the elfdata pointer on a special location
+static unsigned __linker_init_post_relocation(KernelArgumentBlock& args, unsigned linker_base) {
+    /* NOTE: we store the args pointer on a special location
      *       of the temporary TLS area in order to pass it to
      *       the C Library's runtime initializer.
      *
@@ -1772,62 +1623,38 @@
      *       to point to a different location to ensure that no other
      *       shared library constructor can access it.
      */
-    __libc_init_tls(elfdata);
-
-    pid = getpid();
+  __libc_init_tls(args);
 
 #if TIMING
     struct timeval t0, t1;
     gettimeofday(&t0, 0);
 #endif
 
-    /* Initialize environment functions, and get to the ELF aux vectors table */
-    vecs = linker_env_init(vecs);
+    // Initialize environment functions, and get to the ELF aux vectors table.
+    linker_env_init(args);
 
-    /* Check auxv for AT_SECURE first to see if program is setuid, setgid,
-       has file caps, or caused a SELinux/AppArmor domain transition. */
-    for (v = vecs; v[0]; v += 2) {
-        if (v[0] == AT_SECURE) {
-            /* kernel told us whether to enable secure mode */
-            program_is_setuid = v[1];
-            goto sanitize;
-        }
+    debuggerd_init();
+
+    // Get a few environment variables.
+    const char* LD_DEBUG = linker_env_get("LD_DEBUG");
+    if (LD_DEBUG != NULL) {
+      gLdDebugVerbosity = atoi(LD_DEBUG);
     }
 
-    /* Kernel did not provide AT_SECURE - fall back on legacy test. */
-    program_is_setuid = (getuid() != geteuid()) || (getgid() != getegid());
-
-sanitize:
-    /* Sanitize environment if we're loading a setuid program */
-    if (program_is_setuid) {
-        linker_env_secure();
-    }
-
-    debugger_init();
-
-    /* Get a few environment variables */
-    {
-#if LINKER_DEBUG
-        const char* env;
-        env = linker_env_get("DEBUG"); /* XXX: TODO: Change to LD_DEBUG */
-        if (env)
-            debug_verbosity = atoi(env);
-#endif
-
-        /* Normally, these are cleaned by linker_env_secure, but the test
-         * against program_is_setuid doesn't cost us anything */
-        if (!program_is_setuid) {
-            ldpath_env = linker_env_get("LD_LIBRARY_PATH");
-            ldpreload_env = linker_env_get("LD_PRELOAD");
-        }
+    // Normally, these are cleaned by linker_env_init, but the test
+    // doesn't cost us anything.
+    const char* ldpath_env = NULL;
+    const char* ldpreload_env = NULL;
+    if (!get_AT_SECURE()) {
+      ldpath_env = linker_env_get("LD_LIBRARY_PATH");
+      ldpreload_env = linker_env_get("LD_PRELOAD");
     }
 
     INFO("[ android linker & debugger ]\n");
-    DEBUG("%5d elfdata @ 0x%08x\n", pid, (unsigned)elfdata);
 
-    si = soinfo_alloc(argv[0]);
-    if(si == 0) {
-        exit(-1);
+    soinfo* si = soinfo_alloc(args.argv[0]);
+    if (si == NULL) {
+        exit(EXIT_FAILURE);
     }
 
     /* bootstrap the link map, the main exe always needs to be first */
@@ -1835,106 +1662,95 @@
     link_map* map = &(si->linkmap);
 
     map->l_addr = 0;
-    map->l_name = argv[0];
+    map->l_name = args.argv[0];
     map->l_prev = NULL;
     map->l_next = NULL;
 
     _r_debug.r_map = map;
     r_debug_tail = map;
 
-        /* gdb expects the linker to be in the debug shared object list.
-         * Without this, gdb has trouble locating the linker's ".text"
-         * and ".plt" sections. Gdb could also potentially use this to
-         * relocate the offset of our exported 'rtld_db_dlactivity' symbol.
-         * Don't use soinfo_alloc(), because the linker shouldn't
-         * be on the soinfo list.
-         */
-    strlcpy((char*) linker_soinfo.name, "/system/bin/linker", sizeof linker_soinfo.name);
-    linker_soinfo.flags = 0;
-    linker_soinfo.base = linker_base;
-    /*
-     * Set the dynamic field in the link map otherwise gdb will complain with
-     * the following:
-     *   warning: .dynamic section for "/system/bin/linker" is not at the
-     *   expected address (wrong library or version mismatch?)
+    /* gdb expects the linker to be in the debug shared object list.
+     * Without this, gdb has trouble locating the linker's ".text"
+     * and ".plt" sections. Gdb could also potentially use this to
+     * relocate the offset of our exported 'rtld_db_dlactivity' symbol.
+     * Don't use soinfo_alloc(), because the linker shouldn't
+     * be on the soinfo list.
      */
-    Elf32_Ehdr *elf_hdr = (Elf32_Ehdr *) linker_base;
-    Elf32_Phdr *phdr =
-        (Elf32_Phdr *)((unsigned char *) linker_base + elf_hdr->e_phoff);
-    phdr_table_get_dynamic_section(phdr, elf_hdr->e_phnum, linker_base,
-                                   &linker_soinfo.dynamic, NULL);
-    insert_soinfo_into_debug_map(&linker_soinfo);
+    {
+        static soinfo linker_soinfo;
+        strlcpy(linker_soinfo.name, "/system/bin/linker", sizeof(linker_soinfo.name));
+        linker_soinfo.flags = 0;
+        linker_soinfo.base = linker_base;
 
-    /* extract information passed from the kernel */
-    while(vecs[0] != 0){
-        switch(vecs[0]){
-        case AT_PHDR:
-            si->phdr = (Elf32_Phdr*) vecs[1];
-            break;
-        case AT_PHNUM:
-            si->phnum = (int) vecs[1];
-            break;
-        case AT_ENTRY:
-            si->entry = vecs[1];
-            break;
-        }
-        vecs += 2;
+        /*
+         * Set the dynamic field in the link map otherwise gdb will complain with
+         * the following:
+         *   warning: .dynamic section for "/system/bin/linker" is not at the
+         *   expected address (wrong library or version mismatch?)
+         */
+        Elf32_Ehdr *elf_hdr = (Elf32_Ehdr *) linker_base;
+        Elf32_Phdr *phdr = (Elf32_Phdr*)((unsigned char*) linker_base + elf_hdr->e_phoff);
+        phdr_table_get_dynamic_section(phdr, elf_hdr->e_phnum, linker_base,
+                                       &linker_soinfo.dynamic, NULL, NULL);
+        insert_soinfo_into_debug_map(&linker_soinfo);
     }
 
+    // Extract information passed from the kernel.
+    si->phdr = reinterpret_cast<Elf32_Phdr*>(args.getauxval(AT_PHDR));
+    si->phnum = args.getauxval(AT_PHNUM);
+    si->entry = args.getauxval(AT_ENTRY);
+
     /* Compute the value of si->base. We can't rely on the fact that
      * the first entry is the PHDR because this will not be true
      * for certain executables (e.g. some in the NDK unit test suite)
      */
-    int nn;
     si->base = 0;
     si->size = phdr_table_get_load_size(si->phdr, si->phnum);
     si->load_bias = 0;
-    for ( nn = 0; nn < si->phnum; nn++ ) {
-        if (si->phdr[nn].p_type == PT_PHDR) {
-            si->load_bias = (Elf32_Addr)si->phdr - si->phdr[nn].p_vaddr;
-            si->base = (Elf32_Addr) si->phdr - si->phdr[nn].p_offset;
-            break;
-        }
+    for (int i = 0; i < si->phnum; ++i) {
+      if (si->phdr[i].p_type == PT_PHDR) {
+        si->load_bias = reinterpret_cast<Elf32_Addr>(si->phdr) - si->phdr[i].p_vaddr;
+        si->base = reinterpret_cast<Elf32_Addr>(si->phdr) - si->phdr[i].p_offset;
+        break;
+      }
     }
-    si->dynamic = (unsigned *)-1;
+    si->dynamic = NULL;
     si->refcount = 1;
 
     // Use LD_LIBRARY_PATH and LD_PRELOAD (but only if we aren't setuid/setgid).
     parse_LD_LIBRARY_PATH(ldpath_env);
     parse_LD_PRELOAD(ldpreload_env);
 
-    if(soinfo_link_image(si)) {
-        char errmsg[] = "CANNOT LINK EXECUTABLE\n";
-        write(2, __linker_dl_err_buf, strlen(__linker_dl_err_buf));
-        write(2, errmsg, sizeof(errmsg));
-        exit(-1);
-    }
-
-    soinfo_call_preinit_constructors(si);
-
-    for(i = 0; preloads[i] != NULL; i++) {
-        soinfo_call_constructors(preloads[i]);
-    }
-
-    soinfo_call_constructors(si);
-
-#if ALLOW_SYMBOLS_FROM_MAIN
-    /* Set somain after we've loaded all the libraries in order to prevent
-     * linking of symbols back to the main image, which is not set up at that
-     * point yet.
-     */
     somain = si;
-#endif
+
+    if (!soinfo_link_image(si)) {
+        __libc_format_fd(2, "CANNOT LINK EXECUTABLE: %s\n", linker_get_error_buffer());
+        exit(EXIT_FAILURE);
+    }
+
+    si->CallPreInitConstructors();
+
+    for (size_t i = 0; gLdPreloads[i] != NULL; ++i) {
+        gLdPreloads[i]->CallConstructors();
+    }
+
+    /* After the link_image, the si->load_bias is initialized.
+     * For so lib, the map->l_addr will be updated in notify_gdb_of_load.
+     * We need to update this value for so exe here. So Unwind_Backtrace
+     * for some arch like x86 could work correctly within so exe.
+     */
+    map->l_addr = si->load_bias;
+    si->CallConstructors();
 
 #if TIMING
     gettimeofday(&t1,NULL);
-    PRINT("LINKER TIME: %s: %d microseconds\n", argv[0], (int) (
+    PRINT("LINKER TIME: %s: %d microseconds\n", args.argv[0], (int) (
                (((long long)t1.tv_sec * 1000000LL) + (long long)t1.tv_usec) -
                (((long long)t0.tv_sec * 1000000LL) + (long long)t0.tv_usec)
                ));
 #endif
 #if STATS
-    PRINT("RELO STATS: %s: %d abs, %d rel, %d copy, %d symbol\n", argv[0],
+    PRINT("RELO STATS: %s: %d abs, %d rel, %d copy, %d symbol\n", args.argv[0],
            linker_stats.count[kRelocAbsolute],
            linker_stats.count[kRelocRelative],
            linker_stats.count[kRelocCopy],
@@ -1945,16 +1761,18 @@
         unsigned n;
         unsigned i;
         unsigned count = 0;
-        for(n = 0; n < 4096; n++){
-            if(bitmask[n]){
+        for (n = 0; n < 4096; n++) {
+            if (bitmask[n]) {
                 unsigned x = bitmask[n];
-                for(i = 0; i < 8; i++){
-                    if(x & 1) count++;
+                for (i = 0; i < 8; i++) {
+                    if (x & 1) {
+                        count++;
+                    }
                     x >>= 1;
                 }
             }
         }
-        PRINT("PAGES MODIFIED: %s: %d (%dKB)\n", argv[0], count, count * 4);
+        PRINT("PAGES MODIFIED: %s: %d (%dKB)\n", args.argv[0], count, count * 4);
     }
 #endif
 
@@ -1962,36 +1780,10 @@
     fflush(stdout);
 #endif
 
-    TRACE("[ %5d Ready to execute '%s' @ 0x%08x ]\n", pid, si->name,
-          si->entry);
+    TRACE("[ Ready to execute '%s' @ 0x%08x ]\n", si->name, si->entry);
     return si->entry;
 }
 
-/*
- * Find the value of AT_BASE passed to us by the kernel. This is the load
- * location of the linker.
- */
-static unsigned find_linker_base(unsigned **elfdata) {
-    int argc = (int) *elfdata;
-    char **argv = (char**) (elfdata + 1);
-    unsigned *vecs = (unsigned*) (argv + argc + 1);
-    while (vecs[0] != 0) {
-        vecs++;
-    }
-
-    /* The end of the environment block is marked by two NULL pointers */
-    vecs++;
-
-    while(vecs[0]) {
-        if (vecs[0] == AT_BASE) {
-            return vecs[1];
-        }
-        vecs += 2;
-    }
-
-    return 0; // should never happen
-}
-
 /* Compute the load-bias of an existing executable. This shall only
  * be used to compute the load bias of an executable or shared library
  * that was loaded by the kernel itself.
@@ -2027,34 +1819,41 @@
  * relocations, any attempt to reference an extern variable, extern
  * function, or other GOT reference will generate a segfault.
  */
-extern "C" unsigned __linker_init(unsigned **elfdata) {
-    unsigned linker_addr = find_linker_base(elfdata);
-    Elf32_Ehdr *elf_hdr = (Elf32_Ehdr *) linker_addr;
-    Elf32_Phdr *phdr =
-        (Elf32_Phdr *)((unsigned char *) linker_addr + elf_hdr->e_phoff);
+extern "C" unsigned __linker_init(void* raw_args) {
+  KernelArgumentBlock args(raw_args);
 
-    soinfo linker_so;
-    memset(&linker_so, 0, sizeof(soinfo));
+  unsigned linker_addr = args.getauxval(AT_BASE);
 
-    linker_so.base = linker_addr;
-    linker_so.size = phdr_table_get_load_size(phdr, elf_hdr->e_phnum);
-    linker_so.load_bias = get_elf_exec_load_bias(elf_hdr);
-    linker_so.dynamic = (unsigned *) -1;
-    linker_so.phdr = phdr;
-    linker_so.phnum = elf_hdr->e_phnum;
-    linker_so.flags |= FLAG_LINKER;
+  Elf32_Ehdr *elf_hdr = (Elf32_Ehdr*) linker_addr;
+  Elf32_Phdr *phdr = (Elf32_Phdr*)((unsigned char*) linker_addr + elf_hdr->e_phoff);
 
-    if (soinfo_link_image(&linker_so)) {
-        // It would be nice to print an error message, but if the linker
-        // can't link itself, there's no guarantee that we'll be able to
-        // call write() (because it involves a GOT reference).
-        //
-        // This situation should never occur unless the linker itself
-        // is corrupt.
-        exit(-1);
-    }
+  soinfo linker_so;
+  memset(&linker_so, 0, sizeof(soinfo));
 
-    // We have successfully fixed our own relocations. It's safe to run
-    // the main part of the linker now.
-    return __linker_init_post_relocation(elfdata, linker_addr);
+  linker_so.base = linker_addr;
+  linker_so.size = phdr_table_get_load_size(phdr, elf_hdr->e_phnum);
+  linker_so.load_bias = get_elf_exec_load_bias(elf_hdr);
+  linker_so.dynamic = NULL;
+  linker_so.phdr = phdr;
+  linker_so.phnum = elf_hdr->e_phnum;
+  linker_so.flags |= FLAG_LINKER;
+
+  if (!soinfo_link_image(&linker_so)) {
+    // It would be nice to print an error message, but if the linker
+    // can't link itself, there's no guarantee that we'll be able to
+    // call write() (because it involves a GOT reference).
+    //
+    // This situation should never occur unless the linker itself
+    // is corrupt.
+    exit(EXIT_FAILURE);
+  }
+
+  // We have successfully fixed our own relocations. It's safe to run
+  // the main part of the linker now.
+  unsigned start_address = __linker_init_post_relocation(args, linker_addr);
+
+  set_soinfo_pool_protection(PROT_READ);
+
+  // Return the address that the calling assembly stub should jump to.
+  return start_address;
 }
diff --git a/linker/linker.h b/linker/linker.h
index 8ed433c..cef6905 100644
--- a/linker/linker.h
+++ b/linker/linker.h
@@ -34,206 +34,158 @@
 #include <elf.h>
 #include <sys/exec_elf.h>
 
-#ifdef __cplusplus
-extern "C" {
-#endif
 #include <link.h>
 
-#undef PAGE_MASK
-#undef PAGE_SIZE
-#define PAGE_SIZE 4096
-#define PAGE_MASK (PAGE_SIZE-1)
+#include <private/debug_format.h>
 
-/* Convenience macros to make page address/offset computations more explicit */
+#define DL_ERR(fmt, x...) \
+    do { \
+      __libc_format_buffer(linker_get_error_buffer(), linker_get_error_buffer_size(), fmt, ##x); \
+      /* If LD_DEBUG is set high enough, log every dlerror(3) message. */ \
+      DEBUG("%s\n", linker_get_error_buffer()); \
+    } while(0)
 
-/* Returns the address of the page starting at address 'x' */
-#define PAGE_START(x)  ((x) & ~PAGE_MASK)
+// Returns the address of the page containing address 'x'.
+#define PAGE_START(x)  ((x) & PAGE_MASK)
 
-/* Returns the offset of address 'x' in its memory page, i.e. this is the
- * same than 'x' - PAGE_START(x) */
-#define PAGE_OFFSET(x) ((x) & PAGE_MASK)
+// Returns the offset of address 'x' in its page.
+#define PAGE_OFFSET(x) ((x) & ~PAGE_MASK)
 
-/* Returns the address of the next page after address 'x', unless 'x' is
- * itself at the start of a page. Equivalent to:
- *
- *  (x == PAGE_START(x)) ? x : PAGE_START(x)+PAGE_SIZE
- */
+// Returns the address of the next page after address 'x', unless 'x' is
+// itself at the start of a page.
 #define PAGE_END(x)    PAGE_START((x) + (PAGE_SIZE-1))
 
-void debugger_init();
+// Magic shared structures that GDB knows about.
 
-/* magic shared structures that GDB knows about */
-
-struct link_map
-{
-    uintptr_t l_addr;
-    char * l_name;
-    uintptr_t l_ld;
-    struct link_map * l_next;
-    struct link_map * l_prev;
+struct link_map {
+  uintptr_t l_addr;
+  char*  l_name;
+  uintptr_t l_ld;
+  struct link_map* l_next;
+  struct link_map* l_prev;
 };
 
 // Values for r_debug->state
 enum {
-    RT_CONSISTENT,
-    RT_ADD,
-    RT_DELETE
+  RT_CONSISTENT,
+  RT_ADD,
+  RT_DELETE
 };
 
-struct r_debug
-{
-    int32_t r_version;
-    struct link_map * r_map;
-    void (*r_brk)(void);
-    int32_t r_state;
-    uintptr_t r_ldbase;
+struct r_debug {
+  int32_t r_version;
+  struct link_map* r_map;
+  void (*r_brk)(void);
+  int32_t r_state;
+  uintptr_t r_ldbase;
 };
 
-typedef struct soinfo soinfo;
-
 #define FLAG_LINKED     0x00000001
-#define FLAG_ERROR      0x00000002
 #define FLAG_EXE        0x00000004 // The main executable
 #define FLAG_LINKER     0x00000010 // The linker itself
 
 #define SOINFO_NAME_LEN 128
 
-struct soinfo
-{
-    char name[SOINFO_NAME_LEN];
-    const Elf32_Phdr *phdr;
-    int phnum;
-    unsigned entry;
-    unsigned base;
-    unsigned size;
+struct soinfo {
+  char name[SOINFO_NAME_LEN];
+  const Elf32_Phdr* phdr;
+  int phnum;
+  unsigned entry;
+  unsigned base;
+  unsigned size;
 
-    int unused;  // DO NOT USE, maintained for compatibility.
+  int unused;  // DO NOT USE, maintained for compatibility.
 
-    unsigned *dynamic;
+  Elf32_Dyn* dynamic;
 
-    unsigned unused2; // DO NOT USE, maintained for compatibility
-    unsigned unused3; // DO NOT USE, maintained for compatibility
+  unsigned unused2; // DO NOT USE, maintained for compatibility
+  unsigned unused3; // DO NOT USE, maintained for compatibility
 
-    soinfo *next;
-    unsigned flags;
+  soinfo* next;
+  unsigned flags;
 
-    const char *strtab;
-    Elf32_Sym *symtab;
+  const char* strtab;
+  Elf32_Sym* symtab;
 
-    unsigned nbucket;
-    unsigned nchain;
-    unsigned *bucket;
-    unsigned *chain;
+  unsigned nbucket;
+  unsigned nchain;
+  unsigned* bucket;
+  unsigned* chain;
 
-    unsigned *plt_got;
+  unsigned* plt_got;
 
-    Elf32_Rel *plt_rel;
-    unsigned plt_rel_count;
+  Elf32_Rel* plt_rel;
+  unsigned plt_rel_count;
 
-    Elf32_Rel *rel;
-    unsigned rel_count;
+  Elf32_Rel* rel;
+  unsigned rel_count;
 
-    unsigned *preinit_array;
-    unsigned preinit_array_count;
+  unsigned* preinit_array;
+  unsigned preinit_array_count;
 
-    unsigned *init_array;
-    unsigned init_array_count;
-    unsigned *fini_array;
-    unsigned fini_array_count;
+  unsigned* init_array;
+  unsigned init_array_count;
+  unsigned* fini_array;
+  unsigned fini_array_count;
 
-    void (*init_func)(void);
-    void (*fini_func)(void);
+  void (*init_func)();
+  void (*fini_func)();
 
 #if defined(ANDROID_ARM_LINKER)
-    /* ARM EABI section used for stack unwinding. */
-    unsigned *ARM_exidx;
-    unsigned ARM_exidx_count;
+  // ARM EABI section used for stack unwinding.
+  unsigned* ARM_exidx;
+  unsigned ARM_exidx_count;
 #elif defined(ANDROID_MIPS_LINKER)
-#if 0
-     /* not yet */
-     unsigned *mips_pltgot
+  unsigned mips_symtabno;
+  unsigned mips_local_gotno;
+  unsigned mips_gotsym;
 #endif
-     unsigned mips_symtabno;
-     unsigned mips_local_gotno;
-     unsigned mips_gotsym;
-#endif /* ANDROID_*_LINKER */
 
-    unsigned refcount;
-    struct link_map linkmap;
+  unsigned refcount;
+  struct link_map linkmap;
 
-    int constructors_called;
+  bool constructors_called;
 
-    /* When you read a virtual address from the ELF file, add this
-     * value to get the corresponding address in the process' address space */
-    Elf32_Addr load_bias;
-    int has_text_relocations;
+  // When you read a virtual address from the ELF file, add this
+  // value to get the corresponding address in the process' address space.
+  Elf32_Addr load_bias;
+
+  bool has_text_relocations;
+  bool has_DT_SYMBOLIC;
+
+  void CallConstructors();
+  void CallDestructors();
+  void CallPreInitConstructors();
+
+ private:
+  void CallArray(const char* array_name, unsigned* array, int count, bool reverse);
+  void CallFunction(const char* function_name, void (*function)());
 };
 
-
 extern soinfo libdl_info;
 
-
-#include <asm/elf.h>
-
-#if defined(ANDROID_ARM_LINKER)
-
-// These aren't defined in <arch-arm/asm/elf.h>.
-#define R_ARM_REL32      3
-#define R_ARM_COPY       20
-#define R_ARM_GLOB_DAT   21
-#define R_ARM_JUMP_SLOT  22
-#define R_ARM_RELATIVE   23
-
-#elif defined(ANDROID_MIPS_LINKER)
-
-// These aren't defined in <arch-arm/mips/elf.h>.
-#define R_MIPS_JUMP_SLOT       127
-
-#define DT_MIPS_PLTGOT         0x70000032
-#define DT_MIPS_RWPLT          0x70000034
-
-#elif defined(ANDROID_X86_LINKER)
-
-// x86 has everything it needs in <arch-arm/x86/elf.h>.
-
-#endif /* ANDROID_*_LINKER */
-
-#ifndef DT_INIT_ARRAY
-#define DT_INIT_ARRAY      25
-#endif
-
-#ifndef DT_FINI_ARRAY
-#define DT_FINI_ARRAY      26
-#endif
-
-#ifndef DT_INIT_ARRAYSZ
-#define DT_INIT_ARRAYSZ    27
-#endif
-
-#ifndef DT_FINI_ARRAYSZ
-#define DT_FINI_ARRAYSZ    28
-#endif
-
+// These aren't defined in <sys/exec_elf.h>.
 #ifndef DT_PREINIT_ARRAY
 #define DT_PREINIT_ARRAY   32
 #endif
-
 #ifndef DT_PREINIT_ARRAYSZ
 #define DT_PREINIT_ARRAYSZ 33
 #endif
 
-soinfo *find_library(const char *name);
-Elf32_Sym *lookup(const char *name, soinfo **found, soinfo *start);
-soinfo *find_containing_library(const void *addr);
-const char *linker_get_error(void);
+void do_android_update_LD_LIBRARY_PATH(const char* ld_library_path);
+soinfo* do_dlopen(const char* name, int flags);
+int do_dlclose(soinfo* si);
 
-int soinfo_unload(soinfo* si);
-Elf32_Sym *soinfo_find_symbol(soinfo* si, const void *addr);
-Elf32_Sym *soinfo_lookup(soinfo *si, const char *name);
-void soinfo_call_constructors(soinfo *si);
+Elf32_Sym* dlsym_linear_lookup(const char* name, soinfo** found, soinfo* start);
+soinfo* find_containing_library(const void* addr);
 
-#ifdef __cplusplus
-};
-#endif
+Elf32_Sym* dladdr_find_symbol(soinfo* si, const void* addr);
+Elf32_Sym* dlsym_handle_lookup(soinfo* si, const char* name);
+
+void debuggerd_init();
+extern "C" void notify_gdb_of_libraries();
+
+char* linker_get_error_buffer();
+size_t linker_get_error_buffer_size();
 
 #endif
diff --git a/linker/linker_debug.h b/linker/linker_debug.h
index 48a7abf..6aeb9ac 100644
--- a/linker/linker_debug.h
+++ b/linker/linker_debug.h
@@ -31,14 +31,16 @@
 
 #include <stdio.h>
 
-#ifndef LINKER_DEBUG
-#error LINKER_DEBUG should be defined to either 1 or 0 in Android.mk
-#endif
+// You can increase the verbosity of debug traces by defining the LD_DEBUG
+// environment variable to a numeric value from 0 to 2 (corresponding to
+// INFO, TRACE, and DEBUG calls in the source). This will only
+// affect new processes being launched.
 
-/* set LINKER_DEBUG_TO_LOG to 1 to send the logs to logcat,
- * or 0 to use stdout instead.
- */
+// By default, traces are sent to logcat, with the "linker" tag. You can
+// change this to go to stdout instead by setting the definition of
+// LINKER_DEBUG_TO_LOG to 0.
 #define LINKER_DEBUG_TO_LOG  1
+
 #define TRACE_DEBUG          1
 #define DO_TRACE_LOOKUP      1
 #define DO_TRACE_RELO        1
@@ -56,47 +58,25 @@
 
 /*********************************************************************/
 
-/* Only use printf() during debugging.  We have seen occasional memory
- * corruption when the linker uses printf().
- */
-#if LINKER_DEBUG
-#include "linker_format.h"
+#include <private/debug_format.h>
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+__LIBC_HIDDEN__ extern int gLdDebugVerbosity;
 
-extern int debug_verbosity;
 #if LINKER_DEBUG_TO_LOG
-extern int format_log(int, const char *, const char *, ...);
 #define _PRINTVF(v,x...)                                        \
     do {                                                          \
-        if (debug_verbosity > (v)) format_log(5-(v),"linker",x);  \
+        if (gLdDebugVerbosity > (v)) __libc_format_log(5-(v),"linker",x);  \
     } while (0)
 #else /* !LINKER_DEBUG_TO_LOG */
-extern int format_fd(int, const char *, ...);
 #define _PRINTVF(v,x...)                           \
     do {                                             \
-        if (debug_verbosity > (v)) format_fd(1, x);  \
+        if (gLdDebugVerbosity > (v)) __libc_format_fd(1, x);  \
     } while (0)
 #endif /* !LINKER_DEBUG_TO_LOG */
 
-#ifdef __cplusplus
-};
-#endif
-
-#else /* !LINKER_DEBUG */
-#define _PRINTVF(v,f,x...)   do {} while(0)
-#endif /* LINKER_DEBUG */
-
 #define PRINT(x...)          _PRINTVF(-1, x)
 #define INFO(x...)           _PRINTVF(0, x)
 #define TRACE(x...)          _PRINTVF(1, x)
-#define WARN(fmt,args...)    \
-        _PRINTVF(-1, "%s:%d| WARNING: " fmt, __FILE__, __LINE__, ## args)
-#define ERROR(fmt,args...)    \
-        _PRINTVF(-1, "%s:%d| ERROR: " fmt, __FILE__, __LINE__, ## args)
-
 
 #if TRACE_DEBUG
 #define DEBUG(x...)          _PRINTVF(2, "DEBUG: " x)
@@ -104,26 +84,6 @@
 #define DEBUG(x...)          do {} while (0)
 #endif /* TRACE_DEBUG */
 
-#if LINKER_DEBUG
 #define TRACE_TYPE(t,x...)   do { if (DO_TRACE_##t) { TRACE(x); } } while (0)
-#else  /* !LINKER_DEBUG */
-#define TRACE_TYPE(t,x...)   do {} while (0)
-#endif /* LINKER_DEBUG */
-
-#if TIMING
-#undef WARN
-#define WARN(x...)           do {} while (0)
-#endif /* TIMING */
-
-#define DEBUG_DUMP_PHDR(phdr, name, pid) do { \
-        DEBUG("%5d %s (phdr = 0x%08x)\n", (pid), (name), (unsigned)(phdr));   \
-        DEBUG("\t\tphdr->offset   = 0x%08x\n", (unsigned)((phdr)->p_offset)); \
-        DEBUG("\t\tphdr->p_vaddr  = 0x%08x\n", (unsigned)((phdr)->p_vaddr));  \
-        DEBUG("\t\tphdr->p_paddr  = 0x%08x\n", (unsigned)((phdr)->p_paddr));  \
-        DEBUG("\t\tphdr->p_filesz = 0x%08x\n", (unsigned)((phdr)->p_filesz)); \
-        DEBUG("\t\tphdr->p_memsz  = 0x%08x\n", (unsigned)((phdr)->p_memsz));  \
-        DEBUG("\t\tphdr->p_flags  = 0x%08x\n", (unsigned)((phdr)->p_flags));  \
-        DEBUG("\t\tphdr->p_align  = 0x%08x\n", (unsigned)((phdr)->p_align));  \
-    } while (0)
 
 #endif /* _LINKER_DEBUG_H_ */
diff --git a/linker/linker_environ.c b/linker/linker_environ.c
deleted file mode 100644
index fadcb60..0000000
--- a/linker/linker_environ.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include "linker_environ.h"
-#include <stddef.h>
-
-static char** _envp;
-
-/* Returns 1 if 'str' points to a valid environment variable definition.
- * For now, we check that:
- *  - It is smaller than MAX_ENV_LEN (to detect non-zero terminated strings)
- *  - It contains at least one equal sign that is not the first character
- */
-static int
-_is_valid_definition(const char*  str)
-{
-    int   pos = 0;
-    int   first_equal_pos = -1;
-
-    /* According to its sources, the kernel uses 32*PAGE_SIZE by default
-     * as the maximum size for an env. variable definition.
-     */
-    const int MAX_ENV_LEN = 32*4096;
-
-    if (str == NULL)
-        return 0;
-
-    /* Parse the string, looking for the first '=' there, and its size */
-    do {
-        if (str[pos] == '\0')
-            break;
-        if (str[pos] == '=' && first_equal_pos < 0)
-            first_equal_pos = pos;
-        pos++;
-    } while (pos < MAX_ENV_LEN);
-
-    if (pos >= MAX_ENV_LEN)  /* Too large */
-        return 0;
-
-    if (first_equal_pos < 1)  /* No equal sign, or it is the first character */
-        return 0;
-
-    return 1;
-}
-
-unsigned*
-linker_env_init(unsigned* vecs)
-{
-    /* Store environment pointer - can't be NULL */
-    _envp = (char**) vecs;
-
-    /* Skip over all definitions */
-    while (vecs[0] != 0)
-        vecs++;
-    /* The end of the environment block is marked by two NULL pointers */
-    vecs++;
-
-    /* As a sanity check, we're going to remove all invalid variable
-     * definitions from the environment array.
-     */
-    {
-        char** readp  = _envp;
-        char** writep = _envp;
-        for ( ; readp[0] != NULL; readp++ ) {
-            if (!_is_valid_definition(readp[0]))
-                continue;
-            writep[0] = readp[0];
-            writep++;
-        }
-        writep[0] = NULL;
-    }
-
-    /* Return the address of the aux vectors table */
-    return vecs;
-}
-
-/* Check if the environment variable definition at 'envstr'
- * starts with '<name>=', and if so return the address of the
- * first character after the equal sign. Otherwise return NULL.
- */
-static char*
-env_match(char* envstr, const char* name)
-{
-    size_t  cnt = 0;
-
-    while (envstr[cnt] == name[cnt] && name[cnt] != '\0')
-        cnt++;
-
-    if (name[cnt] == '\0' && envstr[cnt] == '=')
-        return envstr + cnt + 1;
-
-    return NULL;
-}
-
-#define MAX_ENV_LEN  (16*4096)
-
-const char*
-linker_env_get(const char* name)
-{
-    char** readp = _envp;
-
-    if (name == NULL || name[0] == '\0')
-        return NULL;
-
-    for ( ; readp[0] != NULL; readp++ ) {
-        char* val = env_match(readp[0], name);
-        if (val != NULL) {
-            /* Return NULL for empty strings, or if it is too large */
-            if (val[0] == '\0')
-                val = NULL;
-            return val;
-        }
-    }
-    return NULL;
-}
-
-
-void
-linker_env_unset(const char* name)
-{
-    char**  readp = _envp;
-    char**  writep = readp;
-
-    if (name == NULL || name[0] == '\0')
-        return;
-
-    for ( ; readp[0] != NULL; readp++ ) {
-        if (env_match(readp[0], name))
-            continue;
-        writep[0] = readp[0];
-        writep++;
-    }
-    /* end list with a NULL */
-    writep[0] = NULL;
-}
-
-
-
-/* Remove unsafe environment variables. This should be used when
- * running setuid programs. */
-void
-linker_env_secure(void)
-{
-    /* The same list than GLibc at this point */
-    static const char* const unsec_vars[] = {
-        "GCONV_PATH",
-        "GETCONF_DIR",
-        "HOSTALIASES",
-        "LD_AUDIT",
-        "LD_DEBUG",
-        "LD_DEBUG_OUTPUT",
-        "LD_DYNAMIC_WEAK",
-        "LD_LIBRARY_PATH",
-        "LD_ORIGIN_PATH",
-        "LD_PRELOAD",
-        "LD_PROFILE",
-        "LD_SHOW_AUXV",
-        "LD_USE_LOAD_BIAS",
-        "LOCALDOMAIN",
-        "LOCPATH",
-        "MALLOC_TRACE",
-        "MALLOC_CHECK_",
-        "NIS_PATH",
-        "NLSPATH",
-        "RESOLV_HOST_CONF",
-        "RES_OPTIONS",
-        "TMPDIR",
-        "TZDIR",
-        "LD_AOUT_LIBRARY_PATH",
-        "LD_AOUT_PRELOAD",
-        NULL
-    };
-
-    int count;
-    for (count = 0; unsec_vars[count] != NULL; count++) {
-        linker_env_unset(unsec_vars[count]);
-    }
-}
diff --git a/linker/linker_environ.cpp b/linker/linker_environ.cpp
new file mode 100644
index 0000000..edc659a
--- /dev/null
+++ b/linker/linker_environ.cpp
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "linker_environ.h"
+
+#include <linux/auxvec.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <private/KernelArgumentBlock.h>
+
+static char** _envp;
+static bool _AT_SECURE_value = true;
+
+bool get_AT_SECURE() {
+  return _AT_SECURE_value;
+}
+
+static void __init_AT_SECURE(KernelArgumentBlock& args) {
+  // Check auxv for AT_SECURE first to see if program is setuid, setgid,
+  // has file caps, or caused a SELinux/AppArmor domain transition.
+  bool kernel_supplied_AT_SECURE;
+  _AT_SECURE_value = args.getauxval(AT_SECURE, &kernel_supplied_AT_SECURE);
+
+  // We don't support ancient kernels.
+  if (!kernel_supplied_AT_SECURE) {
+    const char* msg = "FATAL: kernel did not supply AT_SECURE\n";
+    write(2, msg, strlen(msg));
+    exit(EXIT_FAILURE);
+  }
+}
+
+// Check if the environment variable definition at 'envstr'
+// starts with '<name>=', and if so return the address of the
+// first character after the equal sign. Otherwise return NULL.
+static const char* env_match(const char* envstr, const char* name) {
+  size_t i = 0;
+
+  while (envstr[i] == name[i] && name[i] != '\0') {
+    ++i;
+  }
+
+  if (name[i] == '\0' && envstr[i] == '=') {
+    return envstr + i + 1;
+  }
+
+  return NULL;
+}
+
+static bool __is_valid_environment_variable(const char* name) {
+  // According to its sources, the kernel uses 32*PAGE_SIZE by default
+  // as the maximum size for an env. variable definition.
+  const int MAX_ENV_LEN = 32*4096;
+
+  if (name == NULL) {
+    return false;
+  }
+
+  // Parse the string, looking for the first '=' there, and its size.
+  int pos = 0;
+  int first_equal_pos = -1;
+  while (pos < MAX_ENV_LEN) {
+    if (name[pos] == '\0') {
+      break;
+    }
+    if (name[pos] == '=' && first_equal_pos < 0) {
+      first_equal_pos = pos;
+    }
+    pos++;
+  }
+
+  // Check that it's smaller than MAX_ENV_LEN (to detect non-zero terminated strings).
+  if (pos >= MAX_ENV_LEN) {
+    return false;
+  }
+
+  // Check that it contains at least one equal sign that is not the first character
+  if (first_equal_pos < 1) {
+    return false;
+  }
+
+  return true;
+}
+
+static bool __is_unsafe_environment_variable(const char* name) {
+  // None of these should be allowed in setuid programs.
+  static const char* const UNSAFE_VARIABLE_NAMES[] = {
+      "GCONV_PATH",
+      "GETCONF_DIR",
+      "HOSTALIASES",
+      "LD_AOUT_LIBRARY_PATH",
+      "LD_AOUT_PRELOAD",
+      "LD_AUDIT",
+      "LD_DEBUG",
+      "LD_DEBUG_OUTPUT",
+      "LD_DYNAMIC_WEAK",
+      "LD_LIBRARY_PATH",
+      "LD_ORIGIN_PATH",
+      "LD_PRELOAD",
+      "LD_PROFILE",
+      "LD_SHOW_AUXV",
+      "LD_USE_LOAD_BIAS",
+      "LOCALDOMAIN",
+      "LOCPATH",
+      "MALLOC_CHECK_",
+      "MALLOC_TRACE",
+      "NIS_PATH",
+      "NLSPATH",
+      "RESOLV_HOST_CONF",
+      "RES_OPTIONS",
+      "TMPDIR",
+      "TZDIR",
+      NULL
+  };
+  for (size_t i = 0; UNSAFE_VARIABLE_NAMES[i] != NULL; ++i) {
+    if (env_match(name, UNSAFE_VARIABLE_NAMES[i]) != NULL) {
+      return true;
+    }
+  }
+  return false;
+}
+
+static void __sanitize_environment_variables() {
+  char** src  = _envp;
+  char** dst = _envp;
+  for (; src[0] != NULL; ++src) {
+    if (!__is_valid_environment_variable(src[0])) {
+      continue;
+    }
+    // Remove various unsafe environment variables if we're loading a setuid program.
+    if (get_AT_SECURE() && __is_unsafe_environment_variable(src[0])) {
+        continue;
+    }
+    dst[0] = src[0];
+    ++dst;
+  }
+  dst[0] = NULL;
+}
+
+void linker_env_init(KernelArgumentBlock& args) {
+  // Store environment pointer - can't be NULL.
+  _envp = args.envp;
+
+  __init_AT_SECURE(args);
+  __sanitize_environment_variables();
+}
+
+const char* linker_env_get(const char* name) {
+  if (name == NULL || name[0] == '\0') {
+    return NULL;
+  }
+
+  for (char** p = _envp; p[0] != NULL; ++p) {
+    const char* val = env_match(p[0], name);
+    if (val != NULL) {
+      if (val[0] == '\0') {
+        return NULL; // Return NULL for empty strings.
+      }
+      return val;
+    }
+  }
+  return NULL;
+}
diff --git a/linker/linker_environ.h b/linker/linker_environ.h
index d5f75a1..cd7a65b 100644
--- a/linker/linker_environ.h
+++ b/linker/linker_environ.h
@@ -25,38 +25,20 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #ifndef LINKER_ENVIRON_H
 #define LINKER_ENVIRON_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+struct KernelArgumentBlock;
 
-/* Call this function before anything else. 'vecs' must be the pointer
- * to the environment block in the ELF data block. The function returns
- * the start of the aux vectors after the env block.
- */
-extern unsigned*   linker_env_init(unsigned* vecs);
+// Call this function before any of the other functions in this header file.
+extern void linker_env_init(KernelArgumentBlock& args);
 
-/* Unset a given environment variable. In case the variable is defined
- * multiple times, unset all instances. This modifies the environment
- * block, so any pointer returned by linker_env_get() after this call
- * might become invalid */
-extern void        linker_env_unset(const char* name);
-
-
-/* Returns the value of environment variable 'name' if defined and not
- * empty, or NULL otherwise. Note that the returned pointer may become
- * invalid if linker_env_unset() or linker_env_secure() are called
- * after this function. */
+// Returns the value of environment variable 'name' if defined and not
+// empty, or NULL otherwise.
 extern const char* linker_env_get(const char* name);
 
-/* Remove insecure environment variables. This should be used when
- * running setuid programs. */
-extern void        linker_env_secure(void);
+// Returns the value of this program's AT_SECURE variable.
+extern bool get_AT_SECURE();
 
-#ifdef __cplusplus
-};
-#endif
-
-#endif /* LINKER_ENVIRON_H */
+#endif // LINKER_ENVIRON_H
diff --git a/linker/linker_format.c b/linker/linker_format.c
deleted file mode 100644
index f60e259..0000000
--- a/linker/linker_format.c
+++ /dev/null
@@ -1,706 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdarg.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <stddef.h>
-#include "linker_format.h"
-#include "linker_debug.h"
-
-/* define UNIT_TESTS to build this file as a single executable that runs
- * the formatter's unit tests
- */
-#define xxUNIT_TESTS
-
-/*** Generic output sink
- ***/
-
-typedef struct {
-    void *opaque;
-    void (*send)(void *opaque, const char *data, int len);
-} Out;
-
-static void
-out_send(Out *o, const void *data, size_t len)
-{
-    o->send(o->opaque, data, (int)len);
-}
-
-static void
-out_send_repeat(Out *o, char ch, int count)
-{
-    char pad[8];
-    const int padSize = (int)sizeof(pad);
-
-    memset(pad, ch, sizeof(pad));
-    while (count > 0) {
-        int avail = count;
-        if (avail > padSize) {
-            avail = padSize;
-        }
-        o->send(o->opaque, pad, avail);
-        count -= avail;
-    }
-}
-
-/* forward declaration */
-static void
-out_vformat(Out *o, const char *format, va_list args);
-
-/*** Bounded buffer output
- ***/
-
-typedef struct {
-    Out out[1];
-    char *buffer;
-    char *pos;
-    char *end;
-    int total;
-} BufOut;
-
-static void
-buf_out_send(void *opaque, const char *data, int len)
-{
-    BufOut *bo = opaque;
-
-    if (len < 0)
-        len = strlen(data);
-
-    bo->total += len;
-
-    while (len > 0) {
-        int avail = bo->end - bo->pos;
-        if (avail == 0)
-            break;
-        if (avail > len)
-            avail = len;
-        memcpy(bo->pos, data, avail);
-        bo->pos += avail;
-        bo->pos[0] = '\0';
-        len -= avail;
-    }
-}
-
-static Out*
-buf_out_init(BufOut *bo, char *buffer, size_t size)
-{
-    if (size == 0)
-        return NULL;
-
-    bo->out->opaque = bo;
-    bo->out->send   = buf_out_send;
-    bo->buffer      = buffer;
-    bo->end         = buffer + size - 1;
-    bo->pos         = bo->buffer;
-    bo->pos[0]      = '\0';
-    bo->total       = 0;
-
-    return bo->out;
-}
-
-static int
-buf_out_length(BufOut *bo)
-{
-    return bo->total;
-}
-
-static int
-vformat_buffer(char *buff, size_t buffsize, const char *format, va_list args)
-{
-    BufOut bo;
-    Out *out;
-
-    out = buf_out_init(&bo, buff, buffsize);
-    if (out == NULL)
-        return 0;
-
-    out_vformat(out, format, args);
-
-    return buf_out_length(&bo);
-}
-
-int
-format_buffer(char *buff, size_t buffsize, const char *format, ...)
-{
-    va_list args;
-    int ret;
-
-    va_start(args, format);
-    ret = vformat_buffer(buff, buffsize, format, args);
-    va_end(args);
-
-    return ret;
-}
-
-/* The __stack_chk_fail() function calls __libc_android_log_print()
- * which calls vsnprintf().
- *
- * We define our version of the function here to avoid dragging
- * about 25 KB of C library routines related to formatting.
- */
-int
-vsnprintf(char *buff, size_t bufsize, const char *format, va_list args)
-{
-    return format_buffer(buff, bufsize, format, args);
-}
-
-/* The pthread implementation uses snprintf(). If we define it here, we
- * avoid pulling the stdio vfprintf() implementation into the linker
- * saving about 19KB of machine code.
- */
-int
-snprintf(char* buff, size_t bufsize, const char* format, ...)
-{
-    va_list args;
-    int ret;
-    va_start(args, format);
-    ret = vsnprintf(buff, bufsize, format, args);
-    va_end(args);
-    return ret;
-}
-
-#if LINKER_DEBUG
-
-#if !LINKER_DEBUG_TO_LOG
-
-/*** File descriptor output
- ***/
-
-typedef struct {
-    Out out[1];
-    int fd;
-    int total;
-} FdOut;
-
-static void
-fd_out_send(void *opaque, const char *data, int len)
-{
-    FdOut *fdo = opaque;
-
-    if (len < 0)
-        len = strlen(data);
-
-    while (len > 0) {
-        int ret = write(fdo->fd, data, len);
-        if (ret < 0) {
-            if (errno == EINTR)
-                continue;
-            break;
-        }
-        data += ret;
-        len -= ret;
-        fdo->total += ret;
-    }
-}
-
-static Out*
-fd_out_init(FdOut *fdo, int  fd)
-{
-    fdo->out->opaque = fdo;
-    fdo->out->send = fd_out_send;
-    fdo->fd = fd;
-    fdo->total = 0;
-
-    return fdo->out;
-}
-
-static int
-fd_out_length(FdOut *fdo)
-{
-    return fdo->total;
-}
-
-
-int
-format_fd(int fd, const char *format, ...)
-{
-    FdOut fdo;
-    Out* out;
-    va_list args;
-
-    out = fd_out_init(&fdo, fd);
-    if (out == NULL)
-        return 0;
-
-    va_start(args, format);
-    out_vformat(out, format, args);
-    va_end(args);
-
-    return fd_out_length(&fdo);
-}
-
-#else /* LINKER_DEBUG_TO_LOG */
-
-/*** Log output
- ***/
-
-/* We need our own version of __libc_android_log_vprint, otherwise
- * the log output is completely broken. Probably due to the fact
- * that the C library is not initialized yet.
- *
- * You can test that by setting CUSTOM_LOG_VPRINT to 0
- */
-#define  CUSTOM_LOG_VPRINT  1
-
-#if CUSTOM_LOG_VPRINT
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/uio.h>
-
-static int log_vprint(int prio, const char *tag, const char *fmt, va_list  args)
-{
-    char buf[1024];
-    int result;
-    static int log_fd = -1;
-
-    result = vformat_buffer(buf, sizeof buf, fmt, args);
-
-    if (log_fd < 0) {
-        log_fd = open("/dev/log/main", O_WRONLY);
-        if (log_fd < 0)
-            return result;
-    }
-
-    {
-        ssize_t ret;
-        struct iovec vec[3];
-
-        vec[0].iov_base = (unsigned char *) &prio;
-        vec[0].iov_len = 1;
-        vec[1].iov_base = (void *) tag;
-        vec[1].iov_len = strlen(tag) + 1;
-        vec[2].iov_base = (void *) buf;
-        vec[2].iov_len = strlen(buf) + 1;
-
-        do {
-            ret = writev(log_fd, vec, 3);
-        } while ((ret < 0) && (errno == EINTR));
-    }
-    return result;
-}
-
-#define  __libc_android_log_vprint  log_vprint
-
-#else /* !CUSTOM_LOG_VPRINT */
-
-extern "C" int __libc_android_log_vprint(int  prio, const char* tag, const char*  format, va_list ap);
-
-#endif /* !CUSTOM_LOG_VPRINT */
-
-int
-format_log(int prio, const char *tag, const char *format, ...)
-{
-    int ret;
-    va_list  args;
-    va_start(args, format);
-    ret = __libc_android_log_vprint(prio, tag, format, args);
-    va_end(args);
-    return ret;
-}
-
-#endif /* LINKER_DEBUG_TO_LOG */
-
-#endif /* LINKER_DEBUG */
-
-/*** formatted output implementation
- ***/
-
-/* Parse a decimal string from 'format + *ppos',
- * return the value, and writes the new position past
- * the decimal string in '*ppos' on exit.
- *
- * NOTE: Does *not* handle a sign prefix.
- */
-static unsigned
-parse_decimal(const char *format, int *ppos)
-{
-    const char* p = format + *ppos;
-    unsigned result = 0;
-
-    for (;;) {
-        int ch = *p;
-        unsigned d = (unsigned)(ch - '0');
-
-        if (d >= 10U)
-            break;
-
-        result = result*10 + d;
-        p++;
-    }
-    *ppos = p - format;
-    return result;
-}
-
-/* write an octal/decimal/number into a bounded buffer.
- * assumes that bufsize > 0, and 'digits' is a string of
- * digits of at least 'base' values.
- */
-static void
-format_number(char *buffer, size_t bufsize, uint64_t value, int base, const char *digits)
-{
-    char *pos = buffer;
-    char *end = buffer + bufsize - 1;
-
-    /* generate digit string in reverse order */
-    while (value) {
-        unsigned d = value % base;
-        value /= base;
-        if (pos < end) {
-            *pos++ = digits[d];
-        }
-    }
-
-    /* special case for 0 */
-    if (pos == buffer) {
-        if (pos < end) {
-            *pos++ = '0';
-        }
-    }
-    pos[0] = '\0';
-
-    /* now reverse digit string in-place */
-    end = pos - 1;
-    pos = buffer;
-    while (pos < end) {
-        int ch = pos[0];
-        pos[0] = end[0];
-        end[0] = (char) ch;
-        pos++;
-        end--;
-    }
-}
-
-/* Write an integer (octal or decimal) into a buffer, assumes buffsize > 2 */
-static void
-format_integer(char *buffer, size_t buffsize, uint64_t value, int base, int isSigned)
-{
-    if (isSigned && (int64_t)value < 0) {
-        buffer[0] = '-';
-        buffer += 1;
-        buffsize -= 1;
-        value = (uint64_t)(-(int64_t)value);
-    }
-
-    format_number(buffer, buffsize, value, base, "0123456789");
-}
-
-/* Write an hexadecimal into a buffer, isCap is true for capital alphas.
- * Assumes bufsize > 2 */
-static void
-format_hex(char *buffer, size_t buffsize, uint64_t value, int isCap)
-{
-    const char *digits = isCap ? "0123456789ABCDEF" : "0123456789abcdef";
-
-    format_number(buffer, buffsize, value, 16, digits);
-}
-
-
-/* Perform formatted output to an output target 'o' */
-static void
-out_vformat(Out *o, const char *format, va_list args)
-{
-    int nn = 0;
-
-    for (;;) {
-        int mm;
-        int padZero = 0;
-        int padLeft = 0;
-        char sign = '\0';
-        int width = -1;
-        int prec  = -1;
-        size_t bytelen = sizeof(int);
-        const char*  str;
-        int slen;
-        char buffer[32];  /* temporary buffer used to format numbers */
-
-        char  c;
-
-        /* first, find all characters that are not 0 or '%' */
-        /* then send them to the output directly */
-        mm = nn;
-        do {
-            c = format[mm];
-            if (c == '\0' || c == '%')
-                break;
-            mm++;
-        } while (1);
-
-        if (mm > nn) {
-            out_send(o, format+nn, mm-nn);
-            nn = mm;
-        }
-
-        /* is this it ? then exit */
-        if (c == '\0')
-            break;
-
-        /* nope, we are at a '%' modifier */
-        nn++;  // skip it
-
-        /* parse flags */
-        for (;;) {
-            c = format[nn++];
-            if (c == '\0') {  /* single trailing '%' ? */
-                c = '%';
-                out_send(o, &c, 1);
-                return;
-            }
-            else if (c == '0') {
-                padZero = 1;
-                continue;
-            }
-            else if (c == '-') {
-                padLeft = 1;
-                continue;
-            }
-            else if (c == ' ' || c == '+') {
-                sign = c;
-                continue;
-            }
-            break;
-        }
-
-        /* parse field width */
-        if ((c >= '0' && c <= '9')) {
-            nn --;
-            width = (int)parse_decimal(format, &nn);
-            c = format[nn++];
-        }
-
-        /* parse precision */
-        if (c == '.') {
-            prec = (int)parse_decimal(format, &nn);
-            c = format[nn++];
-        }
-
-        /* length modifier */
-        switch (c) {
-        case 'h':
-            bytelen = sizeof(short);
-            if (format[nn] == 'h') {
-                bytelen = sizeof(char);
-                nn += 1;
-            }
-            c = format[nn++];
-            break;
-        case 'l':
-            bytelen = sizeof(long);
-            if (format[nn] == 'l') {
-                bytelen = sizeof(long long);
-                nn += 1;
-            }
-            c = format[nn++];
-            break;
-        case 'z':
-            bytelen = sizeof(size_t);
-            c = format[nn++];
-            break;
-        case 't':
-            bytelen = sizeof(ptrdiff_t);
-            c = format[nn++];
-            break;
-        default:
-            ;
-        }
-
-        /* conversion specifier */
-        if (c == 's') {
-            /* string */
-            str = va_arg(args, const char*);
-        } else if (c == 'c') {
-            /* character */
-            /* NOTE: char is promoted to int when passed through the stack */
-            buffer[0] = (char) va_arg(args, int);
-            buffer[1] = '\0';
-            str = buffer;
-        } else if (c == 'p') {
-            uint64_t  value = (uintptr_t) va_arg(args, void*);
-            buffer[0] = '0';
-            buffer[1] = 'x';
-            format_hex(buffer + 2, sizeof buffer-2, value, 0);
-            str = buffer;
-        } else {
-            /* integers - first read value from stack */
-            uint64_t value;
-            int isSigned = (c == 'd' || c == 'i' || c == 'o');
-
-            /* NOTE: int8_t and int16_t are promoted to int when passed
-             *       through the stack
-             */
-            switch (bytelen) {
-            case 1: value = (uint8_t)  va_arg(args, int); break;
-            case 2: value = (uint16_t) va_arg(args, int); break;
-            case 4: value = va_arg(args, uint32_t); break;
-            case 8: value = va_arg(args, uint64_t); break;
-            default: return;  /* should not happen */
-            }
-
-            /* sign extension, if needed */
-            if (isSigned) {
-                int shift = 64 - 8*bytelen;
-                value = (uint64_t)(((int64_t)(value << shift)) >> shift);
-            }
-
-            /* format the number properly into our buffer */
-            switch (c) {
-            case 'i': case 'd':
-                format_integer(buffer, sizeof buffer, value, 10, isSigned);
-                break;
-            case 'o':
-                format_integer(buffer, sizeof buffer, value, 8, isSigned);
-                break;
-            case 'x': case 'X':
-                format_hex(buffer, sizeof buffer, value, (c == 'X'));
-                break;
-            default:
-                buffer[0] = '\0';
-            }
-            /* then point to it */
-            str = buffer;
-        }
-
-        /* if we are here, 'str' points to the content that must be
-         * outputted. handle padding and alignment now */
-
-        slen = strlen(str);
-
-        if (slen < width && !padLeft) {
-            char padChar = padZero ? '0' : ' ';
-            out_send_repeat(o, padChar, width - slen);
-        }
-
-        out_send(o, str, slen);
-
-        if (slen < width && padLeft) {
-            char padChar = padZero ? '0' : ' ';
-            out_send_repeat(o, padChar, width - slen);
-        }
-    }
-}
-
-
-#ifdef UNIT_TESTS
-
-#include <stdio.h>
-
-static int   gFails = 0;
-
-#define  MARGIN  40
-
-#define  UTEST_CHECK(condition,message) \
-    printf("Checking %-*s: ", MARGIN, message); fflush(stdout); \
-    if (!(condition)) { \
-        printf("KO\n"); \
-        gFails += 1; \
-    } else { \
-        printf("ok\n"); \
-    }
-
-static void
-utest_BufOut(void)
-{
-    char buffer[16];
-    BufOut bo[1];
-    Out* out;
-    int ret;
-
-    buffer[0] = '1';
-    out = buf_out_init(bo, buffer, sizeof buffer);
-    UTEST_CHECK(buffer[0] == '\0', "buf_out_init clears initial byte");
-    out_send(out, "abc", 3);
-    UTEST_CHECK(!memcmp(buffer, "abc", 4), "out_send() works with BufOut");
-    out_send_repeat(out, 'X', 4);
-    UTEST_CHECK(!memcmp(buffer, "abcXXXX", 8), "out_send_repeat() works with BufOut");
-    buffer[sizeof buffer-1] = 'x';
-    out_send_repeat(out, 'Y', 2*sizeof(buffer));
-    UTEST_CHECK(buffer[sizeof buffer-1] == '\0', "overflows always zero-terminates");
-
-    out = buf_out_init(bo, buffer, sizeof buffer);
-    out_send_repeat(out, 'X', 2*sizeof(buffer));
-    ret = buf_out_length(bo);
-    UTEST_CHECK(ret == 2*sizeof(buffer), "correct size returned on overflow");
-}
-
-static void
-utest_expect(const char*  result, const char*  format, ...)
-{
-    va_list args;
-    BufOut bo[1];
-    char buffer[256];
-    Out* out = buf_out_init(bo, buffer, sizeof buffer);
-
-    printf("Checking %-*s: ", MARGIN, format); fflush(stdout);
-    va_start(args, format);
-    out_vformat(out, format, args);
-    va_end(args);
-
-    if (strcmp(result, buffer)) {
-        printf("KO. got '%s' expecting '%s'\n", buffer, result);
-        gFails += 1;
-    } else {
-        printf("ok. got '%s'\n", result);
-    }
-}
-
-int  main(void)
-{
-    utest_BufOut();
-    utest_expect("", "");
-    utest_expect("a", "a");
-    utest_expect("01234", "01234", "");
-    utest_expect("01234", "%s", "01234");
-    utest_expect("aabbcc", "aa%scc", "bb");
-    utest_expect("a", "%c", 'a');
-    utest_expect("1234", "%d", 1234);
-    utest_expect("-8123", "%d", -8123);
-    utest_expect("16", "%hd", 0x7fff0010);
-    utest_expect("16", "%hhd", 0x7fffff10);
-    utest_expect("68719476736", "%lld", 0x1000000000LL);
-    utest_expect("70000", "%ld", 70000);
-    utest_expect("0xb0001234", "%p", (void*)0xb0001234);
-    utest_expect("12ab", "%x", 0x12ab);
-    utest_expect("12AB", "%X", 0x12ab);
-    utest_expect("00123456", "%08x", 0x123456);
-    utest_expect("01234", "0%d", 1234);
-    utest_expect(" 1234", "%5d", 1234);
-    utest_expect("01234", "%05d", 1234);
-    utest_expect("    1234", "%8d", 1234);
-    utest_expect("1234    ", "%-8d", 1234);
-    utest_expect("abcdef     ", "%-11s", "abcdef");
-    utest_expect("something:1234", "%s:%d", "something", 1234);
-    utest_expect("005:5:05", "%03d:%d:%02d", 5, 5, 5);
-    utest_expect("5,0x0", "%d,%p", 5, NULL);
-    utest_expect("68719476736,6,7,8", "%lld,%d,%d,%d", 0x1000000000LL, 6, 7, 8);
-    return gFails != 0;
-}
-
-#endif /* UNIT_TESTS */
diff --git a/linker/linker_format.h b/linker/linker_format.h
deleted file mode 100644
index 3766b62..0000000
--- a/linker/linker_format.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#ifndef _LINKER_FORMAT_H
-#define _LINKER_FORMAT_H
-
-#include <stdarg.h>
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Formatting routines for the dynamic linker's debug traces */
-/* We want to avoid dragging the whole C library fprintf()   */
-/* implementation into the dynamic linker since this creates */
-/* issues (it uses malloc()/free()) and increases code size  */
-
-int format_buffer(char *buffer, size_t bufsize, const char *format, ...);
-
-#ifdef __cplusplus
-};
-#endif
-
-#endif /* _LINKER_FORMAT_H */
diff --git a/linker/linker_phdr.c b/linker/linker_phdr.c
deleted file mode 100644
index 250ca20..0000000
--- a/linker/linker_phdr.c
+++ /dev/null
@@ -1,644 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <errno.h>
-#include <sys/mman.h>
-
-#include "linker_phdr.h"
-
-/**
-  TECHNICAL NOTE ON ELF LOADING.
-
-  An ELF file's program header table contains one or more PT_LOAD
-  segments, which corresponds to portions of the file that need to
-  be mapped into the process' address space.
-
-  Each loadable segment has the following important properties:
-
-    p_offset  -> segment file offset
-    p_filesz  -> segment file size
-    p_memsz   -> segment memory size (always >= p_filesz)
-    p_vaddr   -> segment's virtual address
-    p_flags   -> segment flags (e.g. readable, writable, executable)
-
-  We will ignore the p_paddr and p_align fields of Elf32_Phdr for now.
-
-  The loadable segments can be seen as a list of [p_vaddr ... p_vaddr+p_memsz)
-  ranges of virtual addresses. A few rules apply:
-
-  - the virtual address ranges should not overlap.
-
-  - if a segment's p_filesz is smaller than its p_memsz, the extra bytes
-    between them should always be initialized to 0.
-
-  - ranges do not necessarily start or end at page boundaries. Two distinct
-    segments can have their start and end on the same page. In this case, the
-    page inherits the mapping flags of the latter segment.
-
-  Finally, the real load addrs of each segment is not p_vaddr. Instead the
-  loader decides where to load the first segment, then will load all others
-  relative to the first one to respect the initial range layout.
-
-  For example, consider the following list:
-
-    [ offset:0,      filesz:0x4000, memsz:0x4000, vaddr:0x30000 ],
-    [ offset:0x4000, filesz:0x2000, memsz:0x8000, vaddr:0x40000 ],
-
-  This corresponds to two segments that cover these virtual address ranges:
-
-       0x30000...0x34000
-       0x40000...0x48000
-
-  If the loader decides to load the first segment at address 0xa0000000
-  then the segments' load address ranges will be:
-
-       0xa0030000...0xa0034000
-       0xa0040000...0xa0048000
-
-  In other words, all segments must be loaded at an address that has the same
-  constant offset from their p_vaddr value. This offset is computed as the
-  difference between the first segment's load address, and its p_vaddr value.
-
-  However, in practice, segments do _not_ start at page boundaries. Since we
-  can only memory-map at page boundaries, this means that the bias is
-  computed as:
-
-       load_bias = phdr0_load_address - PAGE_START(phdr0->p_vaddr)
-
-  (NOTE: The value must be used as a 32-bit unsigned integer, to deal with
-          possible wrap around UINT32_MAX for possible large p_vaddr values).
-
-  And that the phdr0_load_address must start at a page boundary, with
-  the segment's real content starting at:
-
-       phdr0_load_address + PAGE_OFFSET(phdr0->p_vaddr)
-
-  Note that ELF requires the following condition to make the mmap()-ing work:
-
-      PAGE_OFFSET(phdr0->p_vaddr) == PAGE_OFFSET(phdr0->p_offset)
-
-  The load_bias must be added to any p_vaddr value read from the ELF file to
-  determine the corresponding memory address.
-
- **/
-
-#define MAYBE_MAP_FLAG(x,from,to)    (((x) & (from)) ? (to) : 0)
-#define PFLAGS_TO_PROT(x)            (MAYBE_MAP_FLAG((x), PF_X, PROT_EXEC) | \
-                                      MAYBE_MAP_FLAG((x), PF_R, PROT_READ) | \
-                                      MAYBE_MAP_FLAG((x), PF_W, PROT_WRITE))
-
-/* Load the program header table from an ELF file into a read-only private
- * anonymous mmap-ed block.
- *
- * Input:
- *   fd           -> file descriptor
- *   phdr_offset  -> file offset of phdr table
- *   phdr_num     -> number of entries in the table.
- *
- * Output:
- *   phdr_mmap    -> address of mmap block in memory.
- *   phdr_memsize -> size of mmap block in memory.
- *   phdr_table   -> address of first entry in memory.
- *
- * Return:
- *   -1 on error, or 0 on success.
- */
-int phdr_table_load(int                fd,
-                    Elf32_Addr         phdr_offset,
-                    Elf32_Half         phdr_num,
-                    void**             phdr_mmap,
-                    Elf32_Addr*        phdr_size,
-                    const Elf32_Phdr** phdr_table)
-{
-    Elf32_Addr  page_min, page_max, page_offset;
-    void*       mmap_result;
-
-    /* Just like the kernel, we only accept program header tables that
-     * are smaller than 64KB. */
-    if (phdr_num < 1 || phdr_num > 65536/sizeof(Elf32_Phdr)) {
-        errno = EINVAL;
-        return -1;
-    }
-
-    page_min = PAGE_START(phdr_offset);
-    page_max = PAGE_END(phdr_offset + phdr_num*sizeof(Elf32_Phdr));
-    page_offset = PAGE_OFFSET(phdr_offset);
-
-    mmap_result = mmap(NULL,
-                       page_max - page_min,
-                       PROT_READ,
-                       MAP_PRIVATE,
-                       fd,
-                       page_min);
-
-    if (mmap_result == MAP_FAILED) {
-        return -1;
-    }
-
-    *phdr_mmap = mmap_result;
-    *phdr_size = page_max - page_min;
-    *phdr_table = (Elf32_Phdr*)((char*)mmap_result + page_offset);
-
-    return 0;
-}
-
-void phdr_table_unload(void* phdr_mmap, Elf32_Addr phdr_memsize)
-{
-    munmap(phdr_mmap, phdr_memsize);
-}
-
-
-/* Compute the extent of all loadable segments in an ELF program header
- * table. This corresponds to the page-aligned size in bytes that needs to be
- * reserved in the process' address space
- *
- * This returns 0 if there are no loadable segments.
- */
-Elf32_Addr phdr_table_get_load_size(const Elf32_Phdr* phdr_table,
-                                    size_t phdr_count)
-{
-    Elf32_Addr min_vaddr = 0xFFFFFFFFU;
-    Elf32_Addr max_vaddr = 0x00000000U;
-
-    for (size_t i = 0; i < phdr_count; ++i) {
-        const Elf32_Phdr* phdr = &phdr_table[i];
-
-        if (phdr->p_type != PT_LOAD) {
-            continue;
-        }
-
-        if (phdr->p_vaddr < min_vaddr) {
-            min_vaddr = phdr->p_vaddr;
-        }
-
-        if (phdr->p_vaddr + phdr->p_memsz > max_vaddr) {
-            max_vaddr = phdr->p_vaddr + phdr->p_memsz;
-        }
-    }
-
-    if (min_vaddr > max_vaddr) {
-        return 0;
-    }
-
-    min_vaddr = PAGE_START(min_vaddr);
-    max_vaddr = PAGE_END(max_vaddr);
-
-    return max_vaddr - min_vaddr;
-}
-
-/* Reserve a virtual address range big enough to hold all loadable
- * segments of a program header table. This is done by creating a
- * private anonymous mmap() with PROT_NONE.
- *
- * Input:
- *   phdr_table    -> program header table
- *   phdr_count    -> number of entries in the tables
- * Output:
- *   load_start    -> first page of reserved address space range
- *   load_size     -> size in bytes of reserved address space range
- *   load_bias     -> load bias, as described in technical note above.
- *
- * Return:
- *   0 on success, -1 otherwise. Error code in errno.
- */
-int
-phdr_table_reserve_memory(const Elf32_Phdr* phdr_table,
-                          size_t phdr_count,
-                          void** load_start,
-                          Elf32_Addr* load_size,
-                          Elf32_Addr* load_bias)
-{
-    Elf32_Addr size = phdr_table_get_load_size(phdr_table, phdr_count);
-    if (size == 0) {
-        errno = EINVAL;
-        return -1;
-    }
-
-    int mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS;
-    void* start = mmap(NULL, size, PROT_NONE, mmap_flags, -1, 0);
-    if (start == MAP_FAILED) {
-        return -1;
-    }
-
-    *load_start = start;
-    *load_size  = size;
-    *load_bias  = 0;
-
-    for (size_t i = 0; i < phdr_count; ++i) {
-        const Elf32_Phdr* phdr = &phdr_table[i];
-        if (phdr->p_type == PT_LOAD) {
-            *load_bias = (Elf32_Addr)start - PAGE_START(phdr->p_vaddr);
-            break;
-        }
-    }
-    return 0;
-}
-
-/* Map all loadable segments in process' address space.
- * This assumes you already called phdr_table_reserve_memory to
- * reserve the address space range for the library.
- *
- * Input:
- *   phdr_table    -> program header table
- *   phdr_count    -> number of entries in the table
- *   load_bias     -> load offset.
- *   fd            -> input file descriptor.
- *
- * Return:
- *   0 on success, -1 otherwise. Error code in errno.
- */
-int
-phdr_table_load_segments(const Elf32_Phdr* phdr_table,
-                         int               phdr_count,
-                         Elf32_Addr        load_bias,
-                         int               fd)
-{
-    int nn;
-
-    for (nn = 0; nn < phdr_count; nn++) {
-        const Elf32_Phdr* phdr = &phdr_table[nn];
-        void* seg_addr;
-
-        if (phdr->p_type != PT_LOAD)
-            continue;
-
-        /* Segment addresses in memory */
-        Elf32_Addr seg_start = phdr->p_vaddr + load_bias;
-        Elf32_Addr seg_end   = seg_start + phdr->p_memsz;
-
-        Elf32_Addr seg_page_start = PAGE_START(seg_start);
-        Elf32_Addr seg_page_end   = PAGE_END(seg_end);
-
-        Elf32_Addr seg_file_end   = seg_start + phdr->p_filesz;
-
-        /* File offsets */
-        Elf32_Addr file_start = phdr->p_offset;
-        Elf32_Addr file_end   = file_start + phdr->p_filesz;
-
-        Elf32_Addr file_page_start = PAGE_START(file_start);
-        Elf32_Addr file_page_end   = PAGE_END(file_end);
-
-        seg_addr = mmap((void*)seg_page_start,
-                        file_end - file_page_start,
-                        PFLAGS_TO_PROT(phdr->p_flags),
-                        MAP_FIXED|MAP_PRIVATE,
-                        fd,
-                        file_page_start);
-
-        if (seg_addr == MAP_FAILED) {
-            return -1;
-        }
-
-        /* if the segment is writable, and does not end on a page boundary,
-         * zero-fill it until the page limit. */
-        if ((phdr->p_flags & PF_W) != 0 && PAGE_OFFSET(seg_file_end) > 0) {
-            memset((void*)seg_file_end, 0, PAGE_SIZE - PAGE_OFFSET(seg_file_end));
-        }
-
-        seg_file_end = PAGE_END(seg_file_end);
-
-        /* seg_file_end is now the first page address after the file
-         * content. If seg_end is larger, we need to zero anything
-         * between them. This is done by using a private anonymous
-         * map for all extra pages.
-         */
-        if (seg_page_end > seg_file_end) {
-            void* zeromap = mmap((void*)seg_file_end,
-                                    seg_page_end - seg_file_end,
-                                    PFLAGS_TO_PROT(phdr->p_flags),
-                                    MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE,
-                                    -1,
-                                    0);
-            if (zeromap == MAP_FAILED) {
-                return -1;
-            }
-        }
-    }
-    return 0;
-}
-
-/* Used internally. Used to set the protection bits of all loaded segments
- * with optional extra flags (i.e. really PROT_WRITE). Used by
- * phdr_table_protect_segments and phdr_table_unprotect_segments.
- */
-static int
-_phdr_table_set_load_prot(const Elf32_Phdr* phdr_table,
-                          int               phdr_count,
-                          Elf32_Addr        load_bias,
-                          int               extra_prot_flags)
-{
-    const Elf32_Phdr* phdr = phdr_table;
-    const Elf32_Phdr* phdr_limit = phdr + phdr_count;
-
-    for (; phdr < phdr_limit; phdr++) {
-        if (phdr->p_type != PT_LOAD || (phdr->p_flags & PF_W) != 0)
-            continue;
-
-        Elf32_Addr seg_page_start = PAGE_START(phdr->p_vaddr) + load_bias;
-        Elf32_Addr seg_page_end   = PAGE_END(phdr->p_vaddr + phdr->p_memsz) + load_bias;
-
-        int ret = mprotect((void*)seg_page_start,
-                           seg_page_end - seg_page_start,
-                           PFLAGS_TO_PROT(phdr->p_flags) | extra_prot_flags);
-        if (ret < 0) {
-            return -1;
-        }
-    }
-    return 0;
-}
-
-/* Restore the original protection modes for all loadable segments.
- * You should only call this after phdr_table_unprotect_segments and
- * applying all relocations.
- *
- * Input:
- *   phdr_table  -> program header table
- *   phdr_count  -> number of entries in tables
- *   load_bias   -> load bias
- * Return:
- *   0 on error, -1 on failure (error code in errno).
- */
-int
-phdr_table_protect_segments(const Elf32_Phdr* phdr_table,
-                            int               phdr_count,
-                            Elf32_Addr        load_bias)
-{
-    return _phdr_table_set_load_prot(phdr_table, phdr_count,
-                                      load_bias, 0);
-}
-
-/* Change the protection of all loaded segments in memory to writable.
- * This is useful before performing relocations. Once completed, you
- * will have to call phdr_table_protect_segments to restore the original
- * protection flags on all segments.
- *
- * Note that some writable segments can also have their content turned
- * to read-only by calling phdr_table_protect_gnu_relro. This is no
- * performed here.
- *
- * Input:
- *   phdr_table  -> program header table
- *   phdr_count  -> number of entries in tables
- *   load_bias   -> load bias
- * Return:
- *   0 on error, -1 on failure (error code in errno).
- */
-int
-phdr_table_unprotect_segments(const Elf32_Phdr* phdr_table,
-                              int               phdr_count,
-                              Elf32_Addr        load_bias)
-{
-    return _phdr_table_set_load_prot(phdr_table, phdr_count,
-                                      load_bias, PROT_WRITE);
-}
-
-/* Used internally by phdr_table_protect_gnu_relro and
- * phdr_table_unprotect_gnu_relro.
- */
-static int
-_phdr_table_set_gnu_relro_prot(const Elf32_Phdr* phdr_table,
-                               int               phdr_count,
-                               Elf32_Addr        load_bias,
-                               int               prot_flags)
-{
-    const Elf32_Phdr* phdr = phdr_table;
-    const Elf32_Phdr* phdr_limit = phdr + phdr_count;
-
-    for (phdr = phdr_table; phdr < phdr_limit; phdr++) {
-        if (phdr->p_type != PT_GNU_RELRO)
-            continue;
-
-        /* Tricky: what happens when the relro segment does not start
-         * or end at page boundaries?. We're going to be over-protective
-         * here and put every page touched by the segment as read-only.
-         *
-         * This seems to match Ian Lance Taylor's description of the
-         * feature at http://www.airs.com/blog/archives/189.
-         *
-         * Extract:
-         *    Note that the current dynamic linker code will only work
-         *    correctly if the PT_GNU_RELRO segment starts on a page
-         *    boundary. This is because the dynamic linker rounds the
-         *    p_vaddr field down to the previous page boundary. If
-         *    there is anything on the page which should not be read-only,
-         *    the program is likely to fail at runtime. So in effect the
-         *    linker must only emit a PT_GNU_RELRO segment if it ensures
-         *    that it starts on a page boundary.
-         */
-        Elf32_Addr seg_page_start = PAGE_START(phdr->p_vaddr) + load_bias;
-        Elf32_Addr seg_page_end   = PAGE_END(phdr->p_vaddr + phdr->p_memsz) + load_bias;
-
-        int ret = mprotect((void*)seg_page_start,
-                           seg_page_end - seg_page_start,
-                           prot_flags);
-        if (ret < 0) {
-            return -1;
-        }
-    }
-    return 0;
-}
-
-/* Apply GNU relro protection if specified by the program header. This will
- * turn some of the pages of a writable PT_LOAD segment to read-only, as
- * specified by one or more PT_GNU_RELRO segments. This must be always
- * performed after relocations.
- *
- * The areas typically covered are .got and .data.rel.ro, these are
- * read-only from the program's POV, but contain absolute addresses
- * that need to be relocated before use.
- *
- * Input:
- *   phdr_table  -> program header table
- *   phdr_count  -> number of entries in tables
- *   load_bias   -> load bias
- * Return:
- *   0 on error, -1 on failure (error code in errno).
- */
-int
-phdr_table_protect_gnu_relro(const Elf32_Phdr* phdr_table,
-                             int               phdr_count,
-                             Elf32_Addr        load_bias)
-{
-    return _phdr_table_set_gnu_relro_prot(phdr_table,
-                                          phdr_count,
-                                          load_bias,
-                                          PROT_READ);
-}
-
-#ifdef ANDROID_ARM_LINKER
-
-#  ifndef PT_ARM_EXIDX
-#    define PT_ARM_EXIDX    0x70000001      /* .ARM.exidx segment */
-#  endif
-
-/* Return the address and size of the .ARM.exidx section in memory,
- * if present.
- *
- * Input:
- *   phdr_table  -> program header table
- *   phdr_count  -> number of entries in tables
- *   load_bias   -> load bias
- * Output:
- *   arm_exidx       -> address of table in memory (NULL on failure).
- *   arm_exidx_count -> number of items in table (0 on failure).
- * Return:
- *   0 on error, -1 on failure (_no_ error code in errno)
- */
-int
-phdr_table_get_arm_exidx(const Elf32_Phdr* phdr_table,
-                         int               phdr_count,
-                         Elf32_Addr        load_bias,
-                         Elf32_Addr**      arm_exidx,
-                         unsigned*         arm_exidx_count)
-{
-    const Elf32_Phdr* phdr = phdr_table;
-    const Elf32_Phdr* phdr_limit = phdr + phdr_count;
-
-    for (phdr = phdr_table; phdr < phdr_limit; phdr++) {
-        if (phdr->p_type != PT_ARM_EXIDX)
-            continue;
-
-        *arm_exidx = (Elf32_Addr*)(load_bias + phdr->p_vaddr);
-        *arm_exidx_count = (unsigned)(phdr->p_memsz / 8);
-        return 0;
-    }
-    *arm_exidx = NULL;
-    *arm_exidx_count = 0;
-    return -1;
-}
-#endif /* ANDROID_ARM_LINKER */
-
-/* Return the address and size of the ELF file's .dynamic section in memory,
- * or NULL if missing.
- *
- * Input:
- *   phdr_table  -> program header table
- *   phdr_count  -> number of entries in tables
- *   load_bias   -> load bias
- * Output:
- *   dynamic       -> address of table in memory (NULL on failure).
- *   dynamic_count -> number of items in table (0 on failure).
- * Return:
- *   void
- */
-void
-phdr_table_get_dynamic_section(const Elf32_Phdr* phdr_table,
-                               int               phdr_count,
-                               Elf32_Addr        load_bias,
-                               Elf32_Addr**      dynamic,
-                               size_t*           dynamic_count)
-{
-    const Elf32_Phdr* phdr = phdr_table;
-    const Elf32_Phdr* phdr_limit = phdr + phdr_count;
-
-    for (phdr = phdr_table; phdr < phdr_limit; phdr++) {
-        if (phdr->p_type != PT_DYNAMIC) {
-            continue;
-        }
-
-        *dynamic = (Elf32_Addr*)(load_bias + phdr->p_vaddr);
-        if (dynamic_count) {
-            *dynamic_count = (unsigned)(phdr->p_memsz / 8);
-        }
-        return;
-    }
-    *dynamic = NULL;
-    if (dynamic_count) {
-        *dynamic_count = 0;
-    }
-}
-
-/* Return the address of the program header table as it appears in the loaded
- * segments in memory. This is in contrast with the input 'phdr_table' which
- * is temporary and will be released before the library is relocated.
- *
- * Input:
- *   phdr_table  -> program header table
- *   phdr_count  -> number of entries in tables
- *   load_bias   -> load bias
- * Return:
- *   Address of loaded program header table on success (it has
- *   'phdr_count' entries), or NULL on failure (no error code).
- */
-const Elf32_Phdr*
-phdr_table_get_loaded_phdr(const Elf32_Phdr*   phdr_table,
-                           int                 phdr_count,
-                           Elf32_Addr          load_bias)
-{
-    const Elf32_Phdr* phdr = phdr_table;
-    const Elf32_Phdr* phdr_limit = phdr + phdr_count;
-    Elf32_Addr  loaded = 0;
-    Elf32_Addr  loaded_end;
-
-    /* If there is a PT_PHDR, use it directly */
-    for (phdr = phdr_table; phdr < phdr_limit; phdr++) {
-        if (phdr->p_type == PT_PHDR) {
-            loaded = load_bias + phdr->p_vaddr;
-            goto CHECK;
-        }
-    }
-
-    /* Otherwise, check the first loadable segment. If its file offset
-     * is 0, it starts with the ELF header, and we can trivially find the
-     * loaded program header from it. */
-    for (phdr = phdr_table; phdr < phdr_limit; phdr++) {
-        if (phdr->p_type == PT_LOAD) {
-            if (phdr->p_offset == 0) {
-                Elf32_Addr  elf_addr = load_bias + phdr->p_vaddr;
-                const Elf32_Ehdr* ehdr = (const Elf32_Ehdr*)(void*)elf_addr;
-                Elf32_Addr  offset = ehdr->e_phoff;
-                loaded = (Elf32_Addr)ehdr + offset;
-                goto CHECK;
-            }
-            break;
-        }
-    }
-
-    /* We didn't find it, let the client know. He may be able to
-     * keep a copy of the input phdr_table instead. */
-    return NULL;
-
-CHECK:
-    /* Ensure that our program header is actually within a loadable
-     * segment. This should help catch badly-formed ELF files that
-     * would cause the linker to crash later when trying to access it.
-     */
-    loaded_end = loaded + phdr_count*sizeof(Elf32_Phdr);
-
-    for (phdr = phdr_table; phdr < phdr_limit; phdr++) {
-        if (phdr->p_type != PT_LOAD)
-            continue;
-        Elf32_Addr seg_start = phdr->p_vaddr + load_bias;
-        Elf32_Addr seg_end   = phdr->p_filesz + seg_start;
-
-        if (seg_start <= loaded && loaded_end <= seg_end) {
-            return (const Elf32_Phdr*)loaded;
-        }
-    }
-    return NULL;
-}
diff --git a/linker/linker_phdr.cpp b/linker/linker_phdr.cpp
new file mode 100644
index 0000000..64dbb70
--- /dev/null
+++ b/linker/linker_phdr.cpp
@@ -0,0 +1,650 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "linker_phdr.h"
+
+#include <errno.h>
+#include <sys/mman.h>
+
+#include "linker.h"
+#include "linker_debug.h"
+
+/**
+  TECHNICAL NOTE ON ELF LOADING.
+
+  An ELF file's program header table contains one or more PT_LOAD
+  segments, which corresponds to portions of the file that need to
+  be mapped into the process' address space.
+
+  Each loadable segment has the following important properties:
+
+    p_offset  -> segment file offset
+    p_filesz  -> segment file size
+    p_memsz   -> segment memory size (always >= p_filesz)
+    p_vaddr   -> segment's virtual address
+    p_flags   -> segment flags (e.g. readable, writable, executable)
+
+  We will ignore the p_paddr and p_align fields of Elf32_Phdr for now.
+
+  The loadable segments can be seen as a list of [p_vaddr ... p_vaddr+p_memsz)
+  ranges of virtual addresses. A few rules apply:
+
+  - the virtual address ranges should not overlap.
+
+  - if a segment's p_filesz is smaller than its p_memsz, the extra bytes
+    between them should always be initialized to 0.
+
+  - ranges do not necessarily start or end at page boundaries. Two distinct
+    segments can have their start and end on the same page. In this case, the
+    page inherits the mapping flags of the latter segment.
+
+  Finally, the real load addrs of each segment is not p_vaddr. Instead the
+  loader decides where to load the first segment, then will load all others
+  relative to the first one to respect the initial range layout.
+
+  For example, consider the following list:
+
+    [ offset:0,      filesz:0x4000, memsz:0x4000, vaddr:0x30000 ],
+    [ offset:0x4000, filesz:0x2000, memsz:0x8000, vaddr:0x40000 ],
+
+  This corresponds to two segments that cover these virtual address ranges:
+
+       0x30000...0x34000
+       0x40000...0x48000
+
+  If the loader decides to load the first segment at address 0xa0000000
+  then the segments' load address ranges will be:
+
+       0xa0030000...0xa0034000
+       0xa0040000...0xa0048000
+
+  In other words, all segments must be loaded at an address that has the same
+  constant offset from their p_vaddr value. This offset is computed as the
+  difference between the first segment's load address, and its p_vaddr value.
+
+  However, in practice, segments do _not_ start at page boundaries. Since we
+  can only memory-map at page boundaries, this means that the bias is
+  computed as:
+
+       load_bias = phdr0_load_address - PAGE_START(phdr0->p_vaddr)
+
+  (NOTE: The value must be used as a 32-bit unsigned integer, to deal with
+          possible wrap around UINT32_MAX for possible large p_vaddr values).
+
+  And that the phdr0_load_address must start at a page boundary, with
+  the segment's real content starting at:
+
+       phdr0_load_address + PAGE_OFFSET(phdr0->p_vaddr)
+
+  Note that ELF requires the following condition to make the mmap()-ing work:
+
+      PAGE_OFFSET(phdr0->p_vaddr) == PAGE_OFFSET(phdr0->p_offset)
+
+  The load_bias must be added to any p_vaddr value read from the ELF file to
+  determine the corresponding memory address.
+
+ **/
+
+#define MAYBE_MAP_FLAG(x,from,to)    (((x) & (from)) ? (to) : 0)
+#define PFLAGS_TO_PROT(x)            (MAYBE_MAP_FLAG((x), PF_X, PROT_EXEC) | \
+                                      MAYBE_MAP_FLAG((x), PF_R, PROT_READ) | \
+                                      MAYBE_MAP_FLAG((x), PF_W, PROT_WRITE))
+
+ElfReader::ElfReader(const char* name, int fd)
+    : name_(name), fd_(fd),
+      phdr_num_(0), phdr_mmap_(NULL), phdr_table_(NULL), phdr_size_(0),
+      load_start_(NULL), load_size_(0), load_bias_(0),
+      loaded_phdr_(NULL) {
+}
+
+ElfReader::~ElfReader() {
+  if (fd_ != -1) {
+    close(fd_);
+  }
+  if (phdr_mmap_ != NULL) {
+    munmap(phdr_mmap_, phdr_size_);
+  }
+}
+
+bool ElfReader::Load() {
+  return ReadElfHeader() &&
+         VerifyElfHeader() &&
+         ReadProgramHeader() &&
+         ReserveAddressSpace() &&
+         LoadSegments() &&
+         FindPhdr();
+}
+
+bool ElfReader::ReadElfHeader() {
+  ssize_t rc = TEMP_FAILURE_RETRY(read(fd_, &header_, sizeof(header_)));
+  if (rc < 0) {
+    DL_ERR("can't read file \"%s\": %s", name_, strerror(errno));
+    return false;
+  }
+  if (rc != sizeof(header_)) {
+    DL_ERR("\"%s\" is too small to be an ELF executable", name_);
+    return false;
+  }
+  return true;
+}
+
+bool ElfReader::VerifyElfHeader() {
+  if (header_.e_ident[EI_MAG0] != ELFMAG0 ||
+      header_.e_ident[EI_MAG1] != ELFMAG1 ||
+      header_.e_ident[EI_MAG2] != ELFMAG2 ||
+      header_.e_ident[EI_MAG3] != ELFMAG3) {
+    DL_ERR("\"%s\" has bad ELF magic", name_);
+    return false;
+  }
+
+  if (header_.e_ident[EI_CLASS] != ELFCLASS32) {
+    DL_ERR("\"%s\" not 32-bit: %d", name_, header_.e_ident[EI_CLASS]);
+    return false;
+  }
+  if (header_.e_ident[EI_DATA] != ELFDATA2LSB) {
+    DL_ERR("\"%s\" not little-endian: %d", name_, header_.e_ident[EI_DATA]);
+    return false;
+  }
+
+  if (header_.e_type != ET_DYN) {
+    DL_ERR("\"%s\" has unexpected e_type: %d", name_, header_.e_type);
+    return false;
+  }
+
+  if (header_.e_version != EV_CURRENT) {
+    DL_ERR("\"%s\" has unexpected e_version: %d", name_, header_.e_version);
+    return false;
+  }
+
+  if (header_.e_machine !=
+#ifdef ANDROID_ARM_LINKER
+      EM_ARM
+#elif defined(ANDROID_MIPS_LINKER)
+      EM_MIPS
+#elif defined(ANDROID_X86_LINKER)
+      EM_386
+#endif
+  ) {
+    DL_ERR("\"%s\" has unexpected e_machine: %d", name_, header_.e_machine);
+    return false;
+  }
+
+  return true;
+}
+
+// Loads the program header table from an ELF file into a read-only private
+// anonymous mmap-ed block.
+bool ElfReader::ReadProgramHeader() {
+  phdr_num_ = header_.e_phnum;
+
+  // Like the kernel, we only accept program header tables that
+  // are smaller than 64KiB.
+  if (phdr_num_ < 1 || phdr_num_ > 65536/sizeof(Elf32_Phdr)) {
+    DL_ERR("\"%s\" has invalid e_phnum: %d", name_, phdr_num_);
+    return false;
+  }
+
+  Elf32_Addr page_min = PAGE_START(header_.e_phoff);
+  Elf32_Addr page_max = PAGE_END(header_.e_phoff + (phdr_num_ * sizeof(Elf32_Phdr)));
+  Elf32_Addr page_offset = PAGE_OFFSET(header_.e_phoff);
+
+  phdr_size_ = page_max - page_min;
+
+  void* mmap_result = mmap(NULL, phdr_size_, PROT_READ, MAP_PRIVATE, fd_, page_min);
+  if (mmap_result == MAP_FAILED) {
+    DL_ERR("\"%s\" phdr mmap failed: %s", name_, strerror(errno));
+    return false;
+  }
+
+  phdr_mmap_ = mmap_result;
+  phdr_table_ = reinterpret_cast<Elf32_Phdr*>(reinterpret_cast<char*>(mmap_result) + page_offset);
+  return true;
+}
+
+/* Compute the extent of all loadable segments in an ELF program header
+ * table. This corresponds to the page-aligned size in bytes that needs to be
+ * reserved in the process' address space
+ *
+ * This returns 0 if there are no loadable segments.
+ */
+Elf32_Addr phdr_table_get_load_size(const Elf32_Phdr* phdr_table,
+                                    size_t phdr_count)
+{
+    Elf32_Addr min_vaddr = 0xFFFFFFFFU;
+    Elf32_Addr max_vaddr = 0x00000000U;
+
+    for (size_t i = 0; i < phdr_count; ++i) {
+        const Elf32_Phdr* phdr = &phdr_table[i];
+
+        if (phdr->p_type != PT_LOAD) {
+            continue;
+        }
+
+        if (phdr->p_vaddr < min_vaddr) {
+            min_vaddr = phdr->p_vaddr;
+        }
+
+        if (phdr->p_vaddr + phdr->p_memsz > max_vaddr) {
+            max_vaddr = phdr->p_vaddr + phdr->p_memsz;
+        }
+    }
+
+    if (min_vaddr > max_vaddr) {
+        return 0;
+    }
+
+    min_vaddr = PAGE_START(min_vaddr);
+    max_vaddr = PAGE_END(max_vaddr);
+
+    return max_vaddr - min_vaddr;
+}
+
+// Reserve a virtual address range big enough to hold all loadable
+// segments of a program header table. This is done by creating a
+// private anonymous mmap() with PROT_NONE.
+bool ElfReader::ReserveAddressSpace() {
+  load_size_ = phdr_table_get_load_size(phdr_table_, phdr_num_);
+  if (load_size_ == 0) {
+    DL_ERR("\"%s\" has no loadable segments", name_);
+    return false;
+  }
+
+  int mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS;
+  void* start = mmap(NULL, load_size_, PROT_NONE, mmap_flags, -1, 0);
+  if (start == MAP_FAILED) {
+    DL_ERR("couldn't reserve %d bytes of address space for \"%s\"", load_size_, name_);
+    return false;
+  }
+
+  load_start_ = start;
+  load_bias_ = 0;
+
+  for (size_t i = 0; i < phdr_num_; ++i) {
+    const Elf32_Phdr* phdr = &phdr_table_[i];
+    if (phdr->p_type == PT_LOAD) {
+      load_bias_ = reinterpret_cast<Elf32_Addr>(start) - PAGE_START(phdr->p_vaddr);
+      break;
+    }
+  }
+  return true;
+}
+
+// Map all loadable segments in process' address space.
+// This assumes you already called phdr_table_reserve_memory to
+// reserve the address space range for the library.
+// TODO: assert assumption.
+bool ElfReader::LoadSegments() {
+  for (size_t i = 0; i < phdr_num_; ++i) {
+    const Elf32_Phdr* phdr = &phdr_table_[i];
+
+    if (phdr->p_type != PT_LOAD) {
+      continue;
+    }
+
+    // Segment addresses in memory.
+    Elf32_Addr seg_start = phdr->p_vaddr + load_bias_;
+    Elf32_Addr seg_end   = seg_start + phdr->p_memsz;
+
+    Elf32_Addr seg_page_start = PAGE_START(seg_start);
+    Elf32_Addr seg_page_end   = PAGE_END(seg_end);
+
+    Elf32_Addr seg_file_end   = seg_start + phdr->p_filesz;
+
+    // File offsets.
+    Elf32_Addr file_start = phdr->p_offset;
+    Elf32_Addr file_end   = file_start + phdr->p_filesz;
+
+    Elf32_Addr file_page_start = PAGE_START(file_start);
+
+    void* seg_addr = mmap((void*)seg_page_start,
+                          file_end - file_page_start,
+                          PFLAGS_TO_PROT(phdr->p_flags),
+                          MAP_FIXED|MAP_PRIVATE,
+                          fd_,
+                          file_page_start);
+    if (seg_addr == MAP_FAILED) {
+      DL_ERR("couldn't map \"%s\" segment %d: %s", name_, i, strerror(errno));
+      return false;
+    }
+
+    // if the segment is writable, and does not end on a page boundary,
+    // zero-fill it until the page limit.
+    if ((phdr->p_flags & PF_W) != 0 && PAGE_OFFSET(seg_file_end) > 0) {
+      memset((void*)seg_file_end, 0, PAGE_SIZE - PAGE_OFFSET(seg_file_end));
+    }
+
+    seg_file_end = PAGE_END(seg_file_end);
+
+    // seg_file_end is now the first page address after the file
+    // content. If seg_end is larger, we need to zero anything
+    // between them. This is done by using a private anonymous
+    // map for all extra pages.
+    if (seg_page_end > seg_file_end) {
+      void* zeromap = mmap((void*)seg_file_end,
+                           seg_page_end - seg_file_end,
+                           PFLAGS_TO_PROT(phdr->p_flags),
+                           MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE,
+                           -1,
+                           0);
+      if (zeromap == MAP_FAILED) {
+        DL_ERR("couldn't zero fill \"%s\" gap: %s", name_, strerror(errno));
+        return false;
+      }
+    }
+  }
+  return true;
+}
+
+/* Used internally. Used to set the protection bits of all loaded segments
+ * with optional extra flags (i.e. really PROT_WRITE). Used by
+ * phdr_table_protect_segments and phdr_table_unprotect_segments.
+ */
+static int
+_phdr_table_set_load_prot(const Elf32_Phdr* phdr_table,
+                          int               phdr_count,
+                          Elf32_Addr        load_bias,
+                          int               extra_prot_flags)
+{
+    const Elf32_Phdr* phdr = phdr_table;
+    const Elf32_Phdr* phdr_limit = phdr + phdr_count;
+
+    for (; phdr < phdr_limit; phdr++) {
+        if (phdr->p_type != PT_LOAD || (phdr->p_flags & PF_W) != 0)
+            continue;
+
+        Elf32_Addr seg_page_start = PAGE_START(phdr->p_vaddr) + load_bias;
+        Elf32_Addr seg_page_end   = PAGE_END(phdr->p_vaddr + phdr->p_memsz) + load_bias;
+
+        int ret = mprotect((void*)seg_page_start,
+                           seg_page_end - seg_page_start,
+                           PFLAGS_TO_PROT(phdr->p_flags) | extra_prot_flags);
+        if (ret < 0) {
+            return -1;
+        }
+    }
+    return 0;
+}
+
+/* Restore the original protection modes for all loadable segments.
+ * You should only call this after phdr_table_unprotect_segments and
+ * applying all relocations.
+ *
+ * Input:
+ *   phdr_table  -> program header table
+ *   phdr_count  -> number of entries in tables
+ *   load_bias   -> load bias
+ * Return:
+ *   0 on error, -1 on failure (error code in errno).
+ */
+int
+phdr_table_protect_segments(const Elf32_Phdr* phdr_table,
+                            int               phdr_count,
+                            Elf32_Addr        load_bias)
+{
+    return _phdr_table_set_load_prot(phdr_table, phdr_count,
+                                      load_bias, 0);
+}
+
+/* Change the protection of all loaded segments in memory to writable.
+ * This is useful before performing relocations. Once completed, you
+ * will have to call phdr_table_protect_segments to restore the original
+ * protection flags on all segments.
+ *
+ * Note that some writable segments can also have their content turned
+ * to read-only by calling phdr_table_protect_gnu_relro. This is no
+ * performed here.
+ *
+ * Input:
+ *   phdr_table  -> program header table
+ *   phdr_count  -> number of entries in tables
+ *   load_bias   -> load bias
+ * Return:
+ *   0 on error, -1 on failure (error code in errno).
+ */
+int
+phdr_table_unprotect_segments(const Elf32_Phdr* phdr_table,
+                              int               phdr_count,
+                              Elf32_Addr        load_bias)
+{
+    return _phdr_table_set_load_prot(phdr_table, phdr_count,
+                                      load_bias, PROT_WRITE);
+}
+
+/* Used internally by phdr_table_protect_gnu_relro and
+ * phdr_table_unprotect_gnu_relro.
+ */
+static int
+_phdr_table_set_gnu_relro_prot(const Elf32_Phdr* phdr_table,
+                               int               phdr_count,
+                               Elf32_Addr        load_bias,
+                               int               prot_flags)
+{
+    const Elf32_Phdr* phdr = phdr_table;
+    const Elf32_Phdr* phdr_limit = phdr + phdr_count;
+
+    for (phdr = phdr_table; phdr < phdr_limit; phdr++) {
+        if (phdr->p_type != PT_GNU_RELRO)
+            continue;
+
+        /* Tricky: what happens when the relro segment does not start
+         * or end at page boundaries?. We're going to be over-protective
+         * here and put every page touched by the segment as read-only.
+         *
+         * This seems to match Ian Lance Taylor's description of the
+         * feature at http://www.airs.com/blog/archives/189.
+         *
+         * Extract:
+         *    Note that the current dynamic linker code will only work
+         *    correctly if the PT_GNU_RELRO segment starts on a page
+         *    boundary. This is because the dynamic linker rounds the
+         *    p_vaddr field down to the previous page boundary. If
+         *    there is anything on the page which should not be read-only,
+         *    the program is likely to fail at runtime. So in effect the
+         *    linker must only emit a PT_GNU_RELRO segment if it ensures
+         *    that it starts on a page boundary.
+         */
+        Elf32_Addr seg_page_start = PAGE_START(phdr->p_vaddr) + load_bias;
+        Elf32_Addr seg_page_end   = PAGE_END(phdr->p_vaddr + phdr->p_memsz) + load_bias;
+
+        int ret = mprotect((void*)seg_page_start,
+                           seg_page_end - seg_page_start,
+                           prot_flags);
+        if (ret < 0) {
+            return -1;
+        }
+    }
+    return 0;
+}
+
+/* Apply GNU relro protection if specified by the program header. This will
+ * turn some of the pages of a writable PT_LOAD segment to read-only, as
+ * specified by one or more PT_GNU_RELRO segments. This must be always
+ * performed after relocations.
+ *
+ * The areas typically covered are .got and .data.rel.ro, these are
+ * read-only from the program's POV, but contain absolute addresses
+ * that need to be relocated before use.
+ *
+ * Input:
+ *   phdr_table  -> program header table
+ *   phdr_count  -> number of entries in tables
+ *   load_bias   -> load bias
+ * Return:
+ *   0 on error, -1 on failure (error code in errno).
+ */
+int
+phdr_table_protect_gnu_relro(const Elf32_Phdr* phdr_table,
+                             int               phdr_count,
+                             Elf32_Addr        load_bias)
+{
+    return _phdr_table_set_gnu_relro_prot(phdr_table,
+                                          phdr_count,
+                                          load_bias,
+                                          PROT_READ);
+}
+
+#ifdef ANDROID_ARM_LINKER
+
+#  ifndef PT_ARM_EXIDX
+#    define PT_ARM_EXIDX    0x70000001      /* .ARM.exidx segment */
+#  endif
+
+/* Return the address and size of the .ARM.exidx section in memory,
+ * if present.
+ *
+ * Input:
+ *   phdr_table  -> program header table
+ *   phdr_count  -> number of entries in tables
+ *   load_bias   -> load bias
+ * Output:
+ *   arm_exidx       -> address of table in memory (NULL on failure).
+ *   arm_exidx_count -> number of items in table (0 on failure).
+ * Return:
+ *   0 on error, -1 on failure (_no_ error code in errno)
+ */
+int
+phdr_table_get_arm_exidx(const Elf32_Phdr* phdr_table,
+                         int               phdr_count,
+                         Elf32_Addr        load_bias,
+                         Elf32_Addr**      arm_exidx,
+                         unsigned*         arm_exidx_count)
+{
+    const Elf32_Phdr* phdr = phdr_table;
+    const Elf32_Phdr* phdr_limit = phdr + phdr_count;
+
+    for (phdr = phdr_table; phdr < phdr_limit; phdr++) {
+        if (phdr->p_type != PT_ARM_EXIDX)
+            continue;
+
+        *arm_exidx = (Elf32_Addr*)(load_bias + phdr->p_vaddr);
+        *arm_exidx_count = (unsigned)(phdr->p_memsz / 8);
+        return 0;
+    }
+    *arm_exidx = NULL;
+    *arm_exidx_count = 0;
+    return -1;
+}
+#endif /* ANDROID_ARM_LINKER */
+
+/* Return the address and size of the ELF file's .dynamic section in memory,
+ * or NULL if missing.
+ *
+ * Input:
+ *   phdr_table  -> program header table
+ *   phdr_count  -> number of entries in tables
+ *   load_bias   -> load bias
+ * Output:
+ *   dynamic       -> address of table in memory (NULL on failure).
+ *   dynamic_count -> number of items in table (0 on failure).
+ *   dynamic_flags -> protection flags for section (unset on failure)
+ * Return:
+ *   void
+ */
+void
+phdr_table_get_dynamic_section(const Elf32_Phdr* phdr_table,
+                               int               phdr_count,
+                               Elf32_Addr        load_bias,
+                               Elf32_Dyn**       dynamic,
+                               size_t*           dynamic_count,
+                               Elf32_Word*       dynamic_flags)
+{
+    const Elf32_Phdr* phdr = phdr_table;
+    const Elf32_Phdr* phdr_limit = phdr + phdr_count;
+
+    for (phdr = phdr_table; phdr < phdr_limit; phdr++) {
+        if (phdr->p_type != PT_DYNAMIC) {
+            continue;
+        }
+
+        *dynamic = reinterpret_cast<Elf32_Dyn*>(load_bias + phdr->p_vaddr);
+        if (dynamic_count) {
+            *dynamic_count = (unsigned)(phdr->p_memsz / 8);
+        }
+        if (dynamic_flags) {
+            *dynamic_flags = phdr->p_flags;
+        }
+        return;
+    }
+    *dynamic = NULL;
+    if (dynamic_count) {
+        *dynamic_count = 0;
+    }
+}
+
+// Returns the address of the program header table as it appears in the loaded
+// segments in memory. This is in contrast with 'phdr_table_' which
+// is temporary and will be released before the library is relocated.
+bool ElfReader::FindPhdr() {
+  const Elf32_Phdr* phdr_limit = phdr_table_ + phdr_num_;
+
+  // If there is a PT_PHDR, use it directly.
+  for (const Elf32_Phdr* phdr = phdr_table_; phdr < phdr_limit; ++phdr) {
+    if (phdr->p_type == PT_PHDR) {
+      return CheckPhdr(load_bias_ + phdr->p_vaddr);
+    }
+  }
+
+  // Otherwise, check the first loadable segment. If its file offset
+  // is 0, it starts with the ELF header, and we can trivially find the
+  // loaded program header from it.
+  for (const Elf32_Phdr* phdr = phdr_table_; phdr < phdr_limit; ++phdr) {
+    if (phdr->p_type == PT_LOAD) {
+      if (phdr->p_offset == 0) {
+        Elf32_Addr  elf_addr = load_bias_ + phdr->p_vaddr;
+        const Elf32_Ehdr* ehdr = (const Elf32_Ehdr*)(void*)elf_addr;
+        Elf32_Addr  offset = ehdr->e_phoff;
+        return CheckPhdr((Elf32_Addr)ehdr + offset);
+      }
+      break;
+    }
+  }
+
+  DL_ERR("can't find loaded phdr for \"%s\"", name_);
+  return false;
+}
+
+// Ensures that our program header is actually within a loadable
+// segment. This should help catch badly-formed ELF files that
+// would cause the linker to crash later when trying to access it.
+bool ElfReader::CheckPhdr(Elf32_Addr loaded) {
+  const Elf32_Phdr* phdr_limit = phdr_table_ + phdr_num_;
+  Elf32_Addr loaded_end = loaded + (phdr_num_ * sizeof(Elf32_Phdr));
+  for (Elf32_Phdr* phdr = phdr_table_; phdr < phdr_limit; ++phdr) {
+    if (phdr->p_type != PT_LOAD) {
+      continue;
+    }
+    Elf32_Addr seg_start = phdr->p_vaddr + load_bias_;
+    Elf32_Addr seg_end = phdr->p_filesz + seg_start;
+    if (seg_start <= loaded && loaded_end <= seg_end) {
+      loaded_phdr_ = reinterpret_cast<const Elf32_Phdr*>(loaded);
+      return true;
+    }
+  }
+  DL_ERR("\"%s\" loaded phdr %x not in loadable segment", name_, loaded);
+  return false;
+}
diff --git a/linker/linker_phdr.h b/linker/linker_phdr.h
index a759262..a31d1d9 100644
--- a/linker/linker_phdr.h
+++ b/linker/linker_phdr.h
@@ -37,39 +37,50 @@
 
 #include "linker.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+class ElfReader {
+ public:
+  ElfReader(const char* name, int fd);
+  ~ElfReader();
 
-/* See linker_phdr.c for all usage documentation */
+  bool Load();
 
-int
-phdr_table_load(int                fd,
-                Elf32_Addr         phdr_offset,
-                Elf32_Half         phdr_num,
-                void**             phdr_mmap,
-                Elf32_Addr*        phdr_size,
-                const Elf32_Phdr** phdr_table);
+  size_t phdr_count() { return phdr_num_; }
+  Elf32_Addr load_start() { return reinterpret_cast<Elf32_Addr>(load_start_); }
+  Elf32_Addr load_size() { return load_size_; }
+  Elf32_Addr load_bias() { return load_bias_; }
+  const Elf32_Phdr* loaded_phdr() { return loaded_phdr_; }
 
-void
-phdr_table_unload(void* phdr_mmap, Elf32_Addr phdr_memsize);
+ private:
+  bool ReadElfHeader();
+  bool VerifyElfHeader();
+  bool ReadProgramHeader();
+  bool ReserveAddressSpace();
+  bool LoadSegments();
+  bool FindPhdr();
+  bool CheckPhdr(Elf32_Addr);
 
-Elf32_Addr
-phdr_table_get_load_size(const Elf32_Phdr* phdr_table,
-                         size_t phdr_count);
+  const char* name_;
+  int fd_;
 
-int
-phdr_table_reserve_memory(const Elf32_Phdr* phdr_table,
-                          size_t phdr_count,
-                          void** load_start,
-                          Elf32_Addr* load_size,
-                          Elf32_Addr* load_bias);
+  Elf32_Ehdr header_;
+  size_t phdr_num_;
 
-int
-phdr_table_load_segments(const Elf32_Phdr* phdr_table,
-                         int               phdr_count,
-                         Elf32_Addr        load_bias,
-                         int               fd);
+  void* phdr_mmap_;
+  Elf32_Phdr* phdr_table_;
+  Elf32_Addr phdr_size_;
+
+  // First page of reserved address space.
+  void* load_start_;
+  // Size in bytes of reserved address space.
+  Elf32_Addr load_size_;
+  // Load bias.
+  Elf32_Addr load_bias_;
+
+  // Loaded phdr.
+  const Elf32_Phdr* loaded_phdr_;
+};
+
+Elf32_Addr phdr_table_get_load_size(const Elf32_Phdr* phdr, size_t phnum);
 
 int
 phdr_table_protect_segments(const Elf32_Phdr* phdr_table,
@@ -86,10 +97,6 @@
                              int               phdr_count,
                              Elf32_Addr        load_bias);
 
-const Elf32_Phdr*
-phdr_table_get_loaded_phdr(const Elf32_Phdr*   phdr_table,
-                           int                 phdr_count,
-                           Elf32_Addr          load_bias);
 
 #ifdef ANDROID_ARM_LINKER
 int
@@ -104,11 +111,8 @@
 phdr_table_get_dynamic_section(const Elf32_Phdr* phdr_table,
                                int               phdr_count,
                                Elf32_Addr        load_bias,
-                               Elf32_Addr**      dynamic,
-                               size_t*           dynamic_count);
-
-#ifdef __cplusplus
-};
-#endif
+                               Elf32_Dyn**       dynamic,
+                               size_t*           dynamic_count,
+                               Elf32_Word*       dynamic_flags);
 
 #endif /* LINKER_PHDR_H */
diff --git a/linker/rt.c b/linker/rt.c
deleted file mode 100644
index afbd651..0000000
--- a/linker/rt.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * This function is an empty stub where GDB locates a breakpoint to get notified
- * about linker activity.  It canʼt be inlined away, canʼt be hidden.
- */
-void __attribute__((noinline)) __attribute__((visibility("default"))) rtld_db_dlactivity(void)
-{
-}
-
diff --git a/linker/rt.cpp b/linker/rt.cpp
new file mode 100644
index 0000000..710892a
--- /dev/null
+++ b/linker/rt.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * This function is an empty stub where GDB locates a breakpoint to get notified
+ * about linker activity.  It canʼt be inlined away, can't be hidden.
+ */
+extern "C" void __attribute__((noinline)) __attribute__((visibility("default"))) rtld_db_dlactivity() {
+}
+
diff --git a/tests/Android.mk b/tests/Android.mk
index be47585..1e4ef59 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -18,38 +18,109 @@
 
 LOCAL_PATH := $(call my-dir)
 
+# -----------------------------------------------------------------------------
+# Benchmarks.
+# -----------------------------------------------------------------------------
+
+benchmark_c_flags = \
+    -O2 \
+    -Wall -Wextra \
+    -Werror \
+    -fno-builtin \
+
+benchmark_src_files = \
+    benchmark_main.cpp \
+    math_benchmark.cpp \
+    string_benchmark.cpp \
+
+# Build benchmarks for the device (with bionic's .so). Run with:
+#   adb shell bionic-benchmarks
+include $(CLEAR_VARS)
+LOCAL_MODULE := bionic-benchmarks
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+LOCAL_CFLAGS += $(benchmark_c_flags)
+LOCAL_C_INCLUDES += external/stlport/stlport bionic/ bionic/libstdc++/include
+LOCAL_SHARED_LIBRARIES += libstlport
+LOCAL_SRC_FILES := $(benchmark_src_files)
+include $(BUILD_EXECUTABLE)
+
+# -----------------------------------------------------------------------------
+# Unit tests.
+# -----------------------------------------------------------------------------
+
+test_c_flags = \
+    -fstack-protector-all \
+    -g \
+    -Wall -Wextra \
+    -Werror \
+    -fno-builtin \
+
 test_src_files = \
+    debug_format_test.cpp \
+    dirent_test.cpp \
+    fenv_test.cpp \
+    getauxval_test.cpp \
     getcwd_test.cpp \
+    libgen_test.cpp \
+    math_test.cpp \
+    netdb_test.cpp \
     pthread_test.cpp \
     regex_test.cpp \
+    signal_test.cpp \
+    stack_protector_test.cpp \
+    stdio_test.cpp \
+    stdlib_test.cpp \
     string_test.cpp \
+    strings_test.cpp \
     stubs_test.cpp \
+    unistd_test.cpp \
 
 test_dynamic_ldflags = -Wl,--export-dynamic -Wl,-u,DlSymTestFunction
 test_dynamic_src_files = \
-    dlopen_test.cpp \
+    dlfcn_test.cpp \
 
-# Build for the device (with bionic's .so). Run with:
+# Build tests for the device (with bionic's .so). Run with:
 #   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
 include $(CLEAR_VARS)
 LOCAL_MODULE := bionic-unit-tests
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+LOCAL_CFLAGS += $(test_c_flags)
 LOCAL_LDFLAGS += $(test_dynamic_ldflags)
 LOCAL_SHARED_LIBRARIES += libdl
 LOCAL_SRC_FILES := $(test_src_files) $(test_dynamic_src_files)
 include $(BUILD_NATIVE_TEST)
 
-# Build for the device (with bionic's .a). Run with:
+# Build tests for the device (with bionic's .a). Run with:
 #   adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
 include $(CLEAR_VARS)
 LOCAL_MODULE := bionic-unit-tests-static
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+LOCAL_CFLAGS += $(test_c_flags)
 LOCAL_FORCE_STATIC_EXECUTABLE := true
 LOCAL_SRC_FILES := $(test_src_files)
 LOCAL_STATIC_LIBRARIES += libstlport_static libstdc++ libm libc
 include $(BUILD_NATIVE_TEST)
 
-# Build for the host (with glibc).
+# -----------------------------------------------------------------------------
+# Test library for the unit tests.
+# -----------------------------------------------------------------------------
+
+# Build no-elf-hash-table-library.so to test dlopen(3) on a library that
+# only has a GNU-style hash table. MIPS doesn't support GNU hash style.
+ifneq ($(TARGET_ARCH),mips)
+include $(CLEAR_VARS)
+LOCAL_MODULE := no-elf-hash-table-library
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+LOCAL_SRC_FILES := empty.cpp
+LOCAL_LDFLAGS := -Wl,--hash-style=gnu
+include $(BUILD_SHARED_LIBRARY)
+endif
+
+# -----------------------------------------------------------------------------
+# Unit tests built against glibc.
+# -----------------------------------------------------------------------------
+
+# Build tests for the host (with glibc).
 # Note that this will build against glibc, so it's not useful for testing
 # bionic's implementation, but it does let you use glibc as a reference
 # implementation for testing the tests themselves.
@@ -57,6 +128,7 @@
 include $(CLEAR_VARS)
 LOCAL_MODULE := bionic-unit-tests-glibc
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+LOCAL_CFLAGS += $(test_c_flags)
 LOCAL_LDFLAGS += -lpthread -ldl
 LOCAL_LDFLAGS += $(test_dynamic_ldflags)
 LOCAL_SRC_FILES := $(test_src_files) $(test_dynamic_src_files)
diff --git a/tests/benchmark.h b/tests/benchmark.h
new file mode 100644
index 0000000..d7af50f
--- /dev/null
+++ b/tests/benchmark.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdint.h>
+
+#include <vector>
+
+namespace testing {
+
+class Benchmark {
+ public:
+  Benchmark(const char* name, void (*fn)(int)) {
+    Register(name, fn, NULL);
+  }
+
+  Benchmark(const char* name, void (*fn_range)(int, int)) {
+    Register(name, NULL, fn_range);
+  }
+
+  Benchmark* Arg(int x);
+
+  const char* Name();
+
+  bool ShouldRun(int argc, char* argv[]);
+  void Run();
+
+ private:
+  const char* name_;
+
+  void (*fn_)(int);
+  void (*fn_range_)(int, int);
+
+  std::vector<int> args_;
+
+  void Register(const char* name, void (*fn)(int), void (*fn_range)(int, int));
+  void RunRepeatedlyWithArg(int iterations, int arg);
+  void RunWithArg(int arg);
+};
+
+}  // namespace testing
+
+void SetBenchmarkBytesProcessed(int64_t);
+void StopBenchmarkTiming();
+void StartBenchmarkTiming();
+
+#define BENCHMARK(f) \
+    static ::testing::Benchmark* _benchmark_##f __attribute__((unused)) = \
+        (new ::testing::Benchmark(#f, f))
diff --git a/tests/benchmark_main.cpp b/tests/benchmark_main.cpp
new file mode 100644
index 0000000..e15a688
--- /dev/null
+++ b/tests/benchmark_main.cpp
@@ -0,0 +1,218 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "benchmark.h"
+
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <string>
+#include <map>
+
+static int64_t gBytesProcessed;
+static int64_t gBenchmarkTotalTimeNs;
+static int64_t gBenchmarkStartTimeNs;
+
+typedef std::map<std::string, ::testing::Benchmark*> BenchmarkMap;
+typedef BenchmarkMap::iterator BenchmarkMapIt;
+static BenchmarkMap gBenchmarks;
+
+static int Round(int n) {
+  int base = 1;
+  while (base*10 < n) {
+    base *= 10;
+  }
+  if (n < 2*base) {
+    return 2*base;
+  }
+  if (n < 5*base) {
+    return 5*base;
+  }
+  return 10*base;
+}
+
+static int64_t NanoTime() {
+  struct timespec t;
+  t.tv_sec = t.tv_nsec = 0;
+  clock_gettime(CLOCK_MONOTONIC, &t);
+  return static_cast<int64_t>(t.tv_sec) * 1000000000LL + t.tv_nsec;
+}
+
+namespace testing {
+
+Benchmark* Benchmark::Arg(int arg) {
+  args_.push_back(arg);
+  return this;
+}
+
+const char* Benchmark::Name() {
+  return name_;
+}
+
+bool Benchmark::ShouldRun(int argc, char* argv[]) {
+  if (argc == 1) {
+    return true;  // With no arguments, we run all benchmarks.
+  }
+  // Otherwise, we interpret each argument as a regular expression and
+  // see if any of our benchmarks match.
+  for (int i = 1; i < argc; i++) {
+    regex_t re;
+    if (regcomp(&re, argv[i], 0) != 0) {
+      fprintf(stderr, "couldn't compile \"%s\" as a regular expression!\n", argv[i]);
+      exit(EXIT_FAILURE);
+    }
+    int match = regexec(&re, name_, 0, NULL, 0);
+    regfree(&re);
+    if (match != REG_NOMATCH) {
+      return true;
+    }
+  }
+  return false;
+}
+
+void Benchmark::Register(const char* name, void (*fn)(int), void (*fn_range)(int, int)) {
+  name_ = name;
+  fn_ = fn;
+  fn_range_ = fn_range;
+
+  if (fn_ == NULL && fn_range_ == NULL) {
+    fprintf(stderr, "%s: missing function\n", name_);
+    exit(EXIT_FAILURE);
+  }
+
+  gBenchmarks.insert(std::make_pair(name, this));
+}
+
+void Benchmark::Run() {
+  if (fn_ != NULL) {
+    RunWithArg(0);
+  } else {
+    if (args_.empty()) {
+      fprintf(stderr, "%s: no args!\n", name_);
+      exit(EXIT_FAILURE);
+    }
+    for (size_t i = 0; i < args_.size(); ++i) {
+      RunWithArg(args_[i]);
+    }
+  }
+}
+
+void Benchmark::RunRepeatedlyWithArg(int iterations, int arg) {
+  gBytesProcessed = 0;
+  gBenchmarkTotalTimeNs = 0;
+  gBenchmarkStartTimeNs = NanoTime();
+  if (fn_ != NULL) {
+    fn_(iterations);
+  } else {
+    fn_range_(iterations, arg);
+  }
+  if (gBenchmarkStartTimeNs != 0) {
+    gBenchmarkTotalTimeNs += NanoTime() - gBenchmarkStartTimeNs;
+  }
+}
+
+void Benchmark::RunWithArg(int arg) {
+  // run once in case it's expensive
+  int iterations = 1;
+  RunRepeatedlyWithArg(iterations, arg);
+  while (gBenchmarkTotalTimeNs < 1e9 && iterations < 1e9) {
+    int last = iterations;
+    if (gBenchmarkTotalTimeNs/iterations == 0) {
+      iterations = 1e9;
+    } else {
+      iterations = 1e9 / (gBenchmarkTotalTimeNs/iterations);
+    }
+    iterations = std::max(last + 1, std::min(iterations + iterations/2, 100*last));
+    iterations = Round(iterations);
+    RunRepeatedlyWithArg(iterations, arg);
+  }
+
+  char throughput[100];
+  throughput[0] = '\0';
+  if (gBenchmarkTotalTimeNs > 0 && gBytesProcessed > 0) {
+    double mib_processed = static_cast<double>(gBytesProcessed)/1e6;
+    double seconds = static_cast<double>(gBenchmarkTotalTimeNs)/1e9;
+    snprintf(throughput, sizeof(throughput), " %8.2f MiB/s", mib_processed/seconds);
+  }
+
+  char full_name[100];
+  if (fn_range_ != NULL) {
+    if (arg >= (1<<20)) {
+      snprintf(full_name, sizeof(full_name), "%s/%dM", name_, arg/(1<<20));
+    } else if (arg >= (1<<10)) {
+      snprintf(full_name, sizeof(full_name), "%s/%dK", name_, arg/(1<<10));
+    } else {
+      snprintf(full_name, sizeof(full_name), "%s/%d", name_, arg);
+    }
+  } else {
+    snprintf(full_name, sizeof(full_name), "%s", name_);
+  }
+
+  printf("%-20s %10lld %10lld%s\n", full_name,
+         static_cast<int64_t>(iterations), gBenchmarkTotalTimeNs/iterations, throughput);
+  fflush(stdout);
+}
+
+}  // namespace testing
+
+void SetBenchmarkBytesProcessed(int64_t x) {
+  gBytesProcessed = x;
+}
+
+void StopBenchmarkTiming() {
+  if (gBenchmarkStartTimeNs != 0) {
+    gBenchmarkTotalTimeNs += NanoTime() - gBenchmarkStartTimeNs;
+  }
+  gBenchmarkStartTimeNs = 0;
+}
+
+void StartBenchmarkTiming() {
+  if (gBenchmarkStartTimeNs == 0) {
+    gBenchmarkStartTimeNs = NanoTime();
+  }
+}
+
+int main(int argc, char* argv[]) {
+  if (gBenchmarks.empty()) {
+    fprintf(stderr, "No benchmarks registered!\n");
+    exit(EXIT_FAILURE);
+  }
+
+  bool need_header = true;
+  for (BenchmarkMapIt it = gBenchmarks.begin(); it != gBenchmarks.end(); ++it) {
+    ::testing::Benchmark* b = it->second;
+    if (b->ShouldRun(argc, argv)) {
+      if (need_header) {
+        printf("%-20s %10s %10s\n", "", "iterations", "ns/op");
+        fflush(stdout);
+        need_header = false;
+      }
+      b->Run();
+    }
+  }
+
+  if (need_header) {
+    fprintf(stderr, "No matching benchmarks!\n");
+    fprintf(stderr, "Available benchmarks:\n");
+    for (BenchmarkMapIt it = gBenchmarks.begin(); it != gBenchmarks.end(); ++it) {
+      fprintf(stderr, "  %s\n", it->second->Name());
+    }
+    exit(EXIT_FAILURE);
+  }
+
+  return 0;
+}
diff --git a/tests/debug_format_test.cpp b/tests/debug_format_test.cpp
new file mode 100644
index 0000000..8419e4a
--- /dev/null
+++ b/tests/debug_format_test.cpp
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+#if defined(__BIONIC__)
+
+#include "../libc/bionic/debug_format.cpp"
+
+extern int __libc_format_buffer(char* buffer, size_t buffer_size, const char* format, ...);
+
+TEST(debug_format, smoke) {
+  char buf[BUFSIZ];
+
+  __libc_format_buffer(buf, sizeof(buf), "a");
+  EXPECT_STREQ("a", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "%%");
+  EXPECT_STREQ("%", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "01234");
+  EXPECT_STREQ("01234", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "a%sb", "01234");
+  EXPECT_STREQ("a01234b", buf);
+
+  char* s = NULL;
+  __libc_format_buffer(buf, sizeof(buf), "a%sb", s);
+  EXPECT_STREQ("a(null)b", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "aa%scc", "bb");
+  EXPECT_STREQ("aabbcc", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "a%cc", 'b');
+  EXPECT_STREQ("abc", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "a%db", 1234);
+  EXPECT_STREQ("a1234b", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "a%db", -8123);
+  EXPECT_STREQ("a-8123b", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "a%hdb", 0x7fff0010);
+  EXPECT_STREQ("a16b", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "a%hhdb", 0x7fffff10);
+  EXPECT_STREQ("a16b", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "a%lldb", 0x1000000000LL);
+  EXPECT_STREQ("a68719476736b", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "a%ldb", 70000L);
+  EXPECT_STREQ("a70000b", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "a%pb", reinterpret_cast<void*>(0xb0001234));
+  EXPECT_STREQ("a0xb0001234b", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "a%xz", 0x12ab);
+  EXPECT_STREQ("a12abz", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "a%Xz", 0x12ab);
+  EXPECT_STREQ("a12ABz", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "a%08xz", 0x123456);
+  EXPECT_STREQ("a00123456z", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "a%5dz", 1234);
+  EXPECT_STREQ("a 1234z", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "a%05dz", 1234);
+  EXPECT_STREQ("a01234z", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "a%8dz", 1234);
+  EXPECT_STREQ("a    1234z", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "a%-8dz", 1234);
+  EXPECT_STREQ("a1234    z", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "A%-11sZ", "abcdef");
+  EXPECT_STREQ("Aabcdef     Z", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "A%s:%dZ", "hello", 1234);
+  EXPECT_STREQ("Ahello:1234Z", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "a%03d:%d:%02dz", 5, 5, 5);
+  EXPECT_STREQ("a005:5:05z", buf);
+
+  void* p = NULL;
+  __libc_format_buffer(buf, sizeof(buf), "a%d,%pz", 5, p);
+  EXPECT_STREQ("a5,0x0z", buf);
+
+  __libc_format_buffer(buf, sizeof(buf), "a%lld,%d,%d,%dz", 0x1000000000LL, 6, 7, 8);
+  EXPECT_STREQ("a68719476736,6,7,8z", buf);
+}
+
+TEST(debug_format, d_INT_MAX) {
+  char buf[BUFSIZ];
+  __libc_format_buffer(buf, sizeof(buf), "%d", INT_MAX);
+  EXPECT_STREQ("2147483647", buf);
+}
+
+TEST(debug_format, d_INT_MIN) {
+  char buf[BUFSIZ];
+  __libc_format_buffer(buf, sizeof(buf), "%d", INT_MIN);
+  EXPECT_STREQ("-2147483648", buf);
+}
+
+TEST(debug_format, ld_LONG_MAX) {
+  char buf[BUFSIZ];
+  __libc_format_buffer(buf, sizeof(buf), "%ld", LONG_MAX);
+  EXPECT_STREQ("2147483647", buf);
+}
+
+TEST(debug_format, ld_LONG_MIN) {
+  char buf[BUFSIZ];
+  __libc_format_buffer(buf, sizeof(buf), "%ld", LONG_MIN);
+  EXPECT_STREQ("-2147483648", buf);
+}
+
+TEST(debug_format, lld_LLONG_MAX) {
+  char buf[BUFSIZ];
+  __libc_format_buffer(buf, sizeof(buf), "%lld", LLONG_MAX);
+  EXPECT_STREQ("9223372036854775807", buf);
+}
+
+TEST(debug_format, lld_LLONG_MIN) {
+  char buf[BUFSIZ];
+  __libc_format_buffer(buf, sizeof(buf), "%lld", LLONG_MIN);
+  EXPECT_STREQ("-9223372036854775808", buf);
+}
+
+#endif
diff --git a/tests/dirent_test.cpp b/tests/dirent_test.cpp
new file mode 100644
index 0000000..48ca819
--- /dev/null
+++ b/tests/dirent_test.cpp
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <algorithm>
+#include <set>
+#include <string>
+
+static void CheckProcSelf(std::set<std::string>& names) {
+  // We have a good idea of what should be in /proc/self.
+  ASSERT_TRUE(names.find(".") != names.end());
+  ASSERT_TRUE(names.find("..") != names.end());
+  ASSERT_TRUE(names.find("cmdline") != names.end());
+  ASSERT_TRUE(names.find("fd") != names.end());
+  ASSERT_TRUE(names.find("stat") != names.end());
+}
+
+TEST(dirent, scandir) {
+  // Get everything from /proc/self...
+  dirent** entries;
+  int entry_count = scandir("/proc/self", &entries, NULL, alphasort);
+  ASSERT_GE(entry_count, 0);
+
+  // Turn the directory entries into a set and vector of the names.
+  std::set<std::string> name_set;
+  std::vector<std::string> unsorted_name_list;
+  for (size_t i = 0; i < static_cast<size_t>(entry_count); ++i) {
+    name_set.insert(entries[i]->d_name);
+    unsorted_name_list.push_back(entries[i]->d_name);
+    free(entries[i]);
+  }
+  free(entries);
+
+  // No duplicates.
+  ASSERT_EQ(name_set.size(), unsorted_name_list.size());
+
+  // All entries sorted.
+  std::vector<std::string> sorted_name_list(unsorted_name_list);
+  std::sort(sorted_name_list.begin(), sorted_name_list.end());
+  ASSERT_EQ(sorted_name_list, unsorted_name_list);
+
+  CheckProcSelf(name_set);
+}
+
+TEST(dirent, fdopendir_invalid) {
+  ASSERT_TRUE(fdopendir(-1) == NULL);
+  ASSERT_EQ(EBADF, errno);
+
+  int fd = open("/dev/null", O_RDONLY);
+  ASSERT_NE(fd, -1);
+  ASSERT_TRUE(fdopendir(fd) == NULL);
+  ASSERT_EQ(ENOTDIR, errno);
+  close(fd);
+}
+
+TEST(dirent, fdopendir) {
+  int fd = open("/proc/self", O_RDONLY);
+  DIR* d = fdopendir(fd);
+  ASSERT_TRUE(d != NULL);
+  dirent* e = readdir(d);
+  ASSERT_STREQ(e->d_name, ".");
+  ASSERT_EQ(closedir(d), 0);
+
+  // fdopendir(3) took ownership, so closedir(3) closed our fd.
+  ASSERT_EQ(close(fd), -1);
+  ASSERT_EQ(EBADF, errno);
+}
+
+TEST(dirent, opendir_invalid) {
+  ASSERT_TRUE(opendir("/does/not/exist") == NULL);
+  ASSERT_EQ(ENOENT, errno);
+
+  ASSERT_TRUE(opendir("/dev/null") == NULL);
+  ASSERT_EQ(ENOTDIR, errno);
+}
+
+TEST(dirent, opendir) {
+  DIR* d = opendir("/proc/self");
+  ASSERT_TRUE(d != NULL);
+  dirent* e = readdir(d);
+  ASSERT_STREQ(e->d_name, ".");
+  ASSERT_EQ(closedir(d), 0);
+}
+
+TEST(dirent, closedir_invalid) {
+  DIR* d = NULL;
+  ASSERT_EQ(closedir(d), -1);
+  ASSERT_EQ(EINVAL, errno);
+}
+
+TEST(dirent, closedir) {
+  DIR* d = opendir("/proc/self");
+  ASSERT_TRUE(d != NULL);
+  ASSERT_EQ(closedir(d), 0);
+}
+
+TEST(dirent, readdir) {
+  DIR* d = opendir("/proc/self");
+  ASSERT_TRUE(d != NULL);
+  std::set<std::string> name_set;
+  errno = 0;
+  dirent* e;
+  while ((e = readdir(d)) != NULL) {
+    name_set.insert(e->d_name);
+  }
+  // Reading to the end of the directory is not an error.
+  // readdir(3) returns NULL, but leaves errno as 0.
+  ASSERT_EQ(0, errno);
+  ASSERT_EQ(closedir(d), 0);
+
+  CheckProcSelf(name_set);
+}
+
+TEST(dirent, readdir_r) {
+  DIR* d = opendir("/proc/self");
+  ASSERT_TRUE(d != NULL);
+  std::set<std::string> name_set;
+  errno = 0;
+  dirent storage;
+  dirent* e = NULL;
+  while (readdir_r(d, &storage, &e) == 0 && e != NULL) {
+    name_set.insert(e->d_name);
+  }
+  // Reading to the end of the directory is not an error.
+  // readdir_r(3) returns NULL, but leaves errno as 0.
+  ASSERT_EQ(0, errno);
+  ASSERT_EQ(closedir(d), 0);
+
+  CheckProcSelf(name_set);
+}
+
+TEST(dirent, rewinddir) {
+  DIR* d = opendir("/proc/self");
+  ASSERT_TRUE(d != NULL);
+
+  // Get all the names once...
+  std::vector<std::string> pass1;
+  dirent* e;
+  while ((e = readdir(d)) != NULL) {
+    pass1.push_back(e->d_name);
+  }
+
+  // ...rewind...
+  rewinddir(d);
+
+  // ...and get all the names again.
+  std::vector<std::string> pass2;
+  while ((e = readdir(d)) != NULL) {
+    pass2.push_back(e->d_name);
+  }
+
+  ASSERT_EQ(closedir(d), 0);
+
+  // We should have seen the same names in the same order both times.
+  ASSERT_EQ(pass1.size(), pass2.size());
+  for (size_t i = 0; i < pass1.size(); ++i) {
+    ASSERT_EQ(pass1[i], pass2[i]);
+  }
+}
diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp
new file mode 100644
index 0000000..938b8a5
--- /dev/null
+++ b/tests/dlfcn_test.cpp
@@ -0,0 +1,224 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+#include <dlfcn.h>
+#include <libgen.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdint.h>
+
+#include <string>
+
+#define ASSERT_SUBSTR(needle, haystack) \
+    ASSERT_PRED_FORMAT2(::testing::IsSubstring, needle, haystack)
+
+static bool gCalled = false;
+extern "C" void DlSymTestFunction() {
+  gCalled = true;
+}
+
+TEST(dlfcn, dlsym_in_self) {
+  dlerror(); // Clear any pending errors.
+  void* self = dlopen(NULL, RTLD_NOW);
+  ASSERT_TRUE(self != NULL);
+  ASSERT_TRUE(dlerror() == NULL);
+
+  void* sym = dlsym(self, "DlSymTestFunction");
+  ASSERT_TRUE(sym != NULL);
+
+  void (*function)() = reinterpret_cast<void(*)()>(sym);
+
+  gCalled = false;
+  function();
+  ASSERT_TRUE(gCalled);
+
+  ASSERT_EQ(0, dlclose(self));
+}
+
+TEST(dlfcn, dlopen_failure) {
+  void* self = dlopen("/does/not/exist", RTLD_NOW);
+  ASSERT_TRUE(self == NULL);
+#if __BIONIC__
+  ASSERT_STREQ("dlopen failed: library \"/does/not/exist\" not found", dlerror());
+#else
+  ASSERT_STREQ("/does/not/exist: cannot open shared object file: No such file or directory", dlerror());
+#endif
+}
+
+static void* ConcurrentDlErrorFn(void*) {
+  dlopen("/child/thread", RTLD_NOW);
+  return reinterpret_cast<void*>(strdup(dlerror()));
+}
+
+TEST(dlfcn, dlerror_concurrent) {
+  dlopen("/main/thread", RTLD_NOW);
+  const char* main_thread_error = dlerror();
+  ASSERT_SUBSTR("/main/thread", main_thread_error);
+
+  pthread_t t;
+  ASSERT_EQ(0, pthread_create(&t, NULL, ConcurrentDlErrorFn, NULL));
+  void* result;
+  ASSERT_EQ(0, pthread_join(t, &result));
+  char* child_thread_error = static_cast<char*>(result);
+  ASSERT_SUBSTR("/child/thread", child_thread_error);
+  free(child_thread_error);
+
+  ASSERT_SUBSTR("/main/thread", main_thread_error);
+}
+
+TEST(dlfcn, dlsym_failures) {
+  dlerror(); // Clear any pending errors.
+  void* self = dlopen(NULL, RTLD_NOW);
+  ASSERT_TRUE(self != NULL);
+  ASSERT_TRUE(dlerror() == NULL);
+
+  void* sym;
+
+  // NULL handle.
+  sym = dlsym(NULL, "test");
+  ASSERT_TRUE(sym == NULL);
+#if __BIONIC__
+  ASSERT_SUBSTR("dlsym library handle is null", dlerror());
+#else
+  ASSERT_SUBSTR("undefined symbol: test", dlerror()); // glibc isn't specific about the failure.
+#endif
+
+  // NULL symbol name.
+#if __BIONIC__
+  // glibc marks this parameter non-null and SEGVs if you cheat.
+  sym = dlsym(self, NULL);
+  ASSERT_TRUE(sym == NULL);
+  ASSERT_SUBSTR("", dlerror());
+#endif
+
+  // Symbol that doesn't exist.
+  sym = dlsym(self, "ThisSymbolDoesNotExist");
+  ASSERT_TRUE(sym == NULL);
+  ASSERT_SUBSTR("undefined symbol: ThisSymbolDoesNotExist", dlerror());
+
+  ASSERT_EQ(0, dlclose(self));
+}
+
+TEST(dlfcn, dladdr) {
+  dlerror(); // Clear any pending errors.
+  void* self = dlopen(NULL, RTLD_NOW);
+  ASSERT_TRUE(self != NULL);
+  ASSERT_TRUE(dlerror() == NULL);
+
+  void* sym = dlsym(self, "DlSymTestFunction");
+  ASSERT_TRUE(sym != NULL);
+
+  // Deliberately ask dladdr for an address inside a symbol, rather than the symbol base address.
+  void* addr = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(sym) + 2);
+
+  Dl_info info;
+  int rc = dladdr(addr, &info);
+  ASSERT_NE(rc, 0); // Zero on error, non-zero on success.
+
+  // Get the name of this executable.
+  char executable_path[PATH_MAX];
+  rc = readlink("/proc/self/exe", executable_path, sizeof(executable_path));
+  ASSERT_NE(rc, -1);
+  executable_path[rc] = '\0';
+  std::string executable_name(basename(executable_path));
+
+  // The filename should be that of this executable.
+  // Note that we don't know whether or not we have the full path, so we want an "ends_with" test.
+  std::string dli_fname(info.dli_fname);
+  dli_fname = basename(&dli_fname[0]);
+  ASSERT_EQ(dli_fname, executable_name);
+
+  // The symbol name should be the symbol we looked up.
+  ASSERT_STREQ(info.dli_sname, "DlSymTestFunction");
+
+  // The address should be the exact address of the symbol.
+  ASSERT_EQ(info.dli_saddr, sym);
+
+  // Look in /proc/pid/maps to find out what address we were loaded at.
+  // TODO: factor /proc/pid/maps parsing out into a class and reuse all over bionic.
+  void* base_address = NULL;
+  char path[PATH_MAX];
+  snprintf(path, sizeof(path), "/proc/%d/maps", getpid());
+  char line[BUFSIZ];
+  FILE* fp = fopen(path, "r");
+  ASSERT_TRUE(fp != NULL);
+  while (fgets(line, sizeof(line), fp) != NULL) {
+    uintptr_t start = strtoul(line, 0, 16);
+    line[strlen(line) - 1] = '\0'; // Chomp the '\n'.
+    char* path = strchr(line, '/');
+    if (path != NULL && strcmp(executable_path, path) == 0) {
+      base_address = reinterpret_cast<void*>(start);
+      break;
+    }
+  }
+  fclose(fp);
+
+  // The base address should be the address we were loaded at.
+  ASSERT_EQ(info.dli_fbase, base_address);
+
+  ASSERT_EQ(0, dlclose(self));
+}
+
+TEST(dlfcn, dladdr_invalid) {
+  Dl_info info;
+
+  dlerror(); // Clear any pending errors.
+
+  // No symbol corresponding to NULL.
+  ASSERT_EQ(dladdr(NULL, &info), 0); // Zero on error, non-zero on success.
+  ASSERT_TRUE(dlerror() == NULL); // dladdr(3) doesn't set dlerror(3).
+
+  // No symbol corresponding to a stack address.
+  ASSERT_EQ(dladdr(&info, &info), 0); // Zero on error, non-zero on success.
+  ASSERT_TRUE(dlerror() == NULL); // dladdr(3) doesn't set dlerror(3).
+}
+
+// Our dynamic linker doesn't support GNU hash tables.
+#if defined(__BIONIC__)
+// GNU-style ELF hash tables are incompatible with the MIPS ABI.
+// MIPS requires .dynsym to be sorted to match the GOT but GNU-style requires sorting by hash code.
+#if !defined(__mips__)
+TEST(dlfcn, dlopen_library_with_only_gnu_hash) {
+  dlerror(); // Clear any pending errors.
+  void* handle = dlopen("no-elf-hash-table-library.so", RTLD_NOW);
+  ASSERT_TRUE(handle == NULL);
+  ASSERT_STREQ("dlopen failed: empty/missing DT_HASH in \"no-elf-hash-table-library.so\" (built with --hash-style=gnu?)", dlerror());
+}
+#endif
+#endif
+
+TEST(dlfcn, dlopen_bad_flags) {
+  dlerror(); // Clear any pending errors.
+  void* handle;
+
+#ifdef __GLIBC__
+  // glibc was smart enough not to define RTLD_NOW as 0, so it can detect missing flags.
+  handle = dlopen(NULL, 0);
+  ASSERT_TRUE(handle == NULL);
+  ASSERT_SUBSTR("invalid", dlerror());
+#endif
+
+  handle = dlopen(NULL, 0xffffffff);
+  ASSERT_TRUE(handle == NULL);
+  ASSERT_SUBSTR("invalid", dlerror());
+
+  // glibc actually allows you to choose both RTLD_NOW and RTLD_LAZY at the same time, and so do we.
+  handle = dlopen(NULL, RTLD_NOW|RTLD_LAZY);
+  ASSERT_TRUE(handle != NULL);
+  ASSERT_SUBSTR(NULL, dlerror());
+}
diff --git a/tests/dlopen_test.cpp b/tests/dlopen_test.cpp
deleted file mode 100644
index c290b4d..0000000
--- a/tests/dlopen_test.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <gtest/gtest.h>
-
-#include <dlfcn.h>
-
-static bool gCalled = false;
-extern "C" void DlSymTestFunction() {
-  gCalled = true;
-}
-
-TEST(dlopen, dlsym_in_self) {
-  void* self = dlopen(NULL, RTLD_NOW);
-  ASSERT_TRUE(self != NULL);
-
-  void* sym = dlsym(self, "DlSymTestFunction");
-  ASSERT_TRUE(sym != NULL);
-
-  void (*function)() = reinterpret_cast<void(*)()>(sym);
-
-  gCalled = false;
-  function();
-  ASSERT_TRUE(gCalled);
-}
diff --git a/tests/empty.cpp b/tests/empty.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/empty.cpp
diff --git a/tests/fenv_test.cpp b/tests/fenv_test.cpp
new file mode 100644
index 0000000..db1bfc3
--- /dev/null
+++ b/tests/fenv_test.cpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+#include <fenv.h>
+#include <stdint.h>
+
+static void TestRounding(float expectation1, float expectation2) {
+  // volatile to prevent compiler optimizations.
+  volatile float f = 1.968750f;
+  volatile float m = 0x1.0p23f;
+  volatile float x = f + m;
+  ASSERT_FLOAT_EQ(expectation1, x);
+  x -= m;
+  ASSERT_EQ(expectation2, x);
+}
+
+static void DivideByZero() {
+  // volatile to prevent compiler optimizations.
+  volatile float zero = 0.0f;
+  volatile float result __attribute__((unused)) = 123.0f / zero;
+}
+
+TEST(fenv, fesetround_fegetround_FE_TONEAREST) {
+  fesetround(FE_TONEAREST);
+  ASSERT_EQ(FE_TONEAREST, fegetround());
+  TestRounding(8388610.0f, 2.0f);
+}
+
+TEST(fenv, fesetround_fegetround_FE_TOWARDZERO) {
+  fesetround(FE_TOWARDZERO);
+  ASSERT_EQ(FE_TOWARDZERO, fegetround());
+  TestRounding(8388609.0f, 1.0f);
+}
+
+TEST(fenv, fesetround_fegetround_FE_UPWARD) {
+  fesetround(FE_UPWARD);
+  ASSERT_EQ(FE_UPWARD, fegetround());
+  TestRounding(8388610.0f, 2.0f);
+}
+
+TEST(fenv, fesetround_fegetround_FE_DOWNWARD) {
+  fesetround(FE_DOWNWARD);
+  ASSERT_EQ(FE_DOWNWARD, fegetround());
+  TestRounding(8388609.0f, 1.0f);
+}
+
+TEST(fenv, feclearexcept_fetestexcept) {
+  // Clearing clears.
+  feclearexcept(FE_ALL_EXCEPT);
+  ASSERT_EQ(0, fetestexcept(FE_ALL_EXCEPT));
+
+  // Dividing by zero sets FE_DIVBYZERO.
+  DivideByZero();
+  int raised = fetestexcept(FE_DIVBYZERO | FE_OVERFLOW);
+  ASSERT_TRUE((raised & FE_OVERFLOW) == 0);
+  ASSERT_TRUE((raised & FE_DIVBYZERO) != 0);
+
+  // Clearing an unset bit is a no-op.
+  feclearexcept(FE_OVERFLOW);
+  ASSERT_TRUE((raised & FE_OVERFLOW) == 0);
+  ASSERT_TRUE((raised & FE_DIVBYZERO) != 0);
+
+  // Clearing a set bit works.
+  feclearexcept(FE_DIVBYZERO);
+  ASSERT_EQ(0, fetestexcept(FE_ALL_EXCEPT));
+}
+
+TEST(fenv, FE_DFL_ENV_macro) {
+  ASSERT_EQ(0, fesetenv(FE_DFL_ENV));
+}
diff --git a/tests/getauxval_test.cpp b/tests/getauxval_test.cpp
new file mode 100644
index 0000000..01c11c3
--- /dev/null
+++ b/tests/getauxval_test.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <sys/cdefs.h>
+#include <features.h>
+#include <gtest/gtest.h>
+
+// getauxval() was only added as of glibc version 2.16.
+// See: http://lwn.net/Articles/519085/
+// Don't try to compile this code on older glibc versions.
+
+#if defined(__BIONIC__)
+  #define GETAUXVAL_CAN_COMPILE 1
+#elif defined(__GLIBC_PREREQ)
+  #if __GLIBC_PREREQ(2, 16)
+    #define GETAUXVAL_CAN_COMPILE 1
+  #endif
+#endif
+
+#if defined(GETAUXVAL_CAN_COMPILE)
+
+#include <sys/auxv.h>
+
+TEST(getauxval, expected_values) {
+  ASSERT_EQ((unsigned long int) 0, getauxval(AT_SECURE));
+  ASSERT_EQ(getuid(), getauxval(AT_UID));
+  ASSERT_EQ(geteuid(), getauxval(AT_EUID));
+  ASSERT_EQ(getgid(), getauxval(AT_GID));
+  ASSERT_EQ(getegid(), getauxval(AT_EGID));
+  ASSERT_EQ((unsigned long int) getpagesize(), getauxval(AT_PAGESZ));
+
+  ASSERT_NE((unsigned long int) 0, getauxval(AT_PHDR));
+  ASSERT_NE((unsigned long int) 0, getauxval(AT_PHNUM));
+  ASSERT_NE((unsigned long int) 0, getauxval(AT_ENTRY));
+  ASSERT_NE((unsigned long int) 0, getauxval(AT_PAGESZ));
+}
+
+TEST(getauxval, unexpected_values) {
+  ASSERT_EQ((unsigned long int) 0, getauxval(0xdeadbeef));
+}
+
+#endif /* GETAUXVAL_CAN_COMPILE */
diff --git a/tests/getcwd_test.cpp b/tests/getcwd_test.cpp
index 45ff395..b3b4136 100644
--- a/tests/getcwd_test.cpp
+++ b/tests/getcwd_test.cpp
@@ -25,7 +25,7 @@
   errno = 0;
   char* cwd = getcwd(NULL, 0);
   ASSERT_TRUE(cwd != NULL);
-  ASSERT_EQ(errno, 0);
+  ASSERT_EQ(0, errno);
   ASSERT_GE(strlen(cwd), 1U);
   free(cwd);
 }
@@ -35,7 +35,7 @@
   errno = 0;
   char* cwd = getcwd(NULL, PATH_MAX);
   ASSERT_TRUE(cwd != NULL);
-  ASSERT_EQ(errno, 0);
+  ASSERT_EQ(0, errno);
   ASSERT_GE(strlen(cwd), 1U);
   free(cwd);
 }
@@ -45,7 +45,7 @@
   errno = 0;
   char* cwd = getcwd(NULL, 1);
   ASSERT_TRUE(cwd == NULL);
-  ASSERT_EQ(errno, ERANGE);
+  ASSERT_EQ(ERANGE, errno);
 }
 
 TEST(getcwd, auto_too_large) {
@@ -53,7 +53,7 @@
   errno = 0;
   char* cwd = getcwd(NULL, static_cast<size_t>(-1));
   ASSERT_TRUE(cwd == NULL);
-  ASSERT_EQ(errno, ENOMEM);
+  ASSERT_EQ(ENOMEM, errno);
 }
 
 TEST(getcwd, manual_too_small) {
@@ -62,7 +62,7 @@
   errno = 0;
   char* cwd = getcwd(tiny_buf, sizeof(tiny_buf));
   ASSERT_TRUE(cwd == NULL);
-  ASSERT_EQ(errno, ERANGE);
+  ASSERT_EQ(ERANGE, errno);
 }
 
 TEST(getcwd, manual_zero) {
@@ -71,7 +71,7 @@
   errno = 0;
   char* cwd = getcwd(tiny_buf, 0);
   ASSERT_TRUE(cwd == NULL);
-  ASSERT_EQ(errno, EINVAL);
+  ASSERT_EQ(EINVAL, errno);
 }
 
 TEST(getcwd, manual_path_max) {
@@ -79,7 +79,7 @@
   errno = 0;
   char* cwd = getcwd(buf, PATH_MAX);
   ASSERT_TRUE(cwd == buf);
-  ASSERT_EQ(errno, 0);
+  ASSERT_EQ(0, errno);
   ASSERT_GE(strlen(cwd), 1U);
   delete[] cwd;
 }
diff --git a/tests/libgen_test.cpp b/tests/libgen_test.cpp
new file mode 100644
index 0000000..c2c01f6
--- /dev/null
+++ b/tests/libgen_test.cpp
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+#include <libgen.h>
+
+#include <errno.h>
+
+static void TestBasename(const char* in, const char* expected_out) {
+  char* writable_in = (in != NULL) ? strdup(in) : NULL;
+  errno = 0;
+  const char* out = basename(&writable_in[0]);
+  ASSERT_STREQ(expected_out, out) << in;
+  ASSERT_EQ(0, errno) << in;
+  free(writable_in);
+}
+
+static void TestDirname(const char* in, const char* expected_out) {
+  char* writable_in = (in != NULL) ? strdup(in) : NULL;
+  errno = 0;
+  const char* out = dirname(&writable_in[0]);
+  ASSERT_STREQ(expected_out, out) << in;
+  ASSERT_EQ(0, errno) << in;
+  free(writable_in);
+}
+
+TEST(libgen, basename) {
+  TestBasename(NULL, ".");
+  TestBasename("", ".");
+  TestBasename("/usr/lib", "lib");
+  TestBasename("/usr/", "usr");
+  TestBasename("usr", "usr");
+  TestBasename("/", "/");
+  TestBasename(".", ".");
+  TestBasename("..", "..");
+  TestBasename("///", "/");
+  TestBasename("//usr//lib//", "lib");
+}
+
+TEST(libgen, dirname) {
+  TestDirname(NULL, ".");
+  TestDirname("", ".");
+  TestDirname("/usr/lib", "/usr");
+  TestDirname("/usr/", "/");
+  TestDirname("usr", ".");
+  TestDirname(".", ".");
+  TestDirname("..", ".");
+  TestDirname("/", "/");
+}
+
+#if __BIONIC__
+
+static void TestBasename(const char* in, const char* expected_out, int expected_rc,
+                         char* buf, size_t buf_size, int expected_errno) {
+  errno = 0;
+  int rc = basename_r(in, buf, buf_size);
+  ASSERT_EQ(expected_rc, rc) << in;
+  if (rc != -1 && buf != NULL) {
+    ASSERT_STREQ(expected_out, buf) << in;
+  }
+  ASSERT_EQ(expected_errno, errno) << in;
+}
+
+static void TestDirname(const char* in, const char* expected_out, int expected_rc,
+                        char* buf, size_t buf_size, int expected_errno) {
+  errno = 0;
+  int rc = dirname_r(in, buf, buf_size);
+  ASSERT_EQ(expected_rc, rc) << in;
+  if (rc != -1 && buf != NULL) {
+    ASSERT_STREQ(expected_out, buf) << in;
+  }
+  ASSERT_EQ(expected_errno, errno) << in;
+}
+
+TEST(libgen, basename_r) {
+  char buf[256];
+  TestBasename("", ".",  1, NULL, 0, 0);
+  TestBasename("", ".", -1, buf, 0, ERANGE);
+  TestBasename("", ".", -1, buf, 1, ERANGE);
+  TestBasename("", ".", 1, buf, 2, 0);
+  TestBasename("", ".", 1, buf, sizeof(buf), 0);
+  TestBasename("/usr/lib", "lib", 3, buf, sizeof(buf), 0);
+  TestBasename("/usr/", "usr", 3, buf, sizeof(buf), 0);
+  TestBasename("usr", "usr", 3, buf, sizeof(buf), 0);
+  TestBasename("/", "/", 1, buf, sizeof(buf), 0);
+  TestBasename(".", ".", 1, buf, sizeof(buf), 0);
+  TestBasename("..", "..", 2, buf, sizeof(buf), 0);
+}
+
+TEST(libgen, dirname_r) {
+  char buf[256];
+  TestDirname("", ".",  1, NULL, 0, 0);
+  TestDirname("", ".", -1, buf, 0, ERANGE);
+  TestDirname("", ".", -1, buf, 1, ERANGE);
+  TestDirname("", ".", 1, buf, 2, 0);
+  TestDirname("/usr/lib", "/usr", 4, buf, sizeof(buf), 0);
+  TestDirname("/usr/", "/", 1, buf, sizeof(buf), 0);
+  TestDirname("usr", ".", 1, buf, sizeof(buf), 0);
+  TestDirname(".", ".", 1, buf, sizeof(buf), 0);
+  TestDirname("..", ".", 1, buf, sizeof(buf), 0);
+}
+
+#endif
diff --git a/tests/math_benchmark.cpp b/tests/math_benchmark.cpp
new file mode 100644
index 0000000..a8c1cfa
--- /dev/null
+++ b/tests/math_benchmark.cpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "benchmark.h"
+
+#include <math.h>
+
+// Avoid optimization.
+double d;
+double v;
+
+static void BM_math_sqrt(int iters) {
+  StartBenchmarkTiming();
+
+  d = 0.0;
+  v = 2.0;
+  for (int i = 0; i < iters; ++i) {
+    d += sqrt(v);
+  }
+
+  StopBenchmarkTiming();
+}
+BENCHMARK(BM_math_sqrt);
+
+static void BM_math_log10(int iters) {
+  StartBenchmarkTiming();
+
+  d = 0.0;
+  v = 1234.0;
+  for (int i = 0; i < iters; ++i) {
+    d += log10(v);
+  }
+
+  StopBenchmarkTiming();
+}
+BENCHMARK(BM_math_log10);
+
+static void BM_math_logb(int iters) {
+  StartBenchmarkTiming();
+
+  d = 0.0;
+  v = 1234.0;
+  for (int i = 0; i < iters; ++i) {
+    d += logb(v);
+  }
+
+  StopBenchmarkTiming();
+}
+BENCHMARK(BM_math_logb);
diff --git a/tests/math_test.cpp b/tests/math_test.cpp
new file mode 100644
index 0000000..458a146
--- /dev/null
+++ b/tests/math_test.cpp
@@ -0,0 +1,1176 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define _DECLARE_C99_LDBL_MATH 1
+
+#include <gtest/gtest.h>
+
+#include <fenv.h>
+#include <limits.h>
+#include <math.h>
+#include <stdint.h>
+
+float float_subnormal() {
+  union {
+    float f;
+    uint32_t i;
+  } u;
+  u.i = 0x007fffff;
+  return u.f;
+}
+
+double double_subnormal() {
+  union {
+    double d;
+    uint64_t i;
+  } u;
+  u.i = 0x000fffffffffffffLL;
+  return u.d;
+}
+
+TEST(math, fpclassify) {
+  ASSERT_EQ(FP_INFINITE, fpclassify(INFINITY));
+  ASSERT_EQ(FP_INFINITE, fpclassify(HUGE_VALF));
+  ASSERT_EQ(FP_INFINITE, fpclassify(HUGE_VAL));
+
+  ASSERT_EQ(FP_NAN, fpclassify(nanf("")));
+  ASSERT_EQ(FP_NAN, fpclassify(nan("")));
+
+  ASSERT_EQ(FP_NORMAL, fpclassify(1.0f));
+  ASSERT_EQ(FP_NORMAL, fpclassify(1.0));
+
+  ASSERT_EQ(FP_SUBNORMAL, fpclassify(float_subnormal()));
+  ASSERT_EQ(FP_SUBNORMAL, fpclassify(double_subnormal()));
+
+  ASSERT_EQ(FP_ZERO, fpclassify(0.0f));
+  ASSERT_EQ(FP_ZERO, fpclassify(0.0));
+}
+
+/* TODO: stlport breaks the isfinite macro
+TEST(math, isfinite) {
+  ASSERT_TRUE(isfinite(123.0f));
+  ASSERT_TRUE(isfinite(123.0));
+  ASSERT_FALSE(isfinite(HUGE_VALF));
+  ASSERT_FALSE(isfinite(HUGE_VAL));
+}
+*/
+
+TEST(math, isinf) {
+  ASSERT_FALSE(isinf(123.0f));
+  ASSERT_FALSE(isinf(123.0));
+  ASSERT_TRUE(isinf(HUGE_VALF));
+  ASSERT_TRUE(isinf(HUGE_VAL));
+}
+
+TEST(math, isnan) {
+  ASSERT_FALSE(isnan(123.0f));
+  ASSERT_FALSE(isnan(123.0));
+  ASSERT_TRUE(isnan(nanf("")));
+  ASSERT_TRUE(isnan(nan("")));
+}
+
+TEST(math, isnormal) {
+  ASSERT_TRUE(isnormal(123.0f));
+  ASSERT_TRUE(isnormal(123.0));
+  ASSERT_FALSE(isnormal(float_subnormal()));
+  ASSERT_FALSE(isnormal(double_subnormal()));
+}
+
+// TODO: isgreater, isgreaterequals, isless, islessequal, islessgreater, isunordered
+
+/* TODO: stlport breaks the signbit macro
+TEST(math, signbit) {
+  ASSERT_EQ(0, signbit(0.0f));
+  ASSERT_EQ(0, signbit(0.0));
+
+  ASSERT_EQ(0, signbit(1.0f));
+  ASSERT_EQ(0, signbit(1.0));
+
+  ASSERT_NE(0, signbit(-1.0f));
+  ASSERT_NE(0, signbit(-1.0));
+}
+*/
+
+#if defined(__BIONIC__)
+TEST(math, __fpclassifyd) {
+  ASSERT_EQ(FP_INFINITE, __fpclassifyd(HUGE_VAL));
+  ASSERT_EQ(FP_NAN, __fpclassifyd(nan("")));
+  ASSERT_EQ(FP_NORMAL, __fpclassifyd(1.0));
+  ASSERT_EQ(FP_SUBNORMAL, __fpclassifyd(double_subnormal()));
+  ASSERT_EQ(FP_ZERO, __fpclassifyd(0.0));
+}
+#endif
+
+#if defined(__BIONIC__)
+TEST(math, __fpclassifyf) {
+  ASSERT_EQ(FP_INFINITE, __fpclassifyf(HUGE_VALF));
+  ASSERT_EQ(FP_NAN, __fpclassifyf(nanf("")));
+  ASSERT_EQ(FP_NORMAL, __fpclassifyf(1.0f));
+  ASSERT_EQ(FP_SUBNORMAL, __fpclassifyf(float_subnormal()));
+  ASSERT_EQ(FP_ZERO, __fpclassifyf(0.0f));
+}
+#endif
+
+#if defined(__BIONIC__)
+TEST(math, __fpclassifyl) {
+  EXPECT_EQ(FP_INFINITE, __fpclassifyl(HUGE_VALL));
+  EXPECT_EQ(FP_NAN, __fpclassifyl(nanl("")));
+  EXPECT_EQ(FP_NORMAL, __fpclassifyl(1.0));
+  EXPECT_EQ(FP_SUBNORMAL, __fpclassifyl(double_subnormal()));
+  EXPECT_EQ(FP_ZERO, __fpclassifyl(0.0));
+}
+#endif
+
+TEST(math, finitef) {
+  ASSERT_TRUE(finitef(123.0f));
+  ASSERT_FALSE(finitef(HUGE_VALF));
+}
+
+#if defined(__BIONIC__)
+TEST(math, __isfinite) {
+  ASSERT_TRUE(__isfinite(123.0));
+  ASSERT_FALSE(__isfinite(HUGE_VAL));
+}
+#endif
+
+#if defined(__BIONIC__)
+TEST(math, __isfinitef) {
+  ASSERT_TRUE(__isfinitef(123.0f));
+  ASSERT_FALSE(__isfinitef(HUGE_VALF));
+}
+#endif
+
+#if defined(__BIONIC__)
+TEST(math, __isfinitel) {
+  ASSERT_TRUE(__isfinitel(123.0f));
+  ASSERT_FALSE(__isfinitel(HUGE_VALL));
+}
+#endif
+
+TEST(math, finite) {
+  ASSERT_TRUE(finite(123.0));
+  ASSERT_FALSE(finite(HUGE_VAL));
+}
+
+TEST(math, __isinff) {
+  ASSERT_FALSE(__isinff(123.0f));
+  ASSERT_TRUE(__isinff(HUGE_VALF));
+}
+
+TEST(math, __isinfl) {
+  ASSERT_FALSE(__isinfl(123.0));
+  ASSERT_TRUE(__isinfl(HUGE_VALL));
+}
+
+TEST(math, __isnanf) {
+  ASSERT_FALSE(__isnanf(123.0f));
+  ASSERT_TRUE(__isnanf(nanf("")));
+}
+
+TEST(math, __isnanl) {
+  ASSERT_FALSE(__isnanl(123.0));
+  ASSERT_TRUE(__isnanl(nanl("")));
+}
+
+TEST(math, isnanf) {
+  ASSERT_FALSE(isnanf(123.0f));
+  ASSERT_TRUE(isnanf(nanf("")));
+}
+
+#if defined(__BIONIC__)
+TEST(math, __isnormal) {
+  ASSERT_TRUE(__isnormal(123.0));
+  ASSERT_FALSE(__isnormal(double_subnormal()));
+}
+#endif
+
+#if defined(__BIONIC__)
+TEST(math, __isnormalf) {
+  ASSERT_TRUE(__isnormalf(123.0f));
+  ASSERT_FALSE(__isnormalf(float_subnormal()));
+}
+#endif
+
+#if defined(__BIONIC__)
+TEST(math, __isnormall) {
+  ASSERT_TRUE(__isnormall(123.0));
+  ASSERT_FALSE(__isnormall(double_subnormal()));
+}
+#endif
+
+TEST(math, __signbit) {
+  ASSERT_EQ(0, __signbit(0.0));
+  ASSERT_EQ(0, __signbit(1.0));
+  ASSERT_NE(0, __signbit(-1.0));
+}
+
+TEST(math, __signbitf) {
+  ASSERT_EQ(0, __signbitf(0.0f));
+  ASSERT_EQ(0, __signbitf(1.0f));
+  ASSERT_NE(0, __signbitf(-1.0f));
+}
+
+TEST(math, __signbitl) {
+  ASSERT_EQ(0, __signbitl(0.0));
+  ASSERT_EQ(0, __signbitl(1.0));
+  ASSERT_NE(0, __signbitl(-1.0));
+}
+
+TEST(math, acos) {
+  ASSERT_FLOAT_EQ(M_PI/2.0, acos(0.0));
+}
+
+TEST(math, acosf) {
+  ASSERT_FLOAT_EQ(static_cast<float>(M_PI)/2.0f, acosf(0.0f));
+}
+
+TEST(math, acosl) {
+  ASSERT_FLOAT_EQ(M_PI/2.0, acosl(0.0));
+}
+
+TEST(math, asin) {
+  ASSERT_FLOAT_EQ(0.0, asin(0.0));
+}
+
+TEST(math, asinf) {
+  ASSERT_FLOAT_EQ(0.0f, asinf(0.0f));
+}
+
+TEST(math, asinl) {
+  ASSERT_FLOAT_EQ(0.0, asinl(0.0));
+}
+
+TEST(math, atan) {
+  ASSERT_FLOAT_EQ(0.0, atan(0.0));
+}
+
+TEST(math, atanf) {
+  ASSERT_FLOAT_EQ(0.0f, atanf(0.0f));
+}
+
+TEST(math, atanl) {
+  ASSERT_FLOAT_EQ(0.0, atanl(0.0));
+}
+
+TEST(math, atan2) {
+  ASSERT_FLOAT_EQ(0.0, atan2(0.0, 0.0));
+}
+
+TEST(math, atan2f) {
+  ASSERT_FLOAT_EQ(0.0f, atan2f(0.0f, 0.0f));
+}
+
+TEST(math, atan2l) {
+  ASSERT_FLOAT_EQ(0.0, atan2l(0.0, 0.0));
+}
+
+TEST(math, cos) {
+  ASSERT_FLOAT_EQ(1.0, cos(0.0));
+}
+
+TEST(math, cosf) {
+  ASSERT_FLOAT_EQ(1.0f, cosf(0.0f));
+}
+
+TEST(math, cosl) {
+  ASSERT_FLOAT_EQ(1.0, cosl(0.0));
+}
+
+TEST(math, sin) {
+  ASSERT_FLOAT_EQ(0.0, sin(0.0));
+}
+
+TEST(math, sinf) {
+  ASSERT_FLOAT_EQ(0.0f, sinf(0.0f));
+}
+
+TEST(math, sinl) {
+  ASSERT_FLOAT_EQ(0.0, sinl(0.0));
+}
+
+TEST(math, tan) {
+  ASSERT_FLOAT_EQ(0.0, tan(0.0));
+}
+
+TEST(math, tanf) {
+  ASSERT_FLOAT_EQ(0.0f, tanf(0.0f));
+}
+
+TEST(math, tanl) {
+  ASSERT_FLOAT_EQ(0.0, tanl(0.0));
+}
+
+TEST(math, acosh) {
+  ASSERT_FLOAT_EQ(0.0, acosh(1.0));
+}
+
+TEST(math, acoshf) {
+  ASSERT_FLOAT_EQ(0.0f, acoshf(1.0f));
+}
+
+TEST(math, acoshl) {
+  ASSERT_FLOAT_EQ(0.0, acoshl(1.0));
+}
+
+TEST(math, asinh) {
+  ASSERT_FLOAT_EQ(0.0, asinh(0.0));
+}
+
+TEST(math, asinhf) {
+  ASSERT_FLOAT_EQ(0.0f, asinhf(0.0f));
+}
+
+TEST(math, asinhl) {
+  ASSERT_FLOAT_EQ(0.0, asinhl(0.0));
+}
+
+TEST(math, atanh) {
+  ASSERT_FLOAT_EQ(0.0, atanh(0.0));
+}
+
+TEST(math, atanhf) {
+  ASSERT_FLOAT_EQ(0.0f, atanhf(0.0f));
+}
+
+TEST(math, atanhl) {
+  ASSERT_FLOAT_EQ(0.0, atanhl(0.0));
+}
+
+TEST(math, cosh) {
+  ASSERT_FLOAT_EQ(1.0, cosh(0.0));
+}
+
+TEST(math, coshf) {
+  ASSERT_FLOAT_EQ(1.0f, coshf(0.0f));
+}
+
+TEST(math, coshl) {
+  ASSERT_FLOAT_EQ(1.0, coshl(0.0));
+}
+
+TEST(math, sinh) {
+  ASSERT_FLOAT_EQ(0.0, sinh(0.0));
+}
+
+TEST(math, sinhf) {
+  ASSERT_FLOAT_EQ(0.0f, sinhf(0.0f));
+}
+
+TEST(math, sinhl) {
+  ASSERT_FLOAT_EQ(0.0, sinhl(0.0));
+}
+
+TEST(math, tanh) {
+  ASSERT_FLOAT_EQ(0.0, tanh(0.0));
+}
+
+TEST(math, tanhf) {
+  ASSERT_FLOAT_EQ(0.0f, tanhf(0.0f));
+}
+
+TEST(math, tanhl) {
+  ASSERT_FLOAT_EQ(0.0, tanhl(0.0));
+}
+
+TEST(math, log) {
+  ASSERT_FLOAT_EQ(1.0, log(M_E));
+}
+
+TEST(math, logf) {
+  ASSERT_FLOAT_EQ(1.0f, logf(static_cast<float>(M_E)));
+}
+
+TEST(math, logl) {
+  ASSERT_FLOAT_EQ(1.0, logl(M_E));
+}
+
+TEST(math, log2) {
+  ASSERT_FLOAT_EQ(12.0, log2(4096.0));
+}
+
+TEST(math, log2f) {
+  ASSERT_FLOAT_EQ(12.0f, log2f(4096.0f));
+}
+
+TEST(math, log2l) {
+  ASSERT_FLOAT_EQ(12.0, log2l(4096.0));
+}
+
+TEST(math, log10) {
+  ASSERT_FLOAT_EQ(3.0, log10(1000.0));
+}
+
+TEST(math, log10f) {
+  ASSERT_FLOAT_EQ(3.0f, log10f(1000.0f));
+}
+
+TEST(math, log10l) {
+  ASSERT_FLOAT_EQ(3.0, log10l(1000.0));
+}
+
+TEST(math, cbrt) {
+  ASSERT_FLOAT_EQ(3.0, cbrt(27.0));
+}
+
+TEST(math, cbrtf) {
+  ASSERT_FLOAT_EQ(3.0f, cbrtf(27.0f));
+}
+
+TEST(math, cbrtl) {
+  ASSERT_FLOAT_EQ(3.0, cbrtl(27.0));
+}
+
+TEST(math, sqrt) {
+  ASSERT_FLOAT_EQ(2.0, sqrt(4.0));
+}
+
+TEST(math, sqrtf) {
+  ASSERT_FLOAT_EQ(2.0f, sqrtf(4.0f));
+}
+
+TEST(math, sqrtl) {
+  ASSERT_FLOAT_EQ(2.0, sqrtl(4.0));
+}
+
+TEST(math, exp) {
+  ASSERT_FLOAT_EQ(1.0, exp(0.0));
+  ASSERT_FLOAT_EQ(M_E, exp(1.0));
+}
+
+TEST(math, expf) {
+  ASSERT_FLOAT_EQ(1.0f, expf(0.0f));
+  ASSERT_FLOAT_EQ(static_cast<float>(M_E), expf(1.0f));
+}
+
+TEST(math, expl) {
+  ASSERT_FLOAT_EQ(1.0, expl(0.0));
+  ASSERT_FLOAT_EQ(M_E, expl(1.0));
+}
+
+TEST(math, exp2) {
+  ASSERT_FLOAT_EQ(8.0, exp2(3.0));
+}
+
+TEST(math, exp2f) {
+  ASSERT_FLOAT_EQ(8.0f, exp2f(3.0f));
+}
+
+TEST(math, exp2l) {
+  ASSERT_FLOAT_EQ(8.0, exp2l(3.0));
+}
+
+TEST(math, expm1) {
+  ASSERT_FLOAT_EQ(M_E - 1.0, expm1(1.0));
+}
+
+TEST(math, expm1f) {
+  ASSERT_FLOAT_EQ(static_cast<float>(M_E) - 1.0f, expm1f(1.0f));
+}
+
+TEST(math, expm1l) {
+  ASSERT_FLOAT_EQ(M_E - 1.0, expm1l(1.0));
+}
+
+TEST(math, pow) {
+  ASSERT_FLOAT_EQ(8.0, pow(2.0, 3.0));
+}
+
+TEST(math, powf) {
+  ASSERT_FLOAT_EQ(8.0f, powf(2.0f, 3.0f));
+}
+
+TEST(math, powl) {
+  ASSERT_FLOAT_EQ(8.0, powl(2.0, 3.0));
+}
+
+TEST(math, ceil) {
+  ASSERT_FLOAT_EQ(1.0, ceil(0.9));
+}
+
+TEST(math, ceilf) {
+  ASSERT_FLOAT_EQ(1.0f, ceilf(0.9f));
+}
+
+TEST(math, ceill) {
+  ASSERT_FLOAT_EQ(1.0, ceill(0.9));
+}
+
+TEST(math, floor) {
+  ASSERT_FLOAT_EQ(1.0, floor(1.1));
+}
+
+TEST(math, floorf) {
+  ASSERT_FLOAT_EQ(1.0f, floorf(1.1f));
+}
+
+TEST(math, floorl) {
+  ASSERT_FLOAT_EQ(1.0, floorl(1.1));
+}
+
+TEST(math, fabs) {
+  ASSERT_FLOAT_EQ(1.0, fabs(-1.0));
+}
+
+TEST(math, fabsf) {
+  ASSERT_FLOAT_EQ(1.0f, fabsf(-1.0f));
+}
+
+TEST(math, fabsl) {
+  ASSERT_FLOAT_EQ(1.0, fabsl(-1.0));
+}
+
+TEST(math, ldexp) {
+  ASSERT_FLOAT_EQ(16.0, ldexp(2.0, 3.0));
+}
+
+TEST(math, ldexpf) {
+  ASSERT_FLOAT_EQ(16.0f, ldexpf(2.0f, 3.0f));
+}
+
+TEST(math, ldexpl) {
+  ASSERT_FLOAT_EQ(16.0, ldexpl(2.0, 3.0));
+}
+
+TEST(math, fmod) {
+  ASSERT_FLOAT_EQ(2.0, fmod(12.0, 10.0));
+}
+
+TEST(math, fmodf) {
+  ASSERT_FLOAT_EQ(2.0f, fmodf(12.0f, 10.0f));
+}
+
+TEST(math, fmodl) {
+  ASSERT_FLOAT_EQ(2.0, fmodl(12.0, 10.0));
+}
+
+TEST(math, remainder) {
+  ASSERT_FLOAT_EQ(2.0, remainder(12.0, 10.0));
+}
+
+TEST(math, remainderf) {
+  ASSERT_FLOAT_EQ(2.0f, remainderf(12.0f, 10.0f));
+}
+
+TEST(math, remainderl) {
+  ASSERT_FLOAT_EQ(2.0, remainderl(12.0, 10.0));
+}
+
+TEST(math, drem) {
+  ASSERT_FLOAT_EQ(2.0, drem(12.0, 10.0));
+}
+
+TEST(math, dremf) {
+  ASSERT_FLOAT_EQ(2.0f, dremf(12.0f, 10.0f));
+}
+
+TEST(math, fmax) {
+  ASSERT_FLOAT_EQ(12.0, fmax(12.0, 10.0));
+  ASSERT_FLOAT_EQ(12.0, fmax(12.0, nan("")));
+  ASSERT_FLOAT_EQ(12.0, fmax(nan(""), 12.0));
+}
+
+TEST(math, fmaxf) {
+  ASSERT_FLOAT_EQ(12.0f, fmaxf(12.0f, 10.0f));
+  ASSERT_FLOAT_EQ(12.0f, fmaxf(12.0f, nanf("")));
+  ASSERT_FLOAT_EQ(12.0f, fmaxf(nanf(""), 12.0f));
+}
+
+TEST(math, fmaxl) {
+  ASSERT_FLOAT_EQ(12.0, fmaxl(12.0, 10.0));
+  ASSERT_FLOAT_EQ(12.0, fmaxl(12.0, nanl("")));
+  ASSERT_FLOAT_EQ(12.0, fmaxl(nanl(""), 12.0));
+}
+
+TEST(math, fmin) {
+  ASSERT_FLOAT_EQ(10.0, fmin(12.0, 10.0));
+  ASSERT_FLOAT_EQ(12.0, fmin(12.0, nan("")));
+  ASSERT_FLOAT_EQ(12.0, fmin(nan(""), 12.0));
+}
+
+TEST(math, fminf) {
+  ASSERT_FLOAT_EQ(10.0f, fminf(12.0f, 10.0f));
+  ASSERT_FLOAT_EQ(12.0f, fminf(12.0f, nanf("")));
+  ASSERT_FLOAT_EQ(12.0f, fminf(nanf(""), 12.0f));
+}
+
+TEST(math, fminl) {
+  ASSERT_FLOAT_EQ(10.0, fminl(12.0, 10.0));
+  ASSERT_FLOAT_EQ(12.0, fminl(12.0, nan("")));
+  ASSERT_FLOAT_EQ(12.0, fminl(nan(""), 12.0));
+}
+
+TEST(math, fma) {
+  ASSERT_FLOAT_EQ(10.0, fma(2.0, 3.0, 4.0));
+}
+
+TEST(math, fmaf) {
+  ASSERT_FLOAT_EQ(10.0f, fmaf(2.0f, 3.0f, 4.0f));
+}
+
+TEST(math, fmal) {
+  ASSERT_FLOAT_EQ(10.0, fmal(2.0, 3.0, 4.0));
+}
+
+TEST(math, hypot) {
+  ASSERT_FLOAT_EQ(5.0, hypot(3.0, 4.0));
+}
+
+TEST(math, hypotf) {
+  ASSERT_FLOAT_EQ(5.0f, hypotf(3.0f, 4.0f));
+}
+
+TEST(math, hypotl) {
+  ASSERT_FLOAT_EQ(5.0, hypotl(3.0, 4.0));
+}
+
+TEST(math, erf) {
+  ASSERT_FLOAT_EQ(0.84270078, erf(1.0));
+}
+
+TEST(math, erff) {
+  ASSERT_FLOAT_EQ(0.84270078f, erff(1.0f));
+}
+
+TEST(math, erfl) {
+  ASSERT_FLOAT_EQ(0.84270078, erfl(1.0));
+}
+
+TEST(math, erfc) {
+  ASSERT_FLOAT_EQ(0.15729921, erfc(1.0));
+}
+
+TEST(math, erfcf) {
+  ASSERT_FLOAT_EQ(0.15729921f, erfcf(1.0f));
+}
+
+TEST(math, erfcl) {
+  ASSERT_FLOAT_EQ(0.15729921, erfcl(1.0));
+}
+
+TEST(math, lrint) {
+  fesetround(FE_UPWARD); // lrint/lrintf/lrintl obey the rounding mode.
+  ASSERT_EQ(1235, lrint(1234.01));
+  ASSERT_EQ(1235, lrintf(1234.01f));
+  ASSERT_EQ(1235, lrintl(1234.01));
+  fesetround(FE_TOWARDZERO); // lrint/lrintf/lrintl obey the rounding mode.
+  ASSERT_EQ(1234, lrint(1234.01));
+  ASSERT_EQ(1234, lrintf(1234.01f));
+  ASSERT_EQ(1234, lrintl(1234.01));
+
+  fesetround(FE_UPWARD); // llrint/llrintf/llrintl obey the rounding mode.
+  ASSERT_EQ(1235L, llrint(1234.01));
+  ASSERT_EQ(1235L, llrintf(1234.01f));
+  ASSERT_EQ(1235L, llrintl(1234.01));
+  fesetround(FE_TOWARDZERO); // llrint/llrintf/llrintl obey the rounding mode.
+  ASSERT_EQ(1234L, llrint(1234.01));
+  ASSERT_EQ(1234L, llrintf(1234.01f));
+  ASSERT_EQ(1234L, llrintl(1234.01));
+}
+
+TEST(math, rint) {
+  fesetround(FE_UPWARD); // rint/rintf/rintl obey the rounding mode.
+  feclearexcept(FE_ALL_EXCEPT); // rint/rintf/rintl do set the FE_INEXACT flag.
+  ASSERT_EQ(1234.0, rint(1234.0));
+  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
+  ASSERT_EQ(1235.0, rint(1234.01));
+  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) != 0);
+
+  feclearexcept(FE_ALL_EXCEPT); // rint/rintf/rintl do set the FE_INEXACT flag.
+  ASSERT_EQ(1234.0f, rintf(1234.0f));
+  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
+  ASSERT_EQ(1235.0f, rintf(1234.01f));
+  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) != 0);
+
+  feclearexcept(FE_ALL_EXCEPT); // rint/rintf/rintl do set the FE_INEXACT flag.
+  ASSERT_EQ(1234.0, rintl(1234.0));
+  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
+  ASSERT_EQ(1235.0, rintl(1234.01));
+  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) != 0);
+
+  fesetround(FE_TOWARDZERO); // rint/rintf obey the rounding mode.
+  ASSERT_EQ(1234.0, rint(1234.01));
+  ASSERT_EQ(1234.0f, rintf(1234.01f));
+  ASSERT_EQ(1234.0, rintl(1234.01));
+}
+
+TEST(math, nearbyint) {
+  fesetround(FE_UPWARD); // nearbyint/nearbyintf/nearbyintl obey the rounding mode.
+  feclearexcept(FE_ALL_EXCEPT); // nearbyint/nearbyintf/nearbyintl don't set the FE_INEXACT flag.
+  ASSERT_EQ(1234.0, nearbyint(1234.0));
+  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
+  ASSERT_EQ(1235.0, nearbyint(1234.01));
+  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
+
+  feclearexcept(FE_ALL_EXCEPT);
+  ASSERT_EQ(1234.0f, nearbyintf(1234.0f));
+  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
+  ASSERT_EQ(1235.0f, nearbyintf(1234.01f));
+  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
+
+  feclearexcept(FE_ALL_EXCEPT); // nearbyint/nearbyintf/nearbyintl don't set the FE_INEXACT flag.
+  ASSERT_EQ(1234.0, nearbyintl(1234.0));
+  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
+  ASSERT_EQ(1235.0, nearbyintl(1234.01));
+  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
+
+  fesetround(FE_TOWARDZERO); // nearbyint/nearbyintf/nearbyintl obey the rounding mode.
+  ASSERT_EQ(1234.0, nearbyint(1234.01));
+  ASSERT_EQ(1234.0f, nearbyintf(1234.01f));
+  ASSERT_EQ(1234.0, nearbyintl(1234.01));
+}
+
+TEST(math, lround) {
+  fesetround(FE_UPWARD); // lround ignores the rounding mode.
+  ASSERT_EQ(1234, lround(1234.01));
+  ASSERT_EQ(1234, lroundf(1234.01f));
+  ASSERT_EQ(1234, lroundl(1234.01));
+}
+
+TEST(math, llround) {
+  fesetround(FE_UPWARD); // llround ignores the rounding mode.
+  ASSERT_EQ(1234L, llround(1234.01));
+  ASSERT_EQ(1234L, llroundf(1234.01f));
+  ASSERT_EQ(1234L, llroundl(1234.01));
+}
+
+TEST(math, ilogb) {
+  ASSERT_EQ(FP_ILOGB0, ilogb(0.0));
+  ASSERT_EQ(FP_ILOGBNAN, ilogb(nan("")));
+  ASSERT_EQ(INT_MAX, ilogb(HUGE_VAL));
+  ASSERT_EQ(0, ilogb(1.0));
+  ASSERT_EQ(3, ilogb(10.0));
+}
+
+TEST(math, ilogbf) {
+  ASSERT_EQ(FP_ILOGB0, ilogbf(0.0f));
+  ASSERT_EQ(FP_ILOGBNAN, ilogbf(nanf("")));
+  ASSERT_EQ(INT_MAX, ilogbf(HUGE_VALF));
+  ASSERT_EQ(0, ilogbf(1.0f));
+  ASSERT_EQ(3, ilogbf(10.0f));
+}
+
+TEST(math, ilogbl) {
+  ASSERT_EQ(FP_ILOGB0, ilogbl(0.0));
+  ASSERT_EQ(FP_ILOGBNAN, ilogbl(nanl("")));
+  ASSERT_EQ(INT_MAX, ilogbl(HUGE_VALL));
+  ASSERT_EQ(0, ilogbl(1.0));
+  ASSERT_EQ(3, ilogbl(10.0));
+}
+
+TEST(math, logb) {
+  ASSERT_EQ(-HUGE_VAL, logb(0.0));
+  ASSERT_TRUE(isnan(logb(nan(""))));
+  ASSERT_TRUE(isinf(logb(HUGE_VAL)));
+  ASSERT_EQ(0.0, logb(1.0));
+  ASSERT_EQ(3.0, logb(10.0));
+}
+
+TEST(math, logbf) {
+  ASSERT_EQ(-HUGE_VALF, logbf(0.0f));
+  ASSERT_TRUE(isnanf(logbf(nanf(""))));
+  ASSERT_TRUE(__isinff(logbf(HUGE_VALF)));
+  ASSERT_EQ(0.0f, logbf(1.0f));
+  ASSERT_EQ(3.0f, logbf(10.0f));
+}
+
+TEST(math, logbl) {
+  ASSERT_EQ(-HUGE_VAL, logbl(0.0));
+  ASSERT_TRUE(isnan(logbl(nanl(""))));
+  ASSERT_TRUE(isinf(logbl(HUGE_VALL)));
+  ASSERT_EQ(0.0, logbl(1.0));
+  ASSERT_EQ(3.0, logbl(10.0));
+}
+
+TEST(math, log1p) {
+  ASSERT_EQ(-HUGE_VAL, log1p(-1.0));
+  ASSERT_TRUE(isnan(log1p(nan(""))));
+  ASSERT_TRUE(isinf(log1p(HUGE_VAL)));
+  ASSERT_FLOAT_EQ(1.0, log1p(M_E - 1.0));
+}
+
+TEST(math, log1pf) {
+  ASSERT_EQ(-HUGE_VALF, log1pf(-1.0f));
+  ASSERT_TRUE(isnanf(log1pf(nanf(""))));
+  ASSERT_TRUE(__isinff(log1pf(HUGE_VALF)));
+  ASSERT_FLOAT_EQ(1.0f, log1pf(static_cast<float>(M_E) - 1.0f));
+}
+
+TEST(math, log1pl) {
+  ASSERT_EQ(-HUGE_VALL, log1pl(-1.0));
+  ASSERT_TRUE(isnan(log1pl(nanl(""))));
+  ASSERT_TRUE(isinf(log1pl(HUGE_VALL)));
+  ASSERT_FLOAT_EQ(1.0, log1pl(M_E - 1.0));
+}
+
+TEST(math, fdim) {
+  ASSERT_FLOAT_EQ(0.0, fdim(1.0, 1.0));
+  ASSERT_FLOAT_EQ(1.0, fdim(2.0, 1.0));
+  ASSERT_FLOAT_EQ(0.0, fdim(1.0, 2.0));
+}
+
+TEST(math, fdimf) {
+  ASSERT_FLOAT_EQ(0.0f, fdimf(1.0f, 1.0f));
+  ASSERT_FLOAT_EQ(1.0f, fdimf(2.0f, 1.0f));
+  ASSERT_FLOAT_EQ(0.0f, fdimf(1.0f, 2.0f));
+}
+
+TEST(math, fdiml) {
+  ASSERT_FLOAT_EQ(0.0, fdiml(1.0, 1.0));
+  ASSERT_FLOAT_EQ(1.0, fdiml(2.0, 1.0));
+  ASSERT_FLOAT_EQ(0.0, fdiml(1.0, 2.0));
+}
+
+TEST(math, round) {
+  fesetround(FE_TOWARDZERO); // round ignores the rounding mode and always rounds away from zero.
+  ASSERT_FLOAT_EQ(1.0, round(0.5));
+  ASSERT_FLOAT_EQ(-1.0, round(-0.5));
+  ASSERT_FLOAT_EQ(0.0, round(0.0));
+  ASSERT_FLOAT_EQ(-0.0, round(-0.0));
+  ASSERT_TRUE(isnan(round(nan(""))));
+  ASSERT_FLOAT_EQ(HUGE_VAL, round(HUGE_VAL));
+}
+
+TEST(math, roundf) {
+  fesetround(FE_TOWARDZERO); // roundf ignores the rounding mode and always rounds away from zero.
+  ASSERT_FLOAT_EQ(1.0f, roundf(0.5f));
+  ASSERT_FLOAT_EQ(-1.0f, roundf(-0.5f));
+  ASSERT_FLOAT_EQ(0.0f, roundf(0.0f));
+  ASSERT_FLOAT_EQ(-0.0f, roundf(-0.0f));
+  ASSERT_TRUE(isnanf(roundf(nanf(""))));
+  ASSERT_FLOAT_EQ(HUGE_VALF, roundf(HUGE_VALF));
+}
+
+TEST(math, roundl) {
+  fesetround(FE_TOWARDZERO); // roundl ignores the rounding mode and always rounds away from zero.
+  ASSERT_FLOAT_EQ(1.0, roundl(0.5));
+  ASSERT_FLOAT_EQ(-1.0, roundl(-0.5));
+  ASSERT_FLOAT_EQ(0.0, roundl(0.0));
+  ASSERT_FLOAT_EQ(-0.0, roundl(-0.0));
+  ASSERT_TRUE(isnan(roundl(nanl(""))));
+  ASSERT_FLOAT_EQ(HUGE_VALL, roundl(HUGE_VALL));
+}
+
+TEST(math, trunc) {
+  fesetround(FE_UPWARD); // trunc ignores the rounding mode and always rounds toward zero.
+  ASSERT_FLOAT_EQ(1.0, trunc(1.5));
+  ASSERT_FLOAT_EQ(-1.0, trunc(-1.5));
+  ASSERT_FLOAT_EQ(0.0, trunc(0.0));
+  ASSERT_FLOAT_EQ(-0.0, trunc(-0.0));
+  ASSERT_TRUE(isnan(trunc(nan(""))));
+  ASSERT_FLOAT_EQ(HUGE_VAL, trunc(HUGE_VAL));
+}
+
+TEST(math, truncf) {
+  fesetround(FE_UPWARD); // truncf ignores the rounding mode and always rounds toward zero.
+  ASSERT_FLOAT_EQ(1.0f, truncf(1.5f));
+  ASSERT_FLOAT_EQ(-1.0f, truncf(-1.5f));
+  ASSERT_FLOAT_EQ(0.0f, truncf(0.0f));
+  ASSERT_FLOAT_EQ(-0.0f, truncf(-0.0f));
+  ASSERT_TRUE(isnan(truncf(nanf(""))));
+  ASSERT_FLOAT_EQ(HUGE_VALF, truncf(HUGE_VALF));
+}
+
+TEST(math, truncl) {
+  fesetround(FE_UPWARD); // truncl ignores the rounding mode and always rounds toward zero.
+  ASSERT_FLOAT_EQ(1.0, truncl(1.5));
+  ASSERT_FLOAT_EQ(-1.0, truncl(-1.5));
+  ASSERT_FLOAT_EQ(0.0, truncl(0.0));
+  ASSERT_FLOAT_EQ(-0.0, truncl(-0.0));
+  ASSERT_TRUE(isnan(truncl(nan(""))));
+  ASSERT_FLOAT_EQ(HUGE_VALL, truncl(HUGE_VALL));
+}
+
+TEST(math, nextafter) {
+  ASSERT_FLOAT_EQ(0.0, nextafter(0.0, 0.0));
+  ASSERT_FLOAT_EQ(1.4012985e-45, nextafter(0.0, 1.0));
+  ASSERT_FLOAT_EQ(0.0, nextafter(0.0, -1.0));
+}
+
+TEST(math, nextafterf) {
+  ASSERT_FLOAT_EQ(0.0f, nextafterf(0.0f, 0.0f));
+  ASSERT_FLOAT_EQ(1.4012985e-45f, nextafterf(0.0f, 1.0f));
+  ASSERT_FLOAT_EQ(0.0f, nextafterf(0.0f, -1.0f));
+}
+
+TEST(math, nextafterl) {
+  ASSERT_FLOAT_EQ(0.0, nextafterl(0.0, 0.0));
+  ASSERT_FLOAT_EQ(1.4012985e-45, nextafterl(0.0, 1.0));
+  ASSERT_FLOAT_EQ(0.0, nextafterl(0.0, -1.0));
+}
+
+// TODO: nexttoward
+// TODO: nexttowardf
+// TODO: nexttowardl
+
+TEST(math, copysign) {
+  ASSERT_FLOAT_EQ(0.0, copysign(0.0, 1.0));
+  ASSERT_FLOAT_EQ(-0.0, copysign(0.0, -1.0));
+  ASSERT_FLOAT_EQ(2.0, copysign(2.0, 1.0));
+  ASSERT_FLOAT_EQ(-2.0, copysign(2.0, -1.0));
+}
+
+TEST(math, copysignf) {
+  ASSERT_FLOAT_EQ(0.0f, copysignf(0.0f, 1.0f));
+  ASSERT_FLOAT_EQ(-0.0f, copysignf(0.0f, -1.0f));
+  ASSERT_FLOAT_EQ(2.0f, copysignf(2.0f, 1.0f));
+  ASSERT_FLOAT_EQ(-2.0f, copysignf(2.0f, -1.0f));
+}
+
+TEST(math, copysignl) {
+  ASSERT_FLOAT_EQ(0.0f, copysignl(0.0, 1.0));
+  ASSERT_FLOAT_EQ(-0.0f, copysignl(0.0, -1.0));
+  ASSERT_FLOAT_EQ(2.0f, copysignl(2.0, 1.0));
+  ASSERT_FLOAT_EQ(-2.0f, copysignl(2.0, -1.0));
+}
+
+TEST(math, significand) {
+  ASSERT_FLOAT_EQ(0.0, significand(0.0));
+  ASSERT_FLOAT_EQ(1.2, significand(1.2));
+  ASSERT_FLOAT_EQ(1.5375, significand(12.3));
+}
+
+TEST(math, significandf) {
+  ASSERT_FLOAT_EQ(0.0f, significandf(0.0f));
+  ASSERT_FLOAT_EQ(1.2f, significandf(1.2f));
+  ASSERT_FLOAT_EQ(1.5375f, significandf(12.3f));
+}
+
+extern "C" long double significandl(long double); // BSD's <math.h> doesn't declare this.
+
+TEST(math, significandl) {
+  ASSERT_FLOAT_EQ(0.0, significandl(0.0));
+  ASSERT_FLOAT_EQ(1.2, significandl(1.2));
+  ASSERT_FLOAT_EQ(1.5375, significandl(12.3));
+}
+
+TEST(math, scalb) {
+  ASSERT_FLOAT_EQ(12.0, scalb(3.0, 2.0));
+}
+
+TEST(math, scalbf) {
+  ASSERT_FLOAT_EQ(12.0f, scalbf(3.0f, 2.0f));
+}
+
+TEST(math, scalbln) {
+  ASSERT_FLOAT_EQ(12.0, scalbln(3.0, 2L));
+}
+
+TEST(math, scalblnf) {
+  ASSERT_FLOAT_EQ(12.0f, scalblnf(3.0f, 2L));
+}
+
+TEST(math, scalblnl) {
+  ASSERT_FLOAT_EQ(12.0, scalblnl(3.0, 2L));
+}
+
+TEST(math, scalbn) {
+  ASSERT_FLOAT_EQ(12.0, scalbn(3.0, 2));
+}
+
+TEST(math, scalbnf) {
+  ASSERT_FLOAT_EQ(12.0f, scalbnf(3.0f, 2));
+}
+
+TEST(math, scalbnl) {
+  ASSERT_FLOAT_EQ(12.0, scalbnl(3.0, 2));
+}
+
+TEST(math, gamma) {
+  ASSERT_FLOAT_EQ(log(24.0), gamma(5.0));
+}
+
+TEST(math, gammaf) {
+  ASSERT_FLOAT_EQ(logf(24.0f), gammaf(5.0f));
+}
+
+#if defined(__BIONIC__)
+TEST(math, gamma_r) {
+  int sign;
+  ASSERT_FLOAT_EQ(log(24.0), gamma_r(5.0, &sign));
+  ASSERT_EQ(1, sign);
+}
+#endif
+
+#if defined(__BIONIC__)
+TEST(math, gammaf_r) {
+  int sign;
+  ASSERT_FLOAT_EQ(logf(24.0f), gammaf_r(5.0f, &sign));
+  ASSERT_EQ(1, sign);
+}
+#endif
+
+TEST(math, lgamma) {
+  ASSERT_FLOAT_EQ(log(24.0), lgamma(5.0));
+}
+
+TEST(math, lgammaf) {
+  ASSERT_FLOAT_EQ(logf(24.0f), lgammaf(5.0f));
+}
+
+TEST(math, lgammal) {
+  ASSERT_FLOAT_EQ(logl(24.0), lgammal(5.0));
+}
+
+TEST(math, lgamma_r) {
+  int sign;
+  ASSERT_FLOAT_EQ(log(24.0), lgamma_r(5.0, &sign));
+  ASSERT_EQ(1, sign);
+}
+
+TEST(math, lgammaf_r) {
+  int sign;
+  ASSERT_FLOAT_EQ(logf(24.0f), lgammaf_r(5.0f, &sign));
+  ASSERT_EQ(1, sign);
+}
+
+TEST(math, tgamma) {
+  ASSERT_FLOAT_EQ(24.0, tgamma(5.0));
+}
+
+TEST(math, tgammaf) {
+  ASSERT_FLOAT_EQ(24.0f, tgammaf(5.0f));
+}
+
+TEST(math, tgammal) {
+  ASSERT_FLOAT_EQ(24.0, tgammal(5.0));
+}
+
+TEST(math, j0) {
+  ASSERT_FLOAT_EQ(1.0, j0(0.0));
+  ASSERT_FLOAT_EQ(0.76519769, j0(1.0));
+}
+
+TEST(math, j0f) {
+  ASSERT_FLOAT_EQ(1.0f, j0f(0.0f));
+  ASSERT_FLOAT_EQ(0.76519769f, j0f(1.0f));
+}
+
+TEST(math, j1) {
+  ASSERT_FLOAT_EQ(0.0, j1(0.0));
+  ASSERT_FLOAT_EQ(0.44005057, j1(1.0));
+}
+
+TEST(math, j1f) {
+  ASSERT_FLOAT_EQ(0.0f, j1f(0.0f));
+  ASSERT_FLOAT_EQ(0.44005057f, j1f(1.0f));
+}
+
+TEST(math, jn) {
+  ASSERT_FLOAT_EQ(0.0, jn(4, 0.0));
+  ASSERT_FLOAT_EQ(0.0024766389, jn(4, 1.0));
+}
+
+TEST(math, jnf) {
+  ASSERT_FLOAT_EQ(0.0f, jnf(4, 0.0f));
+  ASSERT_FLOAT_EQ(0.0024766389f, jnf(4, 1.0f));
+}
+
+TEST(math, y0) {
+  ASSERT_FLOAT_EQ(-HUGE_VAL, y0(0.0));
+  ASSERT_FLOAT_EQ(0.088256963, y0(1.0));
+}
+
+TEST(math, y0f) {
+  ASSERT_FLOAT_EQ(-HUGE_VALF, y0f(0.0f));
+  ASSERT_FLOAT_EQ(0.088256963f, y0f(1.0f));
+}
+
+TEST(math, y1) {
+  ASSERT_FLOAT_EQ(-HUGE_VAL, y1(0.0));
+  ASSERT_FLOAT_EQ(-0.78121281, y1(1.0));
+}
+
+TEST(math, y1f) {
+  ASSERT_FLOAT_EQ(-HUGE_VALF, y1f(0.0f));
+  ASSERT_FLOAT_EQ(-0.78121281f, y1f(1.0f));
+}
+
+TEST(math, yn) {
+  ASSERT_FLOAT_EQ(-HUGE_VAL, yn(4, 0.0));
+  ASSERT_FLOAT_EQ(-33.278423, yn(4, 1.0));
+}
+
+TEST(math, ynf) {
+  ASSERT_FLOAT_EQ(-HUGE_VALF, ynf(4, 0.0f));
+  ASSERT_FLOAT_EQ(-33.278423f, ynf(4, 1.0f));
+}
+
+TEST(math, frexp) {
+  int exp;
+  double dr = frexp(1024.0, &exp);
+  ASSERT_FLOAT_EQ(1024.0, scalbn(dr, exp));
+}
+
+TEST(math, frexpf) {
+  int exp;
+  float fr = frexpf(1024.0f, &exp);
+  ASSERT_FLOAT_EQ(1024.0f, scalbnf(fr, exp));
+}
+
+TEST(math, frexpl) {
+  int exp;
+  long double ldr = frexpl(1024.0, &exp);
+  ASSERT_FLOAT_EQ(1024.0, scalbnl(ldr, exp));
+}
+
+TEST(math, modf) {
+  double di;
+  double df = modf(123.456, &di);
+  ASSERT_FLOAT_EQ(123.0, di);
+  ASSERT_FLOAT_EQ(0.456, df);
+}
+
+TEST(math, modff) {
+  float fi;
+  float ff = modff(123.456f, &fi);
+  ASSERT_FLOAT_EQ(123.0f, fi);
+  ASSERT_FLOAT_EQ(0.45600128f, ff);
+}
+
+TEST(math, modfl) {
+  long double ldi;
+  long double ldf = modfl(123.456, &ldi);
+  ASSERT_FLOAT_EQ(123.0, ldi);
+  ASSERT_FLOAT_EQ(0.456, ldf);
+}
+
+TEST(math, remquo) {
+  int q;
+  double d = remquo(13.0, 4.0, &q);
+  ASSERT_EQ(3, q);
+  ASSERT_FLOAT_EQ(1.0, d);
+}
+
+TEST(math, remquof) {
+  int q;
+  float f = remquof(13.0f, 4.0f, &q);
+  ASSERT_EQ(3, q);
+  ASSERT_FLOAT_EQ(1.0, f);
+}
+
+TEST(math, remquol) {
+  int q;
+  long double ld = remquol(13.0, 4.0, &q);
+  ASSERT_EQ(3, q);
+  ASSERT_FLOAT_EQ(1.0, ld);
+}
+
+// https://code.google.com/p/android/issues/detail?id=6697
+TEST(math, frexpf_public_bug_6697) {
+  int exp;
+  float fr = frexpf(14.1f, &exp);
+  ASSERT_FLOAT_EQ(14.1f, scalbnf(fr, exp));
+}
diff --git a/tests/netdb_test.cpp b/tests/netdb_test.cpp
new file mode 100644
index 0000000..33f6c01
--- /dev/null
+++ b/tests/netdb_test.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <netinet/in.h>
+
+TEST(netdb, getaddrinfo_NULL_hints) {
+  addrinfo* ai = NULL;
+  ASSERT_EQ(0, getaddrinfo("localhost", "9999", NULL, &ai));
+  freeaddrinfo(ai);
+}
+
+TEST(netdb, getnameinfo_salen) {
+  sockaddr_storage ss;
+  memset(&ss, 0, sizeof(ss));
+  sockaddr* sa = reinterpret_cast<sockaddr*>(&ss);
+  char tmp[16];
+
+  ss.ss_family = AF_INET;
+  socklen_t too_much = sizeof(ss);
+  socklen_t just_right = sizeof(sockaddr_in);
+  socklen_t too_little = sizeof(sockaddr_in) - 1;
+
+  ASSERT_EQ(0, getnameinfo(sa, too_much, tmp, sizeof(tmp), NULL, 0, NI_NUMERICHOST));
+  ASSERT_STREQ("0.0.0.0", tmp);
+  ASSERT_EQ(0, getnameinfo(sa, just_right, tmp, sizeof(tmp), NULL, 0, NI_NUMERICHOST));
+  ASSERT_STREQ("0.0.0.0", tmp);
+  ASSERT_EQ(EAI_FAMILY, getnameinfo(sa, too_little, tmp, sizeof(tmp), NULL, 0, NI_NUMERICHOST));
+
+  ss.ss_family = AF_INET6;
+  just_right = sizeof(sockaddr_in6);
+  too_little = sizeof(sockaddr_in6) - 1;
+  too_much = just_right + 1;
+
+  ASSERT_EQ(0, getnameinfo(sa, too_much, tmp, sizeof(tmp), NULL, 0, NI_NUMERICHOST));
+  ASSERT_STREQ("::", tmp);
+  ASSERT_EQ(0, getnameinfo(sa, just_right, tmp, sizeof(tmp), NULL, 0, NI_NUMERICHOST));
+  ASSERT_STREQ("::", tmp);
+  ASSERT_EQ(EAI_FAMILY, getnameinfo(sa, too_little, tmp, sizeof(tmp), NULL, 0, NI_NUMERICHOST));
+}
diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp
index 9a474c0..98bc4e5 100644
--- a/tests/pthread_test.cpp
+++ b/tests/pthread_test.cpp
@@ -28,6 +28,28 @@
   ASSERT_EQ(EINVAL, pthread_key_delete(key));
 }
 
+#if !defined(__GLIBC__) // glibc uses keys internally that its sysconf value doesn't account for.
+TEST(pthread, pthread_key_create_lots) {
+  // We can allocate _SC_THREAD_KEYS_MAX keys.
+  std::vector<pthread_key_t> keys;
+  for (int i = 0; i < sysconf(_SC_THREAD_KEYS_MAX); ++i) {
+    pthread_key_t key;
+    // If this fails, it's likely that GLOBAL_INIT_THREAD_LOCAL_BUFFER_COUNT is wrong.
+    ASSERT_EQ(0, pthread_key_create(&key, NULL)) << i << " of " << sysconf(_SC_THREAD_KEYS_MAX);
+    keys.push_back(key);
+  }
+
+  // ...and that really is the maximum.
+  pthread_key_t key;
+  ASSERT_EQ(EAGAIN, pthread_key_create(&key, NULL));
+
+  // (Don't leak all those keys!)
+  for (size_t i = 0; i < keys.size(); ++i) {
+    ASSERT_EQ(0, pthread_key_delete(keys[i]));
+  }
+}
+#endif
+
 static void* IdFn(void* arg) {
   return arg;
 }
@@ -37,10 +59,32 @@
   return NULL;
 }
 
+static void* SpinFn(void* arg) {
+  volatile bool* b = reinterpret_cast<volatile bool*>(arg);
+  while (!*b) {
+  }
+  return NULL;
+}
+
 static void* JoinFn(void* arg) {
   return reinterpret_cast<void*>(pthread_join(reinterpret_cast<pthread_t>(arg), NULL));
 }
 
+static void AssertDetached(pthread_t t, bool is_detached) {
+  pthread_attr_t attr;
+  ASSERT_EQ(0, pthread_getattr_np(t, &attr));
+  int detach_state;
+  ASSERT_EQ(0, pthread_attr_getdetachstate(&attr, &detach_state));
+  pthread_attr_destroy(&attr);
+  ASSERT_EQ(is_detached, (detach_state == PTHREAD_CREATE_DETACHED));
+}
+
+static void MakeDeadThread(pthread_t& t) {
+  ASSERT_EQ(0, pthread_create(&t, NULL, IdFn, NULL));
+  void* result;
+  ASSERT_EQ(0, pthread_join(t, &result));
+}
+
 TEST(pthread, pthread_create) {
   void* expected_result = reinterpret_cast<void*>(123);
   // Can we create a thread?
@@ -52,12 +96,22 @@
   ASSERT_EQ(expected_result, result);
 }
 
+TEST(pthread, pthread_create_EAGAIN) {
+  pthread_attr_t attributes;
+  ASSERT_EQ(0, pthread_attr_init(&attributes));
+  ASSERT_EQ(0, pthread_attr_setstacksize(&attributes, static_cast<size_t>(-1) & ~(getpagesize() - 1)));
+
+  pthread_t t;
+  ASSERT_EQ(EAGAIN, pthread_create(&t, &attributes, IdFn, NULL));
+}
+
 TEST(pthread, pthread_no_join_after_detach) {
   pthread_t t1;
   ASSERT_EQ(0, pthread_create(&t1, NULL, SleepFn, reinterpret_cast<void*>(5)));
 
   // After a pthread_detach...
   ASSERT_EQ(0, pthread_detach(t1));
+  AssertDetached(t1, true);
 
   // ...pthread_join should fail.
   void* result;
@@ -65,18 +119,201 @@
 }
 
 TEST(pthread, pthread_no_op_detach_after_join) {
+  bool done = false;
+
   pthread_t t1;
-  ASSERT_EQ(0, pthread_create(&t1, NULL, SleepFn, reinterpret_cast<void*>(1)));
+  ASSERT_EQ(0, pthread_create(&t1, NULL, SpinFn, &done));
 
   // If thread 2 is already waiting to join thread 1...
   pthread_t t2;
   ASSERT_EQ(0, pthread_create(&t2, NULL, JoinFn, reinterpret_cast<void*>(t1)));
 
-  // ...a call to pthread_detach on thread 1 will "succeed"...
-  ASSERT_EQ(0, pthread_detach(t1));
+  sleep(1); // (Give t2 a chance to call pthread_join.)
 
-  // ...but the join still goes ahead.
+  // ...a call to pthread_detach on thread 1 will "succeed" (silently fail)...
+  ASSERT_EQ(0, pthread_detach(t1));
+  AssertDetached(t1, false);
+
+  done = true;
+
+  // ...but t2's join on t1 still goes ahead (which we can tell because our join on t2 finishes).
   void* join_result;
   ASSERT_EQ(0, pthread_join(t2, &join_result));
-  ASSERT_EQ(EINVAL, reinterpret_cast<int>(join_result));
+  ASSERT_EQ(0, reinterpret_cast<int>(join_result));
+}
+
+TEST(pthread, pthread_join_self) {
+  void* result;
+  ASSERT_EQ(EDEADLK, pthread_join(pthread_self(), &result));
+}
+
+#if __BIONIC__ // For some reason, gtest on bionic can cope with this but gtest on glibc can't.
+
+static void TestBug37410() {
+  pthread_t t1;
+  ASSERT_EQ(0, pthread_create(&t1, NULL, JoinFn, reinterpret_cast<void*>(pthread_self())));
+  pthread_exit(NULL);
+}
+
+// Even though this isn't really a death test, we have to say "DeathTest" here so gtest knows to
+// run this test (which exits normally) in its own process.
+TEST(pthread_DeathTest, pthread_bug_37410) {
+  // http://code.google.com/p/android/issues/detail?id=37410
+  ::testing::FLAGS_gtest_death_test_style = "threadsafe";
+  ASSERT_EXIT(TestBug37410(), ::testing::ExitedWithCode(0), "");
+}
+#endif
+
+static void* SignalHandlerFn(void* arg) {
+  sigset_t wait_set;
+  sigfillset(&wait_set);
+  return reinterpret_cast<void*>(sigwait(&wait_set, reinterpret_cast<int*>(arg)));
+}
+
+TEST(pthread, pthread_sigmask) {
+  // Block SIGUSR1.
+  sigset_t set;
+  sigemptyset(&set);
+  sigaddset(&set, SIGUSR1);
+  ASSERT_EQ(0, pthread_sigmask(SIG_BLOCK, &set, NULL));
+
+  // Spawn a thread that calls sigwait and tells us what it received.
+  pthread_t signal_thread;
+  int received_signal = -1;
+  ASSERT_EQ(0, pthread_create(&signal_thread, NULL, SignalHandlerFn, &received_signal));
+
+  // Send that thread SIGUSR1.
+  pthread_kill(signal_thread, SIGUSR1);
+
+  // See what it got.
+  void* join_result;
+  ASSERT_EQ(0, pthread_join(signal_thread, &join_result));
+  ASSERT_EQ(SIGUSR1, received_signal);
+  ASSERT_EQ(0, reinterpret_cast<int>(join_result));
+}
+
+#if __BIONIC__
+extern "C" int  __pthread_clone(void* (*fn)(void*), void* child_stack, int flags, void* arg);
+TEST(pthread, __pthread_clone) {
+  uintptr_t fake_child_stack[16];
+  errno = 0;
+  ASSERT_EQ(-1, __pthread_clone(NULL, &fake_child_stack[0], CLONE_THREAD, NULL));
+  ASSERT_EQ(EINVAL, errno);
+}
+#endif
+
+#if __BIONIC__ // Not all build servers have a new enough glibc? TODO: remove when they're on gprecise.
+TEST(pthread, pthread_setname_np__too_long) {
+  ASSERT_EQ(ERANGE, pthread_setname_np(pthread_self(), "this name is far too long for linux"));
+}
+#endif
+
+#if __BIONIC__ // Not all build servers have a new enough glibc? TODO: remove when they're on gprecise.
+TEST(pthread, pthread_setname_np__self) {
+  ASSERT_EQ(0, pthread_setname_np(pthread_self(), "short 1"));
+}
+#endif
+
+#if __BIONIC__ // Not all build servers have a new enough glibc? TODO: remove when they're on gprecise.
+TEST(pthread, pthread_setname_np__other) {
+  // Emulator kernels don't currently support setting the name of other threads.
+  char* filename = NULL;
+  asprintf(&filename, "/proc/self/task/%d/comm", gettid());
+  struct stat sb;
+  bool has_comm = (stat(filename, &sb) != -1);
+  free(filename);
+
+  if (has_comm) {
+    pthread_t t1;
+    ASSERT_EQ(0, pthread_create(&t1, NULL, SleepFn, reinterpret_cast<void*>(5)));
+    ASSERT_EQ(0, pthread_setname_np(t1, "short 2"));
+  } else {
+    fprintf(stderr, "skipping test: this kernel doesn't have /proc/self/task/tid/comm files!\n");
+  }
+}
+#endif
+
+#if __BIONIC__ // Not all build servers have a new enough glibc? TODO: remove when they're on gprecise.
+TEST(pthread, pthread_setname_np__no_such_thread) {
+  pthread_t dead_thread;
+  MakeDeadThread(dead_thread);
+
+  // Call pthread_setname_np after thread has already exited.
+  ASSERT_EQ(ENOENT, pthread_setname_np(dead_thread, "short 3"));
+}
+#endif
+
+TEST(pthread, pthread_kill__0) {
+  // Signal 0 just tests that the thread exists, so it's safe to call on ourselves.
+  ASSERT_EQ(0, pthread_kill(pthread_self(), 0));
+}
+
+TEST(pthread, pthread_kill__invalid_signal) {
+  ASSERT_EQ(EINVAL, pthread_kill(pthread_self(), -1));
+}
+
+static void pthread_kill__in_signal_handler_helper(int signal_number) {
+  static int count = 0;
+  ASSERT_EQ(SIGALRM, signal_number);
+  if (++count == 1) {
+    // Can we call pthread_kill from a signal handler?
+    ASSERT_EQ(0, pthread_kill(pthread_self(), SIGALRM));
+  }
+}
+
+TEST(pthread, pthread_kill__in_signal_handler) {
+  struct sigaction action;
+  sigemptyset(&action.sa_mask);
+  action.sa_flags = 0;
+  action.sa_handler = pthread_kill__in_signal_handler_helper;
+  sigaction(SIGALRM, &action, NULL);
+  ASSERT_EQ(0, pthread_kill(pthread_self(), SIGALRM));
+}
+
+TEST(pthread, pthread_detach__no_such_thread) {
+  pthread_t dead_thread;
+  MakeDeadThread(dead_thread);
+
+  ASSERT_EQ(ESRCH, pthread_detach(dead_thread));
+}
+
+TEST(pthread, pthread_getcpuclockid__no_such_thread) {
+  pthread_t dead_thread;
+  MakeDeadThread(dead_thread);
+
+  clockid_t c;
+  ASSERT_EQ(ESRCH, pthread_getcpuclockid(dead_thread, &c));
+}
+
+TEST(pthread, pthread_getschedparam__no_such_thread) {
+  pthread_t dead_thread;
+  MakeDeadThread(dead_thread);
+
+  int policy;
+  sched_param param;
+  ASSERT_EQ(ESRCH, pthread_getschedparam(dead_thread, &policy, &param));
+}
+
+TEST(pthread, pthread_setschedparam__no_such_thread) {
+  pthread_t dead_thread;
+  MakeDeadThread(dead_thread);
+
+  int policy = 0;
+  sched_param param;
+  ASSERT_EQ(ESRCH, pthread_setschedparam(dead_thread, policy, &param));
+}
+
+TEST(pthread, pthread_join__no_such_thread) {
+  pthread_t dead_thread;
+  MakeDeadThread(dead_thread);
+
+  void* result;
+  ASSERT_EQ(ESRCH, pthread_join(dead_thread, &result));
+}
+
+TEST(pthread, pthread_kill__no_such_thread) {
+  pthread_t dead_thread;
+  MakeDeadThread(dead_thread);
+
+  ASSERT_EQ(ESRCH, pthread_kill(dead_thread, 0));
 }
diff --git a/tests/signal_test.cpp b/tests/signal_test.cpp
new file mode 100644
index 0000000..e41dc1c
--- /dev/null
+++ b/tests/signal_test.cpp
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+#include <errno.h>
+#include <signal.h>
+
+template <typename Fn>
+static void TestSigSet1(Fn fn) {
+  // NULL sigset_t*.
+  sigset_t* set_ptr = NULL;
+  errno = 0;
+  ASSERT_EQ(-1, fn(set_ptr));
+  ASSERT_EQ(EINVAL, errno);
+
+  // Non-NULL.
+  sigset_t set;
+  errno = 0;
+  ASSERT_EQ(0, fn(&set));
+  ASSERT_EQ(0, errno);
+}
+
+template <typename Fn>
+static void TestSigSet2(Fn fn) {
+  // NULL sigset_t*.
+  sigset_t* set_ptr = NULL;
+  errno = 0;
+  ASSERT_EQ(-1, fn(set_ptr, SIGSEGV));
+  ASSERT_EQ(EINVAL, errno);
+
+  sigset_t set;
+  sigemptyset(&set);
+
+  int min_signal = SIGHUP;
+  int max_signal = SIGRTMAX;
+
+#if defined(__BIONIC__) && !defined(__mips__)
+  // bionic's sigset_t is too small for ARM and x86: 32 bits instead of 64.
+  // This means you can't refer to any of the real-time signals.
+  // See http://b/3038348 and http://b/5828899.
+  max_signal = 32;
+#else
+  // Other C libraries (or bionic for MIPS) are perfectly capable of using their largest signal.
+  ASSERT_GE(sizeof(sigset_t) * 8, static_cast<size_t>(SIGRTMAX));
+#endif
+
+  // Bad signal number: too small.
+  errno = 0;
+  ASSERT_EQ(-1, fn(&set, 0));
+  ASSERT_EQ(EINVAL, errno);
+
+  // Bad signal number: too high.
+  errno = 0;
+  ASSERT_EQ(-1, fn(&set, max_signal + 1));
+  ASSERT_EQ(EINVAL, errno);
+
+  // Good signal numbers, low and high ends of range.
+  errno = 0;
+  ASSERT_EQ(0, fn(&set, min_signal));
+  ASSERT_EQ(0, errno);
+  ASSERT_EQ(0, fn(&set, max_signal));
+  ASSERT_EQ(0, errno);
+}
+
+class ScopedSignalHandler {
+ public:
+  ScopedSignalHandler(int signal_number, void (*handler)(int)) : signal_number_(signal_number) {
+    sigemptyset(&action_.sa_mask);
+    action_.sa_flags = 0;
+    action_.sa_handler = handler;
+    sigaction(signal_number_, &action_, &old_action_);
+  }
+
+  ~ScopedSignalHandler() {
+    sigaction(signal_number_, &old_action_, NULL);
+  }
+
+ private:
+  struct sigaction action_;
+  struct sigaction old_action_;
+  const int signal_number_;
+};
+
+TEST(signal, sigismember_invalid) {
+  TestSigSet2(sigismember);
+}
+
+TEST(signal, sigaddset_invalid) {
+  TestSigSet2(sigaddset);
+}
+
+TEST(signal, sigdelset_invalid) {
+  TestSigSet2(sigdelset);
+}
+
+TEST(signal, sigemptyset_invalid) {
+  TestSigSet1(sigemptyset);
+}
+
+TEST(signal, sigfillset_invalid) {
+  TestSigSet1(sigfillset);
+}
+
+TEST(signal, raise_invalid) {
+  errno = 0;
+  ASSERT_EQ(-1, raise(-1));
+  ASSERT_EQ(EINVAL, errno);
+}
+
+static void raise_in_signal_handler_helper(int signal_number) {
+  ASSERT_EQ(SIGALRM, signal_number);
+  static int count = 0;
+  if (++count == 1) {
+    raise(SIGALRM);
+  }
+}
+
+TEST(signal, raise_in_signal_handler) {
+  ScopedSignalHandler ssh(SIGALRM, raise_in_signal_handler_helper);
+  raise(SIGALRM);
+}
+
+static void HandleSIGALRM(int signal_number) {
+  ASSERT_EQ(SIGALRM, signal_number);
+}
+
+TEST(signal, sigwait) {
+  ScopedSignalHandler ssh(SIGALRM, HandleSIGALRM);
+
+  sigset_t wait_set;
+  sigemptyset(&wait_set);
+  sigaddset(&wait_set, SIGALRM);
+
+  alarm(1);
+
+  int received_signal;
+  errno = 0;
+  ASSERT_EQ(0, sigwait(&wait_set, &received_signal));
+  ASSERT_EQ(0, errno);
+  ASSERT_EQ(SIGALRM, received_signal);
+}
diff --git a/tests/stack_protector_test.cpp b/tests/stack_protector_test.cpp
new file mode 100644
index 0000000..7946bbc
--- /dev/null
+++ b/tests/stack_protector_test.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Contributed by: Intel Corporation
+ */
+
+#include <gtest/gtest.h>
+
+#include <pthread.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+#include <set>
+
+#ifdef __GLIBC__
+
+// glibc doesn't expose gettid(2).
+pid_t gettid() { return syscall(__NR_gettid); }
+
+#endif
+
+#ifdef __i386__
+
+// For x86, bionic and glibc have per-thread stack guard values (all identical).
+
+static uint32_t GetGuardFromTls() {
+  uint32_t guard;
+  asm ("mov %%gs:0x14, %0": "=d" (guard));
+  return guard;
+}
+
+struct stack_protector_checker {
+  std::set<pid_t> tids;
+  std::set<uint32_t> guards;
+
+  void Check() {
+    pid_t tid = gettid();
+    uint32_t guard = GetGuardFromTls();
+
+    printf("[thread %d] %%gs:0x14 = 0x%08x\n", tid, guard);
+
+    // Duplicate tid. gettid(2) bug? Seeing this would be very upsetting.
+    ASSERT_TRUE(tids.find(tid) == tids.end());
+
+    // Uninitialized guard. Our bug. Note this is potentially flaky; we _could_ get
+    // four random zero bytes, but it should be vanishingly unlikely.
+    ASSERT_NE(guard, 0U);
+
+    tids.insert(tid);
+    guards.insert(guard);
+  }
+};
+
+static void* ThreadGuardHelper(void* arg) {
+  stack_protector_checker* checker = reinterpret_cast<stack_protector_checker*>(arg);
+  checker->Check();
+  return NULL;
+}
+
+TEST(stack_protector, same_guard_per_thread) {
+  stack_protector_checker checker;
+  size_t thread_count = 10;
+  for (size_t i = 0; i < thread_count; ++i) {
+    pthread_t t;
+    ASSERT_EQ(0, pthread_create(&t, NULL, ThreadGuardHelper, &checker));
+    void* result;
+    ASSERT_EQ(0, pthread_join(t, &result));
+    ASSERT_EQ(NULL, result);
+  }
+  ASSERT_EQ(thread_count, checker.tids.size());
+
+  // bionic and glibc use the same guard for every thread.
+  ASSERT_EQ(1U, checker.guards.size());
+}
+
+#endif
+
+#if defined(__BIONIC__) || defined(__arm__) || defined(__mips__)
+
+// For ARM and MIPS, glibc has a global stack check guard value.
+
+// Bionic has the global for x86 too, to support binaries that can run on
+// Android releases that didn't implement the TLS guard value.
+
+extern "C" uintptr_t __stack_chk_guard;
+
+TEST(stack_protector, global_guard) {
+  ASSERT_NE(0, gettid());
+  ASSERT_NE(0U, __stack_chk_guard);
+}
+
+/*
+ * When this function returns, the stack canary will be inconsistent
+ * with the previous value, which will generate a call to __stack_chk_fail(),
+ * eventually resulting in a SIGABRT.
+ *
+ * This must be marked with "__attribute__ ((noinline))", to ensure the
+ * compiler generates the proper stack guards around this function.
+ */
+__attribute__ ((noinline))
+static void do_modify_stack_chk_guard() {
+  __stack_chk_guard = 0x12345678;
+}
+
+TEST(stack_protector_DeathTest, modify_stack_protector) {
+  ::testing::FLAGS_gtest_death_test_style = "threadsafe";
+  ASSERT_EXIT(do_modify_stack_chk_guard(), testing::KilledBySignal(SIGSEGV), "");
+}
+
+#endif
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
new file mode 100644
index 0000000..4b5a1f9
--- /dev/null
+++ b/tests/stdio_test.cpp
@@ -0,0 +1,195 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+TEST(stdio, tmpfile_fileno_fprintf_rewind_fgets) {
+  FILE* fp = tmpfile();
+  ASSERT_TRUE(fp != NULL);
+
+  int fd = fileno(fp);
+  ASSERT_NE(fd, -1);
+
+  struct stat sb;
+  int rc = fstat(fd, &sb);
+  ASSERT_NE(rc, -1);
+  ASSERT_EQ(sb.st_mode & 0777, 0600U);
+
+  rc = fprintf(fp, "hello\n");
+  ASSERT_EQ(rc, 6);
+
+  rewind(fp);
+
+  char buf[16];
+  char* s = fgets(buf, sizeof(buf), fp);
+  ASSERT_TRUE(s != NULL);
+  ASSERT_STREQ("hello\n", s);
+
+  fclose(fp);
+}
+
+TEST(stdio, getdelim) {
+  FILE* fp = tmpfile();
+  ASSERT_TRUE(fp != NULL);
+
+  const char* line_written = "This  is a test";
+  int rc = fprintf(fp, "%s", line_written);
+  ASSERT_EQ(rc, static_cast<int>(strlen(line_written)));
+
+  rewind(fp);
+
+  char* word_read = NULL;
+  size_t allocated_length = 0;
+
+  const char* expected[] = { "This ", " ", "is ", "a ", "test" };
+  for (size_t i = 0; i < 5; ++i) {
+    ASSERT_FALSE(feof(fp));
+    ASSERT_EQ(getdelim(&word_read, &allocated_length, ' ', fp), static_cast<int>(strlen(expected[i])));
+    ASSERT_GE(allocated_length, strlen(expected[i]));
+    ASSERT_STREQ(word_read, expected[i]);
+  }
+  // The last read should have set the end-of-file indicator for the stream.
+  ASSERT_TRUE(feof(fp));
+  clearerr(fp);
+
+  // getdelim returns -1 but doesn't set errno if we're already at EOF.
+  // It should set the end-of-file indicator for the stream, though.
+  errno = 0;
+  ASSERT_EQ(getdelim(&word_read, &allocated_length, ' ', fp), -1);
+  ASSERT_EQ(0, errno);
+  ASSERT_TRUE(feof(fp));
+
+  free(word_read);
+  fclose(fp);
+}
+
+TEST(stdio, getdelim_invalid) {
+  FILE* fp = tmpfile();
+
+  char* buffer = NULL;
+  size_t buffer_length = 0;
+
+  // The first argument can't be NULL.
+  errno = 0;
+  ASSERT_EQ(getdelim(NULL, &buffer_length, ' ', fp), -1);
+  ASSERT_EQ(EINVAL, errno);
+
+  // The second argument can't be NULL.
+  errno = 0;
+  ASSERT_EQ(getdelim(&buffer, NULL, ' ', fp), -1);
+  ASSERT_EQ(EINVAL, errno);
+
+  // The stream can't be closed.
+  fclose(fp);
+  errno = 0;
+  ASSERT_EQ(getdelim(&buffer, &buffer_length, ' ', fp), -1);
+  ASSERT_EQ(EBADF, errno);
+}
+
+TEST(stdio, getline) {
+  FILE* fp = tmpfile();
+  ASSERT_TRUE(fp != NULL);
+
+  const char* line_written = "This is a test for getline\n";
+  const size_t line_count = 5;
+
+  for (size_t i = 0; i < line_count; ++i) {
+    int rc = fprintf(fp, "%s", line_written);
+    ASSERT_EQ(rc, static_cast<int>(strlen(line_written)));
+  }
+
+  rewind(fp);
+
+  char* line_read = NULL;
+  size_t allocated_length = 0;
+
+  size_t read_line_count = 0;
+  ssize_t read_char_count;
+  while ((read_char_count = getline(&line_read, &allocated_length, fp)) != -1) {
+    ASSERT_EQ(read_char_count, static_cast<int>(strlen(line_written)));
+    ASSERT_GE(allocated_length, strlen(line_written));
+    ASSERT_STREQ(line_read, line_written);
+    ++read_line_count;
+  }
+  ASSERT_EQ(read_line_count, line_count);
+
+  // The last read should have set the end-of-file indicator for the stream.
+  ASSERT_TRUE(feof(fp));
+  clearerr(fp);
+
+  // getline returns -1 but doesn't set errno if we're already at EOF.
+  // It should set the end-of-file indicator for the stream, though.
+  errno = 0;
+  ASSERT_EQ(getline(&line_read, &allocated_length, fp), -1);
+  ASSERT_EQ(0, errno);
+  ASSERT_TRUE(feof(fp));
+
+  free(line_read);
+  fclose(fp);
+}
+
+TEST(stdio, getline_invalid) {
+  FILE* fp = tmpfile();
+
+  char* buffer = NULL;
+  size_t buffer_length = 0;
+
+  // The first argument can't be NULL.
+  errno = 0;
+  ASSERT_EQ(getline(NULL, &buffer_length, fp), -1);
+  ASSERT_EQ(EINVAL, errno);
+
+  // The second argument can't be NULL.
+  errno = 0;
+  ASSERT_EQ(getline(&buffer, NULL, fp), -1);
+  ASSERT_EQ(EINVAL, errno);
+
+  // The stream can't be closed.
+  fclose(fp);
+  errno = 0;
+  ASSERT_EQ(getline(&buffer, &buffer_length, fp), -1);
+  ASSERT_EQ(EBADF, errno);
+}
+
+TEST(stdio, printf_ssize_t) {
+  // http://b/8253769
+  ASSERT_EQ(sizeof(ssize_t), sizeof(long int));
+  ASSERT_EQ(sizeof(ssize_t), sizeof(size_t));
+  // For our 32-bit ABI, we had a ssize_t definition that confuses GCC into saying:
+  // error: format '%zd' expects argument of type 'signed size_t',
+  //     but argument 4 has type 'ssize_t {aka long int}' [-Werror=format]
+  ssize_t v = 1;
+  char buf[32];
+  snprintf(buf, sizeof(buf), "%zd", v);
+}
+
+TEST(stdio, popen) {
+  FILE* fp = popen("cat /proc/version", "r");
+  ASSERT_TRUE(fp != NULL);
+
+  char buf[16];
+  char* s = fgets(buf, sizeof(buf), fp);
+  buf[13] = '\0';
+  ASSERT_STREQ("Linux version", s);
+
+  ASSERT_EQ(0, pclose(fp));
+}
diff --git a/tests/stdlib_test.cpp b/tests/stdlib_test.cpp
new file mode 100644
index 0000000..fed39f8
--- /dev/null
+++ b/tests/stdlib_test.cpp
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+#include <errno.h>
+#include <libgen.h>
+#include <limits.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+TEST(stdlib, drand48) {
+  srand48(0x01020304);
+  EXPECT_DOUBLE_EQ(0.65619299195623526, drand48());
+  EXPECT_DOUBLE_EQ(0.18522597229772941, drand48());
+  EXPECT_DOUBLE_EQ(0.42015087072844537, drand48());
+  EXPECT_DOUBLE_EQ(0.061637783047395089, drand48());
+}
+
+TEST(stdlib, lrand48_random_rand) {
+  srand48(0x01020304);
+  EXPECT_EQ(1409163720, lrand48());
+  EXPECT_EQ(397769746, lrand48());
+  EXPECT_EQ(902267124, lrand48());
+  EXPECT_EQ(132366131, lrand48());
+
+#if __BIONIC__
+  // On bionic, random(3) is equivalent to lrand48...
+  srandom(0x01020304);
+  EXPECT_EQ(1409163720, random());
+  EXPECT_EQ(397769746, random());
+  EXPECT_EQ(902267124, random());
+  EXPECT_EQ(132366131, random());
+
+  // ...and rand(3) is the bottom 32 bits.
+  srand(0x01020304);
+  EXPECT_EQ(static_cast<int>(1409163720), rand());
+  EXPECT_EQ(static_cast<int>(397769746), rand());
+  EXPECT_EQ(static_cast<int>(902267124), rand());
+  EXPECT_EQ(static_cast<int>(132366131), rand());
+#endif
+}
+
+TEST(stdlib, mrand48) {
+  srand48(0x01020304);
+  EXPECT_EQ(-1476639856, mrand48());
+  EXPECT_EQ(795539493, mrand48());
+  EXPECT_EQ(1804534249, mrand48());
+  EXPECT_EQ(264732262, mrand48());
+}
+
+TEST(stdlib, posix_memalign) {
+  void* p;
+
+  ASSERT_EQ(0, posix_memalign(&p, 512, 128));
+  ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(p) % 512);
+  free(p);
+
+  // Can't align to a non-power of 2.
+  ASSERT_EQ(EINVAL, posix_memalign(&p, 81, 128));
+}
+
+TEST(stdlib, realpath__NULL_filename) {
+  errno = 0;
+  char* p = realpath(NULL, NULL);
+  ASSERT_TRUE(p == NULL);
+  ASSERT_EQ(EINVAL, errno);
+}
+
+TEST(stdlib, realpath__empty_filename) {
+  errno = 0;
+  char* p = realpath("", NULL);
+  ASSERT_TRUE(p == NULL);
+  ASSERT_EQ(ENOENT, errno);
+}
+
+TEST(stdlib, realpath__ENOENT) {
+  errno = 0;
+  char* p = realpath("/this/directory/path/almost/certainly/does/not/exist", NULL);
+  ASSERT_TRUE(p == NULL);
+  ASSERT_EQ(ENOENT, errno);
+}
+
+TEST(stdlib, realpath) {
+  // Get the name of this executable.
+  char executable_path[PATH_MAX];
+  int rc = readlink("/proc/self/exe", executable_path, sizeof(executable_path));
+  ASSERT_NE(rc, -1);
+  executable_path[rc] = '\0';
+
+  char buf[PATH_MAX + 1];
+  char* p = realpath("/proc/self/exe", buf);
+  ASSERT_STREQ(executable_path, p);
+
+  p = realpath("/proc/self/exe", NULL);
+  ASSERT_STREQ(executable_path, p);
+  free(p);
+}
diff --git a/tests/string_benchmark.cpp b/tests/string_benchmark.cpp
new file mode 100644
index 0000000..536e253
--- /dev/null
+++ b/tests/string_benchmark.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "benchmark.h"
+
+#include <string.h>
+
+#define KB 1024
+#define MB 1024*KB
+
+#define AT_COMMON_SIZES \
+    Arg(8)->Arg(64)->Arg(512)->Arg(1*KB)->Arg(8*KB)->Arg(16*KB)->Arg(32*KB)->Arg(64*KB)
+
+// TODO: test unaligned operation too? (currently everything will be 8-byte aligned by malloc.)
+
+static void BM_string_memcmp(int iters, int nbytes) {
+  StopBenchmarkTiming();
+  char* src = new char[nbytes]; char* dst = new char[nbytes];
+  memset(src, 'x', nbytes);
+  memset(dst, 'x', nbytes);
+  StartBenchmarkTiming();
+
+  volatile int c __attribute__((unused)) = 0;
+  for (int i = 0; i < iters; ++i) {
+    c += memcmp(dst, src, nbytes);
+  }
+
+  StopBenchmarkTiming();
+  SetBenchmarkBytesProcessed(int64_t(iters) * int64_t(nbytes));
+  delete[] src;
+  delete[] dst;
+}
+BENCHMARK(BM_string_memcmp)->AT_COMMON_SIZES;
+
+static void BM_string_memcpy(int iters, int nbytes) {
+  StopBenchmarkTiming();
+  char* src = new char[nbytes]; char* dst = new char[nbytes];
+  memset(src, 'x', nbytes);
+  StartBenchmarkTiming();
+
+  for (int i = 0; i < iters; ++i) {
+    memcpy(dst, src, nbytes);
+  }
+
+  StopBenchmarkTiming();
+  SetBenchmarkBytesProcessed(int64_t(iters) * int64_t(nbytes));
+  delete[] src;
+  delete[] dst;
+}
+BENCHMARK(BM_string_memcpy)->AT_COMMON_SIZES;
+
+static void BM_string_memmove(int iters, int nbytes) {
+  StopBenchmarkTiming();
+  char* buf = new char[nbytes + 64];
+  memset(buf, 'x', nbytes + 64);
+  StartBenchmarkTiming();
+
+  for (int i = 0; i < iters; ++i) {
+    memmove(buf, buf + 1, nbytes); // Worst-case overlap.
+  }
+
+  StopBenchmarkTiming();
+  SetBenchmarkBytesProcessed(int64_t(iters) * int64_t(nbytes));
+  delete[] buf;
+}
+BENCHMARK(BM_string_memmove)->AT_COMMON_SIZES;
+
+static void BM_string_memset(int iters, int nbytes) {
+  StopBenchmarkTiming();
+  char* dst = new char[nbytes];
+  StartBenchmarkTiming();
+
+  for (int i = 0; i < iters; ++i) {
+    memset(dst, 0, nbytes);
+  }
+
+  StopBenchmarkTiming();
+  SetBenchmarkBytesProcessed(int64_t(iters) * int64_t(nbytes));
+  delete[] dst;
+}
+BENCHMARK(BM_string_memset)->AT_COMMON_SIZES;
+
+static void BM_string_strlen(int iters, int nbytes) {
+  StopBenchmarkTiming();
+  char* s = new char[nbytes];
+  memset(s, 'x', nbytes);
+  s[nbytes - 1] = 0;
+  StartBenchmarkTiming();
+
+  volatile int c __attribute__((unused)) = 0;
+  for (int i = 0; i < iters; ++i) {
+    c += strlen(s);
+  }
+
+  StopBenchmarkTiming();
+  SetBenchmarkBytesProcessed(int64_t(iters) * int64_t(nbytes));
+  delete[] s;
+}
+BENCHMARK(BM_string_strlen)->AT_COMMON_SIZES;
diff --git a/tests/string_test.cpp b/tests/string_test.cpp
index ea1491c..1720058 100644
--- a/tests/string_test.cpp
+++ b/tests/string_test.cpp
@@ -17,24 +17,39 @@
 #include <gtest/gtest.h>
 
 #include <errno.h>
+#include <math.h>
 #include <string.h>
 
+#define KB 1024
+#define SMALL 1*KB
+#define LARGE 64*KB
+
+static int signum(int i) {
+  if (i < 0) {
+    return -1;
+  } else if (i > 0) {
+    return 1;
+  }
+  return 0;
+}
+
 TEST(string, strerror) {
   // Valid.
   ASSERT_STREQ("Success", strerror(0));
   ASSERT_STREQ("Operation not permitted", strerror(1));
 
   // Invalid.
-  ASSERT_STREQ("Unknown error 4294967295", strerror(-1));
+  ASSERT_STREQ("Unknown error -1", strerror(-1));
   ASSERT_STREQ("Unknown error 1234", strerror(1234));
 }
 
-void* ConcurrentStrErrorFn(void* arg) {
+#if __BIONIC__ // glibc's strerror isn't thread safe, only its strsignal.
+
+static void* ConcurrentStrErrorFn(void*) {
   bool equal = (strcmp("Unknown error 2002", strerror(2002)) == 0);
   return reinterpret_cast<void*>(equal);
 }
 
-#if __BIONIC__ // glibc's strerror isn't thread safe, only its strsignal.
 TEST(string, strerror_concurrent) {
   const char* strerror1001 = strerror(1001);
   ASSERT_STREQ("Unknown error 1001", strerror1001);
@@ -47,6 +62,7 @@
 
   ASSERT_STREQ("Unknown error 1001", strerror1001);
 }
+
 #endif
 
 #if __BIONIC__ // glibc's strerror_r doesn't even have the same signature as the POSIX one.
@@ -61,7 +77,7 @@
 
   // Invalid.
   ASSERT_EQ(0, strerror_r(-1, buf, sizeof(buf)));
-  ASSERT_STREQ("Unknown error 4294967295", buf);
+  ASSERT_STREQ("Unknown error -1", buf);
   ASSERT_EQ(0, strerror_r(1234, buf, sizeof(buf)));
   ASSERT_STREQ("Unknown error 1234", buf);
 
@@ -88,7 +104,7 @@
   ASSERT_STREQ("Unknown signal 1234", strsignal(1234)); // Too large.
 }
 
-void* ConcurrentStrSignalFn(void* arg) {
+static void* ConcurrentStrSignalFn(void*) {
   bool equal = (strcmp("Unknown signal 2002", strsignal(2002)) == 0);
   return reinterpret_cast<void*>(equal);
 }
@@ -105,3 +121,578 @@
 
   ASSERT_STREQ("Unknown signal 1001", strsignal1001);
 }
+
+// TODO: where did these numbers come from?
+#define POS_ITER    10
+#define ITER        500
+
+// For every length we want to test, vary and change alignment
+// of allocated memory, fill it with some values, calculate
+// expected result and then run function and compare what we got.
+// These tests contributed by Intel Corporation.
+// TODO: make these tests more intention-revealing and less random.
+struct StringTestState {
+  StringTestState(size_t MAX_LEN) : MAX_LEN(MAX_LEN) {
+    int max_alignment = 64;
+
+    // TODO: fix the tests to not sometimes use twice their specified "MAX_LEN".
+    glob_ptr = reinterpret_cast<char*>(valloc(2 * MAX_LEN + max_alignment));
+    glob_ptr1 = reinterpret_cast<char*>(valloc(2 * MAX_LEN + max_alignment));
+    glob_ptr2 = reinterpret_cast<char*>(valloc(2 * MAX_LEN + max_alignment));
+
+    InitLenArray();
+
+    srandom(1234);
+  }
+
+  ~StringTestState() {
+    free(glob_ptr);
+    free(glob_ptr1);
+    free(glob_ptr2);
+  }
+
+  void NewIteration() {
+    int alignments[] = { 24, 32, 16, 48, 1, 2, 3, 0, 5, 11 };
+    int usable_alignments = 10;
+    int align1 = alignments[random() % (usable_alignments - 1)];
+    int align2 = alignments[random() % (usable_alignments - 1)];
+
+    ptr = glob_ptr + align1;
+    ptr1 = glob_ptr1 + align1;
+    ptr2 = glob_ptr2 + align2;
+  }
+
+  const size_t MAX_LEN;
+  char *ptr, *ptr1, *ptr2;
+  size_t n;
+  int len[ITER + 1];
+
+ private:
+  char *glob_ptr, *glob_ptr1, *glob_ptr2;
+
+  // Calculate input lengths and fill state.len with them.
+  // Test small lengths with more density than big ones. Manually push
+  // smallest (0) and biggest (MAX_LEN) lengths. Avoid repeats.
+  // Return number of lengths to test.
+  void InitLenArray() {
+    n = 0;
+    len[n++] = 0;
+    for (size_t i = 1; i < ITER; ++i) {
+      int l = (int) exp(log((double) MAX_LEN) * i / ITER);
+      if (l != len[n - 1]) {
+        len[n++] = l;
+      }
+    }
+    len[n++] = MAX_LEN;
+  }
+};
+
+TEST(string, strcat) {
+  StringTestState state(SMALL);
+  for (size_t i = 1; i < state.n; i++) {
+    for (size_t j = 0; j < POS_ITER; j++) {
+      state.NewIteration();
+
+      memset(state.ptr2, '\2', state.MAX_LEN);
+      state.ptr2[state.MAX_LEN - 1] = '\0';
+      memcpy(state.ptr, state.ptr2, 2 * state.MAX_LEN);
+
+      memset(state.ptr1, random() & 255, state.len[i]);
+      state.ptr1[random() % state.len[i]] = '\0';
+      state.ptr1[state.len[i] - 1] = '\0';
+
+      strcpy(state.ptr + state.MAX_LEN - 1, state.ptr1);
+
+      EXPECT_TRUE(strcat(state.ptr2, state.ptr1) == state.ptr2);
+      EXPECT_TRUE(memcmp(state.ptr, state.ptr2, 2 * state.MAX_LEN) == 0);
+    }
+  }
+}
+
+TEST(string, strchr) {
+  int seek_char = random() & 255;
+
+  StringTestState state(SMALL);
+  for (size_t i = 1; i < state.n; i++) {
+    for (size_t j = 0; j < POS_ITER; j++) {
+      state.NewIteration();
+
+      if (~seek_char > 0) {
+        memset(state.ptr1, ~seek_char, state.len[i]);
+      } else {
+        memset(state.ptr1, '\1', state.len[i]);
+      }
+      state.ptr1[state.len[i] - 1] = '\0';
+
+      int pos = random() % state.MAX_LEN;
+      char* expected;
+      if (pos >= state.len[i] - 1) {
+        if (seek_char == 0) {
+          expected = state.ptr1 + state.len[i] - 1;
+        } else {
+          expected = NULL;
+        }
+      } else {
+        state.ptr1[pos] = seek_char;
+        expected = state.ptr1 + pos;
+      }
+
+      ASSERT_TRUE(strchr(state.ptr1, seek_char) == expected);
+    }
+  }
+}
+
+TEST(string, strcmp) {
+  StringTestState state(SMALL);
+  for (size_t i = 1; i < state.n; i++) {
+    for (size_t j = 0; j < POS_ITER; j++) {
+      state.NewIteration();
+
+      memset(state.ptr1, 'v', state.MAX_LEN);
+      memset(state.ptr2, 'n', state.MAX_LEN);
+      state.ptr1[state.len[i] - 1] = '\0';
+      state.ptr2[state.len[i] - 1] = '\0';
+
+      int pos = 1 + (random() % (state.MAX_LEN - 1));
+      int actual;
+      int expected;
+      if (pos >= state.len[i] - 1) {
+        memcpy(state.ptr1, state.ptr2, state.len[i]);
+        expected = 0;
+        actual = strcmp(state.ptr1, state.ptr2);
+      } else {
+        memcpy(state.ptr1, state.ptr2, pos);
+        if (state.ptr1[pos] > state.ptr2[pos]) {
+          expected = 1;
+        } else if (state.ptr1[pos] == state.ptr2[pos]) {
+          state.ptr1[pos + 1] = '\0';
+          state.ptr2[pos + 1] = '\0';
+          expected = 0;
+        } else {
+          expected = -1;
+        }
+        actual = strcmp(state.ptr1, state.ptr2);
+      }
+
+      ASSERT_EQ(expected, signum(actual));
+    }
+  }
+}
+
+TEST(string, strcpy) {
+  StringTestState state(SMALL);
+  for (size_t j = 0; j < POS_ITER; j++) {
+    state.NewIteration();
+
+    size_t pos = random() % state.MAX_LEN;
+
+    memset(state.ptr1, '\2', pos);
+    state.ptr1[pos] = '\0';
+    state.ptr1[state.MAX_LEN - 1] = '\0';
+
+    memcpy(state.ptr, state.ptr1, state.MAX_LEN);
+
+    memset(state.ptr2, '\1', state.MAX_LEN);
+    state.ptr2[state.MAX_LEN - 1] = '\0';
+
+    memset(state.ptr + state.MAX_LEN, '\1', state.MAX_LEN);
+    memcpy(state.ptr + state.MAX_LEN, state.ptr1, pos + 1);
+    state.ptr[2 * state.MAX_LEN - 1] = '\0';
+
+    ASSERT_TRUE(strcpy(state.ptr2, state.ptr1) == state.ptr2);
+    ASSERT_FALSE((memcmp(state.ptr1, state.ptr, state.MAX_LEN)) != 0 ||
+                 (memcmp(state.ptr2, state.ptr + state.MAX_LEN, state.MAX_LEN) != 0));
+  }
+}
+
+
+#if __BIONIC__
+// We have to say "DeathTest" here so gtest knows to run this test (which exits)
+// in its own process.
+TEST(string_DeathTest, strcpy_fortified) {
+  ::testing::FLAGS_gtest_death_test_style = "threadsafe";
+  char buf[10];
+  char *orig = strdup("0123456789");
+  ASSERT_EXIT(strcpy(buf, orig), testing::KilledBySignal(SIGSEGV), "");
+  free(orig);
+}
+
+TEST(string_DeathTest, strlen_fortified) {
+  ::testing::FLAGS_gtest_death_test_style = "threadsafe";
+  char buf[10];
+  memcpy(buf, "0123456789", sizeof(buf));
+  ASSERT_EXIT(printf("%d", strlen(buf)), testing::KilledBySignal(SIGSEGV), "");
+}
+
+TEST(string_DeathTest, strchr_fortified) {
+  ::testing::FLAGS_gtest_death_test_style = "threadsafe";
+  char buf[10];
+  memcpy(buf, "0123456789", sizeof(buf));
+  ASSERT_EXIT(printf("%s", strchr(buf, 'a')), testing::KilledBySignal(SIGSEGV), "");
+}
+
+TEST(string_DeathTest, strrchr_fortified) {
+  ::testing::FLAGS_gtest_death_test_style = "threadsafe";
+  char buf[10];
+  memcpy(buf, "0123456789", sizeof(buf));
+  ASSERT_EXIT(printf("%s", strrchr(buf, 'a')), testing::KilledBySignal(SIGSEGV), "");
+}
+#endif
+
+#if __BIONIC__
+TEST(string, strlcat) {
+  StringTestState state(SMALL);
+  for (size_t i = 0; i < state.n; i++) {
+    for (size_t j = 0; j < POS_ITER; j++) {
+      state.NewIteration();
+
+      memset(state.ptr2, '\2', state.MAX_LEN + state.len[i]);
+      state.ptr2[state.MAX_LEN - 1] = '\0';
+      memcpy(state.ptr, state.ptr2, state.MAX_LEN + state.len[i]);
+
+      int pos = random() % state.MAX_LEN;
+      memset(state.ptr1, '\3', pos);
+      state.ptr1[pos] = '\0';
+      if (pos < state.len[i]) {
+        memcpy(state.ptr + state.MAX_LEN - 1, state.ptr1, pos + 1);
+      } else {
+        memcpy(state.ptr + state.MAX_LEN - 1, state.ptr1, state.len[i]);
+        state.ptr[state.MAX_LEN + state.len[i] - 1] = '\0';
+      }
+
+      strlcat(state.ptr2, state.ptr1, state.MAX_LEN + state.len[i]);
+
+      ASSERT_TRUE(memcmp(state.ptr, state.ptr2, state.MAX_LEN + state.len[i]) == 0);
+    }
+  }
+}
+#endif
+
+#if __BIONIC__
+TEST(string, strlcpy) {
+  StringTestState state(SMALL);
+  for (size_t j = 0; j < POS_ITER; j++) {
+    state.NewIteration();
+
+    int rand = random() & 255;
+    if (rand < 1) {
+      rand = 1;
+    }
+    memset(state.ptr1, rand, state.MAX_LEN);
+
+    size_t pos = random() % state.MAX_LEN;
+    if (pos < state.MAX_LEN) {
+      state.ptr1[pos] = '\0';
+    }
+    memcpy(state.ptr, state.ptr1, state.MAX_LEN);
+
+    memset(state.ptr2, random() & 255, state.MAX_LEN);
+    memcpy(state.ptr + state.MAX_LEN, state.ptr2, state.MAX_LEN);
+
+    if (pos > state.MAX_LEN - 1) {
+      memcpy(state.ptr + state.MAX_LEN, state.ptr1, state.MAX_LEN);
+      state.ptr[2 * state.MAX_LEN - 1] = '\0';
+    } else {
+      memcpy(state.ptr + state.MAX_LEN, state.ptr1, pos + 1);
+    }
+
+    ASSERT_EQ(strlcpy(state.ptr2, state.ptr1, state.MAX_LEN), strlen(state.ptr1));
+    ASSERT_FALSE((memcmp(state.ptr1, state.ptr, state.MAX_LEN) != 0) ||
+                 (memcmp(state.ptr2, state.ptr + state.MAX_LEN, state.MAX_LEN) != 0));
+  }
+}
+#endif
+
+TEST(string, strncat) {
+  StringTestState state(SMALL);
+  for (size_t i = 1; i < state.n; i++) {
+    for (size_t j = 0; j < POS_ITER; j++) {
+      state.NewIteration();
+
+      memset(state.ptr2, '\2', state.MAX_LEN);
+      state.ptr2[state.MAX_LEN - 1] = '\0';
+      memcpy(state.ptr, state.ptr2, 2 * state.MAX_LEN);
+
+      memset(state.ptr1, random() & 255, state.len[i]);
+      state.ptr1[random() % state.len[i]] = '\0';
+      state.ptr1[state.len[i] - 1] = '\0';
+
+      size_t pos = strlen(state.ptr1);
+
+      size_t actual = random() % state.len[i];
+      strncpy(state.ptr + state.MAX_LEN - 1, state.ptr1, std::min(actual, pos));
+      state.ptr[state.MAX_LEN + std::min(actual, pos) - 1] = '\0';
+
+      ASSERT_TRUE(strncat(state.ptr2, state.ptr1, actual) == state.ptr2);
+      ASSERT_EQ(memcmp(state.ptr, state.ptr2, 2 * state.MAX_LEN), 0);
+    }
+  }
+}
+
+TEST(string, strncmp) {
+  StringTestState state(SMALL);
+  for (size_t i = 1; i < state.n; i++) {
+    for (size_t j = 0; j < POS_ITER; j++) {
+      state.NewIteration();
+
+      memset(state.ptr1, 'v', state.MAX_LEN);
+      memset(state.ptr2, 'n', state.MAX_LEN);
+      state.ptr1[state.len[i] - 1] = '\0';
+      state.ptr2[state.len[i] - 1] = '\0';
+
+      int pos = 1 + (random() % (state.MAX_LEN - 1));
+      int actual;
+      int expected;
+      if (pos >= state.len[i] - 1) {
+        memcpy(state.ptr1, state.ptr2, state.len[i]);
+        expected = 0;
+        actual = strncmp(state.ptr1, state.ptr2, state.len[i]);
+      } else {
+        memcpy(state.ptr1, state.ptr2, pos);
+        if (state.ptr1[pos] > state.ptr2[pos]) {
+          expected = 1;
+        } else if (state.ptr1[pos] == state.ptr2[pos]) {
+          state.ptr1[pos + 1] = '\0';
+          state.ptr2[pos + 1] = '\0';
+          expected = 0;
+        } else {
+          expected = -1;
+        }
+        actual = strncmp(state.ptr1, state.ptr2, state.len[i]);
+      }
+
+      ASSERT_EQ(expected, signum(actual));
+    }
+  }
+}
+
+TEST(string, strncpy) {
+  StringTestState state(SMALL);
+  for (size_t j = 0; j < ITER; j++) {
+    state.NewIteration();
+
+    memset(state.ptr1, random() & 255, state.MAX_LEN);
+    state.ptr1[random () % state.MAX_LEN] = '\0';
+    memcpy(state.ptr, state.ptr1, state.MAX_LEN);
+
+    memset(state.ptr2, '\1', state.MAX_LEN);
+
+    size_t pos;
+    if (memchr(state.ptr1, 0, state.MAX_LEN)) {
+      pos = strlen(state.ptr1);
+    } else {
+      pos = state.MAX_LEN - 1;
+    }
+
+    memset(state.ptr + state.MAX_LEN, '\0', state.MAX_LEN);
+    memcpy(state.ptr + state.MAX_LEN, state.ptr1, pos + 1);
+
+    ASSERT_TRUE(strncpy(state.ptr2, state.ptr1, state.MAX_LEN) == state.ptr2);
+    ASSERT_FALSE(memcmp(state.ptr1, state.ptr, state.MAX_LEN) != 0 ||
+                 memcmp(state.ptr2, state.ptr + state.MAX_LEN, state.MAX_LEN) != 0);
+  }
+}
+
+TEST(string, strrchr) {
+  int seek_char = random() & 255;
+  StringTestState state(SMALL);
+  for (size_t i = 1; i < state.n; i++) {
+    for (size_t j = 0; j < POS_ITER; j++) {
+      state.NewIteration();
+
+      if (~seek_char > 0) {
+        memset(state.ptr1, ~seek_char, state.len[i]);
+      } else {
+        memset(state.ptr1, '\1', state.len[i]);
+      }
+      state.ptr1[state.len[i] - 1] = '\0';
+
+      int pos = random() % state.MAX_LEN;
+      char* expected;
+      if (pos >= state.len[i] - 1) {
+        if (seek_char == 0) {
+          expected = state.ptr1 + state.len[i] - 1;
+        } else {
+          expected = NULL;
+        }
+      } else {
+        state.ptr1[pos] = seek_char;
+        expected = state.ptr1 + pos;
+      }
+
+      ASSERT_TRUE(strrchr(state.ptr1, seek_char) == expected);
+    }
+  }
+}
+
+TEST(string, memchr) {
+  int seek_char = random() & 255;
+  StringTestState state(SMALL);
+  for (size_t i = 0; i < state.n; i++) {
+    for (size_t j = 0; j < POS_ITER; j++) {
+      state.NewIteration();
+
+      memset(state.ptr1, ~seek_char, state.len[i]);
+
+      int pos = random() % state.MAX_LEN;
+      char* expected;
+      if (pos >= state.len[i]) {
+        expected = NULL;
+      } else {
+        state.ptr1[pos] = seek_char;
+        expected = state.ptr1 + pos;
+      }
+
+      ASSERT_TRUE(memchr(state.ptr1, seek_char, state.len[i]) == expected);
+    }
+  }
+}
+
+TEST(string, memrchr) {
+  int seek_char = random() & 255;
+  StringTestState state(SMALL);
+  for (size_t i = 0; i < state.n; i++) {
+    for (size_t j = 0; j < POS_ITER; j++) {
+      state.NewIteration();
+
+      memset(state.ptr1, ~seek_char, state.len[i]);
+
+      int pos = random() % state.MAX_LEN;
+      char* expected;
+      if (pos >= state.len[i]) {
+        expected = NULL;
+      } else {
+        state.ptr1[pos] = seek_char;
+        expected = state.ptr1 + pos;
+      }
+
+      ASSERT_TRUE(memrchr(state.ptr1, seek_char, state.len[i]) == expected);
+    }
+  }
+}
+
+TEST(string, memcmp) {
+  StringTestState state(SMALL);
+  for (size_t i = 0; i < state.n; i++) {
+    for (size_t j = 0; j < POS_ITER; j++) {
+      state.NewIteration();
+
+      int c1 = random() & 0xff;
+      int c2 = random() & 0xff;
+      memset(state.ptr1, c1, state.MAX_LEN);
+      memset(state.ptr2, c1, state.MAX_LEN);
+
+      int pos = (state.len[i] == 0) ? 0 : (random() % state.len[i]);
+      state.ptr2[pos] = c2;
+
+      int expected = (static_cast<int>(c1) - static_cast<int>(c2));
+      int actual = memcmp(state.ptr1, state.ptr2, state.MAX_LEN);
+
+      ASSERT_EQ(signum(expected), signum(actual));
+    }
+  }
+}
+
+TEST(string, memcpy) {
+  StringTestState state(LARGE);
+  int rand = random() & 255;
+  for (size_t i = 0; i < state.n - 1; i++) {
+    for (size_t j = 0; j < POS_ITER; j++) {
+      state.NewIteration();
+
+      size_t pos = random() % (state.MAX_LEN - state.len[i]);
+
+      memset(state.ptr1, rand, state.len[i]);
+      memset(state.ptr1 + state.len[i], ~rand, state.MAX_LEN - state.len[i]);
+
+      memset(state.ptr2, rand, state.len[i]);
+      memset(state.ptr2 + state.len[i], ~rand, state.MAX_LEN - state.len[i]);
+      memset(state.ptr2 + pos, '\0', state.len[i]);
+
+      ASSERT_FALSE(memcpy(state.ptr2 + pos, state.ptr1 + pos, state.len[i]) != state.ptr2 + pos);
+      ASSERT_EQ(0, memcmp(state.ptr1, state.ptr2, state.MAX_LEN));
+    }
+  }
+}
+
+TEST(string, memset) {
+  StringTestState state(LARGE);
+  char ch = random () & 255;
+  for (size_t i = 0; i < state.n - 1; i++) {
+    for (size_t j = 0; j < POS_ITER; j++) {
+      state.NewIteration();
+
+      memset(state.ptr1, ~ch, state.MAX_LEN);
+      memcpy(state.ptr2, state.ptr1, state.MAX_LEN);
+
+      size_t pos = random () % (state.MAX_LEN - state.len[i]);
+      for (size_t k = pos; k < pos + state.len[i]; k++) {
+        state.ptr1[k] = ch;
+      }
+
+      ASSERT_TRUE(memset(state.ptr2 + pos, ch, state.len[i]) == state.ptr2 + pos);
+
+      ASSERT_EQ(0, memcmp(state.ptr1, state.ptr2, state.MAX_LEN));
+    }
+  }
+}
+
+TEST(string, memmove) {
+  StringTestState state(LARGE);
+  for (size_t i = 0; i < state.n - 1; i++) {
+    for (size_t j = 0; j < POS_ITER; j++) {
+      state.NewIteration();
+
+      memset(state.ptr1, random() & 255, 2 * state.MAX_LEN);
+
+      size_t pos = random() % (state.MAX_LEN - state.len[i]);
+
+      memset(state.ptr1, random() & 255, state.len[i]);
+      memcpy(state.ptr2, state.ptr1, 2 * state.MAX_LEN);
+      memcpy(state.ptr, state.ptr1, state.len[i]);
+      memcpy(state.ptr1 + pos, state.ptr, state.len[i]);
+
+      ASSERT_TRUE(memmove(state.ptr2 + pos, state.ptr2, state.len[i]) == state.ptr2 + pos);
+      ASSERT_EQ(0, memcmp(state.ptr2, state.ptr1, 2 * state.MAX_LEN));
+    }
+  }
+}
+
+TEST(string, bcopy) {
+  StringTestState state(LARGE);
+  for (size_t i = 0; i < state.n; i++) {
+    for (size_t j = 0; j < POS_ITER; j++) {
+      state.NewIteration();
+
+      memset(state.ptr1, random() & 255, state.MAX_LEN);
+      memset(state.ptr1 + state.MAX_LEN, random() & 255, state.MAX_LEN);
+      memcpy(state.ptr2, state.ptr1, 2 * state.MAX_LEN);
+
+      size_t start = random() % (2 * state.MAX_LEN - state.len[i]);
+      memcpy(state.ptr2 + start, state.ptr1, state.len[i]);
+
+      bcopy(state.ptr1, state.ptr1 + start, state.len[i]);
+      ASSERT_EQ(0, memcmp(state.ptr1, state.ptr2, 2 * state.MAX_LEN));
+    }
+  }
+}
+
+TEST(string, bzero) {
+  StringTestState state(LARGE);
+  for (size_t j = 0; j < ITER; j++) {
+    state.NewIteration();
+
+    memset(state.ptr1, random() & 255, state.MAX_LEN);
+
+    size_t start = random() % state.MAX_LEN;
+    size_t end = start + random() % (state.MAX_LEN - start);
+
+    memcpy(state.ptr2, state.ptr1, start);
+    memset(state.ptr2 + start, '\0', end - start);
+    memcpy(state.ptr2 + end, state.ptr1 + end, state.MAX_LEN - end);
+
+    bzero(state.ptr1 + start, end - start);
+
+    ASSERT_EQ(0, memcmp(state.ptr1, state.ptr2, state.MAX_LEN));
+  }
+}
diff --git a/tests/strings_test.cpp b/tests/strings_test.cpp
new file mode 100644
index 0000000..5200859
--- /dev/null
+++ b/tests/strings_test.cpp
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+#include <errno.h>
+#include <strings.h>
+
+TEST(strings, ffs) {
+  ASSERT_EQ( 0, ffs(0x00000000));
+  ASSERT_EQ( 1, ffs(0x00000001));
+  ASSERT_EQ( 6, ffs(0x00000020));
+  ASSERT_EQ(11, ffs(0x00000400));
+  ASSERT_EQ(16, ffs(0x00008000));
+  ASSERT_EQ(17, ffs(0x00010000));
+  ASSERT_EQ(22, ffs(0x00200000));
+  ASSERT_EQ(27, ffs(0x04000000));
+  ASSERT_EQ(32, ffs(0x80000000));
+}
diff --git a/tests/stubs_test.cpp b/tests/stubs_test.cpp
index d2d0ad8..2e1acc1 100644
--- a/tests/stubs_test.cpp
+++ b/tests/stubs_test.cpp
@@ -34,11 +34,11 @@
   TYPE_APP
 } uid_type_t;
 
-static void check_getpwnam(const char* username, int uid, uid_type_t uid_type) {
+static void check_getpwnam(const char* username, uid_t uid, uid_type_t uid_type) {
   errno = 0;
   passwd* pwd = getpwuid(uid);
   ASSERT_TRUE(pwd != NULL);
-  ASSERT_EQ(errno, 0);
+  ASSERT_EQ(0, errno);
   EXPECT_STREQ(username, pwd->pw_name);
   EXPECT_EQ(uid, pwd->pw_uid);
   EXPECT_EQ(uid, pwd->pw_gid);
diff --git a/tests/unistd_test.cpp b/tests/unistd_test.cpp
new file mode 100644
index 0000000..3ccaf3b
--- /dev/null
+++ b/tests/unistd_test.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+#include <stdint.h>
+#include <unistd.h>
+
+TEST(unistd, sysconf_SC_MONOTONIC_CLOCK) {
+  ASSERT_GT(sysconf(_SC_MONOTONIC_CLOCK), 0);
+}
+
+TEST(unistd, sbrk) {
+  void* initial_break = sbrk(0);
+
+  void* new_break = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(initial_break) + 2000);
+  ASSERT_EQ(0, brk(new_break));
+
+  void* final_break = sbrk(0);
+  ASSERT_EQ(final_break, new_break);
+}