Move abi bits to separate header. Force AAPCS for EABI in accordance with ARM RTABI.


git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@129769 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/absvdi2.c b/lib/absvdi2.c
index 2ba6687..9c5d4a2 100644
--- a/lib/absvdi2.c
+++ b/lib/absvdi2.c
@@ -11,6 +11,7 @@
  *
  *===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 #include <stdlib.h>
@@ -19,7 +20,7 @@
 
 /* Effects: aborts if abs(x) < 0 */
 
-di_int
+COMPILER_RT_ABI di_int
 __absvdi2(di_int a)
 {
     const int N = (int)(sizeof(di_int) * CHAR_BIT);
diff --git a/lib/absvsi2.c b/lib/absvsi2.c
index ec5cf69..80a1a78 100644
--- a/lib/absvsi2.c
+++ b/lib/absvsi2.c
@@ -10,7 +10,8 @@
  * This file implements __absvsi2 for the compiler_rt library.
  *
  * ===----------------------------------------------------------------------===
- */ 
+ */
+#include "abi.h"
 
 #include "int_lib.h"
 #include <stdlib.h>
@@ -19,7 +20,7 @@
 
 /* Effects: aborts if abs(x) < 0 */
 
-si_int
+COMPILER_RT_ABI si_int
 __absvsi2(si_int a)
 {
     const int N = (int)(sizeof(si_int) * CHAR_BIT);
diff --git a/lib/adddf3.c b/lib/adddf3.c
index 16b394c..3cc997b 100644
--- a/lib/adddf3.c
+++ b/lib/adddf3.c
@@ -12,14 +12,15 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "int_lib.h"
+#include "abi.h"
 
 #define DOUBLE_PRECISION
 #include "fp_lib.h"
 
 ARM_EABI_FNALIAS(dadd, adddf3);
 
-fp_t __adddf3(fp_t a, fp_t b) {
+COMPILER_RT_ABI fp_t
+__adddf3(fp_t a, fp_t b) {
     
     rep_t aRep = toRep(a);
     rep_t bRep = toRep(b);
diff --git a/lib/addsf3.c b/lib/addsf3.c
index d4ee2c4..20610ef 100644
--- a/lib/addsf3.c
+++ b/lib/addsf3.c
@@ -12,11 +12,11 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "abi.h"
+
 #define SINGLE_PRECISION
 #include "fp_lib.h"
 
-#include "int_lib.h"
-
 ARM_EABI_FNALIAS(fadd, addsf3);
 
 fp_t __addsf3(fp_t a, fp_t b) {
diff --git a/lib/addvdi3.c b/lib/addvdi3.c
index ded023e..51ad397 100644
--- a/lib/addvdi3.c
+++ b/lib/addvdi3.c
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 #include <stdlib.h>
@@ -19,7 +20,7 @@
 
 /* Effects: aborts if a + b overflows */
 
-di_int
+COMPILER_RT_ABI di_int
 __addvdi3(di_int a, di_int b)
 {
     di_int s = a + b;
diff --git a/lib/addvsi3.c b/lib/addvsi3.c
index 7bdb39b..c18f7bd 100644
--- a/lib/addvsi3.c
+++ b/lib/addvsi3.c
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 #include <stdlib.h>
@@ -19,7 +20,7 @@
 
 /* Effects: aborts if a + b overflows */
 
-si_int
+COMPILER_RT_ABI si_int
 __addvsi3(si_int a, si_int b)
 {
     si_int s = a + b;
diff --git a/lib/ashldi3.c b/lib/ashldi3.c
index 65bd7b2..adce4e2 100644
--- a/lib/ashldi3.c
+++ b/lib/ashldi3.c
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
@@ -20,7 +21,7 @@
 
 ARM_EABI_FNALIAS(llsl, ashldi3);
 
-di_int
+COMPILER_RT_ABI di_int
 __ashldi3(di_int a, si_int b)
 {
     const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT);
diff --git a/lib/ashrdi3.c b/lib/ashrdi3.c
index cd0855d..03692a3 100644
--- a/lib/ashrdi3.c
+++ b/lib/ashrdi3.c
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
@@ -20,7 +21,7 @@
 
 ARM_EABI_FNALIAS(lasr, ashrdi3);
 
-di_int
+COMPILER_RT_ABI di_int
 __ashrdi3(di_int a, si_int b)
 {
     const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT);
diff --git a/lib/clzdi2.c b/lib/clzdi2.c
index 2132777..c281945 100644
--- a/lib/clzdi2.c
+++ b/lib/clzdi2.c
@@ -1,6 +1,6 @@
 /* ===-- clzdi2.c - Implement __clzdi2 -------------------------------------===
  *
- *      	       The LLVM Compiler Infrastructure
+ *               The LLVM Compiler Infrastructure
  *
  * This file is dual licensed under the MIT and the University of Illinois Open
  * Source Licenses. See LICENSE.TXT for details.
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
@@ -18,7 +19,7 @@
 
 /* Precondition: a != 0 */
 
-si_int
+COMPILER_RT_ABI si_int
 __clzdi2(di_int a)
 {
     dwords x;
diff --git a/lib/clzsi2.c b/lib/clzsi2.c
index d99047d..d0a6aea 100644
--- a/lib/clzsi2.c
+++ b/lib/clzsi2.c
@@ -1,6 +1,6 @@
 /* ===-- clzsi2.c - Implement __clzsi2 -------------------------------------===
  *
- *      	       The LLVM Compiler Infrastructure
+ *               The LLVM Compiler Infrastructure
  *
  * This file is dual licensed under the MIT and the University of Illinois Open
  * Source Licenses. See LICENSE.TXT for details.
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
@@ -18,7 +19,7 @@
 
 /* Precondition: a != 0 */
 
-si_int
+COMPILER_RT_ABI si_int
 __clzsi2(si_int a)
 {
     su_int x = (su_int)a;
diff --git a/lib/cmpdi2.c b/lib/cmpdi2.c
index 04bd7cf..999c3d2 100644
--- a/lib/cmpdi2.c
+++ b/lib/cmpdi2.c
@@ -6,20 +6,21 @@
  * Source Licenses. See LICENSE.TXT for details.
  *
  * ===----------------------------------------------------------------------===
- * 
+ *
  * This file implements __cmpdi2 for the compiler_rt library.
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
-/* Returns:  if (a <  b) returns 0
+/* Returns: if (a <  b) returns 0
 *           if (a == b) returns 1
 *           if (a >  b) returns 2
 */
 
-si_int
+COMPILER_RT_ABI si_int
 __cmpdi2(di_int a, di_int b)
 {
     dwords x;
diff --git a/lib/ctzdi2.c b/lib/ctzdi2.c
index f7ae50f..b3d37d0 100644
--- a/lib/ctzdi2.c
+++ b/lib/ctzdi2.c
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
@@ -18,7 +19,7 @@
 
 /* Precondition: a != 0 */
 
-si_int
+COMPILER_RT_ABI si_int
 __ctzdi2(di_int a)
 {
     dwords x;
diff --git a/lib/ctzsi2.c b/lib/ctzsi2.c
index 0c738fa..2ff0e5d 100644
--- a/lib/ctzsi2.c
+++ b/lib/ctzsi2.c
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
@@ -18,7 +19,7 @@
 
 /* Precondition: a != 0 */
 
-si_int
+COMPILER_RT_ABI si_int
 __ctzsi2(si_int a)
 {
     su_int x = (su_int)a;
diff --git a/lib/divdf3.c b/lib/divdf3.c
index 820b4c8..925abd5 100644
--- a/lib/divdf3.c
+++ b/lib/divdf3.c
@@ -15,12 +15,11 @@
 // underflow with correct rounding.
 //
 //===----------------------------------------------------------------------===//
+#include "abi.h"
 
 #define DOUBLE_PRECISION
 #include "fp_lib.h"
 
-#include "int_lib.h"
-
 ARM_EABI_FNALIAS(ddiv, divdf3);
 
 fp_t __divdf3(fp_t a, fp_t b) {
diff --git a/lib/divdi3.c b/lib/divdi3.c
index a1b83ea..d62df56 100644
--- a/lib/divdi3.c
+++ b/lib/divdi3.c
@@ -11,14 +11,15 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
-du_int __udivmoddi4(du_int a, du_int b, du_int* rem);
+du_int COMPILER_RT_ABI __udivmoddi4(du_int a, du_int b, du_int* rem);
 
 /* Returns: a / b */
 
-di_int
+COMPILER_RT_ABI di_int
 __divdi3(di_int a, di_int b)
 {
     const int bits_in_dword_m1 = (int)(sizeof(di_int) * CHAR_BIT) - 1;
diff --git a/lib/divmodsi4.c b/lib/divmodsi4.c
index 2ec3dd4..4dc1978 100644
--- a/lib/divmodsi4.c
+++ b/lib/divmodsi4.c
@@ -11,15 +11,16 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
-extern si_int __divsi3(si_int a, si_int b);
+extern COMPILER_RT_ABI si_int __divsi3(si_int a, si_int b);
 
 
 /* Returns: a / b, *rem = a % b  */
 
-si_int
+COMPILER_RT_ABI si_int
 __divmodsi4(si_int a, si_int b, si_int* rem)
 {
   si_int d = __divsi3(a,b);
diff --git a/lib/divsf3.c b/lib/divsf3.c
index 84e9a37..b733307 100644
--- a/lib/divsf3.c
+++ b/lib/divsf3.c
@@ -15,12 +15,11 @@
 // underflow with correct rounding.
 //
 //===----------------------------------------------------------------------===//
+#include "abi.h"
 
 #define SINGLE_PRECISION
 #include "fp_lib.h"
 
-#include "int_lib.h"
-
 ARM_EABI_FNALIAS(fdiv, divsf3);
 
 fp_t __divsf3(fp_t a, fp_t b) {
diff --git a/lib/divsi3.c b/lib/divsi3.c
index db2b6e8..01ef274 100644
--- a/lib/divsi3.c
+++ b/lib/divsi3.c
@@ -11,16 +11,17 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
-su_int __udivsi3(su_int n, su_int d);
+su_int COMPILER_RT_ABI __udivsi3(su_int n, su_int d);
 
 /* Returns: a / b */
 
 ARM_EABI_FNALIAS(idiv, divsi3);
 
-si_int
+COMPILER_RT_ABI si_int
 __divsi3(si_int a, si_int b)
 {
     const int bits_in_word_m1 = (int)(sizeof(si_int) * CHAR_BIT) - 1;
diff --git a/lib/extendsfdf2.c b/lib/extendsfdf2.c
index a630154..c0b628d 100644
--- a/lib/extendsfdf2.c
+++ b/lib/extendsfdf2.c
@@ -41,7 +41,7 @@
 #include <stdint.h>
 #include <limits.h>
 
-#include "int_lib.h"
+#include "abi.h"
 
 typedef float src_t;
 typedef uint32_t src_rep_t;
diff --git a/lib/ffsdi2.c b/lib/ffsdi2.c
index 8a1c68c..89f1b7b 100644
--- a/lib/ffsdi2.c
+++ b/lib/ffsdi2.c
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
@@ -18,7 +19,7 @@
  * the value zero if a is zero. The least significant bit is index one.
  */
 
-si_int
+COMPILER_RT_ABI si_int
 __ffsdi2(di_int a)
 {
     dwords x;
diff --git a/lib/fixdfdi.c b/lib/fixdfdi.c
index c6732db..85a456d 100644
--- a/lib/fixdfdi.c
+++ b/lib/fixdfdi.c
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
diff --git a/lib/fixsfdi.c b/lib/fixsfdi.c
index e32b85f..d80e33e 100644
--- a/lib/fixsfdi.c
+++ b/lib/fixsfdi.c
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
@@ -25,7 +26,7 @@
 
 ARM_EABI_FNALIAS(d2lz, fixsfdi);
 
-di_int
+COMPILER_RT_ABI di_int
 __fixsfdi(float a)
 {
     float_bits fb;
diff --git a/lib/fixsfsi.c b/lib/fixsfsi.c
index 4cdc47f..67749a5 100644
--- a/lib/fixsfsi.c
+++ b/lib/fixsfsi.c
@@ -12,16 +12,15 @@
 // conversion is undefined for out of range values in the C standard.
 //
 //===----------------------------------------------------------------------===//
+#include "abi.h"
 
 #define SINGLE_PRECISION
 #include "fp_lib.h"
 
-#include "int_lib.h"
-
 ARM_EABI_FNALIAS(f2iz, fixsfsi);
 
-int __fixsfsi(fp_t a) {
-    
+COMPILER_RT_ABI int
+__fixsfsi(fp_t a) {
     // Break a into sign, exponent, significand
     const rep_t aRep = toRep(a);
     const rep_t aAbs = aRep & absMask;
diff --git a/lib/fixunsdfdi.c b/lib/fixunsdfdi.c
index 1721d33..d80b84a 100644
--- a/lib/fixunsdfdi.c
+++ b/lib/fixunsdfdi.c
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
@@ -28,7 +29,7 @@
 
 ARM_EABI_FNALIAS(d2ulz, fixunsdfdi);
 
-du_int
+COMPILER_RT_ABI du_int
 __fixunsdfdi(double a)
 {
     double_bits fb;
diff --git a/lib/fixunsdfsi.c b/lib/fixunsdfsi.c
index 7a803f2..ecdfb5d 100644
--- a/lib/fixunsdfsi.c
+++ b/lib/fixunsdfsi.c
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
@@ -28,7 +29,7 @@
 
 ARM_EABI_FNALIAS(d2uiz, fixunsdfsi);
 
-su_int
+COMPILER_RT_ABI su_int
 __fixunsdfsi(double a)
 {
     double_bits fb;
diff --git a/lib/fixunssfdi.c b/lib/fixunssfdi.c
index 3d7d95c..1506420 100644
--- a/lib/fixunssfdi.c
+++ b/lib/fixunssfdi.c
@@ -11,9 +11,9 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
-
 /* Returns: convert a to a unsigned long long, rounding toward zero.
  *          Negative values all become zero.
  */
@@ -26,11 +26,9 @@
 
 /* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */
 
-#include "int_lib.h"
-
 ARM_EABI_FNALIAS(f2ulz, fixunssfdi);
 
-du_int
+COMPILER_RT_ABI du_int
 __fixunssfdi(float a)
 {
     float_bits fb;
diff --git a/lib/fixunssfsi.c b/lib/fixunssfsi.c
index b822ffe..dbaa511 100644
--- a/lib/fixunssfsi.c
+++ b/lib/fixunssfsi.c
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
@@ -28,7 +29,7 @@
 
 ARM_EABI_FNALIAS(f2uiz, fixunssfsi);
 
-su_int
+COMPILER_RT_ABI su_int
 __fixunssfsi(float a)
 {
     float_bits fb;
diff --git a/lib/floatdidf.c b/lib/floatdidf.c
index 1633f73..5ba9526 100644
--- a/lib/floatdidf.c
+++ b/lib/floatdidf.c
@@ -11,6 +11,7 @@
  *
  *===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 #include <float.h>
@@ -23,8 +24,6 @@
 
 /* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */
 
-#include "int_lib.h"
-
 ARM_EABI_FNALIAS(l2d, floatdidf);
 
 #ifndef __SOFT_FP__
@@ -33,7 +32,7 @@
  */
 #include <stdint.h>
 
-double
+COMPILER_RT_ABI double
 __floatdidf(di_int a)
 {
 	static const double twop52 = 0x1.0p52;
@@ -53,7 +52,7 @@
  * set, and we don't want to code-gen to an unknown soft-float implementation.
  */
 
-double
+COMPILER_RT_ABI double
 __floatdidf(di_int a)
 {
     if (a == 0)
diff --git a/lib/floatdisf.c b/lib/floatdisf.c
index cdede6c..4dc13ca 100644
--- a/lib/floatdisf.c
+++ b/lib/floatdisf.c
@@ -12,7 +12,7 @@
  *===----------------------------------------------------------------------===
  */
 
-#include "int_lib.h"
+#include "abi.h"
 #include <float.h>
 
 /* Returns: convert a to a float, rounding toward even.*/
@@ -27,7 +27,7 @@
 
 ARM_EABI_FNALIAS(l2f, floatdisf);
 
-float
+COMPILER_RT_ABI float
 __floatdisf(di_int a)
 {
     if (a == 0)
diff --git a/lib/floatundidf.c b/lib/floatundidf.c
index 64bec04..e74e9d8 100644
--- a/lib/floatundidf.c
+++ b/lib/floatundidf.c
@@ -12,7 +12,7 @@
  * ===----------------------------------------------------------------------===
  */
 
-#include "int_lib.h"
+#include "abi.h"
 #include <float.h>
 
 /* Returns: convert a to a double, rounding toward even. */
@@ -34,7 +34,7 @@
 
 #include <stdint.h>
 
-double
+COMPILER_RT_ABI double
 __floatundidf(du_int a)
 {
 	static const double twop52 = 0x1.0p52;
@@ -56,7 +56,7 @@
  * set, and we don't want to code-gen to an unknown soft-float implementation.
  */ 
 
-double
+COMPILER_RT_ABI double
 __floatundidf(du_int a)
 {
     if (a == 0)
diff --git a/lib/floatundisf.c b/lib/floatundisf.c
index 2d2a514..eea45a7 100644
--- a/lib/floatundisf.c
+++ b/lib/floatundisf.c
@@ -12,7 +12,7 @@
  *===----------------------------------------------------------------------===
  */
 
-#include "int_lib.h"
+#include "abi.h"
 #include <float.h>
 
 /* Returns: convert a to a float, rounding toward even. */
@@ -27,7 +27,7 @@
 
 ARM_EABI_FNALIAS(ul2f, floatundisf);
 
-float
+COMPILER_RT_ABI float
 __floatundisf(du_int a)
 {
     if (a == 0)
diff --git a/lib/int_lib.h b/lib/int_lib.h
index c0224ce..e1fd6b7 100644
--- a/lib/int_lib.h
+++ b/lib/int_lib.h
@@ -37,13 +37,6 @@
 #define INFINITY HUGE_VAL
 #endif /* INFINITY */
 
-#if __ARM_EABI__
-# define ARM_EABI_FNALIAS(aeabi_name, name)         \
-  void __aeabi_##aeabi_name() __attribute__((alias("__" #name)));
-#else
-# define ARM_EABI_FNALIAS(aeabi_name, name)
-#endif
-
 typedef      int si_int;
 typedef unsigned su_int;
 
diff --git a/lib/lshrdi3.c b/lib/lshrdi3.c
index 7468cb7..911edb1 100644
--- a/lib/lshrdi3.c
+++ b/lib/lshrdi3.c
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
@@ -20,7 +21,7 @@
 
 ARM_EABI_FNALIAS(llsr, lshrdi3);
 
-di_int
+COMPILER_RT_ABI di_int
 __lshrdi3(di_int a, si_int b)
 {
     const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT);
diff --git a/lib/moddi3.c b/lib/moddi3.c
index 3b350dd..af0a808 100644
--- a/lib/moddi3.c
+++ b/lib/moddi3.c
@@ -11,14 +11,15 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
-du_int __udivmoddi4(du_int a, du_int b, du_int* rem);
+COMPILER_RT_ABI du_int __udivmoddi4(du_int a, du_int b, du_int* rem);
 
 /* Returns: a % b */
 
-di_int
+COMPILER_RT_ABI di_int
 __moddi3(di_int a, di_int b)
 {
     const int bits_in_dword_m1 = (int)(sizeof(di_int) * CHAR_BIT) - 1;
diff --git a/lib/modsi3.c b/lib/modsi3.c
index 70d38a6..05ce806 100644
--- a/lib/modsi3.c
+++ b/lib/modsi3.c
@@ -11,14 +11,15 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
-su_int __divsi3(si_int a, si_int b);
+su_int COMPILER_RT_ABI __divsi3(si_int a, si_int b);
 
 /* Returns: a % b */
 
-si_int
+COMPILER_RT_ABI si_int
 __modsi3(si_int a, si_int b)
 {
     return a - __divsi3(a, b) * b;
diff --git a/lib/muldf3.c b/lib/muldf3.c
index 5cfe62b..f402cfb 100644
--- a/lib/muldf3.c
+++ b/lib/muldf3.c
@@ -11,15 +11,15 @@
 // with the IEEE-754 default rounding (to nearest, ties to even).
 //
 //===----------------------------------------------------------------------===//
+#include "abi.h"
 
 #define DOUBLE_PRECISION
 #include "fp_lib.h"
 
-#include "int_lib.h"
-
 ARM_EABI_FNALIAS(dmul, muldf3);
 
-fp_t __muldf3(fp_t a, fp_t b) {
+COMPILER_RT_ABI fp_t
+__muldf3(fp_t a, fp_t b) {
     
     const unsigned int aExponent = toRep(a) >> significandBits & maxExponent;
     const unsigned int bExponent = toRep(b) >> significandBits & maxExponent;
diff --git a/lib/muldi3.c b/lib/muldi3.c
index 537b735..e6322bf 100644
--- a/lib/muldi3.c
+++ b/lib/muldi3.c
@@ -10,7 +10,8 @@
  * This file implements __muldi3 for the compiler_rt library.
  *
  * ===----------------------------------------------------------------------===
- */ 
+ */
+#include "abi.h"
 
 #include "int_lib.h"
 
@@ -42,7 +43,7 @@
 
 ARM_EABI_FNALIAS(lmul, muldi3);
 
-di_int
+COMPILER_RT_ABI di_int
 __muldi3(di_int a, di_int b)
 {
     dwords x;
diff --git a/lib/mulsf3.c b/lib/mulsf3.c
index 96dcfd9..bf46e14 100644
--- a/lib/mulsf3.c
+++ b/lib/mulsf3.c
@@ -11,15 +11,15 @@
 // with the IEEE-754 default rounding (to nearest, ties to even).
 //
 //===----------------------------------------------------------------------===//
+#include "abi.h"
 
 #define SINGLE_PRECISION
 #include "fp_lib.h"
 
-#include "int_lib.h"
-
 ARM_EABI_FNALIAS(fmul, mulsf3);
 
-fp_t __mulsf3(fp_t a, fp_t b) {
+COMPILER_RT_ABI fp_t
+__mulsf3(fp_t a, fp_t b) {
     
     const unsigned int aExponent = toRep(a) >> significandBits & maxExponent;
     const unsigned int bExponent = toRep(b) >> significandBits & maxExponent;
diff --git a/lib/negdf2.c b/lib/negdf2.c
index 9344ae1..b47f397 100644
--- a/lib/negdf2.c
+++ b/lib/negdf2.c
@@ -10,12 +10,11 @@
 // This file implements double-precision soft-float negation.
 //
 //===----------------------------------------------------------------------===//
+#include "abi.h"
 
 #define DOUBLE_PRECISION
 #include "fp_lib.h"
 
-#include "int_lib.h"
-
 ARM_EABI_FNALIAS(dneg, negdf2);
 
 fp_t __negdf2(fp_t a) {
diff --git a/lib/negsf2.c b/lib/negsf2.c
index 6b0e62c..98f9fc0 100644
--- a/lib/negsf2.c
+++ b/lib/negsf2.c
@@ -10,14 +10,14 @@
 // This file implements single-precision soft-float negation.
 //
 //===----------------------------------------------------------------------===//
+#include "abi.h"
 
 #define SINGLE_PRECISION
 #include "fp_lib.h"
 
-#include "int_lib.h"
-
 ARM_EABI_FNALIAS(fneg, negsf2);
 
-fp_t __negsf2(fp_t a) {
+COMPILER_RT_ABI fp_t
+__negsf2(fp_t a) {
     return fromRep(toRep(a) ^ signBit);
 }
diff --git a/lib/negvdi2.c b/lib/negvdi2.c
index 2851d26..aafaa9d 100644
--- a/lib/negvdi2.c
+++ b/lib/negvdi2.c
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 #include <stdlib.h>
@@ -19,7 +20,7 @@
 
 /* Effects: aborts if -a overflows */
 
-di_int
+COMPILER_RT_ABI di_int
 __negvdi2(di_int a)
 {
     const di_int MIN = (di_int)1 << ((int)(sizeof(di_int) * CHAR_BIT)-1);
diff --git a/lib/negvsi2.c b/lib/negvsi2.c
index 1a83347..559ea18 100644
--- a/lib/negvsi2.c
+++ b/lib/negvsi2.c
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 #include <stdlib.h>
@@ -19,7 +20,7 @@
 
 /* Effects: aborts if -a overflows */
 
-si_int
+COMPILER_RT_ABI si_int
 __negvsi2(si_int a)
 {
     const si_int MIN = (si_int)1 << ((int)(sizeof(si_int) * CHAR_BIT)-1);
diff --git a/lib/paritydi2.c b/lib/paritydi2.c
index 9d349b8..e7bebf6 100644
--- a/lib/paritydi2.c
+++ b/lib/paritydi2.c
@@ -11,14 +11,15 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
 /* Returns: 1 if number of bits is odd else returns 0 */
 
-si_int __paritysi2(si_int a);
+si_int COMPILER_RT_ABI __paritysi2(si_int a);
 
-si_int
+COMPILER_RT_ABI si_int
 __paritydi2(di_int a)
 {
     dwords x;
diff --git a/lib/paritysi2.c b/lib/paritysi2.c
index 76de328..64d509f 100644
--- a/lib/paritysi2.c
+++ b/lib/paritysi2.c
@@ -11,12 +11,13 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
 /* Returns: 1 if number of bits is odd else returns 0 */
 
-si_int
+COMPILER_RT_ABI si_int
 __paritysi2(si_int a)
 {
     su_int x = (su_int)a;
diff --git a/lib/popcountdi2.c b/lib/popcountdi2.c
index 0778a66..136fc04 100644
--- a/lib/popcountdi2.c
+++ b/lib/popcountdi2.c
@@ -11,12 +11,13 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
 /* Returns: count of 1 bits */
 
-si_int
+COMPILER_RT_ABI si_int
 __popcountdi2(di_int a)
 {
     du_int x2 = (du_int)a;
diff --git a/lib/popcountsi2.c b/lib/popcountsi2.c
index e425b0b..bfaa3ff 100644
--- a/lib/popcountsi2.c
+++ b/lib/popcountsi2.c
@@ -11,12 +11,13 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
 /* Returns: count of 1 bits */
 
-si_int
+COMPILER_RT_ABI si_int
 __popcountsi2(si_int a)
 {
     su_int x = (su_int)a;
diff --git a/lib/powidf2.c b/lib/powidf2.c
index 0200e1e..2e211eb 100644
--- a/lib/powidf2.c
+++ b/lib/powidf2.c
@@ -11,12 +11,13 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
 /* Returns: a ^ b */
 
-double
+COMPILER_RT_ABI double
 __powidf2(double a, si_int b)
 {
     const int recip = b < 0;
diff --git a/lib/powisf2.c b/lib/powisf2.c
index c834b96..e6b43b3 100644
--- a/lib/powisf2.c
+++ b/lib/powisf2.c
@@ -11,12 +11,13 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
 /* Returns: a ^ b */
 
-float
+COMPILER_RT_ABI float
 __powisf2(float a, si_int b)
 {
     const int recip = b < 0;
diff --git a/lib/subdf3.c b/lib/subdf3.c
index d9ed494..825e3c6 100644
--- a/lib/subdf3.c
+++ b/lib/subdf3.c
@@ -11,19 +11,19 @@
 // IEEE-754 default rounding (to nearest, ties to even).
 //
 //===----------------------------------------------------------------------===//
+#include "abi.h"
 
 #define DOUBLE_PRECISION
 #include "fp_lib.h"
 
-#include "int_lib.h"
-
-fp_t __adddf3(fp_t a, fp_t b);
+fp_t COMPILER_RT_ABI __adddf3(fp_t a, fp_t b);
 
 
 ARM_EABI_FNALIAS(dsub, subdf3);
 
 // Subtraction; flip the sign bit of b and add.
-fp_t __subdf3(fp_t a, fp_t b) {
+COMPILER_RT_ABI fp_t
+__subdf3(fp_t a, fp_t b) {
     return __adddf3(a, fromRep(toRep(b) ^ signBit));
 }
 
diff --git a/lib/subsf3.c b/lib/subsf3.c
index 5345eb2..625376a 100644
--- a/lib/subsf3.c
+++ b/lib/subsf3.c
@@ -11,18 +11,18 @@
 // IEEE-754 default rounding (to nearest, ties to even).
 //
 //===----------------------------------------------------------------------===//
+#include "abi.h"
 
 #define SINGLE_PRECISION
 #include "fp_lib.h"
 
-#include "int_lib.h"
-
-fp_t __addsf3(fp_t a, fp_t b);
+fp_t COMPILER_RT_ABI __addsf3(fp_t a, fp_t b);
 
 ARM_EABI_FNALIAS(fsub, subsf3);
 
 // Subtraction; flip the sign bit of b and add.
-fp_t __subsf3(fp_t a, fp_t b) {
+COMPILER_RT_ABI fp_t
+__subsf3(fp_t a, fp_t b) {
     return __addsf3(a, fromRep(toRep(b) ^ signBit));
 }
 
diff --git a/lib/subvdi3.c b/lib/subvdi3.c
index 17f55d0..36b51ad 100644
--- a/lib/subvdi3.c
+++ b/lib/subvdi3.c
@@ -1,6 +1,6 @@
 /* ===-- subvdi3.c - Implement __subvdi3 -----------------------------------===
  *
- *      	       The LLVM Compiler Infrastructure
+ *                The LLVM Compiler Infrastructure
  *
  * This file is dual licensed under the MIT and the University of Illinois Open
  * Source Licenses. See LICENSE.TXT for details.
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 #include <stdlib.h>
@@ -19,7 +20,7 @@
 
 /* Effects: aborts if a - b overflows */
 
-di_int
+COMPILER_RT_ABI di_int
 __subvdi3(di_int a, di_int b)
 {
     di_int s = a - b;
diff --git a/lib/subvsi3.c b/lib/subvsi3.c
index 51bb454..03983f7 100644
--- a/lib/subvsi3.c
+++ b/lib/subvsi3.c
@@ -1,6 +1,6 @@
 /* ===-- subvsi3.c - Implement __subvsi3 -----------------------------------===
  *
- *      	       The LLVM Compiler Infrastructure
+ *                The LLVM Compiler Infrastructure
  *
  * This file is dual licensed under the MIT and the University of Illinois Open
  * Source Licenses. See LICENSE.TXT for details.
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 #include <stdlib.h>
@@ -19,7 +20,7 @@
 
 /* Effects: aborts if a - b overflows */
 
-si_int
+COMPILER_RT_ABI si_int
 __subvsi3(si_int a, si_int b)
 {
     si_int s = a - b;
diff --git a/lib/truncdfsf2.c b/lib/truncdfsf2.c
index f3de219..1dbf02f 100644
--- a/lib/truncdfsf2.c
+++ b/lib/truncdfsf2.c
@@ -41,7 +41,7 @@
 #include <limits.h>
 #include <stdbool.h>
 
-#include "int_lib.h"
+#include "abi.h"
 
 typedef double src_t;
 typedef uint64_t src_rep_t;
@@ -70,7 +70,8 @@
 
 ARM_EABI_FNALIAS(d2f, truncdfsf2);
 
-dst_t __truncdfsf2(src_t a) {
+COMPILER_RT_ABI dst_t
+__truncdfsf2(src_t a) {
     
     // Various constants whose values follow from the type parameters.
     // Any reasonable optimizer will fold and propagate all of these.
diff --git a/lib/ucmpdi2.c b/lib/ucmpdi2.c
index ead7267..f2d3f99 100644
--- a/lib/ucmpdi2.c
+++ b/lib/ucmpdi2.c
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
@@ -19,7 +20,7 @@
  *           if (a >  b) returns 2
  */
 
-si_int
+COMPILER_RT_ABI si_int
 __ucmpdi2(du_int a, du_int b)
 {
     udwords x;
diff --git a/lib/udivdi3.c b/lib/udivdi3.c
index 642f2fb..bbd551a 100644
--- a/lib/udivdi3.c
+++ b/lib/udivdi3.c
@@ -11,14 +11,15 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
-du_int __udivmoddi4(du_int a, du_int b, du_int* rem);
+du_int COMPILER_RT_ABI __udivmoddi4(du_int a, du_int b, du_int* rem);
 
 /* Returns: a / b */
 
-du_int
+COMPILER_RT_ABI du_int
 __udivdi3(du_int a, du_int b)
 {
     return __udivmoddi4(a, b, 0);
diff --git a/lib/udivmoddi4.c b/lib/udivmoddi4.c
index 6b8c4e8..c5db21c 100644
--- a/lib/udivmoddi4.c
+++ b/lib/udivmoddi4.c
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
@@ -22,7 +23,7 @@
 
 ARM_EABI_FNALIAS(uldivmod, udivmoddi4);
 
-du_int
+COMPILER_RT_ABI du_int
 __udivmoddi4(du_int a, du_int b, du_int* rem)
 {
     const unsigned n_uword_bits = sizeof(su_int) * CHAR_BIT;
diff --git a/lib/udivmodsi4.c b/lib/udivmodsi4.c
index 38b5bd4..2a3ee27 100644
--- a/lib/udivmodsi4.c
+++ b/lib/udivmodsi4.c
@@ -11,20 +11,21 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
-extern su_int __udivsi3(su_int n, su_int d);
+extern su_int COMPILER_RT_ABI __udivsi3(su_int n, su_int d);
 
 
 /* Returns: a / b, *rem = a % b  */
 
-su_int 
+COMPILER_RT_ABI su_int
 __udivmodsi4(su_int a, su_int b, su_int* rem)
 {
   si_int d = __udivsi3(a,b);
   *rem = a - (d*b);
-  return d; 
+  return d;
 }
 
 
diff --git a/lib/udivsi3.c b/lib/udivsi3.c
index 8a5695d..721ae89 100644
--- a/lib/udivsi3.c
+++ b/lib/udivsi3.c
@@ -11,6 +11,7 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
@@ -20,7 +21,7 @@
 
 ARM_EABI_FNALIAS(uidiv, udivsi3);
 
-su_int
+COMPILER_RT_ABI su_int
 __udivsi3(su_int n, su_int d)
 {
     const unsigned n_uword_bits = sizeof(su_int) * CHAR_BIT;
diff --git a/lib/umoddi3.c b/lib/umoddi3.c
index adb4b0e..9de1a64 100644
--- a/lib/umoddi3.c
+++ b/lib/umoddi3.c
@@ -11,14 +11,15 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
-du_int __udivmoddi4(du_int a, du_int b, du_int* rem);
+du_int COMPILER_RT_ABI __udivmoddi4(du_int a, du_int b, du_int* rem);
 
 /* Returns: a % b */
 
-du_int
+COMPILER_RT_ABI du_int
 __umoddi3(du_int a, du_int b)
 {
     du_int r;
diff --git a/lib/umodsi3.c b/lib/umodsi3.c
index d3aaaea..569b7fc 100644
--- a/lib/umodsi3.c
+++ b/lib/umodsi3.c
@@ -11,14 +11,15 @@
  *
  * ===----------------------------------------------------------------------===
  */
+#include "abi.h"
 
 #include "int_lib.h"
 
 /* Returns: a % b */
 
-su_int __udivsi3(su_int a, su_int b);
+su_int COMPILER_RT_ABI __udivsi3(su_int a, su_int b);
 
-su_int
+COMPILER_RT_ABI su_int
 __umodsi3(su_int a, su_int b)
 {
     return a - __udivsi3(a, b) * b;