- struct ctf_float dest = {
- .exp_len = sizeof(double) * CHAR_BIT - DBL_MANT_DIG,
- .mantissa_len = DBL_MANT_DIG,
- .byte_order = BYTE_ORDER,
- };
-
- ctf_float_copy(&u.bits, &dest, ptr, src);
- return u.v;
+ struct definition *tmpdef;
+ struct definition_float *tmpfloat;
+ struct ctf_stream_pos destp;
+ int ret;
+
+ switch (float_declaration->mantissa->len + 1) {
+ case FLT_MANT_DIG:
+ tmpdef = static_float_declaration->p.definition_new(
+ &static_float_declaration->p,
+ NULL, 0, 0, "__tmpfloat");
+ break;
+ case DBL_MANT_DIG:
+ tmpdef = static_double_declaration->p.definition_new(
+ &static_double_declaration->p,
+ NULL, 0, 0, "__tmpfloat");
+ break;
+ default:
+ return -EINVAL;
+ }
+ tmpfloat = container_of(tmpdef, struct definition_float, p);
+ ctf_init_pos(&destp, -1, O_RDWR);
+ destp.base = (char *) u.bits;
+ destp.packet_size = sizeof(u) * CHAR_BIT;
+ ctf_align_pos(pos, float_declaration->p.alignment);
+ ret = _ctf_float_copy(&destp.parent, tmpfloat, ppos, float_definition);
+ switch (float_declaration->mantissa->len + 1) {
+ case FLT_MANT_DIG:
+ float_definition->value = u.vf;
+ break;
+ case DBL_MANT_DIG:
+ float_definition->value = u.vd;
+ break;
+ default:
+ return -EINVAL;
+ }
+ definition_unref(tmpdef);
+ return ret;