#include <glib.h>
#include <endian.h>
+/*
+ * The aligned read/write functions are expected to be faster than the
+ * bitfield variants. They will be enabled eventually as an
+ * optimisation.
+ */
+
static
void _aligned_integer_read(struct stream_pos *ppos,
struct definition *definition)
{
uint8_t v;
- v = *(const uint8_t *)pos->base;
+ v = *(const uint8_t *) ctf_get_pos_addr(pos);
integer_definition->value._unsigned = v;
break;
}
{
uint16_t v;
- v = *(const uint16_t *)pos->base;
+ v = *(const uint16_t *) ctf_get_pos_addr(pos);
integer_definition->value._unsigned =
rbo ? GUINT16_SWAP_LE_BE(v) : v;
break;
{
uint32_t v;
- v = *(const uint32_t *)pos->base;
+ v = *(const uint32_t *) ctf_get_pos_addr(pos);
integer_definition->value._unsigned =
rbo ? GUINT32_SWAP_LE_BE(v) : v;
break;
{
uint64_t v;
- v = *(const uint64_t *)pos->base;
+ v = *(const uint64_t *) ctf_get_pos_addr(pos);
integer_definition->value._unsigned =
rbo ? GUINT64_SWAP_LE_BE(v) : v;
break;
{
int8_t v;
- v = *(const int8_t *)pos->base;
+ v = *(const int8_t *) ctf_get_pos_addr(pos);
integer_definition->value._signed = v;
break;
}
{
int16_t v;
- v = *(const int16_t *)pos->base;
+ v = *(const int16_t *) ctf_get_pos_addr(pos);
integer_definition->value._signed =
rbo ? GUINT16_SWAP_LE_BE(v) : v;
break;
{
int32_t v;
- v = *(const int32_t *)pos->base;
+ v = *(const int32_t *) ctf_get_pos_addr(pos);
integer_definition->value._signed =
rbo ? GUINT32_SWAP_LE_BE(v) : v;
break;
{
int64_t v;
- v = *(const int64_t *)pos->base;
+ v = *(const int64_t *) ctf_get_pos_addr(pos);
integer_definition->value._signed =
rbo ? GUINT64_SWAP_LE_BE(v) : v;
break;
integer_definition->declaration;
struct ctf_stream_pos *pos = ctf_pos(ppos);
+ if (!(integer_declaration->p.alignment % CHAR_BIT)
+ && !(integer_declaration->len % CHAR_BIT)) {
+ _aligned_integer_read(ppos, definition);
+ return;
+ }
+
ctf_align_pos(pos, integer_declaration->p.alignment);
if (!integer_declaration->signedness) {
if (integer_declaration->byte_order == LITTLE_ENDIAN)
integer_definition->declaration;
struct ctf_stream_pos *pos = ctf_pos(ppos);
+ if (!(integer_declaration->p.alignment % CHAR_BIT)
+ && !(integer_declaration->len % CHAR_BIT)) {
+ _aligned_integer_write(ppos, definition);
+ return;
+ }
+
ctf_align_pos(pos, integer_declaration->p.alignment);
if (pos->dummy)
goto end;