Indentation fix, cleanup.
[AROS.git] / arch / arm-all / arm-aeabi / l2d.c
blob175bb3133d328e05f3a4d8ab7bb229c87b538fef
1 /*
2 Copyright (C) 2009-2015, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <inttypes.h>
8 uint64_t __aeabi_ul2d(uint64_t val)
10 uint64_t exp = 0;
11 uint64_t result = 0;
13 if (val == 0)
14 return 0;
16 exp = __builtin_clzl(val);
18 if (exp <= 9)
19 val >>= (10 - exp);
20 else
21 val <<= (exp - 10);
23 if ((val & 1))
25 val ++;
26 if (0x40000000000000ULL == val) exp++;
29 val >>= 1;
30 val &= 0xfffffffffffffULL;
31 exp = 1022 + 64 - exp;
33 exp <<= 52;
34 result = val | exp;
36 return result;
39 uint64_t __aeabi_l2d(int64_t val)
41 if (val == 0)
42 return 0;
44 if (val < 0)
45 return (uint64_t)0x8000000000000000 | __aeabi_ul2d((uint64_t)-val);
46 else
47 return __aeabi_ul2d((uint64_t)val);