aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-06-28 16:23:00 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-07-09 00:55:48 +0200
commita52ccc23e3c97e752cfabe7edebe05331b0d94e4 (patch)
treee7c5e5d96fa021a98460428e0188d78d006330f7
parentc9676a3b0349a1053c673243af52a2ef1b272bd7 (diff)
downloadsparse-a52ccc23e3c97e752cfabe7edebe05331b0d94e4.tar.gz
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 <luc.vanoostenryck@gmail.com>
-rw-r--r--target-x86.c52
1 files 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,
};