xref: /qemu/include/exec/user/abitypes.h (revision 6e0dc9d2)
1 #ifndef EXEC_USER_ABITYPES_H
2 #define EXEC_USER_ABITYPES_H
3 
4 #include "cpu.h"
5 
6 #ifdef TARGET_ABI32
7 #define TARGET_ABI_BITS 32
8 #else
9 #define TARGET_ABI_BITS TARGET_LONG_BITS
10 #endif
11 
12 #ifdef TARGET_M68K
13 #define ABI_INT_ALIGNMENT 2
14 #define ABI_LONG_ALIGNMENT 2
15 #define ABI_LLONG_ALIGNMENT 2
16 #endif
17 
18 #ifdef TARGET_CRIS
19 #define ABI_SHORT_ALIGNMENT 1
20 #define ABI_INT_ALIGNMENT 1
21 #define ABI_LONG_ALIGNMENT 1
22 #define ABI_LLONG_ALIGNMENT 1
23 #endif
24 
25 #if (defined(TARGET_I386) && !defined(TARGET_X86_64)) \
26     || defined(TARGET_SH4) \
27     || defined(TARGET_OPENRISC) \
28     || defined(TARGET_MICROBLAZE) \
29     || defined(TARGET_NIOS2)
30 #define ABI_LLONG_ALIGNMENT 4
31 #endif
32 
33 #ifndef ABI_SHORT_ALIGNMENT
34 #define ABI_SHORT_ALIGNMENT 2
35 #endif
36 #ifndef ABI_INT_ALIGNMENT
37 #define ABI_INT_ALIGNMENT 4
38 #endif
39 #ifndef ABI_LONG_ALIGNMENT
40 #define ABI_LONG_ALIGNMENT (TARGET_ABI_BITS / 8)
41 #endif
42 #ifndef ABI_LLONG_ALIGNMENT
43 #define ABI_LLONG_ALIGNMENT 8
44 #endif
45 
46 typedef int16_t abi_short __attribute__ ((aligned(ABI_SHORT_ALIGNMENT)));
47 typedef uint16_t abi_ushort __attribute__((aligned(ABI_SHORT_ALIGNMENT)));
48 typedef int32_t abi_int __attribute__((aligned(ABI_INT_ALIGNMENT)));
49 typedef uint32_t abi_uint __attribute__((aligned(ABI_INT_ALIGNMENT)));
50 typedef int64_t abi_llong __attribute__((aligned(ABI_LLONG_ALIGNMENT)));
51 typedef uint64_t abi_ullong __attribute__((aligned(ABI_LLONG_ALIGNMENT)));
52 
53 #ifdef TARGET_ABI32
54 typedef uint32_t abi_ulong __attribute__((aligned(ABI_LONG_ALIGNMENT)));
55 typedef int32_t abi_long __attribute__((aligned(ABI_LONG_ALIGNMENT)));
56 #define TARGET_ABI_FMT_lx "%08x"
57 #define TARGET_ABI_FMT_ld "%d"
58 #define TARGET_ABI_FMT_lu "%u"
59 
60 static inline abi_ulong tswapal(abi_ulong v)
61 {
62     return tswap32(v);
63 }
64 
65 #else
66 typedef target_ulong abi_ulong __attribute__((aligned(ABI_LONG_ALIGNMENT)));
67 typedef target_long abi_long __attribute__((aligned(ABI_LONG_ALIGNMENT)));
68 #define TARGET_ABI_FMT_lx TARGET_FMT_lx
69 #define TARGET_ABI_FMT_ld TARGET_FMT_ld
70 #define TARGET_ABI_FMT_lu TARGET_FMT_lu
71 /* for consistency, define ABI32 too */
72 #if TARGET_ABI_BITS == 32
73 #define TARGET_ABI32 1
74 #endif
75 
76 static inline abi_ulong tswapal(abi_ulong v)
77 {
78     return tswapl(v);
79 }
80 
81 #endif
82 #endif
83