From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: [PATCH V5 09/32] libxl_internal.h: move / add some libxl defbool #define here Date: Tue, 13 May 2014 22:53:51 +0100 Message-ID: <1400018054-26038-10-git-send-email-wei.liu2@citrix.com> References: <1400018054-26038-1-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1400018054-26038-1-git-send-email-wei.liu2@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Wei Liu , ian.jackson@eu.citrix.com, ian.campbell@citrix.com List-Id: xen-devel@lists.xenproject.org They will be used by both JSON generator and parser so they should be in header file. Signed-off-by: Wei Liu --- tools/libxl/libxl.c | 10 +++------- tools/libxl/libxl_internal.h | 8 ++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 70830fe..0589d4e 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -232,10 +232,6 @@ void libxl_key_value_list_dispose(libxl_key_value_list *pkvl) free(kvl); } -#define LIBXL__DEFBOOL_DEFAULT (0) -#define LIBXL__DEFBOOL_FALSE (-1) -#define LIBXL__DEFBOOL_TRUE (1) - void libxl_defbool_set(libxl_defbool *db, bool b) { db->val = b ? LIBXL__DEFBOOL_TRUE : LIBXL__DEFBOOL_FALSE; @@ -266,11 +262,11 @@ bool libxl_defbool_val(libxl_defbool db) const char *libxl_defbool_to_string(libxl_defbool b) { if (b.val < 0) - return "False"; + return LIBXL__DEFBOOL_STR_FALSE; else if (b.val > 0) - return "True"; + return LIBXL__DEFBOOL_STR_TRUE; else - return ""; + return LIBXL__DEFBOOL_STR_DEFAULT; } /******************************************************************************/ diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index c2b73c4..294c595 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -3036,6 +3036,14 @@ void libxl__numa_candidate_put_nodemap(libxl__gc *gc, libxl_bitmap_copy(CTX, &cndt->nodemap, nodemap); } +/* Som handy macros for defbool type. */ +#define LIBXL__DEFBOOL_DEFAULT (0) +#define LIBXL__DEFBOOL_FALSE (-1) +#define LIBXL__DEFBOOL_TRUE (1) +#define LIBXL__DEFBOOL_STR_DEFAULT "" +#define LIBXL__DEFBOOL_STR_FALSE "False" +#define LIBXL__DEFBOOL_STR_TRUE "True" + /* * Inserts "elm_new" into the sorted list "head". * -- 1.7.10.4