From 94632b9fe1b71140751fb49369a8bfa000d0ecaa Mon Sep 17 00:00:00 2001 From: Marcel Moolenaar Date: Thu, 21 Dec 2006 05:40:46 +0000 Subject: 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. --- sys/fs/msdosfs/bpb.h | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'sys/fs/msdosfs/bpb.h') diff --git a/sys/fs/msdosfs/bpb.h b/sys/fs/msdosfs/bpb.h index 1374c9ae7564..683e755276c3 100644 --- a/sys/fs/msdosfs/bpb.h +++ b/sys/fs/msdosfs/bpb.h @@ -92,25 +92,12 @@ struct bpb710 { * use the macros for the big-endian case. */ -#include +#include -#if (BYTE_ORDER == LITTLE_ENDIAN) -#define getushort(x) *((u_int16_t *)(x)) -#define getulong(x) *((u_int32_t *)(x)) -#define putushort(p, v) (*((u_int16_t *)(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 +#define getushort(x) le16dec(x) +#define getulong(x) le32dec(x) +#define putushort(p, v) le16enc(p, v) +#define putulong(p, v) le32enc(p, v) /* * BIOS Parameter Block (BPB) for DOS 3.3 -- cgit v1.2.3