Skip to contentSkip to conversation

qemu 1.7.0 does not build on NetBSD (patch)

Qemu-devel Applied Martin Husemann 7 participants 8 messages Dec 17, 2013 – Jan 21, 2014

lore
Share & tools
lore
#0 lore raw

On NetBSD int8_t and friends are preprocessor macros expanding to __int8_t (which is a typedef provided by machine dependent headers).

include/exec/softmmu_template.h tries to safe 3 lines of code by using preprosseor concatenation, which only will work if int8_t is not a define, or defined to int8_t.

The attached patch fixes this.

Martin

Do not rely on int8_t (and friends) not being preprocessor symbols (or symbols expanding to themselves). On NetBSD (for example) the glue(u, SDATA_TYPE) results in u__int8_t, which is undefined. There is no way to stop cpp expanding inner macros, so just add the few lines explicitly and get rid of the magic.

exec/softmmu_template.h renamed from exec/softmmu_template.h.orig +4 -1
@@ -30,23 +30,26 @@
 #define SUFFIX q
 #define LSUFFIX q
 #define SDATA_TYPE  int64_t
+#define DATA_TYPE  uint64_t
 #elif DATA_SIZE == 4
 #define SUFFIX l
 #define LSUFFIX l
 #define SDATA_TYPE  int32_t
+#define DATA_TYPE  uint32_t
 #elif DATA_SIZE == 2
 #define SUFFIX w
 #define LSUFFIX uw
 #define SDATA_TYPE  int16_t
+#define DATA_TYPE  uint16_t
 #elif DATA_SIZE == 1
 #define SUFFIX b
 #define LSUFFIX ub
 #define SDATA_TYPE  int8_t
+#define DATA_TYPE  uint8_t
 #else
 #error unsupported data size
 #endif
 
