]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/builtins/fixunsdfdi.c
MFV ntp-4.2.8p4 (r289715)
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / builtins / fixunsdfdi.c
1 /* ===-- fixunsdfdi.c - Implement __fixunsdfdi -----------------------------===
2  *
3  *                     The LLVM Compiler Infrastructure
4  *
5  * This file is dual licensed under the MIT and the University of Illinois Open
6  * Source Licenses. See LICENSE.TXT for details.
7  *
8  * ===----------------------------------------------------------------------===
9  */
10
11 #define DOUBLE_PRECISION
12 #include "fp_lib.h"
13
14 ARM_EABI_FNALIAS(d2ulz, fixunsdfdi)
15
16 #ifndef __SOFT_FP__
17 /* Support for systems that have hardware floating-point; can set the invalid
18  * flag as a side-effect of computation.
19  */
20
21 COMPILER_RT_ABI du_int
22 __fixunsdfdi(double a)
23 {
24     if (a <= 0.0) return 0;
25     su_int high = a/0x1p32f;
26     su_int low = a - (double)high*0x1p32f;
27     return ((du_int)high << 32) | low;
28 }
29
30 #else
31 /* Support for systems that don't have hardware floating-point; there are no
32  * flags to set, and we don't want to code-gen to an unknown soft-float
33  * implementation.
34  */
35
36 typedef du_int fixuint_t;
37 #include "fp_fixuint_impl.inc"
38
39 COMPILER_RT_ABI du_int
40 __fixunsdfdi(fp_t a) {
41     return __fixuint(a);
42 }
43
44 #endif