int_lib.h revision 230021
1214152Sed/* ===-- int_lib.h - configuration header for compiler-rt  -----------------===
2214152Sed *
3214152Sed *                     The LLVM Compiler Infrastructure
4214152Sed *
5222656Sed * This file is dual licensed under the MIT and the University of Illinois Open
6222656Sed * Source Licenses. See LICENSE.TXT for details.
7214152Sed *
8214152Sed * ===----------------------------------------------------------------------===
9214152Sed *
10214152Sed * This file is a configuration header for compiler-rt.
11214152Sed * This file is not part of the interface of this library.
12214152Sed *
13214152Sed * ===----------------------------------------------------------------------===
14214152Sed */
15214152Sed
16214152Sed#ifndef INT_LIB_H
17214152Sed#define INT_LIB_H
18214152Sed
19229135Sed/* Assumption: Signed integral is 2's complement. */
20229135Sed/* Assumption: Right shift of signed negative is arithmetic shift. */
21229135Sed/* Assumption: Endianness is little or big (not mixed). */
22214152Sed
23229135Sed/* ABI macro definitions */
24214152Sed
25229135Sed#if __ARM_EABI__
26229135Sed# define ARM_EABI_FNALIAS(aeabi_name, name)         \
27229135Sed  void __aeabi_##aeabi_name() __attribute__((alias("__" #name)));
28229135Sed# define COMPILER_RT_ABI __attribute__((pcs("aapcs")))
29214152Sed#else
30229135Sed# define ARM_EABI_FNALIAS(aeabi_name, name)
31229135Sed# define COMPILER_RT_ABI
32214152Sed#endif
33214152Sed
34229135Sed/* Include the standard compiler builtin headers we use functionality from. */
35229135Sed#include <limits.h>
36229135Sed#include <stdint.h>
37229135Sed#include <stdbool.h>
38229135Sed#include <float.h>
39214152Sed
40229135Sed/* Include the commonly used internal type definitions. */
41229135Sed#include "int_types.h"
42214152Sed
43229135Sed/* Include internal utility function declarations. */
44229135Sed#include "int_util.h"
45214152Sed
46230021Sed/*
47230021Sed * Workaround for LLVM bug 11663.  Prevent endless recursion in
48230021Sed * __c?zdi2(), where calls to __builtin_c?z() are expanded to
49230021Sed * __c?zdi2() instead of __c?zsi2().
50230021Sed *
51230021Sed * Instead of placing this workaround in c?zdi2.c, put it in this
52230021Sed * global header to prevent other C files from making the detour
53230021Sed * through __c?zdi2() as well.
54230021Sed *
55230021Sed * This problem has only been observed on FreeBSD for sparc64 and
56230021Sed * mips64 with GCC 4.2.1.
57230021Sed */
58230021Sed#if defined(__FreeBSD__) && (defined(__sparc64__) || \
59230021Sed    defined(__mips_n64) || defined(__mips_o64))
60230021Sedsi_int __clzsi2(si_int);
61230021Sedsi_int __ctzsi2(si_int);
62230021Sed#define	__builtin_clz	__clzsi2
63230021Sed#define	__builtin_ctz	__ctzsi2
64230021Sed#endif
65230021Sed
66214152Sed#endif /* INT_LIB_H */
67