libc: add new swab.c file
authorAlan Cox <alan@etchedpixels.co.uk>
Wed, 21 Oct 2015 20:53:41 +0000 (21:53 +0100)
committerAlan Cox <alan@etchedpixels.co.uk>
Wed, 21 Oct 2015 20:53:41 +0000 (21:53 +0100)
Library/libs/swab.c [new file with mode: 0644]

diff --git a/Library/libs/swab.c b/Library/libs/swab.c
new file mode 100644 (file)
index 0000000..17f7235
--- /dev/null
@@ -0,0 +1,13 @@
+#include <unistd.h>
+
+void swab(const void *from, void *to, ssize_t n)
+{
+  const uint8_t *f = from;
+  uint8_t *t = to;
+  n >>= 1;
+  while(n--) {
+    *t++ = f[1];
+    *t++ = *f;
+    f += 2;
+  }
+}