[Feature][ZXW-33]merge ZXW 0428 version

Change-Id: I11f167edfea428d9fab198ff00ff1364932d1b0b
diff --git a/ap/libc/glibc/glibc-2.23/assert/Depend b/ap/libc/glibc/glibc-2.23/assert/Depend
new file mode 100644
index 0000000..981111e
--- /dev/null
+++ b/ap/libc/glibc/glibc-2.23/assert/Depend
@@ -0,0 +1,2 @@
+iconvdata
+localedata
diff --git a/ap/libc/glibc/glibc-2.23/assert/Makefile b/ap/libc/glibc/glibc-2.23/assert/Makefile
new file mode 100644
index 0000000..cd0d809
--- /dev/null
+++ b/ap/libc/glibc/glibc-2.23/assert/Makefile
@@ -0,0 +1,30 @@
+# Copyright (C) 1991-2016 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+#
+#	Sub-makefile for assert portion of the library.
+#
+subdir	:= assert
+
+include ../Makeconfig
+
+headers	:= assert.h
+
+routines := assert assert-perr __assert
+tests := test-assert test-assert-perr
+
+include ../Rules
diff --git a/ap/libc/glibc/glibc-2.23/assert/Versions b/ap/libc/glibc/glibc-2.23/assert/Versions
new file mode 100644
index 0000000..9e1a5f2
--- /dev/null
+++ b/ap/libc/glibc/glibc-2.23/assert/Versions
@@ -0,0 +1,10 @@
+libc {
+  GLIBC_2.0 {
+    # functions used in inline functions or macros
+    __assert_fail; __assert_perror_fail;
+  }
+  GLIBC_2.2 {
+    # just for standard compliance
+    __assert;
+  }
+}
diff --git a/ap/libc/glibc/glibc-2.23/assert/__assert.c b/ap/libc/glibc/glibc-2.23/assert/__assert.c
new file mode 100644
index 0000000..75c6852
--- /dev/null
+++ b/ap/libc/glibc/glibc-2.23/assert/__assert.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 2000-2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* We have to see the prototype.  */
+#undef NDEBUG
+#include <assert.h>
+
+void
+__assert (const char *assertion, const char *file, int line)
+{
+  __assert_fail (assertion, file, line, (const char *) 0);
+}
diff --git a/ap/libc/glibc/glibc-2.23/assert/assert-perr.c b/ap/libc/glibc/glibc-2.23/assert/assert-perr.c
new file mode 100644
index 0000000..f4fc08f
--- /dev/null
+++ b/ap/libc/glibc/glibc-2.23/assert/assert-perr.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1994-2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <assert.h>
+#include <libintl.h>
+#include <string.h>
+
+
+/* This function, when passed an error number, a filename, and a line
+   number, prints a message on the standard error stream of the form:
+	a.c:10: foobar: Unexpected error: Computer bought the farm
+   It then aborts program execution via a call to `abort'.  */
+void
+__assert_perror_fail (int errnum,
+		      const char *file, unsigned int line,
+		      const char *function)
+{
+  char errbuf[1024];
+
+  char *e = __strerror_r (errnum, errbuf, sizeof errbuf);
+  __assert_fail_base (_("%s%s%s:%u: %s%sUnexpected error: %s.\n"),
+		      e, file, line, function);
+}
+libc_hidden_def (__assert_perror_fail)
diff --git a/ap/libc/glibc/glibc-2.23/assert/assert.c b/ap/libc/glibc/glibc-2.23/assert/assert.c
new file mode 100644
index 0000000..8e8e298
--- /dev/null
+++ b/ap/libc/glibc/glibc-2.23/assert/assert.c
@@ -0,0 +1,104 @@
+/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <assert.h>
+#include <atomic.h>
+#include <ldsodefs.h>
+#include <libintl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sysdep.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+
+extern const char *__progname;
+
+#include <wchar.h>
+#include <libio/iolibio.h>
+#define fflush(s) _IO_fflush (s)
+
+/* This function, when passed a string containing an asserted
+   expression, a filename, and a line number, prints a message
+   on the standard error stream of the form:
+	a.c:10: foobar: Assertion `a == b' failed.
+   It then aborts program execution via a call to `abort'.  */
+
+#ifdef FATAL_PREPARE_INCLUDE
+# include FATAL_PREPARE_INCLUDE
+#endif
+
+
+void
+__assert_fail_base (const char *fmt, const char *assertion, const char *file,
+		    unsigned int line, const char *function)
+{
+  char *str;
+
+#ifdef FATAL_PREPARE
+  FATAL_PREPARE;
+#endif
+
+  int total;
+  if (__asprintf (&str, fmt,
+		  __progname, __progname[0] ? ": " : "",
+		  file, line,
+		  function ? function : "", function ? ": " : "",
+		  assertion, &total) >= 0)
+    {
+      /* Print the message.  */
+      (void) __fxprintf (NULL, "%s", str);
+      (void) fflush (stderr);
+
+      total = (total + 1 + GLRO(dl_pagesize) - 1) & ~(GLRO(dl_pagesize) - 1);
+      struct abort_msg_s *buf = __mmap (NULL, total, PROT_READ | PROT_WRITE,
+					MAP_ANON | MAP_PRIVATE, -1, 0);
+      if (__glibc_likely (buf != MAP_FAILED))
+	{
+	  buf->size = total;
+	  strcpy (buf->msg, str);
+
+	  /* We have to free the old buffer since the application might
+	     catch the SIGABRT signal.  */
+	  struct abort_msg_s *old = atomic_exchange_acq (&__abort_msg, buf);
+
+	  if (old != NULL)
+	    __munmap (old, old->size);
+	}
+
+      free (str);
+    }
+  else
+    {
+      /* At least print a minimal message.  */
+      static const char errstr[] = "Unexpected error.\n";
+      __libc_write (STDERR_FILENO, errstr, sizeof (errstr) - 1);
+    }
+
+  abort ();
+}
+
+
+#undef __assert_fail
+void
+__assert_fail (const char *assertion, const char *file, unsigned int line,
+	       const char *function)
+{
+  __assert_fail_base (_("%s%s%s:%u: %s%sAssertion `%s' failed.\n%n"),
+		      assertion, file, line, function);
+}
+hidden_def(__assert_fail)
diff --git a/ap/libc/glibc/glibc-2.23/assert/assert.h b/ap/libc/glibc/glibc-2.23/assert/assert.h
new file mode 100644
index 0000000..729edeb
--- /dev/null
+++ b/ap/libc/glibc/glibc-2.23/assert/assert.h
@@ -0,0 +1,118 @@
+/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/*
+ *	ISO C99 Standard: 7.2 Diagnostics	<assert.h>
+ */
+
+#ifdef	_ASSERT_H
+
+# undef	_ASSERT_H
+# undef	assert
+# undef __ASSERT_VOID_CAST
+
+# ifdef	__USE_GNU
+#  undef assert_perror
+# endif
+
+#endif /* assert.h	*/
+
+#define	_ASSERT_H	1
+#include <features.h>
+
+#if defined __cplusplus && __GNUC_PREREQ (2,95)
+# define __ASSERT_VOID_CAST static_cast<void>
+#else
+# define __ASSERT_VOID_CAST (void)
+#endif
+
+/* void assert (int expression);
+
+   If NDEBUG is defined, do nothing.
+   If not, and EXPRESSION is zero, print an error message and abort.  */
+
+#ifdef	NDEBUG
+
+# define assert(expr)		(__ASSERT_VOID_CAST (0))
+
+/* void assert_perror (int errnum);
+
+   If NDEBUG is defined, do nothing.  If not, and ERRNUM is not zero, print an
+   error message with the error text for ERRNUM and abort.
+   (This is a GNU extension.) */
+
+# ifdef	__USE_GNU
+#  define assert_perror(errnum)	(__ASSERT_VOID_CAST (0))
+# endif
+
+#else /* Not NDEBUG.  */
+
+__BEGIN_DECLS
+
+/* This prints an "Assertion failed" message and aborts.  */
+extern void __assert_fail (const char *__assertion, const char *__file,
+			   unsigned int __line, const char *__function)
+     __THROW __attribute__ ((__noreturn__));
+
+/* Likewise, but prints the error text for ERRNUM.  */
+extern void __assert_perror_fail (int __errnum, const char *__file,
+				  unsigned int __line, const char *__function)
+     __THROW __attribute__ ((__noreturn__));
+
+
+/* The following is not at all used here but needed for standard
+   compliance.  */
+extern void __assert (const char *__assertion, const char *__file, int __line)
+     __THROW __attribute__ ((__noreturn__));
+
+
+__END_DECLS
+
+# define assert(expr)							\
+  ((expr)								\
+   ? __ASSERT_VOID_CAST (0)						\
+   : __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION))
+
+# ifdef	__USE_GNU
+#  define assert_perror(errnum)						\
+  (!(errnum)								\
+   ? __ASSERT_VOID_CAST (0)						\
+   : __assert_perror_fail ((errnum), __FILE__, __LINE__, __ASSERT_FUNCTION))
+# endif
+
+/* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
+   which contains the name of the function currently being defined.
+   This is broken in G++ before version 2.6.
+   C9x has a similar variable called __func__, but prefer the GCC one since
+   it demangles C++ function names.  */
+# if defined __cplusplus ? __GNUC_PREREQ (2, 6) : __GNUC_PREREQ (2, 4)
+#   define __ASSERT_FUNCTION	__PRETTY_FUNCTION__
+# else
+#  if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+#   define __ASSERT_FUNCTION	__func__
+#  else
+#   define __ASSERT_FUNCTION	((const char *) 0)
+#  endif
+# endif
+
+#endif /* NDEBUG.  */
+
+
+#if defined __USE_ISOC11 && !defined __cplusplus
+# undef static_assert
+# define static_assert _Static_assert
+#endif
diff --git a/ap/libc/glibc/glibc-2.23/assert/test-assert-perr.c b/ap/libc/glibc/glibc-2.23/assert/test-assert-perr.c
new file mode 100644
index 0000000..8496db6
--- /dev/null
+++ b/ap/libc/glibc/glibc-2.23/assert/test-assert-perr.c
@@ -0,0 +1,86 @@
+/* Test assert_perror().
+ *
+ * This is hairier than you'd think, involving games with
+ * stdio and signals.
+ *
+ */
+
+#include <signal.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <setjmp.h>
+
+jmp_buf rec;
+char buf[160];
+
+static void
+sigabrt (int unused)
+{
+  longjmp (rec, 1);  /* recover control */
+}
+
+#undef NDEBUG
+#include <assert.h>
+static void
+assert1 (void)
+{
+  assert_perror (1);
+}
+
+static void
+assert2 (void)
+{
+  assert_perror (0);
+}
+
+#define NDEBUG
+#include <assert.h>
+static void
+assert3 (void)
+{
+  assert_perror (2);
+}
+
+int
+main(void)
+{
+  volatile int failed = 1;  /* safety in presence of longjmp() */
+
+  fclose (stderr);
+  stderr = tmpfile ();
+  if (!stderr)
+    abort ();
+
+  signal (SIGABRT, sigabrt);
+
+  if (!setjmp (rec))
+    assert1 ();
+  else
+    failed = 0;  /* should happen */
+
+  if (!setjmp (rec))
+    assert2 ();
+  else
+    failed = 1; /* should not happen */
+
+  if (!setjmp (rec))
+    assert3 ();
+  else
+    failed = 1; /* should not happen */
+
+  rewind (stderr);
+  fgets (buf, 160, stderr);
+  if (!strstr(buf, strerror (1)))
+    failed = 1;
+
+  fgets (buf, 160, stderr);
+  if (strstr (buf, strerror (0)))
+    failed = 1;
+
+  fgets (buf, 160, stderr);
+  if (strstr (buf, strerror (2)))
+    failed = 1;
+
+  return failed;
+}
diff --git a/ap/libc/glibc/glibc-2.23/assert/test-assert.c b/ap/libc/glibc/glibc-2.23/assert/test-assert.c
new file mode 100644
index 0000000..26b58d4
--- /dev/null
+++ b/ap/libc/glibc/glibc-2.23/assert/test-assert.c
@@ -0,0 +1,88 @@
+/* Test assert().
+ *
+ * This is hairier than you'd think, involving games with
+ * stdio and signals.
+ *
+ */
+
+#include <signal.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <setjmp.h>
+
+jmp_buf rec;
+char buf[160];
+
+static void
+sigabrt (int unused)
+{
+  longjmp (rec, 1);  /* recover control */
+}
+
+#undef NDEBUG
+#include <assert.h>
+static void
+assert1 (void)
+{
+  assert (1 == 2);
+}
+
+static void
+assert2 (void)
+{
+  assert (1 == 1);
+}
+
+
+#define NDEBUG
+#include <assert.h>
+static void
+assert3 (void)
+{
+  assert (2 == 3);
+}
+
+int
+main (void)
+{
+
+  volatile int failed = 1;
+
+  fclose (stderr);
+  stderr = tmpfile ();
+  if(!stderr)
+    abort ();
+
+  signal (SIGABRT, sigabrt);
+
+  if (!setjmp (rec))
+    assert1 ();
+  else
+    failed = 0;  /* should happen */
+
+  if (!setjmp (rec))
+    assert2 ();
+  else
+    failed = 1; /* should not happen */
+
+  if (!setjmp (rec))
+    assert3 ();
+  else
+    failed = 1; /* should not happen */
+
+  rewind (stderr);
+  fgets (buf, 160, stderr);
+  if (!strstr (buf, "1 == 2"))
+    failed = 1;
+
+  fgets (buf, 160, stderr);
+  if (strstr (buf, "1 == 1"))
+    failed = 1;
+
+  fgets (buf, 160, stderr);
+  if (strstr (buf, "2 == 3"))
+    failed = 1;
+
+  return failed;
+}