1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-20 11:11:24 +00:00

Unbreak 64-bit little-endian systems that do require alignment.

The fix involves using le16dec(), le32dec(), le16enc() and
le32enc(). This eliminates invalid casts and duplicated logic.
This commit is contained in:
Marcel Moolenaar 2006-12-21 05:40:46 +00:00
parent 6f3914bcf4
commit 94632b9fe1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=165431

View File

@ -92,25 +92,12 @@ struct bpb710 {
* use the macros for the big-endian case. * use the macros for the big-endian case.
*/ */
#include <machine/endian.h> #include <sys/endian.h>
#if (BYTE_ORDER == LITTLE_ENDIAN) #define getushort(x) le16dec(x)
#define getushort(x) *((u_int16_t *)(x)) #define getulong(x) le32dec(x)
#define getulong(x) *((u_int32_t *)(x)) #define putushort(p, v) le16enc(p, v)
#define putushort(p, v) (*((u_int16_t *)(p)) = (v)) #define putulong(p, v) le32enc(p, v)
#define putulong(p, v) (*((u_int32_t *)(p)) = (v))
#else
#define getushort(x) (((u_int8_t *)(x))[0] + (((u_int8_t *)(x))[1] << 8))
#define getulong(x) (u_int32_t)(((u_int8_t *)(x))[0] + (((u_int8_t *)(x))[1] << 8) \
+ (((u_int8_t *)(x))[2] << 16) \
+ (((u_int8_t *)(x))[3] << 24))
#define putushort(p, v) (((u_int8_t *)(p))[0] = (v), \
((u_int8_t *)(p))[1] = (v) >> 8)
#define putulong(p, v) (((u_int8_t *)(p))[0] = (v), \
((u_int8_t *)(p))[1] = (v) >> 8, \
((u_int8_t *)(p))[2] = (v) >> 16,\
((u_int8_t *)(p))[3] = (v) >> 24)
#endif
/* /*
* BIOS Parameter Block (BPB) for DOS 3.3 * BIOS Parameter Block (BPB) for DOS 3.3