aboutsummaryrefslogtreecommitdiff
path: root/targ.c
blob: 5a2f806225786809e49d9a675f5455d9c11a3bca (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
#include <stdint.h>
#include <string.h>
#include "util.h"
#include "cc.h"

struct target *targ;

static struct target alltargs[] = {
	{
		.name = "x86_64",
		.typewchar = &typeint,
	},
	{
		.name = "aarch64",
		.typewchar = &typeuint,
	},
};

void
targinit(const char *name)
{
	size_t i;

	if (!name) {
		/* TODO: provide a way to set this default */
		targ = &alltargs[0];
		return;
	}
	for (i = 0; i < LEN(alltargs); ++i) {
		if (strcmp(alltargs[i].name, name) == 0) {
			targ = &alltargs[i];
			return;
		}
	}
	fatal("unknown target '%s'", name);
}