UNALIGNED_LOAD64 a puzzle?

36 views
Skip to first unread message

szxia...@gmail.com

unread,
Jun 15, 2014, 2:33:00 AM6/15/14
to cityhash...@googlegroups.com
static uint64 UNALIGNED_LOAD64(const char *p) {
  uint64 result;
  memcpy(&result, p, sizeof(result));
  return result;
}
 
why not
 memcpy(&result, &p, sizeof(result));
 
 
memcpy(&result, p, sizeof(result)  only copy character values cutted 64 bit  from p.
 memcpy(&result, &p, sizeof(result));  really copy the address 64bit value to result.
 
is realy right?
 

tay...@gmail.com

unread,
Nov 19, 2014, 2:14:16 AM11/19/14
to cityhash...@googlegroups.com
You are really copying data pointed to by p which might be unaligned to result. This is needed for machines that don't support unaligned access.
Reply all
Reply to author
Forward
0 new messages