- 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 bt_definition *tmpdef;
+ struct definition_float *tmpfloat;
+ struct ctf_stream_pos destp;
+ struct mmap_align mma;
+ int ret;
+
+ float_lock();
+ 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:
+ ret = -EINVAL;
+ goto end;
+ }
+ tmpfloat = container_of(tmpdef, struct definition_float, p);
+ memset(&destp, 0, sizeof(destp));
+ ctf_init_pos(&destp, NULL, -1, O_RDWR);
+ mmap_align_set_addr(&mma, (char *) u.bits);
+ destp.base_mma = &mma;
+ destp.packet_size = sizeof(u) * CHAR_BIT;
+ if (!ctf_align_pos(pos, float_declaration->p.alignment)) {
+ ret = -EFAULT;
+ goto end_unref;
+ }
+ 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:
+ ret = -EINVAL;
+ goto end_unref;
+ }
+
+end_unref:
+ bt_definition_unref(tmpdef);
+end:
+ float_unlock();
+ return ret;