X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf%2Ftypes%2Ffloat.c;h=d33e6ad976460a4098125d49138c061293bab47e;hp=000bc18361f2a081abcb2f7aa7825f3b1daafef2;hb=46322b331aefc5739efd841df72d1928e35050e6;hpb=6b71274a81b38da08261f2122597c540b02b7aee diff --git a/formats/ctf/types/float.c b/formats/ctf/types/float.c index 000bc183..d33e6ad9 100644 --- a/formats/ctf/types/float.c +++ b/formats/ctf/types/float.c @@ -32,7 +32,7 @@ /* * Aliasing float/double and unsigned long is not strictly permitted by strict - * aliasing, but in practice type prunning is well supported, and this permits + * aliasing, but in practice declaration prunning is well supported, and this permits * us to use per-word read/writes rather than per-byte. */ @@ -69,114 +69,118 @@ struct pos_len { }; void _ctf_float_copy(struct stream_pos *destp, - const struct type_class_float *dest_class, + const struct declaration_float *dest_declaration, struct stream_pos *srcp, - const struct type_class_float *src_class) + const struct declaration_float *src_declaration) { uint8_t sign; int64_t exp; uint64_t mantissa; /* Read */ - if (src_class->byte_order == LITTLE_ENDIAN) { - mantissa = ctf_uint_read(srcp, src_class->mantissa); - exp = ctf_int_read(srcp, src_class->exp); - sign = ctf_uint_read(srcp, src_class->sign); + if (src_declaration->byte_order == LITTLE_ENDIAN) { + mantissa = ctf_uint_read(srcp, src_declaration->mantissa); + exp = ctf_int_read(srcp, src_declaration->exp); + sign = ctf_uint_read(srcp, src_declaration->sign); } else { - sign = ctf_uint_read(srcp, src_class->sign); - exp = ctf_int_read(srcp, src_class->exp); - mantissa = ctf_uint_read(srcp, src_class->mantissa); + sign = ctf_uint_read(srcp, src_declaration->sign); + exp = ctf_int_read(srcp, src_declaration->exp); + mantissa = ctf_uint_read(srcp, src_declaration->mantissa); } /* Write */ - if (dest_class->byte_order == LITTLE_ENDIAN) { - ctf_uint_write(destp, dest_class->mantissa, mantissa); - ctf_int_write(destp, dest_class->exp, exp); - ctf_uint_write(destp, dest_class->sign, sign); + if (dest_declaration->byte_order == LITTLE_ENDIAN) { + ctf_uint_write(destp, dest_declaration->mantissa, mantissa); + ctf_int_write(destp, dest_declaration->exp, exp); + ctf_uint_write(destp, dest_declaration->sign, sign); } else { - ctf_uint_write(destp, dest_class->sign, sign); - ctf_int_write(destp, dest_class->exp, exp); - ctf_uint_write(destp, dest_class->mantissa, mantissa); + ctf_uint_write(destp, dest_declaration->sign, sign); + ctf_int_write(destp, dest_declaration->exp, exp); + ctf_uint_write(destp, dest_declaration->mantissa, mantissa); } } void ctf_float_copy(struct stream_pos *dest, struct stream_pos *src, - const struct type_class_float *float_class) + const struct declaration_float *float_declaration) { - align_pos(src, float_class->p.alignment); - align_pos(dest, float_class->p.alignment); - _ctf_float_copy(dest, float_class, src, float_class); + ctf_align_pos(ctf_pos(src), float_declaration->p.alignment); + ctf_align_pos(ctf_pos(dest), float_declaration->p.alignment); + _ctf_float_copy(dest, float_declaration, src, float_declaration); } double ctf_double_read(struct stream_pos *srcp, - const struct type_class_float *float_class) + const struct declaration_float *float_declaration) { union doubleIEEE754 u; - struct type_class_float *dest_class = float_type_class_new(NULL, - DBL_MANT_DIG, + struct declaration_float *dest_declaration = + float_declaration_new(DBL_MANT_DIG, sizeof(double) * CHAR_BIT - DBL_MANT_DIG, BYTE_ORDER, __alignof__(double)); - struct stream_pos destp; + struct ctf_stream_pos destp; - align_pos(srcp, float_class->p.alignment); - init_pos(&destp, (char *) u.bits); - _ctf_float_copy(&destp, dest_class, srcp, float_class); - type_class_unref(&dest_class->p); + ctf_align_pos(ctf_pos(srcp), float_declaration->p.alignment); + ctf_init_pos(&destp, -1); + destp.base = (char *) u.bits; + _ctf_float_copy(&destp.parent, dest_declaration, srcp, float_declaration); + declaration_unref(&dest_declaration->p); return u.v; } void ctf_double_write(struct stream_pos *destp, - const struct type_class_float *float_class, + const struct declaration_float *float_declaration, double v) { union doubleIEEE754 u; - struct type_class_float *src_class = float_type_class_new(NULL, - DBL_MANT_DIG, + struct declaration_float *src_declaration = + float_declaration_new(DBL_MANT_DIG, sizeof(double) * CHAR_BIT - DBL_MANT_DIG, BYTE_ORDER, __alignof__(double)); - struct stream_pos srcp; + struct ctf_stream_pos srcp; u.v = v; - align_pos(destp, float_class->p.alignment); - init_pos(&srcp, (char *) u.bits); - _ctf_float_copy(destp, float_class, &srcp, src_class); - type_class_unref(&src_class->p); + ctf_align_pos(ctf_pos(destp), float_declaration->p.alignment); + ctf_init_pos(&srcp, -1); + srcp.base = (char *) u.bits; + _ctf_float_copy(destp, float_declaration, &srcp.parent, src_declaration); + declaration_unref(&src_declaration->p); } long double ctf_ldouble_read(struct stream_pos *srcp, - const struct type_class_float *float_class) + const struct declaration_float *float_declaration) { union ldoubleIEEE754 u; - struct type_class_float *dest_class = float_type_class_new(NULL, - LDBL_MANT_DIG, + struct declaration_float *dest_declaration = + float_declaration_new(LDBL_MANT_DIG, sizeof(long double) * CHAR_BIT - LDBL_MANT_DIG, BYTE_ORDER, __alignof__(long double)); - struct stream_pos destp; + struct ctf_stream_pos destp; - align_pos(srcp, float_class->p.alignment); - init_pos(&destp, (char *) u.bits); - _ctf_float_copy(&destp, dest_class, srcp, float_class); - type_class_unref(&dest_class->p); + ctf_align_pos(ctf_pos(srcp), float_declaration->p.alignment); + ctf_init_pos(&destp, -1); + destp.base = (char *) u.bits; + _ctf_float_copy(&destp.parent, dest_declaration, srcp, float_declaration); + declaration_unref(&dest_declaration->p); return u.v; } void ctf_ldouble_write(struct stream_pos *destp, - const struct type_class_float *float_class, + const struct declaration_float *float_declaration, long double v) { union ldoubleIEEE754 u; - struct type_class_float *src_class = float_type_class_new(NULL, - LDBL_MANT_DIG, + struct declaration_float *src_declaration = + float_declaration_new(LDBL_MANT_DIG, sizeof(long double) * CHAR_BIT - LDBL_MANT_DIG, BYTE_ORDER, __alignof__(long double)); - struct stream_pos srcp; + struct ctf_stream_pos srcp; u.v = v; - align_pos(destp, float_class->p.alignment); - init_pos(&srcp, (char *) u.bits); - _ctf_float_copy(destp, float_class, &srcp, src_class); - type_class_unref(&src_class->p); + ctf_align_pos(ctf_pos(destp), float_declaration->p.alignment); + ctf_init_pos(&srcp, -1); + srcp.base = (char *) u.bits; + _ctf_float_copy(destp, float_declaration, &srcp.parent, src_declaration); + declaration_unref(&src_declaration->p); }