aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/target.c
blob: 12cd219a3b694985e7ab347a531479ec98e7cccd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include <stdio.h>

#include "symbol.h"
#include "target.h"
#include "machine.h"

struct symbol *size_t_ctype = &uint_ctype;
struct symbol *ssize_t_ctype = &int_ctype;
struct symbol *intmax_ctype = &llong_ctype;
struct symbol *uintmax_ctype = &ullong_ctype;
struct symbol *int64_ctype = &long_ctype;
struct symbol *uint64_ctype = &ulong_ctype;
struct symbol *int32_ctype = &int_ctype;
struct symbol *uint32_ctype = &uint_ctype;
struct symbol *wchar_ctype = &int_ctype;
struct symbol *wint_ctype = &uint_ctype;

/*
 * For "__attribute__((aligned))"
 */
int max_alignment = 16;

/*
 * Integer data types
 */
int bits_in_bool = 1;
int bits_in_char = 8;
int bits_in_short = 16;
int bits_in_int = 32;
int bits_in_long = 32;
int bits_in_longlong = 64;
int bits_in_longlonglong = 128;

int max_int_alignment = 4;

/*
 * Floating point data types
 */
int bits_in_float = 32;
int bits_in_double = 64;
int bits_in_longdouble = 80;

int max_fp_alignment = 8;

/*
 * Pointer data type
 */
int bits_in_pointer = 32;
int pointer_alignment = 4;

/*
 * Enum data types
 */
int bits_in_enum = 32;
int enum_alignment = 4;


void init_target(void)
{
	switch (arch_mach) {
	case MACH_X86_64:
		if (arch_m64 == ARCH_LP64)
			break;
		/* fall through */
	case MACH_I386:
	case MACH_M68K:
	case MACH_SPARC32:
	case MACH_PPC32:
		wchar_ctype = &long_ctype;
		break;
	case MACH_ARM:
	case MACH_ARM64:
		wchar_ctype = &uint_ctype;
		break;
	default:
		break;
	}

	switch (arch_mach) {
	case MACH_MIPS64:
		if (arch_m64 == ARCH_LP64)
			break;
		/* fall through */
	case MACH_M68K:
	case MACH_SPARC32:
	case MACH_PPC32:
	case MACH_MIPS32:
	case MACH_RISCV32:
		int32_ctype = &long_ctype;
		uint32_ctype = &ulong_ctype;
		break;
	default:
		break;
	}

#if defined(__CYGWIN__)
	wchar_ctype = &ushort_ctype;
#endif
#if defined(__FreeBSD__) || defined(__APPLE__)
	wint_ctype = &int_ctype;
#endif
#if defined(__APPLE__)
	int64_ctype = &llong_ctype;
	uint64_ctype = &ullong_ctype;
#endif
}