Commit Graph

7 Commits

Author SHA1 Message Date
H. Peter Anvin
f52ea70dd1 bytesex.h: more simplifications and add const
Add more simplifications where it is practical; unify WRITECHAR() as
it has no need for byte swapping in any way.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-11-29 17:19:27 -08:00
H. Peter Anvin
df5548a40c bytesex.h: make sure WRITE*() doesn't screw up on wrong pointer type
Make the WRITE*() macros independent of pointer type.  As it was, we
would get totally wrong result on X86_MEMORY machines if the pointer
was not uint8_t *.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-11-29 17:07:58 -08:00
H. Peter Anvin
7370483b00 bytesex.h: remove an unnecessary double expansion in WRITEADDR()
We can't really avoid the double expansion of (p), but the WRITE*()
macros all do that.  However, there is no reason to double-expand (s).

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-11-29 16:59:49 -08:00
H. Peter Anvin
8cdde2bbaa bytesex.h: simplify the trivial case of cpu_to_le*()
In the trivial case, cpu_to_le*() can just be macros containing a
single cast.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-11-29 16:56:59 -08:00
H. Peter Anvin
b230622576 bytesex.h: unify and optimize WRITEADDR()
WRITEADDR() really doesn't need multiple implementations.  Unify them,
and optimize the case of a constant length argument (not sure if that
is currently used, however.)

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-11-29 16:05:59 -08:00
H. Peter Anvin
53cd7c7bf0 bytesex: more endianness detection hacks
A few more tricks for sussing out endinanness, and add an ultimate
fallback option.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-25 12:51:17 -07:00
H. Peter Anvin
d3e22572b3 Clean up byteorder functions
Move byte order handling functions to their own header file, and try
to be more specific about how exactly to handle things.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-24 13:01:08 -07:00