summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-01-23 08:06:41 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-01-24 08:39:22 +0100
commit2711914f828d19d726d3b2d9cda401352b626fc2 (patch)
tree00304bdca9afa49e5edb28f4c951f00a29698060
parentdc9b70445015402d4d043830ecf4dd84b9400d49 (diff)
downloadrtems-2711914f828d19d726d3b2d9cda401352b626fc2.tar.bz2
Use <sys/endian.h>
Update #2803.
-rw-r--r--c/src/libchip/ide/ata_internal.h16
-rw-r--r--cpukit/libblock/include/rtems/ide_part_table.h18
-rw-r--r--cpukit/libfs/src/dosfs/fat.h18
-rw-r--r--cpukit/libmisc/shell/main_pci.c4
4 files changed, 17 insertions, 39 deletions
diff --git a/c/src/libchip/ide/ata_internal.h b/c/src/libchip/ide/ata_internal.h
index 887199d213..985b6f597c 100644
--- a/c/src/libchip/ide/ata_internal.h
+++ b/c/src/libchip/ide/ata_internal.h
@@ -16,6 +16,7 @@
#define __ATA_INTERNAL_H__
#include <sys/param.h>
+#include <sys/endian.h>
#include <rtems.h>
#include <sys/types.h>
#include <rtems/libio.h>
@@ -34,17 +35,10 @@ extern "C" {
* Naming: Ca_b_c, where a: F = from, T = to, b: LE = little-endian,
* BE = big-endian, c: W = word (16 bits), L = longword (32 bits)
*/
-#if (CPU_BIG_ENDIAN == TRUE)
-# define CF_LE_W(v) CPU_swap_u16(v)
-# define CF_LE_L(v) CPU_swap_u32(v)
-# define CT_LE_W(v) CPU_swap_u16(v)
-# define CT_LE_L(v) CPU_swap_u32(v)
-#else
-# define CF_LE_W(v) (v)
-# define CF_LE_L(v) (v)
-# define CT_LE_W(v) (v)
-# define CT_LE_L(v) (v)
-#endif
+#define CF_LE_W(v) le16toh(v)
+#define CF_LE_L(v) le32toh(v)
+#define CT_LE_W(v) htole16(v)
+#define CT_LE_L(v) htole32(v)
#define ATA_UNDEFINED_VALUE (-1)
diff --git a/cpukit/libblock/include/rtems/ide_part_table.h b/cpukit/libblock/include/rtems/ide_part_table.h
index c638e2808e..8b683b3ff5 100644
--- a/cpukit/libblock/include/rtems/ide_part_table.h
+++ b/cpukit/libblock/include/rtems/ide_part_table.h
@@ -26,6 +26,7 @@
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/types.h>
+#include <sys/endian.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
@@ -57,19 +58,10 @@
/*
* Conversion from and to little-endian byte order. (no-op on i386/i486)
*/
-
-#if (CPU_BIG_ENDIAN == TRUE)
-# define LE_TO_CPU_U16(v) CPU_swap_u16(v)
-# define LE_TO_CPU_U32(v) CPU_swap_u32(v)
-# define CPU_TO_LE_U16(v) CPU_swap_u16(v)
-# define CPU_TO_LE_U32(v) CPU_swap_u32(v)
-#else
-# define LE_TO_CPU_U16(v) (v)
-# define LE_TO_CPU_U32(v) (v)
-# define CPU_TO_LE_U16(v) (v)
-# define CPU_TO_LE_U32(v) (v)
-#endif
-
+#define LE_TO_CPU_U16(v) le16toh(v)
+#define LE_TO_CPU_U32(v) le32toh(v)
+#define CPU_TO_LE_U16(v) htole16(v)
+#define CPU_TO_LE_U32(v) htole32(v)
/*
* sector_data_t --
diff --git a/cpukit/libfs/src/dosfs/fat.h b/cpukit/libfs/src/dosfs/fat.h
index 6b866794e1..8fcd17f926 100644
--- a/cpukit/libfs/src/dosfs/fat.h
+++ b/cpukit/libfs/src/dosfs/fat.h
@@ -23,11 +23,11 @@
#define __DOSFS_FAT_H__
#include <sys/param.h>
+#include <sys/endian.h>
#include <string.h>
#include <rtems/seterr.h>
-#include <rtems/score/cpu.h>
#include <errno.h>
#include <rtems/bdbuf.h>
@@ -56,18 +56,10 @@ extern "C" {
* Naming: Ca_b_c, where a: F = from, T = to, b: LE = little-endian,
* BE = big-endian, c: W = word (16 bits), L = longword (32 bits)
*/
-
-#if (CPU_BIG_ENDIAN == TRUE)
-# define CF_LE_W(v) CPU_swap_u16((uint16_t)(v))
-# define CF_LE_L(v) CPU_swap_u32((uint32_t)(v))
-# define CT_LE_W(v) CPU_swap_u16((uint16_t)(v))
-# define CT_LE_L(v) CPU_swap_u32((uint32_t)(v))
-#else
-# define CF_LE_W(v) (v)
-# define CF_LE_L(v) (v)
-# define CT_LE_W(v) (v)
-# define CT_LE_L(v) (v)
-#endif
+#define CF_LE_W(v) le16toh(v)
+#define CF_LE_L(v) le32toh(v)
+#define CT_LE_W(v) htole16(v)
+#define CT_LE_L(v) htole32(v)
#define FAT_HASH_SIZE 2
#define FAT_HASH_MODULE FAT_HASH_SIZE
diff --git a/cpukit/libmisc/shell/main_pci.c b/cpukit/libmisc/shell/main_pci.c
index c1d9535459..a71b3fdb37 100644
--- a/cpukit/libmisc/shell/main_pci.c
+++ b/cpukit/libmisc/shell/main_pci.c
@@ -19,7 +19,7 @@
#include <pci.h>
#include <pci/cfg.h>
#include <pci/access.h>
-#include <rtems/endian.h>
+#include <sys/endian.h>
#include <bsp.h> /* For PCI endianness config */
#include <rtems.h>
@@ -416,7 +416,7 @@ static int pci_summary(void)
printf(" CFG LIBRARY: %s\n", cfglib_strs[pci_config_lib_type]);
printf(" NO. PCI BUSES: %d buses\n", pci_bus_count());
printf(" PCI ENDIAN: %s\n", pci_endian ? "Big" : "Little");
-#if (CPU_LITTLE_ENDIAN == TRUE)
+#if BYTE_ORDER == LITTLE_ENDIAN
puts(" MACHINE ENDIAN: Little");
#else
puts(" MACHINE ENDIAN: Big");