- struct type_class_float *src_class = float_type_new(NULL,
- DBL_MANT_DIG,
- sizeof(double) * CHAR_BIT - DBL_MANT_DIG,
- BYTE_ORDER,
- __alignof__(double));
- struct stream_pos srcp;
+ struct bt_definition *tmpdef;
+ struct definition_float *tmpfloat;
+ struct ctf_stream_pos srcp;
+ 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);
+ ctf_init_pos(&srcp, -1, O_RDONLY);
+ mmap_align_set_addr(&mma, (char *) u.bits);
+ srcp.base_mma = &mma;
+ srcp.packet_size = sizeof(u) * CHAR_BIT;
+ switch (float_declaration->mantissa->len + 1) {
+ case FLT_MANT_DIG:
+ u.vf = float_definition->value;
+ break;
+ case DBL_MANT_DIG:
+ u.vd = float_definition->value;
+ break;
+ default:
+ ret = -EINVAL;
+ goto end_unref;
+ }
+ ctf_align_pos(pos, float_declaration->p.alignment);
+ ret = _ctf_float_copy(ppos, float_definition, &srcp.parent, tmpfloat);