- switch (int_class->len) {
- case 8: *(int8_t *) get_pos_addr(pos) = (int8_t) v;
- break;
- case 16:
- *(int16_t *) get_pos_addr(pos) = rbo ?
- GUINT16_SWAP_LE_BE((int16_t) v) :
- (int16_t) v;
- break;
- case 32:
- *(int32_t *) get_pos_addr(pos) = rbo ?
- GUINT32_SWAP_LE_BE((int32_t) v) :
- (int32_t) v;
- break;
- case 64:
- *(int64_t *) get_pos_addr(pos) = rbo ?
- GUINT64_SWAP_LE_BE(v) : v;
- break;
- default:
- assert(0);
+ ctf_align_pos(pos, integer_declaration->p.alignment);
+
+ if (!ctf_pos_access_ok(pos, integer_declaration->len))
+ return -EFAULT;
+
+ if (!integer_declaration->signedness) {
+ if (integer_declaration->byte_order == LITTLE_ENDIAN)
+ bt_bitfield_read_le(mmap_align_addr(pos->base_mma) +
+ pos->mmap_base_offset, unsigned long,
+ pos->offset, integer_declaration->len,
+ &integer_definition->value._unsigned);
+ else
+ bt_bitfield_read_be(mmap_align_addr(pos->base_mma) +
+ pos->mmap_base_offset, unsigned long,
+ pos->offset, integer_declaration->len,
+ &integer_definition->value._unsigned);
+ } else {
+ if (integer_declaration->byte_order == LITTLE_ENDIAN)
+ bt_bitfield_read_le(mmap_align_addr(pos->base_mma) +
+ pos->mmap_base_offset, unsigned long,
+ pos->offset, integer_declaration->len,
+ &integer_definition->value._signed);
+ else
+ bt_bitfield_read_be(mmap_align_addr(pos->base_mma) +
+ pos->mmap_base_offset, unsigned long,
+ pos->offset, integer_declaration->len,
+ &integer_definition->value._signed);