On 06/09/2017 10:14 PM, Matteo Bruni wrote:
2017-06-09 20:55 GMT+02:00 Paul Gofman gofmanp@gmail.com:
That would break in patch 2/5 (if it isn't updated accordingly) though, as I mentioned.
Yes, sure, I will update the code accordingly in this patchset to do memcpy when it is required only.
The assertion I envision would check that both the source and the destination data type have size == sizeof(unsigned int), which is what you're depending on. It could be a static assert (see e.g. C_ASSERT()), in principle.
So I will put something like C_ASSERT(sizeof(BOOL) == sizeof(unsigned int) && sizeof(float) == sizeof(unsigned int) ...) in set_constants(), is it ok?
} } start_offset += get_offset_reg(table,
const_set->register_count); data += param->rows * param->columns; }
start_offset = get_offset_reg(table, const_set->register_index);
regstore_set_data(rs, table, start_offset, (unsigned int
*)rs->tables[table] + start_offset,
get_offset_reg(table, const_set->register_count) *
const_set->element_count, param_type);
I understand that you want to avoid to use some separate storage for the "to be converted" data but, like above, this regstore table pointer cast makes me a bit uncomfortable.
Or yeah, I really want to avoid extra storage for conversion, it adds extra memory access and affects performance a bit (I had such variant as a first time implementation). Same as above, it is essentially the same as it was before, just previously it was a single "unsigned int out;" while now it is an array. Maybe then I will add runtime check (or preprocessor check) in initialization that all the supported types really have the same size as 'unsigned int'?
Yeah, that's the "assert" I want. Not sure what's the best form for that, it doesn't necessarily have to be an assert().
I will update the patchset probably in a few days, as I am away now.