From 4921211dbe91ba28a2a540c960a71bf2d135d14a Mon Sep 17 00:00:00 2001 From: David Schleef Date: Sat, 19 Sep 2009 17:53:59 -0700 Subject: [PATCH] orcc: Add custom header barrier --- tools/orcc.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/tools/orcc.c b/tools/orcc.c index 2311208..e39bd39 100644 --- a/tools/orcc.c +++ b/tools/orcc.c @@ -8,6 +8,7 @@ #include #include #include +#include static char * read_file (const char *filename); void output_code (OrcProgram *p, FILE *output); @@ -17,6 +18,7 @@ void output_code_backup (OrcProgram *p, FILE *output); void output_code_no_orc (OrcProgram *p, FILE *output); static void print_defines (FILE *output); static void print_exec_header (FILE *output); +static char * get_barrier (const char *s); int verbose = 0; @@ -157,8 +159,11 @@ main (int argc, char *argv[]) output_code (programs[i], output); } } else if (mode == MODE_HEADER) { - fprintf(output, "#ifndef _ORC_OUT_H_\n"); - fprintf(output, "#define _ORC_OUT_H_\n"); + char *barrier = get_barrier (output_file); + + fprintf(output, "#ifndef _%s_\n", barrier); + fprintf(output, "#define _%s_\n", barrier); + free (barrier); fprintf(output, "\n"); if (include_file) { fprintf(output, "#include <%s>\n", include_file); @@ -289,6 +294,27 @@ print_exec_header (FILE *output) #endif } +static char * +get_barrier (const char *s) +{ + char *barrier; + int n; + int i; + + n = strlen(s); + barrier = malloc (n + 1); + for(i=0;i