All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0 of 3] libxl: cleanups for type destructor generation
@ 2010-08-27 15:32 Ian Campbell
  2010-08-27 15:32 ` [PATCH 1 of 3] libxl: correctly free Reference types in autogenerated destroy functions Ian Campbell
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ian Campbell @ 2010-08-27 15:32 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell

Following series cleans up a few niggles in the libxl destructor
autogeneration.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1 of 3] libxl: correctly free Reference types in autogenerated destroy functions
  2010-08-27 15:32 [PATCH 0 of 3] libxl: cleanups for type destructor generation Ian Campbell
@ 2010-08-27 15:32 ` Ian Campbell
  2010-08-27 15:32 ` [PATCH 2 of 3] libxl: correct indentation of _libxl_types.c Ian Campbell
  2010-08-27 15:32 ` [PATCH 3 of 3] libxl: builtin list types should be pass-by-reference Ian Campbell
  2 siblings, 0 replies; 4+ messages in thread
From: Ian Campbell @ 2010-08-27 15:32 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1282922856 -3600
# Node ID 75a3469cfac671cbf0271527d245e29b34b0e60f
# Parent  76b574e9805f6154f3e651e3610befd7847f97e3
libxl: correctly free Reference types in autogenerated destroy functions

References types should be recursively destroyed and then the actual
reference itself should be destroyed.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 76b574e9805f -r 75a3469cfac6 tools/libxl/gentypes.py
--- a/tools/libxl/gentypes.py	Fri Aug 27 16:27:36 2010 +0100
+++ b/tools/libxl/gentypes.py	Fri Aug 27 16:27:36 2010 +0100
@@ -64,6 +64,11 @@ def libxl_C_type_destroy(ty, v, referenc
         deref = v + "->"
     else:
         deref = v + "."
+        
+    if ty.passby == libxltypes.PASS_BY_REFERENCE and not reference:
+        makeref = "&"
+    else:
+        makeref = ""
 
     s = ""
     if isinstance(ty, libxltypes.KeyedUnion):
@@ -76,6 +81,8 @@ def libxl_C_type_destroy(ty, v, referenc
             s += "}\n"
     elif isinstance(ty, libxltypes.Reference):
         s += libxl_C_type_destroy(ty.ref_type, v, True, indent, v)
+        if ty.destructor_fn is not None:
+            s += "%s(%s);\n" % (ty.destructor_fn, makeref + v)
     elif isinstance(ty, libxltypes.Struct) and (parent is None or ty.destructor_fn is None):
         for f in [f for f in ty.fields if not f.const]:
 
@@ -84,11 +91,6 @@ def libxl_C_type_destroy(ty, v, referenc
             else:
                 s += libxl_C_type_destroy(f.type, deref + f.name, False, "", deref)
     else:
-        if ty.passby == libxltypes.PASS_BY_REFERENCE and not reference:
-            makeref = "&"
-        else:
-            makeref = ""
-
         if ty.destructor_fn is not None:
             s += "%s(%s);\n" % (ty.destructor_fn, makeref + v)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2 of 3] libxl: correct indentation of _libxl_types.c
  2010-08-27 15:32 [PATCH 0 of 3] libxl: cleanups for type destructor generation Ian Campbell
  2010-08-27 15:32 ` [PATCH 1 of 3] libxl: correctly free Reference types in autogenerated destroy functions Ian Campbell
@ 2010-08-27 15:32 ` Ian Campbell
  2010-08-27 15:32 ` [PATCH 3 of 3] libxl: builtin list types should be pass-by-reference Ian Campbell
  2 siblings, 0 replies; 4+ messages in thread
From: Ian Campbell @ 2010-08-27 15:32 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1282922856 -3600
# Node ID 228640a1efbb120939de2718e7a6c997cac2880f
# Parent  75a3469cfac671cbf0271527d245e29b34b0e60f
libxl: correct indentation of _libxl_types.c

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 75a3469cfac6 -r 228640a1efbb tools/libxl/gentypes.py
--- a/tools/libxl/gentypes.py	Fri Aug 27 16:27:36 2010 +0100
+++ b/tools/libxl/gentypes.py	Fri Aug 27 16:27:36 2010 +0100
@@ -159,7 +159,7 @@ if __name__ == '__main__':
         f.write("void %s(%s *p)\n" % (ty.destructor_fn, ty.typename))
         f.write("{\n")
         f.write(libxl_C_type_destroy(ty, "p", True))
-        f.write("\tmemset(p, LIBXL_DTOR_POISON, sizeof(*p));\n")
+        f.write("    memset(p, LIBXL_DTOR_POISON, sizeof(*p));\n")
         f.write("}\n")
         f.write("\n")
     f.close()

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3 of 3] libxl: builtin list types should be pass-by-reference
  2010-08-27 15:32 [PATCH 0 of 3] libxl: cleanups for type destructor generation Ian Campbell
  2010-08-27 15:32 ` [PATCH 1 of 3] libxl: correctly free Reference types in autogenerated destroy functions Ian Campbell
  2010-08-27 15:32 ` [PATCH 2 of 3] libxl: correct indentation of _libxl_types.c Ian Campbell
@ 2010-08-27 15:32 ` Ian Campbell
  2 siblings, 0 replies; 4+ messages in thread
From: Ian Campbell @ 2010-08-27 15:32 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1282923129 -3600
# Node ID 6b7c034c4710056bcc7ecba46971c24f99683236
# Parent  228640a1efbb120939de2718e7a6c997cac2880f
libxl: builtin list types should be pass-by-reference

This makes all _destroy functions consistent wrt freeing the actual
reference passed in. Previously we were relying on the reference
contained within the type itself which worked but was semantically a
little confusing.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 228640a1efbb -r 6b7c034c4710 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Fri Aug 27 16:27:36 2010 +0100
+++ b/tools/libxl/libxl.c	Fri Aug 27 16:32:09 2010 +0100
@@ -71,9 +71,10 @@ int libxl_ctx_free(libxl_ctx *ctx)
     return 0;
 }
 
-void libxl_string_list_destroy(libxl_string_list sl)
+void libxl_string_list_destroy(libxl_string_list *psl)
 {
     int i;
+    libxl_string_list sl = *psl;
 
     if (!sl)
         return;
@@ -83,9 +84,10 @@ void libxl_string_list_destroy(libxl_str
     free(sl);
 }
 
-void libxl_key_value_list_destroy(libxl_key_value_list kvl)
+void libxl_key_value_list_destroy(libxl_key_value_list *pkvl)
 {
     int i;
+    libxl_key_value_list kvl = *pkvl;
 
     if (!kvl)
         return;
diff -r 228640a1efbb -r 6b7c034c4710 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Fri Aug 27 16:27:36 2010 +0100
+++ b/tools/libxl/libxl.h	Fri Aug 27 16:32:09 2010 +0100
@@ -234,8 +234,8 @@ int libxl_domain_preserve(libxl_ctx *ctx
 int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid, libxl_domain_create_info *info, const char *name_suffix, libxl_uuid new_uuid);
 
 /* destructors for builtin data types */
-void libxl_string_list_destroy(libxl_string_list sl);
-void libxl_key_value_list_destroy(libxl_key_value_list kvl);
+void libxl_string_list_destroy(libxl_string_list *sl);
+void libxl_key_value_list_destroy(libxl_key_value_list *kvl);
 void libxl_file_reference_destroy(libxl_file_reference *f);
 
 /*
diff -r 228640a1efbb -r 6b7c034c4710 tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl	Fri Aug 27 16:27:36 2010 +0100
+++ b/tools/libxl/libxl.idl	Fri Aug 27 16:32:09 2010 +0100
@@ -12,8 +12,8 @@ libxl_disk_phystype = Builtin("disk_phys
 libxl_disk_phystype = Builtin("disk_phystype")
 libxl_nic_type = Builtin("nic_type")
 
-libxl_string_list = Builtin("string_list", destructor_fn="libxl_string_list_destroy")
-libxl_key_value_list = Builtin("key_value_list", destructor_fn="libxl_key_value_list_destroy")
+libxl_string_list = Builtin("string_list", destructor_fn="libxl_string_list_destroy", passby=PASS_BY_REFERENCE)
+libxl_key_value_list = Builtin("key_value_list", destructor_fn="libxl_key_value_list_destroy", passby=PASS_BY_REFERENCE)
 
 libxl_cpumap = Builtin("cpumap", destructor_fn="free")
 
diff -r 228640a1efbb -r 6b7c034c4710 tools/libxl/libxltypes.py
--- a/tools/libxl/libxltypes.py	Fri Aug 27 16:27:36 2010 +0100
+++ b/tools/libxl/libxltypes.py	Fri Aug 27 16:32:09 2010 +0100
@@ -182,6 +182,8 @@ def parse(f):
             globs[n] = t
         elif isinstance(t,type(object)) and issubclass(t, Type):
             globs[n] = t
+        elif n in ['PASS_BY_REFERENCE', 'PASS_BY_VALUE']:
+            globs[n] = t
 
     try:
         execfile(f, globs, locs)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-08-27 15:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-27 15:32 [PATCH 0 of 3] libxl: cleanups for type destructor generation Ian Campbell
2010-08-27 15:32 ` [PATCH 1 of 3] libxl: correctly free Reference types in autogenerated destroy functions Ian Campbell
2010-08-27 15:32 ` [PATCH 2 of 3] libxl: correct indentation of _libxl_types.c Ian Campbell
2010-08-27 15:32 ` [PATCH 3 of 3] libxl: builtin list types should be pass-by-reference Ian Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.