Skip to contentSkip to conversation

tools/libxl: Fix building against libxl for LIBXL_API_VERSION < 0x040500

PATCH In review Andrew Cooper 4 participants 10 messages Oct 17, 2014 – Oct 23, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/libxl: Fix building against libxl for LIBXL_API_VERSION < 0x040500

c/s 6276f66ebe "libxl: libxl_uuid_copy now takes a ctx argument" introduces API compatibiltiy for libxl_uuid_copy() which sadly is not valid C. Fix it.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/libxl/libxl_uuid.h |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/libxl/libxl_uuid.h +6 -1
index 196b5bc..c5041c7 100644
@@ -61,7 +61,12 @@ int libxl_uuid_from_string(libxl_uuid *uuid, const char *in);
 void libxl_uuid_copy(libxl_ctx *ctx_opt, libxl_uuid *dst,
                      const libxl_uuid *src);
 #if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x040500
-void libxl_uuid_copy(dst, src) libxl_uuid_copy(NULL, dst, src)
+void static inline libxl_uuid_copy_0x040400(libxl_uuid *dst,
+                                            const libxl_uuid *src)
+{
+    libxl_uuid_copy(NULL, dst, src);
+}
+#define libxl_uuid_copy libxl_uuid_copy_0x040400
 #endif
 
 void libxl_uuid_clear(libxl_uuid *uuid);
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Andrew Cooper

c/s 6276f66ebe "libxl: libxl_uuid_copy now takes a ctx argument" introduces API compatibiltiy for libxl_uuid_copy() which sadly is not valid C. Fix it.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
Quoted 24 lines
---
 tools/libxl/libxl_uuid.h |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/libxl/libxl_uuid.h +6 -1
index 196b5bc..c5041c7 100644
@@ -61,7 +61,12 @@ int libxl_uuid_from_string(libxl_uuid *uuid, const char *in);
 void libxl_uuid_copy(libxl_ctx *ctx_opt, libxl_uuid *dst,
                      const libxl_uuid *src);
 #if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x040500
-void libxl_uuid_copy(dst, src) libxl_uuid_copy(NULL, dst, src)
+void static inline libxl_uuid_copy_0x040400(libxl_uuid *dst,
+                                            const libxl_uuid *src)
+{
+    libxl_uuid_copy(NULL, dst, src);
+}
+#define libxl_uuid_copy libxl_uuid_copy_0x040400
 #endif
 
 void libxl_uuid_clear(libxl_uuid *uuid);
Signature · 1 line
1.7.10.4
#2 lore raw
In reply to Andrew Cooper

Andrew Cooper writes ("[PATCH for-4.5] tools/libxl: Fix building against libxl for LIBXL_API_VERSION < 0x040500"):

Quoted 2 lines

c/s 6276f66ebe "libxl: libxl_uuid_copy now takes a ctx argument" introduces API compatibiltiy for libxl_uuid_copy() which sadly is not valid C. Fix it.

...

Quoted 2 lines

#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x040500
-void libxl_uuid_copy(dst, src) libxl_uuid_copy(NULL, dst, src)

I think this was intended to read
#define libxl_uuid_copy(dst, src) libxl_uuid_copy(NULL, dst, src)
but should in fact read
#define libxl_uuid_copy(dst, src) libxl_uuid_copy(NULL, (dst), (src))

I don't understand why you want to introduce a function as well as a macro.

Ian.

#3 lore raw
Quoted 10 lines · Ian Jackson

Andrew Cooper writes ("[PATCH for-4.5] tools/libxl: Fix building against libxl for LIBXL_API_VERSION < 0x040500"):

Quoted 2 lines

c/s 6276f66ebe "libxl: libxl_uuid_copy now takes a ctx argument" introduces API compatibiltiy for libxl_uuid_copy() which sadly is not valid C. Fix it.

...

Quoted 2 lines

#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x040500
-void libxl_uuid_copy(dst, src) libxl_uuid_copy(NULL, dst, src)

I think this was intended to read
#define libxl_uuid_copy(dst, src) libxl_uuid_copy(NULL, dst, src)
but should in fact read
#define libxl_uuid_copy(dst, src) libxl_uuid_copy(NULL, (dst), (src))

Does this even work?

Won't the parser complain about passing 3 parameters to a two-parameter macro?

~Andrew

#4 lore raw

Andrew Cooper writes ("Re: [PATCH for-4.5] tools/libxl: Fix building against libxl for LIBXL_API_VERSION < 0x040500"):

Quoted 10 lines · Ian Jackson
Quoted 4 lines

I think this was intended to read
#define libxl_uuid_copy(dst, src) libxl_uuid_copy(NULL, dst, src)
but should in fact read
#define libxl_uuid_copy(dst, src) libxl_uuid_copy(NULL, (dst), (src))

Does this even work?

Won't the parser complain about passing 3 parameters to a two-parameter macro?

mariner:~> ed t.c
t.c: No such file or directory
a
#define libxl_uuid_copy(dst, src) libxl_uuid_copy(NULL, (dst), (src)) libxl_uuid_copy(1,2)
.
w
91
q
mariner:~> gcc -E t.c
# 1 "t.c"
# 1 "<command-line>"
# 1 "t.c"

