bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 4/5] Move the generation of x_server_routine function into a func


From: Justus Winter
Subject: [PATCH 4/5] Move the generation of x_server_routine function into a function
Date: Mon, 2 Dec 2013 10:58:18 +0100

* server.c (WriteSubsystemServerRoutine): New function.
(WriteEpilog): Adjust accordingly.
* write.h (WriteSubsystemServerRoutine): New declaration.
---
 server.c |   35 +++++++++++++++++++++--------------
 write.h  |    1 +
 2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/server.c b/server.c
index 8496da7..db315fa 100644
--- a/server.c
+++ b/server.c
@@ -133,6 +133,26 @@ WriteArrayEntries(FILE *file, const statement_t *stats)
        fprintf(file, "\t\t\t0,\n");
 }
 
+void
+WriteSubsystemServerRoutine(FILE *file, const char *typeModifier)
+{
+    fprintf(file, "%s mig_routine_t %s_routine\n", typeModifier,
+           ServerDemux);
+    fprintf(file, "\t(const mach_msg_header_t *InHeadP)\n");
+
+    fprintf(file, "{\n");
+    fprintf(file, "\tint msgh_id;\n");
+    fprintf(file, "\n");
+    fprintf(file, "\tmsgh_id = InHeadP->msgh_id - %d;\n", SubsystemBase);
+    fprintf(file, "\n");
+    fprintf(file, "\tif ((msgh_id > %d) || (msgh_id < 0))\n",
+           rtNumber - 1);
+    fprintf(file, "\t\treturn 0;\n");
+    fprintf(file, "\n");
+    fprintf(file, "\treturn %s_routines[msgh_id];\n", ServerDemux);
+    fprintf(file, "}\n");
+}
+
 static void
 WriteEpilog(FILE *file, const statement_t *stats)
 {
@@ -199,20 +219,7 @@ WriteEpilog(FILE *file, const statement_t *stats)
     /*
      * Then, the <subsystem>_server_routine routine
      */
-    fprintf(file, "mig_external mig_routine_t %s_routine\n", ServerDemux);
-    fprintf(file, "\t(const mach_msg_header_t *InHeadP)\n");
-
-    fprintf(file, "{\n");
-    fprintf(file, "\tint msgh_id;\n");
-    fprintf(file, "\n");
-    fprintf(file, "\tmsgh_id = InHeadP->msgh_id - %d;\n", SubsystemBase);
-    fprintf(file, "\n");
-    fprintf(file, "\tif ((msgh_id > %d) || (msgh_id < 0))\n",
-           rtNumber - 1);
-    fprintf(file, "\t\treturn 0;\n");
-    fprintf(file, "\n");
-    fprintf(file, "\treturn %s_routines[msgh_id];\n", ServerDemux);
-    fprintf(file, "}\n");
+    WriteSubsystemServerRoutine(file, "mig_external");
     fprintf(file, "\n");
 
     /* symtab */
diff --git a/write.h b/write.h
index b5180df..4d24e63 100644
--- a/write.h
+++ b/write.h
@@ -38,5 +38,6 @@ extern void WriteUser(FILE *file, const statement_t *stats);
 extern void WriteUserIndividual(const statement_t *stats);
 extern void WriteServer(FILE *file, const statement_t *stats);
 extern void WriteRoutineList(FILE *file, const statement_t *stats);
+extern void WriteSubsystemServerRoutine(FILE *file, const char *typeModifier);
 
 #endif /* _WRITE_H */
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]