All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH]  stand-alone build of sxpr parser
@ 2004-11-22 18:30 Charles Coffing
  0 siblings, 0 replies; only message in thread
From: Charles Coffing @ 2004-11-22 18:30 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 332 bytes --]

This patch applies to 2.0-testing.

It updates/fixes the stand-alone build of the S-expression parser, so
that it may be debugged more easily.  It makes no code changes to the
normal build.

>From tools/xfrd, you may do...
SXPR_DEBUG=1 make
...to get a version of xfrd solely meant to test the S-expression
parser.

Thanks,
Charles

[-- Attachment #2: sxpr_debug.patch --]
[-- Type: application/octet-stream, Size: 4032 bytes --]

===== tools/xfrd/Makefile 1.7 vs edited =====
--- 1.7/tools/xfrd/Makefile	2004-11-02 02:08:36 -07:00
+++ edited/tools/xfrd/Makefile	2004-11-22 11:25:58 -07:00
@@ -26,11 +26,15 @@
 # Define to use stubs, undefine to use the real Xen functions.
 #CPPFLAGS += -D _XEN_XFR_STUB_
 
+ifeq ($(SXPR_DEBUG),1)
+CPPFLAGS += -D _XEN_XFR_STUB_ -D SXPR_PARSER_MAIN
+endif
+
 CC := gcc
 
 CFLAGS += -g
 CFLAGS += -Wall
-CFALGS += -Werror
+CFLAGS += -Werror
 CFLAGS += $(INCLUDES)
 # Make gcc generate dependencies.
 CFLAGS += -Wp,-MD,.$(@F).d
===== tools/xfrd/debug.h 1.2 vs edited =====
--- 1.2/tools/xfrd/debug.h	2004-09-24 10:06:43 -06:00
+++ edited/tools/xfrd/debug.h	2004-11-22 10:48:36 -07:00
@@ -45,6 +45,7 @@
 #else
 
 #include <stdio.h>
+#include <unistd.h>
 
 #ifdef DEBUG
 
===== tools/xfrd/sxpr_parser.c 1.1 vs edited =====
--- 1.1/tools/xfrd/sxpr_parser.c	2004-07-07 09:54:46 -06:00
+++ edited/tools/xfrd/sxpr_parser.c	2004-11-22 11:15:19 -07:00
@@ -808,26 +808,13 @@
     return p->eof;
 }
 
-//#define SXPR_PARSER_MAIN
 #ifdef SXPR_PARSER_MAIN
 /* Stuff for standalone testing. */
 
 #include "file_stream.h"
 #include "string_stream.h"
 
-int stringof(Sxpr exp, char **s){
-    int err = 0;
-    if(ATOMP(exp)){
-        *s = atom_name(exp);
-    } else if(STRINGP(exp)){
-        *s = string_string(exp);
-    } else {
-        err = -EINVAL;
-        *s = NULL;
-    }
-    return err;
-}
-
+extern int stringof(Sxpr exp, char **s);
 int child_string(Sxpr exp, Sxpr key, char **s){
     int err = 0;
     Sxpr val = sxpr_child_value(exp, key, ONONE);
@@ -835,22 +822,7 @@
     return err;
 }
 
-int intof(Sxpr exp, int *v){
-    int err = 0;
-    char *s;
-    unsigned long l;
-    if(INTP(exp)){
-        *v = OBJ_INT(exp);
-    } else {
-        err = stringof(exp, &s);
-        if(err) goto exit;
-        err = convert_atoul(s, &l);
-        *v = (int)l;
-    }
- exit:
-    return err;
-}
-
+extern int intof(Sxpr exp, int *v);
 int child_int(Sxpr exp, Sxpr key, int *v){
     int err = 0;
     Sxpr val = sxpr_child_value(exp, key, ONONE);
===== tools/xfrd/xen_domain.c 1.20 vs edited =====
--- 1.20/tools/xfrd/xen_domain.c	2004-10-21 10:11:02 -06:00
+++ edited/tools/xfrd/xen_domain.c	2004-11-22 10:46:06 -07:00
@@ -83,7 +83,7 @@
     }
     
     dom = 99;
-    err = domain_suspend(dom, xend);
+    err = domain_suspend(xend, dom);
     IOStream_close(io);
   exit:
 #else 
===== tools/xfrd/xfrd.c 1.18 vs edited =====
--- 1.18/tools/xfrd/xfrd.c	2004-10-21 10:11:02 -06:00
+++ edited/tools/xfrd/xfrd.c	2004-11-22 11:10:58 -07:00
@@ -171,6 +171,25 @@
     exit(err ? 1 : 0);
 }
 
+typedef struct Args {
+    int bufsize;
+    unsigned long port;
+    int verbose;
+    int compress;
+} Args;
+
+/** Transfer states. */
+enum {
+    XFR_INIT,
+    XFR_HELLO,
+    XFR_STATE,
+    XFR_RUN,
+    XFR_FAIL,
+    XFR_DONE,
+    XFR_MAX
+};
+
+#ifndef SXPR_PARSER_MAIN
 /** Short options. Options followed by ':' take an argument. */
 static char *short_opts = (char[]){
     OPT_PORT,     ':',
@@ -190,23 +209,12 @@
     { NULL,         0,                 NULL, 0            }
 };
 
-typedef struct Args {
-    int bufsize;
-    unsigned long port;
-    int verbose;
-    int compress;
-} Args;
+/** Xfrd arguments. */
+static Args _args = {};
 
-/** Transfer states. */
-enum {
-    XFR_INIT,
-    XFR_HELLO,
-    XFR_STATE,
-    XFR_RUN,
-    XFR_FAIL,
-    XFR_DONE,
-    XFR_MAX
-};
+/** Xfrd arguments. */
+static Args *args = &_args;
+#endif
 
 /** Initialize an array element for a constant to its string name. */
 #define VALDEF(val) { val, #val }
@@ -318,12 +326,6 @@
     return s->err_state;
 }
 
-/** Xfrd arguments. */
-static Args _args = {};
-
-/** Xfrd arguments. */
-static Args *args = &_args;
-
 /** Set xfrd default arguments.
  *
  * @param args arguments to set
@@ -1212,6 +1214,7 @@
     return err;
 }
 
+#ifndef SXPR_PARSER_MAIN
 /** Parse command-line arguments and call the xfrd main program.
  *
  * @param arg argument count
@@ -1265,4 +1268,4 @@
     }
     return (err ? 1 : 0);
 }
-
+#endif

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-11-22 18:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-22 18:30 [PATCH] stand-alone build of sxpr parser Charles Coffing

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.