summaryrefslogtreecommitdiff
path: root/cesar/lib/src/swap.c
diff options
context:
space:
mode:
authorsave2008-04-07 14:17:42 +0000
committersave2008-04-07 14:17:42 +0000
commit3d58a62727346b7ac1a6cb36fed1a06ed72228dd (patch)
treed7788c3cf9f76426aef0286d0202e2097f0fa0eb /cesar/lib/src/swap.c
parent095dca4b0a8d4924093bab424f71f588fdd84613 (diff)
Moved the complete svn base into the cesar directory.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1769 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/lib/src/swap.c')
-rw-r--r--cesar/lib/src/swap.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/cesar/lib/src/swap.c b/cesar/lib/src/swap.c
new file mode 100644
index 0000000000..cff0a9473f
--- /dev/null
+++ b/cesar/lib/src/swap.c
@@ -0,0 +1,31 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file lib/src/swap.c
+ * \brief generic swap functions
+ * \ingroup lib
+ */
+#include "common/std.h"
+#include "lib/swap.h"
+
+/** swap an unsigned short */
+u16 swap16(u16 x)
+{
+ return (u16)( (((u16)(x) & (u16)0x00ff) << 8) |
+ (((u16)(x) & (u16)0xff00) >> 8) );
+}
+
+/** swap an unsigned long */
+u32 swap32(u32 x)
+{
+ return (u32)( (((u32)(x) & (u32)0x000000ff) << 24) |
+ (((u32)(x) & (u32)0x0000ff00) << 8) |
+ (((u32)(x) & (u32)0x00ff0000) >> 8) |
+ (((u32)(x) & (u32)0xff000000) >> 24) );
+}
+