X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf%2Ftypes%2Ffloat.c;h=be068316eb9241084abd4b0e662d6f2acd1880a9;hp=20cf7fa537c8e96e7a4e14359688f58f967655c3;hb=4c8bfb7e0a9cef6e74cefa38ed54bf8cbd424183;hpb=11d43b909baeee566511acfec577d4605386fa09 diff --git a/formats/ctf/types/float.c b/formats/ctf/types/float.c index 20cf7fa5..be068316 100644 --- a/formats/ctf/types/float.c +++ b/formats/ctf/types/float.c @@ -3,21 +3,17 @@ * * Floating point read/write functions. * - * Copyright (c) 2010 Mathieu Desnoyers + * Copyright 2010 - Mathieu Desnoyers * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * * Reference: ISO C99 standard 5.2.4 */ @@ -82,28 +78,24 @@ void _ctf_float_copy(struct stream_pos *destp, uint64_t mantissa; /* Read */ - if (src->byte_order == LITTLE_ENDIAN) { - mantissa = ctf_bitfield_unsigned_read(srcp, - src_class->mantissa); - exp = ctf_bitfield_signed_read(srcp, src_class->exp); - sign = ctf_bitfield_unsigned_read(srcp, src_class->sign); + 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); } else { - sign = ctf_bitfield_unsigned_read(srcp, src_class->sign); - exp = ctf_bitfield_signed_read(srcp, src_class->exp); - mantissa = ctf_bitfield_unsigned_read(srcp, - src_class->mantissa); + sign = ctf_uint_read(srcp, src_class->sign); + exp = ctf_int_read(srcp, src_class->exp); + mantissa = ctf_uint_read(srcp, src_class->mantissa); } /* Write */ - if (dest->byte_order == LITTLE_ENDIAN) { - ctf_bitfield_unsigned_write(destp, dest_class->mantissa, - mantissa); - ctf_bitfield_signed_write(destp, dest_class->exp, exp); - ctf_bitfield_unsigned_write(destp, dest_class->sign, sign); + 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); } else { - ctf_bitfield_unsigned_write(destp, dest_class->sign, sign); - ctf_bitfield_signed_write(destp, dest_class->exp, exp); - ctf_bitfield_unsigned_write(destp, dest_class->mantissa, - mantissa); + ctf_uint_write(destp, dest_class->sign, sign); + ctf_int_write(destp, dest_class->exp, exp); + ctf_uint_write(destp, dest_class->mantissa, mantissa); } } @@ -119,7 +111,7 @@ double ctf_double_read(struct stream_pos *srcp, const struct type_class_float *float_class) { union doubleIEEE754 u; - struct ctf_float *dest_class = float_type_new(NULL, + struct type_class_float *dest_class = float_type_new(NULL, DBL_MANT_DIG, sizeof(double) * CHAR_BIT - DBL_MANT_DIG, BYTE_ORDER, @@ -127,7 +119,7 @@ double ctf_double_read(struct stream_pos *srcp, struct stream_pos destp; align_pos(srcp, float_class->p.alignment); - init_pos(&destp, &u.bits); + init_pos(&destp, (unsigned char *) u.bits); _ctf_float_copy(&destp, dest_class, srcp, float_class); float_type_free(dest_class); return u.v; @@ -138,7 +130,7 @@ void ctf_double_write(struct stream_pos *destp, double v) { union doubleIEEE754 u; - struct ctf_float *src_class = float_type_new(NULL, + struct type_class_float *src_class = float_type_new(NULL, DBL_MANT_DIG, sizeof(double) * CHAR_BIT - DBL_MANT_DIG, BYTE_ORDER, @@ -147,7 +139,7 @@ void ctf_double_write(struct stream_pos *destp, u.v = v; align_pos(destp, float_class->p.alignment); - init_pos(&srcp, &u.bits); + init_pos(&srcp, (unsigned char *) u.bits); _ctf_float_copy(destp, float_class, &srcp, src_class); float_type_free(src_class); } @@ -156,7 +148,7 @@ long double ctf_ldouble_read(struct stream_pos *srcp, const struct type_class_float *float_class) { union ldoubleIEEE754 u; - struct ctf_float *dest_class = float_type_new(NULL, + struct type_class_float *dest_class = float_type_new(NULL, LDBL_MANT_DIG, sizeof(long double) * CHAR_BIT - LDBL_MANT_DIG, BYTE_ORDER, @@ -164,7 +156,7 @@ long double ctf_ldouble_read(struct stream_pos *srcp, struct stream_pos destp; align_pos(srcp, float_class->p.alignment); - init_pos(&destp, &u.bits); + init_pos(&destp, (unsigned char *) u.bits); _ctf_float_copy(&destp, dest_class, srcp, float_class); float_type_free(dest_class); return u.v; @@ -175,7 +167,7 @@ void ctf_ldouble_write(struct stream_pos *destp, long double v) { union ldoubleIEEE754 u; - struct ctf_float *src_class = float_type_new(NULL, + struct type_class_float *src_class = float_type_new(NULL, LDBL_MANT_DIG, sizeof(long double) * CHAR_BIT - LDBL_MANT_DIG, BYTE_ORDER, @@ -184,7 +176,7 @@ void ctf_ldouble_write(struct stream_pos *destp, u.v = v; align_pos(destp, float_class->p.alignment); - init_pos(&srcp, &u.bits); + init_pos(&srcp, (unsigned char *) u.bits); _ctf_float_copy(destp, float_class, &srcp, src_class); float_type_free(src_class); }