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