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