Skip to content

Commit

Permalink
hv_macro.h: only use direct memory loads on little endian machines
Browse files Browse the repository at this point in the history
Using the shift logic should work correctly anywhere, using direct
memory loads will only work correctly on little endian machines.
  • Loading branch information
demerphq committed Apr 10, 2022
1 parent bb5e773 commit da03677
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hv_macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#ifndef U8TO16_LE
#define _shifted_octet(type,ptr,idx,shift) (((type)(((U8*)(ptr))[(idx)]))<<(shift))
#ifdef USE_UNALIGNED_PTR_DEREF
#if defined(USE_UNALIGNED_PTR_DEREF) && (BYTEORDER == 0x1234 || BYTEORDER == 0x12345678)
#define U8TO16_LE(ptr) (*((const U16*)(ptr)))
#define U8TO32_LE(ptr) (*((const U32*)(ptr)))
#define U8TO64_LE(ptr) (*((const U64*)(ptr)))
Expand Down

0 comments on commit da03677

Please sign in to comment.