aboutsummaryrefslogtreecommitdiff
path: root/sys/fs/msdosfs/bpb.h
diff options
context:
space:
mode:
authorMarcel Moolenaar <marcel@FreeBSD.org>2006-12-21 05:40:46 +0000
committerMarcel Moolenaar <marcel@FreeBSD.org>2006-12-21 05:40:46 +0000
commit94632b9fe1b71140751fb49369a8bfa000d0ecaa (patch)
tree72af97d29b12d7a9ee3f9fc05be2991505855b0f /sys/fs/msdosfs/bpb.h
parent6f3914bcf4dd5e09693aff94d28498c126579534 (diff)
downloadsrc-94632b9fe1b71140751fb49369a8bfa000d0ecaa.tar.gz
src-94632b9fe1b71140751fb49369a8bfa000d0ecaa.zip
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.
Notes
Notes: svn path=/head/; revision=165431
Diffstat (limited to 'sys/fs/msdosfs/bpb.h')
-rw-r--r--sys/fs/msdosfs/bpb.h23
1 files changed, 5 insertions, 18 deletions
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 <machine/endian.h>
+#include <sys/endian.h>
-#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