libxl_uuid_copy(NULL, (1), (2))
mariner:~>

#5 lore raw

Ian Jackson writes ("Re: [PATCH for-4.5] tools/libxl: Fix building against libxl for LIBXL_API_VERSION < 0x040500"):

Quoted 6 lines

Andrew Cooper writes ("Re: [PATCH for-4.5] tools/libxl: Fix building against libxl for LIBXL_API_VERSION < 0x040500"):

Quoted 5 lines · Ian Jackson
Quoted 4 lines

I think this was intended to read
#define libxl_uuid_copy(dst, src) libxl_uuid_copy(NULL, dst, src)
but should in fact read
#define libxl_uuid_copy(dst, src) libxl_uuid_copy(NULL, (dst), (src))

Having checked the rules, for C++ this might conceivably have to be

    #define libxl_uuid_copy(dst, src) (libxl_uuid_copy(NULL, (dst), (src)))

Ian.

#6 lore raw
Quoted 11 lines · Ian Jackson

Ian Jackson writes ("Re: [PATCH for-4.5] tools/libxl: Fix building against libxl for LIBXL_API_VERSION < 0x040500"):

Quoted 6 lines

Andrew Cooper writes ("Re: [PATCH for-4.5] tools/libxl: Fix building against libxl for LIBXL_API_VERSION < 0x040500"):

Quoted 5 lines · Ian Jackson
Quoted 4 lines

I think this was intended to read
#define libxl_uuid_copy(dst, src) libxl_uuid_copy(NULL, dst, src)
but should in fact read
#define libxl_uuid_copy(dst, src) libxl_uuid_copy(NULL, (dst), (src))

Having checked the rules, for C++ this might conceivably have to be

    #define libxl_uuid_copy(dst, src) (libxl_uuid_copy(NULL, (dst), (src)))

Ian.

Fundamentally, I am not really fussed how this is fixed, although I have confirmed my patch fixes the libvirt build in the XenServer branch I am attempting to test Xen-4.5 under.

~Andrew

#7 lore raw
Quoted 8 lines · Andrew Cooper
Quoted 7 lines · Ian Jackson

Ian Jackson writes ("Re: [PATCH for-4.5] tools/libxl: Fix building against libxl for LIBXL_API_VERSION < 0x040500"):

Quoted 6 lines

Andrew Cooper writes ("Re: [PATCH for-4.5] tools/libxl: Fix building against libxl for LIBXL_API_VERSION < 0x040500"):

Quoted 5 lines · Ian Jackson
Quoted 4 lines

I think this was intended to read
#define libxl_uuid_copy(dst, src) libxl_uuid_copy(NULL, dst, src)
but should in fact read
#define libxl_uuid_copy(dst, src) libxl_uuid_copy(NULL, (dst), (src))

Quoted 8 lines
Quoted 4 lines

Having checked the rules, for C++ this might conceivably have to be

    #define libxl_uuid_copy(dst, src) (libxl_uuid_copy(NULL, (dst), (src)))

Ian.

Fundamentally, I am not really fussed how this is fixed, although I have confirmed my patch fixes the libvirt build in the XenServer branch I am attempting to test Xen-4.5 under.

Ian, are you happy with that or do you want to (ask Andy to) resubmit with the #define?

Ian.

#8 lore raw
Quoted 12 lines · Ian Campbell
Quoted 11 lines · Andrew Cooper
Quoted 10 lines · Ian Jackson

Ian Jackson writes ("Re: [PATCH for-4.5] tools/libxl: Fix building against libxl for LIBXL_API_VERSION < 0x040500"):

Quoted 6 lines

Andrew Cooper writes ("Re: [PATCH for-4.5] tools/libxl: Fix building against libxl for LIBXL_API_VERSION < 0x040500"):

Quoted 5 lines · Ian Jackson
Quoted 4 lines

I think this was intended to read
#define libxl_uuid_copy(dst, src) libxl_uuid_copy(NULL, dst, src)
but should in fact read
#define libxl_uuid_copy(dst, src) libxl_uuid_copy(NULL, (dst), (src))

Having checked the rules, for C++ this might conceivably have to be

    #define libxl_uuid_copy(dst, src) (libxl_uuid_copy(NULL, (dst), (src)))
Quoted 9 lines
Quoted 4 lines
Quoted 1 line

Ian.

Fundamentally, I am not really fussed how this is fixed, although I have confirmed my patch fixes the libvirt build in the XenServer branch I am attempting to test Xen-4.5 under.

Ian, are you happy with that or do you want to (ask Andy to) resubmit with the #define?

Ian.

Ping (regarding question)? Whichever fix gets used eventually. this really needs to get in before the release candidate is cut.

~Andrew

#9 lore raw
Quoted 2 lines · Andrew Cooper

Ping (regarding question)? Whichever fix gets used eventually. this really needs to get in before the release candidate is cut.

I've applied it locally and kicked off my usual set of tests, I'll push once those complete (and/or I've finished lunch, whichever comes second) unless Ian objects before then.

Ian.