From 995b813e91a5eb67a970b9f076911873bdf5dbc4 Mon Sep 17 00:00:00 2001
From: Christopher Ferris <cferris@google.com>
Date: Fri, 13 Mar 2015 17:43:52 -0700
Subject: [PATCH] For libm, use a macro for aliasing symbols.

Change-Id: Ibd42ebc387c2bf3eba9aa96091770915b4b34184
---
 libc/private/bionic_asm.h | 4 ++++
 libm/arm/e_sqrt.S         | 5 +----
 libm/arm/s_floor.S        | 5 +----
 libm/arm64/lrint.S        | 6 ++----
 libm/x86/ceil.S           | 3 +--
 libm/x86/e_acos.S         | 3 +--
 libm/x86/e_asin.S         | 3 +--
 libm/x86/e_atan2.S        | 3 +--
 libm/x86/e_cosh.S         | 3 +--
 libm/x86/e_exp.S          | 3 +--
 libm/x86/e_hypot.S        | 3 +--
 libm/x86/e_log.S          | 3 +--
 libm/x86/e_log10.S        | 3 +--
 libm/x86/e_sinh.S         | 3 +--
 libm/x86/floor.S          | 3 +--
 libm/x86/s_atan.S         | 3 +--
 libm/x86/s_cbrt.S         | 3 +--
 libm/x86/s_cos.S          | 3 +--
 libm/x86/s_expm1.S        | 3 +--
 libm/x86/s_log1p.S        | 3 +--
 libm/x86/s_sin.S          | 3 +--
 libm/x86/s_tan.S          | 3 +--
 libm/x86/s_tanh.S         | 3 +--
 libm/x86/sqrt.S           | 3 +--
 libm/x86/trunc.S          | 3 +--
 25 files changed, 29 insertions(+), 54 deletions(-)

diff --git a/libc/private/bionic_asm.h b/libc/private/bionic_asm.h
index d53ebbae1..5fca222c4 100644
--- a/libc/private/bionic_asm.h
+++ b/libc/private/bionic_asm.h
@@ -57,4 +57,8 @@
     ENTRY(f); \
     .hidden f \
 
+#define ALIAS_SYMBOL(alias, original) \
+    .globl alias; \
+    .equ alias, original
+
 #endif /* _PRIVATE_BIONIC_ASM_H_ */
diff --git a/libm/arm/e_sqrt.S b/libm/arm/e_sqrt.S
index 669212f58..17312f50f 100644
--- a/libm/arm/e_sqrt.S
+++ b/libm/arm/e_sqrt.S
@@ -39,7 +39,4 @@ ENTRY(sqrt)
     bx          lr
 END(sqrt)
 
-#if LDBL_MANT_DIG == 53
-    .weak       sqrtl
-    .equ        sqrtl, sqrt
-#endif
+ALIAS_SYMBOL(sqrtl, sqrt);
diff --git a/libm/arm/s_floor.S b/libm/arm/s_floor.S
index 44053581e..3af8f7624 100644
--- a/libm/arm/s_floor.S
+++ b/libm/arm/s_floor.S
@@ -136,7 +136,4 @@ ENTRY(floor)    /* x in r0, r1 */
 
 END(floor)
 
-#if LDBL_MANT_DIG == 53
-        .weak           floorl
-        .equ            floorl,floor
-#endif
+ALIAS_SYMBOL(floorl, floor);
diff --git a/libm/arm64/lrint.S b/libm/arm64/lrint.S
index 69cc10c3e..d6427598c 100644
--- a/libm/arm64/lrint.S
+++ b/libm/arm64/lrint.S
@@ -29,8 +29,6 @@ ENTRY(lrintf)
 END(lrintf)
 
 // sizeof(long) and sizeof(long long) are the same for aarch64
-.weak llrint
-.equ llrint,lrint
+ALIAS_SYMBOL(llrint, lrint);
 
-.weak llrintf
-.equ llrintf,lrintf
+ALIAS_SYMBOL(llrintf, lrintf);
diff --git a/libm/x86/ceil.S b/libm/x86/ceil.S
index b992057cc..63020378d 100644
--- a/libm/x86/ceil.S
+++ b/libm/x86/ceil.S
@@ -40,5 +40,4 @@ ENTRY(ceil)
 	ret
 END(ceil)
 
-.globl ceill;
-.equ ceill, ceil;
+ALIAS_SYMBOL(ceill, ceil);
diff --git a/libm/x86/e_acos.S b/libm/x86/e_acos.S
index a42948185..fa6185314 100644
--- a/libm/x86/e_acos.S
+++ b/libm/x86/e_acos.S
@@ -388,8 +388,7 @@ END(acos)
 # -- End  acos
 
 # Start file scope ASM
-.weak acosl
-.equ acosl, acos
+ALIAS_SYMBOL(acosl, acos);
 # End file scope ASM
 	.section .rodata, "a"
 	.align 16
