xref: /qemu/include/exec/target_long.h (revision 7bdd67a56036123b52048af45d304a2c926daa8a)
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  #elif TARGET_LONG_SIZE == 8
33  typedef int64_t target_long;
34  typedef uint64_t target_ulong;
35  #define TARGET_FMT_lx "%016" PRIx64
36  #define TARGET_FMT_ld "%" PRId64
37  #define TARGET_FMT_lu "%" PRIu64
38  #else
39  #error TARGET_LONG_SIZE undefined
40  #endif
41  
42  #endif /* _TARGET_LONG_H_ */
43