]>
Commit | Line | Data |
---|---|---|
d799c028 HL |
1 | /**\r |
2 | University of Illinois/NCSA\r | |
3 | Open Source License\r | |
4 | \r | |
5 | Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT\r | |
6 | \r | |
7 | All rights reserved.\r | |
8 | \r | |
9 | Developed by:\r | |
10 | \r | |
11 | LLVM Team\r | |
12 | \r | |
13 | University of Illinois at Urbana-Champaign\r | |
14 | \r | |
15 | http://llvm.org\r | |
16 | \r | |
17 | Permission is hereby granted, free of charge, to any person obtaining a copy of\r | |
18 | this software and associated documentation files (the "Software"), to deal with\r | |
19 | the Software without restriction, including without limitation the rights to\r | |
20 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\r | |
21 | of the Software, and to permit persons to whom the Software is furnished to do\r | |
22 | so, subject to the following conditions:\r | |
23 | \r | |
24 | * Redistributions of source code must retain the above copyright notice,\r | |
25 | this list of conditions and the following disclaimers.\r | |
26 | \r | |
27 | * Redistributions in binary form must reproduce the above copyright notice,\r | |
28 | this list of conditions and the following disclaimers in the\r | |
29 | documentation and/or other materials provided with the distribution.\r | |
30 | \r | |
31 | * Neither the names of the LLVM Team, University of Illinois at\r | |
32 | Urbana-Champaign, nor the names of its contributors may be used to\r | |
33 | endorse or promote products derived from this Software without specific\r | |
34 | prior written permission.\r | |
35 | \r | |
36 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r | |
37 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r | |
38 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r | |
39 | CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r | |
40 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r | |
41 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE\r | |
42 | SOFTWARE.\r | |
43 | **/\r | |
44 | \r | |
45 | #include "int_lib.h"\r | |
46 | \r | |
47 | /* Returns: convert a to a unsigned int, rounding toward zero.\r | |
48 | * Negative values all become zero.\r | |
49 | */\r | |
50 | \r | |
51 | /* Assumption: double is a IEEE 64 bit floating point type\r | |
52 | * su_int is a 32 bit integral type\r | |
53 | * value in double is representable in su_int or is negative\r | |
54 | * (no range checking performed)\r | |
55 | */\r | |
56 | \r | |
57 | /* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */\r | |
58 | \r | |
59 | ARM_EABI_FNALIAS(d2uiz, fixunsdfsi)\r | |
60 | \r | |
61 | COMPILER_RT_ABI su_int\r | |
62 | __fixunsdfsi(double a)\r | |
63 | {\r | |
64 | double_bits fb;\r | |
65 | fb.f = a;\r | |
66 | int e = ((fb.u.s.high & 0x7FF00000) >> 20) - 1023;\r | |
67 | if (e < 0 || (fb.u.s.high & 0x80000000))\r | |
68 | return 0;\r | |
69 | return (\r | |
70 | 0x80000000u |\r | |
71 | ((fb.u.s.high & 0x000FFFFF) << 11) |\r | |
72 | (fb.u.s.low >> 21)\r | |
73 | ) >> (31 - e);\r | |
74 | }\r |