From a52ccc23e3c97e752cfabe7edebe05331b0d94e4 Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Sun, 28 Jun 2020 16:23:00 +0200 Subject: x86: reorg the target file More, specifically, split the 'init' method into a common part and add one for each of the i386 (32-bit) and another one for 64-bit. Signed-off-by: Luc Van Oostenryck --- target-x86.c | 52 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/target-x86.c b/target-x86.c index d770349c..01117bb6 100644 --- a/target-x86.c +++ b/target-x86.c @@ -3,17 +3,28 @@ #include "machine.h" -static void init_x86(const struct target *target) +static void predefine_i386(const struct target *self) +{ + predefine("__i386__", 1, "1"); + predefine("__i386", 1, "1"); + predefine_nostd("i386"); +} + +static void predefine_x86_64(const struct target *self) +{ + predefine("__x86_64__", 1, "1"); + predefine("__x86_64", 1, "1"); + predefine("__amd64__", 1, "1"); + predefine("__amd64", 1, "1"); +} + + +static void init_x86_common(const struct target *target) { switch (arch_os) { case OS_CYGWIN: wchar_ctype = &ushort_ctype; break; - case OS_DARWIN: - int64_ctype = &llong_ctype; - uint64_ctype = &ullong_ctype; - wint_ctype = &int_ctype; - break; case OS_FREEBSD: wint_ctype = &int_ctype; break; @@ -25,11 +36,9 @@ static void init_x86(const struct target *target) } -static void predefine_i386(const struct target *self) +static void init_i386(const struct target *target) { - predefine("__i386__", 1, "1"); - predefine("__i386", 1, "1"); - predefine_nostd("i386"); + init_x86_common(target); } const struct target target_i386 = { @@ -42,19 +51,28 @@ const struct target target_i386 = { .bits_in_longdouble = 96, .max_fp_alignment = 4, - .init = init_x86, .target_64bit = &target_x86_64, + .init = init_i386, .predefine = predefine_i386, }; -static void predefine_x86_64(const struct target *self) +static void init_x86_64(const struct target *target) { - predefine("__x86_64__", 1, "1"); - predefine("__x86_64", 1, "1"); - predefine("__amd64__", 1, "1"); - predefine("__amd64", 1, "1"); + init_x86_common(target); + + switch (arch_os) { + case OS_CYGWIN: + break; + case OS_DARWIN: + int64_ctype = &llong_ctype; + uint64_ctype = &ullong_ctype; + wint_ctype = &int_ctype; + break; + case OS_FREEBSD: + break; + } } const struct target target_x86_64 = { @@ -67,8 +85,8 @@ const struct target target_x86_64 = { .bits_in_longdouble = 128, .max_fp_alignment = 16, - .init = init_x86, .target_32bit = &target_i386, + .init = init_x86_64, .predefine = predefine_x86_64, }; -- cgit 1.2.3-korg