diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/make.configuration.deps | 4 | ||||
-rw-r--r-- | src/output_source.c | 22 | ||||
-rw-r--r-- | src/util/makeblob.c | 152 | ||||
-rw-r--r-- | src/util/makemetablob.c | 13 |
4 files changed, 146 insertions, 45 deletions
diff --git a/src/make.configuration.deps b/src/make.configuration.deps index ba840d1..8c60c5a 100644 --- a/src/make.configuration.deps +++ b/src/make.configuration.deps @@ -82,7 +82,7 @@ $(TARBALL_DIR)/cactus-flesh-source.o: $(TARBALL_DIR)/cactus-flesh-source.c $(CC) $(CFLAGS) -c -o $@ $^ $(TARBALL_DIR)/cactus-flesh-source.c: $(TARBALL_DIR)/cactus-flesh-source.tar.gz - $(TARBALL_DIR)/makeblob '' Cactus < $< > $@ + $(TARBALL_DIR)/makeblob '' Cactus $(@:%.c=%) < $< > $@ $(TARBALL_DIR)/cactus-flesh-source.tar.gz: $(TARBALL_DIR)/cactus-flesh-source.files cd $(CCTK_HOME) && \ @@ -127,7 +127,7 @@ $(TARBALL_DIR)/cactus-thorn-source-%.o: $(TARBALL_DIR)/cactus-thorn-source-%.c $(CC) $(CFLAGS) -c -o $@ $^ $(TARBALL_DIR)/cactus-thorn-source-%.c: $(TARBALL_DIR)/cactus-thorn-source-%.tar.gz - $(TARBALL_DIR)/makeblob $(patsubst %/,%,$(dir $(filter %/$(@:$(TARBALL_DIR)/cactus-thorn-source-%.c=%),$(THORNS)))) $(@:$(TARBALL_DIR)/cactus-thorn-source-%.c=%) < $< > $@ + $(TARBALL_DIR)/makeblob $(patsubst %/,%,$(dir $(filter %/$(@:$(TARBALL_DIR)/cactus-thorn-source-%.c=%),$(THORNS)))) $(@:$(TARBALL_DIR)/cactus-thorn-source-%.c=%) $(@:%.c=%) < $< > $@ $(TARBALL_DIR)/cactus-thorn-source-%.tar.gz: $(TARBALL_DIR)/cactus-thorn-source-%.files cd $(CCTK_HOME) && \ diff --git a/src/output_source.c b/src/output_source.c index d319f72..15b69bd 100644 --- a/src/output_source.c +++ b/src/output_source.c @@ -12,10 +12,16 @@ -struct sourceinfo +struct datainfo { - char const * data; + unsigned char const * data; size_t length; + struct datainfo const * next; +}; + +struct sourceinfo +{ + struct datainfo const * first; char const * arrangement; char const * thorn; }; @@ -38,6 +44,7 @@ Formaline_OutputSource (void) char filename [10000]; FILE * file; int count; + struct datainfo const * datainfo; if (CCTK_MyProc (0) != 0) return 0; @@ -59,10 +66,13 @@ Formaline_OutputSource (void) cactus_source[count]->thorn); file = fopen (filename, "w"); assert (file); - fwrite (cactus_source[count]->data, - sizeof * cactus_source[count]->data, - cactus_source[count]->length, - file); + for (datainfo = cactus_source[count]->first; + datainfo; + datainfo = datainfo->next) + { + fwrite (datainfo->data, sizeof * datainfo->data, datainfo->length, + file); + } fclose (file); } diff --git a/src/util/makeblob.c b/src/util/makeblob.c index f77e8a1..80759bb 100644 --- a/src/util/makeblob.c +++ b/src/util/makeblob.c @@ -8,51 +8,135 @@ main (int argc, char * * argv) { char const * arrangement; char const * thorn; + char const * output; + char filename [10000]; + FILE * file; + int fcount; + int done; unsigned long count; + unsigned long const items_per_line = 16; + unsigned long const items_per_file = 1024 * 1024; - assert (argc == 3); + assert (argc == 4); arrangement = argv[1]; - thorn = argv[2]; assert (arrangement); + thorn = argv[2]; assert (thorn); + output = argv[3]; + assert (output); + +#if 0 + snprintf (filename, sizeof filename, "%s.c", output); + file = fopen (filename, "w"); + assert (file); +#endif + file = stdout; - printf ("/* This is an auto-generated file -- do not edit */\n"); - printf ("\n"); - printf ("#include <stddef.h>\n"); - printf ("\n"); - printf ("struct sourceinfo\n"); - printf ("{\n"); - printf (" char const * data;\n"); - printf (" size_t length;\n"); - printf (" char const * arrangement;\n"); - printf (" char const * thorn;\n"); - printf ("};\n"); - printf ("\n"); - printf ("static char const data [] = {"); - for (count = 0; ; ++ count) + fprintf (file, "/* This is an auto-generated file -- do not edit */\n"); + fprintf (file, "\n"); + fprintf (file, "#include <stddef.h>\n"); + fprintf (file, "\n"); + fprintf (file, "struct datainfo\n"); + fprintf (file, "{\n"); + fprintf (file, " unsigned char const * data;\n"); + fprintf (file, " size_t length;\n"); + fprintf (file, " struct datainfo const * next;\n"); + fprintf (file, "};\n"); + fprintf (file, "\n"); + fprintf (file, "struct sourceinfo\n"); + fprintf (file, "{\n"); + fprintf (file, " struct datainfo const * first;\n"); + fprintf (file, " char const * arrangement;\n"); + fprintf (file, " char const * thorn;\n"); + fprintf (file, "};\n"); + + fprintf (file, "\n"); + fprintf (file, "struct datainfo const cactus_data_%04d_%s;\n", 0, thorn); + fprintf (file, "struct sourceinfo const cactus_source_%s =\n", thorn); + fprintf (file, "{\n"); + fprintf (file, " & cactus_data_%04d_%s,\n", 0, thorn); + fprintf (file, " \"%s\",\n", arrangement); + fprintf (file, " \"%s\"\n", thorn); + fprintf (file, "};\n"); + + for (fcount = 0, done = 0; ! done; ++ fcount) { - int const ch = getc (stdin); - if (feof (stdin)) break; - if (ferror (stdin)) return 1; - if (count != 0) { - printf (","); +#if 0 + snprintf (filename, sizeof filename, "%s-%04d.c", output, fcount); + file = fopen (filename, "w"); + assert (file); + + fprintf (file, "/* This is an auto-generated file -- do not edit */\n"); + fprintf (file, "\n"); + fprintf (file, "#include <stddef.h>\n"); + fprintf (file, "\n"); + fprintf (file, "struct datainfo\n"); + fprintf (file, "{\n"); + fprintf (file, " unsigned char const * data;\n"); + fprintf (file, " size_t length;\n"); + fprintf (file, " struct datainfo const * next;\n"); + fprintf (file, "};\n"); + fprintf (file, "\n"); + fprintf (file, "struct sourceinfo\n"); + fprintf (file, "{\n"); + fprintf (file, " struct datainfo const * first;\n"); + fprintf (file, " char const * arrangement;\n"); + fprintf (file, " char const * thorn;\n"); + fprintf (file, "};\n"); +#endif + + fprintf (file, "\n"); + fprintf (file, "static unsigned char const data_%04d [] = {", fcount); + for (count = 0; count < items_per_file; ++ count) + { + int const ch = getc (stdin); + if (feof (stdin)) + { + done = 1; + break; + } + if (ferror (stdin)) return 1; + if (count != 0) + { + fprintf (file, ","); + } + if (count % items_per_line == 0) + { + fprintf (file, "\n"); + } + fprintf (file, "%3d", ch); } - if (count % 16 == 0) + fprintf (file, "\n"); + fprintf (file, "};\n"); + fprintf (file, "\n"); + if (! done) { - printf ("\n"); + fprintf (file, "struct datainfo const cactus_data_%04d_%s;\n", + fcount + 1, thorn); } - printf ("%3d", ch); + fprintf (file, "struct datainfo const cactus_data_%04d_%s =\n", + fcount, thorn); + fprintf (file, "{\n"); + fprintf (file, " data_%04d,\n", fcount); + fprintf (file, " %luUL,\n", count); + if (! done) + { + fprintf (file, " & cactus_data_%04d_%s\n", fcount + 1, thorn); + } + else + { + fprintf (file, " NULL\n"); + } + fprintf (file, "};\n"); + +#if 0 + fclose (file); +#endif } - printf ("\n"); - printf ("};\n"); - printf ("\n"); - printf ("struct sourceinfo const cactus_source_%s =\n", thorn); - printf ("{\n"); - printf (" data,\n"); - printf (" %luUL,\n", count); - printf (" \"%s\",\n", arrangement); - printf (" \"%s\"\n", thorn); - printf ("};\n"); + +#if 0 + fclose (file); +#endif return 0; } diff --git a/src/util/makemetablob.c b/src/util/makemetablob.c index bc871a6..e5f0d52 100644 --- a/src/util/makemetablob.c +++ b/src/util/makemetablob.c @@ -11,10 +11,16 @@ main (int argc, char * * argv) printf ("\n"); printf ("#include <stddef.h>\n"); printf ("\n"); - printf ("struct sourceinfo\n"); + printf ("struct datainfo\n"); printf ("{\n"); - printf (" char const * data;\n"); + printf (" unsigned char const * data;\n"); printf (" size_t length;\n"); + printf (" struct datainfo const * next;\n"); + printf ("};\n"); + printf ("\n"); + printf ("struct sourceinfo\n"); + printf ("{\n"); + printf (" struct datainfo const * first;\n"); printf (" char const * arrangement;\n"); printf (" char const * thorn;\n"); printf ("};\n"); @@ -27,7 +33,8 @@ main (int argc, char * * argv) printf ("struct sourceinfo const * const cactus_source [] = {"); for (count = 1; count < argc; ++ count) { - if (count != 1) { + if (count != 1) + { printf (","); } printf ("\n"); |