clang fix, don't allow unaligned uint64_t pointers

macbuild
Tim Newsome 2017-09-18 14:56:46 -07:00
parent ed9a04bde9
commit 60354cbea2
2 changed files with 12 additions and 5 deletions

View File

@ -103,7 +103,7 @@ size_t riscv_batch_add_dmi_read(struct riscv_batch *batch, unsigned address)
batch->read_keys[batch->read_keys_used] = batch->used_scans - 1; batch->read_keys[batch->read_keys_used] = batch->used_scans - 1;
LOG_DEBUG("read key %u for batch 0x%p is %u (0x%p)", LOG_DEBUG("read key %u for batch 0x%p is %u (0x%p)",
(unsigned) batch->read_keys_used, batch, (unsigned) (batch->used_scans - 1), (unsigned) batch->read_keys_used, batch, (unsigned) (batch->used_scans - 1),
(uint64_t*)batch->data_in + (batch->used_scans + 1)); batch->data_in + sizeof(uint64_t) * (batch->used_scans + 1));
return batch->read_keys_used++; return batch->read_keys_used++;
} }
@ -112,8 +112,15 @@ uint64_t riscv_batch_get_dmi_read(struct riscv_batch *batch, size_t key)
assert(key < batch->read_keys_used); assert(key < batch->read_keys_used);
size_t index = batch->read_keys[key]; size_t index = batch->read_keys[key];
assert(index <= batch->used_scans); assert(index <= batch->used_scans);
uint64_t *addr = ((uint64_t *)(batch->data_in) + index); uint8_t *base = batch->data_in + 8 * index;
return *addr; return base[0] |
((uint64_t) base[1]) << 8 |
((uint64_t) base[2]) << 16 |
((uint64_t) base[3]) << 24 |
((uint64_t) base[4]) << 32 |
((uint64_t) base[5]) << 40 |
((uint64_t) base[6]) << 48 |
((uint64_t) base[7]) << 56;
} }
void riscv_batch_add_nop(struct riscv_batch *batch) void riscv_batch_add_nop(struct riscv_batch *batch)

View File

@ -23,8 +23,8 @@ struct riscv_batch {
size_t idle_count; size_t idle_count;
char *data_out; uint8_t *data_out;
char *data_in; uint8_t *data_in;
struct scan_field *fields; struct scan_field *fields;
/* In JTAG we scan out the previous value's output when performing a /* In JTAG we scan out the previous value's output when performing a