[Libguestfs] [PATCH 1/3] header: Define GUESTFS_HAVE_* for every function.

Richard W.M. Jones rjones at redhat.com
Tue Sep 15 13:54:35 UTC 2015


Previously we only defined GUESTFS_HAVE_* macros for functions that
were not deprecated, test or debug functions.  The reasoning for that
is given in this commit message [note that 'LIBGUESTFS_HAVE_' is the
old/deprecated macro]:

  commit 2d8fd7dacd77361bc385be42112289faafb5c60d
  Author: Richard Jones <rjones at redhat.com>
  Date:   Thu Sep 2 22:45:54 2010 +0100

    Define LIBGUESTFS_HAVE_<shortname> for C API functions.

    The actions each have a corresponding define, eg:

      #define LIBGUESTFS_HAVE_VGUUID 1
      extern char *guestfs_vguuid (guestfs_h *g, const char *vgname);

    However functions which are for testing, debugging or deprecated do
    not have the corresponding define.  Also a few functions are so
    basic (eg. guestfs_create) that there is no point defining a symbol
    for them.

This wasn't in fact carried through very consistently, since when we
replaced s/LIBGUESTFS_HAVE_/GUESTFS_HAVE_/, we kept the old
LIBGUESTFS_HAVE_* macros, but defined them for every function.  Oops.

This commit defines GUESTFS_HAVE_* for every function in <guestfs.h>,
making it easier to write the Python language bindings (see following
commits).
---
 generator/c.ml | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/generator/c.ml b/generator/c.ml
index a2b9c94..ae8e933 100644
--- a/generator/c.ml
+++ b/generator/c.ml
@@ -645,13 +645,7 @@ extern GUESTFS_DLL_PUBLIC void *guestfs_next_private (guestfs_h *g, const char *
   let generate_action_header { name = shortname;
                                style = ret, args, optargs as style;
                                deprecated_by = deprecated_by } =
-    let test =
-      String.length shortname >= 13 &&
-        String.sub shortname 0 13 = "internal_test" in
-    let debug =
-      String.length shortname >= 5 && String.sub shortname 0 5 = "debug" in
-    if deprecated_by = None && not test && not debug then
-      pr "#define GUESTFS_HAVE_%s 1\n" (String.uppercase shortname);
+    pr "#define GUESTFS_HAVE_%s 1\n" (String.uppercase shortname);
 
     if optargs <> [] then (
       iteri (
-- 
2.5.0




More information about the Libguestfs mailing list