diff --git a/compiler/C_CodeGen.jrag b/compiler/C_CodeGen.jrag index 1c72a7db76757b18e24c4dcfa7bccea3e6a3bc4a..9064f53d7eedddfac9d8d4237a9c095cace5322b 100644 --- a/compiler/C_CodeGen.jrag +++ b/compiler/C_CodeGen.jrag @@ -1269,7 +1269,7 @@ aspect C_Sizeof { "(" + env.prefix + getName() + " *v)"); env.println("{"); env.indent(); - env.println("return labcomm_internal_sizeof(" + + env.println("return labcomm"+env.verStr+"_internal_sizeof(" + "&labcomm" + env.verStr+"_signature_" + env.prefix + getName() + ", v);"); env.unindent(); @@ -1353,8 +1353,8 @@ aspect C_Sizeof { public void PrimType.C_emitSizeof(C_env env) { switch (getToken()) { case LABCOMM_STRING: { - env.print("{ int length = strlen(" + env.qualid + "); "); - env.println("result += labcomm_size_packed32(length) + length; }"); + env.print("{ int l = strlen(" + env.qualid + "); "); + env.println("result += labcomm"+env.verStr+"_size_packed32(l) + l; }"); } break; default: { throw new Error(this.getClass().getName() + diff --git a/lib/c/2006/labcomm2006.c b/lib/c/2006/labcomm2006.c index 34a13ec11ca428da1eac5db458e8e388362b8d56..cbb0ea8763a1e573dba19db591dfcc5e2bf910e6 100644 --- a/lib/c/2006/labcomm2006.c +++ b/lib/c/2006/labcomm2006.c @@ -260,3 +260,11 @@ int labcomm2006_get_local_index(struct labcomm2006_signature *signature) } return signature->index; } + +int labcomm2006_internal_sizeof(struct labcomm2006_signature *signature, + void *v) +{ + int length = signature->encoded_size(v); + return (labcomm2006_size_packed32(signature->index) + + length); +} diff --git a/lib/c/2006/labcomm2006.h b/lib/c/2006/labcomm2006.h index 938aa2d7e7612dfc9554e41600ec8cad930ccee0..fc7919ead1c5ba7430d9af51f532bb82e274f8ff 100644 --- a/lib/c/2006/labcomm2006.h +++ b/lib/c/2006/labcomm2006.h @@ -44,9 +44,8 @@ struct labcomm2006_decoder; * Signature entry */ struct labcomm2006_signature { - int type; char *name; - int (*encoded_size)(struct labcomm2006_signature *, void *); // void * == encoded_sample * + int (*encoded_size)(void *); /* void* refers to sample_data */ int size; unsigned char *signature; int index; diff --git a/lib/c/2006/labcomm2006_decoder.c b/lib/c/2006/labcomm2006_decoder.c index a936f3e1bfd3d1eb0cdf77f0836026aabe55d8e5..36a075af22f1be828b5a892a792e5beaf2c2eb04 100644 --- a/lib/c/2006/labcomm2006_decoder.c +++ b/lib/c/2006/labcomm2006_decoder.c @@ -190,7 +190,6 @@ static int decode_typedef_or_sample(struct labcomm2006_decoder *d, int kind) labcomm2006_writer_start(&writer, writer.action_context, 0, NULL, NULL); remote_index = labcomm2006_read_packed32(d->reader); signature.name = labcomm2006_read_string(d->reader); - signature.type = kind; collect_flat_signature(d, &writer); labcomm2006_writer_end(&writer, writer.action_context); err = writer_ioctl(&writer, @@ -221,7 +220,6 @@ static int decode_typedef_or_sample(struct labcomm2006_decoder *d, int kind) s = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, d->local, struct sample_entry, i); if (s->signature && - s->signature->type == signature.type && s->signature->size == signature.size && strcmp(s->signature->name, signature.name) == 0 && memcmp((void*)s->signature->signature, (void*)signature.signature, diff --git a/lib/c/2006/labcomm2006_encoder.c b/lib/c/2006/labcomm2006_encoder.c index 06eb4dca403a0a43d44544cfe3a939963bc3d63d..28674e179d8ad93a88a2ed79fd20a64e2b06a870 100644 --- a/lib/c/2006/labcomm2006_encoder.c +++ b/lib/c/2006/labcomm2006_encoder.c @@ -77,7 +77,6 @@ int labcomm2006_internal_encoder_register( index = labcomm2006_get_local_index(signature); labcomm2006_scheduler_writer_lock(e->scheduler); - if (signature->type != LABCOMM_SAMPLE) { goto out; } if (index <= 0) { goto out; } done = LABCOMM_SIGNATURE_ARRAY_REF(e->memory, e->registered, int, index); if (*done) { goto out; } @@ -86,7 +85,7 @@ int labcomm2006_internal_encoder_register( index, signature, NULL); if (err == -EALREADY) { result = 0; goto out; } if (err != 0) { result = err; goto out; } - labcomm2006_write_packed32(e->writer, signature->type); + labcomm2006_write_packed32(e->writer, LABCOMM_SAMPLE); labcomm2006_write_packed32(e->writer, index); labcomm2006_write_string(e->writer, signature->name); for (i = 0 ; i < signature->size ; i++) { diff --git a/lib/c/2006/labcomm2006_private.h b/lib/c/2006/labcomm2006_private.h index 1be45d2e0a3d98c3744373895389f78f9b6cf1ab..fa2ec144440f303f63be0cbfc027cacfb53cde5e 100644 --- a/lib/c/2006/labcomm2006_private.h +++ b/lib/c/2006/labcomm2006_private.h @@ -377,6 +377,9 @@ int labcomm2006_internal_encoder_ioctl(struct labcomm2006_encoder *encoder, struct labcomm2006_signature *signature, uint32_t ioctl_action, va_list args); +int labcomm2006_internal_sizeof(struct labcomm2006_signature *signature, + void *v); + #if __BYTE_ORDER == __LITTLE_ENDIAN #define LABCOMM_ENCODE(name, type) \