diff --git a/libm/x86/e_asin.S b/libm/x86/e_asin.S
index 99dfb68d3..5d7f33179 100644
--- a/libm/x86/e_asin.S
+++ b/libm/x86/e_asin.S
@@ -466,8 +466,7 @@ END(asin)
 # -- End  asin
 
 # Start file scope ASM
-.weak asinl
-.equ asinl, asin
+ALIAS_SYMBOL(asinl, asin);
 # End file scope ASM
 	.section .rodata, "a"
 	.align 16
diff --git a/libm/x86/e_atan2.S b/libm/x86/e_atan2.S
index a6ad390e0..1efdf6582 100644
--- a/libm/x86/e_atan2.S
+++ b/libm/x86/e_atan2.S
@@ -452,8 +452,7 @@ END(atan2)
 # -- End  atan2
 
 # Start file scope ASM
-.weak atan2l
-.equ atan2l, atan2
+ALIAS_SYMBOL(atan2l, atan2);
 # End file scope ASM
 	.section .rodata, "a"
 	.align 16
diff --git a/libm/x86/e_cosh.S b/libm/x86/e_cosh.S
index 694202870..ecea8f478 100644
--- a/libm/x86/e_cosh.S
+++ b/libm/x86/e_cosh.S
@@ -272,8 +272,7 @@ END(cosh)
 # -- End  cosh
 
 # Start file scope ASM
-.weak coshl
-.equ coshl, cosh
+ALIAS_SYMBOL(coshl, cosh);
 # End file scope ASM
 	.section .rodata, "a"
 	.align 16
diff --git a/libm/x86/e_exp.S b/libm/x86/e_exp.S
index c4fbe4744..eab619d85 100644
--- a/libm/x86/e_exp.S
+++ b/libm/x86/e_exp.S
@@ -257,8 +257,7 @@ END(exp)
 # -- End  exp
 
 # Start file scope ASM
-.weak expl
-.equ expl, exp
+ALIAS_SYMBOL(expl, exp);
 # End file scope ASM
 	.section .rodata, "a"
 	.align 16
diff --git a/libm/x86/e_hypot.S b/libm/x86/e_hypot.S
index aa6ab64b8..6a143e50b 100644
--- a/libm/x86/e_hypot.S
+++ b/libm/x86/e_hypot.S
@@ -199,8 +199,7 @@ END(hypot)
 # -- End  hypot
 
 # Start file scope ASM
-.weak hypotl
-.equ hypotl, hypot
+ALIAS_SYMBOL(hypotl, hypot);
 # End file scope ASM
 	.section .rodata, "a"
 	.align 16
diff --git a/libm/x86/e_log.S b/libm/x86/e_log.S
index b5df1eaa3..a6181cac0 100644
--- a/libm/x86/e_log.S
+++ b/libm/x86/e_log.S
@@ -231,8 +231,7 @@ END(log)
 # -- End  log
 
 # Start file scope ASM
-.weak logl
-.equ logl, log
+ALIAS_SYMBOL(logl, log);
 # End file scope ASM
 	.section .rodata, "a"
 	.align 16
diff --git a/libm/x86/e_log10.S b/libm/x86/e_log10.S
index d34829cd4..09b295211 100644
--- a/libm/x86/e_log10.S
+++ b/libm/x86/e_log10.S
@@ -242,8 +242,7 @@ END(log10)
 # -- End  log10
 
 # Start file scope ASM
-.weak log10l
-.equ log10l, log10
+ALIAS_SYMBOL(log10l, log10);
 # End file scope ASM
 	.section .rodata, "a"
 	.align 16
diff --git a/libm/x86/e_sinh.S b/libm/x86/e_sinh.S
index 9d28a317b..d6b04b57d 100644
--- a/libm/x86/e_sinh.S
+++ b/libm/x86/e_sinh.S
@@ -324,8 +324,7 @@ END(sinh)
 # -- End  sinh
 
 # Start file scope ASM
-.weak sinhl
-.equ sinhl, sinh
+ALIAS_SYMBOL(sinhl, sinh);
 # End file scope ASM
 	.section .rodata, "a"
 	.align 16
diff --git a/libm/x86/floor.S b/libm/x86/floor.S
index 2b815f346..b859736c7 100644
--- a/libm/x86/floor.S
+++ b/libm/x86/floor.S
@@ -40,5 +40,4 @@ ENTRY(floor)
 	ret
 END(floor)
 
-.globl floorl;
-.equ floorl, floor;
+ALIAS_SYMBOL(floorl, floor);
diff --git a/libm/x86/s_atan.S b/libm/x86/s_atan.S
index 67d8c020f..c4413f158 100644
--- a/libm/x86/s_atan.S
+++ b/libm/x86/s_atan.S
@@ -245,8 +245,7 @@ END(atan)
 # -- End  atan
 
 # Start file scope ASM
