[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Architectures where unaligned access is (not) OK?



On Fri, 21 Nov 2014, Simon McVittie wrote:

> failing to start up on armel due to unaligned memory accesses. lzo2 has
> a cpp macro, LZO_CFG_NO_UNALIGNED which can be defined to stop it doing
> "clever" things with casting pointers. If the maintainer doesn't object

Please define this macro unconditionally:

• “clever” things with pointers are often Undefined Behaviour™
  and GCC is a repeat offender at optimising these into brokenness;
  LLVM also makes advantage of the C standard here

• for i386 and especially amd64, all subarchitectures supported
  by Debian/Linux jessie suffer so much from unaligned access,
  speed-wise, that it’s worth the overhead of forcing aligned
  access (i386, i486 maybe were not as badly affected)

• it’s good to have the same codepath independent of the arch
  compiled for, instead of slightly differing across arches

Thanks,
//mirabilos
-- 
Sometimes they [people] care too much: pretty printers [and syntax highligh-
ting, d.A.] mechanically produce pretty output that accentuates irrelevant
detail in the program, which is as sensible as putting all the prepositions
in English text in bold font.	-- Rob Pike in "Notes on Programming in C"


Reply to: