Merge "Remove the non-uapi kernel headers."
diff --git a/libc/arch-aarch64/aarch64.mk b/libc/arch-aarch64/aarch64.mk
index 847db98..643cf69 100644
--- a/libc/arch-aarch64/aarch64.mk
+++ b/libc/arch-aarch64/aarch64.mk
@@ -12,3 +12,8 @@
     arch-aarch64/bionic/sigsetjmp.S \
     arch-aarch64/bionic/syscall.S \
     arch-aarch64/bionic/vfork.S \
+
+_LIBC_ARCH_STATIC_SRC_FILES := \
+    bionic/dl_iterate_phdr_static.c \
+
+_LIBC_ARCH_DYNAMIC_SRC_FILES :=
diff --git a/libc/arch-aarch64/include/machine/kernel.h b/libc/arch-aarch64/include/machine/kernel.h
deleted file mode 100644
index 070e704..0000000
--- a/libc/arch-aarch64/include/machine/kernel.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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 _ARCH_AARCH64_KERNEL_H
-#define _ARCH_AARCH64_KERNEL_H
-
-/* this file contains kernel-specific definitions that were optimized out of
-   our processed kernel headers, but still useful nonetheless... */
-
-typedef unsigned long   __kernel_blkcnt_t;
-typedef unsigned long   __kernel_blksize_t;
-
-/* these aren't really defined by the kernel headers though... */
-typedef unsigned long   __kernel_fsblkcnt_t;
-typedef unsigned long   __kernel_fsfilcnt_t;
-typedef unsigned int    __kernel_id_t;
-
-#endif /* _ARCH_ARM_KERNEL_H */
-
diff --git a/libc/arch-arm/include/machine/kernel.h b/libc/arch-arm/include/machine/kernel.h
deleted file mode 100644
index 462b8e3..0000000
--- a/libc/arch-arm/include/machine/kernel.h
+++ /dev/null
@@ -1,42 +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.
- */
-#ifndef _ARCH_ARM_KERNEL_H
-#define _ARCH_ARM_KERNEL_H
-
-/* this file contains kernel-specific definitions that were optimized out of
-   our processed kernel headers, but still useful nonetheless... */
-
-typedef unsigned long   __kernel_blkcnt_t;
-typedef unsigned long   __kernel_blksize_t;
-
-/* these aren't really defined by the kernel headers though... */
-typedef unsigned long   __kernel_fsblkcnt_t;
-typedef unsigned long   __kernel_fsfilcnt_t;
-typedef unsigned int    __kernel_id_t;
-
-#endif /* _ARCH_ARM_KERNEL_H */
diff --git a/libc/arch-mips/include/machine/kernel.h b/libc/arch-mips/include/machine/kernel.h
deleted file mode 100644
index 69ad40c..0000000
--- a/libc/arch-mips/include/machine/kernel.h
+++ /dev/null
@@ -1,42 +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.
- */
-#ifndef _ARCH_MIPS_KERNEL_H
-#define _ARCH_MIPS_KERNEL_H
-
-/* this file contains kernel-specific definitions that were optimized out of
-   our processed kernel headers, but still useful nonetheless... */
-
-typedef unsigned long   __kernel_blkcnt_t;
-typedef unsigned long   __kernel_blksize_t;
-
-/* these aren't really defined by the kernel headers though... */
-typedef unsigned long   __kernel_fsblkcnt_t;
-typedef unsigned long   __kernel_fsfilcnt_t;
-typedef unsigned int    __kernel_id_t;
-
-#endif /* _ARCH_MIPS_KERNEL_H */
diff --git a/libc/arch-x86/include/machine/kernel.h b/libc/arch-x86/include/machine/kernel.h
deleted file mode 100644
index d5df7a01..0000000
--- a/libc/arch-x86/include/machine/kernel.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-** Copyright 2006-2008, 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.
-*/
-#ifndef _ARCH_X86_KERNEL_H
-#define _ARCH_X86_KERNEL_H
-
-/* this file contains kernel-specific definitions that were optimized out of
-   our processed kernel headers, but still useful nonetheless... */
-
-typedef unsigned long   __kernel_blkcnt_t;
-typedef unsigned long   __kernel_blksize_t;
-
-/* these aren't really defined by the kernel headers though... */
-typedef unsigned long   __kernel_fsblkcnt_t;
-typedef unsigned long   __kernel_fsfilcnt_t;
-typedef unsigned int    __kernel_id_t;
-
-#endif /* _ARCH_X86_KERNEL_H */
diff --git a/libc/arch-x86_64/include/machine/_types.h b/libc/arch-x86_64/include/machine/_types.h
index bf4b957..234e652 100644
--- a/libc/arch-x86_64/include/machine/_types.h
+++ b/libc/arch-x86_64/include/machine/_types.h
@@ -62,10 +62,8 @@
 typedef	unsigned short		__uint16_t;
 typedef	int			__int32_t;
 typedef	unsigned int		__uint32_t;
