Commit 6ac4ee60 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

2006 tests passes

parent df9405e0
......@@ -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() +
......
......@@ -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);
}
......@@ -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;
......
......@@ -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,
......
......@@ -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++) {
......
......@@ -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) \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment