qmp-events: move 'QUORUM_REPORT_BAD' doc to schema
[qemu/ar7.git] / target / ppc / internal.h
blob1ff4896c45b32725153cd0877b3cea0b1b3c1339
1 /*
2 * PowerPC interal definitions for qemu.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 #ifndef PPC_INTERNAL_H
19 #define PPC_INTERNAL_H
21 #define FUNC_MASK(name, ret_type, size, max_val) \
22 static inline ret_type name(uint##size##_t start, \
23 uint##size##_t end) \
24 { \
25 ret_type ret, max_bit = size - 1; \
27 if (likely(start == 0)) { \
28 ret = max_val << (max_bit - end); \
29 } else if (likely(end == max_bit)) { \
30 ret = max_val >> start; \
31 } else { \
32 ret = (((uint##size##_t)(-1ULL)) >> (start)) ^ \
33 (((uint##size##_t)(-1ULL) >> (end)) >> 1); \
34 if (unlikely(start > end)) { \
35 return ~ret; \
36 } \
37 } \
39 return ret; \
42 #if defined(TARGET_PPC64)
43 FUNC_MASK(MASK, target_ulong, 64, UINT64_MAX);
44 #else
45 FUNC_MASK(MASK, target_ulong, 32, UINT32_MAX);
46 #endif
47 FUNC_MASK(mask_u32, uint32_t, 32, UINT32_MAX);
48 FUNC_MASK(mask_u64, uint64_t, 64, UINT64_MAX);
50 #endif /* PPC_INTERNAL_H */