summaryrefslogtreecommitdiffstats
path: root/freebsd
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@oarcorp.com>2012-04-18 09:48:49 -0500
committerJoel Sherrill <joel.sherrill@oarcorp.com>2012-04-18 09:49:03 -0500
commitf084ec7edce9cfb282c9f46adc7f4677fbdcc376 (patch)
tree541562f12add7d4fccc01df664fc49d965bf9b9e /freebsd
parentMoved rtems-bsd-cyclecount.c to cpu.h (diff)
downloadrtems-libbsd-f084ec7edce9cfb282c9f46adc7f4677fbdcc376.tar.bz2
Add generic implementation of __bswap64
Diffstat (limited to 'freebsd')
-rw-r--r--freebsd/sys/endian.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/freebsd/sys/endian.h b/freebsd/sys/endian.h
index 5c95d748..19e1ff25 100644
--- a/freebsd/sys/endian.h
+++ b/freebsd/sys/endian.h
@@ -197,4 +197,20 @@ le64enc(void *pp, uint64_t u)
le32enc(p + 4, u >> 32);
}
+/*
+ * In FreeBSD, this can be CPU specific but most targets use this
+ * implementation.
+ *
+ * This is from the powerpc implementation.
+ */
+static __inline uint64_t
+__bswap64(uint64_t _x)
+{
+
+ return ((_x >> 56) | ((_x >> 40) & 0xff00) | ((_x >> 24) & 0xff0000) |
+ ((_x >> 8) & 0xff000000) | ((_x << 8) & ((__uint64_t)0xff << 32)) |
+ ((_x << 24) & ((__uint64_t)0xff << 40)) |
+ ((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56)));
+}
+
#endif /* _SYS_ENDIAN_HH_ */