summaryrefslogtreecommitdiffstats
path: root/osdep/swab.c
diff options
context:
space:
mode:
Diffstat (limited to 'osdep/swab.c')
-rw-r--r--osdep/swab.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/osdep/swab.c b/osdep/swab.c
new file mode 100644
index 0000000000..45d26cbc14
--- /dev/null
+++ b/osdep/swab.c
@@ -0,0 +1,17 @@
+#include "../config.h"
+
+#ifndef HAVE_SWAB
+/* system has no swab. emulate via bswap */
+#include "../bswap.h"
+#include <unistd.h>
+
+void swab(const void *from, void *to, ssize_t n) {
+ const int16_t *in = (int16_t*)from;
+ int16_t *out = (int16_t*)to;
+ int i;
+ n /= 2;
+ for (i = 0 ; i < n; i++) {
+ out[i] = bswap_16(in[i]);
+ }
+}
+#endif