[ASan/Win tests] Bring back -GS- as SEH tests fail otherwise
[blocksruntime.git] / lib / builtins / fixunsxfdi.c
blob7224d467e7c9718202718e467c45c6b182d5b4c9
1 /* ===-- fixunsxfdi.c - Implement __fixunsxfdi -----------------------------===
3 * The LLVM Compiler Infrastructure
5 * This file is dual licensed under the MIT and the University of Illinois Open
6 * Source Licenses. See LICENSE.TXT for details.
8 * ===----------------------------------------------------------------------===
10 * This file implements __fixunsxfdi for the compiler_rt library.
12 * ===----------------------------------------------------------------------===
15 #if !_ARCH_PPC
17 #include "int_lib.h"
19 /* Returns: convert a to a unsigned long long, rounding toward zero.
20 * Negative values all become zero.
23 /* Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
24 * du_int is a 64 bit integral type
25 * value in long double is representable in du_int or is negative
26 * (no range checking performed)
29 /* gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
30 * 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
33 COMPILER_RT_ABI du_int
34 __fixunsxfdi(long double a)
36 long_double_bits fb;
37 fb.f = a;
38 int e = (fb.u.high.s.low & 0x00007FFF) - 16383;
39 if (e < 0 || (fb.u.high.s.low & 0x00008000))
40 return 0;
41 return fb.u.low.all >> (63 - e);
44 #endif