]>
Commit | Line | Data |
---|---|---|
1e57a462 | 1 | /** @file\r |
2 | \r | |
3 | Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r | |
4 | \r | |
4059386c | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
1e57a462 | 6 | \r |
7 | **/\r | |
8 | /**\r | |
9 | University of Illinois/NCSA\r | |
10 | Open Source License\r | |
3402aac7 | 11 | \r |
1e57a462 | 12 | Copyright (c) 2003-2008 University of Illinois at Urbana-Champaign.\r |
13 | All rights reserved.\r | |
3402aac7 | 14 | \r |
1e57a462 | 15 | Developed by:\r |
3402aac7 | 16 | \r |
1e57a462 | 17 | LLVM Team\r |
3402aac7 | 18 | \r |
1e57a462 | 19 | University of Illinois at Urbana-Champaign\r |
3402aac7 | 20 | \r |
1e57a462 | 21 | http://llvm.org\r |
3402aac7 | 22 | \r |
1e57a462 | 23 | Permission is hereby granted, free of charge, to any person obtaining a copy of\r |
24 | this software and associated documentation files (the "Software"), to deal with\r | |
25 | the Software without restriction, including without limitation the rights to\r | |
26 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\r | |
27 | of the Software, and to permit persons to whom the Software is furnished to do\r | |
28 | so, subject to the following conditions:\r | |
3402aac7 | 29 | \r |
1e57a462 | 30 | * Redistributions of source code must retain the above copyright notice,\r |
31 | this list of conditions and the following disclaimers.\r | |
3402aac7 | 32 | \r |
1e57a462 | 33 | * Redistributions in binary form must reproduce the above copyright notice,\r |
34 | this list of conditions and the following disclaimers in the\r | |
35 | documentation and/or other materials provided with the distribution.\r | |
3402aac7 | 36 | \r |
1e57a462 | 37 | * Neither the names of the LLVM Team, University of Illinois at\r |
38 | Urbana-Champaign, nor the names of its contributors may be used to\r | |
39 | endorse or promote products derived from this Software without specific\r | |
40 | prior written permission.\r | |
3402aac7 | 41 | \r |
1e57a462 | 42 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r |
43 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r | |
44 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r | |
45 | CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r | |
46 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r | |
47 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE\r | |
48 | SOFTWARE.\r | |
49 | **/\r | |
50 | \r | |
51 | #include <Base.h>\r | |
52 | #include <Library/DebugLib.h>\r | |
53 | \r | |
54 | #define CHAR_BIT 8\r | |
55 | \r | |
56 | typedef union {\r | |
57 | INT64 all;\r | |
58 | struct {\r | |
59 | UINT32 low;\r | |
60 | INT32 high;\r | |
61 | };\r | |
62 | } dwords;\r | |
63 | \r | |
64 | typedef union {\r | |
65 | UINT64 all;\r | |
66 | struct {\r | |
67 | UINT32 low;\r | |
68 | UINT32 high;\r | |
69 | };\r | |
70 | } udwords;\r | |
71 | \r | |
72 | // __aeabi_ return values\r | |
73 | typedef struct {\r | |
74 | UINT64 Quotent;\r | |
75 | UINT64 Remainder;\r | |
76 | } ulldiv_t;\r | |
77 | \r | |
78 | typedef struct {\r | |
79 | INT64 Quotent;\r | |
80 | INT64 Remainder;\r | |
81 | } lldiv_t;\r | |
82 | \r | |
83 | typedef struct {\r | |
84 | UINT32 Quotent;\r | |
85 | UINT32 Remainder;\r | |
86 | } uidiv_return;\r | |
87 | \r | |
88 | #if __GNUC__\r | |
89 | #define COUNT_LEADING_ZEROS(_a) __builtin_clz((_a))\r | |
90 | #define COUNT_TRAILING_ZEROS(_a) __builtin_ctz((_a))\r | |
91 | #else\r | |
92 | #error COUNT_LEADING_ZEROS() and COUNT_TRAILING_ZEROS() macros not ported to your compiler\r | |
93 | #endif\r |