xref: /minix3/sys/external/bsd/compiler_rt/dist/lib/builtins/int_lib.h (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc /* ===-- int_lib.h - configuration header for compiler-rt  -----------------===
2*0a6a1f1dSLionel Sambuc  *
3*0a6a1f1dSLionel Sambuc  *                     The LLVM Compiler Infrastructure
4*0a6a1f1dSLionel Sambuc  *
5*0a6a1f1dSLionel Sambuc  * This file is dual licensed under the MIT and the University of Illinois Open
6*0a6a1f1dSLionel Sambuc  * Source Licenses. See LICENSE.TXT for details.
7*0a6a1f1dSLionel Sambuc  *
8*0a6a1f1dSLionel Sambuc  * ===----------------------------------------------------------------------===
9*0a6a1f1dSLionel Sambuc  *
10*0a6a1f1dSLionel Sambuc  * This file is a configuration header for compiler-rt.
11*0a6a1f1dSLionel Sambuc  * This file is not part of the interface of this library.
12*0a6a1f1dSLionel Sambuc  *
13*0a6a1f1dSLionel Sambuc  * ===----------------------------------------------------------------------===
14*0a6a1f1dSLionel Sambuc  */
15*0a6a1f1dSLionel Sambuc 
16*0a6a1f1dSLionel Sambuc #ifndef INT_LIB_H
17*0a6a1f1dSLionel Sambuc #define INT_LIB_H
18*0a6a1f1dSLionel Sambuc 
19*0a6a1f1dSLionel Sambuc /* Assumption: Signed integral is 2's complement. */
20*0a6a1f1dSLionel Sambuc /* Assumption: Right shift of signed negative is arithmetic shift. */
21*0a6a1f1dSLionel Sambuc /* Assumption: Endianness is little or big (not mixed). */
22*0a6a1f1dSLionel Sambuc 
23*0a6a1f1dSLionel Sambuc /* ABI macro definitions */
24*0a6a1f1dSLionel Sambuc 
25*0a6a1f1dSLionel Sambuc /*
26*0a6a1f1dSLionel Sambuc  * TODO define this appropriately for targets that require explicit export
27*0a6a1f1dSLionel Sambuc  * declarations (i.e. Windows)
28*0a6a1f1dSLionel Sambuc  */
29*0a6a1f1dSLionel Sambuc #define COMPILER_RT_EXPORT
30*0a6a1f1dSLionel Sambuc 
31*0a6a1f1dSLionel Sambuc #if __ARM_EABI__
32*0a6a1f1dSLionel Sambuc # define ARM_EABI_FNALIAS(aeabi_name, name)         \
33*0a6a1f1dSLionel Sambuc   void __aeabi_##aeabi_name() __attribute__((alias("__" #name)));
34*0a6a1f1dSLionel Sambuc # define COMPILER_RT_ABI COMPILER_RT_EXPORT __attribute__((pcs("aapcs")))
35*0a6a1f1dSLionel Sambuc #else
36*0a6a1f1dSLionel Sambuc # define ARM_EABI_FNALIAS(aeabi_name, name)
37*0a6a1f1dSLionel Sambuc # define COMPILER_RT_ABI COMPILER_RT_EXPORT
38*0a6a1f1dSLionel Sambuc #endif
39*0a6a1f1dSLionel Sambuc 
40*0a6a1f1dSLionel Sambuc #if defined(__NetBSD__) && (defined(_KERNEL) || defined(_STANDALONE))
41*0a6a1f1dSLionel Sambuc /*
42*0a6a1f1dSLionel Sambuc  * Kernel and boot environment can't use normal headers,
43*0a6a1f1dSLionel Sambuc  * so use the equivalent system headers.
44*0a6a1f1dSLionel Sambuc  */
45*0a6a1f1dSLionel Sambuc #  include <machine/limits.h>
46*0a6a1f1dSLionel Sambuc #  include <sys/stdint.h>
47*0a6a1f1dSLionel Sambuc #  include <sys/types.h>
48*0a6a1f1dSLionel Sambuc #else
49*0a6a1f1dSLionel Sambuc /* Include the standard compiler builtin headers we use functionality from. */
50*0a6a1f1dSLionel Sambuc #  include <limits.h>
51*0a6a1f1dSLionel Sambuc #  include <stdint.h>
52*0a6a1f1dSLionel Sambuc #  include <stdbool.h>
53*0a6a1f1dSLionel Sambuc #  include <float.h>
54*0a6a1f1dSLionel Sambuc #endif
55*0a6a1f1dSLionel Sambuc 
56*0a6a1f1dSLionel Sambuc /* Include the commonly used internal type definitions. */
57*0a6a1f1dSLionel Sambuc #include "int_types.h"
58*0a6a1f1dSLionel Sambuc 
59*0a6a1f1dSLionel Sambuc /* Include internal utility function declarations. */
60*0a6a1f1dSLionel Sambuc #include "int_util.h"
61*0a6a1f1dSLionel Sambuc 
62*0a6a1f1dSLionel Sambuc COMPILER_RT_ABI si_int __paritysi2(si_int a);
63*0a6a1f1dSLionel Sambuc COMPILER_RT_ABI si_int __paritydi2(di_int a);
64*0a6a1f1dSLionel Sambuc 
65*0a6a1f1dSLionel Sambuc COMPILER_RT_ABI di_int __divdi3(di_int a, di_int b);
66*0a6a1f1dSLionel Sambuc COMPILER_RT_ABI si_int __divsi3(si_int a, si_int b);
67*0a6a1f1dSLionel Sambuc COMPILER_RT_ABI su_int __udivsi3(su_int n, su_int d);
68*0a6a1f1dSLionel Sambuc 
69*0a6a1f1dSLionel Sambuc COMPILER_RT_ABI su_int __udivmodsi4(su_int a, su_int b, su_int* rem);
70*0a6a1f1dSLionel Sambuc COMPILER_RT_ABI du_int __udivmoddi4(du_int a, du_int b, du_int* rem);
71*0a6a1f1dSLionel Sambuc #ifdef CRT_HAS_128BIT
72*0a6a1f1dSLionel Sambuc COMPILER_RT_ABI si_int __clzti2(ti_int a);
73*0a6a1f1dSLionel Sambuc COMPILER_RT_ABI tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem);
74*0a6a1f1dSLionel Sambuc #endif
75*0a6a1f1dSLionel Sambuc 
76*0a6a1f1dSLionel Sambuc #endif /* INT_LIB_H */
77