-.weak atanl
-.equ atanl, atan
+ALIAS_SYMBOL(atanl, atan);
 # End file scope ASM
 	.section .rodata, "a"
 	.align 16
diff --git a/libm/x86/s_cbrt.S b/libm/x86/s_cbrt.S
index d065de285..0c98c9949 100644
--- a/libm/x86/s_cbrt.S
+++ b/libm/x86/s_cbrt.S
@@ -225,8 +225,7 @@ END(cbrt)
 # -- End  cbrt
 
 # Start file scope ASM
-.weak cbrtl
-.equ cbrtl, cbrt
+ALIAS_SYMBOL(cbrtl, cbrt);
 # End file scope ASM
 	.section .rodata, "a"
 	.align 16
diff --git a/libm/x86/s_cos.S b/libm/x86/s_cos.S
index 0f5d57011..fd5ef5db6 100644
--- a/libm/x86/s_cos.S
+++ b/libm/x86/s_cos.S
@@ -314,8 +314,7 @@ END(cos)
 # -- End  cos
 
 # Start file scope ASM
-.weak cosl
-.equ cosl, cos
+ALIAS_SYMBOL(cosl, cos);
 # End file scope ASM
 	.section .rodata, "a"
 	.align 16
diff --git a/libm/x86/s_expm1.S b/libm/x86/s_expm1.S
index 58819efc4..1f21cde00 100644
--- a/libm/x86/s_expm1.S
+++ b/libm/x86/s_expm1.S
@@ -365,8 +365,7 @@ END(expm1)
 # -- End  expm1
 
 # Start file scope ASM
-.weak expm1l
-.equ expm1l, expm1
+ALIAS_SYMBOL(exmp1l, exmp1);
 # End file scope ASM
 	.section .rodata, "a"
 	.align 16
diff --git a/libm/x86/s_log1p.S b/libm/x86/s_log1p.S
index 76fb8265e..7a6d845bd 100644
--- a/libm/x86/s_log1p.S
+++ b/libm/x86/s_log1p.S
@@ -266,8 +266,7 @@ END(log1p)
 # -- End  log1p
 
 # Start file scope ASM
-.weak log1pl
-.equ log1pl, log1p
+ALIAS_SYMBOL(log1pl, log1p);
 # End file scope ASM
 	.section .rodata, "a"
 	.align 16
diff --git a/libm/x86/s_sin.S b/libm/x86/s_sin.S
index a0578bebb..1e6cbd4aa 100644
--- a/libm/x86/s_sin.S
+++ b/libm/x86/s_sin.S
@@ -321,8 +321,7 @@ END(sin)
 # -- End  sin
 
 # Start file scope ASM
-.weak sinl
-.equ sinl, sin
+ALIAS_SYMBOL(sinl, sin);
 # End file scope ASM
 	.section .rodata, "a"
 	.align 16
diff --git a/libm/x86/s_tan.S b/libm/x86/s_tan.S
index 621c94a0f..3ee21075f 100644
--- a/libm/x86/s_tan.S
+++ b/libm/x86/s_tan.S
@@ -284,8 +284,7 @@ END(tan)
 # -- End  tan
 
 # Start file scope ASM
-.weak tanl
-.equ tanl, tan
+ALIAS_SYMBOL(tanl, tan);
 # End file scope ASM
 	.section .rodata, "a"
 	.align 16
diff --git a/libm/x86/s_tanh.S b/libm/x86/s_tanh.S
index 3975fa937..737bcbbd9 100644
--- a/libm/x86/s_tanh.S
+++ b/libm/x86/s_tanh.S
@@ -278,8 +278,7 @@ END(tanh)
 # -- End  tanh
 
 # Start file scope ASM
-.weak tanhl
-.equ tanhl, tanh
+ALIAS_SYMBOL(tanhl, tanh);
 # End file scope ASM
 	.section .rodata, "a"
 	.align 16
diff --git a/libm/x86/sqrt.S b/libm/x86/sqrt.S
index 3e459ceaf..c9d434d2e 100644
--- a/libm/x86/sqrt.S
+++ b/libm/x86/sqrt.S
@@ -40,5 +40,4 @@ ENTRY(sqrt)
 	ret
 END(sqrt)
 
-.globl sqrtl;
-.equ sqrtl, sqrt;
+ALIAS_SYMBOL(sqrtl, sqrt);
diff --git a/libm/x86/trunc.S b/libm/x86/trunc.S
index 2f21e88db..da9d5fb3a 100644
--- a/libm/x86/trunc.S
+++ b/libm/x86/trunc.S
@@ -40,5 +40,4 @@ ENTRY(trunc)
 	ret
 END(trunc)
 
-.globl truncl;
-.equ truncl, trunc;
+ALIAS_SYMBOL(truncl, trunc);