[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit

Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/build/uClibc/test/stat/Makefile b/ap/build/uClibc/test/stat/Makefile
new file mode 100644
index 0000000..ecde416
--- /dev/null
+++ b/ap/build/uClibc/test/stat/Makefile
@@ -0,0 +1,7 @@
+# uClibc stat tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+top_builddir=../../
+include ../Rules.mak
+-include Makefile.in
+include ../Test.mak
diff --git a/ap/build/uClibc/test/stat/Makefile.in b/ap/build/uClibc/test/stat/Makefile.in
new file mode 100644
index 0000000..9c06ded
--- /dev/null
+++ b/ap/build/uClibc/test/stat/Makefile.in
@@ -0,0 +1,13 @@
+# uClibc stat tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+ifeq ($(UCLIBC_HAS_LFS),)
+TESTS_DISABLED := stat64
+endif
+CFLAGS_stat64 := -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
+
+DODIFF_stat   := 1
+DODIFF_stat64 := 1
+
+OPTS_stat   := Makefile
+OPTS_stat64 := Makefile
diff --git a/ap/build/uClibc/test/stat/memcmp-stat.c b/ap/build/uClibc/test/stat/memcmp-stat.c
new file mode 100644
index 0000000..254c754
--- /dev/null
+++ b/ap/build/uClibc/test/stat/memcmp-stat.c
@@ -0,0 +1,107 @@
+/* Distilled from issue found with tar and symlinks.
+ * Make sure that the whole stat struct between runs
+ * is agreeable.
+ */
+
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <assert.h>
+#include <time.h>
+
+static void show_stat(struct stat *st)
+{
+	printf(
+		"------------------\n"
+		"st_dev     = %li\n"
+		"st_ino     = %li\n"
+		"st_mode    = %li\n"
+		"st_nlink   = %li\n"
+		"st_uid     = %li\n"
+		"st_gid     = %li\n"
+		"st_rdev    = %li\n"
+		"st_size    = %li\n"
+		"st_blksize = %li\n"
+		"st_blocks  = %li\n"
+		"st_atime   = %li\n"
+		"st_ansec   = %li\n"
+		"st_mtime   = %li\n"
+		"st_mnsec   = %li\n"
+		"st_ctime   = %li\n"
+		"st_cnsec   = %li\n",
+		(long int)st->st_dev,
+		(long int)st->st_ino,
+		(long int)st->st_mode,
+		(long int)st->st_nlink,
+		(long int)st->st_uid,
+		(long int)st->st_gid,
+		(long int)st->st_rdev,
+		(long int)st->st_size,
+		(long int)st->st_blksize,
+		(long int)st->st_blocks,
+#if !defined(__UCLIBC__) || defined(__USE_MISC)
+		(long int)st->st_atime,
+		(long int)st->st_atim.tv_nsec,
+		(long int)st->st_mtime,
+		(long int)st->st_mtim.tv_nsec,
+		(long int)st->st_ctime,
+		(long int)st->st_ctim.tv_nsec
+#else
+		(long int)st->st_atime,
+		(long int)st->st_atimensec,
+		(long int)st->st_mtime,
+		(long int)st->st_mtimensec,
+		(long int)st->st_ctime,
+		(long int)st->st_ctimensec
+#endif
+	);
+}
+
+int main(void)
+{
+	int ret;
+	int fd;
+	struct stat fst, st;
+
+	memset(&fst, 0xAA, sizeof(fst));
+	memset(&st, 0x55, sizeof(st));
+
+	unlink(".testfile");
+	fd = open(".testfile", O_WRONLY | O_CREAT | O_EXCL, 0);
+	if (fd < 0) {
+		perror("open(.testfile) failed");
+		return 1;
+	}
+	ret = fstat(fd, &fst);
+	if (ret != 0) {
+		perror("fstat(.testfile) failed");
+		return 1;
+	}
+	close(fd);
+
+	ret = stat(".testfile", &st);
+	if (ret != 0) {
+		perror("stat(.testfile) failed");
+		return 1;
+	}
+
+	ret = memcmp(&fst, &st, sizeof(fst));
+	if (ret != 0) {
+		printf("FAILED: memcmp() = %i\n", ret);
+		show_stat(&fst);
+		show_stat(&st);
+	}
+
+	unlink(".testfile");
+
+	return ret;
+}
diff --git a/ap/build/uClibc/test/stat/stat-loop256.c b/ap/build/uClibc/test/stat/stat-loop256.c
new file mode 100644
index 0000000..14284c1
--- /dev/null
+++ b/ap/build/uClibc/test/stat/stat-loop256.c
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+int main()
+{
+    struct stat statbuf;
+    int ret = 0;
+    char* loop255 = "/dev/loop255";
+    char* loop256 = "/dev/loop256";
+    mode_t mode = 0660;
+    mknod(loop255, mode, 0x7ff);
+    mknod(loop256, mode, 0x100700);
+    ret = stat(loop255, &statbuf);
+    if(ret < 0) {
+	printf("stat: Cant stat %s\n",loop255);
+	unlink(loop255);
+	exit(1);
+    }
+    ret = stat(loop256, &statbuf);
+    if(ret < 0) {
+        printf("stat: Cant stat %s\n",loop256);
+	unlink(loop255);
+	unlink(loop256);
+        exit(1);
+    }
+
+    unlink(loop255);
+    unlink(loop256);
+    exit(0);
+}
+
diff --git a/ap/build/uClibc/test/stat/stat.c b/ap/build/uClibc/test/stat/stat.c
new file mode 100644
index 0000000..4980cdd
--- /dev/null
+++ b/ap/build/uClibc/test/stat/stat.c
@@ -0,0 +1,71 @@
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+static void print_struct_stat(char *msg, struct stat *s)
+{
+    printf("%s\n", msg);
+    /* The casts are because glibc thinks it's cool */
+    printf("device    : 0x%llx\n",(long long)s->st_dev);
+    printf("inode     : %lld\n",  (long long)s->st_ino);
+    printf("mode      : 0x%llx\n",(long long)s->st_mode);
+    printf("nlink     : %lld\n",  (long long)s->st_nlink);
+    printf("uid       : %lld\n",  (long long)s->st_uid);
+    printf("gid       : %lld\n",  (long long)s->st_gid);
+    printf("rdev      : 0x%llx\n",(long long)s->st_rdev);
+    printf("size      : %lld\n",  (long long)s->st_size);
+    printf("blksize   : %lld\n",  (long long)s->st_blksize);
+    printf("blocks    : %lld\n",  (long long)s->st_blocks);
+    printf("atime     : %lld\n",  (long long)s->st_atime);
+    printf("mtime     : %lld\n",  (long long)s->st_mtime);
+    printf("ctime     : %lld\n",  (long long)s->st_ctime);
+}
+
+int main(int argc,char **argv)
+{
+    int fd, ret;
+    char *file;
+    struct stat s;
+
+    if (argc < 2) {
+	fprintf(stderr, "Usage: stat FILE\n");
+	exit(1);
+    }
+    file = argv[1];
+
+    memset(&s, 0, sizeof(struct stat));
+    ret = stat(file, &s);
+    if(ret<0){
+	perror("stat");
+	exit(1);
+    }
+    print_struct_stat("\nTesting stat:", &s);
+
+    memset(&s, 0, sizeof(struct stat));
+    ret = lstat(file, &s);
+    if(ret<0){
+	perror("lstat");
+	exit(1);
+    }
+    print_struct_stat("\nTesting lstat:", &s);
+
+
+    fd = open(file, O_RDONLY);
+    if(fd<0){
+	perror("open");
+	exit(1);
+    }
+    memset(&s, 0, sizeof(struct stat));
+    ret = fstat(fd,&s);
+    if(ret<0){
+	perror("fstat");
+	exit(1);
+    }
+    print_struct_stat("\nTesting fstat:", &s);
+
+    exit(0);
+}
+
diff --git a/ap/build/uClibc/test/stat/stat64.c b/ap/build/uClibc/test/stat/stat64.c
new file mode 100644
index 0000000..a074251
--- /dev/null
+++ b/ap/build/uClibc/test/stat/stat64.c
@@ -0,0 +1 @@
+#include "stat.c"