From 30d72138904f5f318a5ba8767381620573eb1f3b Mon Sep 17 00:00:00 2001 From: compudj Date: Thu, 1 Dec 2005 18:57:22 +0000 Subject: [PATCH] code layout git-svn-id: http://ltt.polymtl.ca/svn@1350 04897980-b3bd-0310-b5e0-8ef037075253 --- genevent-new/genevent.c | 38 +++++++++++++++++++++++++++----------- genevent-new/parser.c | 2 +- genevent-new/parser.h | 4 ++-- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/genevent-new/genevent.c b/genevent-new/genevent.c index 15518d80..e54398ac 100644 --- a/genevent-new/genevent.c +++ b/genevent-new/genevent.c @@ -654,7 +654,7 @@ int print_type_write(type_descriptor_t * td, FILE *fd, unsigned int tabs, if(print_type(td, fd, 0, basename, "")) return 1; fprintf(fd, ");\n"); print_tabs(tabs, fd); - fprintf(fd, "size += ltt_align(*to+*len, size) + size;"); + fprintf(fd, "size += ltt_align(*to+*len, size) + size;\n"); print_tabs(tabs, fd); fprintf(fd, "*len += size;"); break; @@ -1167,11 +1167,11 @@ int print_event_logging_function(char *basename, facility_t *fac, fprintf(fd, "void *from;"); print_tabs(1, fd); fprintf(fd, "size_t len = 0;\n"); - fprintf(fd, "\n"); + print_tabs(1, fd); fprintf(fd, "size_t slot_size;\n"); - fprintf(fd, "\n"); + print_tabs(1, fd); fprintf(fd, "cycles_t tsc;\n"); - fprintf(fd, "\n"); + print_tabs(1, fd); fprintf(fd, "size_t before_hdr_pad, size_t after_hdr_pad;\n"); fprintf(fd, "\n"); @@ -1189,9 +1189,9 @@ int print_event_logging_function(char *basename, facility_t *fac, print_tabs(1, fd); fprintf(fd, "/* size = to_base + to + len */\n"); print_tabs(1, fd); - fprintf(fd, "/* Assume that the padding for alignment starts at a void*\n"); + fprintf(fd, "/* Assume that the padding for alignment starts at a\n"); print_tabs(1, fd); - fprintf(fd, "/* address. */\n"); + fprintf(fd, " * sizeof(void *) address. */\n"); fprintf(fd, "\n"); for(unsigned int i=0;ifields.position;i++){ @@ -1201,6 +1201,7 @@ int print_event_logging_function(char *basename, facility_t *fac, fd, 1, basename, field->name)) return 1; fprintf(fd, "\n"); } + fprintf(fd, "\n"); /* Take locks : make sure the trace does not vanish while we write on * it. A simple preemption disabling is enough (using rcu traces). */ @@ -1218,7 +1219,7 @@ int print_event_logging_function(char *basename, facility_t *fac, print_tabs(1, fd); fprintf(fd, "index = ltt_get_index_from_facility(ltt_facility_%s_%X,\n"\ - "\t\t\t\tevent_%s);\n", + "\t\t\t\t\t\tevent_%s);\n", fac->name, fac->checksum, event->name); } fprintf(fd,"\n"); @@ -1248,8 +1249,11 @@ int print_event_logging_function(char *basename, facility_t *fac, print_tabs(2, fd); fprintf(fd, "slot_size = 0;\n"); print_tabs(2, fd); - fprintf(fd, "buffer = ltt_reserve_slot(trace, relayfs_buf, to_base + to + len, &slot_size, &tsc,\n" - "\t\t&before_hdr_pad, &after_hdr_pad);\n"); + fprintf(fd, "buffer = ltt_reserve_slot(trace, relayfs_buf,\n"); + print_tabs(3, fd); + fprintf(fd, "to_base + to + len, &slot_size, &tsc,\n"); + print_tabs(3, fd); + fprintf(fd, "&before_hdr_pad, &after_hdr_pad);\n"); /* If error, return */ print_tabs(2, fd); fprintf(fd, "if(!buffer) return;\n\n"); @@ -1261,8 +1265,20 @@ int print_event_logging_function(char *basename, facility_t *fac, type_descriptor_t *type = field->type; /* Set from */ - print_tabs(3, fd); - fprintf(fd, "from = %s;\n", field->name); + print_tabs(2, fd); + switch(type->type) { + case SEQUENCE: + case UNION: + case ARRAY: + case STRUCT: + case STRING: + fprintf(fd, "from = %s;\n", field->name); + break; + default: + fprintf(fd, "from = &%s;\n", field->name); + break; + } + if(print_type_write(type, fd, 2, basename, field->name)) return 1; diff --git a/genevent-new/parser.c b/genevent-new/parser.c index 1b746c30..48f3bdcf 100644 --- a/genevent-new/parser.c +++ b/genevent-new/parser.c @@ -1228,7 +1228,7 @@ void checkNamedTypesImplemented(table_t * named_types) ****************************************************************************/ void generateChecksum(char* facName, - unsigned long * checksum, sequence_t * events) + unsigned int * checksum, sequence_t * events) { unsigned long crc ; int pos; diff --git a/genevent-new/parser.h b/genevent-new/parser.h index 45d7f801..cf90b7a7 100644 --- a/genevent-new/parser.h +++ b/genevent-new/parser.h @@ -141,7 +141,7 @@ typedef struct _facility { sequence_t events; sequence_t unnamed_types; table_t named_types; - unsigned long checksum; + unsigned int checksum; } facility_t; int getSizeindex(unsigned int value); @@ -162,7 +162,7 @@ void parseFields(parse_file_t *in, field_t *f, void checkNamedTypesImplemented(table_t * namedTypes); type_descriptor_t * find_named_type(char *name, table_t * named_types); void generateChecksum(char * facName, - unsigned long * checksum, sequence_t * events); + unsigned int * checksum, sequence_t * events); /* get attributes */ -- 2.34.1