> Can't you do the CRC byte-by-byte until you reach an address that is properly aligned?
> See lib/memchr.c for an example. That would be perfect, I'll look over lib/memchr.c. My background is in network engineering and reverse engineering so I am in my element with how everything looks on the wire, but I am trying my best to do things by the book here for portability. If there's a kosher way of telling when we're aligned then that would be the holy grail here. On Mon, 14 Oct 2024 at 23:25, Collin Funk <collin.fu...@gmail.com> wrote: > Sam Russell <sam.h.russ...@gmail.com> writes: > > > One issue I've noticed is that the crc functions take a char* and while > > this is ok in other implementations, gnulib appears to enforce strict > > alignment (presumably for portability purposes). > > > > Because of this, we might need to introduce a new function that takes an > > unsigned long long* (and then _m128* when we do the SSE4.1 option) > because > > casting a char* doesn't work. > > > > Do you know of any workarounds here? memcpy() to an unsigned long long* > > solves the alignment problem but adds a performance overhead. If the > worst > > case is better than the existing algorithm then it might be worth it > > though... It would make sense to also offer a second function to allow > > callers to dump in a block of guaranteed-aligned memory. > > Can't you do the CRC byte-by-byte until you reach an address that is > properly aligned? > > See lib/memchr.c for an example. > > Thanks for working on this, by the way. > > Collin >