summaryrefslogtreecommitdiff
path: root/fatfs
diff options
context:
space:
mode:
authorMarcus Brinkmann <marcus@gnu.org>2003-08-09 16:37:58 +0000
committerMarcus Brinkmann <marcus@gnu.org>2003-08-09 16:37:58 +0000
commitc9404ef427b7e57f986c1a83ec54fed86def5c58 (patch)
tree5712dd2a12355440d403e60f141c36940535451e /fatfs
parent1e738dbcb04eb5f9ac7a32028dcbb5751ee76fb9 (diff)
2003-08-09 Marcus Brinkmann <marcus@gnu.org>
* fat.h (read_dword) [BYTE_ORDER == BIG_ENDIAN]: Use bswap_32 to swap bytes. (write_dword) [BYTE_ORDER == BIG_ENDIAN]: Likewise. (read_word) [BYTE_ORDER == BIG_ENDIAN]: Use bswap_16 to swap bytes. (write_word) [BYTE_ORDER == BIG_ENDIAN]: Likewise.
Diffstat (limited to 'fatfs')
-rw-r--r--fatfs/ChangeLog8
-rw-r--r--fatfs/fat.h23
2 files changed, 17 insertions, 14 deletions
diff --git a/fatfs/ChangeLog b/fatfs/ChangeLog
index 3c5acce8..9d282f1f 100644
--- a/fatfs/ChangeLog
+++ b/fatfs/ChangeLog
@@ -1,3 +1,11 @@
+2003-08-09 Marcus Brinkmann <marcus@gnu.org>
+
+ * fat.h (read_dword) [BYTE_ORDER == BIG_ENDIAN]: Use bswap_32 to
+ swap bytes.
+ (write_dword) [BYTE_ORDER == BIG_ENDIAN]: Likewise.
+ (read_word) [BYTE_ORDER == BIG_ENDIAN]: Use bswap_16 to swap bytes.
+ (write_word) [BYTE_ORDER == BIG_ENDIAN]: Likewise.
+
2003-08-03 Marco Gerards <metgerards@student.han.nl>
* fatfs.h (struct disknode): New member DIRNODE.
diff --git a/fatfs/fat.h b/fatfs/fat.h
index 91e5a5cb..a76e37f8 100644
--- a/fatfs/fat.h
+++ b/fatfs/fat.h
@@ -1,5 +1,5 @@
/* fat.h - Support for FAT filesystems interfaces.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Written by Marcus Brinkmann.
This file is part of the GNU Hurd.
@@ -353,10 +353,9 @@ read_dword (unsigned char *addr)
#if BYTE_ORDER == LITTLE_ENDIAN
return *(unsigned int *)addr;
#elif BYTE_ORDER == BIG_ENDIAN
- return *(unsigned int *)(addr + 4);
+ return bswap_32 (*(unsigned int *) addr);
#else
- return
- addr[0] | (addr[1] << 8) | (addr[2] << 16) | (addr[3] << 24);
+#error unknown byte order
#endif
}
@@ -366,9 +365,9 @@ read_word (unsigned char *addr)
#if BYTE_ORDER == LITTLE_ENDIAN
return *(unsigned short *)addr;
#elif BYTE_ORDER == BIG_ENDIAN
- return *(unsigned short *)addr + 2;
+ return bswap_16 (*(unsigned int *) addr);
#else
- return addr[0] | (addr[1] << 8);
+#error unknown byte order
#endif
}
@@ -378,12 +377,9 @@ write_dword (unsigned char *addr, unsigned int value)
#if BYTE_ORDER == LITTLE_ENDIAN
*(unsigned int *)addr = value;
#elif BYTE_ORDER == BIG_ENDIAN
-#error unknown byte order
+ *(unsigned int *)addr = bswap_32 (value);
#else
- addr[0] = value & 0xff;
- addr[1] = (value >> 8) & 0xff;
- addr[2] = (value >> 16) & 0xff;
- addr[3] = (value >> 24) & 0xff;
+#error unknown byte order
#endif
}
@@ -393,10 +389,9 @@ write_word (unsigned char *addr, unsigned int value)
#if BYTE_ORDER == LITTLE_ENDIAN
*(unsigned short *)addr = value;
#elif BYTE_ORDER == BIG_ENDIAN
-#error unknown byte order
+ *(unsigned int *)addr = bswap_16 (value);
#else
- addr[0] = value & 0xff;
- addr[1] = (value >> 8) & 0xff;
+#error unknown byte order
#endif
}