|
@@ -0,0 +1,44 @@
|
|
|
+# Copyright (C) 2016 Rene Nielsen <rene.nielsen@microsemi.com>
|
|
|
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
|
|
|
+
|
|
|
+#include <string.h>
|
|
|
+#include <stdio.h>
|
|
|
+
|
|
|
+#define LEN 1024
|
|
|
+
|
|
|
+int main(int argc, char *argv[])
|
|
|
+{
|
|
|
+ unsigned char a[LEN], exp;
|
|
|
+ int i, move_len, move_src, err = 0;
|
|
|
+
|
|
|
+
|
|
|
+ for (i = 0; i < LEN; i++) {
|
|
|
+ a[i] = i;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ move_src = LEN / 64;
|
|
|
+ move_len = LEN - move_src;
|
|
|
+
|
|
|
+ printf("Moving %d entries from index %d to 0\n", move_len, move_src);
|
|
|
+ memmove(a, &a[move_src], sizeof(a[0]) * move_len);
|
|
|
+
|
|
|
+
|
|
|
+ for (i = 0; i < LEN; i++) {
|
|
|
+
|
|
|
+
|
|
|
+ exp = i >= move_len ? i : i + move_src;
|
|
|
+ if (a[i] != exp) {
|
|
|
+ printf("Error: memmove() failed. Expected a[%d] = %u, got %u\n", i, exp, a[i]);
|
|
|
+ err = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!err) {
|
|
|
+ printf("memmove() succeeded\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ return err;
|
|
|
+}
|
|
|
+
|