-#define DATA_TYPE   glue(u, SDATA_TYPE)
 
 /* For the benefit of TCG generated code, we want to avoid the complication
    of ABI-specific return type promotion and always return a value extended
#1 lore raw

Il 17/12/2013 09:55, Martin Husemann ha scritto:

Quoted 8 lines

On NetBSD int8_t and friends are preprocessor macros expanding to __int8_t (which is a typedef provided by machine dependent headers).

include/exec/softmmu_template.h tries to safe 3 lines of code by using preprosseor concatenation, which only will work if int8_t is not a define, or defined to int8_t.

The attached patch fixes this.

Hi Martin, the patch looks good, but please resend it according to the rules in http://wiki.qemu.org/Contribute/SubmitAPatch - thanks!

Paolo

#2 lore raw

Il 17/12/2013 11:15, Paolo Bonzini ha scritto:

Quoted 4 lines

Il 17/12/2013 09:55, Martin Husemann ha scritto:

Quoted 3 lines

On NetBSD int8_t and friends are preprocessor macros expanding to __int8_t (which is a typedef provided by machine dependent headers).

Quoted 8 lines
Quoted 5 lines

include/exec/softmmu_template.h tries to safe 3 lines of code by using preprosseor concatenation, which only will work if int8_t is not a define, or defined to int8_t.

The attached patch fixes this.

Hi Martin, the patch looks good, but please resend it according to the rules in http://wiki.qemu.org/Contribute/SubmitAPatch - thanks!

Ping?

Paolo

#3 lore raw

PATCH v2 1/1 qemu 1.7.0 does not build on NetBSD

Do not rely on int8_t (and friends) not being preprocessor symbols (or symbols expanding to themselves). On NetBSD (for example) the glue(u, SDATA_TYPE) results in u__int8_t, which is undefined. There is no way to stop cpp expanding inner macros, so just add the few lines explicitly and get rid of the magic.

---
 include/exec/softmmu_template.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
include/exec/softmmu_template.h +4 -1
index c6a5440..8712dcd 100644
@@ -30,23 +30,26 @@
 #define SUFFIX q
 #define LSUFFIX q
 #define SDATA_TYPE  int64_t
+#define DATA_TYPE  uint64_t
 #elif DATA_SIZE == 4
 #define SUFFIX l
 #define LSUFFIX l
 #define SDATA_TYPE  int32_t
+#define DATA_TYPE  uint32_t
 #elif DATA_SIZE == 2
 #define SUFFIX w
 #define LSUFFIX uw
 #define SDATA_TYPE  int16_t
+#define DATA_TYPE  uint16_t
 #elif DATA_SIZE == 1
 #define SUFFIX b
 #define LSUFFIX ub
 #define SDATA_TYPE  int8_t
+#define DATA_TYPE  uint8_t
 #else
 #error unsupported data size
 #endif
 
-#define DATA_TYPE   glue(u, SDATA_TYPE)
 
 /* For the benefit of TCG generated code, we want to avoid the complication
    of ABI-specific return type promotion and always return a value extended
Signature · 1 line
1.8.5.3
Reviewed-by on v2 1/1
#4 lore raw

Re: [Qemu-devel] [PATCH v2] qemu 1.7.0 does not build on NetBSD

Quoted 7 lines · Martin Husemann

Do not rely on int8_t (and friends) not being preprocessor symbols (or symbols expanding to themselves). On NetBSD (for example) the glue(u, SDATA_TYPE) results in u__int8_t, which is undefined. There is no way to stop cpp expanding inner macros, so just add the few lines explicitly and get rid of the magic.

This was introduced in commit c8f94df593.
Richard, do you want to take this fix via the tcg tree, or should it go via trivial?

Quoted 37 lines
---
 include/exec/softmmu_template.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
include/exec/softmmu_template.h +4 -2
index c6a5440..8712dcd 100644
@@ -30,23 +30,26 @@
 #define SUFFIX q
 #define LSUFFIX q
 #define SDATA_TYPE  int64_t
+#define DATA_TYPE  uint64_t
 #elif DATA_SIZE == 4
 #define SUFFIX l
 #define LSUFFIX l
 #define SDATA_TYPE  int32_t
+#define DATA_TYPE  uint32_t
 #elif DATA_SIZE == 2
 #define SUFFIX w
 #define LSUFFIX uw
 #define SDATA_TYPE  int16_t
+#define DATA_TYPE  uint16_t
 #elif DATA_SIZE == 1
 #define SUFFIX b
 #define LSUFFIX ub
 #define SDATA_TYPE  int8_t
+#define DATA_TYPE  uint8_t
 #else
 #error unsupported data size
 #endif
 
-#define DATA_TYPE   glue(u, SDATA_TYPE)
 
 /* For the benefit of TCG generated code, we want to avoid the complication
    of ABI-specific return type promotion and always return a value extended
--
Quoted 1 line

1.8.5.3

thanks
-- PMM

#5 lore raw

Re: [Qemu-devel] [PATCH v2] qemu 1.7.0 does not build on NetBSD

Quoted 7 lines · Peter Maydell
Quoted 6 lines · Martin Husemann

Do not rely on int8_t (and friends) not being preprocessor symbols (or symbols expanding to themselves). On NetBSD (for example) the glue(u, SDATA_TYPE) results in u__int8_t, which is undefined. There is no way to stop cpp expanding inner macros, so just add the few lines explicitly and get rid of the magic.

Quoted 7 lines
Quoted 1 line

This was introduced in commit c8f94df593.
Richard, do you want to take this fix via the tcg tree, or should it go via trivial?

Trivial is fine. Saves me the effort. ;-)

r~

Reviewed-by on v2 1/1
#6 lore raw

Re: [Qemu-devel] [PATCH v2] qemu 1.7.0 does not build on NetBSD

In reply to Martin Husemann

Am 18.01.2014 14:47, schrieb Martin Husemann:

Quoted 7 lines

Do not rely on int8_t (and friends) not being preprocessor symbols (or symbols expanding to themselves). On NetBSD (for example) the glue(u, SDATA_TYPE) results in u__int8_t, which is undefined. There is no way to stop cpp expanding inner macros, so just add the few lines explicitly and get rid of the magic.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#7 lore raw

Re: [Qemu-devel] [PATCH v2] qemu 1.7.0 does not build on NetBSD

In reply to Martin Husemann
Quoted 5 lines · Martin Husemann

Do not rely on int8_t (and friends) not being preprocessor symbols (or symbols expanding to themselves). On NetBSD (for example) the glue(u, SDATA_TYPE) results in u__int8_t, which is undefined. There is no way to stop cpp expanding inner macros, so just add the few lines explicitly and get rid of the magic.

Thanks, applied to the trivial-patches queue.

/mjt