xref: /openbmc/qemu/include/exec/target_long.h (revision 2e1cacfb)
1 /*
2  * Target Long Definitions
3  *
4  * Copyright (c) 2003 Fabrice Bellard
5  * Copyright (c) 2023 Linaro Ltd
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  */
9 
10 #ifndef _TARGET_LONG_H_
11 #define _TARGET_LONG_H_
12 
13 /*
14  * Usually this should only be included via cpu-defs.h however for
15  * certain cases where we want to build only two versions of a binary
16  * object we can include directly. However the build-system must
17  * ensure TARGET_LONG_BITS is defined directly.
18  */
19 #ifndef TARGET_LONG_BITS
20 #error TARGET_LONG_BITS not defined
21 #endif
22 
23 #define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8)
24 
25 /* target_ulong is the type of a virtual address */
26 #if TARGET_LONG_SIZE == 4
27 typedef int32_t target_long;
28 typedef uint32_t target_ulong;
29 #define TARGET_FMT_lx "%08x"
30 #define TARGET_FMT_ld "%d"
31 #define TARGET_FMT_lu "%u"
32 #define MO_TL MO_32
33 #elif TARGET_LONG_SIZE == 8
34 typedef int64_t target_long;
35 typedef uint64_t target_ulong;
36 #define TARGET_FMT_lx "%016" PRIx64
37 #define TARGET_FMT_ld "%" PRId64
38 #define TARGET_FMT_lu "%" PRIu64
39 #define MO_TL MO_64
40 #else
41 #error TARGET_LONG_SIZE undefined
42 #endif
43 
44 #endif /* _TARGET_LONG_H_ */
45