-/* LONGLONG */
-typedef	long long		__int64_t;
-/* LONGLONG */
-typedef	unsigned long long	__uint64_t;
+typedef	long                    __int64_t;
+typedef	unsigned long           __uint64_t;
 
 /* 7.18.1.2 Minimum-width integer types */
 typedef	__int8_t		__int_least8_t;
diff --git a/libc/arch-x86_64/include/machine/kernel.h b/libc/arch-x86_64/include/machine/kernel.h
deleted file mode 100644
index 8fc9d6c..0000000
--- a/libc/arch-x86_64/include/machine/kernel.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-** Copyright 2006-2008, 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.
-*/
-
-#ifndef _ARCH_X86_64_KERNEL_H
-#define _ARCH_X86_64_KERNEL_H
-
-/* this file contains kernel-specific definitions that were optimized out of
-   our processed kernel headers, but still useful nonetheless... */
-
-typedef __kernel_ulong_t __kernel_blkcnt_t;
-typedef __kernel_ulong_t __kernel_blksize_t;
-
-/* these aren't really defined by the kernel headers though... */
-typedef __kernel_ulong_t __kernel_fsblkcnt_t;
-typedef __kernel_ulong_t __kernel_fsfilcnt_t;
-typedef unsigned int __kernel_id_t;
-
-#endif /* _ARCH_X86_64_KERNEL_H */
diff --git a/libc/bionic/__fgets_chk.cpp b/libc/bionic/__fgets_chk.cpp
index 61dad70..c09f6c5 100644
--- a/libc/bionic/__fgets_chk.cpp
+++ b/libc/bionic/__fgets_chk.cpp
@@ -26,6 +26,8 @@
  * SUCH DAMAGE.
  */
 
+#undef _FORTIFY_SOURCE
+
 #include <stdio.h>
 #include <stdlib.h>
 #include "private/libc_logging.h"
diff --git a/libc/bionic/__memmove_chk.cpp b/libc/bionic/__memmove_chk.cpp
index 26bd646..b88a94f 100644
--- a/libc/bionic/__memmove_chk.cpp
+++ b/libc/bionic/__memmove_chk.cpp
@@ -26,6 +26,8 @@
  * SUCH DAMAGE.
  */
 
+#undef _FORTIFY_SOURCE
+
 #include <string.h>
 #include <stdlib.h>
 #include "private/libc_logging.h"
diff --git a/libc/bionic/__memset_chk.cpp b/libc/bionic/__memset_chk.cpp
index 9a3be19..5f20452 100644
--- a/libc/bionic/__memset_chk.cpp
+++ b/libc/bionic/__memset_chk.cpp
@@ -26,6 +26,8 @@
  * SUCH DAMAGE.
  */
 
+#undef _FORTIFY_SOURCE
+
 #include <string.h>
 #include <stdlib.h>
 #include "private/libc_logging.h"
diff --git a/libc/bionic/__strlcat_chk.cpp b/libc/bionic/__strlcat_chk.cpp
index f583154..2b7373b 100644
--- a/libc/bionic/__strlcat_chk.cpp
+++ b/libc/bionic/__strlcat_chk.cpp
@@ -26,6 +26,8 @@
  * SUCH DAMAGE.
  */
 
+#undef _FORTIFY_SOURCE
+
 #include <string.h>
 #include <stdlib.h>
 #include "private/libc_logging.h"
diff --git a/libc/bionic/__strlcpy_chk.cpp b/libc/bionic/__strlcpy_chk.cpp
index ebf1444..6b21879 100644
--- a/libc/bionic/__strlcpy_chk.cpp
+++ b/libc/bionic/__strlcpy_chk.cpp
@@ -26,6 +26,8 @@
  * SUCH DAMAGE.
  */
 
+#undef _FORTIFY_SOURCE
+
 #include <string.h>
 #include <stdlib.h>
 #include "private/libc_logging.h"
