Linux-Sparse Archive on lore.kernel.org
 help / color / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 1/9] x86: reorg the target file
Date: Thu,  9 Jul 2020 01:41:43 +0200
Message-ID: <20200708234151.57845-2-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20200708234151.57845-1-luc.vanoostenryck@gmail.com>

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>
---
 target-x86.c | 52 +++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 35 insertions(+), 17 deletions(-)

diff --git a/target-x86.c b/target-x86.c
index d770349c27e7..01117bb6ecc8 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,
 };
-- 
2.27.0


  reply index

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-08 23:41 [PATCH 0/9] OS-specific small fixes & cleanup Luc Van Oostenryck
2020-07-08 23:41 ` Luc Van Oostenryck [this message]
2020-07-08 23:41 ` [PATCH 2/9] arch: add an option to specify the OS: --os=$OS Luc Van Oostenryck
2020-07-08 23:41 ` [PATCH 3/9] predefine: add __linux__ & __linux Luc Van Oostenryck
2020-07-08 23:41 ` [PATCH 4/9] predefine: no __unix__ for Darwin Luc Van Oostenryck
2020-07-08 23:41 ` [PATCH 5/9] x86: fixes types for NetBSD & OpenBSD Luc Van Oostenryck
2020-07-08 23:41 ` [PATCH 6/9] sparc: char are unsigned on Solaris Luc Van Oostenryck
2020-07-08 23:41 ` [PATCH 7/9] arch: add predefines for OS identification Luc Van Oostenryck
2020-07-08 23:41 ` [PATCH 8/9] cygwin: add the predefines '__cdecl', Luc Van Oostenryck
2020-07-08 23:41 ` [PATCH 9/9] cgcc: remove now unneeded options & defines Luc Van Oostenryck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200708234151.57845-2-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Sparse Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-sparse/0 linux-sparse/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-sparse linux-sparse/ https://lore.kernel.org/linux-sparse \
		linux-sparse@vger.kernel.org
	public-inbox-index linux-sparse

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-sparse


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git