Patchwork poison TARGET_<ARCH> for compile once.

login
register
mail settings
Submitter Isaku Yamahata
Date June 24, 2010, 7:14 a.m.
Message ID <20100624071452.GB4498@valinux.co.jp>
Download mbox | patch
Permalink /patch/56761/
State New
Headers show

Comments

Isaku Yamahata - June 24, 2010, 7:14 a.m.
Sorry, I sent out the old patch. Here is the right one.

Subject: [PATCH] poison TARGET_arch for compile once.

poison TARGET_arch for compile once object
to prevent those ifdef from creeping in again.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 Makefile        |    6 +++---
 Makefile.objs   |   11 ++++++++++-
 Makefile.target |    4 ++--
 poison-arch.h   |   25 +++++++++++++++++++++++++
 poison.h        |   16 +---------------
 5 files changed, 41 insertions(+), 21 deletions(-)
 create mode 100644 poison-arch.h
Paolo Bonzini - June 24, 2010, 11:09 a.m.
On 06/24/2010 09:14 AM, Isaku Yamahata wrote:
> Sorry, I sent out the old patch. Here is the right one.
>
> Subject: [PATCH] poison TARGET_arch for compile once.
>
> poison TARGET_arch for compile once object
> to prevent those ifdef from creeping in again.

Why do you need to split poison.h?  Are there identifiers that are not 
in your new poison-arch.h and can be legitimately used in 
target-independent code?

Paolo
Richard Henderson - June 24, 2010, 6:41 p.m.
On 06/24/2010 12:14 AM, Isaku Yamahata wrote:
>  QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
>  obj-y = main.o syscall.o strace.o mmap.o signal.o thunk.o \
> -      elfload.o linuxload.o uaccess.o gdbstub.o cpu-uname.o \
> -      qemu-malloc.o
> +      elfload.o linuxload.o uaccess.o gdbstub.o cpu-uname.o
>  
>  obj-$(TARGET_HAS_BFLT) += flatload.o
>  
> @@ -302,6 +301,7 @@ obj-y += $(addprefix $(HWDIR)/, $(hw-obj-y))
>  
>  endif # CONFIG_SOFTMMU
>  
> +obj-y += qemu-malloc.o
>  obj-$(CONFIG_GDBSTUB_XML) += gdbstub-xml.o
>  

Does this break BSD compile?  That host still has qemu_malloc 
defined in bsd-user/mmap.c.


r~

Patch

diff --git a/Makefile b/Makefile
index 221fbd8..6a55b86 100644
--- a/Makefile
+++ b/Makefile
@@ -137,11 +137,11 @@  iov.o: iov.c iov.h
 qemu-img.o: qemu-img-cmds.h
 qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o: $(GENERATED_HEADERS)
 
-qemu-img$(EXESUF): qemu-img.o qemu-tool.o qemu-error.o $(block-obj-y) $(qobject-obj-y)
+qemu-img$(EXESUF): qemu-img.o qemu-tool.o qemu-error.o qemu-malloc.o $(block-obj-y) $(qobject-obj-y)
 
-qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o qemu-error.o $(block-obj-y) $(qobject-obj-y)
+qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o qemu-error.o qemu-malloc.o $(block-obj-y) $(qobject-obj-y)
 
-qemu-io$(EXESUF): qemu-io.o cmd.o qemu-tool.o qemu-error.o $(block-obj-y) $(qobject-obj-y)
+qemu-io$(EXESUF): qemu-io.o cmd.o qemu-tool.o qemu-error.o qemu-malloc.o $(block-obj-y) $(qobject-obj-y)
 
 qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
 	$(call quiet-command,sh $(SRC_PATH)/hxtool -h < $< > $@,"  GEN   $@")
diff --git a/Makefile.objs b/Makefile.objs
index 53fb68e..5674922 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -7,7 +7,7 @@  qobject-obj-y += qerror.o
 #######################################################################
 # block-obj-y is code used by both qemu system emulation and qemu-img
 
-block-obj-y = cutils.o cache-utils.o qemu-malloc.o qemu-option.o module.o
+block-obj-y = cutils.o cache-utils.o qemu-option.o module.o
 block-obj-y += nbd.o block.o aio.o aes.o osdep.o qemu-config.o
 block-obj-$(CONFIG_POSIX) += posix-aio-compat.o
 block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