diff --git a/libc/bionic/__strlen_chk.cpp b/libc/bionic/__strlen_chk.cpp
index 6621a6a..a67e15e 100644
--- a/libc/bionic/__strlen_chk.cpp
+++ b/libc/bionic/__strlen_chk.cpp
@@ -26,6 +26,8 @@
  * SUCH DAMAGE.
  */
 
+#undef _FORTIFY_SOURCE
+
 #include <string.h>
 #include <stdlib.h>
 #include "private/libc_logging.h"
diff --git a/libc/bionic/__strncpy_chk.cpp b/libc/bionic/__strncpy_chk.cpp
index 76458aa..9625929 100644
--- a/libc/bionic/__strncpy_chk.cpp
+++ b/libc/bionic/__strncpy_chk.cpp
@@ -26,6 +26,8 @@
  * SUCH DAMAGE.
  */
 
+#undef _FORTIFY_SOURCE
+
 #include <string.h>
 #include <stdlib.h>
 #include "private/libc_logging.h"
diff --git a/libc/bionic/__vsnprintf_chk.cpp b/libc/bionic/__vsnprintf_chk.cpp
index 8550224..8c09111 100644
--- a/libc/bionic/__vsnprintf_chk.cpp
+++ b/libc/bionic/__vsnprintf_chk.cpp
@@ -26,6 +26,8 @@
  * SUCH DAMAGE.
  */
 
+#undef _FORTIFY_SOURCE
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
diff --git a/libc/bionic/__vsprintf_chk.cpp b/libc/bionic/__vsprintf_chk.cpp
index bd2aeab..5914026 100644
--- a/libc/bionic/__vsprintf_chk.cpp
+++ b/libc/bionic/__vsprintf_chk.cpp
@@ -26,6 +26,8 @@
  * SUCH DAMAGE.
  */
 
+#undef _FORTIFY_SOURCE
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
diff --git a/libc/include/sys/types.h b/libc/include/sys/types.h
index 978393c..e0b6550 100644
--- a/libc/include/sys/types.h
+++ b/libc/include/sys/types.h
@@ -32,44 +32,44 @@
 #include <stdint.h>
 #include <sys/cdefs.h>
 
-#include <linux/posix_types.h>
-#include <asm/types.h>
 #include <linux/types.h>
-#include <machine/kernel.h>
+#include <linux/posix_types.h>
 
-typedef __u32    __kernel_dev_t;
-
-/* be careful with __kernel_gid_t and __kernel_uid_t
- * these are defined as 16-bit for legacy reason, but
- * the kernel uses 32-bits instead.
- *
- * 32-bit values are required for Android, so use
- * __kernel_uid32_t and __kernel_gid32_t
+/* __kernel_gid_t and __kernel_uid_t are 16 bit for legacy reasons.
+ * Android uses __kernel_uid32_t and __kernel_gid32_t instead.
  */
+typedef __kernel_gid32_t gid_t;
+typedef __kernel_uid32_t uid_t;
 
-typedef __kernel_blkcnt_t    blkcnt_t;
-typedef __kernel_blksize_t   blksize_t;
-typedef __kernel_clock_t     clock_t;
-typedef __kernel_clockid_t   clockid_t;
-typedef __kernel_dev_t       dev_t;
-typedef __kernel_fsblkcnt_t  fsblkcnt_t;
-typedef __kernel_fsfilcnt_t  fsfilcnt_t;
-typedef __kernel_gid32_t     gid_t;
-typedef __kernel_uid32_t     uid_t;
-typedef __kernel_id_t        id_t;
-typedef __kernel_ino_t       ino_t;
-typedef __kernel_key_t       key_t;
-typedef __kernel_mode_t      mode_t;
+typedef unsigned long blkcnt_t;
+typedef unsigned long blksize_t;
+typedef __kernel_caddr_t caddr_t;
+typedef __kernel_clock_t clock_t;
+typedef __kernel_clockid_t clockid_t;
+typedef __kernel_daddr_t daddr_t;
+typedef uint32_t dev_t;
+typedef unsigned long fsblkcnt_t;
+typedef unsigned long fsfilcnt_t;
+typedef uint32_t id_t;
+typedef __kernel_ino_t ino_t;
+typedef __kernel_key_t key_t;
+typedef __kernel_mode_t mode_t;
+typedef __nlink_t nlink_t;
+typedef __kernel_pid_t pid_t;
+typedef __kernel_suseconds_t suseconds_t;
+typedef __kernel_timer_t timer_t;
+typedef unsigned int useconds_t;
+
+/* This historical accident means that we had a 32-bit time_t on 32-bit architectures. */
+typedef __kernel_time_t time_t;
+
+/* This historical accident means that we had a 32-bit off_t on 32-bit architectures. */
 #ifndef _OFF_T_DEFINED_
 #define _OFF_T_DEFINED_
