[ASan] Intercept CreateThread on Windows
[blocksruntime.git] / lib / floatdixf.c
blobebf62dba0584147dd9c8b9dcf91ab66eb51ba11f
1 /* ===-- floatdixf.c - Implement __floatdixf -------------------------------===
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 __floatdixf for the compiler_rt library.
12 * ===----------------------------------------------------------------------===
13 */
15 #if !_ARCH_PPC
17 #include "int_lib.h"
19 /* Returns: convert a to a long double, rounding toward even. */
21 /* Assumption: long double is a IEEE 80 bit floating point type padded to 128 bits
22 * di_int is a 64 bit integral type
25 /* gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
26 * 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
29 long double
30 __floatdixf(di_int a)
32 if (a == 0)
33 return 0.0;
34 const unsigned N = sizeof(di_int) * CHAR_BIT;
35 const di_int s = a >> (N-1);
36 a = (a ^ s) - s;
37 int clz = __builtin_clzll(a);
38 int e = (N - 1) - clz ; /* exponent */
39 long_double_bits fb;
40 fb.u.high.s.low = ((su_int)s & 0x00008000) | /* sign */
41 (e + 16383); /* exponent */
42 fb.u.low.all = a << clz; /* mantissa */
43 return fb.f;
46 #endif /* !_ARCH_PPC */