- switch (len) {
- case 8: *(int8_t *)ptr = (int8_t) v;
- break;
- case 16:
- *(int16_t *)ptr = rbo ? GUINT16_SWAP_LE_BE((int16_t) v) :
- (int16_t) v;
- break;
- case 32:
- *(int32_t *)ptr = rbo ? GUINT32_SWAP_LE_BE((int32_t) v) :
- (int32_t) v;
- break;
- case 64:
- *(int64_t *)ptr = 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 (pos->dummy)
+ goto end;
+ if (!integer_declaration->signedness) {
+ if (integer_declaration->byte_order == LITTLE_ENDIAN)
+ bt_bitfield_write_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_write_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_write_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_write_be(mmap_align_addr(pos->base_mma) +
+ pos->mmap_base_offset, unsigned long,
+ pos->offset, integer_declaration->len,
+ integer_definition->value._signed);