From 31f46bb638c553356395330f200832f87e81a7e4 Mon Sep 17 00:00:00 2001 From: Anders Blomdell <anders.blomdell@control.lth.se> Date: Thu, 23 Jun 2016 12:52:59 +0200 Subject: [PATCH] labcomm_ to labcomm2014_ prefix changes --- compiler/2014/C_CodeGen.jrag | 6 +- examples/twoway/client.c | 2 +- examples/twoway/decimating.c | 18 +-- examples/twoway/decimating.h | 2 +- examples/twoway/introspecting.c | 22 ++-- examples/twoway/introspecting.h | 2 +- examples/twoway/server.c | 2 +- examples/user_types/example_decoder.c | 4 +- lib/c/2014/experimental/ThrottleDrv/display.h | 2 +- .../experimental/ThrottleDrv/ethernet_drv.c | 2 +- lib/c/2014/experimental/ethaddr.c | 2 +- lib/c/2014/experimental/labcomm_sig_parser.c | 44 +++---- lib/c/2014/experimental/labcomm_sig_parser.h | 40 +++--- lib/c/2014/experimental/udp_hack.c | 2 +- lib/c/2014/labcomm2014.c | 8 +- lib/c/2014/labcomm2014.h | 4 +- lib/c/2014/labcomm2014_compat_osx.h | 4 +- lib/c/2014/labcomm2014_compat_vxworks.h | 4 +- lib/c/2014/labcomm2014_decoder.c | 94 +++++++------- .../2014/labcomm2014_dynamic_buffer_writer.c | 4 +- lib/c/2014/labcomm2014_encoder.c | 56 ++++----- lib/c/2014/labcomm2014_ioctl.h | 116 +++++++++--------- lib/c/2014/labcomm2014_private.h | 104 ++++++++-------- lib/c/2014/labcomm2014_pthread_scheduler.c | 4 +- lib/c/2014/labcomm2014_renaming_decoder.c | 14 +-- lib/c/2014/labcomm2014_renaming_encoder.c | 14 +-- lib/c/2014/labcomm2014_renaming_registry.c | 22 ++-- lib/c/2014/labcomm2014_scheduler.h | 4 +- lib/c/2014/labcomm2014_scheduler_private.h | 4 +- lib/c/2014/labcomm2014_type_signature.c | 2 +- lib/c/2014/labcomm2014_type_signature.h | 26 ++-- lib/c/2014/test/labcomm_mem_reader.h | 4 +- lib/c/2014/test/labcomm_mem_writer.c | 2 +- lib/c/2014/test/labcomm_mem_writer.h | 4 +- lib/c/2014/test/test_labcomm_errors.c | 12 +- lib/c/2014/test/test_labcomm_errors.h | 4 +- lib/c/2014/test/test_signature_numbers.c | 4 +- 37 files changed, 332 insertions(+), 332 deletions(-) diff --git a/compiler/2014/C_CodeGen.jrag b/compiler/2014/C_CodeGen.jrag index a68fa0e..fe64ca1 100644 --- a/compiler/2014/C_CodeGen.jrag +++ b/compiler/2014/C_CodeGen.jrag @@ -1465,7 +1465,7 @@ aspect C_Constructor { } public void Specification.C_emitConstructor(C_env env) { - env.println("LABCOMM_CONSTRUCTOR void init_" + + env.println("LABCOMM2014_CONSTRUCTOR void labcomm2014_init_" + env.prefix + "_signatures(void)"); env.println("{"); env.indent(); @@ -1502,7 +1502,7 @@ aspect C_Constructor { } public void Specification.C_emitConstructorDeclaration(C_env env) { - env.println("void init_" + env.prefix + "_signatures(void);"); + env.println("void labcomm2014_init_" + env.prefix + "_signatures(void);"); } } @@ -1691,7 +1691,7 @@ aspect C_Sizeof { aspect C_forAll { public void Specification.C_emitForAll(C_env env) { - env.print("#define LABCOMM_FORALL_SAMPLES_" + env.lcName + + env.print("#define LABCOMM2014_FORALL_SAMPLES_" + env.lcName + "(func, sep)"); env.indent(); boolean needSeparator = false; diff --git a/examples/twoway/client.c b/examples/twoway/client.c index f0e5447..e04f349 100644 --- a/examples/twoway/client.c +++ b/examples/twoway/client.c @@ -21,7 +21,7 @@ #include <errno.h> #include <arpa/inet.h> -#ifndef LABCOMM_OS_DARWIN +#ifndef LABCOMM2014_OS_DARWIN #include <linux/tcp.h> #else #include <netinet/in.h> diff --git a/examples/twoway/decimating.c b/examples/twoway/decimating.c index f6696db..34feb1e 100644 --- a/examples/twoway/decimating.c +++ b/examples/twoway/decimating.c @@ -35,12 +35,12 @@ struct decimating_private { int encoder_initialized; struct labcomm2014_reader_action_context reader_action_context; struct labcomm2014_writer_action_context writer_action_context; - LABCOMM_SIGNATURE_ARRAY_DEF(writer_decimation, + LABCOMM2014_SIGNATURE_ARRAY_DEF(writer_decimation, struct decimation { int n; int current; }); - LABCOMM_SIGNATURE_ARRAY_DEF(reader_decimation, int); + LABCOMM2014_SIGNATURE_ARRAY_DEF(reader_decimation, int); }; static void set_decimation( @@ -51,7 +51,7 @@ static void set_decimation( struct decimation *decimation; labcomm2014_scheduler_data_lock(decimating->scheduler); - decimation = LABCOMM_SIGNATURE_ARRAY_REF(decimating->memory, + decimation = LABCOMM2014_SIGNATURE_ARRAY_REF(decimating->memory, decimating->writer_decimation, struct decimation, value->signature_index); @@ -115,7 +115,7 @@ static int wrap_reader_start( int *decimation, amount; labcomm2014_scheduler_data_lock(decimating->scheduler); - decimation = LABCOMM_SIGNATURE_ARRAY_REF(decimating->memory, + decimation = LABCOMM2014_SIGNATURE_ARRAY_REF(decimating->memory, decimating->reader_decimation, int, local_index); @@ -148,7 +148,7 @@ static int wrap_reader_ioctl( va_end(va); labcomm2014_scheduler_data_lock(decimating->scheduler); - decimation = LABCOMM_SIGNATURE_ARRAY_REF(decimating->memory, + decimation = LABCOMM2014_SIGNATURE_ARRAY_REF(decimating->memory, decimating->reader_decimation, int, local_index); @@ -204,11 +204,11 @@ static int wrap_writer_start( struct decimation *decimation; int result; - if (index < LABCOMM_USER) { + if (index < LABCOMM2014_USER) { result = 0; } else { labcomm2014_scheduler_data_lock(decimating->scheduler); - decimation = LABCOMM_SIGNATURE_ARRAY_REF(decimating->memory, + decimation = LABCOMM2014_SIGNATURE_ARRAY_REF(decimating->memory, decimating->writer_decimation, struct decimation, index); decimation->current++; @@ -269,8 +269,8 @@ struct decimating *decimating_new( result->error = error; result->memory = memory; result->scheduler = scheduler; - LABCOMM_SIGNATURE_ARRAY_INIT(result->writer_decimation, struct decimation); - LABCOMM_SIGNATURE_ARRAY_INIT(result->reader_decimation, int); + LABCOMM2014_SIGNATURE_ARRAY_INIT(result->writer_decimation, struct decimation); + LABCOMM2014_SIGNATURE_ARRAY_INIT(result->reader_decimation, int); goto out_ok; diff --git a/examples/twoway/decimating.h b/examples/twoway/decimating.h index 3d91c67..e000d53 100644 --- a/examples/twoway/decimating.h +++ b/examples/twoway/decimating.h @@ -16,6 +16,6 @@ extern struct decimating *decimating_new( struct labcomm2014_memory *memory, struct labcomm2014_scheduler *scheduler); -#define SET_DECIMATION LABCOMM_IOSW('d',0,int) +#define SET_DECIMATION LABCOMM2014_IOSW('d',0,int) #endif diff --git a/examples/twoway/introspecting.c b/examples/twoway/introspecting.c index 6491dc6..fcd987c 100644 --- a/examples/twoway/introspecting.c +++ b/examples/twoway/introspecting.c @@ -35,13 +35,13 @@ struct introspecting_private { struct labcomm2014_reader_action_context reader_action_context; struct labcomm2014_writer_action_context writer_action_context; - LABCOMM_SIGNATURE_ARRAY_DEF(remote, + LABCOMM2014_SIGNATURE_ARRAY_DEF(remote, struct remote { char *name; int size; uint8_t *signature; }); - LABCOMM_SIGNATURE_ARRAY_DEF(local, + LABCOMM2014_SIGNATURE_ARRAY_DEF(local, struct local { enum introspecting_status status; const struct labcomm2014_signature *signature; @@ -55,7 +55,7 @@ static struct local *get_local(struct introspecting_private *introspecting, /* Called with data_lock held */ struct local *local; - local = LABCOMM_SIGNATURE_ARRAY_REF(introspecting->memory, + local = LABCOMM2014_SIGNATURE_ARRAY_REF(introspecting->memory, introspecting->local, struct local, index); @@ -67,10 +67,10 @@ static struct local *get_local(struct introspecting_private *introspecting, int i; local->status = introspecting_unhandled; - LABCOMM_SIGNATURE_ARRAY_FOREACH(introspecting->remote, struct remote, i) { + LABCOMM2014_SIGNATURE_ARRAY_FOREACH(introspecting->remote, struct remote, i) { struct remote *r; - r = LABCOMM_SIGNATURE_ARRAY_REF(introspecting->memory, + r = LABCOMM2014_SIGNATURE_ARRAY_REF(introspecting->memory, introspecting->remote, struct remote, i); if (r->name && strcmp(signature->name, r->name) == 0 && @@ -92,7 +92,7 @@ static void handles_signature( struct remote *remote; labcomm2014_scheduler_data_lock(introspecting->scheduler); - remote = LABCOMM_SIGNATURE_ARRAY_REF(introspecting->memory, + remote = LABCOMM2014_SIGNATURE_ARRAY_REF(introspecting->memory, introspecting->remote, struct remote, value->index); @@ -103,10 +103,10 @@ static void handles_signature( memcpy(remote->signature, value->signature.a, value->signature.n_0); remote->size = value->signature.n_0; - LABCOMM_SIGNATURE_ARRAY_FOREACH(introspecting->local, struct local, i) { + LABCOMM2014_SIGNATURE_ARRAY_FOREACH(introspecting->local, struct local, i) { struct local *l; - l = LABCOMM_SIGNATURE_ARRAY_REF(introspecting->memory, + l = LABCOMM2014_SIGNATURE_ARRAY_REF(introspecting->memory, introspecting->local, struct local, i); if (l->signature && l->status == introspecting_unhandled && @@ -229,7 +229,7 @@ static int wrap_writer_start( { struct introspecting_private *introspecting = action_context->context; - if (index >= LABCOMM_USER && value == NULL) { + if (index >= LABCOMM2014_USER && value == NULL) { struct local *local; labcomm2014_scheduler_data_lock(introspecting->scheduler); @@ -308,8 +308,8 @@ extern struct introspecting *introspecting_new( result->error = error; result->memory = memory; result->scheduler = scheduler; - LABCOMM_SIGNATURE_ARRAY_INIT(result->remote, struct remote); - LABCOMM_SIGNATURE_ARRAY_INIT(result->local, struct local); + LABCOMM2014_SIGNATURE_ARRAY_INIT(result->remote, struct remote); + LABCOMM2014_SIGNATURE_ARRAY_INIT(result->local, struct local); goto out_ok; diff --git a/examples/twoway/introspecting.h b/examples/twoway/introspecting.h index bcd3be7..6022a84 100644 --- a/examples/twoway/introspecting.h +++ b/examples/twoway/introspecting.h @@ -40,7 +40,7 @@ extern struct introspecting *introspecting_new( struct labcomm2014_memory *memory, struct labcomm2014_scheduler *scheduler); -#define HAS_SIGNATURE LABCOMM_IOS('i',2) +#define HAS_SIGNATURE LABCOMM2014_IOS('i',2) enum introspecting_status { introspecting_unknown, introspecting_unhandled, introspecting_unregistered, diff --git a/examples/twoway/server.c b/examples/twoway/server.c index 152f8a9..cf4553b 100644 --- a/examples/twoway/server.c +++ b/examples/twoway/server.c @@ -20,7 +20,7 @@ */ #include <arpa/inet.h> -#ifndef LABCOMM_OS_DARWIN +#ifndef LABCOMM2014_OS_DARWIN #include <linux/tcp.h> #else #include <netinet/in.h> diff --git a/examples/user_types/example_decoder.c b/examples/user_types/example_decoder.c index 0237b76..2c35da9 100644 --- a/examples/user_types/example_decoder.c +++ b/examples/user_types/example_decoder.c @@ -28,7 +28,7 @@ static void handle_test_theSecondInt(int *v,void *context) { printf("Got theSecondInt. (%d) \n", *v); } -#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS +#ifdef LABCOMM2014_USE_UNSUPPORTED_TYPEDEFS static void handle_type_def(struct labcomm2014_raw_type_def *v,void *context) { printf("Got type_def. (0x%x) %s\n", v->index, v->name); } @@ -71,7 +71,7 @@ int main(int argc, char *argv[]) { labcomm2014_decoder_register_test_theFirstInt(decoder, handle_test_theFirstInt, context); labcomm2014_decoder_register_test_theSecondInt(decoder, handle_test_theSecondInt, context); labcomm2014_decoder_register_test_twoLines(decoder, handle_test_twoLines, context); -#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS +#ifdef LABCOMM2014_USE_UNSUPPORTED_TYPEDEFS labcomm2014_decoder_register_labcomm2014_type_def(decoder, handle_type_def, context); labcomm2014_decoder_register_labcomm2014_type_binding(decoder, handle_type_binding, context); #endif diff --git a/lib/c/2014/experimental/ThrottleDrv/display.h b/lib/c/2014/experimental/ThrottleDrv/display.h index 49c9cd4..3facac7 100644 --- a/lib/c/2014/experimental/ThrottleDrv/display.h +++ b/lib/c/2014/experimental/ThrottleDrv/display.h @@ -3,7 +3,7 @@ #define DISPLAY_ERR(s) perror(s); // Some projects can not use stdio.h. -#ifndef LABCOMM_NO_STDIO +#ifndef LABCOMM2014_NO_STDIO #include <stdio.h> #endif diff --git a/lib/c/2014/experimental/ThrottleDrv/ethernet_drv.c b/lib/c/2014/experimental/ThrottleDrv/ethernet_drv.c index 9b4126e..f90a5ab 100644 --- a/lib/c/2014/experimental/ThrottleDrv/ethernet_drv.c +++ b/lib/c/2014/experimental/ThrottleDrv/ethernet_drv.c @@ -14,7 +14,7 @@ #include "display.h" // Some projects can not use stdio.h. -#ifndef LABCOMM_NO_STDIO +#ifndef LABCOMM2014_NO_STDIO #include <stdio.h> #endif diff --git a/lib/c/2014/experimental/ethaddr.c b/lib/c/2014/experimental/ethaddr.c index 5aed408..b673c33 100644 --- a/lib/c/2014/experimental/ethaddr.c +++ b/lib/c/2014/experimental/ethaddr.c @@ -1,7 +1,7 @@ #include "ethaddr.h" // Some projects can not use stdio.h. -#ifndef LABCOMM_NO_STDIO +#ifndef LABCOMM2014_NO_STDIO #include <stdio.h> #endif diff --git a/lib/c/2014/experimental/labcomm_sig_parser.c b/lib/c/2014/experimental/labcomm_sig_parser.c index 75e9771..5d24505 100644 --- a/lib/c/2014/experimental/labcomm_sig_parser.c +++ b/lib/c/2014/experimental/labcomm_sig_parser.c @@ -222,26 +222,26 @@ void getStr(labcomm_sig_parser_t *b, unsigned char *dest, size_t size) { struct labcomm_signature *get_sig_t(labcomm_sig_parser_t *p, unsigned int uid) { - return &(p->sig_ts[uid-LABCOMM_USER]); + return &(p->sig_ts[uid-LABCOMM2014_USER]); } unsigned int get_signature_len(labcomm_sig_parser_t *p, unsigned int uid){ - //return signatures_length[uid-LABCOMM_USER]; - return p->sig_ts[uid-LABCOMM_USER].size; + //return signatures_length[uid-LABCOMM2014_USER]; + return p->sig_ts[uid-LABCOMM2014_USER].size; } unsigned char* get_signature(labcomm_sig_parser_t *p, unsigned int uid){ - //return signatures[uid-LABCOMM_USER]; - return p->sig_ts[uid-LABCOMM_USER].signature; + //return signatures[uid-LABCOMM2014_USER]; + return p->sig_ts[uid-LABCOMM2014_USER].signature; } //is this needed? //unsigned int get_signature_name_len(labcomm_sig_parser_t *p, unsigned int uid){ -// return signatures_name_length[uid-LABCOMM_USER]; +// return signatures_name_length[uid-LABCOMM2014_USER]; //} char* get_signature_name(labcomm_sig_parser_t *p, unsigned int uid){ - //return signatures_name[uid-LABCOMM_USER]; - return p->sig_ts[uid-LABCOMM_USER].name; + //return signatures_name[uid-LABCOMM2014_USER]; + return p->sig_ts[uid-LABCOMM2014_USER].name; } void dump_signature(labcomm_sig_parser_t *p, unsigned int uid){ @@ -316,7 +316,7 @@ static unsigned char labcomm_varint_sizeof(unsigned int i) } int encoded_size_static(struct labcomm_signature *sig, void *unused) { -#ifdef LABCOMM_EXPERIMENTAL_CACHED_ENCODED_SIZE +#ifdef LABCOMM2014_EXPERIMENTAL_CACHED_ENCODED_SIZE if(sig->cached_encoded_size == -1) { error("encoded_size_static called for var_size sample or uninitialized signature"); } @@ -375,17 +375,17 @@ static int accept_signature(labcomm_sig_parser_t *d, struct labcomm_signature *newsig = get_sig_t(d, uid); // newsig->type = type; if(len <= d->max_sig_len) { - d->signatures_length[uid-LABCOMM_USER] = len; - memcpy(d->signatures[uid-LABCOMM_USER], &d->c[start], len); + d->signatures_length[uid-LABCOMM2014_USER] = len; + memcpy(d->signatures[uid-LABCOMM2014_USER], &d->c[start], len); newsig->size = len; - newsig->signature = d->signatures[uid-LABCOMM_USER]; + newsig->signature = d->signatures[uid-LABCOMM2014_USER]; newsig->name = name; } else { error("sig longer than max length (this ought to be dynamic...)"); } VERBOSE_PRINTF("signature for uid %x: %s (start=%x,end=%x,len=%d)\n", uid, get_signature_name(d, uid), start,end, len); INFO_PRINTF("accept_signature: %s\n", newsig->name); -#ifdef LABCOMM_EXPERIMENTAL_CACHED_ENCODED_SIZE +#ifdef LABCOMM2014_EXPERIMENTAL_CACHED_ENCODED_SIZE if(! d->current_decl_is_varsize) { newsig->cached_encoded_size = enc_size; newsig->encoded_size = encoded_size_static; @@ -421,17 +421,17 @@ static int accept_decl(labcomm_sig_parser_t *d, labcomm_type type) } if(nlen < d->max_name_len) { // leave 1 byte for terminating NULL char *name; - d->signatures_name_length[uid-LABCOMM_USER] = nlen; - memcpy(d->signatures_name[uid-LABCOMM_USER], &d->c[nstart+lenlen], nlen); - d->signatures_name[uid-LABCOMM_USER][nlen]=0; - name = d->signatures_name[uid-LABCOMM_USER]; + d->signatures_name_length[uid-LABCOMM2014_USER] = nlen; + memcpy(d->signatures_name[uid-LABCOMM2014_USER], &d->c[nstart+lenlen], nlen); + d->signatures_name[uid-LABCOMM2014_USER][nlen]=0; + name = d->signatures_name[uid-LABCOMM2014_USER]; return accept_signature(d, type, start, uid, name); } else { error("sig name longer than max length (this ought to be dynamic..."); return FALSE; } } else { - error("sample_decl with uid < LABCOMM_USER"); + error("sample_decl with uid < LABCOMM2014_USER"); return FALSE; } } @@ -481,7 +481,7 @@ int accept_packet(labcomm_sig_parser_t *d) { #endif get_varint(d); //ignore type id field VERBOSE_PRINTF("sid=0x%x, tid=0x%x\n ", sid, tid); - } else if(type >= LABCOMM_USER) { + } else if(type >= LABCOMM2014_USER) { #ifdef EXIT_WHEN_RECEIVING_DATA printf("*** got sample data, exiting\n"); exit(0); @@ -490,7 +490,7 @@ int accept_packet(labcomm_sig_parser_t *d) { #endif } else { #ifdef EXIT_ON_UNKNOWN_TAG - error("got unknown type (<LABCOMM_USER)"); + error("got unknown type (<LABCOMM2014_USER)"); exit(1); #else int len = get_varint(d); // length field @@ -504,13 +504,13 @@ int accept_packet(labcomm_sig_parser_t *d) { static int accept_user_id(labcomm_sig_parser_t *d){ size_t nbytes; int uid = peek_varint(d, &nbytes); - if(uid >= LABCOMM_USER) { + if(uid >= LABCOMM2014_USER) { advancen(d, nbytes); VERBOSE_PRINTF("uid = 0x%x ", uid); push_val(d, uid); return TRUE; } else { - error("uid < LABCOMM_USER"); + error("uid < LABCOMM2014_USER"); return FALSE; } } diff --git a/lib/c/2014/experimental/labcomm_sig_parser.h b/lib/c/2014/experimental/labcomm_sig_parser.h index 46a1d1e..692ba50 100644 --- a/lib/c/2014/experimental/labcomm_sig_parser.h +++ b/lib/c/2014/experimental/labcomm_sig_parser.h @@ -5,8 +5,8 @@ * registered handler. */ -#ifndef LABCOMM_SIG_PARSER_H -#define LABCOMM_SIG_PARSER_H +#ifndef LABCOMM2014_SIG_PARSER_H +#define LABCOMM2014_SIG_PARSER_H #include "../labcomm.h" #include "../labcomm_private.h" @@ -113,23 +113,23 @@ int skip_packed_sample_data(labcomm_sig_parser_t *p, struct labcomm_signature *s #undef RETURN_STRINGS // not really tested typedef enum{ - PKG_VERSION = LABCOMM_VERSION, - PKG_SAMPLE_DECL = LABCOMM_SAMPLE_DEF, - PKG_SAMPLE_REF = LABCOMM_SAMPLE_REF, - PKG_TYPE_DECL = LABCOMM_TYPE_DEF, - PKG_TYPE_BINDING = LABCOMM_TYPE_BINDING, - - ARRAY_DECL = LABCOMM_ARRAY, - STRUCT_DECL = LABCOMM_STRUCT, - - TYPE_BOOLEAN = LABCOMM_BOOLEAN, - TYPE_BYTE = LABCOMM_BYTE, - TYPE_SHORT = LABCOMM_SHORT, - TYPE_INTEGER = LABCOMM_INT, - TYPE_LONG = LABCOMM_LONG, - TYPE_FLOAT = LABCOMM_FLOAT, - TYPE_DOUBLE = LABCOMM_DOUBLE, - TYPE_STRING = LABCOMM_STRING, - TYPE_SAMPLE_REF = LABCOMM_REF + PKG_VERSION = LABCOMM2014_VERSION, + PKG_SAMPLE_DECL = LABCOMM2014_SAMPLE_DEF, + PKG_SAMPLE_REF = LABCOMM2014_SAMPLE_REF, + PKG_TYPE_DECL = LABCOMM2014_TYPE_DEF, + PKG_TYPE_BINDING = LABCOMM2014_TYPE_BINDING, + + ARRAY_DECL = LABCOMM2014_ARRAY, + STRUCT_DECL = LABCOMM2014_STRUCT, + + TYPE_BOOLEAN = LABCOMM2014_BOOLEAN, + TYPE_BYTE = LABCOMM2014_BYTE, + TYPE_SHORT = LABCOMM2014_SHORT, + TYPE_INTEGER = LABCOMM2014_INT, + TYPE_LONG = LABCOMM2014_LONG, + TYPE_FLOAT = LABCOMM2014_FLOAT, + TYPE_DOUBLE = LABCOMM2014_DOUBLE, + TYPE_STRING = LABCOMM2014_STRING, + TYPE_SAMPLE_REF = LABCOMM2014_REF } labcomm_type ; #endif diff --git a/lib/c/2014/experimental/udp_hack.c b/lib/c/2014/experimental/udp_hack.c index 1d26eb7..4b6db64 100644 --- a/lib/c/2014/experimental/udp_hack.c +++ b/lib/c/2014/experimental/udp_hack.c @@ -6,7 +6,7 @@ #include <unistd.h> // Some projects can not use stdio.h. -#ifndef LABCOMM_NO_STDIO +#ifndef LABCOMM2014_NO_STDIO #include <stdio.h> #endif diff --git a/lib/c/2014/labcomm2014.c b/lib/c/2014/labcomm2014.c index 5ce088c..f5ac319 100644 --- a/lib/c/2014/labcomm2014.c +++ b/lib/c/2014/labcomm2014.c @@ -20,8 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifdef LABCOMM_COMPAT - #include LABCOMM_COMPAT +#ifdef LABCOMM2014_COMPAT + #include LABCOMM2014_COMPAT #else #include <stdio.h> #include <strings.h> @@ -164,7 +164,7 @@ const char *labcomm2014_error_get_str(enum labcomm2014_error error_id) void labcomm2014_on_error_fprintf(enum labcomm2014_error error_id, size_t nbr_va_args, ...) { -#ifndef LABCOMM_NO_STDIO +#ifndef LABCOMM2014_NO_STDIO const char *err_msg = labcomm2014_error_get_str(error_id); // The final string to print. if (err_msg == NULL) { err_msg = "Error with an unknown error ID occured."; @@ -242,7 +242,7 @@ void *labcomm2014_signature_array_ref(struct labcomm2014_memory *memory, } } -static int local_index = LABCOMM_USER; +static int local_index = LABCOMM2014_USER; void labcomm2014_set_local_index(struct labcomm2014_signature *signature) { diff --git a/lib/c/2014/labcomm2014.h b/lib/c/2014/labcomm2014.h index a4aa2f5..96599c5 100644 --- a/lib/c/2014/labcomm2014.h +++ b/lib/c/2014/labcomm2014.h @@ -25,8 +25,8 @@ #include <stdarg.h> -#ifdef LABCOMM_COMPAT - #include LABCOMM_COMPAT +#ifdef LABCOMM2014_COMPAT + #include LABCOMM2014_COMPAT #else #include <stdint.h> #include <unistd.h> diff --git a/lib/c/2014/labcomm2014_compat_osx.h b/lib/c/2014/labcomm2014_compat_osx.h index 1219f3f..1fc7ea3 100644 --- a/lib/c/2014/labcomm2014_compat_osx.h +++ b/lib/c/2014/labcomm2014_compat_osx.h @@ -2,8 +2,8 @@ #error "__APPLE__" not defined #endif -#ifndef LABCOMM_COMPAT_OSX -#define LABCOMM_COMPAT_OSX +#ifndef LABCOMM2014_COMPAT_OSX +#define LABCOMM2014_COMPAT_OSX #include <machine/endian.h> #include <stdio.h> diff --git a/lib/c/2014/labcomm2014_compat_vxworks.h b/lib/c/2014/labcomm2014_compat_vxworks.h index 94b161f..14f1035 100644 --- a/lib/c/2014/labcomm2014_compat_vxworks.h +++ b/lib/c/2014/labcomm2014_compat_vxworks.h @@ -1,5 +1,5 @@ -#ifndef _LABCOMM_COMPAT_VXWORKS_H_ -#define _LABCOMM_COMPAT_VXWORKS_H_ +#ifndef _LABCOMM2014_COMPAT_VXWORKS_H_ +#define _LABCOMM2014_COMPAT_VXWORKS_H_ #ifndef __VXWORKS__ #error "__VXWORKS__" not defined diff --git a/lib/c/2014/labcomm2014_decoder.c b/lib/c/2014/labcomm2014_decoder.c index 102d0da..7f16a79 100644 --- a/lib/c/2014/labcomm2014_decoder.c +++ b/lib/c/2014/labcomm2014_decoder.c @@ -48,10 +48,10 @@ struct sample_entry { struct decoder { struct labcomm2014_decoder decoder; - LABCOMM_SIGNATURE_ARRAY_DEF(local, struct sample_entry); - LABCOMM_SIGNATURE_ARRAY_DEF(remote_to_local, int); - LABCOMM_SIGNATURE_ARRAY_DEF(local_ref, const struct labcomm2014_signature *); - LABCOMM_SIGNATURE_ARRAY_DEF(remote_to_local_ref, int); + LABCOMM2014_SIGNATURE_ARRAY_DEF(local, struct sample_entry); + LABCOMM2014_SIGNATURE_ARRAY_DEF(remote_to_local, int); + LABCOMM2014_SIGNATURE_ARRAY_DEF(local_ref, const struct labcomm2014_signature *); + LABCOMM2014_SIGNATURE_ARRAY_DEF(remote_to_local_ref, int); }; static int handle_sample_def(struct labcomm2014_decoder *d, int remote_index, @@ -64,12 +64,12 @@ static int handle_sample_def(struct labcomm2014_decoder *d, int remote_index, int local_index = 0; labcomm2014_scheduler_data_lock(d->scheduler); - LABCOMM_SIGNATURE_ARRAY_FOREACH(id->local, struct sample_entry, i) { + LABCOMM2014_SIGNATURE_ARRAY_FOREACH(id->local, struct sample_entry, i) { struct sample_entry *s; int *remote_to_local; result = -ENOENT; - s = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, + s = LABCOMM2014_SIGNATURE_ARRAY_REF(d->memory, id->local, struct sample_entry, i); if (s->signature && s->signature->size == signature->size && @@ -79,7 +79,7 @@ static int handle_sample_def(struct labcomm2014_decoder *d, int remote_index, s->remote_index = remote_index; local_signature = s->signature; local_index = i; - remote_to_local = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, + remote_to_local = LABCOMM2014_SIGNATURE_ARRAY_REF(d->memory, id->remote_to_local, int, remote_index); *remote_to_local = i; @@ -105,19 +105,19 @@ static int handle_sample_ref(struct labcomm2014_decoder *d, int remote_index, int i; labcomm2014_scheduler_data_lock(d->scheduler); - LABCOMM_SIGNATURE_ARRAY_FOREACH(id->local_ref, + LABCOMM2014_SIGNATURE_ARRAY_FOREACH(id->local_ref, const struct labcomm2014_signature *, i) { const struct labcomm2014_signature *s; int *remote_to_local_ref; result = -ENOENT; - s = LABCOMM_SIGNATURE_ARRAY_GET(id->local_ref, const struct labcomm2014_signature *, i, 0); + s = LABCOMM2014_SIGNATURE_ARRAY_GET(id->local_ref, const struct labcomm2014_signature *, i, 0); if (s && s->signature && s->size == signature->size && strcmp(s->name, signature->name) == 0 && memcmp((void*)s->signature, (void*)signature->signature, signature->size) == 0) { - remote_to_local_ref = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, + remote_to_local_ref = LABCOMM2014_SIGNATURE_ARRAY_REF(d->memory, id->remote_to_local_ref, int, remote_index); @@ -180,15 +180,15 @@ static int decode_sample_def_or_ref(struct labcomm2014_decoder *d, int kind) } } switch (kind) { - case LABCOMM_SAMPLE_DEF: { + case LABCOMM2014_SAMPLE_DEF: { result = handle_sample_def(d, remote_index, &signature); break; } - case LABCOMM_SAMPLE_REF: { + case LABCOMM2014_SAMPLE_REF: { result = handle_sample_ref(d, remote_index, &signature); if (result == -ENOENT) { /* Dummy value to silently continue */ - result = LABCOMM_SAMPLE_REF; + result = LABCOMM2014_SAMPLE_REF; } break; } @@ -259,7 +259,7 @@ static int decode_pragma(struct labcomm2014_decoder *d, } int bytes = labcomm2014_size_string(pragma_type); int psize = len-bytes; - result = decoder_skip(d, psize, LABCOMM_PRAGMA); + result = decoder_skip(d, psize, LABCOMM2014_PRAGMA); out: return result; } @@ -274,14 +274,14 @@ static labcomm2014_decoder_function lookup_h(struct labcomm2014_decoder *d, int *local_index; labcomm2014_scheduler_data_lock(d->scheduler); - local_index = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, + local_index = LABCOMM2014_SIGNATURE_ARRAY_REF(d->memory, id->remote_to_local, int, remote_index); *r_local_index = *local_index; if (*local_index != 0) { struct sample_entry *entry; - entry = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, + entry = LABCOMM2014_SIGNATURE_ARRAY_REF(d->memory, id->local, struct sample_entry, *local_index); wrap->local_index = *local_index; @@ -344,12 +344,12 @@ static int do_decode_one(struct labcomm2014_decoder *d) result = d->reader->error; goto out; } - if (remote_index == LABCOMM_VERSION) { + if (remote_index == LABCOMM2014_VERSION) { char *version = labcomm2014_read_string(d->reader); if (d->reader->error < 0) { result = d->reader->error; } else if (strcmp(version, CURRENT_VERSION) == 0) { - result = LABCOMM_VERSION; + result = LABCOMM2014_VERSION; d->version_ok = 1; } else { result = -ECONNRESET; @@ -365,25 +365,25 @@ static int do_decode_one(struct labcomm2014_decoder *d) } else if (! d->version_ok) { DEBUG_FPRINTF(stderr, "No VERSION %d %d\n", remote_index, length); result = -ECONNRESET; - } else if (remote_index == LABCOMM_SAMPLE_DEF) { - result = decode_sample_def_or_ref(d, LABCOMM_SAMPLE_DEF); - } else if (remote_index == LABCOMM_SAMPLE_REF) { - result = decode_sample_def_or_ref(d, LABCOMM_SAMPLE_REF); - } else if (remote_index == LABCOMM_TYPE_DEF) { + } else if (remote_index == LABCOMM2014_SAMPLE_DEF) { + result = decode_sample_def_or_ref(d, LABCOMM2014_SAMPLE_DEF); + } else if (remote_index == LABCOMM2014_SAMPLE_REF) { + result = decode_sample_def_or_ref(d, LABCOMM2014_SAMPLE_REF); + } else if (remote_index == LABCOMM2014_TYPE_DEF) { result = decode_and_handle(d, d, remote_index); if(result == -ENOENT) { //No handler for type_defs, skip result = decoder_skip(d, length, remote_index); } - } else if (remote_index == LABCOMM_TYPE_BINDING) { + } else if (remote_index == LABCOMM2014_TYPE_BINDING) { result = decode_and_handle(d, d, remote_index); if(result == -ENOENT) { //No handler for type_bindings, skip result = decoder_skip(d, length, remote_index); } - } else if (remote_index == LABCOMM_PRAGMA) { + } else if (remote_index == LABCOMM2014_PRAGMA) { result = decode_pragma(d, d, length); - } else if (remote_index < LABCOMM_USER) { + } else if (remote_index < LABCOMM2014_USER) { DECODER_DEBUG_FPRINTF(stderr, "SKIP %d %d\n", remote_index, length); result = decoder_skip(d, length, remote_index); } else { @@ -430,13 +430,13 @@ static int do_ref_register( local_index = labcomm2014_get_local_index(signature); if (local_index <= 0) { goto out; } labcomm2014_scheduler_data_lock(d->scheduler); - s = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, + s = LABCOMM2014_SIGNATURE_ARRAY_REF(d->memory, id->local_ref, const struct labcomm2014_signature*, local_index); if (s == NULL) { local_index = -ENOMEM; goto unlock; }; if (*s) { goto unlock; } *s = signature; - remote_to_local_ref = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, + remote_to_local_ref = LABCOMM2014_SIGNATURE_ARRAY_REF(d->memory, id->remote_to_local_ref, int, local_index); *remote_to_local_ref = 0; @@ -459,7 +459,7 @@ static int do_ioctl(struct labcomm2014_decoder *d, remote_index = 0; } else { labcomm2014_scheduler_data_lock(d->scheduler); - remote_index = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, + remote_index = LABCOMM2014_SIGNATURE_ARRAY_REF(d->memory, id->local, struct sample_entry, local_index)->remote_index; @@ -471,7 +471,7 @@ static int do_ioctl(struct labcomm2014_decoder *d, return result; } -#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS +#ifdef LABCOMM2014_USE_UNSUPPORTED_TYPEDEFS //// Code for allowing user code to handle type_defs //// (should perhaps be moved to another file) @@ -517,12 +517,12 @@ int labcomm2014_decoder_register_labcomm2014_type_def( ) { struct decoder *id = d->context; - int tag = LABCOMM_TYPE_DEF; + int tag = LABCOMM2014_TYPE_DEF; struct sample_entry *entry; int *remote_to_local; labcomm2014_scheduler_data_lock(d->scheduler); - entry = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, + entry = LABCOMM2014_SIGNATURE_ARRAY_REF(d->memory, id->local, struct sample_entry, tag); if (entry == NULL) { tag = -ENOMEM; goto unlock; } @@ -532,7 +532,7 @@ int labcomm2014_decoder_register_labcomm2014_type_def( entry->handler =(labcomm2014_handler_function) handler; entry->context = context; - remote_to_local = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, + remote_to_local = LABCOMM2014_SIGNATURE_ARRAY_REF(d->memory, id->remote_to_local, int, tag); *remote_to_local = tag; @@ -572,12 +572,12 @@ int labcomm2014_decoder_register_labcomm2014_type_binding( ) { struct decoder *id = d->context; - int tag = LABCOMM_TYPE_BINDING; + int tag = LABCOMM2014_TYPE_BINDING; struct sample_entry *entry; int *remote_to_local; labcomm2014_scheduler_data_lock(d->scheduler); - entry = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, + entry = LABCOMM2014_SIGNATURE_ARRAY_REF(d->memory, id->local, struct sample_entry, tag); if (entry == NULL) { tag = -ENOMEM; goto unlock; } @@ -587,7 +587,7 @@ int labcomm2014_decoder_register_labcomm2014_type_binding( entry->handler =(labcomm2014_handler_function) handler; entry->context = context; - remote_to_local = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, + remote_to_local = LABCOMM2014_SIGNATURE_ARRAY_REF(d->memory, id->remote_to_local, int, tag); *remote_to_local = tag; @@ -620,7 +620,7 @@ static int do_register_sample( labcomm2014_reader_end(d->reader, d->reader->action_context); labcomm2014_scheduler_data_lock(d->scheduler); - entry = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, + entry = LABCOMM2014_SIGNATURE_ARRAY_REF(d->memory, id->local, struct sample_entry, local_index); if (entry == NULL) { local_index = -ENOMEM; goto unlock; } @@ -643,10 +643,10 @@ static const struct labcomm2014_sample_ref *do_index_to_sample_ref( int local_index; labcomm2014_scheduler_data_lock(d->scheduler); - local_index = LABCOMM_SIGNATURE_ARRAY_GET(id->remote_to_local_ref, + local_index = LABCOMM2014_SIGNATURE_ARRAY_GET(id->remote_to_local_ref, int, index, 0); if (local_index) { - result = LABCOMM_SIGNATURE_ARRAY_GET(id->local_ref, + result = LABCOMM2014_SIGNATURE_ARRAY_GET(id->local_ref, const struct labcomm2014_signature*, local_index, 0); } @@ -667,11 +667,11 @@ static void do_free(struct labcomm2014_decoder* d) struct labcomm2014_memory *memory = d->memory; labcomm2014_reader_free(d->reader, d->reader->action_context); - LABCOMM_SIGNATURE_ARRAY_FREE(memory, id->local, struct sample_entry); - LABCOMM_SIGNATURE_ARRAY_FREE(memory, id->remote_to_local, int); - LABCOMM_SIGNATURE_ARRAY_FREE(memory, id->local_ref, + LABCOMM2014_SIGNATURE_ARRAY_FREE(memory, id->local, struct sample_entry); + LABCOMM2014_SIGNATURE_ARRAY_FREE(memory, id->remote_to_local, int); + LABCOMM2014_SIGNATURE_ARRAY_FREE(memory, id->local_ref, const struct labcomm2014_signature*); - LABCOMM_SIGNATURE_ARRAY_FREE(memory, id->remote_to_local_ref, int); + LABCOMM2014_SIGNATURE_ARRAY_FREE(memory, id->remote_to_local_ref, int); labcomm2014_memory_free(memory, 0, id); } @@ -711,11 +711,11 @@ struct labcomm2014_decoder *labcomm2014_decoder_new( result->decoder.ioctl = do_ioctl; result->decoder.index_to_sample_ref = do_index_to_sample_ref; result->decoder.ref_get = do_ref_get; - LABCOMM_SIGNATURE_ARRAY_INIT(result->local, struct sample_entry); - LABCOMM_SIGNATURE_ARRAY_INIT(result->remote_to_local, int); - LABCOMM_SIGNATURE_ARRAY_INIT(result->local_ref, + LABCOMM2014_SIGNATURE_ARRAY_INIT(result->local, struct sample_entry); + LABCOMM2014_SIGNATURE_ARRAY_INIT(result->remote_to_local, int); + LABCOMM2014_SIGNATURE_ARRAY_INIT(result->local_ref, const struct labcomm2014_signature*); - LABCOMM_SIGNATURE_ARRAY_INIT(result->remote_to_local_ref, int); + LABCOMM2014_SIGNATURE_ARRAY_INIT(result->remote_to_local_ref, int); } return &(result->decoder); } diff --git a/lib/c/2014/labcomm2014_dynamic_buffer_writer.c b/lib/c/2014/labcomm2014_dynamic_buffer_writer.c index c209862..67db27b 100644 --- a/lib/c/2014/labcomm2014_dynamic_buffer_writer.c +++ b/lib/c/2014/labcomm2014_dynamic_buffer_writer.c @@ -108,12 +108,12 @@ static int dyn_ioctl(struct labcomm2014_writer *w, { int result = -ENOTSUP; switch (action) { - case LABCOMM_IOCTL_WRITER_GET_BYTES_WRITTEN: { + case LABCOMM2014_IOCTL_WRITER_GET_BYTES_WRITTEN: { int *value = va_arg(arg, int*); *value = w->pos; result = 0; } break; - case LABCOMM_IOCTL_WRITER_GET_BYTE_POINTER: { + case LABCOMM2014_IOCTL_WRITER_GET_BYTE_POINTER: { void **value = va_arg(arg, void**); *value = w->data; result = 0; diff --git a/lib/c/2014/labcomm2014_encoder.c b/lib/c/2014/labcomm2014_encoder.c index 70a2f9c..59b5a7b 100644 --- a/lib/c/2014/labcomm2014_encoder.c +++ b/lib/c/2014/labcomm2014_encoder.c @@ -27,13 +27,13 @@ #include "labcomm2014_dynamic_buffer_writer.h" //define the following to disable encoding of typedefs -#undef LABCOMM_USE_UNSUPPORTED_TYPEDEFS +#undef LABCOMM2014_USE_UNSUPPORTED_TYPEDEFS struct encoder { struct labcomm2014_encoder encoder; - LABCOMM_SIGNATURE_ARRAY_DEF(registered, int); - LABCOMM_SIGNATURE_ARRAY_DEF(sample_ref, int); - LABCOMM_SIGNATURE_ARRAY_DEF(typedefs, int); + LABCOMM2014_SIGNATURE_ARRAY_DEF(registered, int); + LABCOMM2014_SIGNATURE_ARRAY_DEF(sample_ref, int); + LABCOMM2014_SIGNATURE_ARRAY_DEF(typedefs, int); }; static int do_sample_register( @@ -48,7 +48,7 @@ static int do_sample_register( index = labcomm2014_get_local_index(signature); labcomm2014_scheduler_writer_lock(e->scheduler); if (index <= 0) { goto out; } - done = LABCOMM_SIGNATURE_ARRAY_REF(e->memory, ie->registered, int, index); + done = LABCOMM2014_SIGNATURE_ARRAY_REF(e->memory, ie->registered, int, index); if (*done) { goto out; } *done = 1; @@ -56,7 +56,7 @@ static int do_sample_register( index, signature, NULL); if (err == -EALREADY) { result = 0; goto out; } if (err != 0) { result = err; goto out; } - labcomm2014_write_packed32(e->writer, LABCOMM_SAMPLE_DEF); + labcomm2014_write_packed32(e->writer, LABCOMM2014_SAMPLE_DEF); length = (labcomm2014_size_packed32(index) + labcomm2014_size_string(signature->name) + labcomm2014_size_packed32(signature->size) + @@ -91,7 +91,7 @@ static int do_encode( index = labcomm2014_get_local_index(signature); length = (signature->encoded_size(value)); labcomm2014_scheduler_writer_lock(e->scheduler); - if (! LABCOMM_SIGNATURE_ARRAY_GET(ie->registered, int, index, 0)) { + if (! LABCOMM2014_SIGNATURE_ARRAY_GET(ie->registered, int, index, 0)) { result = -EINVAL; goto no_end; } @@ -129,14 +129,14 @@ static int do_ref_register( labcomm2014_scheduler_writer_lock(e->scheduler); if (index <= 0) { goto out; } - done = LABCOMM_SIGNATURE_ARRAY_REF(e->memory, ie->sample_ref, int, index); + done = LABCOMM2014_SIGNATURE_ARRAY_REF(e->memory, ie->sample_ref, int, index); if (*done) { goto out; } *done = 1; err = labcomm2014_writer_start(e->writer, e->writer->action_context, index, signature, NULL); if (err == -EALREADY) { result = 0; goto out; } if (err != 0) { result = err; goto out; } - labcomm2014_write_packed32(e->writer, LABCOMM_SAMPLE_REF); + labcomm2014_write_packed32(e->writer, LABCOMM2014_SAMPLE_REF); length = (labcomm2014_size_packed32(index) + labcomm2014_size_string(signature->name) + labcomm2014_size_packed32(signature->size) + @@ -166,7 +166,7 @@ int labcomm2014_encoder_ioctl(struct labcomm2014_encoder *encoder, int result; va_list va; - if (LABCOMM_IOC_SIG(action) != LABCOMM_IOC_NOSIG) { + if (LABCOMM2014_IOC_SIG(action) != LABCOMM2014_IOC_NOSIG) { result = -EINVAL; goto out; } @@ -204,7 +204,7 @@ static int do_sample_ref_to_index( if (sample_ref != NULL) { index = labcomm2014_get_local_index( (struct labcomm2014_signature *)sample_ref); - if (! LABCOMM_SIGNATURE_ARRAY_GET(ie->sample_ref, int, index, 0)) { + if (! LABCOMM2014_SIGNATURE_ARRAY_GET(ie->sample_ref, int, index, 0)) { index = 0; } } @@ -214,9 +214,9 @@ static int do_sample_ref_to_index( /********************************************************** * Start of code related to sending (hierarchical) - * typedefs. Define LABCOMM_WITHOUT_TYPEDEFS to disable + * typedefs. Define LABCOMM2014_WITHOUT_TYPEDEFS to disable **********************************************************/ -#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS +#ifdef LABCOMM2014_USE_UNSUPPORTED_TYPEDEFS static void write_sig_tree_byte(char b, const struct labcomm2014_signature *signature, void *context) @@ -274,7 +274,7 @@ static int internal_reg_type( index = labcomm2014_get_local_index(signature); labcomm2014_scheduler_writer_lock(e->scheduler); if (index <= 0) { goto out; } - done = LABCOMM_SIGNATURE_ARRAY_REF(e->memory, ie->typedefs, int, index); + done = LABCOMM2014_SIGNATURE_ARRAY_REF(e->memory, ie->typedefs, int, index); if (*done) { goto out; } *done = 1; err = labcomm2014_writer_start(e->writer, e->writer->action_context, @@ -288,7 +288,7 @@ static int internal_reg_type( labcomm2014_size_packed32(sig_size) + sig_size; - labcomm2014_write_packed32(e->writer, LABCOMM_TYPE_DEF); + labcomm2014_write_packed32(e->writer, LABCOMM2014_TYPE_DEF); labcomm2014_write_packed32(e->writer, len); labcomm2014_write_packed32(e->writer, index); labcomm2014_write_string(e->writer, signature->name); @@ -307,7 +307,7 @@ static int do_type_register( struct labcomm2014_encoder *e, const struct labcomm2014_signature *signature) { -#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS +#ifdef LABCOMM2014_USE_UNSUPPORTED_TYPEDEFS return internal_reg_type(e, signature, LABCOMM2014_FALSE); #else return 0; @@ -319,20 +319,20 @@ static int do_type_bind( const struct labcomm2014_signature *signature, char has_deps) { -#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS +#ifdef LABCOMM2014_USE_UNSUPPORTED_TYPEDEFS int result = -EINVAL; int err; int sindex = labcomm2014_get_local_index(signature); - int tindex = has_deps ? labcomm2014_get_local_type_index(signature) : LABCOMM_BIND_SELF; + int tindex = has_deps ? labcomm2014_get_local_type_index(signature) : LABCOMM2014_BIND_SELF; labcomm2014_scheduler_writer_lock(e->scheduler); if(sindex <= 0 || (has_deps && tindex <= 0)) {goto out;} err = labcomm2014_writer_start(e->writer, e->writer->action_context, - LABCOMM_TYPE_BINDING, signature, NULL); + LABCOMM2014_TYPE_BINDING, signature, NULL); if (err == -EALREADY) { result = 0; goto out; } if (err != 0) { result = err; goto out; } int length = (labcomm2014_size_packed32(sindex) + labcomm2014_size_packed32(tindex)); - labcomm2014_write_packed32(e->writer, LABCOMM_TYPE_BINDING); + labcomm2014_write_packed32(e->writer, LABCOMM2014_TYPE_BINDING); labcomm2014_write_packed32(e->writer, length); labcomm2014_write_packed32(e->writer, sindex); labcomm2014_write_packed32(e->writer, tindex); @@ -365,9 +365,9 @@ static void do_free(struct labcomm2014_encoder* e) struct labcomm2014_memory *memory = e->memory; labcomm2014_writer_free(e->writer, e->writer->action_context); - LABCOMM_SIGNATURE_ARRAY_FREE(e->memory, ie->registered, int); - LABCOMM_SIGNATURE_ARRAY_FREE(e->memory, ie->sample_ref, int); - LABCOMM_SIGNATURE_ARRAY_FREE(e->memory, ie->typedefs, int); + LABCOMM2014_SIGNATURE_ARRAY_FREE(e->memory, ie->registered, int); + LABCOMM2014_SIGNATURE_ARRAY_FREE(e->memory, ie->sample_ref, int); + LABCOMM2014_SIGNATURE_ARRAY_FREE(e->memory, ie->typedefs, int); labcomm2014_memory_free(memory, 0, ie); } @@ -404,16 +404,16 @@ static struct labcomm2014_encoder *internal_encoder_new( result->encoder.ioctl = do_ioctl; result->encoder.sample_ref_to_index = do_sample_ref_to_index; result->encoder.ref_get = do_ref_get; - LABCOMM_SIGNATURE_ARRAY_INIT(result->registered, int); - LABCOMM_SIGNATURE_ARRAY_INIT(result->sample_ref, int); - LABCOMM_SIGNATURE_ARRAY_INIT(result->typedefs, int); + LABCOMM2014_SIGNATURE_ARRAY_INIT(result->registered, int); + LABCOMM2014_SIGNATURE_ARRAY_INIT(result->sample_ref, int); + LABCOMM2014_SIGNATURE_ARRAY_INIT(result->typedefs, int); labcomm2014_writer_alloc(result->encoder.writer, result->encoder.writer->action_context); if(outputVer) { labcomm2014_writer_start(result->encoder.writer, result->encoder.writer->action_context, - LABCOMM_VERSION, NULL, CURRENT_VERSION); - labcomm2014_write_packed32(result->encoder.writer, LABCOMM_VERSION); + LABCOMM2014_VERSION, NULL, CURRENT_VERSION); + labcomm2014_write_packed32(result->encoder.writer, LABCOMM2014_VERSION); length = labcomm2014_size_string(CURRENT_VERSION); labcomm2014_write_packed32(result->encoder.writer, length); labcomm2014_write_string(result->encoder.writer, CURRENT_VERSION); diff --git a/lib/c/2014/labcomm2014_ioctl.h b/lib/c/2014/labcomm2014_ioctl.h index bb321ed..e7b0939 100644 --- a/lib/c/2014/labcomm2014_ioctl.h +++ b/lib/c/2014/labcomm2014_ioctl.h @@ -39,63 +39,63 @@ */ -#define LABCOMM_IOC_NRBITS 8 -#define LABCOMM_IOC_TYPEBITS 8 -#define LABCOMM_IOC_SIZEBITS 13 -#define LABCOMM_IOC_DIRBITS 2 -#define LABCOMM_IOC_SIGBITS 1 -#define LABCOMM_IOC_NRMASK ((1 << LABCOMM_IOC_NRBITS)-1) -#define LABCOMM_IOC_TYPEMASK ((1 << LABCOMM_IOC_TYPEBITS)-1) -#define LABCOMM_IOC_SIZEMASK ((1 << LABCOMM_IOC_SIZEBITS)-1) -#define LABCOMM_IOC_DIRMASK ((1 << LABCOMM_IOC_DIRBITS)-1) -#define LABCOMM_IOC_SIGMASK ((1 << LABCOMM_IOC_SIGBITS)-1) -#define LABCOMM_IOC_NRSHIFT 0 -#define LABCOMM_IOC_TYPESHIFT (LABCOMM_IOC_NRSHIFT+LABCOMM_IOC_NRBITS) -#define LABCOMM_IOC_SIZESHIFT (LABCOMM_IOC_TYPESHIFT+LABCOMM_IOC_TYPEBITS) -#define LABCOMM_IOC_DIRSHIFT (LABCOMM_IOC_SIZESHIFT+LABCOMM_IOC_SIZEBITS) -#define LABCOMM_IOC_SIGSHIFT (LABCOMM_IOC_DIRSHIFT+LABCOMM_IOC_DIRBITS) - -#define LABCOMM_IOC_NOSIG 0U -#define LABCOMM_IOC_USESIG 1U - -#define LABCOMM_IOC_NONE 0U -#define LABCOMM_IOC_WRITE 1U -#define LABCOMM_IOC_READ 2U - -#define LABCOMM_IOC(signature,dir,type,nr,size) \ - (((signature) << LABCOMM_IOC_SIGSHIFT) | \ - ((dir) << LABCOMM_IOC_DIRSHIFT) | \ - ((size) << LABCOMM_IOC_SIZESHIFT) | \ - ((type) << LABCOMM_IOC_TYPESHIFT) | \ - ((nr) << LABCOMM_IOC_NRSHIFT)) - -#define LABCOMM_IOC_SIG(nr) \ - (((nr) >> LABCOMM_IOC_SIGSHIFT) & LABCOMM_IOC_SIGMASK) -#define LABCOMM_IOC_DIR(nr) \ - (((nr) >> LABCOMM_IOC_DIRSHIFT) & LABCOMM_IOC_DIRMASK) -#define LABCOMM_IOC_SIZE(nr) \ - (((nr) >> LABCOMM_IOC_SIZESHIFT) & LABCOMM_IOC_SIZEMASK) -#define LABCOMM_IOC_TYPE(nr) \ - (((nr) >> LABCOMM_IOC_TYPESHIFT) & LABCOMM_IOC_TYPEMASK) -#define LABCOMM_IOC_NR(nr) \ - (((nr) >> LABCOMM_IOC_NRSHIFT) & LABCOMM_IOC_NRMASK) - -#define LABCOMM_IO(type,nr) \ - LABCOMM_IOC(LABCOMM_IOC_NOSIG,LABCOMM_IOC_NONE,type,nr,0) -#define LABCOMM_IOR(type,nr,size) \ - LABCOMM_IOC(LABCOMM_IOC_NOSIG,LABCOMM_IOC_READ,type,nr,sizeof(size)) -#define LABCOMM_IOW(type,nr,size) \ - LABCOMM_IOC(LABCOMM_IOC_NOSIG,LABCOMM_IOC_WRITE,type,nr,sizeof(size)) -#define LABCOMM_IOS(type,nr) \ - LABCOMM_IOC(LABCOMM_IOC_USESIG,LABCOMM_IOC_READ,type,nr,0) -#define LABCOMM_IOSR(type,nr,size) \ - LABCOMM_IOC(LABCOMM_IOC_USESIG,LABCOMM_IOC_READ,type,nr,sizeof(size)) -#define LABCOMM_IOSW(type,nr,size) \ - LABCOMM_IOC(LABCOMM_IOC_USESIG,LABCOMM_IOC_WRITE,type,nr,sizeof(size)) - -#define LABCOMM_IOCTL_WRITER_GET_BYTES_WRITTEN \ - LABCOMM_IOR(0,1,int) -#define LABCOMM_IOCTL_WRITER_GET_BYTE_POINTER \ - LABCOMM_IOR(0,2,void*) +#define LABCOMM2014_IOC_NRBITS 8 +#define LABCOMM2014_IOC_TYPEBITS 8 +#define LABCOMM2014_IOC_SIZEBITS 13 +#define LABCOMM2014_IOC_DIRBITS 2 +#define LABCOMM2014_IOC_SIGBITS 1 +#define LABCOMM2014_IOC_NRMASK ((1 << LABCOMM2014_IOC_NRBITS)-1) +#define LABCOMM2014_IOC_TYPEMASK ((1 << LABCOMM2014_IOC_TYPEBITS)-1) +#define LABCOMM2014_IOC_SIZEMASK ((1 << LABCOMM2014_IOC_SIZEBITS)-1) +#define LABCOMM2014_IOC_DIRMASK ((1 << LABCOMM2014_IOC_DIRBITS)-1) +#define LABCOMM2014_IOC_SIGMASK ((1 << LABCOMM2014_IOC_SIGBITS)-1) +#define LABCOMM2014_IOC_NRSHIFT 0 +#define LABCOMM2014_IOC_TYPESHIFT (LABCOMM2014_IOC_NRSHIFT+LABCOMM2014_IOC_NRBITS) +#define LABCOMM2014_IOC_SIZESHIFT (LABCOMM2014_IOC_TYPESHIFT+LABCOMM2014_IOC_TYPEBITS) +#define LABCOMM2014_IOC_DIRSHIFT (LABCOMM2014_IOC_SIZESHIFT+LABCOMM2014_IOC_SIZEBITS) +#define LABCOMM2014_IOC_SIGSHIFT (LABCOMM2014_IOC_DIRSHIFT+LABCOMM2014_IOC_DIRBITS) + +#define LABCOMM2014_IOC_NOSIG 0U +#define LABCOMM2014_IOC_USESIG 1U + +#define LABCOMM2014_IOC_NONE 0U +#define LABCOMM2014_IOC_WRITE 1U +#define LABCOMM2014_IOC_READ 2U + +#define LABCOMM2014_IOC(signature,dir,type,nr,size) \ + (((signature) << LABCOMM2014_IOC_SIGSHIFT) | \ + ((dir) << LABCOMM2014_IOC_DIRSHIFT) | \ + ((size) << LABCOMM2014_IOC_SIZESHIFT) | \ + ((type) << LABCOMM2014_IOC_TYPESHIFT) | \ + ((nr) << LABCOMM2014_IOC_NRSHIFT)) + +#define LABCOMM2014_IOC_SIG(nr) \ + (((nr) >> LABCOMM2014_IOC_SIGSHIFT) & LABCOMM2014_IOC_SIGMASK) +#define LABCOMM2014_IOC_DIR(nr) \ + (((nr) >> LABCOMM2014_IOC_DIRSHIFT) & LABCOMM2014_IOC_DIRMASK) +#define LABCOMM2014_IOC_SIZE(nr) \ + (((nr) >> LABCOMM2014_IOC_SIZESHIFT) & LABCOMM2014_IOC_SIZEMASK) +#define LABCOMM2014_IOC_TYPE(nr) \ + (((nr) >> LABCOMM2014_IOC_TYPESHIFT) & LABCOMM2014_IOC_TYPEMASK) +#define LABCOMM2014_IOC_NR(nr) \ + (((nr) >> LABCOMM2014_IOC_NRSHIFT) & LABCOMM2014_IOC_NRMASK) + +#define LABCOMM2014_IO(type,nr) \ + LABCOMM2014_IOC(LABCOMM2014_IOC_NOSIG,LABCOMM2014_IOC_NONE,type,nr,0) +#define LABCOMM2014_IOR(type,nr,size) \ + LABCOMM2014_IOC(LABCOMM2014_IOC_NOSIG,LABCOMM2014_IOC_READ,type,nr,sizeof(size)) +#define LABCOMM2014_IOW(type,nr,size) \ + LABCOMM2014_IOC(LABCOMM2014_IOC_NOSIG,LABCOMM2014_IOC_WRITE,type,nr,sizeof(size)) +#define LABCOMM2014_IOS(type,nr) \ + LABCOMM2014_IOC(LABCOMM2014_IOC_USESIG,LABCOMM2014_IOC_READ,type,nr,0) +#define LABCOMM2014_IOSR(type,nr,size) \ + LABCOMM2014_IOC(LABCOMM2014_IOC_USESIG,LABCOMM2014_IOC_READ,type,nr,sizeof(size)) +#define LABCOMM2014_IOSW(type,nr,size) \ + LABCOMM2014_IOC(LABCOMM2014_IOC_USESIG,LABCOMM2014_IOC_WRITE,type,nr,sizeof(size)) + +#define LABCOMM2014_IOCTL_WRITER_GET_BYTES_WRITTEN \ + LABCOMM2014_IOR(0,1,int) +#define LABCOMM2014_IOCTL_WRITER_GET_BYTE_POINTER \ + LABCOMM2014_IOR(0,2,void*) #endif diff --git a/lib/c/2014/labcomm2014_private.h b/lib/c/2014/labcomm2014_private.h index b70c44b..77ee4b4 100644 --- a/lib/c/2014/labcomm2014_private.h +++ b/lib/c/2014/labcomm2014_private.h @@ -23,8 +23,8 @@ #ifndef __LABCOMM2014_PRIVATE_H__ #define __LABCOMM2014_PRIVATE_H__ -#ifdef LABCOMM_COMPAT - #include LABCOMM_COMPAT +#ifdef LABCOMM2014_COMPAT + #include LABCOMM2014_COMPAT #else #include <endian.h> #include <stdio.h> @@ -39,46 +39,46 @@ /* * Allowed packet tags */ -#define LABCOMM_VERSION 0x01 -#define LABCOMM_SAMPLE_DEF 0x02 -#define LABCOMM_SAMPLE_REF 0x03 -#define LABCOMM_TYPE_DEF 0x04 -#define LABCOMM_TYPE_BINDING 0x05 -#define LABCOMM_PRAGMA 0x3f -#define LABCOMM_USER 0x40 /* ..0xffffffff */ +#define LABCOMM2014_VERSION 0x01 +#define LABCOMM2014_SAMPLE_DEF 0x02 +#define LABCOMM2014_SAMPLE_REF 0x03 +#define LABCOMM2014_TYPE_DEF 0x04 +#define LABCOMM2014_TYPE_BINDING 0x05 +#define LABCOMM2014_PRAGMA 0x3f +#define LABCOMM2014_USER 0x40 /* ..0xffffffff */ /* * Predefined aggregate type indices */ -#define LABCOMM_ARRAY 0x10 -#define LABCOMM_STRUCT 0x11 +#define LABCOMM2014_ARRAY 0x10 +#define LABCOMM2014_STRUCT 0x11 /* * Predefined primitive type indices */ -#define LABCOMM_BOOLEAN 0x20 -#define LABCOMM_BYTE 0x21 -#define LABCOMM_SHORT 0x22 -#define LABCOMM_INT 0x23 -#define LABCOMM_LONG 0x24 -#define LABCOMM_FLOAT 0x25 -#define LABCOMM_DOUBLE 0x26 -#define LABCOMM_STRING 0x27 -#define LABCOMM_REF 0x28 +#define LABCOMM2014_BOOLEAN 0x20 +#define LABCOMM2014_BYTE 0x21 +#define LABCOMM2014_SHORT 0x22 +#define LABCOMM2014_INT 0x23 +#define LABCOMM2014_LONG 0x24 +#define LABCOMM2014_FLOAT 0x25 +#define LABCOMM2014_DOUBLE 0x26 +#define LABCOMM2014_STRING 0x27 +#define LABCOMM2014_REF 0x28 /* * other special values */ -#define LABCOMM_BIND_SELF 0 +#define LABCOMM2014_BIND_SELF 0 /* * Macro to automagically call constructors in modules compiled * with the labcomm2014 compiler. If __attribute__((constructor)) is * not supported, these calls has to be done first in main program. */ -#ifndef LABCOMM_CONSTRUCTOR -#define LABCOMM_CONSTRUCTOR __attribute__((constructor)) +#ifndef LABCOMM2014_CONSTRUCTOR +#define LABCOMM2014_CONSTRUCTOR __attribute__((constructor)) #endif /* @@ -244,7 +244,7 @@ struct labcomm2014_decoder { #if __BYTE_ORDER == __LITTLE_ENDIAN -#define LABCOMM_DECODE(name, type) \ +#define LABCOMM2014_DECODE(name, type) \ static inline type labcomm2014_read_##name(struct labcomm2014_reader *r) { \ type result; int i; \ for (i = sizeof(type) - 1 ; i >= 0 ; i--) { \ @@ -262,7 +262,7 @@ struct labcomm2014_decoder { #else -#define LABCOMM_DECODE(name, type) \ +#define LABCOMM2014_DECODE(name, type) \ static inline type labcomm2014_read_##name(struct labcomm2014_reader *r) { \ type result; int i; \ for (i = 0 ; i < sizeof(type) ; i++) { \ @@ -280,13 +280,13 @@ struct labcomm2014_decoder { #endif -LABCOMM_DECODE(boolean, unsigned char) -LABCOMM_DECODE(byte, unsigned char) -LABCOMM_DECODE(short, short) -LABCOMM_DECODE(int, int) -LABCOMM_DECODE(long, long long) -LABCOMM_DECODE(float, float) -LABCOMM_DECODE(double, double) +LABCOMM2014_DECODE(boolean, unsigned char) +LABCOMM2014_DECODE(byte, unsigned char) +LABCOMM2014_DECODE(short, short) +LABCOMM2014_DECODE(int, int) +LABCOMM2014_DECODE(long, long long) +LABCOMM2014_DECODE(float, float) +LABCOMM2014_DECODE(double, double) static inline unsigned int labcomm2014_read_packed32(struct labcomm2014_reader *r) { @@ -447,7 +447,7 @@ int labcomm2014_internal_sizeof(const struct labcomm2014_signature *signature, #if __BYTE_ORDER == __LITTLE_ENDIAN -#define LABCOMM_ENCODE(name, type) \ +#define LABCOMM2014_ENCODE(name, type) \ static inline int labcomm2014_write_##name(struct labcomm2014_writer *w, type data) { \ int i; \ for (i = sizeof(type) - 1 ; i >= 0 ; i--) { \ @@ -464,7 +464,7 @@ int labcomm2014_internal_sizeof(const struct labcomm2014_signature *signature, #else -#define LABCOMM_ENCODE(name, type) \ +#define LABCOMM2014_ENCODE(name, type) \ static inline int labcomm2014_write_##name(struct labcomm2014_writer *w, type data) { \ int i; \ for (i = 0 ; i < sizeof(type) ; i++) { \ @@ -481,13 +481,13 @@ int labcomm2014_internal_sizeof(const struct labcomm2014_signature *signature, #endif -LABCOMM_ENCODE(boolean, unsigned char) -LABCOMM_ENCODE(byte, unsigned char) -LABCOMM_ENCODE(short, short) -LABCOMM_ENCODE(int, int) -LABCOMM_ENCODE(long, long long) -LABCOMM_ENCODE(float, float) -LABCOMM_ENCODE(double, double) +LABCOMM2014_ENCODE(boolean, unsigned char) +LABCOMM2014_ENCODE(byte, unsigned char) +LABCOMM2014_ENCODE(short, short) +LABCOMM2014_ENCODE(int, int) +LABCOMM2014_ENCODE(long, long long) +LABCOMM2014_ENCODE(float, float) +LABCOMM2014_ENCODE(double, double) static inline int labcomm2014_write_packed32(struct labcomm2014_writer *w, unsigned int data) @@ -552,21 +552,21 @@ static inline int labcomm2014_size_string(char *s) * Macros for handling arrays indexed by signature index */ -#define LABCOMM_SIGNATURE_ARRAY_DEF(name, kind) \ +#define LABCOMM2014_SIGNATURE_ARRAY_DEF(name, kind) \ struct { \ int first; \ int last; \ kind *data; \ } name -#define LABCOMM_SIGNATURE_ARRAY_DEF_INIT(name, kind) \ - LABCOMM_SIGNATURE_ARRAY_DEF(name, kind) = { 0, 0, NULL } +#define LABCOMM2014_SIGNATURE_ARRAY_DEF_INIT(name, kind) \ + LABCOMM2014_SIGNATURE_ARRAY_DEF(name, kind) = { 0, 0, NULL } -#define LABCOMM_SIGNATURE_ARRAY_INIT(name, kind) \ +#define LABCOMM2014_SIGNATURE_ARRAY_INIT(name, kind) \ name.first = 0; name.last = 0; name.data = NULL; \ name.data = (kind *)name.data; /* typechecking no-op */ -#define LABCOMM_SIGNATURE_ARRAY_FREE(memory, name, kind) \ +#define LABCOMM2014_SIGNATURE_ARRAY_FREE(memory, name, kind) \ if (name.data) { labcomm2014_memory_free(memory, 0, name.data); } \ name.data = (kind *)NULL; /* typechecking */ @@ -574,25 +574,25 @@ void *labcomm2014_signature_array_ref(struct labcomm2014_memory * memory, int *first, int *last, void **data, int size, int index); /* - * NB: the pointer returned by LABCOMM_SIGNATURE_ARRAY_REF might be - * rendered invalid by a subsequent call to LABCOMM_SIGNATURE_ARRAY_REF + * NB: the pointer returned by LABCOMM2014_SIGNATURE_ARRAY_REF might be + * rendered invalid by a subsequent call to LABCOMM2014_SIGNATURE_ARRAY_REF * on the same SIGNATURE_ARRAY, so make sure not to use the result if - * any other code might have made a call to LABCOMM_SIGNATURE_ARRAY_REF + * any other code might have made a call to LABCOMM2014_SIGNATURE_ARRAY_REF * on the same SIGNATURE_ARRAY. */ -#define LABCOMM_SIGNATURE_ARRAY_REF(memory, name, kind, index) \ +#define LABCOMM2014_SIGNATURE_ARRAY_REF(memory, name, kind, index) \ (name.data = (kind *)name.data, /* typechecking no-op */ \ (kind *)(labcomm2014_signature_array_ref(memory, \ &name.first, &name.last, \ (void **)&name.data, \ sizeof(kind), index))) -#define LABCOMM_SIGNATURE_ARRAY_GET(name, kind, index, nomatch) \ +#define LABCOMM2014_SIGNATURE_ARRAY_GET(name, kind, index, nomatch) \ (name.data = (kind *)name.data, /* typechecking no-op */ \ (name.first <= index && \ index < name.last) ? name.data[index - name.first] : nomatch) -#define LABCOMM_SIGNATURE_ARRAY_FOREACH(name, kind, var) \ +#define LABCOMM2014_SIGNATURE_ARRAY_FOREACH(name, kind, var) \ for (name.data = (kind *)name.data, /* typechecking no-op */ \ var = name.first ; var < name.last ; var++) diff --git a/lib/c/2014/labcomm2014_pthread_scheduler.c b/lib/c/2014/labcomm2014_pthread_scheduler.c index e2f5a21..2aca758 100644 --- a/lib/c/2014/labcomm2014_pthread_scheduler.c +++ b/lib/c/2014/labcomm2014_pthread_scheduler.c @@ -28,8 +28,8 @@ #include "labcomm2014_scheduler_private.h" #include "labcomm2014_pthread_scheduler.h" -#ifdef LABCOMM_COMPAT - #include LABCOMM_COMPAT +#ifdef LABCOMM2014_COMPAT + #include LABCOMM2014_COMPAT #endif struct pthread_time { diff --git a/lib/c/2014/labcomm2014_renaming_decoder.c b/lib/c/2014/labcomm2014_renaming_decoder.c index 0a9f193..4329075 100644 --- a/lib/c/2014/labcomm2014_renaming_decoder.c +++ b/lib/c/2014/labcomm2014_renaming_decoder.c @@ -31,7 +31,7 @@ struct decoder { struct labcomm2014_renaming_registry *registry; char *(*rename_func)(struct labcomm2014_memory *m, char *name, void *context); void *context; - LABCOMM_SIGNATURE_ARRAY_DEF(renamed, + LABCOMM2014_SIGNATURE_ARRAY_DEF(renamed, struct labcomm2014_renaming_rename *); }; @@ -45,7 +45,7 @@ static struct labcomm2014_renaming_rename *get_renamed( index = labcomm2014_get_local_index(signature); labcomm2014_scheduler_data_lock(d->scheduler); - result = LABCOMM_SIGNATURE_ARRAY_GET(id->renamed, + result = LABCOMM2014_SIGNATURE_ARRAY_GET(id->renamed, struct labcomm2014_renaming_rename *, index, NULL); labcomm2014_scheduler_data_unlock(d->scheduler); @@ -70,7 +70,7 @@ static struct labcomm2014_renaming_rename *set_renamed( id->rename_func, id->context); if (entry == NULL) { goto out; } labcomm2014_scheduler_data_lock(d->scheduler); - renamed = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, id->renamed, + renamed = LABCOMM2014_SIGNATURE_ARRAY_REF(d->memory, id->renamed, struct labcomm2014_renaming_rename *, index); if (renamed == NULL) { goto free_unlock; } @@ -163,18 +163,18 @@ static void do_free(struct labcomm2014_decoder *d) struct decoder *id = d->context; int i; - LABCOMM_SIGNATURE_ARRAY_FOREACH(id->renamed, + LABCOMM2014_SIGNATURE_ARRAY_FOREACH(id->renamed, struct labcomm2014_renaming_rename *, i) { struct labcomm2014_renaming_rename *r; - r = LABCOMM_SIGNATURE_ARRAY_GET(id->renamed, + r = LABCOMM2014_SIGNATURE_ARRAY_GET(id->renamed, struct labcomm2014_renaming_rename *, i, NULL); if (r) { labcomm2014_renaming_rename_free(id->registry, r); } } - LABCOMM_SIGNATURE_ARRAY_FREE(d->memory, id->renamed, + LABCOMM2014_SIGNATURE_ARRAY_FREE(d->memory, id->renamed, struct labcomm2014_renaming_rename *); labcomm2014_memory_free(d->memory, 0, id); } @@ -206,7 +206,7 @@ struct labcomm2014_decoder *labcomm2014_renaming_decoder_new( result->registry = registry; result->rename_func = rename; result->context = context; - LABCOMM_SIGNATURE_ARRAY_INIT(result->renamed, + LABCOMM2014_SIGNATURE_ARRAY_INIT(result->renamed, struct labcomm2014_renaming_rename *); return &(result->decoder); } diff --git a/lib/c/2014/labcomm2014_renaming_encoder.c b/lib/c/2014/labcomm2014_renaming_encoder.c index 1d61032..83fd7f0 100644 --- a/lib/c/2014/labcomm2014_renaming_encoder.c +++ b/lib/c/2014/labcomm2014_renaming_encoder.c @@ -31,7 +31,7 @@ struct encoder { struct labcomm2014_renaming_registry *registry; char *(*rename_func)(struct labcomm2014_memory *m, char *name, void *context); void *context; - LABCOMM_SIGNATURE_ARRAY_DEF(renamed, + LABCOMM2014_SIGNATURE_ARRAY_DEF(renamed, struct labcomm2014_renaming_rename *); }; @@ -45,7 +45,7 @@ static struct labcomm2014_renaming_rename *get_renamed( index = labcomm2014_get_local_index(signature); labcomm2014_scheduler_writer_lock(e->scheduler); - result = LABCOMM_SIGNATURE_ARRAY_GET(ie->renamed, + result = LABCOMM2014_SIGNATURE_ARRAY_GET(ie->renamed, struct labcomm2014_renaming_rename *, index, NULL); labcomm2014_scheduler_writer_unlock(e->scheduler); @@ -70,7 +70,7 @@ static struct labcomm2014_renaming_rename *set_renamed( ie->rename_func, ie->context); if (entry == NULL) { goto out; } labcomm2014_scheduler_writer_lock(e->scheduler); - renamed = LABCOMM_SIGNATURE_ARRAY_REF(e->memory, ie->renamed, + renamed = LABCOMM2014_SIGNATURE_ARRAY_REF(e->memory, ie->renamed, struct labcomm2014_renaming_rename *, index); if (renamed == NULL) { goto free_unlock; } @@ -206,17 +206,17 @@ static void do_free(struct labcomm2014_encoder *e) struct encoder *ie = e->context; int i; - LABCOMM_SIGNATURE_ARRAY_FOREACH(ie->renamed, + LABCOMM2014_SIGNATURE_ARRAY_FOREACH(ie->renamed, struct labcomm2014_renaming_rename *, i) { struct labcomm2014_renaming_rename *r; - r = LABCOMM_SIGNATURE_ARRAY_GET(ie->renamed, + r = LABCOMM2014_SIGNATURE_ARRAY_GET(ie->renamed, struct labcomm2014_renaming_rename *, i, NULL); if (r) { labcomm2014_renaming_rename_free(ie->registry, r); } } - LABCOMM_SIGNATURE_ARRAY_FREE(e->memory, ie->renamed, struct labcomm2014_renaming_rename *); + LABCOMM2014_SIGNATURE_ARRAY_FREE(e->memory, ie->renamed, struct labcomm2014_renaming_rename *); labcomm2014_memory_free(e->memory, 0, ie); } @@ -249,7 +249,7 @@ struct labcomm2014_encoder *labcomm2014_renaming_encoder_new( result->registry = registry; result->rename_func = rename; result->context = context; - LABCOMM_SIGNATURE_ARRAY_INIT(result->renamed, + LABCOMM2014_SIGNATURE_ARRAY_INIT(result->renamed, struct labcomm2014_renaming_rename *); return &(result->encoder); } diff --git a/lib/c/2014/labcomm2014_renaming_registry.c b/lib/c/2014/labcomm2014_renaming_registry.c index c26c89d..4fc501d 100644 --- a/lib/c/2014/labcomm2014_renaming_registry.c +++ b/lib/c/2014/labcomm2014_renaming_registry.c @@ -40,7 +40,7 @@ struct labcomm2014_renaming_rename { int use_count; struct registry *base; struct labcomm2014_signature signature; -#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS +#ifdef LABCOMM2014_USE_UNSUPPORTED_TYPEDEFS struct labcomm2014_signature_data s_treedata[2]; #endif }; @@ -49,7 +49,7 @@ struct labcomm2014_renaming_registry { struct labcomm2014_error_handler *error; struct labcomm2014_memory *memory; struct labcomm2014_scheduler *scheduler; - LABCOMM_SIGNATURE_ARRAY_DEF(registry, struct registry *); + LABCOMM2014_SIGNATURE_ARRAY_DEF(registry, struct registry *); }; struct labcomm2014_renaming_registry *labcomm2014_renaming_registry_new( @@ -65,7 +65,7 @@ struct labcomm2014_renaming_registry *labcomm2014_renaming_registry_new( result->error = error; result->memory = memory; result->scheduler = scheduler; - LABCOMM_SIGNATURE_ARRAY_INIT(result->registry, struct registry *); + LABCOMM2014_SIGNATURE_ARRAY_INIT(result->registry, struct registry *); return result; } } @@ -73,7 +73,7 @@ struct labcomm2014_renaming_registry *labcomm2014_renaming_registry_new( void labcomm2014_renaming_registry_free( struct labcomm2014_renaming_registry *r) { - LABCOMM_SIGNATURE_ARRAY_FREE(r->memory, r->registry, struct registry *); + LABCOMM2014_SIGNATURE_ARRAY_FREE(r->memory, r->registry, struct registry *); labcomm2014_memory_free(r->memory, 0, r); } @@ -95,14 +95,14 @@ static struct registry *registry_new( signature->name); goto out; } - registry = LABCOMM_SIGNATURE_ARRAY_REF(r->memory, r->registry, + registry = LABCOMM2014_SIGNATURE_ARRAY_REF(r->memory, r->registry, struct registry *, index); if (registry == NULL) { goto out; } if (*registry != NULL) { result = *registry; } else { /* Add previosly unknown sample to registry */ - registry = LABCOMM_SIGNATURE_ARRAY_REF(r->memory, r->registry, + registry = LABCOMM2014_SIGNATURE_ARRAY_REF(r->memory, r->registry, struct registry *, index); if (registry == NULL) { goto out; } result = labcomm2014_memory_alloc(r->memory, 0, sizeof(*result)); @@ -154,10 +154,10 @@ struct labcomm2014_renaming_rename *labcomm2014_renaming_rename_new( entry->signature.size = base->signature->size; entry->signature.signature = base->signature->signature; entry->signature.index = 0; -#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS +#ifdef LABCOMM2014_USE_UNSUPPORTED_TYPEDEFS struct labcomm2014_signature_data s_treedata[2] = { - LABCOMM_SIGDEF_SIGNATURE(*base->signature), - LABCOMM_SIGDEF_END + LABCOMM2014_SIGDEF_SIGNATURE(*base->signature), + LABCOMM2014_SIGDEF_END }; entry->s_treedata[0] = s_treedata[0]; entry->s_treedata[1] = s_treedata[1]; @@ -208,13 +208,13 @@ void labcomm2014_renaming_rename_free( if (rename->base->rename == NULL) { /* Last use of base signature */ index = labcomm2014_get_local_index(rename->base->signature); - registry = LABCOMM_SIGNATURE_ARRAY_REF(r->memory, r->registry, + registry = LABCOMM2014_SIGNATURE_ARRAY_REF(r->memory, r->registry, struct registry *, index); labcomm2014_memory_free(r->memory, 0, *registry); *registry = NULL; } index = labcomm2014_get_local_index(&rename->signature); - registry = LABCOMM_SIGNATURE_ARRAY_REF(r->memory, r->registry, + registry = LABCOMM2014_SIGNATURE_ARRAY_REF(r->memory, r->registry, struct registry *, index); labcomm2014_memory_free(r->memory, 0, *registry); *registry = NULL; diff --git a/lib/c/2014/labcomm2014_scheduler.h b/lib/c/2014/labcomm2014_scheduler.h index 8d7e332..cc46b5f 100644 --- a/lib/c/2014/labcomm2014_scheduler.h +++ b/lib/c/2014/labcomm2014_scheduler.h @@ -22,8 +22,8 @@ #ifndef __LABCOMM2014_SCHEDULER_H__ #define __LABCOMM2014_SCHEDULER_H__ -#ifdef LABCOMM_COMPAT - #include LABCOMM_COMPAT +#ifdef LABCOMM2014_COMPAT + #include LABCOMM2014_COMPAT #else #include <unistd.h> #include <stdint.h> diff --git a/lib/c/2014/labcomm2014_scheduler_private.h b/lib/c/2014/labcomm2014_scheduler_private.h index 31f4cda..52d21bb 100644 --- a/lib/c/2014/labcomm2014_scheduler_private.h +++ b/lib/c/2014/labcomm2014_scheduler_private.h @@ -22,8 +22,8 @@ #ifndef __LABCOMM2014_SCHEDULER_PRIVATE_H__ #define __LABCOMM2014_SCHEDULER_PRIVATE_H__ -#ifdef LABCOMM_COMPAT - #include LABCOMM_COMPAT +#ifdef LABCOMM2014_COMPAT + #include LABCOMM2014_COMPAT #else #include <unistd.h> #endif diff --git a/lib/c/2014/labcomm2014_type_signature.c b/lib/c/2014/labcomm2014_type_signature.c index c1944d5..85be200 100644 --- a/lib/c/2014/labcomm2014_type_signature.c +++ b/lib/c/2014/labcomm2014_type_signature.c @@ -2,7 +2,7 @@ #include <string.h> // for memcmp #include <stdio.h> // for debug printf -#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS +#ifdef LABCOMM2014_USE_UNSUPPORTED_TYPEDEFS /* Dump signature bytes on stdout */ diff --git a/lib/c/2014/labcomm2014_type_signature.h b/lib/c/2014/labcomm2014_type_signature.h index 3bc10d2..a5f9985 100644 --- a/lib/c/2014/labcomm2014_type_signature.h +++ b/lib/c/2014/labcomm2014_type_signature.h @@ -11,38 +11,38 @@ /* * Signature entry */ -#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS +#ifdef LABCOMM2014_USE_UNSUPPORTED_TYPEDEFS #ifdef USE_UNIONS /* Useful for C99 and up (or GCC without -pedantic) */ -#define LABCOMM_SIGDEF_BYTES_OR_SIGNATURE \ +#define LABCOMM2014_SIGDEF_BYTES_OR_SIGNATURE \ union { \ char *bytes; \ struct labcomm2014_signature* signature; \ } u; -#define LABCOMM_SIGDEF_BYTES(l, b) { l, .u.bytes=b } -#define LABCOMM_SIGDEF_SIGNATURE(s) { 0, .u.signature=&s } // addressof, as s is pointing at the sig struct, not directly the the sig_bytes[] -#define LABCOMM_SIGDEF_END { -1, .u.bytes=0 } +#define LABCOMM2014_SIGDEF_BYTES(l, b) { l, .u.bytes=b } +#define LABCOMM2014_SIGDEF_SIGNATURE(s) { 0, .u.signature=&s } // addressof, as s is pointing at the sig struct, not directly the the sig_bytes[] +#define LABCOMM2014_SIGDEF_END { -1, .u.bytes=0 } #else -#define LABCOMM_SIGDEF_BYTES_OR_SIGNATURE \ +#define LABCOMM2014_SIGDEF_BYTES_OR_SIGNATURE \ struct { \ char *bytes; \ const struct labcomm2014_signature *signature; \ } u; -#define LABCOMM_SIGDEF_BYTES(l, b) { l, { b, 0 } } -#define LABCOMM_SIGDEF_SIGNATURE(s) { 0, { 0, &s } } -#define LABCOMM_SIGDEF_END { -1, { 0, 0 } } +#define LABCOMM2014_SIGDEF_BYTES(l, b) { l, { b, 0 } } +#define LABCOMM2014_SIGDEF_SIGNATURE(s) { 0, { 0, &s } } +#define LABCOMM2014_SIGDEF_END { -1, { 0, 0 } } #endif struct labcomm2014_signature_data { int length; - LABCOMM_SIGDEF_BYTES_OR_SIGNATURE + LABCOMM2014_SIGDEF_BYTES_OR_SIGNATURE }; #endif @@ -54,16 +54,16 @@ struct labcomm2014_signature { int size; unsigned char *signature; int index; -#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS +#ifdef LABCOMM2014_USE_UNSUPPORTED_TYPEDEFS int tdsize; struct labcomm2014_signature_data *treedata; #endif -#ifdef LABCOMM_EXPERIMENTAL_CACHED_ENCODED_SIZE +#ifdef LABCOMM2014_EXPERIMENTAL_CACHED_ENCODED_SIZE int cached_encoded_size; // -1 if not initialized or type is variable size #endif }; -#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS +#ifdef LABCOMM2014_USE_UNSUPPORTED_TYPEDEFS /* a struct for "raw" type_defs, to be used as an intermediate representation * between decoder and signature parser */ diff --git a/lib/c/2014/test/labcomm_mem_reader.h b/lib/c/2014/test/labcomm_mem_reader.h index 55b8ea9..9c5a19b 100644 --- a/lib/c/2014/test/labcomm_mem_reader.h +++ b/lib/c/2014/test/labcomm_mem_reader.h @@ -1,5 +1,5 @@ -#ifndef LABCOMM_MEM_READER_H -#define LABCOMM_MEM_READER_H +#ifndef LABCOMM2014_MEM_READER_H +#define LABCOMM2014_MEM_READER_H #include "labcomm.h" diff --git a/lib/c/2014/test/labcomm_mem_writer.c b/lib/c/2014/test/labcomm_mem_writer.c index 4370361..e3679af 100644 --- a/lib/c/2014/test/labcomm_mem_writer.c +++ b/lib/c/2014/test/labcomm_mem_writer.c @@ -131,7 +131,7 @@ static void copy_data(labcomm_writer_t *w, labcomm_mem_writer_context_t *mcontex { int writer_available = get_writer_available(w, mcontext); if (( writer_available - w->pos) < 0) { - w->on_error(LABCOMM_ERROR_ENC_BUF_FULL, 3, "labcomm_writer_t->pos=%i, but available in mcontext is %i", w->pos, writer_available); + w->on_error(LABCOMM2014_ERROR_ENC_BUF_FULL, 3, "labcomm_writer_t->pos=%i, but available in mcontext is %i", w->pos, writer_available); } else { int i; for (i = 0; i < w->pos; ++i, mcontext->write_pos++) { diff --git a/lib/c/2014/test/labcomm_mem_writer.h b/lib/c/2014/test/labcomm_mem_writer.h index 7506342..d40e2ac 100644 --- a/lib/c/2014/test/labcomm_mem_writer.h +++ b/lib/c/2014/test/labcomm_mem_writer.h @@ -1,5 +1,5 @@ -#ifndef LABCOMM_MEM_WRITER_H -#define LABCOMM_MEM_WRITER_H +#ifndef LABCOMM2014_MEM_WRITER_H +#define LABCOMM2014_MEM_WRITER_H #include "labcomm.h" diff --git a/lib/c/2014/test/test_labcomm_errors.c b/lib/c/2014/test/test_labcomm_errors.c index 7808504..506e3ac 100644 --- a/lib/c/2014/test/test_labcomm_errors.c +++ b/lib/c/2014/test/test_labcomm_errors.c @@ -58,7 +58,7 @@ int test_enc_not_reg_encoder_sign() .signature = (unsigned char *) "0"}; encoder->do_encode(encoder, &signature, NULL); - return assert_callback(LABCOMM_ERROR_ENC_NO_REG_SIGNATURE, __FUNCTION__, ""); + return assert_callback(LABCOMM2014_ERROR_ENC_NO_REG_SIGNATURE, __FUNCTION__, ""); } int test_enc_missing_do_reg() @@ -72,7 +72,7 @@ int test_enc_missing_do_reg() encoder->do_register = NULL; labcomm_internal_encoder_register(encoder, NULL, NULL); - return assert_callback(LABCOMM_ERROR_ENC_MISSING_DO_REG, __FUNCTION__, ""); + return assert_callback(LABCOMM2014_ERROR_ENC_MISSING_DO_REG, __FUNCTION__, ""); } int test_enc_missing_do_encode() @@ -86,7 +86,7 @@ int test_enc_missing_do_encode() encoder->do_encode = NULL; labcomm_internal_encode(encoder, NULL, NULL); - return assert_callback(LABCOMM_ERROR_ENC_MISSING_DO_ENCODE, __FUNCTION__, ""); + return assert_callback(LABCOMM2014_ERROR_ENC_MISSING_DO_ENCODE, __FUNCTION__, ""); } int test_enc_buf_full() @@ -104,7 +104,7 @@ int test_enc_buf_full() mcontext->write_pos = 1; test_copy_data(&writer, mcontext, mbuf); - return assert_callback(LABCOMM_ERROR_ENC_BUF_FULL, __FUNCTION__, ""); + return assert_callback(LABCOMM2014_ERROR_ENC_BUF_FULL, __FUNCTION__, ""); } void labcomm_decoder_typecast_t_mock(struct labcomm_decoder *decoder, labcomm_handler_typecast_t handler, void *voidp) @@ -128,7 +128,7 @@ int test_dec_missing_do_reg() decoder->do_register = NULL; labcomm_internal_decoder_register(decoder, NULL, labcomm_decoder_typecast_t_mock, labcomm_handler_typecast_t_mock, buf); - return assert_callback(LABCOMM_ERROR_DEC_MISSING_DO_REG, __FUNCTION__, ""); + return assert_callback(LABCOMM2014_ERROR_DEC_MISSING_DO_REG, __FUNCTION__, ""); } int test_dec_missing_do_decode_one() @@ -141,7 +141,7 @@ int test_dec_missing_do_decode_one() decoder->do_decode_one = NULL; labcomm_decoder_decode_one(decoder); - return assert_callback(LABCOMM_ERROR_DEC_MISSING_DO_DECODE_ONE, __FUNCTION__, ""); + return assert_callback(LABCOMM2014_ERROR_DEC_MISSING_DO_DECODE_ONE, __FUNCTION__, ""); } int main() diff --git a/lib/c/2014/test/test_labcomm_errors.h b/lib/c/2014/test/test_labcomm_errors.h index 8cc3918..c29862b 100644 --- a/lib/c/2014/test/test_labcomm_errors.h +++ b/lib/c/2014/test/test_labcomm_errors.h @@ -1,5 +1,5 @@ -#ifndef TEST_LABCOMM_ERRORS_H -#define TEST_LABCOMM_ERRORS_H +#ifndef TEST_LABCOMM2014_ERRORS_H +#define TEST_LABCOMM2014_ERRORS_H void test_not_reg_encoder_sign(); diff --git a/lib/c/2014/test/test_signature_numbers.c b/lib/c/2014/test/test_signature_numbers.c index c540f81..bf20fba 100644 --- a/lib/c/2014/test/test_signature_numbers.c +++ b/lib/c/2014/test/test_signature_numbers.c @@ -18,7 +18,7 @@ int main(int argc, char *argv[]) #define FUNC(name, full_name) \ info( #name, #full_name, labcomm2014_signature_##full_name) - LABCOMM_FORALL_SAMPLES_generated_encoding(FUNC, ;); - LABCOMM_FORALL_SAMPLES_another_encoding(FUNC, ;); + LABCOMM2014_FORALL_SAMPLES_generated_encoding(FUNC, ;); + LABCOMM2014_FORALL_SAMPLES_another_encoding(FUNC, ;); return 0; } -- GitLab