diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2013-12-01 16:28:44 +0100 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2013-12-16 12:02:40 +0100 |
commit | b39ae10e7d9c9db61822fe48585dbc2fdbbcc5d2 (patch) | |
tree | e99deaf638eb30ca0cb6fab86d95652997c1faa9 | |
parent | 4cf0e0e059f3b1593ab75e436f61a8a36a0c6cd6 (diff) | |
download | mig-b39ae10e7d9c9db61822fe48585dbc2fdbbcc5d2.tar.gz mig-b39ae10e7d9c9db61822fe48585dbc2fdbbcc5d2.tar.bz2 mig-b39ae10e7d9c9db61822fe48585dbc2fdbbcc5d2.zip |
Move the generation of x_server_routine function into a function
* server.c (WriteSubsystemServerRoutine): New function.
(WriteEpilog): Adjust accordingly.
* write.h (WriteSubsystemServerRoutine): New declaration.
-rw-r--r-- | server.c | 35 | ||||
-rw-r--r-- | write.h | 1 |
2 files changed, 22 insertions, 14 deletions
@@ -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 */ @@ -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 */ |