X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=types%2Ffloat.c;h=9113bb8c1cfc3927ad0d845f9f5a174cfc359f28;hp=b12cf6be06d85241d5f9970e1f84ee1502d3f8b8;hb=dc48ecad637fc7fb8479da563ef2dfd3948cee73;hpb=f66259163f060ada8d0fee348857c968e338ea40 diff --git a/types/float.c b/types/float.c index b12cf6be..9113bb8c 100644 --- a/types/float.c +++ b/types/float.c @@ -21,7 +21,8 @@ static struct definition *_float_definition_new(struct declaration *declaration, - struct definition_scope *parent_scope); + struct definition_scope *parent_scope, + GQuark field_name, int index); static void _float_definition_free(struct definition *definition); @@ -34,15 +35,12 @@ void float_copy(struct stream_pos *destp, struct definition_float *_float = container_of(definition, struct definition_float, p); struct declaration_float *float_declaration = _float->declaration; + long double v; - if (fsrc->float_copy == fdest->float_copy) { - fsrc->float_copy(destp, srcp, float_declaration); - } else { - double v; - - v = fsrc->double_read(srcp, float_declaration); - fdest->double_write(destp, float_declaration, v); - } + v = fsrc->ldouble_read(srcp, float_declaration); + _float->value = v; + if (fdest) + fdest->ldouble_write(destp, float_declaration, v); } static @@ -58,7 +56,7 @@ void _float_declaration_free(struct declaration *declaration) } struct declaration_float * - float_declaration_new(const char *name, size_t mantissa_len, + float_declaration_new(size_t mantissa_len, size_t exp_len, int byte_order, size_t alignment) { struct declaration_float *float_declaration; @@ -67,7 +65,6 @@ struct declaration_float * float_declaration = g_new(struct declaration_float, 1); declaration = &float_declaration->p; declaration->id = CTF_TYPE_FLOAT; - declaration->name = g_quark_from_string(name); declaration->alignment = alignment; declaration->copy = float_copy; declaration->declaration_free = _float_declaration_free; @@ -76,11 +73,11 @@ struct declaration_float * declaration->ref = 1; float_declaration->byte_order = byte_order; - float_declaration->sign = integer_declaration_new(NULL, 1, + float_declaration->sign = integer_declaration_new(1, byte_order, false, 1); - float_declaration->mantissa = integer_declaration_new(NULL, mantissa_len - 1, + float_declaration->mantissa = integer_declaration_new(mantissa_len - 1, byte_order, false, 1); - float_declaration->exp = integer_declaration_new(NULL, exp_len, + float_declaration->exp = integer_declaration_new(exp_len, byte_order, true, 1); return float_declaration; } @@ -88,7 +85,8 @@ struct declaration_float * static struct definition * _float_definition_new(struct declaration *declaration, - struct definition_scope *parent_scope) + struct definition_scope *parent_scope, + GQuark field_name, int index) { struct declaration_float *float_declaration = container_of(declaration, struct declaration_float, p); @@ -96,9 +94,10 @@ struct definition * _float = g_new(struct definition_float, 1); declaration_ref(&float_declaration->p); - _float->p.declaration= declaration; - _float->declaration= float_declaration; + _float->p.declaration = declaration; + _float->declaration = float_declaration; _float->p.ref = 1; + _float->p.index = index; _float->value = 0.0; return &_float->p; }