-typedef __kernel_off_t       off_t;
+typedef __kernel_off_t off_t;
 #endif
-typedef __kernel_loff_t      loff_t;
-typedef loff_t               off64_t;
-
-typedef __kernel_pid_t		 pid_t;
-
-typedef __nlink_t nlink_t;
+typedef __kernel_loff_t loff_t;
+typedef loff_t off64_t;
 
 /* while POSIX wants these in <sys/types.h>, we
  * declare then in <pthread.h> instead */
@@ -95,16 +95,6 @@
 typedef __kernel_ssize_t ssize_t;
 #endif
 
-typedef __kernel_time_t time_t;
-
-typedef __kernel_suseconds_t suseconds_t;
-typedef unsigned int useconds_t;
-
-typedef __kernel_daddr_t	daddr_t;
-typedef __kernel_timer_t	timer_t;
-typedef __kernel_mqd_t		mqd_t;
-
-typedef __kernel_caddr_t    caddr_t;
 typedef unsigned int        uint_t;
 typedef unsigned int        uint;
 
diff --git a/libm/fake_long_double.c b/libm/fake_long_double.c
index fab32fe..2a3e420 100644
--- a/libm/fake_long_double.c
+++ b/libm/fake_long_double.c
@@ -20,6 +20,8 @@
 extern int __isinf(double); /* isinf.c */
 int (isinf)(double a1) { return __isinf(a1); }
 
+int (isnanf)(float a1) { return __isnanf(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
@@ -34,20 +36,32 @@
 int __signbitl(long double a1) { return __signbit(a1); }
 
 long double acoshl(long double a1) { return acosh(a1); }
+long double acosl(long double a1) { return acos(a1); }
 long double asinhl(long double a1) { return asinh(a1); }
+long double asinl(long double a1) { return asin(a1); }
+long double atan2l(long double a1, long double a2) { return atan2(a1, a2); }
 long double atanhl(long double a1) { return atanh(a1); }
+long double atanl(long double a1) { return atan(a1); }
 long double cbrtl(long double a1) { return cbrt(a1); }
+long double ceill(long double a1) { return ceil(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 exp2l(long double a1) { return exp2(a1); }
+long double expl(long double a1) { return exp(a1); }
 long double expm1l(long double a1) { return expm1(a1); }
 long double fabsl(long double a1) { return fabs(a1); }
+long double floorl(long double a1) { return floor(a1); }
+long double fmal(long double a1, long double a2, long double a3) { return fma(a1, a2, a3); }
 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); }
+long double frexpl(long double a1, int* a2) { return frexp(a1, a2); }
+long double hypotl(long double a1, long double a2) { return hypot(a1, a2); }
 int ilogbl(long double a1) { return ilogb(a1); }
+long double ldexpl(long double a1, int a2) { return ldexp(a1, a2); }
 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); }
@@ -59,7 +73,11 @@
 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 nanl(const char* a1) { return nan(a1); }
+long double nextafterl(long double a1, long double a2) { return nextafter(a1, a2); }
 long double powl(long double a1, long double a2) { return pow(a1, a2); }
+long double remainderl(long double a1, long double a2) { return remainder(a1, a2); }
+long double remquol(long double a1, long double a2, int* a3) { return remquo(a1, a2, a3); }
 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); }
@@ -70,3 +88,4 @@
 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); }
+long double truncl(long double a1) { return trunc(a1); }
diff --git a/libm/freebsd-compat.h b/libm/freebsd-compat.h
index ca5b42c..4b14fae 100644
--- a/libm/freebsd-compat.h
+++ b/libm/freebsd-compat.h
@@ -18,8 +18,7 @@
 #define _BIONIC_LIBM_FREEBSD_COMPAT_H_included
 
 #define __weak_reference(sym,alias) \
-    __asm__(".weak " #alias); \
-    __asm__(".equ "  #alias ", " #sym)
+    /* We don't use __weak_reference; see "fake_long_double.c". */
 
 #define __strong_reference(sym,aliassym) \
     extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))