@@ -265,3 +265,12 @@  os-win32.o: qemu-options.def
 qemu-options.def: $(SRC_PATH)/qemu-options.hx
 	$(call quiet-command,sh $(SRC_PATH)/hxtool -h < $< > $@,"  GEN   $(TARGET_DIR)$@")
 
+
+######################################################################
+# poison TARGET_arch to prevent from creeping those defines again.
+
+POISON_CFLAGS = -include poison-arch.h
+$(qobject-obj-y) $(block-obj-y) $(block-nested-y) $(block-obj-y) \
+$(net-obj-y) $(net-nested-y) $(fsdev-nested-y) $(fsdev-obj-y) \
+$(common-obj-y) $(audio-obj-y) $(slirp-obj-y) $(user-obj-y) \
+$(hw-obj-y) $(sound-obj-y) $(libdis-y) vl.o: QEMU_CFLAGS += $(POISON_CFLAGS)
diff --git a/Makefile.target b/Makefile.target
index f64702b..3475ce5 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -85,8 +85,7 @@  $(call set-vpath, $(SRC_PATH)/linux-user:$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR
 
 QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
 obj-y = main.o syscall.o strace.o mmap.o signal.o thunk.o \
-      elfload.o linuxload.o uaccess.o gdbstub.o cpu-uname.o \
-      qemu-malloc.o
+      elfload.o linuxload.o uaccess.o gdbstub.o cpu-uname.o
 
 obj-$(TARGET_HAS_BFLT) += flatload.o
 
@@ -302,6 +301,7 @@  obj-y += $(addprefix $(HWDIR)/, $(hw-obj-y))
 
 endif # CONFIG_SOFTMMU
 
+obj-y += qemu-malloc.o
 obj-$(CONFIG_GDBSTUB_XML) += gdbstub-xml.o
 
 $(QEMU_PROG): $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y)
diff --git a/poison-arch.h b/poison-arch.h
new file mode 100644
index 0000000..8143c41
--- /dev/null
+++ b/poison-arch.h
@@ -0,0 +1,25 @@ 
+/* Poison identifiers that should not be used when building
+   target independent device code.  */
+
+#ifndef HW_POISON_ARCH_H
+#define HW_POISON_ARCH_H
+#ifdef __GNUC__
+
+#pragma GCC poison TARGET_I386
+#pragma GCC poison TARGET_X86_64
+#pragma GCC poison TARGET_ALPHA
+#pragma GCC poison TARGET_ARM
+#pragma GCC poison TARGET_CRIS
+#pragma GCC poison TARGET_M68K
+#pragma GCC poison TARGET_MIPS
+#pragma GCC poison TARGET_MIPS64
+#pragma GCC poison TARGET_PPC
+#pragma GCC poison TARGET_PPCEMB
+#pragma GCC poison TARGET_PPC64
+#pragma GCC poison TARGET_ABI32
+#pragma GCC poison TARGET_SH4
+#pragma GCC poison TARGET_SPARC
+#pragma GCC poison TARGET_SPARC64
+
+#endif
+#endif
diff --git a/poison.h b/poison.h
index d7db7f4..f9efae9 100644
--- a/poison.h
+++ b/poison.h
@@ -5,21 +5,7 @@ 
 #define HW_POISON_H
 #ifdef __GNUC__
 
-#pragma GCC poison TARGET_I386
-#pragma GCC poison TARGET_X86_64
-#pragma GCC poison TARGET_ALPHA
-#pragma GCC poison TARGET_ARM
-#pragma GCC poison TARGET_CRIS
-#pragma GCC poison TARGET_M68K
-#pragma GCC poison TARGET_MIPS
-#pragma GCC poison TARGET_MIPS64
-#pragma GCC poison TARGET_PPC
-#pragma GCC poison TARGET_PPCEMB
-#pragma GCC poison TARGET_PPC64
-#pragma GCC poison TARGET_ABI32
-#pragma GCC poison TARGET_SH4
-#pragma GCC poison TARGET_SPARC
-#pragma GCC poison TARGET_SPARC64
+#include "poison-arch.h"
 
 #pragma GCC poison TARGET_WORDS_BIGENDIAN
 #pragma GCC poison BSWAP_NEEDED